Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/stand/lib PR/43563: Wolfgang Solfrank: boot.cf...
details: https://anonhg.NetBSD.org/src/rev/082748490549
branches: trunk
changeset: 768527:082748490549
user: christos <christos%NetBSD.org@localhost>
date: Thu Aug 18 13:20:04 2011 +0000
description:
PR/43563: Wolfgang Solfrank: boot.cfg doesn't support comments
Fix makes it support # comments and treat spaces and tabs the same way.
diffstat:
sys/arch/i386/stand/lib/bootmenu.c | 19 ++++++++++++++-----
sys/arch/i386/stand/lib/parseutils.c | 21 +++++++++++++++------
2 files changed, 29 insertions(+), 11 deletions(-)
diffs (81 lines):
diff -r 2d323f4d756e -r 082748490549 sys/arch/i386/stand/lib/bootmenu.c
--- a/sys/arch/i386/stand/lib/bootmenu.c Thu Aug 18 12:53:25 2011 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c Thu Aug 18 13:20:04 2011 +0000
@@ -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;
diff -r 2d323f4d756e -r 082748490549 sys/arch/i386/stand/lib/parseutils.c
--- a/sys/arch/i386/stand/lib/parseutils.c Thu Aug 18 12:53:25 2011 +0000
+++ b/sys/arch/i386/stand/lib/parseutils.c Thu Aug 18 13:20:04 2011 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index