Print this page
9083 replace regex implementation with tre

@@ -30,106 +30,108 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 /* character-name table */
-static struct cname {
-        char *name;
-        char code;
+static const struct cname {
+        const wchar_t *name;
+        wchar_t code;
 } cnames[] = {
-        {"NUL",                 '\0'},
-        {"SOH",                 '\001'},
-        {"STX",                 '\002'},
-        {"ETX",                 '\003'},
-        {"EOT",                 '\004'},
-        {"ENQ",                 '\005'},
-        {"ACK",                 '\006'},
-        {"BEL",                 '\007'},
-        {"alert",               '\007'},
-        {"BS",                  '\010'},
-        {"backspace",           '\b'},
-        {"HT",                  '\011'},
-        {"tab",                 '\t'},
-        {"LF",                  '\012'},
-        {"newline",             '\n'},
-        {"VT",                  '\013'},
-        {"vertical-tab",        '\v'},
-        {"FF",                  '\014'},
-        {"form-feed",           '\f'},
-        {"CR",                  '\015'},
-        {"carriage-return",     '\r'},
-        {"SO",                  '\016'},
-        {"SI",                  '\017'},
-        {"DLE",                 '\020'},
-        {"DC1",                 '\021'},
-        {"DC2",                 '\022'},
-        {"DC3",                 '\023'},
-        {"DC4",                 '\024'},
-        {"NAK",                 '\025'},
-        {"SYN",                 '\026'},
-        {"ETB",                 '\027'},
-        {"CAN",                 '\030'},
-        {"EM",                  '\031'},
-        {"SUB",                 '\032'},
-        {"ESC",                 '\033'},
-        {"IS4",                 '\034'},
-        {"FS",                  '\034'},
-        {"IS3",                 '\035'},
-        {"GS",                  '\035'},
-        {"IS2",                 '\036'},
-        {"RS",                  '\036'},
-        {"IS1",                 '\037'},
-        {"US",                  '\037'},
-        {"space",               ' '},
-        {"exclamation-mark",    '!'},
-        {"quotation-mark",      '"'},
-        {"number-sign",         '#'},
-        {"dollar-sign",         '$'},
-        {"percent-sign",        '%'},
-        {"ampersand",           '&'},
-        {"apostrophe",          '\''},
-        {"left-parenthesis",    '('},
-        {"right-parenthesis",   ')'},
-        {"asterisk",            '*'},
-        {"plus-sign",           '+'},
-        {"comma",               ','},
-        {"hyphen",              '-'},
-        {"hyphen-minus",        '-'},
-        {"period",              '.'},
-        {"full-stop",           '.'},
-        {"slash",               '/'},
-        {"solidus",             '/'},
-        {"zero",                '0'},
-        {"one",                 '1'},
-        {"two",                 '2'},
-        {"three",               '3'},
-        {"four",                '4'},
-        {"five",                '5'},
-        {"six",                 '6'},
-        {"seven",               '7'},
-        {"eight",               '8'},
-        {"nine",                '9'},
-        {"colon",               ':'},
-        {"semicolon",           ';'},
-        {"less-than-sign",      '<'},
-        {"equals-sign",         '='},
-        {"greater-than-sign",   '>'},
-        {"question-mark",       '?'},
-        {"commercial-at",       '@'},
-        {"left-square-bracket", '['},
-        {"backslash",           '\\'},
-        {"reverse-solidus",     '\\'},
-        {"right-square-bracket", ']'},
-        {"circumflex",          '^'},
-        {"circumflex-accent",   '^'},
-        {"underscore",          '_'},
-        {"low-line",            '_'},
-        {"grave-accent",        '`'},
-        {"left-brace",          '{'},
-        {"left-curly-bracket",  '{'},
-        {"vertical-line",       '|'},
-        {"right-brace",         '}'},
-        {"right-curly-bracket", '}'},
-        {"tilde",               '~'},
-        {"DEL", '\177'},
-        {NULL,  0}
+        {L"",                           (wchar_t)-1}, /* sentinel */
+        {L"ACK",                        L'\006'},
+        {L"BEL",                        L'\007'},
+        {L"BS",                         L'\010'},
+        {L"CAN",                        L'\030'},
+        {L"CR",                         L'\015'},
+        {L"DC1",                        L'\021'},
+        {L"DC2",                        L'\022'},
+        {L"DC3",                        L'\023'},
+        {L"DC4",                        L'\024'},
+        {L"DEL",                        L'\177'},
+        {L"DLE",                        L'\020'},
+        {L"EM",                         L'\031'},
+        {L"ENQ",                        L'\005'},
+        {L"EOT",                        L'\004'},
+        {L"ESC",                        L'\033'},
+        {L"ETB",                        L'\027'},
+        {L"ETX",                        L'\003'},
+        {L"FF",                         L'\014'},
+        {L"FS",                         L'\034'},
+        {L"GS",                         L'\035'},
+        {L"HT",                         L'\011'},
+        {L"IS1",                        L'\037'},
+        {L"IS2",                        L'\036'},
+        {L"IS3",                        L'\035'},
+        {L"IS4",                        L'\034'},
+        {L"LF",                         L'\012'},
+        {L"NAK",                        L'\025'},
+        {L"NUL",                        L'\0'},
+        {L"RS",                         L'\036'},
+        {L"SI",                         L'\017'},
+        {L"SO",                         L'\016'},
+        {L"SOH",                        L'\001'},
+        {L"STX",                        L'\002'},
+        {L"SUB",                        L'\032'},
+        {L"SYN",                        L'\026'},
+        {L"US",                         L'\037'},
+        {L"VT",                         L'\013'},
+        {L"alert",                      L'\007'},
+        {L"ampersand",                  L'&'},
+        {L"apostrophe",                 L'\''},
+        {L"asterisk",                   L'*'},
+        {L"backslash",                  L'\\'},
+        {L"backspace",                  L'\b'},
+        {L"carriage-return",            L'\r'},
+        {L"circumflex",                 L'^'},
+        {L"circumflex-accent",          L'^'},
+        {L"colon",                      L':'},
+        {L"comma",                      L','},
+        {L"commercial-at",              L'@'},
+        {L"dollar-sign",                L'$'},
+        {L"eight",                      L'8'},
+        {L"equals-sign",                L'='},
+        {L"exclamation-mark",           L'!'},
+        {L"five",                       L'5'},
+        {L"form-feed",                  L'\f'},
+        {L"four",                       L'4'},
+        {L"full-stop",                  L'.'},
+        {L"grave-accent",               L'`'},
+        {L"greater-than-sign",          L'>'},
+        {L"hyphen",                     L'-'},
+        {L"hyphen-minus",               L'-'},
+        {L"left-brace",                 L'{'},
+        {L"left-curly-bracket",         L'{'},
+        {L"left-parenthesis",           L'('},
+        {L"left-square-bracket",        L'['},
+        {L"less-than-sign",             L'<'},
+        {L"low-line",                   L'_'},
+        {L"newline",                    L'\n'},
+        {L"nine",                       L'9'},
+        {L"number-sign",                L'#'},
+        {L"one",                        L'1'},
+        {L"percent-sign",               L'%'},
+        {L"period",                     L'.'},
+        {L"plus-sign",                  L'+'},
+        {L"question-mark",              L'?'},
+        {L"quotation-mark",             L'"'},
+        {L"reverse-solidus",            L'\\'},
+        {L"right-brace",                L'}'},
+        {L"right-curly-bracket",        L'}'},
+        {L"right-parenthesis",          L')'},
+        {L"right-square-bracket",       L']'},
+        {L"semicolon",                  L';'},
+        {L"seven",                      L'7'},
+        {L"six",                        L'6'},
+        {L"slash",                      L'/'},
+        {L"solidus",                    L'/'},
+        {L"space",                      L' '},
+        {L"tab",                        L'\t'},
+        {L"three",                      L'3'},
+        {L"tilde",                      L'~'},
+        {L"two",                        L'2'},
+        {L"underscore",                 L'_'},
+        {L"vertical-line",              L'|'},
+        {L"vertical-tab",               L'\v'},
+        {L"zero",                       L'0'},
 };
+
+#define NCNAMES         (sizeof (cnames)/sizeof (*cnames))