From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Allow non-ASCII terminal encodings to accept unicode values for
Date: Fri, 20 May 2011 11:44:55 -0400 (EDT) [thread overview]
Message-ID: <201105201544.p4KFitm1028965@krisdoz.my.domain> (raw)
Log Message:
-----------
Allow non-ASCII terminal encodings to accept unicode values for the
special characters, if possible. This is broken into a separate switch
statement for clarity.
Modified Files:
--------------
mdocml:
term.c
Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -Lterm.c -Lterm.c -u -p -r1.195 -r1.196
--- term.c
+++ term.c
@@ -439,18 +439,37 @@ term_word(struct termp *p, const char *w
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:
break;
}
- uc = mchars_num2uc(seq + 1, sz - 1);
- if ('\0' != uc)
- encode1(p, uc);
+
+ switch (esc) {
+ case (ESCAPE_UNICODE):
+ encode1(p, '?');
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):
@@ -597,6 +616,7 @@ term_strlen(const struct termp *p, const
size_t sz, rsz, i;
int ssz, c;
const char *seq, *rhs;
+ enum mandoc_esc esc;
static const char rej[] = { '\\', ASCII_HYPH, ASCII_NBRSP, '\0' };
/*
@@ -615,18 +635,42 @@ term_strlen(const struct termp *p, const
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)
return(sz);
- 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:
break;
}
- 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);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2011-05-20 15:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201105201544.p4KFitm1028965@krisdoz.my.domain \
--to=kristaps@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).