summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flex.skl17
-rw-r--r--flex.texi13
-rw-r--r--gen.c4
3 files changed, 29 insertions, 5 deletions
diff --git a/flex.skl b/flex.skl
index b34572f..668aec3 100644
--- a/flex.skl
+++ b/flex.skl
@@ -1903,6 +1903,10 @@ static int yy_init_globals YYFARGS0(void)
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
return 0;
}
@@ -1919,9 +1923,18 @@ int yylex_init( ptr_yy_globals )
yyscan_t* ptr_yy_globals;
#endif
{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
- yy_init_globals ( *ptr_yy_globals );
- return 0;
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ return yy_init_globals ( *ptr_yy_globals );
}
#endif /* End YY_REENTRANT */
diff --git a/flex.texi b/flex.texi
index 798f859..8559355 100644
--- a/flex.texi
+++ b/flex.texi
@@ -3754,6 +3754,17 @@ takes one argument, which is the value returned (via an argument) by
@code{yylex_init}. Otherwise, it behaves the same as the non-reentrant
version of @code{yylex}.
+@code{yylex_init} returns 0 (zero) on success, or non-zero on failure,
+in which case, errno is set to one of the following values:
+
+@itemize
+@item ENOMEM
+Memory allocation error. @xref{memory-management}.
+@item EINVAL
+Invalid argument.
+@end itemize
+
+
The function @code{yylex_destroy} should be
called to free resources used by the scanner. After @code{yylex_destroy}
is called, the contents of @code{yyscanner} should not be used. Of
@@ -4340,7 +4351,7 @@ in braces are simply terminated at the end of the line.
@chapter Memory Management
@cindex memory management
-
+@anchor{memory-management}
This chapter describes how flex handles dynamic memory, and how you can
override the default behavior.
diff --git a/gen.c b/gen.c
index 31fa50e..ef03f99 100644
--- a/gen.c
+++ b/gen.c
@@ -1516,10 +1516,10 @@ void make_tables()
else
{
indent_puts(
- "fprintf( stderr, \"--accepting rule at line %d (\\\"%s\\\")\\n\"," );
+ "fprintf( stderr, \"--accepting rule at line %ld (\\\"%s\\\")\\n\"," );
indent_puts(
- " yy_rule_linenum[yy_act], yytext );" );
+ " (long)yy_rule_linenum[yy_act], yytext );" );
}
indent_down();