aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-06-05 20:27:11 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-06-05 20:27:11 +0000
commite8650b840ae4e1ba0284839c64d8a503a4cd49f1 (patch)
treeb48630b99ec09854e1d827c28a62f9f73a8661c5
parent8e4a0843a98aff5640c1b35c131853a039780b5f (diff)
downloadmandoc-e8650b840ae4e1ba0284839c64d8a503a4cd49f1.tar.gz
mandoc-e8650b840ae4e1ba0284839c64d8a503a4cd49f1.tar.zst
mandoc-e8650b840ae4e1ba0284839c64d8a503a4cd49f1.zip
Two sanity checks got lost in treescan()
during the switch from db to sqlite; restore these: * Warn and skip when directory and file name mismatch. * Warn and skip when finding special files. * Warning about "mandocdb.db" is useless, it is always present. * While here, do not hardcode "mandocdb.db", use MANDOC_DB.
-rw-r--r--mandocdb.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 0e640672..719a0874 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.59 2013/06/05 17:48:14 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.60 2013/06/05 20:27:11 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>
@@ -567,6 +567,8 @@ treescan(void)
* Disallow duplicate (hard-linked) files.
*/
if (FTS_F == ff->fts_info) {
+ if (0 == strcmp(path, MANDOC_DB))
+ continue;
if ( ! use_all && ff->fts_level < 2) {
if (warnings)
say(path, "Extraneous file");
@@ -575,45 +577,50 @@ treescan(void)
if (warnings)
say(path, "Duplicate file");
continue;
- }
-
- cp = ff->fts_name;
-
- if (0 == strcmp(cp, "mandocdb.db")) {
- if (warnings)
- say(path, "Skip database");
- continue;
- } else if (NULL != (cp = strrchr(cp, '.'))) {
- if (0 == strcmp(cp + 1, "html")) {
+ } else if (NULL == (sec =
+ strrchr(ff->fts_name, '.'))) {
+ if ( ! use_all) {
if (warnings)
- say(path, "Skip html");
- continue;
- } else if (0 == strcmp(cp + 1, "gz")) {
- if (warnings)
- say(path, "Skip gz");
- continue;
- } else if (0 == strcmp(cp + 1, "ps")) {
- if (warnings)
- say(path, "Skip ps");
- continue;
- } else if (0 == strcmp(cp + 1, "pdf")) {
- if (warnings)
- say(path, "Skip pdf");
+ say(path,
+ "No filename suffix");
continue;
}
- }
-
- if (NULL != (sec = strrchr(ff->fts_name, '.'))) {
- *sec = '\0';
- sec = stradd(sec + 1);
+ } else if (0 == strcmp(++sec, "html")) {
+ if (warnings)
+ say(path, "Skip html");
+ continue;
+ } else if (0 == strcmp(sec, "gz")) {
+ if (warnings)
+ say(path, "Skip gz");
+ continue;
+ } else if (0 == strcmp(sec, "ps")) {
+ if (warnings)
+ say(path, "Skip ps");
+ continue;
+ } else if (0 == strcmp(sec, "pdf")) {
+ if (warnings)
+ say(path, "Skip pdf");
+ continue;
+ } else if ( ! use_all &&
+ ((FORM_SRC == dform && strcmp(sec, dsec)) ||
+ (FORM_CAT == dform && strcmp(sec, "0")))) {
+ if (warnings)
+ say(path, "Wrong filename suffix");
+ continue;
+ } else {
+ sec[-1] = '\0';
+ sec = stradd(sec);
}
name = stradd(ff->fts_name);
ofadd(dform, path,
name, dsec, sec, arch, ff->fts_statp);
continue;
} else if (FTS_D != ff->fts_info &&
- FTS_DP != ff->fts_info)
+ FTS_DP != ff->fts_info) {
+ if (warnings)
+ say(path, "Not a regular file");
continue;
+ }
switch (ff->fts_level) {
case (0):