]> granicus.if.org Git - flex/commitdiff
NetBSD downstream patches.
authorChristos Zoulas <christos@zoulas.com>
Fri, 31 Oct 2014 18:20:02 +0000 (14:20 -0400)
committerWill Estes <westes575@gmail.com>
Wed, 12 Nov 2014 02:09:36 +0000 (21:09 -0500)
  const fixes.

  -Wconversion fixes for the skeleton files.

  param namespace protection (add _ to inline function parameters).

  unused variable/code removal.

  rename warn to lwarn to avoid conflict with <err.h>.

  ctype.h function argument correction.

  merged the error functions lerrif and lerrsf -> lerr.

14 files changed:
src/buf.c
src/filter.c
src/flex.skl
src/flexdef.h
src/gen.c
src/libmain.c
src/libyywrap.c
src/main.c
src/misc.c
src/nfa.c
src/scan.l
src/scanflags.c
src/scanopt.c
src/yylex.c

index a9284ceeb6477fe47f8d38e5e4eb87aae5766551..fa713a69da98fc6666ef9f79a87a6b0cdd103450 100644 (file)
--- a/src/buf.c
+++ b/src/buf.c
@@ -91,7 +91,7 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s)
 struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
 {
     char *dst, *t;
-    const charsrc;
+    const char *src;
 
     t = flex_alloc (strlen ("#line \"\"\n")          +   /* constant parts */
                     2 * strlen (filename)            +   /* filename with possibly all backslashes escaped */
index c82f7f8938a183f600e38ede8e63b96701575945..79d2eb3bb7d9237dde03651c0ecdb06c16ad0824 100644 (file)
@@ -135,9 +135,6 @@ struct filter *filter_create_int (struct filter *chain,
 bool filter_apply_chain (struct filter * chain)
 {
        int     pid, pipes[2];
-       int     r;
-       const int readsz = 512;
-       char   *buf;
 
 
        /* Tricky recursion, since we want to begin the chain
@@ -189,7 +186,7 @@ clearerr(stdin);
                else {
                        execvp (chain->argv[0],
                                (char **const) (chain->argv));
-            lerrsf_fatal ( _("exec of %s failed"),
+            lerr_fatal ( _("exec of %s failed"),
                     chain->argv[0]);
                }
 
@@ -312,21 +309,21 @@ int filter_tee_header (struct filter *chain)
 
                fflush (to_h);
                if (ferror (to_h))
-                       lerrsf (_("error writing output file %s"),
+                       lerr (_("error writing output file %s"),
                                (char *) chain->extra);
 
                else if (fclose (to_h))
-                       lerrsf (_("error closing output file %s"),
+                       lerr (_("error closing output file %s"),
                                (char *) chain->extra);
        }
 
        fflush (to_c);
        if (ferror (to_c))
-               lerrsf (_("error writing output file %s"),
+               lerr (_("error writing output file %s"),
                        outfilename ? outfilename : "<stdout>");
 
        else if (fclose (to_c))
-               lerrsf (_("error closing output file %s"),
+               lerr (_("error closing output file %s"),
                        outfilename ? outfilename : "<stdout>");
 
        while (wait (0) > 0) ;
@@ -364,11 +361,10 @@ int filter_fix_linedirs (struct filter *chain)
                if (buf[0] == '#'
                        && regexec (&regex_linedir, buf, 3, m, 0) == 0) {
 
-                       int     num;
                        char   *fname;
 
                        /* extract the line number and filename */
-                       num = regmatch_strtol (&m[1], buf, NULL, 0);
+                       (void)regmatch_strtol (&m[1], buf, NULL, 0);
                        fname = regmatch_dup (&m[2], buf);
 
                        if (strcmp (fname,
@@ -431,11 +427,11 @@ int filter_fix_linedirs (struct filter *chain)
        }
        fflush (stdout);
        if (ferror (stdout))
-               lerrsf (_("error writing output file %s"),
+               lerr (_("error writing output file %s"),
                        outfilename ? outfilename : "<stdout>");
 
        else if (fclose (stdout))
-               lerrsf (_("error closing output file %s"),
+               lerr (_("error closing output file %s"),
                        outfilename ? outfilename : "<stdout>");
 
        return 0;
index 5188a5c2314cda7e4bf31d34b8e1bd405cef20d4..10b27e280bb9e7589fcefd72374691710c593d12 100644 (file)
@@ -755,6 +755,9 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
 static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
 static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state  M4_YY_PROTO_LAST_ARG);
 static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+#if defined(__GNUC__) && __GNUC__ >= 3
+__attribute__((__noreturn__))
+#endif
 static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG );
 ]])
 
@@ -951,7 +954,7 @@ FILE *yyget_in M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
 
 m4_ifdef( [[M4_YY_NO_SET_IN]],,
 [[
-void yyset_in  M4_YY_PARAMS( FILE * in_str M4_YY_PROTO_LAST_ARG );
+void yyset_in  M4_YY_PARAMS( FILE * _in_str M4_YY_PROTO_LAST_ARG );
 ]])
 
 m4_ifdef( [[M4_YY_NO_GET_OUT]],,
@@ -961,7 +964,7 @@ FILE *yyget_out M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
 
 m4_ifdef( [[M4_YY_NO_SET_OUT]],,
 [[
-void yyset_out  M4_YY_PARAMS( FILE * out_str M4_YY_PROTO_LAST_ARG );
+void yyset_out  M4_YY_PARAMS( FILE * _out_str M4_YY_PROTO_LAST_ARG );
 ]])
 
 m4_ifdef( [[M4_YY_NO_GET_LENG]],,
@@ -981,7 +984,7 @@ int yyget_lineno M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
 
 m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
 [[
-void yyset_lineno M4_YY_PARAMS( int line_number M4_YY_PROTO_LAST_ARG );
+void yyset_lineno M4_YY_PARAMS( int _line_number M4_YY_PROTO_LAST_ARG );
 ]])
 
 m4_ifdef( [[M4_YY_REENTRANT]],
@@ -996,7 +999,7 @@ m4_ifdef( [[M4_YY_REENTRANT]],
 [[
 m4_ifdef( [[M4_YY_NO_SET_COLUMN]],,
 [[
-void yyset_column M4_YY_PARAMS( int column_no M4_YY_PROTO_LAST_ARG );
+void yyset_column M4_YY_PARAMS( int _column_no M4_YY_PROTO_LAST_ARG );
 ]])
 ]])
 
@@ -1035,10 +1038,12 @@ extern int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
 #endif
 
 %not-for-header
+#ifndef YY_NO_UNPUT
     m4_ifdef( [[M4_YY_NO_UNPUT]],,
     [[
     static void yyunput M4_YY_PARAMS( int c, char *buf_ptr  M4_YY_PROTO_LAST_ARG);
     ]])
+#endif
 %ok-for-header
 %endif
 
@@ -1082,7 +1087,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
 [[
     m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
     [[
-    static void yy_push_state M4_YY_PARAMS( int new_state M4_YY_PROTO_LAST_ARG);
+    static void yy_push_state M4_YY_PARAMS( int _new_state M4_YY_PROTO_LAST_ARG);
     ]])
     m4_ifdef( [[M4_YY_NO_POP_STATE]],,
     [[
@@ -1138,7 +1143,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
 %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \
 \
 %if-c++-only C++ definition \
-       if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
+       if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \
                YY_FATAL_ERROR( "input in flex scanner failed" );
 %endif
 
@@ -1267,7 +1272,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
 [[
 /* Code executed at the end of each rule. */
 #ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
 #endif
 ]])
 
@@ -1356,7 +1361,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
        {
 %% [7.0] user's declarations go here
 
-       while ( 1 )             /* loops until end-of-file is reached */
+       while ( /*CONSTCOND*/1 )                /* loops until end-of-file is reached */
                {
 %% [8.0] yymore()-related code goes here
                yy_cp = YY_G(yy_c_buf_p);
@@ -1635,7 +1640,7 @@ int yyFlexLexer::yy_get_next_buffer()
     M4_YY_DECL_GUTS_VAR();
        char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
        char *source = YY_G(yytext_ptr);
-       int number_to_move, i;
+       yy_size_t number_to_move, i;
        int ret_val;
 
        if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] )
@@ -1664,7 +1669,7 @@ int yyFlexLexer::yy_get_next_buffer()
        /* Try to read more data. */
 
        /* First move last chars to start of buffer. */
-       number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
+       number_to_move = (yy_size_t) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
 
        for ( i = 0; i < number_to_move; ++i )
                *(dest++) = *(source++);
@@ -1817,6 +1822,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
 }
 
 
+#ifndef YY_NO_UNPUT
 %if-c-only
 m4_ifdef( [[M4_YY_NO_UNPUT]],,
 [[
@@ -1872,6 +1878,7 @@ m4_ifdef( [[M4_YY_USE_LINENO]],
 %if-c-only
 ]])
 %endif
+#endif
 
 %if-c-only
 #ifndef YY_NO_INPUT
@@ -2057,7 +2064,7 @@ static void yy_load_buffer_state  YYFARGS0(void)
        if ( ! b )
                YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
 
-       b->yy_buf_size = size;
+       b->yy_buf_size = (yy_size_t)size;
 
        /* yy_ch_buf has to be 2 characters longer than the size given because
         * we need to put in 2 end-of-buffer characters.
@@ -2290,7 +2297,7 @@ void yyFlexLexer::yyensure_buffer_stack(void)
        if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){
 
                /* Increase the buffer to prepare for a possible push. */
-               int grow_size = 8 /* arbitrary grow size */;
+               yy_size_t grow_size = 8 /* arbitrary grow size */;
 
                num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size;
                YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@@ -2420,10 +2427,10 @@ YY_BUFFER_STATE yy_scan_bytes  YYFARGS2( yyconst char *,yybytes, yy_size_t ,_yyb
 m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
 [[
 %if-c-only
-    static void yy_push_state YYFARGS1( int ,new_state)
+    static void yy_push_state YYFARGS1( int ,_new_state)
 %endif
 %if-c++-only
-    void yyFlexLexer::yy_push_state( int new_state )
+    void yyFlexLexer::yy_push_state( int _new_state )
 %endif
 {
     M4_YY_DECL_GUTS_VAR();
@@ -2447,7 +2454,7 @@ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
 
        YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
 
-       BEGIN(new_state);
+       BEGIN(_new_state);
 }
 ]])
 
@@ -2646,10 +2653,10 @@ void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined)
 m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
 [[
 /** Set the current line number.
- * @param line_number line number
+ * @param _line_number line number
  * M4_YY_DOC_PARAM
  */
-void yyset_lineno YYFARGS1( int ,line_number)
+void yyset_lineno YYFARGS1( int ,_line_number)
 {
     M4_YY_DECL_GUTS_VAR();
 
@@ -2659,7 +2666,7 @@ void yyset_lineno YYFARGS1( int ,line_number)
         if (! YY_CURRENT_BUFFER )
            YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
     ]])
-    yylineno = line_number;
+    yylineno = _line_number;
 }
 ]])
 
@@ -2668,10 +2675,10 @@ m4_ifdef( [[M4_YY_REENTRANT]],
 m4_ifdef( [[M4_YY_NO_SET_COLUMN]],,
 [[
 /** Set the current column.
- * @param column_no column number
+ * @param _column_no column number
  * M4_YY_DOC_PARAM
  */
-void yyset_column YYFARGS1( int , column_no)
+void yyset_column YYFARGS1( int , _column_no)
 {
     M4_YY_DECL_GUTS_VAR();
 
@@ -2681,7 +2688,7 @@ void yyset_column YYFARGS1( int , column_no)
         if (! YY_CURRENT_BUFFER )
            YY_FATAL_ERROR( "yyset_column called with no buffer" );
     ]])
-    yycolumn = column_no;
+    yycolumn = _column_no;
 }
 ]])
 ]])
