version 1.162, 2014/09/03 23:21:47 |
version 1.167, 2014/10/27 13:31:04 |
Line 169 static void putmdockey(const struct mpage *, |
|
Line 169 static void putmdockey(const struct mpage *, |
|
const struct mdoc_node *, uint64_t); |
const struct mdoc_node *, uint64_t); |
static void render_key(struct mchars *, struct str *); |
static void render_key(struct mchars *, struct str *); |
static void say(const char *, const char *, ...); |
static void say(const char *, const char *, ...); |
static int set_basedir(const char *); |
static int set_basedir(const char *, int); |
static int treescan(void); |
static int treescan(void); |
static size_t utf8(unsigned int, char [7]); |
static size_t utf8(unsigned int, char [7]); |
|
|
Line 315 static const struct mdoc_handler mdocs[MDOC_MAX] = { |
|
Line 315 static const struct mdoc_handler mdocs[MDOC_MAX] = { |
|
{ NULL, 0 }, /* sp */ |
{ NULL, 0 }, /* sp */ |
{ NULL, 0 }, /* %U */ |
{ NULL, 0 }, /* %U */ |
{ NULL, 0 }, /* Ta */ |
{ NULL, 0 }, /* Ta */ |
|
{ NULL, 0 }, /* ll */ |
}; |
}; |
|
|
|
|
Line 436 main(int argc, char *argv[]) |
|
Line 437 main(int argc, char *argv[]) |
|
* Most of these deal with a specific directory. |
* Most of these deal with a specific directory. |
* Jump into that directory first. |
* Jump into that directory first. |
*/ |
*/ |
if (OP_TEST != op && 0 == set_basedir(path_arg)) |
if (OP_TEST != op && 0 == set_basedir(path_arg, 1)) |
goto out; |
goto out; |
|
|
if (dbopen(1)) { |
if (dbopen(1)) { |
Line 502 main(int argc, char *argv[]) |
|
Line 503 main(int argc, char *argv[]) |
|
ohash_init(&mlinks, 6, &mlinks_info); |
ohash_init(&mlinks, 6, &mlinks_info); |
} |
} |
|
|
if (0 == set_basedir(dirs.paths[j])) |
if (0 == set_basedir(dirs.paths[j], argc > 0)) |
goto out; |
continue; |
if (0 == treescan()) |
if (0 == treescan()) |
goto out; |
continue; |
if (0 == dbopen(0)) |
if (0 == dbopen(0)) |
goto out; |
continue; |
|
|
mpages_merge(mc, mp); |
mpages_merge(mc, mp); |
if (warnings && !nodb && |
if (warnings && !nodb && |
Line 1196 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1197 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
if (mpage->mlinks->gzip) |
if (mpage->mlinks->gzip) |
mpage->form |= FORM_GZ; |
mpage->form |= FORM_GZ; |
putkey(mpage, mpage->sec, TYPE_sec); |
putkey(mpage, mpage->sec, TYPE_sec); |
putkey(mpage, '\0' == *mpage->arch ? |
if (*mpage->arch != '\0') |
any : mpage->arch, TYPE_arch); |
putkey(mpage, mpage->arch, TYPE_arch); |
|
|
for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { |
for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { |
if ('\0' != *mlink->dsec) |
if ('\0' != *mlink->dsec) |
Line 1735 putkeys(const struct mpage *mpage, |
|
Line 1736 putkeys(const struct mpage *mpage, |
|
htab = &strings; |
htab = &strings; |
if (debug > 1) |
if (debug > 1) |
for (i = 0; i < mansearch_keymax; i++) |
for (i = 0; i < mansearch_keymax; i++) |
if (1 << i & v) |
if ((uint64_t)1 << i & v) |
say(mpage->mlinks->file, |
say(mpage->mlinks->file, |
"Adding key %s=%*s", |
"Adding key %s=%*s", |
mansearch_keynames[i], sz, cp); |
mansearch_keynames[i], sz, cp); |
Line 1902 render_key(struct mchars *mc, struct str *key) |
|
Line 1903 render_key(struct mchars *mc, struct str *key) |
|
*/ |
*/ |
|
|
if (write_utf8) { |
if (write_utf8) { |
if (0 == (u = mchars_spec2cp(mc, seq, len))) |
if ((u = mchars_spec2cp(mc, seq, len)) <= 0) |
continue; |
continue; |
cpp = utfbuf; |
cpp = utfbuf; |
if (0 == (sz = utf8(u, utfbuf))) |
if (0 == (sz = utf8(u, utfbuf))) |
Line 2343 hash_free(void *p, void *arg) |
|
Line 2344 hash_free(void *p, void *arg) |
|
} |
} |
|
|
static int |
static int |
set_basedir(const char *targetdir) |
set_basedir(const char *targetdir, int report_baddir) |
{ |
{ |
static char startdir[PATH_MAX]; |
static char startdir[PATH_MAX]; |
static int getcwd_status; /* 1 = ok, 2 = failure */ |
static int getcwd_status; /* 1 = ok, 2 = failure */ |
Line 2396 set_basedir(const char *targetdir) |
|
Line 2397 set_basedir(const char *targetdir) |
|
* we can reliably check whether files are inside. |
* we can reliably check whether files are inside. |
*/ |
*/ |
if (NULL == realpath(targetdir, basedir)) { |
if (NULL == realpath(targetdir, basedir)) { |
exitcode = (int)MANDOCLEVEL_BADARG; |
if (report_baddir || errno != ENOENT) { |
say("", "&%s: realpath", targetdir); |
exitcode = (int)MANDOCLEVEL_BADARG; |
|
say("", "&%s: realpath", targetdir); |
|
} |
return(0); |
return(0); |
} else if (-1 == chdir(basedir)) { |
} else if (-1 == chdir(basedir)) { |
exitcode = (int)MANDOCLEVEL_BADARG; |
if (report_baddir || errno != ENOENT) { |
say("", "&chdir"); |
exitcode = (int)MANDOCLEVEL_BADARG; |
|
say("", "&chdir"); |
|
} |
return(0); |
return(0); |
} |
} |
chdir_status = 1; |
chdir_status = 1; |