version 1.100, 2009/09/16 15:08:31 |
version 1.105, 2009/10/13 10:57:25 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
|
#include "chars.h" |
#include "term.h" |
#include "term.h" |
#include "man.h" |
#include "man.h" |
#include "mdoc.h" |
#include "mdoc.h" |
|
#include "main.h" |
|
|
extern void man_run(struct termp *, |
/* FIXME: accomodate non-breaking, non-collapsing white-space. */ |
const struct man *); |
/* FIXME: accomodate non-breaking, collapsing white-space. */ |
extern void mdoc_run(struct termp *, |
|
const struct mdoc *); |
|
|
|
static struct termp *term_alloc(enum termenc); |
static struct termp *term_alloc(enum termenc); |
static void term_free(struct termp *); |
static void term_free(struct termp *); |
Line 50 ascii_alloc(void) |
|
Line 50 ascii_alloc(void) |
|
|
|
|
|
void |
void |
terminal_man(void *arg, const struct man *man) |
|
{ |
|
struct termp *p; |
|
|
|
p = (struct termp *)arg; |
|
if (NULL == p->symtab) |
|
p->symtab = term_ascii2htab(); |
|
|
|
man_run(p, man); |
|
} |
|
|
|
|
|
void |
|
terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
{ |
|
struct termp *p; |
|
|
|
p = (struct termp *)arg; |
|
if (NULL == p->symtab) |
|
p->symtab = term_ascii2htab(); |
|
|
|
mdoc_run(p, mdoc); |
|
} |
|
|
|
|
|
void |
|
terminal_free(void *arg) |
terminal_free(void *arg) |
{ |
{ |
|
|
Line 89 term_free(struct termp *p) |
|
Line 63 term_free(struct termp *p) |
|
|
|
if (p->buf) |
if (p->buf) |
free(p->buf); |
free(p->buf); |
if (TERMENC_ASCII == p->enc && p->symtab) |
if (p->symtab) |
term_asciifree(p->symtab); |
chars_free(p->symtab); |
|
|
free(p); |
free(p); |
} |
} |
|
|
term_flushln(struct termp *p) |
term_flushln(struct termp *p) |
{ |
{ |
int i, j; |
int i, j; |
size_t vbl, vsz, vis, maxvis, mmax, bp; |
size_t vbl, vsz, vis, maxvis, mmax, bp, os; |
static int overstep = 0; |
static int overstep = 0; |
|
|
/* |
/* |
Line 168 term_flushln(struct termp *p) |
|
Line 142 term_flushln(struct termp *p) |
|
assert(p->offset < p->rmargin); |
assert(p->offset < p->rmargin); |
assert((int)(p->rmargin - p->offset) - overstep > 0); |
assert((int)(p->rmargin - p->offset) - overstep > 0); |
|
|
|
/* Save the overstep. */ |
|
os = (size_t)overstep; |
|
|
maxvis = /* LINTED */ |
maxvis = /* LINTED */ |
p->rmargin - p->offset - overstep; |
p->rmargin - p->offset - overstep; |
mmax = /* LINTED */ |
mmax = /* LINTED */ |
Line 229 term_flushln(struct termp *p) |
|
Line 206 term_flushln(struct termp *p) |
|
putchar(' '); |
putchar(' '); |
vis = 0; |
vis = 0; |
} |
} |
|
/* Remove the overstep width. */ |
|
bp += os; |
|
os = 0; |
} else { |
} else { |
for (j = 0; j < (int)vbl; j++) |
for (j = 0; j < (int)vbl; j++) |
putchar(' '); |
putchar(' '); |
Line 331 do_special(struct termp *p, const char *word, size_t l |
|
Line 311 do_special(struct termp *p, const char *word, size_t l |
|
size_t sz; |
size_t sz; |
int i; |
int i; |
|
|
rhs = term_a2ascii(p->symtab, word, len, &sz); |
rhs = chars_a2ascii(p->symtab, word, len, &sz); |
|
|
if (NULL == rhs) { |
if (NULL == rhs) { |
#if 0 |
#if 0 |
Line 354 do_reserved(struct termp *p, const char *word, size_t |
|
Line 334 do_reserved(struct termp *p, const char *word, size_t |
|
size_t sz; |
size_t sz; |
int i; |
int i; |
|
|
rhs = term_a2res(p->symtab, word, len, &sz); |
rhs = chars_a2res(p->symtab, word, len, &sz); |
|
|
if (NULL == rhs) { |
if (NULL == rhs) { |
#if 0 |
#if 0 |