Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 87 lines (70 sloc) 2.573 kB
8354436 @mimaki add file header
mimaki authored
1 /*
2 ** re.h - Regexp class
4ec6d41 rm whitespace
roco authored
3 **
8354436 @mimaki add file header
mimaki authored
4 ** See Copyright Notice in mruby.h
5 */
e0d6430 @mimaki add mruby sources
mimaki authored
6
7 #ifndef RE_H
8 #define RE_H
9
10 //#include <sys/types.h>
11 #include <stdio.h>
12
13 #include "node.h"
14 #include "regex.h"
15 #include "encoding.h"
ae2cd24 @matz remove st.h inclusion
matz authored
16 #include "st.h"
e0d6430 @mimaki add mruby sources
mimaki authored
17
18 #define BEG(no) regs->beg[no]
19 #define END(no) regs->end[no]
20
21 struct rmatch_offset {
22 long beg;
23 long end;
24 };
25
26 struct rmatch {
27 struct re_registers regs;
28
29 int char_offset_updated;
30 int char_offset_num_allocated;
31 struct rmatch_offset *char_offset;
32 };
33
34 //struct RMatch {
35 // MRUBY_OBJECT_HEADER;
36 // mrb_value str;
37 // struct re_registers *regs;
38 //};
39 struct RMatch {
40 MRUBY_OBJECT_HEADER;
d0e63a3 @matz RMatch.src should not be mrb_value
matz authored
41 struct RString *str;
e0d6430 @mimaki add mruby sources
mimaki authored
42 struct rmatch *rmatch;
c51c8dd @matz RMatch.regexp should not be mrb_value
matz authored
43 struct RRegexp *regexp;
e0d6430 @mimaki add mruby sources
mimaki authored
44 };
45
46 struct RRegexp {
47 MRUBY_OBJECT_HEADER;
48 struct re_pattern_buffer *ptr;
9182ab8 @matz RRegexp.src should not be mrb_value
matz authored
49 struct RString *src;
e0d6430 @mimaki add mruby sources
mimaki authored
50 unsigned long usecnt;
51 };
52
53 #define mrb_regex_ptr(r) ((struct RRegexp*)((r).value.p))
54 #define RREGEXP(r) ((struct RRegexp*)((r).value.p))
55 #define RREGEXP_SRC(r) (RREGEXP(r)->src)
9182ab8 @matz RRegexp.src should not be mrb_value
matz authored
56 #define RREGEXP_SRC_PTR(r) (RREGEXP_SRC(r)->buf)
57 #define RREGEXP_SRC_LEN(r) (RREGEXP_SRC(r)->len)
e0d6430 @mimaki add mruby sources
mimaki authored
58 int re_adjust_startpos(struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range);
59
60 typedef struct re_pattern_buffer Regexp;
61
62 //#define RMATCH(obj) (R_CAST(RMatch)(obj))
63 #define RMATCH_REGS(v) (&((struct RMatch*)((v).value.p))->rmatch->regs)
64 #define RMATCH(v) ((struct RMatch*)((v).value.p))
65 #define mrb_match_ptr(v) ((struct RMatch*)((v).value.p))
66
67 int mrb_memcmp(const void *p1, const void *p2, int len);
68
69 mrb_int mrb_reg_search (mrb_state *mrb, mrb_value, mrb_value, mrb_int, mrb_int);
70 mrb_value mrb_reg_regsub (mrb_state *mrb, mrb_value, mrb_value, struct re_registers *, mrb_value);
71 //mrb_value mrb_reg_regsub(mrb_value, mrb_value, struct re_registers *, mrb_value);
72 mrb_int mrb_reg_adjust_startpos(mrb_state *mrb, mrb_value re, mrb_value str, mrb_int pos, mrb_int reverse);
73 void mrb_match_busy (mrb_value);
74
75 mrb_value mrb_reg_quote(mrb_state *mrb, mrb_value str);
76 mrb_value mrb_reg_regcomp(mrb_state *mrb, mrb_value str);
77 mrb_value mrb_reg_match_str(mrb_state *mrb, mrb_value re, mrb_value str);
78 mrb_value mrb_reg_nth_match(mrb_state *mrb, mrb_int nth, mrb_value match);
79 mrb_value mrb_backref_get(mrb_state *mrb);
80 //mrb_int mrb_memsearch(const void *x0, mrb_int m, const void *y0, mrb_int n);
81 mrb_value mrb_reg_to_s(mrb_state *mrb, mrb_value re);
82 void mrb_backref_set(mrb_state *mrb, mrb_value val);
83 mrb_value match_alloc(mrb_state *mrb);
84 int mrb_reg_backref_number(mrb_state *mrb, mrb_value match, mrb_value backref);
85
86 #endif
Something went wrong with that request. Please try again.