summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1997-02-14 21:17:00 +0000
committerjkh <jkh@FreeBSD.org>1997-02-14 21:17:00 +0000
commit17a99dd753fab2fb90f7524f9490d667265a61a6 (patch)
tree22ea8f284e5b1e6a9464282eacab5f77e3380a20
parent5dc52e3240da65ca0ddeb05e574d447b212a235e (diff)
downloadFreeBSD-src-17a99dd753fab2fb90f7524f9490d667265a61a6.zip
FreeBSD-src-17a99dd753fab2fb90f7524f9490d667265a61a6.tar.gz
Add better quote elimination (and fix a bug).
-rw-r--r--release/sysinstall/config.c15
-rw-r--r--usr.sbin/sade/config.c15
-rw-r--r--usr.sbin/sysinstall/config.c15
3 files changed, 24 insertions, 21 deletions
diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c
index 96dfcd1..48da24e 100644
--- a/release/sysinstall/config.c
+++ b/release/sysinstall/config.c
@@ -234,10 +234,10 @@ configFstab(void)
fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump?\tfsck pass#\n");
fprintf(fstab, "#\t\t\t\t\t\t\t\t\t(0=no) (0=no fsck)\n");
for (i = 0; i < nchunks; i++)
- fprintf(fstab, "/dev/%s\t\t%s\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
+ fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
Mkdir("/proc");
- fprintf(fstab, "proc\t\t/proc\tprocfs\t\trw\t0\t0\n");
+ fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\t\trw\t0\t0\n");
/* Now look for the CDROMs */
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
@@ -305,7 +305,7 @@ readConfig(char *config, char **lines, int max)
void
configEnvironment(char *config)
{
- char *lines[MAX_LINES], *cp;
+ char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
nlines = readConfig(config, lines, MAX_LINES);
@@ -321,12 +321,13 @@ configEnvironment(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
- if (*cp == '"') /* Eliminate leading quote if it's quoted */
- ++cp;
- j = strlen(cp);
+ if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
+ cp = cp2 + 1;
+ j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
cp[j] = '\0';
- variable_set2(lines[i], cp);
+ if (strlen(cp))
+ variable_set2(lines[i], cp);
free(lines[i]);
}
}
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c
index 96dfcd1..48da24e 100644
--- a/usr.sbin/sade/config.c
+++ b/usr.sbin/sade/config.c
@@ -234,10 +234,10 @@ configFstab(void)
fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump?\tfsck pass#\n");
fprintf(fstab, "#\t\t\t\t\t\t\t\t\t(0=no) (0=no fsck)\n");
for (i = 0; i < nchunks; i++)
- fprintf(fstab, "/dev/%s\t\t%s\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
+ fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
Mkdir("/proc");
- fprintf(fstab, "proc\t\t/proc\tprocfs\t\trw\t0\t0\n");
+ fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\t\trw\t0\t0\n");
/* Now look for the CDROMs */
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
@@ -305,7 +305,7 @@ readConfig(char *config, char **lines, int max)
void
configEnvironment(char *config)
{
- char *lines[MAX_LINES], *cp;
+ char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
nlines = readConfig(config, lines, MAX_LINES);
@@ -321,12 +321,13 @@ configEnvironment(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
- if (*cp == '"') /* Eliminate leading quote if it's quoted */
- ++cp;
- j = strlen(cp);
+ if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
+ cp = cp2 + 1;
+ j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
cp[j] = '\0';
- variable_set2(lines[i], cp);
+ if (strlen(cp))
+ variable_set2(lines[i], cp);
free(lines[i]);
}
}
diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c
index 96dfcd1..48da24e 100644
--- a/usr.sbin/sysinstall/config.c
+++ b/usr.sbin/sysinstall/config.c
@@ -234,10 +234,10 @@ configFstab(void)
fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump?\tfsck pass#\n");
fprintf(fstab, "#\t\t\t\t\t\t\t\t\t(0=no) (0=no fsck)\n");
for (i = 0; i < nchunks; i++)
- fprintf(fstab, "/dev/%s\t\t%s\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
+ fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
Mkdir("/proc");
- fprintf(fstab, "proc\t\t/proc\tprocfs\t\trw\t0\t0\n");
+ fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\t\trw\t0\t0\n");
/* Now look for the CDROMs */
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
@@ -305,7 +305,7 @@ readConfig(char *config, char **lines, int max)
void
configEnvironment(char *config)
{
- char *lines[MAX_LINES], *cp;
+ char *lines[MAX_LINES], *cp, *cp2;
int i, j, nlines;
nlines = readConfig(config, lines, MAX_LINES);
@@ -321,12 +321,13 @@ configEnvironment(char *config)
*cp++ = '\0';
(void)string_prune(lines[i]);
cp = string_skipwhite(string_prune(cp));
- if (*cp == '"') /* Eliminate leading quote if it's quoted */
- ++cp;
- j = strlen(cp);
+ if ((cp2 = index(cp, '"'))) /* Eliminate leading quote if it's quoted */
+ cp = cp2 + 1;
+ j = strlen(cp) - 1;
if (cp[j] == '"') /* And trailing one */
cp[j] = '\0';
- variable_set2(lines[i], cp);
+ if (strlen(cp))
+ variable_set2(lines[i], cp);
free(lines[i]);
}
}
OpenPOWER on IntegriCloud