@@ -2691,23 +2698,23 @@ m4_ifdef( [[M4_YY_NO_SET_IN]],,
 [[
 /** Set the input stream. This does not discard the current
  * input buffer.
- * @param in_str A readable stream.
+ * @param _in_str A readable stream.
  * M4_YY_DOC_PARAM
  * @see yy_switch_to_buffer
  */
-void yyset_in YYFARGS1( FILE * ,in_str)
+void yyset_in YYFARGS1( FILE * ,_in_str)
 {
     M4_YY_DECL_GUTS_VAR();
-    yyin = in_str ;
+    yyin = _in_str ;
 }
 ]])
 
 m4_ifdef( [[M4_YY_NO_SET_OUT]],,
 [[
-void yyset_out YYFARGS1( FILE * ,out_str)
+void yyset_out YYFARGS1( FILE * ,_out_str)
 {
     M4_YY_DECL_GUTS_VAR();
-    yyout = out_str ;
+    yyout = _out_str ;
 }
 ]])
 
@@ -2723,10 +2730,10 @@ int yyget_debug  YYFARGS0(void)
 
 m4_ifdef( [[M4_YY_NO_SET_DEBUG]],,
 [[
-void yyset_debug YYFARGS1( int ,bdebug)
+void yyset_debug YYFARGS1( int ,_bdebug)
 {
     M4_YY_DECL_GUTS_VAR();
-    yy_flex_debug = bdebug ;
+    yy_flex_debug = _bdebug ;
 }
 ]])
 %endif
