Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jul 2018 18:55:42 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336013 - in head: . usr.sbin/config
Message-ID:  <201807051855.w65ItggO016556@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Jul  5 18:55:42 2018
New Revision: 336013
URL: https://svnweb.freebsd.org/changeset/base/336013

Log:
  Revert r336011,r336012 until I can competently test

Modified:
  head/Makefile.inc1
  head/usr.sbin/config/Makefile
  head/usr.sbin/config/mkmakefile.c

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Thu Jul  5 18:39:02 2018	(r336012)
+++ head/Makefile.inc1	Thu Jul  5 18:55:42 2018	(r336013)
@@ -2063,15 +2063,6 @@ _kerberos5_bootstrap_tools= \
 .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
 .endif
 
-# Later config(8) requires newer libnv cnvlist* API
-.if ${BOOTSTRAPPING} < 1200070
-_config= \
-	lib/libnv \
-	usr.sbin/config
-.else
-_config= usr.sbin/config
-.endif
-
 ${_bt}-usr.bin/mandoc: ${_bt}-lib/libopenbsd
 
 bootstrap-tools: .PHONY
@@ -2096,7 +2087,7 @@ bootstrap-tools: .PHONY
     ${_lex} \
     usr.bin/xinstall \
     ${_gensnmptree} \
-    ${_config} \
+    usr.sbin/config \
     ${_crunchide} \
     ${_crunchgen} \
     ${_nmtree} \

Modified: head/usr.sbin/config/Makefile
==============================================================================
--- head/usr.sbin/config/Makefile	Thu Jul  5 18:39:02 2018	(r336012)
+++ head/usr.sbin/config/Makefile	Thu Jul  5 18:55:42 2018	(r336013)
@@ -14,11 +14,11 @@ kernconf.c: kernconf.tmpl
 	${FILE2C} 'char kernconfstr[] = {' ',0};' < \
 	    ${SRCDIR}/kernconf.tmpl > kernconf.c
 
-CFLAGS+= -I. -I${SRCDIR} -I${SRCTOP}/sys
+CFLAGS+= -I. -I${SRCDIR}
 
 NO_WMISSING_VARIABLE_DECLARATIONS=
 
-LIBADD=	l nv sbuf
+LIBADD=	l sbuf
 
 CLEANFILES+=	kernconf.c
 

Modified: head/usr.sbin/config/mkmakefile.c
==============================================================================
--- head/usr.sbin/config/mkmakefile.c	Thu Jul  5 18:39:02 2018	(r336012)
+++ head/usr.sbin/config/mkmakefile.c	Thu Jul  5 18:55:42 2018	(r336013)
@@ -49,8 +49,6 @@ static const char rcsid[] =
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/cnv.h>
-#include <sys/nv.h>
 #include <sys/param.h>
 #include "y.tab.h"
 #include "config.h"
@@ -64,10 +62,6 @@ static void do_objs(FILE *);
 static void do_before_depend(FILE *);
 static int opteq(const char *, const char *);
 static void read_files(void);
-static void sanitize_envline(char *result, const char *src);
-static void process_into_file(char *line, FILE *ofp);
-static void process_into_nvlist(char *line, nvlist_t *nvl);
-static void dump_nvlist(nvlist_t *nvl, FILE *ofp);
 
 static void errout(const char *fmt, ...)
 {
@@ -186,6 +180,64 @@ makefile(void)
 	moveifchanged(path("Makefile.new"), path("Makefile"));
 }
 
+/*
+ * Build hints.c from the skeleton
+ */
+void
+makehints(void)
+{
+	FILE *ifp, *ofp;
+	char line[BUFSIZ];
+	char *s;
+	struct hint *hint;
+
+	ofp = fopen(path("hints.c.new"), "w");
+	if (ofp == NULL)
+		err(1, "%s", path("hints.c.new"));
+	fprintf(ofp, "#include <sys/types.h>\n");
+	fprintf(ofp, "#include <sys/systm.h>\n");
+	fprintf(ofp, "\n");
+	fprintf(ofp, "char static_hints[] = {\n");
+	STAILQ_FOREACH(hint, &hints, hint_next) {
+		ifp = fopen(hint->hint_name, "r");
+		if (ifp == NULL)
+			err(1, "%s", hint->hint_name);
+		while (fgets(line, BUFSIZ, ifp) != NULL) {
+			/* zap trailing CR and/or LF */
+			while ((s = strrchr(line, '\n')) != NULL)
+				*s = '\0';
+			while ((s = strrchr(line, '\r')) != NULL)
+				*s = '\0';
+			/* remove # comments */
+			s = strchr(line, '#');
+			if (s)
+				*s = '\0';
+			/* remove any whitespace and " characters */
+			s = line;
+			while (*s) {
+				if (*s == ' ' || *s == '\t' || *s == '"') {
+					while (*s) {
+						s[0] = s[1];
+						s++;
+					}
+					/* start over */
+					s = line;
+					continue;
+				}
+				s++;
+			}
+			/* anything left? */
+			if (*line == '\0')
+				continue;
+			fprintf(ofp, "\"%s\\0\"\n", line);
+		}
+		fclose(ifp);
+	}
+	fprintf(ofp, "\"\\0\"\n};\n");
+	fclose(ofp);
+	moveifchanged(path("hints.c.new"), path("hints.c"));
+}
+
 static void
 sanitize_envline(char *result, const char *src)
 {
@@ -243,96 +295,14 @@ sanitize_envline(char *result, const char *src)
 	*dst = 0;
 }
 
