From: Daniel Ottavio Date: Tue, 9 Aug 2005 03:28:00 +0000 (+0000) Subject: * amd/sun_map_tok.l: Applied some definition goop to handle the X-Git-Tag: before-clocktime-fixes~41 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=789d8ae68a8faaf7afb8af2db316af8569093f92;p=am-utils-6.1.git * amd/sun_map_tok.l: Applied some definition goop to handle the ECHO symbol that lex defines. This symbol causes problems on RedHat-EL-powerPC platforms. Replaced strncpy with strlcpy. Renamed the function sun_map_yyinput to sun_map_input. This function is a utility function that is not generated by lex. Therefore, the 'yy' may cause confusion. LocalWords: Erez --- diff --git a/ChangeLog b/ChangeLog index ff7d06a..6f79441 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-08-08 Daniel P. Ottavio + + * amd/sun_map_tok.l: Applied some definition goop to handle the + ECHO symbol that lex defines. This symbol causes problems on + RedHat-EL-powerPC platforms. Replaced strncpy with strlcpy. + Renamed the function sun_map_yyinput to sun_map_input. This + function is a utility function that is not generated by lex. + Therefore, the 'yy' may cause confusion. + 2005-08-08 Erez Zadok * amd/sun_map_tok.l: allocate more output slots so lex scanners @@ -11455,3 +11464,5 @@ Wed Dec 10 22:19:29 1996 Erez "HWank1" Zadok ******************************************************************* *** Initial ChangeLog Entry *** ******************************************************************* + LocalWords: Erez + \ No newline at end of file diff --git a/amd/sun_map_tok.l b/amd/sun_map_tok.l index f078485..bfc2eaa 100644 --- a/amd/sun_map_tok.l +++ b/amd/sun_map_tok.l @@ -47,9 +47,34 @@ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ +/* + * Some systems include a definition for the macro ECHO in , + * and their (bad) version of lex defines it too at the very beginning of + * the generated lex.yy.c file (before it can be easily undefined), + * resulting in a conflict. So undefine it here before needed. + * Luckily, it does not appear that this macro is actually used in the rest + * of the generated lex.yy.c file. + */ +#ifdef ECHO +# undef ECHO +#endif /* ECHO */ #include #include #include +/* and once again undefine this, just in case */ +#ifdef ECHO +# undef ECHO +#endif /* ECHO */ + +/* + * There are some things that need to be defined only if using GNU flex. + * These must not be defined if using standard lex + */ +#ifdef FLEX_SCANNER +# ifndef ECHO +# define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +# endif /* not ECHO */ +#endif /* FLEX_SCANNER */ /* * We need to configure lex to parse from a string @@ -71,14 +96,27 @@ const char *sun_map_tok_pos = NULL; const char *sun_map_tok_end = NULL; /* copies the current position + maxsize into buff */ -int sun_map_yyinput(char *buff, int maxsize); +int sun_map_input(char *buff, int maxsize); # undef YY_INPUT -# define YY_INPUT(buff,result,maxsize) (result = sun_map_yyinput(buff,maxsize)) +# define YY_INPUT(buff,result,maxsize) (result = sun_map_input(buff,maxsize)) #else /* not FLEX_SCANNER */ # warning "Currently flex is the only supported version of lex." -#endif /* not FLEX_SCANNER */ +#endif /* FLEX_SCANNER */ + +/* + * some systems such as DU-4.x have a different GNU flex in /usr/bin + * which automatically generates yywrap macros and symbols. So I must + * distinguish between them and when yywrap is actually needed. + */ +#ifndef yywrap +int yywrap(void); +#endif /* not yywrap */ + +/* no need to use yywrap() */ +#define YY_SKIP_YYWRAP + int sun_map_line = 1; int sun_map_tokpos = 1; @@ -104,8 +142,7 @@ CONTINUE_REX "\\"\n {WORD_REX} { sun_map_tokpos += yyleng; - strncpy(yylval.strval,yytext,sizeof(yylval.strval)); - yylval.strval[sizeof(yylval.strval) - 1] = '\0'; + xstrlcpy(yylval.strval,yytext,sizeof(yylval.strval)); return WORD; } @@ -137,21 +174,13 @@ CONTINUE_REX "\\"\n int -sun_map_error(const char* s) +yyerror(const char* s) { plog(XLOG_ERROR,"sun2amd : parsing error : line %d, column %d\n", sun_map_line,sun_map_tokpos); return 1; } - -int -sun_map_wrap(void) -{ - return 1; -} - - #ifdef FLEX_SCANNER void sun_map_tok_setbuff(const char* buff) @@ -163,7 +192,7 @@ sun_map_tok_setbuff(const char* buff) int -sun_map_yyinput(char *buff, int maxsize) +sun_map_input(char *buff, int maxsize) { int size = MIN(maxsize, (sun_map_tok_end - sun_map_tok_pos)); if (size > 0) { @@ -174,3 +203,15 @@ sun_map_yyinput(char *buff, int maxsize) return size; } #endif /* FLEX_SCANNER */ + +/* + * some systems such as DU-4.x have a different GNU flex in /usr/bin + * which automatically generates yywrap macros and symbols. So I must + * distinguish between them and when yywrap is actually needed. + */ +#ifndef yywrap +int yywrap(void) +{ + return 1; +} +#endif /* not yywrap */