]> git.pld-linux.org Git - packages/ruby.git/blob - ruby-oniguruma-258-186.patch
- up
[packages/ruby.git] / ruby-oniguruma-258-186.patch
1 diff -urN oniguruma-185/Makefile.in oniguruma/Makefile.in
2 --- oniguruma-185/Makefile.in   2006-11-07 22:45:50.000000000 -0700
3 +++ oniguruma/Makefile.in       2007-02-19 22:34:07.000000000 -0700
4 @@ -214,7 +214,10 @@
5  185: cpruby
6         patch -d $(RUBYDIR) -p0 < $(srcdir)/ruby185.patch
7  
8 -18: 185
9 +186: cpruby
10 +       patch -d $(RUBYDIR) -p0 < $(srcdir)/ruby186.patch
11 +
12 +18: 186
13  
14  # backup file suffix
15  SORIG = ruby_orig
16 diff -urN oniguruma-185/ruby186.patch oniguruma/ruby186.patch
17 --- oniguruma-185/ruby186.patch 1969-12-31 17:00:00.000000000 -0700
18 +++ oniguruma/ruby186.patch     2007-02-19 22:34:54.000000000 -0700
19 @@ -0,0 +1,321 @@
20 +--- gc.c.ruby_orig     2006-08-25 17:12:46.000000000 +0900
21 ++++ gc.c       2006-11-08 14:11:06.000000000 +0900
22 +@@ -968,6 +968,7 @@ gc_mark_children(ptr, lev)
23 +       break;
24
25 +       case T_MATCH:
26 ++      gc_mark(obj->as.match.regexp, lev);
27 +       if (obj->as.match.str) {
28 +           ptr = obj->as.match.str;
29 +           goto again;
30 +--- re.h.ruby_orig     2003-03-04 23:12:19.000000000 +0900
31 ++++ re.h       2006-11-08 14:11:06.000000000 +0900
32 +@@ -24,13 +24,14 @@ struct RMatch {
33 +     struct RBasic basic;
34 +     VALUE str;
35 +     struct re_registers *regs;
36 ++    VALUE regexp; /* RRegexp */
37 + };
38
39 + #define RMATCH(obj)  (R_CAST(RMatch)(obj))
40
41 + VALUE rb_reg_regcomp _((VALUE));
42 + long rb_reg_search _((VALUE, VALUE, long, long));
43 +-VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *));
44 ++VALUE rb_reg_regsub _((VALUE, VALUE, struct re_registers *, VALUE));
45 + long rb_reg_adjust_startpos _((VALUE, VALUE, long, long));
46 + void rb_match_busy _((VALUE));
47 + VALUE rb_reg_quote _((VALUE));
48 +--- re.c.ruby_orig     2007-02-12 16:01:19.000000000 -0700
49 ++++ re.c       2007-02-19 22:32:31.000000000 -0700
50 +@@ -486,10 +486,12 @@
51 +       }
52 +       if (*ptr == ':' && ptr[len-1] == ')') {
53 +           Regexp *rp;
54 ++                      int r;
55 +           rb_kcode_set_option(re);
56 +-          rp = ALLOC(Regexp);
57 +-          MEMZERO((char *)rp, Regexp, 1);
58 +-          err = re_compile_pattern(++ptr, len -= 2, rp) != 0;
59 ++          r = re_alloc_pattern(&rp);
60 ++          if (r == 0) {
61 ++            err = (re_compile_pattern(++ptr, len -= 2, rp, NULL) != 0);
62 ++          }
63 +           rb_kcode_reset_option();
64 +           re_free_pattern(rp);
65 +       }
66 +@@ -623,7 +625,9 @@
67 +     int flags;
68 + {
69 +     Regexp *rp;
70 +-    char *err;
71 ++    char err[ONIG_MAX_ERROR_MESSAGE_LEN];
72 ++    int r;
73 ++
74
75 +     /* Handle escaped characters first. */
76
77 +@@ -632,17 +636,18 @@
78 +        from that.
79 +     */
80
81 +-    rp = ALLOC(Regexp);
82 +-    MEMZERO((char *)rp, Regexp, 1);
83 +-    rp->buffer = ALLOC_N(char, 16);
84 +-    rp->allocated = 16;
85 +-    rp->fastmap = ALLOC_N(char, 256);
86 ++    r = re_alloc_pattern(&rp);
87 ++    if (r) {
88 ++      re_error_code_to_str((UChar* )err, r);
89 ++      rb_reg_raise(s, len, err, 0);
90 ++    }
91 ++
92 +     if (flags) {
93 +       rp->options = flags;
94 +     }
95 +-    err = re_compile_pattern(s, len, rp);
96 ++    r = re_compile_pattern(s, len, rp, err);
97
98 +-    if (err != NULL) {
99 ++    if (r != 0) {
100 +       re_free_pattern(rp);
101 +       rb_reg_raise(s, len, err, 0);
102 +       return 0;
103 +@@ -676,6 +681,7 @@
104
105 +     match->str = 0;
106 +     match->regs = 0;
107 ++    match->regexp = 0;
108 +     match->regs = ALLOC(struct re_registers);
109 +     MEMZERO(match->regs, struct re_registers, 1);
110
111 +@@ -693,6 +699,7 @@
112 +       rb_raise(rb_eTypeError, "wrong argument class");
113 +     }
114 +     RMATCH(obj)->str = RMATCH(orig)->str;
115 ++    RMATCH(obj)->regexp = RMATCH(orig)->regexp;
116 +     re_free_registers(RMATCH(obj)->regs);
117 +     RMATCH(obj)->regs->allocated = 0;
118 +     re_copy_registers(RMATCH(obj)->regs, RMATCH(orig)->regs);
119 +@@ -846,14 +853,15 @@
120 +     }
121
122 +     if (need_recompile) {
123 +-      char *err;
124 ++      char err[ONIG_MAX_ERROR_MESSAGE_LEN];
125 ++      int r;
126 ++ 
127
128 +       if (FL_TEST(re, KCODE_FIXED))
129 +           rb_kcode_set_option(re);
130 +       rb_reg_check(re);
131 +-      RREGEXP(re)->ptr->fastmap_accurate = 0;
132 +-      err = re_compile_pattern(RREGEXP(re)->str, RREGEXP(re)->len, RREGEXP(re)->ptr);
133 +-      if (err != NULL) {
134 ++      r = re_recompile_pattern(RREGEXP(re)->str, RREGEXP(re)->len, RREGEXP(re)->ptr, err);
135 ++      if (r != 0) {
136 +           rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len, err, re);
137 +       }
138 +     }
139 +@@ -920,14 +928,16 @@
140 +     if (FL_TEST(re, KCODE_FIXED))
141 +       rb_kcode_reset_option();
142
143 +-    if (result == -2) {
144 +-      rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len,
145 +-                   "Stack overflow in regexp matcher", re);
146 +-    }
147 +-
148 +     if (result < 0) {
149 +-      rb_backref_set(Qnil);
150 +-      return result;
151 ++      if (result == ONIG_MISMATCH) {
152 ++        rb_backref_set(Qnil);
153 ++        return result;
154 ++      }
155 ++      else {
156 ++        char err[ONIG_MAX_ERROR_MESSAGE_LEN];
157 ++        re_error_code_to_str((UChar* )err, result);
158 ++        rb_reg_raise(RREGEXP(re)->str, RREGEXP(re)->len, err, 0);
159 ++      }
160 +     }
161
162 +     match = rb_backref_get();
163 +@@ -943,6 +953,7 @@
164
165 +     re_copy_registers(RMATCH(match)->regs, &regs);
166 +     RMATCH(match)->str = rb_str_new4(str);
167 ++    RMATCH(match)->regexp = re;
168 +     rb_backref_set(match);
169
170 +     OBJ_INFECT(match, re);
171 +@@ -1170,6 +1181,23 @@
172 + }
173
174
175 ++static int
176 ++name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
177 ++{
178 ++  int num;
179 ++
180 ++  num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
181 ++            (unsigned char* )name, (unsigned char* )name_end, regs);
182 ++  if (num >= 1) {
183 ++    return num;
184 ++  }
185 ++  else {
186 ++    VALUE s = rb_str_new(name, (long )(name_end - name));
187 ++    rb_raise(rb_eRuntimeError, "undefined group name reference: %s",
188 ++                                StringValuePtr(s));
189 ++  }
190 ++}
191 ++
192 + /*
193 +  *  call-seq:
194 +  *     mtch[i]               => obj
195 +@@ -1199,10 +1227,37 @@
196
197 +     rb_scan_args(argc, argv, "11", &idx, &rest);
198
199 +-    if (!NIL_P(rest) || !FIXNUM_P(idx) || FIX2INT(idx) < 0) {
200 +-      return rb_ary_aref(argc, argv, match_to_a(match));
201 ++    if (NIL_P(rest)) {
202 ++      if (FIXNUM_P(idx)) {
203 ++        if (FIX2INT(idx) >= 0) {
204 ++          return rb_reg_nth_match(FIX2INT(idx), match);
205 ++        }
206 ++      }
207 ++      else {
208 ++        const char *p;
209 ++        int num;
210 ++
211 ++        switch (TYPE(idx)) {
212 ++          case T_SYMBOL:
213 ++            p = rb_id2name(SYM2ID(idx));
214 ++            goto name_to_backref;
215 ++            break;
216 ++          case T_STRING:
217 ++            p = StringValuePtr(idx);
218 ++
219 ++          name_to_backref:
220 ++            num = name_to_backref_number(RMATCH(match)->regs,
221 ++                       RMATCH(match)->regexp, p, p + strlen(p));
222 ++            return rb_reg_nth_match(num, match);
223 ++            break;
224 ++
225 ++          default:
226 ++            break;
227 ++        }
228 ++      }
229 +     }
230 +-    return rb_reg_nth_match(FIX2INT(idx), match);
231 ++
232 ++    return rb_ary_aref(argc, argv, match_to_a(match));
233 + }
234
235 + static VALUE match_entry _((VALUE, long));
236 +@@ -2001,12 +2056,14 @@
237 + }
238
239 + VALUE
240 +-rb_reg_regsub(str, src, regs)
241 ++rb_reg_regsub(str, src, regs, regexp)
242 +     VALUE str, src;
243 +     struct re_registers *regs;
244 ++    VALUE regexp;
245 + {
246 +     VALUE val = 0;
247 +-    char *p, *s, *e, c;
248 ++    char *p, *s, *e;
249 ++    unsigned char uc;
250 +     int no;
251
252 +     p = s = RSTRING(str)->ptr;
253 +@@ -2015,12 +2072,12 @@
254 +     while (s < e) {
255 +       char *ss = s;
256
257 +-      c = *s++;
258 +-      if (ismbchar(c)) {
259 +-          s += mbclen(c) - 1;
260 ++      uc = (unsigned char )*s++;
261 ++      if (ismbchar(uc)) {
262 ++          s += mbclen(uc) - 1;
263 +           continue;
264 +       }
265 +-      if (c != '\\' || s == e) continue;
266 ++      if (uc != '\\' || s == e) continue;
267
268 +       if (!val) {
269 +           val = rb_str_buf_new(ss-p);
270 +@@ -2030,13 +2087,38 @@
271 +           rb_str_buf_cat(val, p, ss-p);
272 +       }
273
274 +-      c = *s++;
275 ++      uc = (unsigned char )*s++;
276 +       p = s;
277 +-      switch (c) {
278 +-        case '0': case '1': case '2': case '3': case '4':
279 ++      switch (uc) {
280 ++        case '1': case '2': case '3': case '4':
281 +         case '5': case '6': case '7': case '8': case '9':
282 +-          no = c - '0';
283 ++          no = uc - '0';
284 +           break;
285 ++
286 ++          case 'k':
287 ++            if (s < e && *s == '<') {
288 ++              char *name, *name_end;
289 ++
290 ++              name_end = name = s + 1;
291 ++              while (name_end < e) {
292 ++                if (*name_end == '>') break;
293 ++                uc = (unsigned char)*name_end;
294 ++                name_end += mbclen(uc);
295 ++              }
296 ++              if (name_end < e) {
297 ++                no = name_to_backref_number(regs, regexp, name, name_end);
298 ++                p = s = name_end + 1;
299 ++                break;
300 ++              }
301 ++              else {
302 ++                rb_raise(rb_eRuntimeError, "invalid group name reference format");
303 ++              }
304 ++            }
305 ++
306 ++            rb_str_buf_cat(val, s-2, 2);
307 ++            continue;
308 ++
309 ++        case '0':
310 +         case '&':
311 +           no = 0;
312 +           break;
313 +@@ -2282,6 +2364,7 @@
314 +     rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(RE_OPTION_IGNORECASE));
315 +     rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(RE_OPTION_EXTENDED));
316 +     rb_define_const(rb_cRegexp, "MULTILINE", INT2FIX(RE_OPTION_MULTILINE));
317 ++    rb_define_const(rb_cRegexp, "ENGINE",    rb_obj_freeze(rb_str_new2("Oniguruma")));
318
319 +     rb_global_variable(&reg_cache);
320
321 +--- string.c.ruby_orig 2006-07-31 15:34:10.000000000 +0900
322 ++++ string.c   2006-11-08 14:11:06.000000000 +0900
323 +@@ -1977,7 +1977,7 @@ rb_str_sub_bang(argc, argv, str)
324 +           rb_backref_set(match);
325 +       }
326 +       else {
327 +-          repl = rb_reg_regsub(repl, str, regs);
328 ++        repl = rb_reg_regsub(repl, str, regs, pat);
329 +       }
330 +       if (OBJ_TAINTED(repl)) tainted = 1;
331 +       plen = END(0) - BEG(0);
332 +@@ -2100,7 +2100,7 @@ str_gsub(argc, argv, str, bang)
333 +           rb_backref_set(match);
334 +       }
335 +       else {
336 +-          val = rb_reg_regsub(repl, str, regs);
337 ++        val = rb_reg_regsub(repl, str, regs, pat);
338 +       }
339 +       if (OBJ_TAINTED(val)) tainted = 1;
340 +       len = (bp - buf) + (beg - offset) + RSTRING(val)->len + 3;
This page took 0.106921 seconds and 3 git commands to generate.