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

Modified Files:
      Tag: REL_2_0_STABLE
	Makefile parser.y scan.l slonik.h 
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: slonik.h
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/slonik.h,v
retrieving revision 1.34.2.2
retrieving revision 1.34.2.3
diff -C 2 -d -r1.34.2.2 -r1.34.2.3
*** slonik.h	17 Aug 2009 17:09:59 -0000	1.34.2.2
--- slonik.h	27 May 2010 20:38:32 -0000	1.34.2.3
***************
*** 616,619 ****
--- 616,671 ----
  
  
+ 
+ /*
+  * Common option types
+  */
+ typedef enum {
+ 	O_ADD_ID,
+ 	O_BACKUP_NODE,
+ 	O_CLIENT,
+ 	O_COMMENT,
+ 	O_CONNINFO,
+ 	O_CONNRETRY,
+ 	O_EVENT_NODE,
+ 	O_EXECUTE_ONLY_ON,
+ 	O_FILENAME,
+ 	O_FORWARD,
+ 	O_FQNAME,
+ 	O_ID,
+ 	O_NEW_ORIGIN,
+ 	O_NEW_SET,
+ 	O_NODE_ID,
+ 	O_OLD_ORIGIN,
+ 	O_OMIT_COPY,
+ 	O_ORIGIN,
+ 	O_PROVIDER,
+ 	O_RECEIVER,
+ 	O_SECONDS,
+ 	O_SERVER,
+ 	O_SET_ID,
+ 	O_TAB_ID,
+ 	O_TIMEOUT,
+ 	O_USE_KEY,
+ 	O_WAIT_CONFIRMED,
+ 	O_WAIT_ON,
+ 
+ 	END_OF_OPTIONS = -1
+ } option_code;
+ 
+ 
+ 
+ 
+ /*
+  * Common given option list
+  */
+ typedef struct option_list {
+ 	option_code	opt_code;
+ 	int			lineno;
+ 	int32		ival;
+ 	char	   *str;
+ 
+ 	struct option_list *next;
+ } option_list;
+ 
  /*
   * Local Variables:

Index: parser.y
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/parser.y,v
retrieving revision 1.32.2.2
retrieving revision 1.32.2.3
diff -C 2 -d -r1.32.2.2 -r1.32.2.3
*** parser.y	17 Aug 2009 17:09:59 -0000	1.32.2.2
--- parser.y	27 May 2010 20:38:32 -0000	1.32.2.3
***************
*** 15,68 ****
  #include "libpq-fe.h"
  #include "slonik.h"
! 
! 
! /*
!  * Common option types
!  */
! typedef enum {
! 	O_ADD_ID,
! 	O_BACKUP_NODE,
! 	O_CLIENT,
! 	O_COMMENT,
! 	O_CONNINFO,
! 	O_CONNRETRY,
! 	O_EVENT_NODE,
! 	O_EXECUTE_ONLY_ON,
! 	O_FILENAME,
! 	O_FORWARD,
! 	O_FQNAME,
! 	O_ID,
! 	O_NEW_ORIGIN,
! 	O_NEW_SET,
! 	O_NODE_ID,
! 	O_OLD_ORIGIN,
! 	O_OMIT_COPY,
! 	O_ORIGIN,
! 	O_PROVIDER,
! 	O_RECEIVER,
! 	O_SECONDS,
! 	O_SERVER,
! 	O_SET_ID,
! 	O_TAB_ID,
! 	O_TIMEOUT,
! 	O_USE_KEY,
! 	O_WAIT_CONFIRMED,
! 	O_WAIT_ON,
! 
! 	END_OF_OPTIONS = -1
! } option_code;
! 
! 
! /*
!  * Common given option list
!  */
! typedef struct option_list {
! 	option_code	opt_code;
! 	int			lineno;
! 	int32		ival;
! 	char	   *str;
! 
! 	struct option_list *next;
! } option_list;
  
  
--- 15,19 ----
  #include "libpq-fe.h"
  #include "slonik.h"
! #include "scan.h"
  
  
***************
*** 86,90 ****
   */
  char   *current_file = "<stdin>";
- extern int yyleng;
  #ifdef DEBUG
  int yydebug=1;
--- 37,40 ----
***************
*** 1755,1762 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 1705,1712 ----
  					{
  						char   *ret;
! 						size_t toklen=yyget_leng();
! 						ret = malloc(yyget_leng() + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 1767,1774 ****
  					{
  						char   *ret;
! 
! 						ret = malloc(yyleng + 1);
! 						memcpy(ret, yytext, yyleng);
! 						ret[yyleng] = '\0';
  
  						$$ = ret;
--- 1717,1724 ----
  					{
  						char   *ret;
! 						size_t toklen=yyget_leng();
! 						ret = malloc(toklen + 1);
! 						memcpy(ret, yytext, toklen);
! 						ret[toklen] = '\0';
  
  						$$ = ret;
***************
*** 1885,1892 ****
  
  
- /*
-  * Include the output of fles for the scanner here.
-  */
- #include "scan.c"
  
  
--- 1835,1838 ----

Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slonik/Makefile,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -C 2 -d -r1.28.2.1 -r1.28.2.2
*** Makefile	17 Aug 2009 17:09:59 -0000	1.28.2.1
--- Makefile	27 May 2010 20:38:32 -0000	1.28.2.2
***************
*** 33,38 ****
  	dbutil.o			\
  	parser.o $(WIN32RES)            \
! 	../parsestatements/scanner.o
! 
  DISTFILES = Makefile $(wildcard *.c) $(wildcard *.h) $(wildcard *.l) $(wildcard *.y)
  
--- 33,38 ----
  	dbutil.o			\
  	parser.o $(WIN32RES)            \
! 	../parsestatements/scanner.o    \
! 	scan.o
  DISTFILES = Makefile $(wildcard *.c) $(wildcard *.h) $(wildcard *.l) $(wildcard *.y)
  
***************
*** 58,64 ****
  endif
  
  scan.c:				scan.l slonik.h
  ifdef FLEX 
! 	$(FLEX) $(FLEXFLAGS) -o'$@' $<
  else
  	@echo "Missing flex $< $@"
--- 58,66 ----
  endif
  
+ scan.c: SCANNER_HEADER=scan.h
+ 
  scan.c:				scan.l slonik.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/slonik/scan.l,v
retrieving revision 1.30.2.2
retrieving revision 1.30.2.3
diff -C 2 -d -r1.30.2.2 -r1.30.2.3
*** scan.l	17 Aug 2009 17:09:59 -0000	1.30.2.2
--- scan.l	27 May 2010 20:38:32 -0000	1.30.2.3
***************
*** 37,40 ****
--- 37,48 ----
  %}
  
+ %{
+ 
+ #include "postgres.h"
+ #include "libpq-fe.h"
+ #include "slonik.h"
+ #include "y.tab.h"
+ %}
+ 
  %option 8bit
  %option nounput



More information about the Slony1-commit mailing list