index 15b344d35e2bd277ef871c13db19e7303b9f5ff5..496e34c7291b6783cbcc503bc1e208983a35d150 100644 (file)
@@ -40,7 +40,7 @@
 #endif
 
 /* AIX requires this to be the first thing in the file.  */
-#ifndef __GNUC__
+#if !defined(__GNUC__) && !defined(__lint__)
 # if HAVE_ALLOCA_H
 #  include <alloca.h>
 # else
@@ -903,14 +903,19 @@ extern void flexfatal PROTO ((const char *));
 /* Convert a hexadecimal digit string to an integer value. */
 extern int htoi PROTO ((Char[]));
 
-/* Report an error message formatted with one integer argument. */
-extern void lerrif PROTO ((const char *, ...));
-
-/* Report an error message formatted with one string argument. */
-extern void lerrsf PROTO ((const char *, ...));
+/* Report an error message formatted  */
+extern void lerr PROTO ((const char *, ...))
+#if defined(__GNUC__) && __GNUC__ >= 3
+    __attribute__((__format__(__printf__, 1, 2)))
+#endif
+;
 
-/* Like lerrsf, but also exit after displaying message. */
-extern void lerrsf_fatal PROTO ((const char *, ...));
+/* Like lerr, but also exit after displaying message. */
+extern void lerr_fatal PROTO ((const char *, ...))
+#if defined(__GNUC__) && __GNUC__ >= 3
+    __attribute__((__format__(__printf__, 1, 2)))
+#endif
+;
 
 /* Spit out a "#line" statement. */
 extern void line_directive_out PROTO ((FILE *, int));
