]> granicus.if.org Git - flex/commitdiff
Fixed type mismatch in printf.
authorJohn Millaway <john43@users.sourceforge.net>
Mon, 12 Aug 2002 19:36:58 +0000 (19:36 +0000)
committerJohn Millaway <john43@users.sourceforge.net>
Mon, 12 Aug 2002 19:36:58 +0000 (19:36 +0000)
yylex_init now reports errors.

flex.skl
flex.texi
gen.c

index b34572fe743195580cb8412e8ea42e6ba1345cf0..668aec39c0c0fa84463e6de8d137f32997abf1d1 100644 (file)
--- 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 */
index 798f8590ee499f8f9d833833ecd5c9e1454e6372..8559355885feadcb1d766e1d8f5ac6c2b85fbb32 100644 (file)
--- 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 31fa50ed5d834d79505fb42fd49e01ec959cc516..ef03f99039f7f9a5d21bbf14112061de5804205d 100644 (file)
--- 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();