]>
Commit | Line | Data |
---|---|---|
14b0e578 CS |
1 | /**********************************************************************\r |
2 | ascii.c - Oniguruma (regular expression library)\r | |
3 | **********************************************************************/\r | |
4 | /*-\r | |
b602265d | 5 | * Copyright (c) 2002-2018 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>\r |
14b0e578 CS |
6 | * All rights reserved.\r |
7 | *\r | |
8 | * Redistribution and use in source and binary forms, with or without\r | |
9 | * modification, are permitted provided that the following conditions\r | |
10 | * are met:\r | |
11 | * 1. Redistributions of source code must retain the above copyright\r | |
12 | * notice, this list of conditions and the following disclaimer.\r | |
13 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
14 | * notice, this list of conditions and the following disclaimer in the\r | |
15 | * documentation and/or other materials provided with the distribution.\r | |
16 | *\r | |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r | |
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r | |
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
27 | * SUCH DAMAGE.\r | |
28 | */\r | |
29 | \r | |
b602265d DG |
30 | #include "regint.h" /* for USE_CALLOUT */\r |
31 | \r | |
32 | static int\r | |
33 | init(void)\r | |
34 | {\r | |
35 | #ifdef USE_CALLOUT\r | |
36 | \r | |
37 | int id;\r | |
38 | OnigEncoding enc;\r | |
39 | char* name;\r | |
40 | unsigned int args[4];\r | |
41 | OnigValue opts[4];\r | |
42 | \r | |
43 | enc = ONIG_ENCODING_ASCII;\r | |
44 | \r | |
45 | name = "FAIL"; BC0_P(name, fail);\r | |
46 | name = "MISMATCH"; BC0_P(name, mismatch);\r | |
47 | \r | |
48 | name = "MAX";\r | |
49 | args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\r | |
50 | args[1] = ONIG_TYPE_CHAR;\r | |
51 | opts[0].c = 'X';\r | |
52 | BC_B_O(name, max, 2, args, 1, opts);\r | |
53 | \r | |
54 | name = "ERROR";\r | |
55 | args[0] = ONIG_TYPE_LONG; opts[0].l = ONIG_ABORT;\r | |
56 | BC_P_O(name, error, 1, args, 1, opts);\r | |
57 | \r | |
58 | name = "COUNT";\r | |
59 | args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\r | |
60 | BC_B_O(name, count, 1, args, 1, opts);\r | |
61 | \r | |
62 | name = "TOTAL_COUNT";\r | |
63 | args[0] = ONIG_TYPE_CHAR; opts[0].c = '>';\r | |
64 | BC_B_O(name, total_count, 1, args, 1, opts);\r | |
65 | \r | |
66 | name = "CMP";\r | |
67 | args[0] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\r | |
68 | args[1] = ONIG_TYPE_STRING;\r | |
69 | args[2] = ONIG_TYPE_TAG | ONIG_TYPE_LONG;\r | |
70 | BC_P(name, cmp, 3, args);\r | |
71 | \r | |
72 | #endif /* USE_CALLOUT */\r | |
73 | \r | |
74 | return ONIG_NORMAL;\r | |
75 | }\r | |
76 | \r | |
77 | #if 0\r | |
78 | static int\r | |
79 | is_initialized(void)\r | |
80 | {\r | |
81 | /* Don't use this function */\r | |
82 | /* can't answer, because builtin callout entries removed in onig_end() */\r | |
83 | return 0;\r | |
84 | }\r | |
85 | #endif\r | |
14b0e578 CS |
86 | \r |
87 | static int\r | |
88 | ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype)\r | |
89 | {\r | |
90 | if (code < 128)\r | |
91 | return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);\r | |
92 | else\r | |
93 | return FALSE;\r | |
94 | }\r | |
95 | \r | |
96 | OnigEncodingType OnigEncodingASCII = {\r | |
97 | onigenc_single_byte_mbc_enc_len,\r | |
98 | "US-ASCII", /* name */\r | |
b602265d DG |
99 | 1, /* max enc length */\r |
100 | 1, /* min enc length */\r | |
14b0e578 CS |
101 | onigenc_is_mbc_newline_0x0a,\r |
102 | onigenc_single_byte_mbc_to_code,\r | |
103 | onigenc_single_byte_code_to_mbclen,\r | |
104 | onigenc_single_byte_code_to_mbc,\r | |
105 | onigenc_ascii_mbc_case_fold,\r | |
106 | onigenc_ascii_apply_all_case_fold,\r | |
107 | onigenc_ascii_get_case_fold_codes_by_str,\r | |
108 | onigenc_minimum_property_name_to_ctype,\r | |
109 | ascii_is_code_ctype,\r | |
110 | onigenc_not_support_get_ctype_code_range,\r | |
111 | onigenc_single_byte_left_adjust_char_head,\r | |
b602265d DG |
112 | onigenc_always_true_is_allowed_reverse_match,\r |
113 | init,\r | |
114 | 0, /* is_initialized */\r | |
115 | onigenc_always_true_is_valid_mbc_string,\r | |
116 | ENC_FLAG_ASCII_COMPATIBLE,\r | |
117 | 0, 0\r | |
14b0e578 | 118 | };\r |