=================================================================== RCS file: /cvs/mandoc/Attic/mdocterm.c,v retrieving revision 1.3 retrieving revision 1.7 diff -u -p -r1.3 -r1.7 --- mandoc/Attic/mdocterm.c 2009/02/23 07:09:13 1.3 +++ mandoc/Attic/mdocterm.c 2009/02/23 15:34:53 1.7 @@ -1,4 +1,4 @@ - /* $Id: mdocterm.c,v 1.3 2009/02/23 07:09:13 kristaps Exp $ */ + /* $Id: mdocterm.c,v 1.7 2009/02/23 15:34:53 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -24,9 +24,19 @@ #include #include +#ifndef __OpenBSD__ +#include +#endif + #include "mmain.h" #include "term.h" +#ifdef __NetBSD__ +#define xisspace(x) isspace((int)(x)) +#else +#define xisspace(x) isspace((x)) +#endif + enum termstyle { STYLE_CLEAR, STYLE_BOLD, @@ -45,6 +55,7 @@ static void pword(struct termp *, const char *, siz static void pescape(struct termp *, const char *, size_t *, size_t); static void chara(struct termp *, char); +static void stringa(struct termp *, const char *); static void style(struct termp *, enum termstyle); #ifdef __linux__ @@ -60,9 +71,6 @@ main(int argc, char *argv[]) const struct mdoc *mdoc; struct termp termp; - extern int optreset; - extern int optind; - p = mmain_alloc(); if ( ! mmain_getopt(p, argc, argv, NULL, NULL, NULL, NULL)) @@ -135,11 +143,11 @@ flushln(struct termp *p) * Count up visible word characters. Control sequences * (starting with the CSI) aren't counted. */ - assert( ! isspace(p->buf[i])); + assert( ! xisspace(p->buf[i])); /* LINTED */ for (j = i, vsz = 0; j < p->col; j++) { - if (isspace(p->buf[j])) + if (xisspace(p->buf[j])) break; else if (27 == p->buf[j]) { assert(j + 4 <= p->col); @@ -165,10 +173,9 @@ flushln(struct termp *p) for (j = 0; j < p->offset; j++) putchar(' '); vis = 0; - } else if (vis + vsz >= maxvis) { + } else if (vis + vsz >= maxvis) /* FIXME */ errx(1, "word breaks right margin"); - } /* * Write out the word and a trailing space. Omit the @@ -176,7 +183,7 @@ flushln(struct termp *p) */ for ( ; i < p->col; i++) { - if (isspace(p->buf[i])) + if (xisspace(p->buf[i])) break; putchar(p->buf[i]); } @@ -231,6 +238,16 @@ vspace(struct termp *p) static void +stringa(struct termp *p, const char *s) +{ + + /* XXX - speed up if not passing to chara. */ + for ( ; *s; s++) + chara(p, *s); +} + + +static void chara(struct termp *p, char c) { @@ -284,6 +301,10 @@ pescape(struct termp *p, const char *word, size_t *i, chara(p, ']'); else if ('l' == word[*i] && 'B' == word[*i + 1]) chara(p, '['); + else if ('<' == word[*i] && '-' == word[*i + 1]) + stringa(p, "<-"); + else if ('-' == word[*i] && '>' == word[*i + 1]) + stringa(p, "->"); (*i)++; return; @@ -363,7 +384,7 @@ word(struct termp *p, const char *word) /* LINTED */ for (j = i = 0; i < len; i++) { - if ( ! isspace(word[i])) { + if ( ! xisspace(word[i])) { j++; continue; } @@ -429,10 +450,10 @@ footer(struct termp *p, const struct mdoc_meta *meta) tm = localtime(&meta->date); -#ifdef __linux__ - if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm)) -#else +#ifdef __OpenBSD__ if (NULL == strftime(buf, p->rmargin, "%B %d, %Y", tm)) +#else + if (0 == strftime(buf, p->rmargin, "%B %d, %Y", tm)) #endif err(1, "strftime");