-static void
-process_into_file(char *line, FILE *ofp)
-{
-	char result[BUFSIZ];
-
-	sanitize_envline(result, line);
-	/* anything left? */
-	if (*result == '\0')
-		return;
-	fprintf(ofp, "\"%s\\0\"\n", result);
-}
-
-static void
-process_into_nvlist(char *line, nvlist_t *nvl)
-{
-	char result[BUFSIZ], *s;
-
-	sanitize_envline(result, line);
-	/* anything left? */
-	if (*result == '\0')
-		return;
-	s = strchr(result, '=');
-	*s = 0;
-	if (nvlist_exists(nvl, result))
-		nvlist_free(nvl, result);
-	nvlist_add_string(nvl, result, s + 1);
-}
-
-static void
-dump_nvlist(nvlist_t *nvl, FILE *ofp)
-{
-	const char *name;
-	void *cookie;
-
-	if (nvl == NULL)
-		return;
-
-	while (!nvlist_empty(nvl)) {
-		cookie = NULL;
-		name = nvlist_next(nvl, NULL, &cookie);
-		fprintf(ofp, "\"%s=%s\\0\"\n", name,
-		     cnvlist_get_string(cookie));
-
-		cnvlist_free_string(cookie);
-	}
-}
-
 /*
- * Build hints.c from the skeleton
- */
-void
-makehints(void)
-{
-	FILE *ifp, *ofp;
-	nvlist_t *nvl;
-	char line[BUFSIZ];
-	struct hint *hint;
-
-	ofp = fopen(path("hints.c.new"), "w");
-	if (ofp == NULL)
-		err(1, "%s", path("hints.c.new"));
-	fprintf(ofp, "#include <sys/types.h>\n");
-	fprintf(ofp, "#include <sys/systm.h>\n");
-	fprintf(ofp, "\n");
-	fprintf(ofp, "char static_hints[] = {\n");
-	nvl = nvlist_create(0);
-	STAILQ_FOREACH(hint, &hints, hint_next) {
-		ifp = fopen(hint->hint_name, "r");
-		if (ifp == NULL)
-			err(1, "%s", hint->hint_name);
-		while (fgets(line, BUFSIZ, ifp) != NULL)
-			process_into_nvlist(line, nvl);
-		dump_nvlist(nvl, ofp);
-		fclose(ifp);
-	}
-	nvlist_destroy(nvl);
-	fprintf(ofp, "\"\\0\"\n};\n");
-	fclose(ofp);
-	moveifchanged(path("hints.c.new"), path("hints.c"));
-}
-
-/*
  * Build env.c from the skeleton
  */
 void
 makeenv(void)
 {
 	FILE *ifp, *ofp;
-	nvlist_t *nvl;
-	char line[BUFSIZ];
+	char line[BUFSIZ], result[BUFSIZ], *linep;
 	struct envvar *envvar;
 
 	ofp = fopen(path("env.c.new"), "w");
@@ -342,20 +312,27 @@ makeenv(void)
 	fprintf(ofp, "#include <sys/systm.h>\n");
 	fprintf(ofp, "\n");
 	fprintf(ofp, "char static_env[] = {\n");
-	nvl = nvlist_create(0);
 	STAILQ_FOREACH(envvar, &envvars, envvar_next) {
 		if (envvar->env_is_file) {
 			ifp = fopen(envvar->env_str, "r");
 			if (ifp == NULL)
 				err(1, "%s", envvar->env_str);
-			while (fgets(line, BUFSIZ, ifp) != NULL)
-				process_into_nvlist(line, nvl);
-			dump_nvlist(nvl, ofp);
+			while (fgets(line, BUFSIZ, ifp) != NULL) {
+				sanitize_envline(result, line);
+				/* anything left? */
+				if (*result == '\0')
+					continue;
+				fprintf(ofp, "\"%s\\0\"\n", result);
+			}
 			fclose(ifp);
-		} else
-			process_into_file(envvar->env_str, ofp);
+		} else {
+			linep = envvar->env_str;
+			sanitize_envline(result, linep);
+			if (*result == '\0')
+				continue;
+			fprintf(ofp, "\"%s\\0\"\n", result);
+		}
 	}
-	nvlist_destroy(nvl);
 	fprintf(ofp, "\"\\0\"\n};\n");
 	fclose(ofp);
 	moveifchanged(path("env.c.new"), path("env.c"));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807051855.w65ItggO016556>