version 1.34, 2014/07/19 00:42:22 |
version 1.35, 2014/10/22 23:10:05 |
Line 1008 command(struct state *st, const char *buf, size_t star |
|
Line 1008 command(struct state *st, const char *buf, size_t star |
|
* always stays in OUST_NL/wantws mode. |
* always stays in OUST_NL/wantws mode. |
*/ |
*/ |
static void |
static void |
verbatim(struct state *st, const char *buf, size_t start, size_t end) |
verbatim(struct state *st, char *buf, size_t start, size_t end) |
{ |
{ |
size_t i; |
size_t i, ift, ifo, ifa, ifc; |
|
char *cp; |
|
|
if ( ! st->parsing || st->paused) |
if ( ! st->parsing || st->paused || start == end) |
return; |
return; |
again: |
again: |
/* |
/* |
|
|
*/ |
*/ |
if (SECT_SYNOPSIS == st->sect) { |
if (SECT_SYNOPSIS == st->sect) { |
i = start; |
i = start; |
for (i = start; i < end && ' ' == buf[i]; i++) |
while (i < end && buf[i] == ' ') |
/* Spin. */ ; |
i++; |
if (i == end) |
if (i == end) |
return; |
return; |
|
|
/* We're an include block! */ |
/* We're an include block! */ |
if (end - i > 10 && |
if (end - i > 10 && |
0 == memcmp(&buf[i], "#include <", 10)) { |
0 == memcmp(&buf[i], "#include <", 10)) { |
|
|
goto again; |
goto again; |
return; |
return; |
} |
} |
|
|
|
/* Parse function declaration. */ |
|
ifo = ifa = ifc = 0; |
|
for (ift = i; i < end && buf[i] != '\n'; i++) { |
|
if (ifa) { |
|
if (buf[i] == ')') |
|
ifc = i; |
|
} else if (ifo && buf[i] == '(') |
|
ifa = i; |
|
else if (buf[i] == ' ') |
|
ifo = i; |
|
} |
|
|
|
/* Encode function declaration. */ |
|
if (ifc) { |
|
buf[ifo++] = '\0'; |
|
printf(".Ft %s", buf + ift); |
|
if (buf[ifo] == '*') { |
|
fputs(" *", stdout); |
|
ifo++; |
|
} |
|
putchar('\n'); |
|
buf[ifa++] = '\0'; |
|
printf(".Fo %s\n", buf + ifo); |
|
buf[ifc++] = '\0'; |
|
for (;;) { |
|
cp = strchr(buf + ifa, ','); |
|
if (cp != NULL) |
|
*cp = '\0'; |
|
printf(".Fa \"%s\"\n", buf + ifa); |
|
if (cp == NULL) |
|
break; |
|
ifa = cp - buf + 1; |
|
} |
|
puts(".Fc"); |
|
if (buf[ifc] == ';') |
|
ifc++; |
|
if (ifc < i) { |
|
buf[i] = '\0'; |
|
puts(buf + ifc); |
|
} |
|
start = i + 1; |
|
if (start < end) |
|
goto again; |
|
return; |
|
} |
} |
} |
|
|
if (start == end) |
|
return; |
|
puts(".Bd -literal"); |
puts(".Bd -literal"); |
for (last = ' '; start < end; start++) { |
for (last = ' '; start < end; start++) { |
/* |
/* |
Line 1335 ordinary(struct state *st, const char *buf, size_t sta |
|
Line 1381 ordinary(struct state *st, const char *buf, size_t sta |
|
* (default: starts with "="). |
* (default: starts with "="). |
*/ |
*/ |
static void |
static void |
dopar(struct state *st, const char *buf, size_t start, size_t end) |
dopar(struct state *st, char *buf, size_t start, size_t end) |
{ |
{ |
|
|
assert(OUST_NL == st->oust); |
assert(OUST_NL == st->oust); |
Line 1357 dopar(struct state *st, const char *buf, size_t start, |
|
Line 1403 dopar(struct state *st, const char *buf, size_t start, |
|
*/ |
*/ |
static void |
static void |
dofile(const struct args *args, const char *fname, |
dofile(const struct args *args, const char *fname, |
const struct tm *tm, const char *buf, size_t sz) |
const struct tm *tm, char *buf, size_t sz) |
{ |
{ |
char datebuf[64]; |
char datebuf[64]; |
struct state st; |
struct state st; |