version 1.164, 2014/09/07 03:08:47 |
version 1.165, 2014/09/09 19:35:25 |
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 436 main(int argc, char *argv[]) |
|
Line 436 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 502 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 2343 hash_free(void *p, void *arg) |
|
Line 2343 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 2396 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; |