version 1.124, 2014/03/26 21:39:38 |
version 1.128, 2014/04/04 02:31:07 |
Line 179 static char *progname; |
|
Line 179 static char *progname; |
|
static int nodb; /* no database changes */ |
static int nodb; /* no database changes */ |
static int mparse_options; /* abort the parse early */ |
static int mparse_options; /* abort the parse early */ |
static int use_all; /* use all found files */ |
static int use_all; /* use all found files */ |
static int verb; /* print what we're doing */ |
static int debug; /* print what we're doing */ |
static int warnings; /* warn about crap */ |
static int warnings; /* warn about crap */ |
static int write_utf8; /* write UTF-8 output; else ASCII */ |
static int write_utf8; /* write UTF-8 output; else ASCII */ |
static int exitcode; /* to be returned by main */ |
static int exitcode; /* to be returned by main */ |
Line 357 main(int argc, char *argv[]) |
|
Line 357 main(int argc, char *argv[]) |
|
path_arg = NULL; |
path_arg = NULL; |
op = OP_DEFAULT; |
op = OP_DEFAULT; |
|
|
while (-1 != (ch = getopt(argc, argv, "aC:d:nQT:tu:vW"))) |
while (-1 != (ch = getopt(argc, argv, "aC:Dd:npQT:tu:v"))) |
switch (ch) { |
switch (ch) { |
case ('a'): |
case ('a'): |
use_all = 1; |
use_all = 1; |
Line 367 main(int argc, char *argv[]) |
|
Line 367 main(int argc, char *argv[]) |
|
path_arg = optarg; |
path_arg = optarg; |
op = OP_CONFFILE; |
op = OP_CONFFILE; |
break; |
break; |
|
case ('D'): |
|
debug++; |
|
break; |
case ('d'): |
case ('d'): |
CHECKOP(op, ch); |
CHECKOP(op, ch); |
path_arg = optarg; |
path_arg = optarg; |
Line 375 main(int argc, char *argv[]) |
|
Line 378 main(int argc, char *argv[]) |
|
case ('n'): |
case ('n'): |
nodb = 1; |
nodb = 1; |
break; |
break; |
|
case ('p'): |
|
warnings = 1; |
|
break; |
case ('Q'): |
case ('Q'): |
mparse_options |= MPARSE_QUICK; |
mparse_options |= MPARSE_QUICK; |
break; |
break; |
Line 398 main(int argc, char *argv[]) |
|
Line 404 main(int argc, char *argv[]) |
|
op = OP_DELETE; |
op = OP_DELETE; |
break; |
break; |
case ('v'): |
case ('v'): |
verb++; |
/* Compatibility with espie@'s makewhatis. */ |
break; |
break; |
case ('W'): |
|
warnings = 1; |
|
break; |
|
default: |
default: |
goto usage; |
goto usage; |
} |
} |
Line 459 main(int argc, char *argv[]) |
|
Line 462 main(int argc, char *argv[]) |
|
} else |
} else |
manpath_parse(&dirs, path_arg, NULL, NULL); |
manpath_parse(&dirs, path_arg, NULL, NULL); |
|
|
|
if (0 == dirs.sz) { |
|
exitcode = (int)MANDOCLEVEL_BADARG; |
|
say("", "Empty manpath"); |
|
} |
|
|
/* |
/* |
* First scan the tree rooted at a base directory, then |
* First scan the tree rooted at a base directory, then |
* build a new database and finally move it into place. |
* build a new database and finally move it into place. |
|
|
ohash_delete(&mlinks); |
ohash_delete(&mlinks); |
return(exitcode); |
return(exitcode); |
usage: |
usage: |
fprintf(stderr, "usage: %s [-anQvW] [-C file] [-Tutf8]\n" |
fprintf(stderr, "usage: %s [-aDnpQ] [-C file] [-Tutf8]\n" |
" %s [-anQvW] [-Tutf8] dir ...\n" |
" %s [-aDnpQ] [-Tutf8] dir ...\n" |
" %s [-nQvW] [-Tutf8] -d dir [file ...]\n" |
" %s [-DnpQ] [-Tutf8] -d dir [file ...]\n" |
" %s [-nvW] -u dir [file ...]\n" |
" %s [-Dnp] -u dir [file ...]\n" |
" %s [-Q] -t file ...\n", |
" %s [-Q] -t file ...\n", |
progname, progname, progname, |
progname, progname, progname, |
progname, progname); |
progname, progname); |
Line 1623 putkeys(const struct mpage *mpage, |
|
Line 1631 putkeys(const struct mpage *mpage, |
|
if (0 == sz) |
if (0 == sz) |
return; |
return; |
|
|
if (verb > 1) { |
if (debug > 1) { |
for (i = 0, mask = 1; |
for (i = 0, mask = 1; |
i < mansearch_keymax; |
i < mansearch_keymax; |
i++, mask <<= 1) |
i++, mask <<= 1) |
Line 1850 dbadd(struct mpage *mpage, struct mchars *mc) |
|
Line 1858 dbadd(struct mpage *mpage, struct mchars *mc) |
|
size_t i; |
size_t i; |
unsigned int slot; |
unsigned int slot; |
|
|
if (verb) |
mlink = mpage->mlinks; |
say(mpage->mlinks->file, "Adding to database"); |
|
|
|
if (nodb) |
if (nodb) { |
|
while (NULL != mlink) { |
|
fputs(mlink->name, stdout); |
|
if (NULL == mlink->next || |
|
strcmp(mlink->dsec, mlink->next->dsec) || |
|
strcmp(mlink->fsec, mlink->next->fsec) || |
|
strcmp(mlink->arch, mlink->next->arch)) { |
|
putchar('('); |
|
if ('\0' == *mlink->dsec) |
|
fputs(mlink->fsec, stdout); |
|
else |
|
fputs(mlink->dsec, stdout); |
|
if ('\0' != *mlink->arch) |
|
printf("/%s", mlink->arch); |
|
putchar(')'); |
|
} |
|
mlink = mlink->next; |
|
if (NULL != mlink) |
|
fputs(", ", stdout); |
|
} |
|
for (key = ohash_first(&strings, &slot); NULL != key; |
|
key = ohash_next(&strings, &slot)) { |
|
if (TYPE_Nd & key->mask) { |
|
if (NULL == key->rendered) |
|
render_key(mc, key); |
|
printf(" - %s", key->rendered); |
|
break; |
|
} |
|
} |
|
putchar('\n'); |
return; |
return; |
|
} |
|
|
|
if (debug) |
|
say(mlink->file, "Adding to database"); |
|
|
i = 1; |
i = 1; |
SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); |
SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); |
SQL_STEP(stmts[STMT_INSERT_PAGE]); |
SQL_STEP(stmts[STMT_INSERT_PAGE]); |
mpage->recno = sqlite3_last_insert_rowid(db); |
mpage->recno = sqlite3_last_insert_rowid(db); |
sqlite3_reset(stmts[STMT_INSERT_PAGE]); |
sqlite3_reset(stmts[STMT_INSERT_PAGE]); |
|
|
for (mlink = mpage->mlinks; mlink; mlink = mlink->next) |
while (NULL != mlink) { |
dbadd_mlink(mlink); |
dbadd_mlink(mlink); |
|
mlink = mlink->next; |
|
} |
|
|
for (key = ohash_first(&strings, &slot); NULL != key; |
for (key = ohash_first(&strings, &slot); NULL != key; |
key = ohash_next(&strings, &slot)) { |
key = ohash_next(&strings, &slot)) { |
|
|
for (mpage = ohash_first(&mpages, &slot); NULL != mpage; |
for (mpage = ohash_first(&mpages, &slot); NULL != mpage; |
mpage = ohash_next(&mpages, &slot)) { |
mpage = ohash_next(&mpages, &slot)) { |
mlink = mpage->mlinks; |
mlink = mpage->mlinks; |
if (verb) |
if (debug) |
say(mlink->file, "Deleting from database"); |
say(mlink->file, "Deleting from database"); |
if (nodb) |
if (nodb) |
continue; |
continue; |