index 68125d7fba143d0f23ba19287365c2f849c5de09..fc1c4a6de859e6365ebc7124535a84c2aacb3b07 100644 (file)
--- a/src/gen.c
+++ b/src/gen.c
@@ -77,9 +77,30 @@ static const char *get_state_decl (void)
                : "static yyconst yy_state_type * %s = 0;\n";
 }
 
+static const char *get_uint16_decl (void)
+{
+       return (gentables)
+               ? "static yyconst flex_uint16_t %s[%d] =\n    {   0,\n"
+               : "static yyconst flex_uint16_t * %s = 0;\n";
+}
+
+static const char *get_uint32_decl (void)
+{
+       return (gentables)
+               ? "static yyconst flex_uint32_t %s[%d] =\n    {   0,\n"
+               : "static yyconst flex_uint32_t * %s = 0;\n";
+}
+
+static const char *get_yy_char_decl (void)
+{
+       return (gentables)
+               ? "static yyconst YY_CHAR %s[%d] =\n    {   0,\n"
+               : "static yyconst YY_CHAR * %s = 0;\n";
+}
+
 /* Indent to the current level. */
 
-void do_indent ()
+void do_indent (void)
 {
        int i = indent_level * 8;
 
@@ -121,7 +142,7 @@ static struct yytbl_data *mkeoltbl (void)
 }
 
 /* Generate the table for possible eol matches. */
-static void geneoltbl ()
+static void geneoltbl (void)
 {
        int     i;
 
@@ -145,7 +166,7 @@ static void geneoltbl ()
 
 /* Generate the code to keep backing-up information. */
 
-void gen_backing_up ()
+void gen_backing_up (void)
 {
        if (reject || num_backing_up == 0)
                return;
@@ -166,7 +187,7 @@ void gen_backing_up ()
 
 /* Generate the code to perform the backing up. */
 
-void gen_bu_action ()
+void gen_bu_action (void)
 {
        if (reject || num_backing_up == 0)
                return;
@@ -330,7 +351,7 @@ static struct yytbl_data *mkssltbl (void)
 
 /* genctbl - generates full speed compressed transition table */
 
-void genctbl ()
+void genctbl (void)
 {
        int i;
        int     end_of_buffer_action = num_rules + 1;
@@ -453,19 +474,19 @@ struct yytbl_data *mkecstbl (void)
 
        buf_prints (&yydmap_buf,
                    "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n",
-                   "flex_int32_t");
+                   "YY_CHAR");
 
        return tbl;
 }
 
 /* Generate equivalence-class tables. */
 
-void genecs ()
+void genecs (void)
 {
        int i, j;
        int     numrows;
 
-       out_str_dec (get_int32_decl (), "yy_ec", csize);
+       out_str_dec (get_yy_char_decl (), "yy_ec", csize);
 
        for (i = 1; i < csize; ++i) {
                ecgroup[i] = ABS (ecgroup[i]);
@@ -495,7 +516,7 @@ void genecs ()
 
 /* Generate the code to find the action number. */
 
-void gen_find_action ()
+void gen_find_action (void)
 {
        if (fullspd)
                indent_puts ("yy_act = yy_current_state[-1].yy_nxt;");
@@ -507,7 +528,11 @@ void gen_find_action ()
                indent_puts ("yy_current_state = *--YY_G(yy_state_ptr);");
                indent_puts ("YY_G(yy_lp) = yy_accept[yy_current_state];");
 
+               if (!variable_trailing_context_rules)
+                       outn ("m4_ifdef( [[M4_YY_USES_REJECT]],\n[[");
                outn ("find_rule: /* we branch to this label when backing up */");
+               if (!variable_trailing_context_rules)
+                       outn ("]])\n");
 
                indent_puts
                        ("for ( ; ; ) /* until we find what rule we matched */");
@@ -672,7 +697,7 @@ struct yytbl_data *mkftbl (void)
 
 /* genftbl - generate full transition table */
 
-void genftbl ()
+void genftbl (void)
 {
        int i;
        int     end_of_buffer_action = num_rules + 1;
@@ -750,7 +775,7 @@ void gen_next_compressed_state (char_map)
 
 /* Generate the code to find the next match. */
 
-void gen_next_match ()
+void gen_next_match (void)
 {
        /* NOTE - changes in here should be reflected in gen_next_state() and
         * gen_NUL_trans().
@@ -927,7 +952,7 @@ void gen_next_state (worry_about_NULs)
 
 /* Generate the code to make a NUL transition. */
 
-void gen_NUL_trans ()
+void gen_NUL_trans (void)
 {                              /* NOTE - changes in here should be reflected in gen_next_match() */
        /* Only generate a definition for "yy_cp" if we'll generate code
         * that uses it.  Otherwise lint and the like complain.
@@ -1012,7 +1037,7 @@ void gen_NUL_trans ()
 
 /* Generate the code to find the start state. */
 
-void gen_start_state ()
+void gen_start_state (void)
 {
        if (fullspd) {
                if (bol_needed) {
@@ -1045,7 +1070,7 @@ void gen_start_state ()
 
 /* gentabs - generate data statements for the transition tables */
 
-void gentabs ()
+void gentabs (void)
 {
        int     i, j, k, *accset, nacc, *acc_array, total_states;
        int     end_of_buffer_action = num_rules + 1;
@@ -1271,10 +1296,10 @@ void gentabs ()
                        fputs (_("\n\nMeta-Equivalence Classes:\n"),
                               stderr);
 
-               out_str_dec (get_int32_decl (), "yy_meta", numecs + 1);
+               out_str_dec (get_yy_char_decl (), "yy_meta", numecs + 1);
                buf_prints (&yydmap_buf,
                            "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n",
-                           "flex_int32_t");
+                           "YY_CHAR");
 
                for (i = 1; i <= numecs; ++i) {
                        if (trace)
@@ -1301,13 +1326,13 @@ void gentabs ()
 
        /* Begin generating yy_base */
        out_str_dec ((tblend >= INT16_MAX || long_align) ?
-                    get_int32_decl () : get_int16_decl (),
+                    get_uint32_decl () : get_uint16_decl (),
                     "yy_base", total_states + 1);
 
        buf_prints (&yydmap_buf,
                    "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n",
                    (tblend >= INT16_MAX
-                    || long_align) ? "flex_int32_t" : "flex_int16_t");
+                    || long_align) ? "flex_uint32_t" : "flex_uint16_t");
        yybase_tbl =
                (struct yytbl_data *) calloc (1,
                                              sizeof (struct yytbl_data));
@@ -1394,13 +1419,13 @@ void gentabs ()
 
        /* Begin generating yy_nxt */
        out_str_dec ((total_states >= INT16_MAX || long_align) ?
-                    get_int32_decl () : get_int16_decl (), "yy_nxt",
+                    get_uint32_decl () : get_uint16_decl (), "yy_nxt",
                     tblend + 1);
 
        buf_prints (&yydmap_buf,
                    "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n",
                    (total_states >= INT16_MAX
-                    || long_align) ? "flex_int32_t" : "flex_int16_t");
+                    || long_align) ? "flex_uint32_t" : "flex_uint16_t");
 
        yynxt_tbl =
                (struct yytbl_data *) calloc (1,
@@ -1499,7 +1524,7 @@ void indent_puts (str)
 /* make_tables - generate transition tables and finishes generating output file
  */
 
-void make_tables ()
+void make_tables (void)
 {
        int i;
        int did_eof_rule = false;
index 49262e462bb03fba42053ecf9fbb5b0d0b7f728a..d4d5b6d851506a964c6a73c8bf15158cc82b5513 100644 (file)
 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
 /*  PURPOSE. */
 
-extern int yylex ();
+extern int yylex (void);
 
-int     main (argc, argv)
-     int     argc;
-     char   *argv[];
+int     main (int argc, char *argv[])
 {
-       while (yylex () != 0) ;
+       while (yylex () != 0)
+               continue;
 
        return 0;
 }
index 8561a43f4cdd328872537814a9d7695e31c42696..b0427c479733ed3f3b9bb7331da264bc3a6a5db8 100644 (file)
@@ -21,6 +21,8 @@
 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
 /*  PURPOSE. */
 
+int     yywrap (void);
+
 int     yywrap (void)
 {
        return 1;
index 8b9f3ed336bebf4b6c50f6aba728b3e976d516f0..8a70b8d5a69415cc0538a140ff5e493428cd5170 100644 (file)
@@ -118,13 +118,13 @@ struct yytbl_writer tableswr;
 char   *program_name = "flex";
 
 #ifndef SHORT_FILE_NAMES
-static char *outfile_template = "lex.%s.%s";
-static char *backing_name = "lex.backup";
-static char *tablesfile_template = "lex.%s.tables";
+static const char outfile_template[] = "lex.%s.%s";
+static const char backing_name[] = "lex.backup";
+static const char tablesfile_template[] = "lex.%s.tables";
 #else
-static char *outfile_template = "lex%s.%s";
-static char *backing_name = "lex.bck";
-static char *tablesfile_template = "lex%s.tbl";
+static const char outfile_template[] = "lex%s.%s";
+static const char backing_name[] = "lex.bck";
+static const char tablesfile_template[] = "lex%s.tbl";
 #endif
 
 #ifdef MS_DOS
@@ -355,7 +355,7 @@ void check_options ()
                prev_stdout = freopen (outfilename, "w+", stdout);
 
                if (prev_stdout == NULL)
-                       lerrsf (_("could not create %s"), outfilename);
+                       lerr (_("could not create %s"), outfilename);
 
                outfile_created = 1;
        }
@@ -401,7 +401,7 @@ void check_options ()
                }
 
                if ((tablesout = fopen (tablesfilename, "w")) == NULL)
-                       lerrsf (_("could not create %s"), tablesfilename);
+                       lerr (_("could not create %s"), tablesfilename);
                if (pname)
                        free (pname);
                tablesfilename = 0;
@@ -418,7 +418,7 @@ void check_options ()
        }
 
        if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
-               lerrsf (_("can't open skeleton file %s"), skelname);
+               lerr (_("can't open skeleton file %s"), skelname);
 
        if (reentrant) {
         buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
@@ -502,11 +502,11 @@ void flexend (exit_status)
 
        if (skelfile != NULL) {
                if (ferror (skelfile))
-                       lerrsf (_("input error reading skeleton file %s"),
+                       lerr (_("input error reading skeleton file %s"),
                                skelname);
 
                else if (fclose (skelfile))
-                       lerrsf (_("error closing skeleton file %s"),
+                       lerr (_("error closing skeleton file %s"),
                                skelname);
        }
 
@@ -691,7 +691,7 @@ void flexend (exit_status)
                fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix);
 
                if (ferror (header_out))
-                       lerrsf (_("error creating header file %s"),
+                       lerr (_("error creating header file %s"),
                                headerfilename);
                fflush (header_out);
                fclose (header_out);
@@ -699,15 +699,15 @@ void flexend (exit_status)
 
        if (exit_status != 0 && outfile_created) {
                if (ferror (stdout))
-                       lerrsf (_("error writing output file %s"),
+                       lerr (_("error writing output file %s"),
                                outfilename);
 
                else if ((_stdout_closed = 1) && fclose (stdout))
-                       lerrsf (_("error closing output file %s"),
+                       lerr (_("error closing output file %s"),
                                outfilename);
 
                else if (unlink (outfilename))
-                       lerrsf (_("error deleting output file %s"),
+                       lerr (_("error deleting output file %s"),
                                outfilename);
        }
 
@@ -725,11 +725,11 @@ void flexend (exit_status)
                                 _("Compressed tables always back up.\n"));
 
                if (ferror (backing_up_file))
-                       lerrsf (_("error writing backup file %s"),
+                       lerr (_("error writing backup file %s"),
                                backing_name);
 
                else if (fclose (backing_up_file))
-                       lerrsf (_("error closing backup file %s"),
+                       lerr (_("error closing backup file %s"),
                                backing_name);
        }
 
@@ -1059,9 +1059,9 @@ void flexinit (argc, argv)
                                        break;
 
                                default:
-                                       lerrif (_
+                                       lerr (_
                                                ("unknown -C option '%c'"),
-                                               (int) arg[i]);
+                                               arg[i]);
                                        break;
                                }
                        break;
@@ -1496,7 +1496,7 @@ void readin ()
        if (backing_up_report) {
                backing_up_file = fopen (backing_name, "w");
                if (backing_up_file == NULL)
-                       lerrsf (_
+                       lerr (_
                                ("could not create backing-up info file %s"),
                                backing_name);
        }
@@ -1579,9 +1579,9 @@ void readin ()
        if (!do_yywrap) {
                if (!C_plus_plus) {
                         if (reentrant)
-                               outn ("\n#define yywrap(yyscanner) 1");
+                               outn ("\n#define yywrap(yyscanner) (/*CONSTCOND*/1)");
                         else
-                               outn ("\n#define yywrap() 1");
+                               outn ("\n#define yywrap() (/*CONSTCOND*/1)");
                }
                outn ("#define YY_SKIP_YYWRAP");
        }
index 0632d3e28d9f75f73a2d7945ce5ed0bb5810bf31..dfb6981548c728352dacd6c5f519e2619c50fb64 100644 (file)
@@ -113,11 +113,12 @@ void action_define (defname, value)
 }
 
 
+#ifdef notdef
 /** Append "m4_define([[defname]],[[value]])m4_dnl\n" to the running buffer.
  *  @param defname The macro name.
  *  @param value The macro value, can be NULL, which is the same as the empty string.
  */
-void action_m4_define (const char *defname, const char * value)
+static void action_m4_define (const char *defname, const char * value)
 {
        char    buf[MAXLINE];
 
@@ -133,6 +134,7 @@ void action_m4_define (const char *defname, const char * value)
        snprintf (buf, sizeof(buf), "m4_define([[%s]],[[%s]])m4_dnl\n", defname, value?value:"");
        add_action (buf);
 }
+#endif
 
 /* Append "new_text" to the running buffer. */
 void add_action (new_text)
@@ -227,11 +229,11 @@ void check_char (c)
      int c;
 {
        if (c >= CSIZE)
-               lerrsf (_("bad character '%s' detected in check_char()"),
+               lerr (_("bad character '%s' detected in check_char()"),
                        readable_form (c));
 
        if (c >= csize)
-               lerrsf (_
+               lerr (_
                        ("scanner requires -8 flag to use the character %s"),
                        readable_form (c));
 }
@@ -383,9 +385,9 @@ int htoi (str)
 }
 
 
-/* lerrif - report an error message formatted with one integer argument */
+/* lerr - report an error message */
 
-void lerrif (const char *msg, ...) {
+void lerr (const char *msg, ...) {
        char    errmsg[MAXLINE];
        va_list args;
 
@@ -396,32 +398,16 @@ void lerrif (const char *msg, ...) {
 }
 
 
-/* lerrsf - report an error message formatted with one string argument */
+/* lerr_fatal - as lerr, but call flexfatal */
 
-void lerrsf (const char *msg, ...)
+void lerr_fatal (const char *msg, ...)
 {
        char    errmsg[MAXLINE];
        va_list args;
-
        va_start(args, msg);
-       vsnprintf (errmsg, sizeof(errmsg)-1, msg, args);
-       va_end(args);
-       errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
-       flexerror (errmsg);
-}
-
-
-/* lerrsf_fatal - as lerrsf, but call flexfatal */
 
-void lerrsf_fatal (const char *msg, ...)
-{
-       char    errmsg[MAXLINE];
-       va_list args;
-       va_start(args, msg);
-
-       vsnprintf (errmsg, sizeof(errmsg)-1, msg, args);
+       vsnprintf (errmsg, sizeof(errmsg), msg, args);
        va_end(args);
-       errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */
        flexfatal (errmsg);
 }
 
index e0c5d0580bfe104a6e02181221d06f9190ed875e..ee06578876bc73ff3aff51d8431fcb702000fb18 100644 (file)
--- a/src/nfa.c
+++ b/src/nfa.c
@@ -605,7 +605,7 @@ int     mkstate (sym)
 {
        if (++lastnfa >= current_mns) {
                if ((current_mns += MNS_INCREMENT) >= maximum_mns)
-                       lerrif (_
+                       lerr(_
                                ("input rules are too complicated (>= %d NFA states)"),
 current_mns);
 
@@ -711,7 +711,7 @@ void    new_rule ()
        }
 
        if (num_rules > MAX_RULE)
-               lerrif (_("too many rules (> %d)!"), MAX_RULE);
+               lerr (_("too many rules (> %d)!"), MAX_RULE);
 
        rule_linenum[num_rules] = linenum;
        rule_useful[num_rules] = false;
index 5a15400b8373a2363862df06217092e1d588b2ee..9ff9d74f1cca85027edf97d23abf60c06ac4d548 100644 (file)
@@ -993,7 +993,7 @@ char *file;
                yyin = fopen( infilename, "r" );
 
                if ( yyin == NULL )
-                       lerrsf( _( "can't open %s" ), file );
+                       lerr( _( "can't open %s" ), file );
                }
 
        else
index c61d47fc93a25b7d53a67a7427e89ef693cb8b4f..5beb24ac3eb9afb35ea9ac2382bb75cbd60906e7 100644 (file)
@@ -61,7 +61,7 @@ sf_init (void)
     assert(_sf_stk == NULL);
     _sf_stk = (scanflags_t*) flex_alloc ( sizeof(scanflags_t) * (_sf_max = 32));
     if (!_sf_stk)
-        lerrsf_fatal(_("Unable to allocate %ld of stack"), sizeof(scanflags_t));
+        lerr_fatal(_("Unable to allocate %zu of stack"), sizeof(scanflags_t));
     _sf_stk[_sf_top_ix] = 0;
 }
 
index f76ecd34dac07b9cc6d0682f2bfa1ca75c8ef664..6d8d481f7eb88b47f187101642ba1f3cb87c2a62 100644 (file)
@@ -46,7 +46,7 @@ static int STRCASECMP (a, b)
      const char *a;
      const char *b;
 {
-       while (tolower (*a++) == tolower (*b++)) ;
+       while (tolower ((unsigned char)*a++) == tolower ((unsigned char)*b++)) ;
        return b - a;
 }
 #endif
@@ -212,7 +212,7 @@ scanopt_t *scanopt_init (options, argc, argv, flags)
                aux->namelen = 0;
                for (p = pname + 1; *p; p++) {
                        /* detect required arg */
-                       if (*p == '=' || isspace (*p)
+                       if (*p == '=' || isspace ((unsigned char)*p)
                            || !(aux->flags & IS_LONG)) {
                                if (aux->namelen == 0)
                                        aux->namelen = p - pname;
@@ -481,7 +481,7 @@ int     scanopt_usage (scanner, fp, usage)
 
                                        while (*p && n < maxlen[1]
                                               && *p != '\n') {
-                                               if (isspace ((Char)(*p))
+                                               if (isspace ((unsigned char)(*p))
                                                    || *p == '-') lastws =
                                                                p;
                                                n++;
@@ -537,10 +537,6 @@ static int scanopt_err (s, opt_offset, is_short, err)
 {
        const char *optname = "";
        char    optchar[2];
-       const optspec_t *opt = NULL;
-
-       if (opt_offset >= 0)
-               opt = s->options + opt_offset;
 
        if (!s->no_err_msg) {
 
index 73d371f0a381a150d80da95f3c43d61bc73f51bf..17b3e61b19eb96ee689f3c21a044793713aa1c66 100644 (file)
 
 /* yylex - scan for a regular expression token */
 
-int     yylex ()
+extern char *yytext;
+int     yylex (void)
 {
        int     toktype;
        static int beglin = false;
-       extern char *yytext;
 
        if (eofseen)
                toktype = EOF;