svn commit: r268883 - in head: contrib/unbound contrib/unbound/util lib/libunbound

Dag-Erling Smørgrav des at FreeBSD.org
Sat Jul 19 18:38:50 UTC 2014


Author: des
Date: Sat Jul 19 18:38:48 2014
New Revision: 268883
URL: http://svnweb.freebsd.org/changeset/base/268883

Log:
  Clean up the libunbound build to avoid accidentally regenerating the
  configuration lexer and parser during buildworld.  Instead of being
  included in the source as it is in the upstream distribution, the code is
  now always generated (in ${.OBJDIR}) at build time.
  
  PR:		190739
  MFC after:	1 week

Deleted:
  head/contrib/unbound/util/configlexer.c
  head/contrib/unbound/util/configparser.c
  head/contrib/unbound/util/configparser.h
Modified:
  head/contrib/unbound/freebsd-configure.sh
  head/contrib/unbound/util/config_file.c
  head/contrib/unbound/util/configlexer.lex
  head/contrib/unbound/util/configparser.y
  head/lib/libunbound/Makefile

Modified: head/contrib/unbound/freebsd-configure.sh
==============================================================================
--- head/contrib/unbound/freebsd-configure.sh	Sat Jul 19 18:33:09 2014	(r268882)
+++ head/contrib/unbound/freebsd-configure.sh	Sat Jul 19 18:38:48 2014	(r268883)
@@ -32,13 +32,6 @@ autoheader
 	--with-run-dir=/var/unbound \
 	--with-username=unbound
 
-# Regenerate the configuration parser
-{
-cat <<EOF
-#include "config.h"
-#include "util/configyyrename.h"
-EOF
-/usr/bin/flex -L -t util/configlexer.lex
-} >util/configlexer.c
-
-/usr/bin/yacc -d -o util/configparser.c util/configparser.y
+# Don't try to provide bogus memory usage statistics based on sbrk(2).
+sed -n -i.orig -e '/HAVE_SBRK/!p' config.status
+./config.status config.h

Modified: head/contrib/unbound/util/config_file.c
==============================================================================
--- head/contrib/unbound/util/config_file.c	Sat Jul 19 18:33:09 2014	(r268882)
+++ head/contrib/unbound/util/config_file.c	Sat Jul 19 18:38:48 2014	(r268883)
@@ -48,7 +48,7 @@
 #include "util/log.h"
 #include "util/configyyrename.h"
 #include "util/config_file.h"
-#include "util/configparser.h"
+#include "configparser.h"
 #include "util/net_help.h"
 #include "util/data/msgparse.h"
 #include "util/module.h"

Modified: head/contrib/unbound/util/configlexer.lex
==============================================================================
--- head/contrib/unbound/util/configlexer.lex	Sat Jul 19 18:33:09 2014	(r268882)
+++ head/contrib/unbound/util/configlexer.lex	Sat Jul 19 18:38:48 2014	(r268883)
@@ -8,6 +8,8 @@
  *
  */
 
+#include "config.h"
+
 #include <ctype.h>
 #include <string.h>
 #include <strings.h>
@@ -16,7 +18,7 @@
 #endif
 
 #include "util/config_file.h"
-#include "util/configparser.h"
+#include "configparser.h"
 void ub_c_error(const char *message);
 
 #if 0
@@ -26,13 +28,13 @@ void ub_c_error(const char *message);
 #endif
 
 /** avoid warning in about fwrite return value */
-#define ECHO ub_c_error_msg("syntax error at text: %s", yytext)
+#define ECHO ub_c_error_msg("syntax error at text: %s", ub_c_text)
 
 /** A parser variable, this is a statement in the config file which is
  * of the form variable: value1 value2 ...  nargs is the number of values. */
 #define YDVAR(nargs, var) \
 	num_args=(nargs); \
-	LEXOUT(("v(%s%d) ", yytext, num_args)); \
+	LEXOUT(("v(%s%d) ", ub_c_text, num_args)); \
 	if(num_args > 0) { BEGIN(val); } \
 	return (var);
 
@@ -166,7 +168,7 @@ static void config_end_include(void)
 #define yy_set_bol(at_bol) \
         { \
 	        if ( ! yy_current_buffer ) \
-	                yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+	                yy_current_buffer = yy_create_buffer( ub_c_in, YY_BUF_SIZE ); \
 	        yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
         }
 #endif
