version 1.68, 2013/06/07 05:27:50 |
version 1.71, 2013/07/02 13:26:52 |
|
|
char *arch; /* path-cued arch. (or empty) */ |
char *arch; /* path-cued arch. (or empty) */ |
}; |
}; |
|
|
|
struct title { |
|
char *title; /* name(sec/arch) given inside the file */ |
|
char *file; /* file name in case of mismatch */ |
|
}; |
|
|
enum stmt { |
enum stmt { |
STMT_DELETE = 0, /* delete manpage */ |
STMT_DELETE = 0, /* delete manpage */ |
STMT_INSERT_DOC, /* insert manpage */ |
STMT_INSERT_DOC, /* insert manpage */ |
Line 135 static int inocheck(const struct stat *); |
|
Line 140 static int inocheck(const struct stat *); |
|
static void ofadd(int, const char *, const char *, const char *, |
static void ofadd(int, const char *, const char *, const char *, |
const char *, const char *, const struct stat *); |
const char *, const char *, const struct stat *); |
static void offree(void); |
static void offree(void); |
static void ofmerge(struct mchars *, struct mparse *, |
static void ofmerge(struct mchars *, struct mparse *, int); |
struct ohash_info*); |
|
static void parse_catpage(struct of *); |
static void parse_catpage(struct of *); |
static void parse_man(struct of *, const struct man_node *); |
static void parse_man(struct of *, const struct man_node *); |
static void parse_mdoc(struct of *, const struct mdoc_node *); |
static void parse_mdoc(struct of *, const struct mdoc_node *); |
Line 311 main(int argc, char *argv[]) |
|
Line 315 main(int argc, char *argv[]) |
|
struct mchars *mc; |
struct mchars *mc; |
struct manpaths dirs; |
struct manpaths dirs; |
struct mparse *mp; |
struct mparse *mp; |
struct ohash_info ino_info, filename_info, str_info; |
struct ohash_info ino_info, filename_info; |
|
|
memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *)); |
memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *)); |
memset(&dirs, 0, sizeof(struct manpaths)); |
memset(&dirs, 0, sizeof(struct manpaths)); |
|
|
ino_info.halloc = filename_info.halloc = |
ino_info.alloc = filename_info.alloc = hash_alloc; |
str_info.halloc = hash_halloc; |
ino_info.halloc = filename_info.halloc = hash_halloc; |
ino_info.hfree = filename_info.hfree = |
ino_info.hfree = filename_info.hfree = hash_free; |
str_info.hfree = hash_free; |
|
ino_info.alloc = filename_info.alloc = |
|
str_info.alloc = hash_alloc; |
|
|
|
ino_info.key_offset = offsetof(struct of, id); |
ino_info.key_offset = offsetof(struct of, id); |
filename_info.key_offset = offsetof(struct of, file); |
filename_info.key_offset = offsetof(struct of, file); |
str_info.key_offset = offsetof(struct str, key); |
|
|
|
progname = strrchr(argv[0], '/'); |
progname = strrchr(argv[0], '/'); |
if (progname == NULL) |
if (progname == NULL) |
Line 422 main(int argc, char *argv[]) |
|
Line 422 main(int argc, char *argv[]) |
|
if (OP_TEST != op) |
if (OP_TEST != op) |
dbprune(); |
dbprune(); |
if (OP_DELETE != op) |
if (OP_DELETE != op) |
ofmerge(mc, mp, &str_info); |
ofmerge(mc, mp, 0); |
dbclose(1); |
dbclose(1); |
} else { |
} else { |
/* |
/* |
Line 440 main(int argc, char *argv[]) |
|
Line 440 main(int argc, char *argv[]) |
|
manpath_parse(&dirs, path_arg, NULL, NULL); |
manpath_parse(&dirs, path_arg, NULL, NULL); |
|
|
/* |
/* |
* First scan the tree rooted at a base directory. |
* First scan the tree rooted at a base directory, then |
* Then whak its database (if one exists), parse, and |
* build a new database and finally move it into place. |
* build up the database. |
|
* Ignore zero-length directories and strip trailing |
* Ignore zero-length directories and strip trailing |
* slashes. |
* slashes. |
*/ |
*/ |
Line 467 main(int argc, char *argv[]) |
|
Line 466 main(int argc, char *argv[]) |
|
if (0 == dbopen(0)) |
if (0 == dbopen(0)) |
goto out; |
goto out; |
|
|
/* |
ofmerge(mc, mp, warnings && !use_all); |
* Since we're opening up a new database, we can |
|
* turn off synchronous mode for much better |
|
* performance. |
|
*/ |
|
#ifndef __APPLE__ |
|
SQL_EXEC("PRAGMA synchronous = OFF"); |
|
#endif |
|
|
|
ofmerge(mc, mp, &str_info); |
|
dbclose(0); |
dbclose(0); |
|
|
if (j + 1 < dirs.sz) { |
if (j + 1 < dirs.sz) { |
|
|
* and filename to determine whether the file is parsable or not. |
* and filename to determine whether the file is parsable or not. |
*/ |
*/ |
static void |
static void |
ofmerge(struct mchars *mc, struct mparse *mp, |
ofmerge(struct mchars *mc, struct mparse *mp, int check_reachable) |
struct ohash_info *infop) |
|
{ |
{ |
int form; |
struct ohash title_table; |
size_t sz; |
struct ohash_info title_info, str_info; |
struct mdoc *mdoc; |
char buf[PATH_MAX]; |
struct man *man; |
struct of *of; |
char buf[PATH_MAX]; |
struct mdoc *mdoc; |
char *bufp; |
struct man *man; |
const char *msec, *march, *mtitle, *cp; |
struct title *title_entry; |
struct of *of; |
char *bufp, *title_str; |
enum mandoclevel lvl; |
const char *msec, *march, *mtitle, *cp; |
|
size_t sz; |
|
int form; |
|
int match; |
|
unsigned int slot; |
|
enum mandoclevel lvl; |
|
|
|
str_info.alloc = hash_alloc; |
|
str_info.halloc = hash_halloc; |
|
str_info.hfree = hash_free; |
|
str_info.key_offset = offsetof(struct str, key); |
|
|
|
if (check_reachable) { |
|
title_info.alloc = hash_alloc; |
|
title_info.halloc = hash_halloc; |
|
title_info.hfree = hash_free; |
|
title_info.key_offset = offsetof(struct title, title); |
|
ohash_init(&title_table, 6, &title_info); |
|
} |
|
|
for (of = ofs; NULL != of; of = of->next) { |
for (of = ofs; NULL != of; of = of->next) { |
/* |
/* |
* If we're a catpage (as defined by our path), then see |
* If we're a catpage (as defined by our path), then see |
Line 939 ofmerge(struct mchars *mc, struct mparse *mp, |
|
Line 946 ofmerge(struct mchars *mc, struct mparse *mp, |
|
} |
} |
} |
} |
|
|
ohash_init(&strings, 6, infop); |
ohash_init(&strings, 6, &str_info); |
mparse_reset(mp); |
mparse_reset(mp); |
mdoc = NULL; |
mdoc = NULL; |
man = NULL; |
man = NULL; |
Line 947 ofmerge(struct mchars *mc, struct mparse *mp, |
|
Line 954 ofmerge(struct mchars *mc, struct mparse *mp, |
|
msec = of->dsec; |
msec = of->dsec; |
march = of->arch; |
march = of->arch; |
mtitle = of->name; |
mtitle = of->name; |
|
match = 1; |
|
|
/* |
/* |
* Try interpreting the file as mdoc(7) or man(7) |
* Try interpreting the file as mdoc(7) or man(7) |
Line 988 ofmerge(struct mchars *mc, struct mparse *mp, |
|
Line 996 ofmerge(struct mchars *mc, struct mparse *mp, |
|
* manuals for such reasons. |
* manuals for such reasons. |
*/ |
*/ |
if (warnings && !use_all && form && |
if (warnings && !use_all && form && |
strcasecmp(msec, of->dsec)) |
strcasecmp(msec, of->dsec)) { |
|
match = 0; |
say(of->file, "Section \"%s\" " |
say(of->file, "Section \"%s\" " |
"manual in %s directory", |
"manual in %s directory", |
msec, of->dsec); |
msec, of->dsec); |
|
} |
|
|
/* |
/* |
* Manual page directories exist for each kernel |
* Manual page directories exist for each kernel |
Line 1007 ofmerge(struct mchars *mc, struct mparse *mp, |
|
Line 1017 ofmerge(struct mchars *mc, struct mparse *mp, |
|
* Thus, warn about architecture mismatches, |
* Thus, warn about architecture mismatches, |
* but don't skip manuals for this reason. |
* but don't skip manuals for this reason. |
*/ |
*/ |
if (warnings && !use_all && strcasecmp(march, of->arch)) |
if (warnings && !use_all && strcasecmp(march, of->arch)) { |
|
match = 0; |
say(of->file, "Architecture \"%s\" " |
say(of->file, "Architecture \"%s\" " |
"manual in \"%s\" directory", |
"manual in \"%s\" directory", |
march, of->arch); |
march, of->arch); |
|
} |
|
if (warnings && !use_all && strcasecmp(mtitle, of->name)) |
|
match = 0; |
|
|
putkey(of, of->name, TYPE_Nm); |
putkey(of, of->name, TYPE_Nm); |
|
|
Line 1026 ofmerge(struct mchars *mc, struct mparse *mp, |
|
Line 1040 ofmerge(struct mchars *mc, struct mparse *mp, |
|
else |
else |
parse_catpage(of); |
parse_catpage(of); |
|
|
|
/* |
|
* Build a title string for the file. If it matches |
|
* the location of the file, remember the title as |
|
* found; else, remember it as missing. |
|
*/ |
|
|
|
if (check_reachable) { |
|
if (-1 == asprintf(&title_str, "%s(%s%s%s)", mtitle, |
|
msec, '\0' == *march ? "" : "/", march)) { |
|
perror(NULL); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
slot = ohash_qlookup(&title_table, title_str); |
|
title_entry = ohash_find(&title_table, slot); |
|
if (NULL == title_entry) { |
|
title_entry = mandoc_malloc( |
|
sizeof(struct title)); |
|
title_entry->title = title_str; |
|
title_entry->file = mandoc_strdup( |
|
match ? "" : of->file); |
|
ohash_insert(&title_table, slot, |
|
title_entry); |
|
} else { |
|
if (match) |
|
*title_entry->file = '\0'; |
|
free(title_str); |
|
} |
|
} |
|
|
dbindex(mc, form, of); |
dbindex(mc, form, of); |
ohash_delete(&strings); |
ohash_delete(&strings); |
} |
} |
|
|
|
if (check_reachable) { |
|
title_entry = ohash_first(&title_table, &slot); |
|
while (NULL != title_entry) { |
|
if ('\0' != *title_entry->file) |
|
say(title_entry->file, |
|
"Probably unreachable, title is %s", |
|
title_entry->title); |
|
free(title_entry->title); |
|
free(title_entry->file); |
|
free(title_entry); |
|
title_entry = ohash_next(&title_table, &slot); |
|
} |
|
ohash_delete(&title_table); |
|
} |
} |
} |
|
|
static void |
static void |
Line 1904 prepare_statements: |
|
Line 1962 prepare_statements: |
|
sql = "INSERT INTO keys " |
sql = "INSERT INTO keys " |
"(bits,key,docid) VALUES (?,?,?)"; |
"(bits,key,docid) VALUES (?,?,?)"; |
sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_KEY], NULL); |
sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_KEY], NULL); |
|
|
|
#ifndef __APPLE__ |
|
/* |
|
* When opening a new database, we can turn off |
|
* synchronous mode for much better performance. |
|
*/ |
|
|
|
if (real) |
|
SQL_EXEC("PRAGMA synchronous = OFF"); |
|
#endif |
|
|
return(1); |
return(1); |
} |
} |
|
|