Ruby  1.9.3p484(2013-11-22revision43786)
regsyntax.c
Go to the documentation of this file.
1 /**********************************************************************
2  regsyntax.c - Oniguruma (regular expression library)
3 **********************************************************************/
4 /*-
5  * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 #include "regint.h"
31 
33  0
35  , 0
37  ,
38  {
39  (OnigCodePoint )'\\' /* esc */
40  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
41  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
42  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
43  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
44  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
45  }
46 };
47 
51  , 0
52  , 0
54  ,
55  {
56  (OnigCodePoint )'\\' /* esc */
57  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
58  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
59  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
60  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
61  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
62  }
63 };
64 
69  , 0
75  ,
76  {
77  (OnigCodePoint )'\\' /* esc */
78  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
79  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
80  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
81  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
82  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
83  }
84 };
85 
96  ,
97  {
98  (OnigCodePoint )'\\' /* esc */
99  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
100  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
101  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
102  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
103  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
104  }
105 };
106 
115  , 0
118  ,
119  {
120  (OnigCodePoint )'\\' /* esc */
121  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
122  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
123  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
124  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
125  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
126  }
127 };
128 
131  , 0
134  ,
135  {
136  (OnigCodePoint )'\\' /* esc */
137  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
138  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
139  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
140  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
141  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
142  }
143 };
144 
157  ,
158  {
159  (OnigCodePoint )'\\' /* esc */
160  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
161  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
162  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
163  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
164  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
165  }
166 };
167 
180  ,
181  {
182  (OnigCodePoint )'\\' /* esc */
183  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
184  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
185  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
186  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
187  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
188  }
189 };
190 
191 /* Perl + named group */
205  , ( SYN_GNU_REGEX_BV |
209  ,
210  {
211  (OnigCodePoint )'\\' /* esc */
212  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
213  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
214  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
215  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
216  , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
217  }
218 };
219 
220 
221 
222 extern int
224 {
225  if (IS_NULL(syntax))
226  syntax = ONIG_SYNTAX_RUBY;
227 
228  OnigDefaultSyntax = syntax;
229  return 0;
230 }
231 
232 extern void
234 {
235  *to = *from;
236 }
237 
238 extern void
239 onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
240 {
241  syntax->op = op;
242 }
243 
244 extern void
245 onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
246 {
247  syntax->op2 = op2;
248 }
249 
250 extern void
251 onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
252 {
253  syntax->behavior = behavior;
254 }
255 
256 extern void
258 {
259  syntax->options = options;
260 }
261 
262 extern unsigned int
264 {
265  return syntax->op;
266 }
267 
268 extern unsigned int
270 {
271  return syntax->op2;
272 }
273 
274 extern unsigned int
276 {
277  return syntax->behavior;
278 }
279 
280 extern OnigOptionType
282 {
283  return syntax->options;
284 }
285 
286 #ifdef USE_VARIABLE_META_CHARS
288  unsigned int what, OnigCodePoint code)
289 {
290  switch (what) {
292  enc->meta_char_table.esc = code;
293  break;
295  enc->meta_char_table.anychar = code;
296  break;
298  enc->meta_char_table.anytime = code;
299  break;
301  enc->meta_char_table.zero_or_one_time = code;
302  break;
304  enc->meta_char_table.one_or_more_time = code;
305  break;
307  enc->meta_char_table.anychar_anytime = code;
308  break;
309  default:
311  break;
312  }
313  return 0;
314 }
315 #endif /* USE_VARIABLE_META_CHARS */
316