From ea7c446076a6b71c3b056effe941ba018cb55384 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Fri, 14 Feb 1997 21:17:00 +0000 Subject: [PATCH] Add better quote elimination (and fix a bug). --- release/sysinstall/config.c | 15 ++++++++------- usr.sbin/sade/config.c | 15 ++++++++------- usr.sbin/sysinstall/config.c | 15 ++++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c index 96dfcd1c8f43..48da24e072b4 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 96dfcd1c8f43..48da24e072b4 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 96dfcd1c8f43..48da24e072b4 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]); } }