Module Name: src
Committed By: christos
Date: Thu Aug 18 13:20:04 UTC 2011
Modified Files:
src/sys/arch/i386/stand/lib: bootmenu.c parseutils.c
Log Message:
PR/43563: Wolfgang Solfrank: boot.cfg doesn't support comments
Fix makes it support # comments and treat spaces and tabs the same way.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/bootmenu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/parseutils.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/i386/stand/lib/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.9 src/sys/arch/i386/stand/lib/bootmenu.c:1.10
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.9 Thu May 26 00:25:27 2011
+++ src/sys/arch/i386/stand/lib/bootmenu.c Thu Aug 18 09:20:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmenu.c,v 1.9 2011/05/26 04:25:27 uebayasi Exp $ */
+/* $NetBSD: bootmenu.c,v 1.10 2011/08/18 13:20:04 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
int cmenu, cbanner, len;
int fd, err, off;
struct stat st;
- char *key, *value, *v2;
+ char *next, *key, *value, *v2;
/* Clear bootconf structure */
memset((void *)&bootconf, 0, sizeof(bootconf));
@@ -157,13 +157,22 @@
cmenu = 0;
cbanner = 0;
- for (c = bc; *c; c++) {
+ for (c = bc; *c; c = next) {
key = c;
+ /* find end of line */
+ for (; *c && *c != '\n'; c++)
+ /* zero terminate line on start of comment */
+ if (*c == '#')
+ *c = 0;
+ /* zero terminate line */
+ if (*(next = c))
+ *next++ = 0;
/* Look for = separator between key and value */
- for (; *c && *c != '='; c++)
+ for (c = key; *c && *c != '='; c++)
continue;
+ /* Ignore lines with no key=value pair */
if (*c == '\0')
- break; /* break if at end of data */
+ continue;
/* zero terminate key which points to keyword */
*c++ = 0;
Index: src/sys/arch/i386/stand/lib/parseutils.c
diff -u src/sys/arch/i386/stand/lib/parseutils.c:1.5 src/sys/arch/i386/stand/lib/parseutils.c:1.6
--- src/sys/arch/i386/stand/lib/parseutils.c:1.5 Sun Dec 14 12:03:43 2008
+++ src/sys/arch/i386/stand/lib/parseutils.c Thu Aug 18 09:20:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: parseutils.c,v 1.5 2008/12/14 17:03:43 christos Exp $ */
+/* $NetBSD: parseutils.c,v 1.6 2011/08/18 13:20:04 christos Exp $ */
/*
* Copyright (c) 1996, 1997
@@ -52,13 +52,22 @@
{
char *options;
- if ((options = strchr(arg, ' ')) == NULL)
+ for (options = arg; *options; options++) {
+ switch (*options) {
+ case ' ':
+ case '\t':
+ *options++ = '\0';
+ break;
+ default:
+ continue;
+ }
+ break;
+ }
+ if (*options == '\0')
return "";
- else
- *options++ = '\0';
- /* trim leading blanks */
- while (*options && *options == ' ')
+ /* trim leading blanks/tabs */
+ while (*options == ' ' || *options == '\t')
options++;
return options;