version 1.14, 2014/04/01 19:50:34 |
version 1.15, 2014/04/02 14:50:09 |
Line 239 trylink(const char *buf, size_t *start, size_t end, si |
|
Line 239 trylink(const char *buf, size_t *start, size_t end, si |
|
return(1); |
return(1); |
} |
} |
|
|
|
|
/* |
/* |
* Doclifting: if we're a bold "-xx" and we're in the SYNOPSIS section, |
* Doclifting: if we're a bold "-xx" and we're in the SYNOPSIS section, |
* then it's likely that we're a flag. |
* then it's likely that we're a flag. |
|
|
* been printed to the current line. |
* been printed to the current line. |
* If "nomacro", then we don't print any macros, just contained data |
* If "nomacro", then we don't print any macros, just contained data |
* (e.g., following "Sh" or "Nm"). |
* (e.g., following "Sh" or "Nm"). |
|
* "pos" is only significant in SYNOPSIS, and should be 0 when invoked |
|
* as the first format code on a line (for decoration as an "Nm"), |
|
* non-zero otherwise. |
* Return whether we've printed a macro or not--in other words, whether |
* Return whether we've printed a macro or not--in other words, whether |
* this should trigger a subsequent newline (this should be ignored when |
* this should trigger a subsequent newline (this should be ignored when |
* reentrant). |
* reentrant). |
*/ |
*/ |
static int |
static int |
formatcode(struct state *st, const char *buf, |
formatcode(struct state *st, const char *buf, size_t *start, |
size_t *start, size_t end, int reentrant, int nomacro) |
size_t end, int reentrant, int nomacro, int pos) |
{ |
{ |
enum fmt fmt; |
enum fmt fmt; |
size_t i, j, dsz; |
size_t i, j, dsz; |
Line 430 formatcode(struct state *st, const char *buf, |
|
Line 432 formatcode(struct state *st, const char *buf, |
|
if (SECT_SYNOPSIS == st->sect) { |
if (SECT_SYNOPSIS == st->sect) { |
if (1 == dsz && '-' == buf[*start]) |
if (1 == dsz && '-' == buf[*start]) |
dosynopsisfl(buf, start, end); |
dosynopsisfl(buf, start, end); |
|
else if (0 == pos) |
|
printf("Nm "); |
else |
else |
printf("Ar "); |
printf("Ar "); |
break; |
break; |
Line 482 formatcode(struct state *st, const char *buf, |
|
Line 486 formatcode(struct state *st, const char *buf, |
|
} |
} |
} |
} |
if (*start + 1 < end && '<' == buf[*start + 1]) { |
if (*start + 1 < end && '<' == buf[*start + 1]) { |
formatcode(st, buf, start, end, 1, nomacro); |
formatcode(st, buf, start, end, 1, nomacro, 1); |
continue; |
continue; |
} |
} |
|
|
Line 544 formatcodeln(struct state *st, const char *buf, |
|
Line 548 formatcodeln(struct state *st, const char *buf, |
|
last = ' '; |
last = ' '; |
while (*start < end) { |
while (*start < end) { |
if (*start + 1 < end && '<' == buf[*start + 1]) { |
if (*start + 1 < end && '<' == buf[*start + 1]) { |
formatcode(st, buf, start, end, 1, nomacro); |
formatcode(st, buf, start, end, 1, nomacro, 1); |
continue; |
continue; |
} |
} |
/* |
/* |
|
|
ordinary(struct state *st, const char *buf, size_t start, size_t end) |
ordinary(struct state *st, const char *buf, size_t start, size_t end) |
{ |
{ |
size_t i, j, opstack; |
size_t i, j, opstack; |
|
int seq; |
|
|
if ( ! st->parsing || st->paused) |
if ( ! st->parsing || st->paused) |
return; |
return; |
Line 884 ordinary(struct state *st, const char *buf, size_t sta |
|
Line 889 ordinary(struct state *st, const char *buf, size_t sta |
|
* To wit, print out a "Nm" and "Nd" in that format. |
* To wit, print out a "Nm" and "Nd" in that format. |
*/ |
*/ |
if (SECT_NAME == st->sect) { |
if (SECT_NAME == st->sect) { |
for (i = end - 1; i > start; i--) |
for (i = end - 2; i > start; i--) |
if ('-' == buf[i]) |
if ('-' == buf[i] && ' ' == buf[i + 1]) |
break; |
break; |
if ('-' == buf[i]) { |
if ('-' == buf[i]) { |
j = i; |
j = i; |
Line 893 ordinary(struct state *st, const char *buf, size_t sta |
|
Line 898 ordinary(struct state *st, const char *buf, size_t sta |
|
for ( ; i > start; i--) |
for ( ; i > start; i--) |
if ('-' != buf[i]) |
if ('-' != buf[i]) |
break; |
break; |
printf(".Nm "); |
fputs(".Nm ", stdout); |
formatcodeln(st, buf, &start, i + 1, 1); |
formatcodeln(st, buf, &start, i + 1, 1); |
putchar('\n'); |
putchar('\n'); |
start = j + 1; |
start = j + 1; |
printf(".Nd "); |
fputs(".Nd ", stdout); |
formatcodeln(st, buf, &start, end, 1); |
formatcodeln(st, buf, &start, end, 1); |
putchar('\n'); |
putchar('\n'); |
return; |
return; |
Line 911 ordinary(struct state *st, const char *buf, size_t sta |
|
Line 916 ordinary(struct state *st, const char *buf, size_t sta |
|
last = '\n'; |
last = '\n'; |
opstack = 0; |
opstack = 0; |
|
|
while (start < end) { |
for (seq = 0; start < end; seq++) { |
/* |
/* |
* Loop til we get either to a newline or escape. |
* Loop til we get either to a newline or escape. |
* Escape initial control characters. |
* Escape initial control characters. |
Line 951 ordinary(struct state *st, const char *buf, size_t sta |
|
Line 956 ordinary(struct state *st, const char *buf, size_t sta |
|
* Consume all whitespace so we don't |
* Consume all whitespace so we don't |
* accidentally start an implicit literal line. |
* accidentally start an implicit literal line. |
*/ |
*/ |
if (formatcode(st, buf, &start, end, 0, 0)) { |
if (formatcode(st, buf, &start, end, 0, 0, seq)) { |
putchar(last = '\n'); |
putchar(last = '\n'); |
while (start < end && ' ' == buf[start]) |
while (start < end && ' ' == buf[start]) |
start++; |
start++; |