Print this page
9083 replace regex implementation with tre


  15  *    notice, this list of conditions and the following disclaimer in the
  16  *    documentation and/or other materials provided with the distribution.
  17  * 3. Neither the name of the University nor the names of its contributors
  18  *    may be used to endorse or promote products derived from this software
  19  *    without specific prior written permission.
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31  * SUCH DAMAGE.
  32  */
  33 
  34 /* character-name table */
  35 static struct cname {
  36         char *name;
  37         char code;
  38 } cnames[] = {
  39         {"NUL",                 '\0'},
  40         {"SOH",                 '\001'},
  41         {"STX",                 '\002'},
  42         {"ETX",                 '\003'},
  43         {"EOT",                 '\004'},
  44         {"ENQ",                 '\005'},
  45         {"ACK",                 '\006'},
  46         {"BEL",                 '\007'},
  47         {"alert",               '\007'},
  48         {"BS",                  '\010'},
  49         {"backspace",           '\b'},
  50         {"HT",                  '\011'},
  51         {"tab",                 '\t'},
  52         {"LF",                  '\012'},
  53         {"newline",             '\n'},
  54         {"VT",                  '\013'},
  55         {"vertical-tab",        '\v'},
  56         {"FF",                  '\014'},
  57         {"form-feed",           '\f'},
  58         {"CR",                  '\015'},
  59         {"carriage-return",     '\r'},
  60         {"SO",                  '\016'},
  61         {"SI",                  '\017'},
  62         {"DLE",                 '\020'},
  63         {"DC1",                 '\021'},
  64         {"DC2",                 '\022'},
  65         {"DC3",                 '\023'},
  66         {"DC4",                 '\024'},
  67         {"NAK",                 '\025'},
  68         {"SYN",                 '\026'},
  69         {"ETB",                 '\027'},
  70         {"CAN",                 '\030'},
  71         {"EM",                  '\031'},
  72         {"SUB",                 '\032'},
  73         {"ESC",                 '\033'},
  74         {"IS4",                 '\034'},
  75         {"FS",                  '\034'},
  76         {"IS3",                 '\035'},
  77         {"GS",                  '\035'},
  78         {"IS2",                 '\036'},
  79         {"RS",                  '\036'},
  80         {"IS1",                 '\037'},
  81         {"US",                  '\037'},
  82         {"space",               ' '},
  83         {"exclamation-mark",    '!'},
  84         {"quotation-mark",      '"'},
  85         {"number-sign",         '#'},
  86         {"dollar-sign",         '$'},
  87         {"percent-sign",        '%'},
  88         {"ampersand",           '&'},
  89         {"apostrophe",          '\''},
  90         {"left-parenthesis",    '('},
  91         {"right-parenthesis",   ')'},
  92         {"asterisk",            '*'},
  93         {"plus-sign",           '+'},
  94         {"comma",               ','},
  95         {"hyphen",              '-'},
  96         {"hyphen-minus",        '-'},
  97         {"period",              '.'},
  98         {"full-stop",           '.'},
  99         {"slash",               '/'},
 100         {"solidus",             '/'},
 101         {"zero",                '0'},
 102         {"one",                 '1'},
 103         {"two",                 '2'},
 104         {"three",               '3'},
 105         {"four",                '4'},
 106         {"five",                '5'},
 107         {"six",                 '6'},
 108         {"seven",               '7'},
 109         {"eight",               '8'},
 110         {"nine",                '9'},
 111         {"colon",               ':'},
 112         {"semicolon",           ';'},
 113         {"less-than-sign",      '<'},
 114         {"equals-sign",         '='},
 115         {"greater-than-sign",   '>'},
 116         {"question-mark",       '?'},
 117         {"commercial-at",       '@'},
 118         {"left-square-bracket", '['},
 119         {"backslash",           '\\'},
 120         {"reverse-solidus",     '\\'},
 121         {"right-square-bracket", ']'},
 122         {"circumflex",          '^'},
 123         {"circumflex-accent",   '^'},
 124         {"underscore",          '_'},
 125         {"low-line",            '_'},
 126         {"grave-accent",        '`'},
 127         {"left-brace",          '{'},
 128         {"left-curly-bracket",  '{'},
 129         {"vertical-line",       '|'},
 130         {"right-brace",         '}'},
 131         {"right-curly-bracket", '}'},
 132         {"tilde",               '~'},
 133         {"DEL", '\177'},
 134         {NULL,  0}
 135 };




  15  *    notice, this list of conditions and the following disclaimer in the
  16  *    documentation and/or other materials provided with the distribution.
  17  * 3. Neither the name of the University nor the names of its contributors
  18  *    may be used to endorse or promote products derived from this software
  19  *    without specific prior written permission.
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31  * SUCH DAMAGE.
  32  */
  33 
  34 /* character-name table */
  35 static const struct cname {
  36         const wchar_t *name;
  37         wchar_t code;
  38 } cnames[] = {
  39         {L"",                           (wchar_t)-1}, /* sentinel */
  40         {L"ACK",                        L'\006'},
  41         {L"BEL",                        L'\007'},
  42         {L"BS",                         L'\010'},
  43         {L"CAN",                        L'\030'},
  44         {L"CR",                         L'\015'},
  45         {L"DC1",                        L'\021'},
  46         {L"DC2",                        L'\022'},
  47         {L"DC3",                        L'\023'},
  48         {L"DC4",                        L'\024'},
  49         {L"DEL",                        L'\177'},
  50         {L"DLE",                        L'\020'},
  51         {L"EM",                         L'\031'},
  52         {L"ENQ",                        L'\005'},
  53         {L"EOT",                        L'\004'},
  54         {L"ESC",                        L'\033'},
  55         {L"ETB",                        L'\027'},
  56         {L"ETX",                        L'\003'},
  57         {L"FF",                         L'\014'},
  58         {L"FS",                         L'\034'},
  59         {L"GS",                         L'\035'},
  60         {L"HT",                         L'\011'},
  61         {L"IS1",                        L'\037'},
  62         {L"IS2",                        L'\036'},
  63         {L"IS3",                        L'\035'},
  64         {L"IS4",                        L'\034'},
  65         {L"LF",                         L'\012'},
  66         {L"NAK",                        L'\025'},
  67         {L"NUL",                        L'\0'},
  68         {L"RS",                         L'\036'},
  69         {L"SI",                         L'\017'},
  70         {L"SO",                         L'\016'},
  71         {L"SOH",                        L'\001'},
  72         {L"STX",                        L'\002'},
  73         {L"SUB",                        L'\032'},
  74         {L"SYN",                        L'\026'},
  75         {L"US",                         L'\037'},
  76         {L"VT",                         L'\013'},
  77         {L"alert",                      L'\007'},
  78         {L"ampersand",                  L'&'},
  79         {L"apostrophe",                 L'\''},
  80         {L"asterisk",                   L'*'},
  81         {L"backslash",                  L'\\'},
  82         {L"backspace",                  L'\b'},
  83         {L"carriage-return",            L'\r'},
  84         {L"circumflex",                 L'^'},
  85         {L"circumflex-accent",          L'^'},
  86         {L"colon",                      L':'},
  87         {L"comma",                      L','},
  88         {L"commercial-at",              L'@'},
  89         {L"dollar-sign",                L'$'},
  90         {L"eight",                      L'8'},
  91         {L"equals-sign",                L'='},
  92         {L"exclamation-mark",           L'!'},
  93         {L"five",                       L'5'},
  94         {L"form-feed",                  L'\f'},
  95         {L"four",                       L'4'},
  96         {L"full-stop",                  L'.'},
  97         {L"grave-accent",               L'`'},
  98         {L"greater-than-sign",          L'>'},
  99         {L"hyphen",                     L'-'},
 100         {L"hyphen-minus",               L'-'},
 101         {L"left-brace",                 L'{'},
 102         {L"left-curly-bracket",         L'{'},
 103         {L"left-parenthesis",           L'('},
 104         {L"left-square-bracket",        L'['},
 105         {L"less-than-sign",             L'<'},
 106         {L"low-line",                   L'_'},
 107         {L"newline",                    L'\n'},
 108         {L"nine",                       L'9'},
 109         {L"number-sign",                L'#'},
 110         {L"one",                        L'1'},
 111         {L"percent-sign",               L'%'},
 112         {L"period",                     L'.'},
 113         {L"plus-sign",                  L'+'},
 114         {L"question-mark",              L'?'},
 115         {L"quotation-mark",             L'"'},
 116         {L"reverse-solidus",            L'\\'},
 117         {L"right-brace",                L'}'},
 118         {L"right-curly-bracket",        L'}'},
 119         {L"right-parenthesis",          L')'},
 120         {L"right-square-bracket",       L']'},
 121         {L"semicolon",                  L';'},
 122         {L"seven",                      L'7'},
 123         {L"six",                        L'6'},
 124         {L"slash",                      L'/'},
 125         {L"solidus",                    L'/'},
 126         {L"space",                      L' '},
 127         {L"tab",                        L'\t'},
 128         {L"three",                      L'3'},
 129         {L"tilde",                      L'~'},
 130         {L"two",                        L'2'},
 131         {L"underscore",                 L'_'},
 132         {L"vertical-line",              L'|'},
 133         {L"vertical-tab",               L'\v'},
 134         {L"zero",                       L'0'},
 135 };
 136 
 137 #define NCNAMES         (sizeof (cnames)/sizeof (*cnames))