version 1.49.2.14, 2014/03/23 12:04:54 |
version 1.49.2.15, 2014/03/23 12:37:58 |
|
|
pman_node(MAN_ARGS) |
pman_node(MAN_ARGS) |
{ |
{ |
const struct man_node *head, *body; |
const struct man_node *head, *body; |
char *start, *sv, *title; |
char *start, *title; |
size_t sz, titlesz; |
size_t sz; |
|
|
if (NULL == n) |
if (NULL == n) |
return(0); |
return(0); |
Line 1404 pman_node(MAN_ARGS) |
|
Line 1404 pman_node(MAN_ARGS) |
|
NULL != (head = (head->child)) && |
NULL != (head = (head->child)) && |
MAN_TEXT == head->type && |
MAN_TEXT == head->type && |
0 == strcmp(head->string, "NAME") && |
0 == strcmp(head->string, "NAME") && |
NULL != (body = body->child) && |
NULL != body->child) { |
MAN_TEXT == body->type) { |
|
|
|
title = NULL; |
|
titlesz = 0; |
|
/* |
/* |
* Suck the entire NAME section into memory. |
* Suck the entire NAME section into memory. |
* Yes, we might run away. |
* Yes, we might run away. |
* But too many manuals have big, spread-out |
* But too many manuals have big, spread-out |
* NAME sections over many lines. |
* NAME sections over many lines. |
*/ |
*/ |
for ( ; NULL != body; body = body->next) { |
|
if (MAN_TEXT != body->type) |
title = NULL; |
break; |
man_deroff(&title, body); |
if (0 == (sz = strlen(body->string))) |
|
continue; |
|
title = mandoc_realloc |
|
(title, titlesz + sz + 1); |
|
memcpy(title + titlesz, body->string, sz); |
|
titlesz += sz + 1; |
|
title[(int)titlesz - 1] = ' '; |
|
} |
|
if (NULL == title) |
if (NULL == title) |
return(0); |
return(0); |
|
|
title = mandoc_realloc(title, titlesz + 1); |
|
title[(int)titlesz] = '\0'; |
|
|
|
/* Skip leading space. */ |
|
|
|
sv = title; |
|
while (isspace((unsigned char)*sv)) |
|
sv++; |
|
|
|
if (0 == (sz = strlen(sv))) { |
|
free(title); |
|
return(0); |
|
} |
|
|
|
/* Erase trailing space. */ |
|
|
|
start = &sv[sz - 1]; |
|
while (start > sv && isspace((unsigned char)*start)) |
|
*start-- = '\0'; |
|
|
|
if (start == sv) { |
|
free(title); |
|
return(0); |
|
} |
|
|
|
start = sv; |
|
|
|
/* |
/* |
* Go through a special heuristic dance here. |
* Go through a special heuristic dance here. |
* This is why -man manuals are great! |
* This is why -man manuals are great! |
Line 1466 pman_node(MAN_ARGS) |
|
Line 1428 pman_node(MAN_ARGS) |
|
* the name parts here. |
* the name parts here. |
*/ |
*/ |
|
|
|
start = title; |
for ( ;; ) { |
for ( ;; ) { |
sz = strcspn(start, " ,"); |
sz = strcspn(start, " ,"); |
if ('\0' == start[(int)sz]) |
if ('\0' == start[(int)sz]) |
Line 1490 pman_node(MAN_ARGS) |
|
Line 1453 pman_node(MAN_ARGS) |
|
|
|
buf->len = 0; |
buf->len = 0; |
|
|
if (sv == start) { |
if (start == title) { |
buf_append(buf, start); |
buf_append(buf, start); |
free(title); |
free(title); |
return(1); |
return(1); |