Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (63 sloc) 2.059 kb
4dbc956 more regexp work
Laurent Sansonetti authored
1 /*
2 * MacRuby Regular Expressions.
3 *
4 * This file is covered by the Ruby license. See COPYING for more details.
5 *
9595725 update copyrights to 2011
Laurent Sansonetti authored
6 * Copyright (C) 2011, Apple Inc. All rights reserved.
4dbc956 more regexp work
Laurent Sansonetti authored
7 */
8
9 #ifndef __RE_H_
10 #define __RE_H_
11
12 #if defined(__cplusplus)
13 extern "C" {
14 #endif
15
16 bool rb_char_to_icu_option(int c, int *option);
80cdbfa added String#match and String#=~
Laurent Sansonetti authored
17
4dbc956 more regexp work
Laurent Sansonetti authored
18 VALUE regexp_eqq(VALUE rcv, SEL sel, VALUE str);
80cdbfa added String#match and String#=~
Laurent Sansonetti authored
19 VALUE regexp_match(VALUE rcv, SEL sel, VALUE str);
20 VALUE regexp_match2(VALUE rcv, SEL sel, int argc, VALUE *argv);
21
22 VALUE rb_reg_quote(VALUE pat);
23 VALUE rb_reg_regcomp(VALUE str);
29af078 added support for regexps marshal'ing
Laurent Sansonetti authored
24 VALUE rb_regexp_source(VALUE re);
25
a86d5f2 always use ucs2 mode, added shared regexp matchers for #gsub, #scan and ...
Laurent Sansonetti authored
26 VALUE rb_reg_matcher_new(VALUE re, VALUE str);
d1673a2 introduce a better unichar API, which should be as fast as before the re...
Laurent Sansonetti authored
27 int rb_reg_matcher_search_find(VALUE re, VALUE matcher, int pos, bool reverse,
28 bool findFirst);
a86d5f2 always use ucs2 mode, added shared regexp matchers for #gsub, #scan and ...
Laurent Sansonetti authored
29 void rb_reg_matcher_destroy(VALUE matcher);
d1673a2 introduce a better unichar API, which should be as fast as before the re...
Laurent Sansonetti authored
30
31 static inline int
32 rb_reg_matcher_search_first(VALUE re, VALUE matcher, int pos, bool reverse)
33 {
34 return rb_reg_matcher_search_find(re, matcher, pos, reverse, true);
35 }
36
37 static inline int
38 rb_reg_matcher_search_next(VALUE re, VALUE matcher, int pos, bool reverse)
39 {
40 return rb_reg_matcher_search_find(re, matcher, pos, reverse, false);
41 }
42
43 static inline int
44 rb_reg_matcher_search(VALUE re, VALUE matcher, int pos, bool reverse)
45 {
46 return rb_reg_matcher_search_next(re, matcher, pos, reverse);
47 }
a86d5f2 always use ucs2 mode, added shared regexp matchers for #gsub, #scan and ...
Laurent Sansonetti authored
48
49 static inline int
50 rb_reg_search(VALUE re, VALUE str, int pos, bool reverse)
51 {
52 VALUE matcher = rb_reg_matcher_new(re, str);
c27f1f9 @Watson1978 will support the \G of Regexp. fixed the #1012.
Watson1978 authored
53 const int res = rb_reg_matcher_search_first(re, matcher, pos, reverse);
a86d5f2 always use ucs2 mode, added shared regexp matchers for #gsub, #scan and ...
Laurent Sansonetti authored
54 rb_reg_matcher_destroy(matcher);
55 return res;
56 }
57
29af078 added support for regexps marshal'ing
Laurent Sansonetti authored
58 int rb_reg_options_to_mri(int opt);
59 int rb_reg_options_from_mri(int mri_opt);
1775a38 more string/regexp work
Laurent Sansonetti authored
60
acc8254 rewrote the regexp layer in pure C to avoid binary incompatibility issue...
Laurent Sansonetti authored
61 void regexp_get_uchars(VALUE re, const UChar **chars_p, int32_t *chars_len_p);
f045214 regexps are now AOT compilable
Laurent Sansonetti authored
62
7ebd7c2 add String#scan
Laurent Sansonetti authored
63 typedef struct rb_match_result {
64 unsigned int beg;
65 unsigned int end;
66 } rb_match_result_t;
67
68 rb_match_result_t *rb_reg_match_results(VALUE match, int *count);
69
1775a38 more string/regexp work
Laurent Sansonetti authored
70 static inline int
71 rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, bool reverse)
72 {
73 return reverse ? -pos : rb_str_chars_len(str) - pos;
74 }
4dbc956 more regexp work
Laurent Sansonetti authored
75
76 #if defined(__cplusplus)
77 } // extern "C"
78 #endif
79
80 #endif // __RE_H_
Something went wrong with that request. Please try again.