version 1.28, 2015/11/07 14:22:29 |
version 1.29, 2015/11/07 17:58:55 |
Line 212 manconf_file(struct manconf *conf, const char *file) |
|
Line 212 manconf_file(struct manconf *conf, const char *file) |
|
char manpath_default[] = MANPATH_DEFAULT; |
char manpath_default[] = MANPATH_DEFAULT; |
|
|
FILE *stream; |
FILE *stream; |
char *cp, *ep; |
char *line, *cp, *ep; |
size_t len, tok; |
size_t linesz, tok, toklen; |
|
ssize_t linelen; |
|
|
if ((stream = fopen(file, "r")) == NULL) |
if ((stream = fopen(file, "r")) == NULL) |
goto out; |
goto out; |
|
|
while ((cp = fgetln(stream, &len)) != NULL) { |
line = NULL; |
ep = cp + len; |
linesz = 0; |
|
|
|
while ((linelen = getline(&line, &linesz, stream)) != -1) { |
|
cp = line; |
|
ep = cp + linelen; |
if (ep[-1] != '\n') |
if (ep[-1] != '\n') |
break; |
break; |
*--ep = '\0'; |
*--ep = '\0'; |
Line 229 manconf_file(struct manconf *conf, const char *file) |
|
Line 234 manconf_file(struct manconf *conf, const char *file) |
|
continue; |
continue; |
|
|
for (tok = 0; tok < sizeof(toks)/sizeof(toks[0]); tok++) { |
for (tok = 0; tok < sizeof(toks)/sizeof(toks[0]); tok++) { |
len = strlen(toks[tok]); |
toklen = strlen(toks[tok]); |
if (cp + len < ep && |
if (cp + toklen < ep && |
isspace((unsigned char)cp[len]) && |
isspace((unsigned char)cp[toklen]) && |
!strncmp(cp, toks[tok], len)) { |
strncmp(cp, toks[tok], toklen) == 0) { |
cp += len; |
cp += toklen; |
while (isspace((unsigned char)*cp)) |
while (isspace((unsigned char)*cp)) |
cp++; |
cp++; |
break; |
break; |
Line 259 manconf_file(struct manconf *conf, const char *file) |
|
Line 264 manconf_file(struct manconf *conf, const char *file) |
|
break; |
break; |
} |
} |
} |
} |
|
free(line); |
fclose(stream); |
fclose(stream); |
|
|
out: |
out: |