Disable bolding for special chars.

If an escape sequence is used to access a char, the the programmer probably
wanted that char, regardless of the current bolding mode.
This commit is contained in:
Bill Currie 2012-07-14 17:47:34 +09:00
parent 3b8141691e
commit 7444371162

View file

@ -173,16 +173,20 @@ make_string (char *token, char **end)
error (0, "EOF inside quote"); error (0, "EOF inside quote");
switch (c) { switch (c) {
case '\\': case '\\':
c = '\\'; boldnext = 0;
c = '\\' ^ mask;
break; break;
case 'n': case 'n':
c = '\n'; boldnext = 0;
c = '\n' ^ mask;
break; break;
case '"': case '"':
c = '\"'; boldnext = 0;
c = '\"' ^ mask;
break; break;
case '\'': case '\'':
c = '\''; boldnext = 0;
c = '\'' ^ mask;
break; break;
case '0': case '0':
case '1': case '1':
@ -201,13 +205,18 @@ make_string (char *token, char **end)
} }
if (!*token) if (!*token)
error (0, "EOF inside quote"); error (0, "EOF inside quote");
c ^= mask;
boldnext = 0;
break; break;
} }
case '8': case '8':
case '9': case '9':
boldnext = 0;
c = 18 + c - '0'; c = 18 + c - '0';
c ^= mask;
break; break;
case 'x': case 'x':
boldnext = 0;
c = 0; c = 0;
while (*token && isxdigit ((unsigned char)*token)) { while (*token && isxdigit ((unsigned char)*token)) {
c *= 16; c *= 16;
@ -221,35 +230,44 @@ make_string (char *token, char **end)
} }
if (!*token) if (!*token)
error (0, "EOF inside quote"); error (0, "EOF inside quote");
c ^= mask;
break; break;
case 'a': case 'a':
c = '\a'; boldnext = 0;
c = '\a' ^ mask;
break; break;
case 'b': case 'b':
boldnext = 0;
if (options.qccx_escapes) { if (options.qccx_escapes) {
mask ^= 0x80; mask ^= 0x80;
continue; continue;
} else { } else {
c = '\b'; c = '\b' ^ mask;
break; break;
} }
case 'e': case 'e':
c = '\033'; boldnext = 0;
c = '\033' ^ mask;
break; break;
case 'f': case 'f':
c = '\f'; boldnext = 0;
c = '\f' ^ mask;
break; break;
case 'r': case 'r':
c = '\r'; boldnext = 0;
c = '\r' ^ mask;
break; break;
case 's': case 's':
boldnext = 0;
mask ^= 0x80; mask ^= 0x80;
continue; continue;
case 't': case 't':
c = '\t'; boldnext = 0;
c = '\t' ^ mask;
break; break;
case 'v': case 'v':
c = '\v'; boldnext = 0;
c = '\v' ^ mask;
break; break;
case '^': case '^':
if (*token == '\"') if (*token == '\"')
@ -257,43 +275,53 @@ make_string (char *token, char **end)
boldnext = 1; boldnext = 1;
continue; continue;
case '[': case '[':
boldnext = 0;
c = 0x90; // gold [ c = 0x90; // gold [
break; break;
case ']': case ']':
boldnext = 0;
c = 0x91; // gold ] c = 0x91; // gold ]
break; break;
case '.': case '.':
boldnext = 0;
c = 28; // center dot c = 28; // center dot
break; break;
case '<': case '<':
boldnext = 0;
if (options.qccx_escapes) { if (options.qccx_escapes) {
c = 29; // brown left end c = 29 ^ mask; // brown left end
break; break;
} else { } else {
mask = 0x80; mask = 0x80;
continue; continue;
} }
case '-': case '-':
boldnext = 0;
c = 30; // brown center bit c = 30; // brown center bit
break; break;
case '>': case '>':
boldnext = 0;
if (options.qccx_escapes) { if (options.qccx_escapes) {
c = 31; // brown right end c = 31 ^ mask; // brown right end
break; break;
} else { } else {
mask = 0x00; mask = 0x00;
continue; continue;
} }
case '(': case '(':
c = 128; // left slider end boldnext = 0;
c = 128 ^ mask; // left slider end
break; break;
case '=': case '=':
c = 129; // slider center boldnext = 0;
c = 129 ^ mask; // slider center
break; break;
case ')': case ')':
c = 130; // right slider end boldnext = 0;
c = 130 ^ mask; // right slider end
break; break;
case '{': case '{':
boldnext = 0;
c = 0; c = 0;
while (*token && *token != '}' while (*token && *token != '}'
&& isdigit ((unsigned char)*token)) { && isdigit ((unsigned char)*token)) {
@ -308,6 +336,7 @@ make_string (char *token, char **end)
token++; token++;
if (c > 255) if (c > 255)
warning (0, "\\{%d} > 255", c); warning (0, "\\{%d} > 255", c);
c ^= mask;
break; break;
default: default:
error (0, "Unknown escape char"); error (0, "Unknown escape char");