version 1.208, 2015/11/07 14:22:29 |
version 1.210, 2015/12/15 17:38:45 |
Line 420 mandocdb(int argc, char *argv[]) |
|
Line 420 mandocdb(int argc, char *argv[]) |
|
argv += optind; |
argv += optind; |
|
|
#if HAVE_PLEDGE |
#if HAVE_PLEDGE |
if (nodb && pledge("stdio rpath", NULL) == -1) { |
if (nodb) { |
perror("pledge"); |
if (pledge("stdio rpath", NULL) == -1) { |
return (int)MANDOCLEVEL_SYSERR; |
perror("pledge"); |
|
return (int)MANDOCLEVEL_SYSERR; |
|
} |
} |
} |
#endif |
#endif |
|
|
Line 452 mandocdb(int argc, char *argv[]) |
|
Line 454 mandocdb(int argc, char *argv[]) |
|
* all files specified on the command-line. |
* all files specified on the command-line. |
*/ |
*/ |
#if HAVE_PLEDGE |
#if HAVE_PLEDGE |
if (!nodb && pledge("stdio rpath wpath cpath fattr flock", |
if (!nodb) { |
NULL) == -1) { |
if (pledge("stdio rpath wpath cpath fattr flock", NULL) == -1) { |
perror("pledge"); |
perror("pledge"); |
exitcode = (int)MANDOCLEVEL_SYSERR; |
exitcode = (int)MANDOCLEVEL_SYSERR; |
goto out; |
goto out; |
|
} |
} |
} |
#endif |
#endif |
use_all = 1; |
use_all = 1; |
Line 1291 parse_cat(struct mpage *mpage, int fd) |
|
Line 1294 parse_cat(struct mpage *mpage, int fd) |
|
{ |
{ |
FILE *stream; |
FILE *stream; |
char *line, *p, *title; |
char *line, *p, *title; |
size_t len, plen, titlesz; |
size_t linesz, plen, titlesz; |
|
ssize_t len; |
|
int offs; |
|
|
stream = (-1 == fd) ? |
stream = (-1 == fd) ? |
fopen(mpage->mlinks->file, "r") : |
fopen(mpage->mlinks->file, "r") : |
Line 1304 parse_cat(struct mpage *mpage, int fd) |
|
Line 1309 parse_cat(struct mpage *mpage, int fd) |
|
return; |
return; |
} |
} |
|
|
|
line = NULL; |
|
linesz = 0; |
|
|
/* Skip to first blank line. */ |
/* Skip to first blank line. */ |
|
|
while (NULL != (line = fgetln(stream, &len))) |
while (getline(&line, &linesz, stream) != -1) |
if ('\n' == *line) |
if (*line == '\n') |
break; |
break; |
|
|
/* |
/* |
Line 1315 parse_cat(struct mpage *mpage, int fd) |
|
Line 1323 parse_cat(struct mpage *mpage, int fd) |
|
* is the first section header. Skip to it. |
* is the first section header. Skip to it. |
*/ |
*/ |
|
|
while (NULL != (line = fgetln(stream, &len))) |
while (getline(&line, &linesz, stream) != -1) |
if ('\n' != *line && ' ' != *line) |
if (*line != '\n' && *line != ' ') |
break; |
break; |
|
|
/* |
/* |
Line 1329 parse_cat(struct mpage *mpage, int fd) |
|
Line 1337 parse_cat(struct mpage *mpage, int fd) |
|
titlesz = 0; |
titlesz = 0; |
title = NULL; |
title = NULL; |
|
|
while (NULL != (line = fgetln(stream, &len))) { |
while ((len = getline(&line, &linesz, stream)) != -1) { |
if (' ' != *line || '\n' != line[len - 1]) |
if (*line != ' ') |
break; |
break; |
while (len > 0 && isspace((unsigned char)*line)) { |
offs = 0; |
line++; |
while (isspace((unsigned char)line[offs])) |
len--; |
offs++; |
} |
if (line[offs] == '\0') |
if (1 == len) |
|
continue; |
continue; |
title = mandoc_realloc(title, titlesz + len); |
title = mandoc_realloc(title, titlesz + len - offs); |
memcpy(title + titlesz, line, len); |
memcpy(title + titlesz, line + offs, len - offs); |
titlesz += len; |
titlesz += len - offs; |
title[titlesz - 1] = ' '; |
title[titlesz - 1] = ' '; |
} |
} |
|
free(line); |
|
|
/* |
/* |
* If no page content can be found, or the input line |
* If no page content can be found, or the input line |
Line 1360 parse_cat(struct mpage *mpage, int fd) |
|
Line 1368 parse_cat(struct mpage *mpage, int fd) |
|
return; |
return; |
} |
} |
|
|
title = mandoc_realloc(title, titlesz + 1); |
title[titlesz - 1] = '\0'; |
title[titlesz] = '\0'; |
|
|
|
/* |
/* |
* Skip to the first dash. |
* Skip to the first dash. |