+ case 'x':
+ case 'X':
+ /* same procedure as in fteqcc */
+ ch = 0;
+ nextch = lex_getch(lex);
+ if (nextch >= '0' && nextch <= '9')
+ ch += nextch - '0';
+ else if (nextch >= 'a' && nextch <= 'f')
+ ch += nextch - 'a' + 10;
+ else if (nextch >= 'A' && nextch <= 'F')
+ ch += nextch - 'A' + 10;
+ else {
+ lexerror(lex, "bad character code");
+ lex_ungetch(lex, nextch);
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+
+ ch *= 0x10;
+ nextch = lex_getch(lex);
+ if (nextch >= '0' && nextch <= '9')
+ ch += nextch - '0';
+ else if (nextch >= 'a' && nextch <= 'f')
+ ch += nextch - 'a' + 10;
+ else if (nextch >= 'A' && nextch <= 'F')
+ ch += nextch - 'A' + 10;
+ else {
+ lexerror(lex, "bad character code");
+ lex_ungetch(lex, nextch);
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+ break;
+
+ /* fteqcc support */
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ ch = 18 + ch - '0';
+ break;
+ case '<': ch = 29; break;
+ case '-': ch = 30; break;
+ case '>': ch = 31; break;
+ case '[': ch = 16; break;
+ case ']': ch = 17; break;
+ case '{':
+ chr = 0;
+ nextch = lex_getch(lex);
+ hex = (nextch == 'x');
+ if (!hex)
+ lex_ungetch(lex, nextch);
+ for (nextch = lex_getch(lex); nextch != '}'; nextch = lex_getch(lex)) {
+ if (!hex) {
+ if (nextch >= '0' && nextch <= '9')
+ chr = chr * 10 + nextch - '0';
+ else {
+ lexerror(lex, "bad character code");
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+ } else {
+ if (nextch >= '0' && nextch <= '9')
+ chr = chr * 0x10 + nextch - '0';
+ else if (nextch >= 'a' && nextch <= 'f')
+ chr = chr * 0x10 + nextch - 'a' + 10;
+ else if (nextch >= 'A' && nextch <= 'F')
+ chr = chr * 0x10 + nextch - 'A' + 10;
+ else {
+ lexerror(lex, "bad character code");
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+ }
+ if (chr > 0x10FFFF || (!OPTS_FLAG(UTF8) && chr > 255))
+ {
+ lexerror(lex, "character code out of range");
+ return (lex->tok.ttype = TOKEN_ERROR);
+ }
+ }
+ if (OPTS_FLAG(UTF8) && chr >= 128) {
+ u8len = u8_fromchar(chr, u8buf, sizeof(u8buf));
+ if (!u8len)
+ ch = 0;
+ else {
+ --u8len;
+ for (uc = 0; uc < u8len; ++uc)
+ lex_tokench(lex, u8buf[uc]);
+ /* the last character will be inserted with the tokench() call
+ * below the switch
+ */
+ ch = u8buf[uc];
+ }
+ }
+ else
+ ch = chr;
+ break;
+ case '\n': ch = '\n'; break;
+