version 1.158, 2010/07/03 16:02:12 |
version 1.164, 2010/07/25 22:56:47 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include "mandoc.h" |
#include "mandoc.h" |
#include "chars.h" |
#include "chars.h" |
#include "out.h" |
#include "out.h" |
#include "regs.h" |
|
#include "term.h" |
#include "term.h" |
#include "main.h" |
#include "main.h" |
|
|
static void spec(struct termp *, const char *, size_t); |
static void spec(struct termp *, enum roffdeco, |
|
const char *, size_t); |
static void res(struct termp *, const char *, size_t); |
static void res(struct termp *, const char *, size_t); |
static void buffera(struct termp *, const char *, size_t); |
static void buffera(struct termp *, const char *, size_t); |
static void bufferc(struct termp *, char); |
static void bufferc(struct termp *, char); |
Line 241 term_flushln(struct termp *p) |
|
Line 242 term_flushln(struct termp *p) |
|
if ('\t' == p->buf[i]) |
if ('\t' == p->buf[i]) |
break; |
break; |
if (' ' == p->buf[i]) { |
if (' ' == p->buf[i]) { |
while (' ' == p->buf[i]) { |
j = i; |
vbl += (*p->width)(p, p->buf[i]); |
while (' ' == p->buf[i]) |
i++; |
i++; |
} |
vbl += (i - j) * (*p->width)(p, ' '); |
break; |
break; |
} |
} |
if (ASCII_NBRSP == p->buf[i]) { |
if (ASCII_NBRSP == p->buf[i]) { |
Line 360 term_vspace(struct termp *p) |
|
Line 361 term_vspace(struct termp *p) |
|
|
|
|
|
static void |
static void |
spec(struct termp *p, const char *word, size_t len) |
spec(struct termp *p, enum roffdeco d, const char *word, size_t len) |
{ |
{ |
const char *rhs; |
const char *rhs; |
size_t sz; |
size_t sz; |
|
|
rhs = chars_a2ascii(p->symtab, word, len, &sz); |
rhs = chars_spec2str(p->symtab, word, len, &sz); |
if (rhs) |
if (rhs) |
encode(p, rhs, sz); |
encode(p, rhs, sz); |
|
else if (DECO_SSPECIAL == d) |
|
encode(p, word, len); |
} |
} |
|
|
|
|
Line 377 res(struct termp *p, const char *word, size_t len) |
|
Line 380 res(struct termp *p, const char *word, size_t len) |
|
const char *rhs; |
const char *rhs; |
size_t sz; |
size_t sz; |
|
|
rhs = chars_a2res(p->symtab, word, len, &sz); |
rhs = chars_res2str(p->symtab, word, len, &sz); |
if (NULL == rhs) { |
|
rhs = roff_getstrn(word, len); |
|
if (rhs) |
|
sz = strlen(rhs); |
|
} |
|
if (rhs) |
if (rhs) |
encode(p, rhs, sz); |
encode(p, rhs, sz); |
} |
} |
Line 508 term_word(struct termp *p, const char *word) |
|
Line 506 term_word(struct termp *p, const char *word) |
|
|
|
p->flags &= ~TERMP_SENTENCE; |
p->flags &= ~TERMP_SENTENCE; |
|
|
/* FIXME: use strcspn. */ |
|
|
|
while (*word) { |
while (*word) { |
if ('\\' != *word) { |
if ((ssz = strcspn(word, "\\")) > 0) |
encode(p, word, 1); |
encode(p, word, ssz); |
word++; |
|
|
word += ssz; |
|
if ('\\' != *word) |
continue; |
continue; |
} |
|
|
|
seq = ++word; |
seq = ++word; |
sz = a2roffdeco(&deco, &seq, &ssz); |
sz = a2roffdeco(&deco, &seq, &ssz); |
Line 525 term_word(struct termp *p, const char *word) |
|
Line 522 term_word(struct termp *p, const char *word) |
|
res(p, seq, ssz); |
res(p, seq, ssz); |
break; |
break; |
case (DECO_SPECIAL): |
case (DECO_SPECIAL): |
spec(p, seq, ssz); |
/* FALLTHROUGH */ |
|
case (DECO_SSPECIAL): |
|
spec(p, deco, seq, ssz); |
break; |
break; |
case (DECO_BOLD): |
case (DECO_BOLD): |
term_fontrepl(p, TERMFONT_BOLD); |
term_fontrepl(p, TERMFONT_BOLD); |
Line 552 term_word(struct termp *p, const char *word) |
|
Line 551 term_word(struct termp *p, const char *word) |
|
* Note that we don't process the pipe: the parser sees it as |
* Note that we don't process the pipe: the parser sees it as |
* punctuation, but we don't in terms of typography. |
* punctuation, but we don't in terms of typography. |
*/ |
*/ |
if (sv[0] && 0 == sv[1]) |
if (sv[0] && '\0' == sv[1]) |
switch (sv[0]) { |
switch (sv[0]) { |
case('('): |
case('('): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |