version 1.9, 2013/12/27 01:16:54 |
version 1.10, 2013/12/27 18:51:25 |
Line 144 mansearch(const struct mansearch *search, |
|
Line 144 mansearch(const struct mansearch *search, |
|
int fd, rc, c; |
int fd, rc, c; |
int64_t id; |
int64_t id; |
char buf[PATH_MAX]; |
char buf[PATH_MAX]; |
char *sql; |
char *sql, *newnames; |
|
const char *oldnames, *sep1, *name, *sec, *sep2, *arch; |
|
struct manpage *mpage; |
struct expr *e, *ep; |
struct expr *e, *ep; |
sqlite3 *db; |
sqlite3 *db; |
sqlite3_stmt *s; |
sqlite3_stmt *s; |
Line 282 mansearch(const struct mansearch *search, |
|
Line 284 mansearch(const struct mansearch *search, |
|
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
|
|
sqlite3_finalize(s); |
sqlite3_finalize(s); |
sqlite3_close(db); |
|
|
|
|
c = sqlite3_prepare_v2(db, |
|
"SELECT * FROM mlinks WHERE pageid=?", |
|
-1, &s, NULL); |
|
if (SQLITE_OK != c) |
|
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
|
|
for (mp = ohash_first(&htab, &idx); |
for (mp = ohash_first(&htab, &idx); |
NULL != mp; |
NULL != mp; |
mp = ohash_next(&htab, &idx)) { |
mp = ohash_next(&htab, &idx)) { |
Line 292 mansearch(const struct mansearch *search, |
|
Line 299 mansearch(const struct mansearch *search, |
|
*res = mandoc_realloc |
*res = mandoc_realloc |
(*res, maxres * sizeof(struct manpage)); |
(*res, maxres * sizeof(struct manpage)); |
} |
} |
strlcpy((*res)[cur].file, |
mpage = *res + cur; |
paths->paths[i], PATH_MAX); |
if (-1 == asprintf(&mpage->file, "%s/%s", |
strlcat((*res)[cur].file, "/", PATH_MAX); |
paths->paths[i], mp->file)) { |
strlcat((*res)[cur].file, mp->file, PATH_MAX); |
perror(0); |
(*res)[cur].desc = mp->desc; |
exit((int)MANDOCLEVEL_SYSERR); |
(*res)[cur].form = mp->form; |
} |
|
mpage->names = NULL; |
|
mpage->desc = mp->desc; |
|
mpage->form = mp->form; |
|
|
|
j = 1; |
|
SQL_BIND_INT64(db, s, j, mp->id); |
|
while (SQLITE_ROW == (c = sqlite3_step(s))) { |
|
if (NULL == mpage->names) { |
|
oldnames = ""; |
|
sep1 = ""; |
|
} else { |
|
oldnames = mpage->names; |
|
sep1 = ", "; |
|
} |
|
sec = sqlite3_column_text(s, 1); |
|
arch = sqlite3_column_text(s, 2); |
|
name = sqlite3_column_text(s, 3); |
|
sep2 = '\0' == *arch ? "" : "/"; |
|
if (-1 == asprintf(&newnames, |
|
"%s%s%s(%s%s%s)", oldnames, sep1, |
|
name, sec, sep2, arch)) { |
|
perror(0); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
} |
|
free(mpage->names); |
|
mpage->names = newnames; |
|
} |
|
if (SQLITE_DONE != c) |
|
fprintf(stderr, "%s\n", sqlite3_errmsg(db)); |
|
sqlite3_reset(s); |
|
|
free(mp->file); |
free(mp->file); |
free(mp); |
free(mp); |
cur++; |
cur++; |
} |
} |
|
|
|
sqlite3_finalize(s); |
|
sqlite3_close(db); |
ohash_delete(&htab); |
ohash_delete(&htab); |
} |
} |
rc = 1; |
rc = 1; |