version 1.271, 2017/06/14 17:51:15 |
version 1.277, 2018/12/15 19:30:26 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2018 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 |
Line 129 term_flushln(struct termp *p) |
|
Line 129 term_flushln(struct termp *p) |
|
p->maxrmargin - p->viscol - vbl : 0; |
p->maxrmargin - p->viscol - vbl : 0; |
vis = vend = 0; |
vis = vend = 0; |
|
|
if ((p->flags && TERMP_MULTICOL) == 0) |
if ((p->flags & TERMP_MULTICOL) == 0) |
p->tcol->col = 0; |
p->tcol->col = 0; |
while (p->tcol->col < p->tcol->lastcol) { |
while (p->tcol->col < p->tcol->lastcol) { |
|
|
Line 477 term_word(struct termp *p, const char *word) |
|
Line 477 term_word(struct termp *p, const char *word) |
|
|
|
word++; |
word++; |
esc = mandoc_escape(&word, &seq, &sz); |
esc = mandoc_escape(&word, &seq, &sz); |
if (ESCAPE_ERROR == esc) |
|
continue; |
|
|
|
switch (esc) { |
switch (esc) { |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
uc = mchars_num2uc(seq + 1, sz - 1); |
uc = mchars_num2uc(seq + 1, sz - 1); |
Line 500 term_word(struct termp *p, const char *word) |
|
Line 497 term_word(struct termp *p, const char *word) |
|
encode1(p, uc); |
encode1(p, uc); |
} |
} |
continue; |
continue; |
|
case ESCAPE_UNDEF: |
|
uc = *seq; |
|
break; |
case ESCAPE_FONTBOLD: |
case ESCAPE_FONTBOLD: |
term_fontrepl(p, TERMFONT_BOLD); |
term_fontrepl(p, TERMFONT_BOLD); |
continue; |
continue; |
Line 510 term_word(struct termp *p, const char *word) |
|
Line 510 term_word(struct termp *p, const char *word) |
|
term_fontrepl(p, TERMFONT_BI); |
term_fontrepl(p, TERMFONT_BI); |
continue; |
continue; |
case ESCAPE_FONT: |
case ESCAPE_FONT: |
|
case ESCAPE_FONTCW: |
case ESCAPE_FONTROMAN: |
case ESCAPE_FONTROMAN: |
term_fontrepl(p, TERMFONT_NONE); |
term_fontrepl(p, TERMFONT_NONE); |
continue; |
continue; |
Line 525 term_word(struct termp *p, const char *word) |
|
Line 526 term_word(struct termp *p, const char *word) |
|
else if (*word == '\0') |
else if (*word == '\0') |
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE); |
p->flags |= (TERMP_NOSPACE | TERMP_NONEWLINE); |
continue; |
continue; |
|
case ESCAPE_DEVICE: |
|
if (p->type == TERMTYPE_PDF) |
|
encode(p, "pdf", 3); |
|
else if (p->type == TERMTYPE_PS) |
|
encode(p, "ps", 2); |
|
else if (p->enc == TERMENC_ASCII) |
|
encode(p, "ascii", 5); |
|
else |
|
encode(p, "utf8", 4); |
|
continue; |
case ESCAPE_HORIZ: |
case ESCAPE_HORIZ: |
|
if (*seq == '|') { |
|
seq++; |
|
uc = -p->col; |
|
} else |
|
uc = 0; |
if (a2roffsu(seq, &su, SCALE_EM) == NULL) |
if (a2roffsu(seq, &su, SCALE_EM) == NULL) |
continue; |
continue; |
uc = term_hen(p, &su); |
uc += term_hen(p, &su); |
if (uc > 0) |
if (uc > 0) |
while (uc-- > 0) |
while (uc-- > 0) |
bufferc(p, ASCII_NBRSP); |
bufferc(p, ASCII_NBRSP); |
Line 547 term_word(struct termp *p, const char *word) |
|
Line 563 term_word(struct termp *p, const char *word) |
|
} |
} |
continue; |
continue; |
case ESCAPE_HLINE: |
case ESCAPE_HLINE: |
if ((seq = a2roffsu(seq, &su, SCALE_EM)) == NULL) |
if ((cp = a2roffsu(seq, &su, SCALE_EM)) == NULL) |
continue; |
continue; |
uc = term_hen(p, &su); |
uc = term_hen(p, &su); |
if (uc <= 0) { |
if (uc <= 0) { |
Line 556 term_word(struct termp *p, const char *word) |
|
Line 572 term_word(struct termp *p, const char *word) |
|
lsz = p->tcol->rmargin - p->tcol->offset; |
lsz = p->tcol->rmargin - p->tcol->offset; |
} else |
} else |
lsz = uc; |
lsz = uc; |
if (*seq == '\0') |
if (*cp == seq[-1]) |
uc = -1; |
uc = -1; |
else if (*seq == '\\') { |
else if (*cp == '\\') { |
seq++; |
seq = cp + 1; |
esc = mandoc_escape(&seq, &cp, &sz); |
esc = mandoc_escape(&seq, &cp, &sz); |
switch (esc) { |
switch (esc) { |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
Line 571 term_word(struct termp *p, const char *word) |
|
Line 587 term_word(struct termp *p, const char *word) |
|
case ESCAPE_SPECIAL: |
case ESCAPE_SPECIAL: |
uc = mchars_spec2cp(cp, sz); |
uc = mchars_spec2cp(cp, sz); |
break; |
break; |
|
case ESCAPE_UNDEF: |
|
uc = *seq; |
|
break; |
default: |
default: |
uc = -1; |
uc = -1; |
break; |
break; |
} |
} |
} else |
} else |
uc = *seq; |
uc = *cp; |
if (uc < 0x20 || (uc > 0x7E && uc < 0xA0)) |
if (uc < 0x20 || (uc > 0x7E && uc < 0xA0)) |
uc = '_'; |
uc = '_'; |
if (p->enc == TERMENC_ASCII) { |
if (p->enc == TERMENC_ASCII) { |
Line 829 term_strlen(const struct termp *p, const char *cp) |
|
Line 848 term_strlen(const struct termp *p, const char *cp) |
|
switch (*cp) { |
switch (*cp) { |
case '\\': |
case '\\': |
cp++; |
cp++; |
esc = mandoc_escape(&cp, &seq, &ssz); |
|
if (ESCAPE_ERROR == esc) |
|
continue; |
|
|
|
rhs = NULL; |
rhs = NULL; |
|
esc = mandoc_escape(&cp, &seq, &ssz); |
switch (esc) { |
switch (esc) { |
case ESCAPE_UNICODE: |
case ESCAPE_UNICODE: |
uc = mchars_num2uc(seq + 1, ssz - 1); |
uc = mchars_num2uc(seq + 1, ssz - 1); |
Line 855 term_strlen(const struct termp *p, const char *cp) |
|
Line 870 term_strlen(const struct termp *p, const char *cp) |
|
sz += cond_width(p, uc, &skip); |
sz += cond_width(p, uc, &skip); |
} |
} |
continue; |
continue; |
|
case ESCAPE_UNDEF: |
|
uc = *seq; |
|
break; |
|
case ESCAPE_DEVICE: |
|
if (p->type == TERMTYPE_PDF) { |
|
rhs = "pdf"; |
|
rsz = 3; |
|
} else if (p->type == TERMTYPE_PS) { |
|
rhs = "ps"; |
|
rsz = 2; |
|
} else if (p->enc == TERMENC_ASCII) { |
|
rhs = "ascii"; |
|
rsz = 5; |
|
} else { |
|
rhs = "utf8"; |
|
rsz = 4; |
|
} |
|
break; |
case ESCAPE_SKIPCHAR: |
case ESCAPE_SKIPCHAR: |
skip = 1; |
skip = 1; |
continue; |
continue; |