yylex_init now reports errors.
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
return 0;
}
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 */
@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
@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.
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();