version 1.27, 2011/12/08 02:24:31 |
version 1.33, 2011/12/10 22:01:06 |
Line 528 index_merge(const struct of *of, struct mparse *mp, |
|
Line 528 index_merge(const struct of *of, struct mparse *mp, |
|
fn = of->fname; |
fn = of->fname; |
|
|
/* |
/* |
* Reclaim an empty index record, if available. |
* Try interpreting the file as mdoc(7) or man(7) |
|
* source code, unless it is already known to be |
|
* formatted. Fall back to formatted mode. |
*/ |
*/ |
|
|
if (reccur > 0) { |
|
--reccur; |
|
rec = recs[(int)reccur]; |
|
} else if (maxrec > 0) { |
|
rec = maxrec; |
|
maxrec = 0; |
|
} else |
|
rec++; |
|
|
|
mparse_reset(mp); |
mparse_reset(mp); |
hash_reset(&hash); |
|
mdoc = NULL; |
mdoc = NULL; |
man = NULL; |
man = NULL; |
|
|
/* |
|
* Try interpreting the file as mdoc(7) or man(7) |
|
* source code, unless it is already known to be |
|
* formatted. Fall back to formatted mode. |
|
*/ |
|
|
|
if ((MANDOC_SRC & of->src_form || |
if ((MANDOC_SRC & of->src_form || |
! (MANDOC_FORM & of->src_form)) && |
! (MANDOC_FORM & of->src_form)) && |
MANDOCLEVEL_FATAL > mparse_readfd(mp, -1, fn)) |
MANDOCLEVEL_FATAL > mparse_readfd(mp, -1, fn)) |
Line 579 index_merge(const struct of *of, struct mparse *mp, |
|
Line 565 index_merge(const struct of *of, struct mparse *mp, |
|
if (0 == use_all) { |
if (0 == use_all) { |
assert(of->sec); |
assert(of->sec); |
assert(msec); |
assert(msec); |
if (strcmp(msec, of->sec)) |
if (strcasecmp(msec, of->sec)) |
continue; |
continue; |
|
|
if (NULL == arch) { |
if (NULL == arch) { |
if (NULL != of->arch) |
if (NULL != of->arch) |
continue; |
continue; |
} else if (NULL == of->arch || |
} else if (NULL == of->arch || |
strcmp(arch, of->arch)) |
strcasecmp(arch, of->arch)) |
continue; |
continue; |
} |
} |
|
|
Line 625 index_merge(const struct of *of, struct mparse *mp, |
|
Line 611 index_merge(const struct of *of, struct mparse *mp, |
|
|
|
sv = dbuf->len; |
sv = dbuf->len; |
|
|
/* Fix the record number in the btree value. */ |
/* |
|
* Collect keyword/mask pairs. |
|
* Each pair will become a new btree node. |
|
*/ |
|
|
|
hash_reset(&hash); |
if (mdoc) |
if (mdoc) |
pmdoc_node(hash, buf, dbuf, |
pmdoc_node(hash, buf, dbuf, |
mdoc_node(mdoc), mdoc_meta(mdoc)); |
mdoc_node(mdoc), mdoc_meta(mdoc)); |
Line 636 index_merge(const struct of *of, struct mparse *mp, |
|
Line 626 index_merge(const struct of *of, struct mparse *mp, |
|
pformatted(hash, buf, dbuf, of); |
pformatted(hash, buf, dbuf, of); |
|
|
/* |
/* |
* Copy from the in-memory hashtable of pending keywords |
* Reclaim an empty index record, if available. |
* into the database. |
* Use its record number for all new btree nodes. |
*/ |
*/ |
|
|
|
if (reccur > 0) { |
|
--reccur; |
|
rec = recs[(int)reccur]; |
|
} else if (maxrec > 0) { |
|
rec = maxrec; |
|
maxrec = 0; |
|
} else |
|
rec++; |
vbuf.rec = htobe32(rec); |
vbuf.rec = htobe32(rec); |
|
|
|
/* |
|
* Copy from the in-memory hashtable of pending |
|
* keyword/mask pairs into the database. |
|
*/ |
|
|
seq = R_FIRST; |
seq = R_FIRST; |
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) { |
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) { |
seq = R_NEXT; |
seq = R_NEXT; |
Line 1288 pformatted(DB *hash, struct buf *buf, struct buf *dbuf |
|
Line 1292 pformatted(DB *hash, struct buf *buf, struct buf *dbuf |
|
buf_append(buf, of->title); |
buf_append(buf, of->title); |
hash_put(hash, buf, TYPE_Nm); |
hash_put(hash, buf, TYPE_Nm); |
|
|
while (NULL != (line = fgetln(stream, &len)) && '\n' != *line) |
/* Skip to first blank line. */ |
/* Skip to first blank line. */ ; |
|
|
|
while (NULL != (line = fgetln(stream, &len)) && |
while (NULL != (line = fgetln(stream, &len))) |
('\n' == *line || ' ' == *line)) |
if ('\n' == *line) |
/* Skip to first section header. */ ; |
break; |
|
|
/* |
/* |
* If no page content can be found, |
* Assume the first line that is not indented |
* reuse the page title as the page description. |
* is the first section header. Skip to it. |
*/ |
*/ |
|
|
if (NULL == (line = fgetln(stream, &len))) { |
while (NULL != (line = fgetln(stream, &len))) |
|
if ('\n' != *line && ' ' != *line) |
|
break; |
|
|
|
/* |
|
* If no page content can be found, or the input line |
|
* is already the next section header, or there is no |
|
* trailing newline, reuse the page title as the page |
|
* description. |
|
*/ |
|
|
|
line = fgetln(stream, &len); |
|
if (NULL == line || ' ' != *line || '\n' != line[(int)len - 1]) { |
buf_appendb(dbuf, buf->cp, buf->size); |
buf_appendb(dbuf, buf->cp, buf->size); |
hash_put(hash, buf, TYPE_Nd); |
hash_put(hash, buf, TYPE_Nd); |
fclose(stream); |
fclose(stream); |
return; |
return; |
} |
} |
fclose(stream); |
|
|
|
|
line[(int)--len] = '\0'; |
|
|
/* |
/* |
* If there is a dash, skip to the text following it. |
* Skip to the first dash. |
|
* Use the remaining line as the description (no more than 70 |
|
* bytes). |
*/ |
*/ |
|
|
for (p = line, plen = len; plen; p++, plen--) |
if (NULL != (p = strstr(line, "- "))) { |
if ('-' == *p) |
for (p += 2; ' ' == *p || '\b' == *p; p++) |
break; |
/* Skip to next word. */ ; |
for ( ; plen; p++, plen--) |
} else |
if ('-' != *p && ' ' != *p && 8 != *p) |
|
break; |
|
if (0 == plen) { |
|
p = line; |
p = line; |
plen = len; |
|
|
if ((plen = strlen(p)) > 70) { |
|
plen = 70; |
|
p[plen] = '\0'; |
} |
} |
|
|
/* |
/* Strip backspace-encoding from line. */ |
* Copy the rest of the line, but no more than 70 bytes. |
|
*/ |
|
|
|
if (70 < plen) |
while (NULL != (line = memchr(p, '\b', plen))) { |
plen = 70; |
len = line - p; |
p[plen-1] = '\0'; |
if (0 == len) { |
buf_appendb(dbuf, p, plen); |
memmove(line, line + 1, plen--); |
|
continue; |
|
} |
|
memmove(line - 1, line + 1, plen - len); |
|
plen -= 2; |
|
} |
|
|
|
buf_appendb(dbuf, p, plen + 1); |
buf->len = 0; |
buf->len = 0; |
buf_appendb(buf, p, plen); |
buf_appendb(buf, p, plen + 1); |
hash_put(hash, buf, TYPE_Nd); |
hash_put(hash, buf, TYPE_Nd); |
|
fclose(stream); |
} |
} |
|
|
static void |
static void |
Line 1539 ofile_dirbuild(const char *dir, const char* psec, cons |
|
Line 1563 ofile_dirbuild(const char *dir, const char* psec, cons |
|
buf[0] = '\0'; |
buf[0] = '\0'; |
strlcat(buf, dir, MAXPATHLEN); |
strlcat(buf, dir, MAXPATHLEN); |
p = strrchr(buf, '/'); |
p = strrchr(buf, '/'); |
|
if (NULL != parch && NULL != p) |
|
for (p--; p > buf; p--) |
|
if ('/' == *p) |
|
break; |
if (NULL == p) |
if (NULL == p) |
p = buf; |
p = buf; |
else |
else |