version 1.5, 2009/02/23 12:45:19 |
version 1.8, 2009/02/24 14:52:55 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#ifdef __linux__ |
#ifndef __OpenBSD__ |
#include <time.h> |
#include <time.h> |
#endif |
#endif |
|
|
#include "mmain.h" |
#include "mmain.h" |
#include "term.h" |
#include "term.h" |
|
|
|
#ifdef __NetBSD__ |
|
#define xisspace(x) isspace((int)(x)) |
|
#else |
|
#define xisspace(x) isspace((x)) |
|
#endif |
|
|
enum termstyle { |
enum termstyle { |
STYLE_CLEAR, |
STYLE_CLEAR, |
STYLE_BOLD, |
STYLE_BOLD, |
Line 137 flushln(struct termp *p) |
|
Line 143 flushln(struct termp *p) |
|
* Count up visible word characters. Control sequences |
* Count up visible word characters. Control sequences |
* (starting with the CSI) aren't counted. |
* (starting with the CSI) aren't counted. |
*/ |
*/ |
assert( ! isspace(p->buf[i])); |
assert( ! xisspace(p->buf[i])); |
|
|
/* LINTED */ |
/* LINTED */ |
for (j = i, vsz = 0; j < p->col; j++) { |
for (j = i, vsz = 0; j < p->col; j++) { |
if (isspace(p->buf[j])) |
if (xisspace(p->buf[j])) |
break; |
break; |
else if (27 == p->buf[j]) { |
else if (27 == p->buf[j]) { |
assert(j + 4 <= p->col); |
assert(j + 4 <= p->col); |
Line 167 flushln(struct termp *p) |
|
Line 173 flushln(struct termp *p) |
|
for (j = 0; j < p->offset; j++) |
for (j = 0; j < p->offset; j++) |
putchar(' '); |
putchar(' '); |
vis = 0; |
vis = 0; |
} else if (vis + vsz >= maxvis) { |
} else if (vis + vsz >= maxvis) |
/* FIXME */ |
/* FIXME */ |
errx(1, "word breaks right margin"); |
errx(1, "word breaks right margin"); |
} |
|
|
|
/* |
/* |
* Write out the word and a trailing space. Omit the |
* Write out the word and a trailing space. Omit the |
Line 178 flushln(struct termp *p) |
|
Line 183 flushln(struct termp *p) |
|
*/ |
*/ |
|
|
for ( ; i < p->col; i++) { |
for ( ; i < p->col; i++) { |
if (isspace(p->buf[i])) |
if (xisspace(p->buf[i])) |
break; |
break; |
putchar(p->buf[i]); |
putchar(p->buf[i]); |
} |
} |
Line 300 pescape(struct termp *p, const char *word, size_t *i, |
|
Line 305 pescape(struct termp *p, const char *word, size_t *i, |
|
stringa(p, "<-"); |
stringa(p, "<-"); |
else if ('-' == word[*i] && '>' == word[*i + 1]) |
else if ('-' == word[*i] && '>' == word[*i + 1]) |
stringa(p, "->"); |
stringa(p, "->"); |
|
else if ('l' == word[*i] && 'q' == word[*i + 1]) |
|
chara(p, '\"'); |
|
else if ('r' == word[*i] && 'q' == word[*i + 1]) |
|
chara(p, '\"'); |
|
|
(*i)++; |
(*i)++; |
return; |
return; |
Line 379 word(struct termp *p, const char *word) |
|
Line 388 word(struct termp *p, const char *word) |
|
|
|
/* LINTED */ |
/* LINTED */ |
for (j = i = 0; i < len; i++) { |
for (j = i = 0; i < len; i++) { |
if ( ! isspace(word[i])) { |
if ( ! xisspace(word[i])) { |
j++; |
j++; |
continue; |
continue; |
} |
} |
Line 445 footer(struct termp *p, const struct mdoc_meta *meta) |
|
Line 454 footer(struct termp *p, const struct mdoc_meta *meta) |
|
|
|
tm = localtime(&meta->date); |
tm = localtime(&meta->date); |
|
|
#ifdef __linux__ |
#ifdef __OpenBSD__ |
if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm)) |
|
#else |
|
if (NULL == strftime(buf, p->rmargin, "%B %d, %Y", tm)) |
if (NULL == strftime(buf, p->rmargin, "%B %d, %Y", tm)) |
|
#else |
|
if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm)) |
#endif |
#endif |
err(1, "strftime"); |
err(1, "strftime"); |
|
|