special characters, if possible. This is broken into a separate switch
statement for clarity.
-/* $Id: term.c,v 1.195 2011/05/18 23:59:08 kristaps Exp $ */
+/* $Id: term.c,v 1.196 2011/05/20 15:44:55 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
if (ESCAPE_ERROR == esc)
break;
if (ESCAPE_ERROR == esc)
break;
- switch (esc) {
- case (ESCAPE_UNICODE):
- if (TERMENC_ASCII == p->enc) {
- encode1(p, '?');
+ if (TERMENC_ASCII != p->enc)
+ switch (esc) {
+ case (ESCAPE_UNICODE):
+ uc = mchars_num2uc(seq + 1, sz - 1);
+ if ('\0' == uc)
+ break;
+ encode1(p, uc);
+ continue;
+ case (ESCAPE_PREDEF):
+ uc = mchars_res2cp(p->symtab, seq, sz);
+ if (uc <= 0)
+ break;
+ encode1(p, uc);
+ continue;
+ case (ESCAPE_SPECIAL):
+ uc = mchars_spec2cp(p->symtab, seq, sz);
+ if (uc <= 0)
+ break;
+ encode1(p, uc);
+ continue;
+ default:
- uc = mchars_num2uc(seq + 1, sz - 1);
- if ('\0' != uc)
- encode1(p, uc);
+
+ switch (esc) {
+ case (ESCAPE_UNICODE):
+ encode1(p, '?');
break;
case (ESCAPE_NUMBERED):
break;
case (ESCAPE_NUMBERED):
- if ('\0' != (c = mchars_num2char(seq, sz)))
+ c = mchars_num2char(seq, sz);
+ if ('\0' != c)
encode(p, &c, 1);
break;
case (ESCAPE_PREDEF):
encode(p, &c, 1);
break;
case (ESCAPE_PREDEF):
size_t sz, rsz, i;
int ssz, c;
const char *seq, *rhs;
size_t sz, rsz, i;
int ssz, c;
const char *seq, *rhs;
static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' };
/*
static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' };
/*
switch (*cp) {
case ('\\'):
cp++;
switch (*cp) {
case ('\\'):
cp++;
- rhs = NULL;
- switch (mandoc_escape(&cp, &seq, &ssz)) {
- case (ESCAPE_ERROR):
+ esc = mandoc_escape(&cp, &seq, &ssz);
+ if (ESCAPE_ERROR == esc)
- case (ESCAPE_UNICODE):
- if (TERMENC_ASCII != p->enc) {
- sz += (*p->width)(p, '?');
+
+ if (TERMENC_ASCII != p->enc)
+ switch (esc) {
+ case (ESCAPE_UNICODE):
+ c = mchars_num2uc
+ (seq + 1, ssz - 1);
+ if ('\0' == c)
+ break;
+ sz += (*p->width)(p, c);
+ continue;
+ case (ESCAPE_PREDEF):
+ c = mchars_res2cp
+ (p->symtab, seq, ssz);
+ if (c <= 0)
+ break;
+ sz += (*p->width)(p, c);
+ continue;
+ case (ESCAPE_SPECIAL):
+ c = mchars_spec2cp
+ (p->symtab, seq, ssz);
+ if (c <= 0)
+ break;
+ sz += (*p->width)(p, c);
+ continue;
+ default:
- c = mchars_num2uc(seq + 1, ssz - 1);
- if ('\0' != c)
- sz += (*p->width)(p, c);
+
+ rhs = NULL;
+
+ switch (esc) {
+ case (ESCAPE_UNICODE):
+ sz += (*p->width)(p, '?');
break;
case (ESCAPE_NUMBERED):
c = mchars_num2char(seq, ssz);
break;
case (ESCAPE_NUMBERED):
c = mchars_num2char(seq, ssz);