Skip to contentSkip to conversation

fix parser.h recursive inclusion

PATCH In review Patrick McHardy 2 participants 3 messages Jan 16, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix parser.h recursive inclusion

This the recursive parser.h inclusion that happens occasionally when regenerating the parser files. Amazingly bison, despite its age, is not using header sandwiches to protect against this *sigh*

Slightly ugly, but fixes the problem.

Makefile.rules.in +8 -1
index 25988dd..ae563a5 100644
@@ -22,7 +22,14 @@ configure:		configure.ac
 
 %.c %.h:		%.y	$(makedeps)
 			@echo -e "  YACC\t\t$<"
-			$(YACC) $(YACCFLAGS) -d -o $@ $<
+			$(YACC) $(YACCFLAGS) --defines=$*.h.tmp -o $@ $<
+			( \
+				echo "#ifndef __$(*F)_H"; \
+				echo "#define __$(*F)_H"; \
+				cat $*.h.tmp; \
+				echo "#endif /* __$(*F)_H */" \
+			) > $*.h
+			$(RM) $*.h.tmp
 
 %.c %.h:		%.l	$(makedeps)
 			@echo -e "  LEX\t\t$<"
#1 lore raw
Quoted 5 lines · Patrick McHardy

This the recursive parser.h inclusion that happens occasionally when regenerating the parser files. Amazingly bison, despite its age, is not using header sandwiches to protect against this *sigh*

Slightly ugly, but fixes the problem.

Ah, much nicer than the "nested too deep" warning message :)

Quoted 20 lines
Makefile.rules.in +8 -1
index 25988dd..ae563a5 100644
@@ -22,7 +22,14 @@ configure:		configure.ac
 
 %.c %.h:		%.y	$(makedeps)
 			@echo -e "  YACC\t\t$<"
-			$(YACC) $(YACCFLAGS) -d -o $@ $<
+			$(YACC) $(YACCFLAGS) --defines=$*.h.tmp -o $@ $<
+			( \
+				echo "#ifndef __$(*F)_H"; \
+				echo "#define __$(*F)_H"; \
+				cat $*.h.tmp; \
+				echo "#endif /* __$(*F)_H */" \
+			) > $*.h
+			$(RM) $*.h.tmp
 
 %.c %.h:		%.l	$(makedeps)
 			@echo -e "  LEX\t\t$<"
#2 lore raw
Quoted 8 lines · Pablo Neira Ayuso
Quoted 5 lines · Patrick McHardy

This the recursive parser.h inclusion that happens occasionally when regenerating the parser files. Amazingly bison, despite its age, is not using header sandwiches to protect against this *sigh*

Slightly ugly, but fixes the problem.

Ah, much nicer than the "nested too deep" warning message :)

Indeed. Pushed out to master.

Quoted 25 lines
Quoted 11 lines
Makefile.rules.in +1 -1
index 25988dd..ae563a5 100644
@@ -22,7 +22,14 @@ configure:		configure.ac
 
 %.c %.h:		%.y	$(makedeps)
 			@echo -e "  YACC\t\t$<"
-			$(YACC) $(YACCFLAGS) -d -o $@ $<
+			$(YACC) $(YACCFLAGS) --defines=$*.h.tmp -o $@ $<

Makefile.rules.in configure: configure.ac · line 35

Quoted 10 lines
Makefile.rules.in +7 -0
+			( \
+				echo "#ifndef __$(*F)_H"; \
+				echo "#define __$(*F)_H"; \
+				cat $*.h.tmp; \
+				echo "#endif /* __$(*F)_H */" \
+			) > $*.h
+			$(RM) $*.h.tmp
 
 %.c %.h:		%.l	$(makedeps)
 			@echo -e "  LEX\t\t$<"

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html