[pushed] Fix flex rule in gdb

Tom Tromey tromey@adacore.com
Tue Feb 1 18:43:02 GMT 2022


Currently, if flex fails, it will leave the resulting .c file in the
tree.  This will cause a cascade of errors, and requires the manual
deletion of the .c file in order to recreate the problem.

It's better for the rule to fail such that the .c file is not updated.
This way, 'make' will fail the same way every time -- which is much
handier for debugging syntax errors.

This fix just updates the Makefile rule to follow the way that the
"yacc" rule already works.
---
 gdb/Makefile.in | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3efd2227698..bf19db45343 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2456,20 +2456,19 @@ po/$(PACKAGE).pot: force
 	  rm -f $@.tmp && \
 	  mv $@.new $@
 %.c: %.l
-	$(ECHO_LEX) $(FLEX) -t $<  \
-	    | sed -e '/extern.*malloc/d' \
-	        -e '/extern.*realloc/d' \
-	        -e '/extern.*free/d' \
-	        -e '/include.*malloc.h/d' \
-	        -e 's/\([^x]\)malloc/\1xmalloc/g' \
-	        -e 's/\([^x]\)realloc/\1xrealloc/g' \
-	        -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
-	        -e 's/\([ \t;,(]\)free$$/\1xfree/g' \
-		-e 's/yy_flex_xrealloc/yyxrealloc/g' \
-	      > $@.new && \
-	    mv $@.new $@
-
-.PRECIOUS: ada-lex.c
+	$(ECHO_LEX) $(FLEX) -t $< > $@.tmp || (rm -f $@.tmp; false)
+	@sed -e '/extern.*malloc/d' \
+	     -e '/extern.*realloc/d' \
+	     -e '/extern.*free/d' \
+	     -e '/include.*malloc.h/d' \
+	     -e 's/\([^x]\)malloc/\1xmalloc/g' \
+	     -e 's/\([^x]\)realloc/\1xrealloc/g' \
+	     -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
+	     -e 's/\([ \t;,(]\)free$$/\1xfree/g' \
+	     -e 's/yy_flex_xrealloc/yyxrealloc/g' \
+	     < $@.tmp > $@.new && \
+	     rm -f $@.tmp && \
+	     mv $@.new $@
 
 # XML rules
 
-- 
2.31.1



More information about the Gdb-patches mailing list