Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 82 lines (65 sloc) 2.471 kb
8354436 Hiroshi Mimaki add file header
mimaki authored
1 /*
2 ** re.h - Regexp class
4ec6d41 rm whitespace
roco authored
3 **
8354436 Hiroshi Mimaki add file header
mimaki authored
4 ** See Copyright Notice in mruby.h
5 */
e0d6430 Hiroshi 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 Yukihiro "Matz" Matsumoto remove st.h inclusion
matz authored
16 #include "st.h"
e0d6430 Hiroshi 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 {
97b7eb6 Yukihiro "Matz" Matsumoto rename MRUBY_OBJECT_HEADER to MRB_OBJECT_HEADER
matz authored
35 MRB_OBJECT_HEADER;
d0e63a3 Yukihiro "Matz" Matsumoto RMatch.src should not be mrb_value
matz authored
36 struct RString *str;
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
37 struct rmatch *rmatch;
c51c8dd Yukihiro "Matz" Matsumoto RMatch.regexp should not be mrb_value
matz authored
38 struct RRegexp *regexp;
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
39 };
40
41 struct RRegexp {
97b7eb6 Yukihiro "Matz" Matsumoto rename MRUBY_OBJECT_HEADER to MRB_OBJECT_HEADER
matz authored
42 MRB_OBJECT_HEADER;
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
43 struct re_pattern_buffer *ptr;
9182ab8 Yukihiro "Matz" Matsumoto RRegexp.src should not be mrb_value
matz authored
44 struct RString *src;
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
45 unsigned long usecnt;
46 };
47
48 #define mrb_regex_ptr(r) ((struct RRegexp*)((r).value.p))
49 #define RREGEXP(r) ((struct RRegexp*)((r).value.p))
50 #define RREGEXP_SRC(r) (RREGEXP(r)->src)
9182ab8 Yukihiro "Matz" Matsumoto RRegexp.src should not be mrb_value
matz authored
51 #define RREGEXP_SRC_PTR(r) (RREGEXP_SRC(r)->buf)
52 #define RREGEXP_SRC_LEN(r) (RREGEXP_SRC(r)->len)
e0d6430 Hiroshi Mimaki add mruby sources
mimaki authored
53 int re_adjust_startpos(struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range);
54
55 typedef struct re_pattern_buffer Regexp;
56
57 //#define RMATCH(obj) (R_CAST(RMatch)(obj))
58 #define RMATCH_REGS(v) (&((struct RMatch*)((v).value.p))->rmatch->regs)
59 #define RMATCH(v) ((struct RMatch*)((v).value.p))
60 #define mrb_match_ptr(v) ((struct RMatch*)((v).value.p))
61
62 int mrb_memcmp(const void *p1, const void *p2, int len);
63
64 mrb_int mrb_reg_search (mrb_state *mrb, mrb_value, mrb_value, mrb_int, mrb_int);
65 mrb_value mrb_reg_regsub (mrb_state *mrb, mrb_value, mrb_value, struct re_registers *, mrb_value);
66 //mrb_value mrb_reg_regsub(mrb_value, mrb_value, struct re_registers *, mrb_value);
67 mrb_int mrb_reg_adjust_startpos(mrb_state *mrb, mrb_value re, mrb_value str, mrb_int pos, mrb_int reverse);
68 void mrb_match_busy (mrb_value);
69
70 mrb_value mrb_reg_quote(mrb_state *mrb, mrb_value str);
71 mrb_value mrb_reg_regcomp(mrb_state *mrb, mrb_value str);
72 mrb_value mrb_reg_match_str(mrb_state *mrb, mrb_value re, mrb_value str);
73 mrb_value mrb_reg_nth_match(mrb_state *mrb, mrb_int nth, mrb_value match);
74 mrb_value mrb_backref_get(mrb_state *mrb);
75 //mrb_int mrb_memsearch(const void *x0, mrb_int m, const void *y0, mrb_int n);
76 mrb_value mrb_reg_to_s(mrb_state *mrb, mrb_value re);
77 void mrb_backref_set(mrb_state *mrb, mrb_value val);
78 mrb_value match_alloc(mrb_state *mrb);
79 int mrb_reg_backref_number(mrb_state *mrb, mrb_value match, mrb_value backref);
80
81 #endif
Something went wrong with that request. Please try again.