Skip to content

HTTPS clone URL

Subversion checkout URL

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