Steve Singer,,, ssinger at lists.slony.info
Thu May 27 13:38:35 PDT 2010
Update of /home/cvsd/slony1/slony1-engine/src/slony_logshipper
In directory main.slony.info:/tmp/cvs-serv2814/src/slony_logshipper

Modified Files:
      Tag: REL_2_0_STABLE
	Makefile parser.y scan.l 
Log Message:
Remove direct uses of yyleng and instead use the function yyget_leng()
More recent versions of flex have changed yyleng from an int to a size_t.
By using the function we will let the compiler do the conversion if required
on the function result.
    
We also add an explicit object for scan.o instead of including it at the
bottom of parser.y because we need to generate and include a header for
the scanner (scan.h) so we have the explicit(and correct) definitions of
the yyyget_leng() function.

A autoconf check to ensure that a version of flex with yyget_leng() is 
available has also been added.


Index: parser.y
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slony_logshipper/parser.y,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C 2 -d -r1.3.2.1 -r1.3.2.2
*** parser.y	17 Aug 2009 17:09:59 -0000	1.3.2.1
--- parser.y	27 May 2010 20:38:32 -0000	1.3.2.2
***************
*** 1,5 ****
  %{
! /*-------------------------------------------------------------------------
!  * parser.y
   *
   *	The slony_logshipper command language grammar
--- 1,4 ----
  %{
! /*
   *
   *	The slony_logshipper command language grammar
***************
*** 12,19 ****
--- 11,22 ----
   */
  
+ #include "config.h"
  #include "postgres.h"
  #include "libpq-fe.h"
  #include "slony_logshipper.h"
  #include "../parsestatements/scanner.h"
+ 
+ #include "scan.h"
+ 
  extern int STMTS[MAXSTATEMENTS];
  
***************
*** 23,27 ****
   */
  char   *current_file = "<stdin>";
- extern int yyleng;
  #ifdef DEBUG
  int yydebug=1;
--- 26,29 ----
***************
*** 370,377 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 372,379 ----
  					{
  						char   *ret;
! 						size_t toklen=yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 823,830 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 825,832 ----
  					{
  						char   *ret;
! 						size_t toklen = yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 853,860 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 855,862 ----
  					{
  						char   *ret;
! 						size_t toklen= yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 884,891 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 886,893 ----
  					{
  						char   *ret;
! 						size_t toklen = yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 948,955 ****
  					{
  						char   *str;
! 
! 						str = malloc(yyleng + 1);
! 						memcpy(str, yytext, yyleng);
! 						str[yyleng] = '\0';
  
  						if (process_simple_sql(str) < 0)
--- 950,957 ----
  					{
  						char   *str;
! 						size_t toklen = yyget_leng();
! 						str = malloc(toklen + 1);
! 						memcpy(str, yytext, toklen);
! 						str[toklen] = '\0';
  
  						if (process_simple_sql(str) < 0)
***************
*** 972,979 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 974,981 ----
  					{
  						char   *ret;
! 						size_t toklen = yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 982,989 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 984,991 ----
  					{
  						char   *ret;
! 						size_t toklen = yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 1096,1104 ****
  
  
- /*
-  * Include the output of fles for the scanner here.
-  */
- #include "scan.c"
- 
  
  
--- 1098,1101 ----

Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slony_logshipper/Makefile,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C 2 -d -r1.2.2.1 -r1.2.2.2
*** Makefile	17 Aug 2009 17:09:59 -0000	1.2.2.1
--- Makefile	27 May 2010 20:38:32 -0000	1.2.2.2
***************
*** 36,40 ****
  	ipcutil.o					\
  	parser.o $(WIN32RES)		\
! 	../parsestatements/scanner.o
  
  DISTFILES = Makefile $(wildcard *.c) $(wildcard *.h) $(wildcard *.l) $(wildcard *.y)
--- 36,41 ----
  	ipcutil.o					\
  	parser.o $(WIN32RES)		\
! 	../parsestatements/scanner.o \
! 	scan.o
  
  DISTFILES = Makefile $(wildcard *.c) $(wildcard *.h) $(wildcard *.l) $(wildcard *.y)
***************
*** 51,55 ****
  dbutil.o:			dbutil.c slony_logshipper.h
  parser.o:			parser.c scan.c
- 
  parser.c:			parser.y slony_logshipper.h
  ifdef YACC
--- 52,55 ----
***************
*** 61,67 ****
  endif
  
  scan.c:				scan.l slony_logshipper.h
  ifdef FLEX 
! 	$(FLEX) $(FLEXFLAGS) -o'$@' $<
  else
  	@echo "Missing flex $< $@"
--- 61,68 ----
  endif
  
+ scan.c:	SCANNER_HEADER=scan.h
  scan.c:				scan.l slony_logshipper.h
  ifdef FLEX 
! 	$(FLEX) $(FLEXFLAGS) --header-file=$(SCANNER_HEADER)  -o'$@' $<
  else
  	@echo "Missing flex $< $@"

Index: scan.l
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slony_logshipper/scan.l,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C 2 -d -r1.3.2.2 -r1.3.2.3
*** scan.l	17 Aug 2009 17:09:59 -0000	1.3.2.2
--- scan.l	27 May 2010 20:38:32 -0000	1.3.2.3
***************
*** 53,56 ****
--- 53,66 ----
  %}
  
+ 
+ %{
+ #include "config.h"
+ #include "postgres.h"
+ #include "libpq-fe.h"
+ #include "slony_logshipper.h"
+ #include "y.tab.h"
+ 
+ %}
+ 
  %option 8bit
  %option noyywrap



More information about the Slony1-commit mailing list