version 1.22, 2014/03/17 16:31:44 |
version 1.25, 2014/03/28 19:17:12 |
|
|
#include <sqlite3.h> |
#include <sqlite3.h> |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "manpath.h" |
#include "manpath.h" |
#include "mansearch.h" |
#include "mansearch.h" |
|
|
Line 309 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
Line 310 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
size_t i; |
size_t i; |
int c; |
int c; |
|
|
|
mpage->file = NULL; |
mpage->names = NULL; |
mpage->names = NULL; |
prevsec = prevarch = NULL; |
prevsec = prevarch = NULL; |
i = 1; |
i = 1; |
Line 337 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
Line 339 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
(strcmp(sec, prevsec) || |
(strcmp(sec, prevsec) || |
strcmp(arch, prevarch))) { |
strcmp(arch, prevarch))) { |
sep2 = '\0' == *prevarch ? "" : "/"; |
sep2 = '\0' == *prevarch ? "" : "/"; |
if (-1 == asprintf(&newnames, "%s(%s%s%s)", |
mandoc_asprintf(&newnames, "%s(%s%s%s)", |
oldnames, prevsec, sep2, prevarch)) { |
oldnames, prevsec, sep2, prevarch); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
free(mpage->names); |
free(mpage->names); |
oldnames = mpage->names = newnames; |
oldnames = mpage->names = newnames; |
free(prevsec); |
free(prevsec); |
Line 358 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
Line 357 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
|
|
/* Append the new name. */ |
/* Append the new name. */ |
|
|
if (-1 == asprintf(&newnames, "%s%s%s", |
mandoc_asprintf(&newnames, "%s%s%s", |
oldnames, sep1, name)) { |
oldnames, sep1, name); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
free(mpage->names); |
free(mpage->names); |
mpage->names = newnames; |
mpage->names = newnames; |
|
|
Line 379 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
Line 375 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
fsec = "0"; |
fsec = "0"; |
} |
} |
sep2 = '\0' == *arch ? "" : "/"; |
sep2 = '\0' == *arch ? "" : "/"; |
if (-1 == asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s", |
mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s", |
path, sep1, sec, sep2, arch, name, fsec)) { |
path, sep1, sec, sep2, arch, name, fsec); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
} |
} |
if (SQLITE_DONE != c) |
if (SQLITE_DONE != c) |
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
Line 393 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
Line 386 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3 |
|
|
|
if (NULL != prevsec) { |
if (NULL != prevsec) { |
sep2 = '\0' == *prevarch ? "" : "/"; |
sep2 = '\0' == *prevarch ? "" : "/"; |
if (-1 == asprintf(&newnames, "%s(%s%s%s)", |
mandoc_asprintf(&newnames, "%s(%s%s%s)", |
mpage->names, prevsec, sep2, prevarch)) { |
mpage->names, prevsec, sep2, prevarch); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
free(mpage->names); |
free(mpage->names); |
mpage->names = newnames; |
mpage->names = newnames; |
free(prevsec); |
free(prevsec); |
Line 426 buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t id, |
|
Line 416 buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t id, |
|
sep1 = " # "; |
sep1 = " # "; |
} |
} |
data = sqlite3_column_text(s, 1); |
data = sqlite3_column_text(s, 1); |
if (-1 == asprintf(&newoutput, "%s%s%s", |
mandoc_asprintf(&newoutput, "%s%s%s", |
oldoutput, sep1, data)) { |
oldoutput, sep1, data); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
free(output); |
free(output); |
output = newoutput; |
output = newoutput; |
} |
} |
Line 602 exprspec(struct expr *cur, uint64_t key, const char *v |
|
Line 589 exprspec(struct expr *cur, uint64_t key, const char *v |
|
if (NULL == value) |
if (NULL == value) |
return(cur); |
return(cur); |
|
|
if (-1 == asprintf(&cp, format, value)) { |
mandoc_asprintf(&cp, format, value); |
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
cur->next = mandoc_calloc(1, sizeof(struct expr)); |
cur->next = mandoc_calloc(1, sizeof(struct expr)); |
cur = cur->next; |
cur = cur->next; |
cur->and = 1; |
cur->and = 1; |