@@ -200,7 +202,7 @@ SQANY     [^\'\n\r\\]|\\.
 	LEXOUT(("SP ")); /* ignore */ }
 <INITIAL,val>{SPACE}*{COMMENT}.*	{ 
 	/* note that flex makes the longest match and '.' is any but not nl */
-	LEXOUT(("comment(%s) ", yytext)); /* ignore */ }
+	LEXOUT(("comment(%s) ", ub_c_text)); /* ignore */ }
 server{COLON}			{ YDVAR(0, VAR_SERVER) }
 num-threads{COLON}		{ YDVAR(1, VAR_NUM_THREADS) }
 verbosity{COLON}		{ YDVAR(1, VAR_VERBOSITY) }
@@ -331,71 +333,71 @@ max-udp-size{COLON}		{ YDVAR(1, VAR_MAX_
 	/* Quoted strings. Strip leading and ending quotes */
 <val>\"			{ BEGIN(quotedstring); LEXOUT(("QS ")); }
 <quotedstring><<EOF>>   {
-        yyerror("EOF inside quoted string");
+        ub_c_error("EOF inside quoted string");
 	if(--num_args == 0) { BEGIN(INITIAL); }
 	else		    { BEGIN(val); }
 }
-<quotedstring>{DQANY}*  { LEXOUT(("STR(%s) ", yytext)); yymore(); }
-<quotedstring>{NEWLINE} { yyerror("newline inside quoted string, no end \""); 
+<quotedstring>{DQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
+<quotedstring>{NEWLINE} { ub_c_error("newline inside quoted string, no end \""); 
 			  cfg_parser->line++; BEGIN(INITIAL); }
 <quotedstring>\" {
         LEXOUT(("QE "));
 	if(--num_args == 0) { BEGIN(INITIAL); }
 	else		    { BEGIN(val); }
-        yytext[yyleng - 1] = '\0';
-	yylval.str = strdup(yytext);
-	if(!yylval.str)
-		yyerror("out of memory");
+        ub_c_text[ub_c_leng - 1] = '\0';
+	ub_c_lval.str = strdup(ub_c_text);
+	if(!ub_c_lval.str)
+		ub_c_error("out of memory");
         return STRING_ARG;
 }
 
 	/* Single Quoted strings. Strip leading and ending quotes */
 <val>\'			{ BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
 <singlequotedstr><<EOF>>   {
-        yyerror("EOF inside quoted string");
+        ub_c_error("EOF inside quoted string");
 	if(--num_args == 0) { BEGIN(INITIAL); }
 	else		    { BEGIN(val); }
 }
-<singlequotedstr>{SQANY}*  { LEXOUT(("STR(%s) ", yytext)); yymore(); }
-<singlequotedstr>{NEWLINE} { yyerror("newline inside quoted string, no end '"); 
+<singlequotedstr>{SQANY}*  { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
+<singlequotedstr>{NEWLINE} { ub_c_error("newline inside quoted string, no end '"); 
 			     cfg_parser->line++; BEGIN(INITIAL); }
 <singlequotedstr>\' {
         LEXOUT(("SQE "));
 	if(--num_args == 0) { BEGIN(INITIAL); }
 	else		    { BEGIN(val); }
-        yytext[yyleng - 1] = '\0';
-	yylval.str = strdup(yytext);
-	if(!yylval.str)
-		yyerror("out of memory");
+        ub_c_text[ub_c_leng - 1] = '\0';
+	ub_c_lval.str = strdup(ub_c_text);
+	if(!ub_c_lval.str)
+		ub_c_error("out of memory");
         return STRING_ARG;
 }
 
 	/* include: directive */
 <INITIAL,val>include{COLON}	{ 
-	LEXOUT(("v(%s) ", yytext)); inc_prev = YYSTATE; BEGIN(include); }
+	LEXOUT(("v(%s) ", ub_c_text)); inc_prev = YYSTATE; BEGIN(include); }
 <include><<EOF>>	{
-        yyerror("EOF inside include directive");
+        ub_c_error("EOF inside include directive");
         BEGIN(inc_prev);
 }
 <include>{SPACE}*	{ LEXOUT(("ISP ")); /* ignore */ }
 <include>{NEWLINE}	{ LEXOUT(("NL\n")); cfg_parser->line++;}
 <include>\"		{ LEXOUT(("IQS ")); BEGIN(include_quoted); }
 <include>{UNQUOTEDLETTER}*	{
-	LEXOUT(("Iunquotedstr(%s) ", yytext));
-	config_start_include_glob(yytext);
+	LEXOUT(("Iunquotedstr(%s) ", ub_c_text));
+	config_start_include_glob(ub_c_text);
 	BEGIN(inc_prev);
 }
 <include_quoted><<EOF>>	{
-        yyerror("EOF inside quoted string");
+        ub_c_error("EOF inside quoted string");
         BEGIN(inc_prev);
 }
-<include_quoted>{DQANY}*	{ LEXOUT(("ISTR(%s) ", yytext)); yymore(); }
-<include_quoted>{NEWLINE}	{ yyerror("newline before \" in include name"); 
+<include_quoted>{DQANY}*	{ LEXOUT(("ISTR(%s) ", ub_c_text)); yymore(); }
+<include_quoted>{NEWLINE}	{ ub_c_error("newline before \" in include name"); 
 				  cfg_parser->line++; BEGIN(inc_prev); }
 <include_quoted>\"	{
 	LEXOUT(("IQE "));
-	yytext[yyleng - 1] = '\0';
-	config_start_include_glob(yytext);
+	ub_c_text[ub_c_leng - 1] = '\0';
+	config_start_include_glob(ub_c_text);
 	BEGIN(inc_prev);
 }
 <INITIAL,val><<EOF>>	{
@@ -404,21 +406,21 @@ max-udp-size{COLON}		{ YDVAR(1, VAR_MAX_
 	if (!config_include_stack) {
 		yyterminate();
 	} else {
-		fclose(yyin);
+		fclose(ub_c_in);
 		config_end_include();
 	}
 }
 
-<val>{UNQUOTEDLETTER}*	{ LEXOUT(("unquotedstr(%s) ", yytext)); 
+<val>{UNQUOTEDLETTER}*	{ LEXOUT(("unquotedstr(%s) ", ub_c_text)); 
 			if(--num_args == 0) { BEGIN(INITIAL); }
-			yylval.str = strdup(yytext); return STRING_ARG; }
+			ub_c_lval.str = strdup(ub_c_text); return STRING_ARG; }
 
 {UNQUOTEDLETTER_NOCOLON}*	{
-	ub_c_error_msg("unknown keyword '%s'", yytext);
+	ub_c_error_msg("unknown keyword '%s'", ub_c_text);
 	}
 
 <*>.	{
-	ub_c_error_msg("stray '%s'", yytext);
+	ub_c_error_msg("stray '%s'", ub_c_text);
 	}
 
 %%

Modified: head/contrib/unbound/util/configparser.y
==============================================================================
--- head/contrib/unbound/util/configparser.y	Sat Jul 19 18:33:09 2014	(r268882)
+++ head/contrib/unbound/util/configparser.y	Sat Jul 19 18:38:48 2014	(r268883)
@@ -44,7 +44,6 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "util/configyyrename.h"
 #include "util/config_file.h"
 #include "util/net_help.h"
 

Modified: head/lib/libunbound/Makefile
==============================================================================
--- head/lib/libunbound/Makefile	Sat Jul 19 18:33:09 2014	(r268882)
+++ head/lib/libunbound/Makefile	Sat Jul 19 18:38:48 2014	(r268883)
@@ -10,9 +10,9 @@ UNBOUNDDIR= ${.CURDIR}/../../contrib/unb
 LIB=	unbound
 PRIVATELIB=
 
-CFLAGS= -I${UNBOUNDDIR}	-I${LDNSDIR}
+CFLAGS= -I${UNBOUNDDIR}	-I${LDNSDIR} -I${.OBJDIR}
 
-SRCS=	alloc.c autotrust.c config_file.c configlexer.c configparser.c \
+SRCS=	alloc.c autotrust.c config_file.c configlexer.l configparser.y \
 	context.c dname.c dns.c dnstree.c fptr_wlist.c infra.c \
 	iter_delegpt.c iter_donotq.c iter_fwd.c iter_hints.c iter_priv.c \
 	iter_resptype.c iter_scrub.c iter_utils.c iterator.c keyraw.c \
@@ -31,4 +31,13 @@ WARNS?=	3
 DPADD+=	${LIBSSL} ${LIBCRYPTO} ${LIBPTHREAD}
 LDADD+=	-lssl -lcrypto -lpthread
 
+# Misnamed file in upstream source
+configlexer.l: configlexer.lex
+	cp -p ${.ALLSRC} ${.TARGET}
+CLEANFILES+= configlexer.l
+
+# Symbol prefix for lex and yacc
+LFLAGS= -Pub_c_
+YFLAGS= -pub_c_ -d
+
 .include <bsd.lib.mk>


More information about the svn-src-head mailing list