Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/config/mkoptions.c
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | do_option(char *name) | ||||
SLIST_INIT(&op_head); | SLIST_INIT(&op_head); | ||||
seen = 0; | seen = 0; | ||||
tidy = 0; | tidy = 0; | ||||
for (;;) { | for (;;) { | ||||
char *cp; | char *cp; | ||||
char *invalue; | char *invalue; | ||||
/* get the #define */ | /* get the #define */ | ||||
if ((inw = get_word(inf)) == NULL || inw == (char *)EOF) | if ((inw = get_word(inf, NULL)) == NULL || inw == (char *)EOF) | ||||
break; | break; | ||||
/* get the option name */ | /* get the option name */ | ||||
if ((inw = get_word(inf)) == NULL || inw == (char *)EOF) | if ((inw = get_word(inf, NULL)) == NULL || inw == (char *)EOF) | ||||
break; | break; | ||||
inw = ns(inw); | inw = ns(inw); | ||||
/* get the option value */ | /* get the option value */ | ||||
if ((cp = get_word(inf)) == NULL || cp == (char *)EOF) | if ((cp = get_word(inf, NULL)) == NULL || cp == (char *)EOF) | ||||
break; | break; | ||||
/* option value */ | /* option value */ | ||||
invalue = ns(cp); /* malloced */ | invalue = ns(cp); /* malloced */ | ||||
if (eq(inw, name)) { | if (eq(inw, name)) { | ||||
oldvalue = invalue; | oldvalue = invalue; | ||||
invalue = value; | invalue = value; | ||||
seen++; | seen++; | ||||
} | } | ||||
Show All 15 Lines | if (!eq(inw, name) && !ol) { | ||||
if (op == NULL) | if (op == NULL) | ||||
err(EXIT_FAILURE, "calloc"); | err(EXIT_FAILURE, "calloc"); | ||||
op->op_name = inw; | op->op_name = inw; | ||||
op->op_value = invalue; | op->op_value = invalue; | ||||
SLIST_INSERT_HEAD(&op_head, op, op_next); | SLIST_INSERT_HEAD(&op_head, op, op_next); | ||||
} | } | ||||
/* EOL? */ | /* EOL? */ | ||||
cp = get_word(inf); | cp = get_word(inf, NULL); | ||||
if (cp == (char *)EOF) | if (cp == (char *)EOF) | ||||
break; | break; | ||||
} | } | ||||
(void)fclose(inf); | (void)fclose(inf); | ||||
if (!tidy && ((value == NULL && oldvalue == NULL) || | if (!tidy && ((value == NULL && oldvalue == NULL) || | ||||
(value && oldvalue && eq(value, oldvalue)))) { | (value && oldvalue && eq(value, oldvalue)))) { | ||||
while (!SLIST_EMPTY(&op_head)) { | while (!SLIST_EMPTY(&op_head)) { | ||||
op = SLIST_FIRST(&op_head); | op = SLIST_FIRST(&op_head); | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
FILE *fp; | FILE *fp; | ||||
char *wd, *this, *val; | char *wd, *this, *val; | ||||
char genopt[MAXPATHLEN]; | char genopt[MAXPATHLEN]; | ||||
fp = fopen(fname, "r"); | fp = fopen(fname, "r"); | ||||
if (fp == NULL) | if (fp == NULL) | ||||
return (0); | return (0); | ||||
while ((wd = get_word(fp)) != (char *)EOF) { | while ((wd = get_word(fp, NULL)) != (char *)EOF) { | ||||
if (wd == NULL) | if (wd == NULL) | ||||
continue; | continue; | ||||
if (wd[0] == '#') { | if (wd[0] == '#') { | ||||
while (((wd = get_word(fp)) != (char *)EOF) && wd) | while (((wd = get_word(fp, NULL)) != (char *)EOF) && wd) | ||||
continue; | continue; | ||||
continue; | continue; | ||||
} | } | ||||
this = ns(wd); | this = ns(wd); | ||||
val = get_word(fp); | val = get_word(fp, NULL); | ||||
if (val == (char *)EOF) | if (val == (char *)EOF) | ||||
return (1); | return (1); | ||||
if (val == NULL) { | if (val == NULL) { | ||||
if (flags) { | if (flags) { | ||||
fprintf(stderr, "%s: compat file requires two" | fprintf(stderr, "%s: compat file requires two" | ||||
" words per line at %s\n", fname, this); | " words per line at %s\n", fname, this); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |