Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/config/mkmakefile.c
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | |||||
sanitize_envline(char *result, const char *src) | sanitize_envline(char *result, const char *src) | ||||
{ | { | ||||
const char *eq; | const char *eq; | ||||
char c, *dst; | char c, *dst; | ||||
bool leading; | bool leading; | ||||
/* If there is no '=' it's not a well-formed name=value line. */ | /* If there is no '=' it's not a well-formed name=value line. */ | ||||
if ((eq = strchr(src, '=')) == NULL) { | if ((eq = strchr(src, '=')) == NULL) { | ||||
*result = 0; | *result = '\0'; | ||||
return; | return; | ||||
} | } | ||||
dst = result; | dst = result; | ||||
/* Copy chars before the '=', skipping any leading spaces/quotes. */ | /* Copy chars before the '=', skipping any leading spaces/quotes. */ | ||||
leading = true; | leading = true; | ||||
while (src < eq) { | while (src < eq) { | ||||
c = *src++; | c = *src++; | ||||
if (leading && (isspace(c) || c == '"')) | if (leading && (isspace(c) || c == '"')) | ||||
continue; | continue; | ||||
*dst++ = c; | *dst++ = c; | ||||
leading = false; | leading = false; | ||||
} | } | ||||
/* If it was all leading space, we don't have a well-formed line. */ | /* If it was all leading space, we don't have a well-formed line. */ | ||||
if (leading) { | if (leading) { | ||||
*result = 0; | *result = '\0'; | ||||
return; | return; | ||||
} | } | ||||
/* Trim spaces/quotes immediately before the '=', then copy the '='. */ | /* Trim spaces/quotes immediately before the '=', then copy the '='. */ | ||||
while (isspace(dst[-1]) || dst[-1] == '"') | while (isspace(dst[-1]) || dst[-1] == '"') | ||||
--dst; | --dst; | ||||
*dst++ = *src++; | *dst++ = *src++; | ||||
/* Copy chars after the '=', skipping any leading whitespace. */ | /* Copy chars after the '=', skipping any leading whitespace. */ | ||||
leading = true; | leading = true; | ||||
while ((c = *src++) != 0) { | while ((c = *src++) != '\0') { | ||||
if (leading && (isspace(c) || c == '"')) | if (leading && (isspace(c) || c == '"')) | ||||
continue; | continue; | ||||
*dst++ = c; | *dst++ = c; | ||||
leading = false; | leading = false; | ||||
} | } | ||||
/* If it was all leading space, it's a valid 'var=' (nil value). */ | /* If it was all leading space, it's a valid 'var=' (nil value). */ | ||||
if (leading) { | if (leading) { | ||||
*dst = 0; | *dst = '\0'; | ||||
return; | return; | ||||
} | } | ||||
/* Trim trailing whitespace and quotes. */ | /* Trim trailing whitespace and quotes. */ | ||||
while (isspace(dst[-1]) || dst[-1] == '"') | while (isspace(dst[-1]) || dst[-1] == '"') | ||||
--dst; | --dst; | ||||
*dst = 0; | *dst = '\0'; | ||||
} | } | ||||
/* | /* | ||||
* Returns true if the caller may use the string. | * Returns true if the caller may use the string. | ||||
*/ | */ | ||||
static bool | static bool | ||||
preprocess(char *line, char *result) | preprocess(char *line, char *result) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | next: | ||||
if (wd == (char *)EOF) | if (wd == (char *)EOF) | ||||
return; | return; | ||||
if (wd == NULL) | if (wd == NULL) | ||||
errout("%s: No type for %s.\n", fname, this); | errout("%s: No type for %s.\n", fname, this); | ||||
tp = fl_lookup(this); | tp = fl_lookup(this); | ||||
compile = 0; | compile = 0; | ||||
match = 1; | match = 1; | ||||
nreqs = 0; | nreqs = 0; | ||||
compilewith = 0; | compilewith = NULL; | ||||
depends = 0; | depends = NULL; | ||||
clean = 0; | clean = NULL; | ||||
warning = 0; | warning = NULL; | ||||
std = 0; | std = 0; | ||||
imp_rule = 0; | imp_rule = 0; | ||||
no_ctfconvert = 0; | no_ctfconvert = 0; | ||||
no_obj = 0; | no_obj = 0; | ||||
before_depend = 0; | before_depend = 0; | ||||
nowerror = 0; | nowerror = 0; | ||||
not = 0; | not = 0; | ||||
filetype = NORMAL; | filetype = NORMAL; | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |