]> granicus.if.org Git - nethack/commitdiff
{dgn,lev}_lex.c - suppress yyunput() complaint
authorPatR <rankin@nethack.org>
Tue, 27 Mar 2018 23:34:47 +0000 (16:34 -0700)
committerPatR <rankin@nethack.org>
Tue, 27 Mar 2018 23:34:47 +0000 (16:34 -0700)
When dgn_comp.l and lev_comp.l are processed by older versions of
flex, 'gcc -Wunused' complains when compiling dgn_lex.c and lev_lex.c
because flex creates 'static void yyunput()' and nethack doesn't use
it.  Newer versions honor macro YY_NO_UNPUT to hide the offending
code, but that doesn't help with older versions (like the one
masquerading as 'lex' on OSX).  Adding a dummy usage would probably
cause problems with other lexers, so change it from static to
'void yyunput()' as a 'sed' fixup in util/Makefile after flex has
finished.  That will be a no-op when yyunput doesn't exist or isn't
static.

In addition to the sys/unix/Makefile.utl change, this checks in new
sys/share/{dgn,lev}_lex.c with the fixup in place.

sys/share/dgn_lex.c
sys/share/lev_lex.c
sys/unix/Makefile.utl

index 9ca4a445dd70a4a327f4149dcf353960621ad7e7..752fcd55a8f5a4c10b7c7b906b82b940dbf4e78e 100644 (file)
@@ -503,7 +503,7 @@ int yy_flex_debug = 0;
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
-/* NetHack 3.6  dgn_comp.l     $NHDT-Date: 1455415233 2016/02/14 02:00:33 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.19 $ */
+/* NetHack 3.6  dgn_comp.l     $NHDT-Date: 1522193682 2018/03/27 23:34:42 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /*     Copyright (c) 1990 by M. Stephenson          */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -617,7 +617,7 @@ extern int yywrap FDECL(FDECL_dummy, (void ));
 
 #ifndef YY_NO_UNPUT
 
-static void yyunput FDECL(FDECL_dummy, (int c,char *buf_ptr  ));
+void yyunput FDECL(FDECL_dummy, (int c,char *buf_ptr  ));
 #endif
 
 #ifndef yytext_ptr
@@ -1282,7 +1282,7 @@ static yy_state_type yy_try_NUL_trans (yy_current_state )
 
 #ifndef YY_NO_UNPUT
 
-static void yyunput (c,yy_bp )
+void yyunput (c,yy_bp )
         int c;
         char * yy_bp;
 {
index ffaf0ae3ed9cdaa89a8839a7f8e25d35b671482f..02a754e3d9e10eb82d9d767326abf4c473db0bcd 100644 (file)
@@ -1024,7 +1024,7 @@ int yy_flex_debug = 0;
 #define YY_MORE_ADJ 0
 #define YY_RESTORE_YY_MORE_OFFSET
 char *yytext;
-/* NetHack 3.6  lev_comp.l     $NHDT-Date: 1455415237 2016/02/14 02:00:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.27 $ */
+/* NetHack 3.6  lev_comp.l     $NHDT-Date: 1522193683 2018/03/27 23:34:43 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.28 $ */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1161,7 +1161,7 @@ extern int yywrap FDECL(FDECL_dummy, (void ));
 
 #ifndef YY_NO_UNPUT
 
-static void yyunput FDECL(FDECL_dummy, (int c,char *buf_ptr  ));
+void yyunput FDECL(FDECL_dummy, (int c,char *buf_ptr  ));
 #endif
 
 #ifndef yytext_ptr
@@ -2525,7 +2525,7 @@ static yy_state_type yy_try_NUL_trans (yy_current_state )
 
 #ifndef YY_NO_UNPUT
 
-static void yyunput (c,yy_bp )
+void yyunput (c,yy_bp )
         int c;
         char * yy_bp;
 {
index ca7124a4056700de85fdc44fb24f67f0df13486c..6dba4e97c7f04a2d281cc3ab28c15cdc34477e30 100644 (file)
@@ -1,5 +1,5 @@
 #      Makefile for NetHack's utility programs.
-# NetHack 3.6  Makefile.utl    $NHDT-Date: 1454712070 2016/02/05 22:41:10 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.29 $
+# NetHack 3.6  Makefile.utl    $NHDT-Date: 1522193681 2018/03/27 23:34:41 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.34 $
 
 # Root of source tree:
 NHSROOT=..
@@ -271,12 +271,18 @@ lev_yacc.c: lev_comp.y
 
 lev_lex.c: lev_comp.l
        $(LEX) $(FLEXDIST) lev_comp.l
-       sed -e 's#"$(LEXYYC)"#"$@"#' -e 's#  *$$##' $(LEXYYC) > $@ \
+       sed -e 's#"$(LEXYYC)"#"$@"#' -e 's#  *$$##' \
+           -e 's#static void yyunput#void yyunput#' $(LEXYYC) > $@ \
                && rm $(LEXYYC)
 #      note: flex code construction using m4 macros results in some trailing
 #      spaces; <space><space><star> is basic RE substitute for <space><plus>
 #      and we don't bother stripping trailing tabs because that gets messy;
 #      make expands <dollar><dollar> into <dollar> which is RE end-of-line.
+#      flex also creates yyunput() as a static routine, but lev_comp doesn't
+#      use it so compiler complaints can ensue; recent flex versions honor
+#      NO_YY_UNPUT to suppress it, but older ones don't; making it global to
+#      avoid an "unused function" warning is simpler than trying to remove
+#      the whole thing (although full 'lint' may still complain).
 
 # with all of extern.h's functions to complain about, we drown in
 # 'defined but not used' without -u
@@ -308,7 +314,8 @@ dgn_yacc.c: dgn_comp.y
 
 dgn_lex.c: dgn_comp.l
        $(LEX) $(FLEXDIST) dgn_comp.l
-       sed -e 's#"$(LEXYYC)"#"$@"#' -e 's#  *$$##' $(LEXYYC) > $@ \
+       sed -e 's#"$(LEXYYC)"#"$@"#' -e 's#  *$$##' \
+           -e 's#static void yyunput#void yyunput#' $(LEXYYC) > $@ \
                && rm $(LEXYYC)
 #      note: <space><space><star> is basic RE substitute for <space><plus>