=================================================================== RCS file: /cvs/mandoc/mandocdb.c,v retrieving revision 1.164 retrieving revision 1.167 diff -u -p -r1.164 -r1.167 --- mandoc/mandocdb.c 2014/09/07 03:08:47 1.164 +++ mandoc/mandocdb.c 2014/10/27 13:31:04 1.167 @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.164 2014/09/07 03:08:47 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.167 2014/10/27 13:31:04 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -169,7 +169,7 @@ static void putmdockey(const struct mpage *, const struct mdoc_node *, uint64_t); static void render_key(struct mchars *, struct str *); 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 size_t utf8(unsigned int, char [7]); @@ -315,6 +315,7 @@ static const struct mdoc_handler mdocs[MDOC_MAX] = { { NULL, 0 }, /* sp */ { NULL, 0 }, /* %U */ { NULL, 0 }, /* Ta */ + { NULL, 0 }, /* ll */ }; @@ -436,7 +437,7 @@ main(int argc, char *argv[]) * Most of these deal with a specific directory. * 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; if (dbopen(1)) { @@ -502,12 +503,12 @@ main(int argc, char *argv[]) ohash_init(&mlinks, 6, &mlinks_info); } - if (0 == set_basedir(dirs.paths[j])) - goto out; + if (0 == set_basedir(dirs.paths[j], argc > 0)) + continue; if (0 == treescan()) - goto out; + continue; if (0 == dbopen(0)) - goto out; + continue; mpages_merge(mc, mp); if (warnings && !nodb && @@ -1902,7 +1903,7 @@ render_key(struct mchars *mc, struct str *key) */ if (write_utf8) { - if (0 == (u = mchars_spec2cp(mc, seq, len))) + if ((u = mchars_spec2cp(mc, seq, len)) <= 0) continue; cpp = utfbuf; if (0 == (sz = utf8(u, utfbuf))) @@ -2343,7 +2344,7 @@ hash_free(void *p, void *arg) } static int -set_basedir(const char *targetdir) +set_basedir(const char *targetdir, int report_baddir) { static char startdir[PATH_MAX]; static int getcwd_status; /* 1 = ok, 2 = failure */ @@ -2396,12 +2397,16 @@ set_basedir(const char *targetdir) * we can reliably check whether files are inside. */ if (NULL == realpath(targetdir, basedir)) { - exitcode = (int)MANDOCLEVEL_BADARG; - say("", "&%s: realpath", targetdir); + if (report_baddir || errno != ENOENT) { + exitcode = (int)MANDOCLEVEL_BADARG; + say("", "&%s: realpath", targetdir); + } return(0); } else if (-1 == chdir(basedir)) { - exitcode = (int)MANDOCLEVEL_BADARG; - say("", "&chdir"); + if (report_baddir || errno != ENOENT) { + exitcode = (int)MANDOCLEVEL_BADARG; + say("", "&chdir"); + } return(0); } chdir_status = 1;