~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to re.c

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2005-09-21 13:16:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050921131619-qhlm5e5pz3bvsh2g
Tags: 1.9.0+20050921-1
* akira yamada <akira@debian.org>
- new upstream snapshot. (2005-09-21)
    - [security] JVN#62914675 CVE-2005-2337
        - preserve safe level in the environment where a method is defined.
        - prohibit calling tainted method (>2) when $SAFE == 0.
- removed debian/patches/802_workaround_for_send.dpatch:
    - the patch is in upstream.
- debian/control: build-depends on libreadline5-dev.  (closes: #326333)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
  re.c -
4
4
 
5
 
  $Author: matz $
 
5
  $Author: ocean $
6
6
  created at: Mon Aug  9 18:24:49 JST 1993
7
7
 
8
8
  Copyright (C) 1993-2003 Yukihiro Matsumoto
76
76
#endif
77
77
 
78
78
int
79
 
rb_memcicmp(p1, p2, len)
80
 
    char *p1, *p2;
81
 
    long len;
 
79
rb_memcicmp(char *p1, char *p2, long len)
82
80
{
83
81
    int tmp;
84
82
 
90
88
}
91
89
 
92
90
int
93
 
rb_memcmp(p1, p2, len)
94
 
    char *p1, *p2;
95
 
    long len;
 
91
rb_memcmp(char *p1, char *p2, long len)
96
92
{
97
93
    if (!ruby_ignorecase) {
98
94
        return memcmp(p1, p2, len);
101
97
}
102
98
 
103
99
long
104
 
rb_memsearch(x0, m, y0, n)
105
 
    char *x0, *y0;
106
 
    long m, n;
 
100
rb_memsearch(char *x0, long m, char *y0, long n)
107
101
{
108
102
    unsigned char *x = (unsigned char *)x0, *y = (unsigned char *)y0;
109
103
    unsigned char *s, *e;
168
162
static int reg_kcode = DEFAULT_KCODE;
169
163
 
170
164
static void
171
 
kcode_euc(re)
172
 
    struct RRegexp *re;
 
165
kcode_euc(struct RRegexp *re)
173
166
{
174
167
    FL_UNSET(re, KCODE_MASK);
175
168
    FL_SET(re, KCODE_EUC);
177
170
}
178
171
 
179
172
static void
180
 
kcode_sjis(re)
181
 
    struct RRegexp *re;
 
173
kcode_sjis(struct RRegexp *re)
182
174
{
183
175
    FL_UNSET(re, KCODE_MASK);
184
176
    FL_SET(re, KCODE_SJIS);
186
178
}
187
179
 
188
180
static void
189
 
kcode_utf8(re)
190
 
    struct RRegexp *re;
 
181
kcode_utf8(struct RRegexp *re)
191
182
{
192
183
    FL_UNSET(re, KCODE_MASK);
193
184
    FL_SET(re, KCODE_UTF8);
195
186
}
196
187
 
197
188
static void
198
 
kcode_none(re)
199
 
    struct RRegexp *re;
 
189
kcode_none(struct RRegexp *re)
200
190
{
201
191
    FL_UNSET(re, KCODE_MASK);
202
192
    FL_SET(re, KCODE_FIXED);
205
195
static int curr_kcode;
206
196
 
207
197
static void
208
 
kcode_set_option(re)
209
 
    VALUE re;
 
198
kcode_set_option(VALUE re)
210
199
{
211
200
    if (!FL_TEST(re, KCODE_FIXED)) return;
212
201
 
229
218
}
230
219
 
231
220
static void
232
 
kcode_reset_option()
 
221
kcode_reset_option(void)
233
222
{
234
223
    if (reg_kcode == curr_kcode) return;
235
224
    switch (reg_kcode) {
249
238
}
250
239
 
251
240
int
252
 
rb_reg_mbclen2(c, re)
253
 
    unsigned int c;
254
 
    VALUE re;
 
241
rb_reg_mbclen2(unsigned int c, VALUE re)
255
242
{
256
243
    int len;
257
244
    unsigned char uc = (unsigned char)c;
265
252
}
266
253
 
267
254
static void
268
 
rb_reg_check(re)
269
 
    VALUE re;
 
255
rb_reg_check(VALUE re)
270
256
{
271
257
    if (!RREGEXP(re)->ptr || !RREGEXP(re)->str) {
272
258
        rb_raise(rb_eTypeError, "uninitialized Regexp");
274
260
}
275
261
 
276
262
static void
277
 
rb_reg_expr_str(str, s, len)
278
 
    VALUE str;
279
 
    const char *s;
280
 
    long len;
 
263
rb_reg_expr_str(VALUE str, const char *s, long len)
281
264
{
282
265
    const char *p, *pend;
283
266
    int need_escape = 0;
330
313
}
331
314
 
332
315
static VALUE
333
 
rb_reg_desc(s, len, re)
334
 
    const char *s;
335
 
    long len;
336
 
    VALUE re;
 
316
rb_reg_desc(const char *s, long len, VALUE re)
337
317
{
338
318
    VALUE str = rb_str_buf_new2("/");
339
319
 
380
360
 */
381
361
 
382
362
static VALUE
383
 
rb_reg_source(re)
384
 
    VALUE re;
 
363
rb_reg_source(VALUE re)
385
364
{
386
365
    VALUE str;
387
366
 
403
382
*/
404
383
 
405
384
static VALUE
406
 
rb_reg_inspect(re)
407
 
    VALUE re;
 
385
rb_reg_inspect(VALUE re)
408
386
{
409
387
    rb_reg_check(re);
410
388
    return rb_reg_desc(RREGEXP(re)->str, RREGEXP(re)->len, re);
432
410
 */
433
411
 
434
412
static VALUE
435
 
rb_reg_to_s(re)
436
 
    VALUE re;
 
413
rb_reg_to_s(VALUE re)
437
414
{
438
415
    int options;
439
416
    const int embeddable = ONIG_OPTION_MULTILINE|ONIG_OPTION_IGNORECASE|ONIG_OPTION_EXTEND;
530
507
}
531
508
 
532
509
static void
533
 
rb_reg_raise(s, len, err, re, ce)
534
 
    const char *s;
535
 
    long len;
536
 
    const char *err;
537
 
    VALUE re;
538
 
    int ce;
 
510
rb_reg_raise(const char *s, long len, const char *err, VALUE re, int ce)
539
511
{
540
512
    VALUE desc = rb_reg_desc(s, len, re);
541
513
 
554
526
 */
555
527
 
556
528
static VALUE
557
 
rb_reg_casefold_p(re)
558
 
    VALUE re;
 
529
rb_reg_casefold_p(VALUE re)
559
530
{
560
531
    rb_reg_check(re);
561
532
    if (RREGEXP(re)->ptr->options & ONIG_OPTION_IGNORECASE) return Qtrue;
587
558
 */
588
559
 
589
560
static VALUE
590
 
rb_reg_options_m(re)
591
 
    VALUE re;
 
561
rb_reg_options_m(VALUE re)
592
562
{
593
563
    int options = rb_reg_options(re);
594
564
    return INT2NUM(options);
603
573
 */
604
574
 
605
575
static VALUE
606
 
rb_reg_kcode_m(re)
607
 
    VALUE re;
 
576
rb_reg_kcode_m(VALUE re)
608
577
{
609
578
    char *kcode;
610
579
 
628
597
}
629
598
 
630
599
static Regexp*
631
 
make_regexp(s, len, flags, ce)
632
 
    const char *s;
633
 
    long len;
634
 
    int flags;
635
 
    int ce;
 
600
make_regexp(const char *s, long len, int flags, int ce)
636
601
{
637
602
    Regexp *rp;
638
603
    char err[ONIG_MAX_ERROR_MESSAGE_LEN];
682
647
 
683
648
static VALUE rb_cMatch;
684
649
 
685
 
static VALUE match_alloc _((VALUE));
686
650
static VALUE
687
 
match_alloc(klass)
688
 
    VALUE klass;
 
651
match_alloc(VALUE klass)
689
652
{
690
653
    NEWOBJ(match, struct RMatch);
691
654
    OBJSETUP(match, klass, T_MATCH);
700
663
 
701
664
/* :nodoc: */
702
665
static VALUE
703
 
match_init_copy(obj, orig)
704
 
    VALUE obj, orig;
 
666
match_init_copy(VALUE obj, VALUE orig)
705
667
{
706
668
    if (obj == orig) return obj;
707
669
 
730
692
 */
731
693
 
732
694
static VALUE
733
 
match_size(match)
734
 
    VALUE match;
 
695
match_size(VALUE match)
735
696
{
736
697
    return INT2FIX(RMATCH(match)->regs->num_regs);
737
698
}
750
711
 */
751
712
 
752
713
static VALUE
753
 
match_offset(match, n)
754
 
    VALUE match, n;
 
714
match_offset(VALUE match, VALUE n)
755
715
{
756
716
    int i = NUM2INT(n);
757
717
 
779
739
 */
780
740
 
781
741
static VALUE
782
 
match_begin(match, n)
783
 
    VALUE match, n;
 
742
match_begin(VALUE match, VALUE n)
784
743
{
785
744
    int i = NUM2INT(n);
786
745
 
807
766
 */
808
767
 
809
768
static VALUE
810
 
match_end(match, n)
811
 
    VALUE match, n;
 
769
match_end(VALUE match, VALUE n)
812
770
{
813
771
    int i = NUM2INT(n);
814
772
 
824
782
#define MATCH_BUSY FL_USER2
825
783
 
826
784
void
827
 
rb_match_busy(match)
828
 
    VALUE match;
 
785
rb_match_busy(VALUE match)
829
786
{
830
787
    FL_SET(match, MATCH_BUSY);
831
788
}
834
791
static int may_need_recompile;
835
792
 
836
793
static void
837
 
rb_reg_prepare_re(re)
838
 
    VALUE re;
 
794
rb_reg_prepare_re(VALUE re)
839
795
{
840
796
    int need_recompile = 0;
841
797
    int state;
885
841
}
886
842
 
887
843
long
888
 
rb_reg_adjust_startpos(re, str, pos, reverse)
889
 
    VALUE re, str;
890
 
    long pos, reverse;
 
844
rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, long reverse)
891
845
{
892
846
    long range;
893
847
    OnigEncoding enc;
926
880
}
927
881
 
928
882
long
929
 
rb_reg_search(re, str, pos, reverse)
930
 
    VALUE re, str;
931
 
    long pos, reverse;
 
883
rb_reg_search(VALUE re, VALUE str, long pos, long reverse)
932
884
{
933
885
    long result;
934
886
    VALUE match;
998
950
}
999
951
 
1000
952
VALUE
1001
 
rb_reg_nth_defined(nth, match)
1002
 
    int nth;
1003
 
    VALUE match;
 
953
rb_reg_nth_defined(int nth, VALUE match)
1004
954
{
1005
955
    if (NIL_P(match)) return Qnil;
1006
956
    if (nth >= RMATCH(match)->regs->num_regs) {
1015
965
}
1016
966
 
1017
967
VALUE
1018
 
rb_reg_nth_match(nth, match)
1019
 
    int nth;
1020
 
    VALUE match;
 
968
rb_reg_nth_match(int nth, VALUE match)
1021
969
{
1022
970
    VALUE str;
1023
971
    long start, end, len;
1040
988
}
1041
989
 
1042
990
VALUE
1043
 
rb_reg_last_match(match)
1044
 
    VALUE match;
 
991
rb_reg_last_match(VALUE match)
1045
992
{
1046
993
    return rb_reg_nth_match(0, match);
1047
994
}
1059
1006
 */
1060
1007
 
1061
1008
VALUE
1062
 
rb_reg_match_pre(match)
1063
 
    VALUE match;
 
1009
rb_reg_match_pre(VALUE match)
1064
1010
{
1065
1011
    VALUE str;
1066
1012
 
1084
1030
 */
1085
1031
 
1086
1032
VALUE
1087
 
rb_reg_match_post(match)
1088
 
    VALUE match;
 
1033
rb_reg_match_post(VALUE match)
1089
1034
{
1090
1035
    VALUE str;
1091
1036
    long pos;
1100
1045
}
1101
1046
 
1102
1047
VALUE
1103
 
rb_reg_match_last(match)
1104
 
    VALUE match;
 
1048
rb_reg_match_last(VALUE match)
1105
1049
{
1106
1050
    int i;
1107
1051
 
1115
1059
}
1116
1060
 
1117
1061
static VALUE
1118
 
last_match_getter()
 
1062
last_match_getter(void)
1119
1063
{
1120
1064
    return rb_reg_last_match(rb_backref_get());
1121
1065
}
1122
1066
 
1123
1067
static VALUE
1124
 
prematch_getter()
 
1068
prematch_getter(void)
1125
1069
{
1126
1070
    return rb_reg_match_pre(rb_backref_get());
1127
1071
}
1128
1072
 
1129
1073
static VALUE
1130
 
postmatch_getter()
 
1074
postmatch_getter(void)
1131
1075
{
1132
1076
    return rb_reg_match_post(rb_backref_get());
1133
1077
}
1134
1078
 
1135
1079
static VALUE
1136
 
last_paren_match_getter()
 
1080
last_paren_match_getter(void)
1137
1081
{
1138
1082
    return rb_reg_match_last(rb_backref_get());
1139
1083
}
1140
1084
 
1141
1085
static VALUE
1142
 
match_array(match, start)
1143
 
    VALUE match;
1144
 
    int start;
 
1086
match_array(VALUE match, int start)
1145
1087
{
1146
1088
    struct re_registers *regs = RMATCH(match)->regs;
1147
1089
    VALUE ary = rb_ary_new2(regs->num_regs);
1190
1132
 */
1191
1133
 
1192
1134
static VALUE
1193
 
match_to_a(match)
1194
 
    VALUE match;
 
1135
match_to_a(VALUE match)
1195
1136
{
1196
1137
    return match_array(match, 0);
1197
1138
}
1210
1151
 *     f4    #=> "8"
1211
1152
 */
1212
1153
static VALUE
1213
 
match_captures(match)
1214
 
    VALUE match;
 
1154
match_captures(VALUE match)
1215
1155
{
1216
1156
    return match_array(match, 1);
1217
1157
}
1237
1177
 */
1238
1178
 
1239
1179
static VALUE
1240
 
match_aref(argc, argv, match)
1241
 
    int argc;
1242
 
    VALUE *argv;
1243
 
    VALUE match;
 
1180
match_aref(int argc, VALUE *argv, VALUE match)
1244
1181
{
1245
1182
    VALUE idx, rest;
1246
1183
 
1252
1189
    return rb_reg_nth_match(FIX2INT(idx), match);
1253
1190
}
1254
1191
 
1255
 
static VALUE match_entry _((VALUE, long));
1256
1192
static VALUE
1257
 
match_entry(match, n)
1258
 
    VALUE match;
1259
 
    long n;
 
1193
match_entry(VALUE match, long n)
1260
1194
{
1261
1195
    return rb_reg_nth_match(n, match);
1262
1196
}
1275
1209
 */
1276
1210
 
1277
1211
static VALUE
1278
 
match_values_at(argc, argv, match)
1279
 
    int argc;
1280
 
    VALUE *argv;
1281
 
    VALUE match;
 
1212
match_values_at(int argc, VALUE *argv, VALUE match)
1282
1213
{
1283
1214
    return rb_get_values_at(match, RMATCH(match)->regs->num_regs, argc, argv, match_entry);
1284
1215
}
1297
1228
 */
1298
1229
 
1299
1230
static VALUE
1300
 
match_select(argc, argv, match)
1301
 
    int argc;
1302
 
    VALUE *argv;
1303
 
    VALUE match;
 
1231
match_select(int argc, VALUE *argv, VALUE match)
1304
1232
{
1305
1233
    if (argc > 0) {
1306
1234
        rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
1335
1263
 */
1336
1264
 
1337
1265
static VALUE
1338
 
match_to_s(match)
1339
 
    VALUE match;
 
1266
match_to_s(VALUE match)
1340
1267
{
1341
1268
    VALUE str = rb_reg_last_match(match);
1342
1269
 
1358
1285
 */
1359
1286
 
1360
1287
static VALUE
1361
 
match_string(match)
1362
 
    VALUE match;
 
1288
match_string(VALUE match)
1363
1289
{
1364
1290
    return RMATCH(match)->str;  /* str is frozen */
1365
1291
}
1367
1293
VALUE rb_cRegexp;
1368
1294
 
1369
1295
static void
1370
 
rb_reg_initialize(obj, s, len, options, ce)
1371
 
    VALUE obj;
1372
 
    const char *s;
1373
 
    long len;
1374
 
    int options;                /* CASEFOLD  = 1 */
 
1296
rb_reg_initialize(VALUE obj, const char *s, long len,
 
1297
    int options,                /* CASEFOLD  = 1 */
1375
1298
                                /* EXTENDED  = 2 */
1376
1299
                                /* MULTILINE = 4 */
1377
1300
                                /* CODE_NONE = 16 */
1378
1301
                                /* CODE_EUC  = 32 */
1379
1302
                                /* CODE_SJIS = 48 */
1380
1303
                                /* CODE_UTF8 = 64 */
1381
 
    int ce;                     /* call rb_compile_error() */
 
1304
    int ce)                     /* call rb_compile_error() */
1382
1305
{
1383
1306
    struct RRegexp *re = RREGEXP(obj);
1384
1307
 
1423
1346
    }
1424
1347
}
1425
1348
 
1426
 
static VALUE rb_reg_s_alloc _((VALUE));
1427
1349
static VALUE
1428
 
rb_reg_s_alloc(klass)
1429
 
    VALUE klass;
 
1350
rb_reg_s_alloc(VALUE klass)
1430
1351
{
1431
1352
    NEWOBJ(re, struct RRegexp);
1432
1353
    OBJSETUP(re, klass, T_REGEXP);
1439
1360
}
1440
1361
 
1441
1362
VALUE
1442
 
rb_reg_new(s, len, options)
1443
 
    const char *s;
1444
 
    long len;
1445
 
    int options;
 
1363
rb_reg_new(const char *s, long len, int options)
1446
1364
{
1447
1365
    VALUE re = rb_reg_s_alloc(rb_cRegexp);
1448
1366
 
1451
1369
}
1452
1370
 
1453
1371
VALUE
1454
 
rb_reg_compile(s, len, options)
1455
 
    const char *s;
1456
 
    long len;
1457
 
    int options;
 
1372
rb_reg_compile(const char *s, long len, int options)
1458
1373
{
1459
1374
    VALUE re = rb_reg_s_alloc(rb_cRegexp);
1460
1375
 
1467
1382
static VALUE reg_cache;
1468
1383
 
1469
1384
VALUE
1470
 
rb_reg_regcomp(str)
1471
 
    VALUE str;
 
1385
rb_reg_regcomp(VALUE str)
1472
1386
{
1473
1387
    if (reg_cache && RREGEXP(reg_cache)->len == RSTRING(str)->len
1474
1388
        && case_cache == ruby_ignorecase
1483
1397
}
1484
1398
 
1485
1399
static int
1486
 
rb_reg_cur_kcode(re)
1487
 
    VALUE re;
 
1400
rb_reg_cur_kcode(VALUE re)
1488
1401
{
1489
1402
    if (FL_TEST(re, KCODE_FIXED)) {
1490
1403
        return RBASIC(re)->flags & KCODE_MASK;
1500
1413
 */
1501
1414
 
1502
1415
static VALUE
1503
 
rb_reg_hash(re)
1504
 
    VALUE re;
 
1416
rb_reg_hash(VALUE re)
1505
1417
{
1506
1418
    int hashval, len;
1507
1419
    char *p;
1534
1446
 */
1535
1447
 
1536
1448
static VALUE
1537
 
rb_reg_equal(re1, re2)
1538
 
    VALUE re1, re2;
 
1449
rb_reg_equal(VALUE re1, VALUE re2)
1539
1450
{
1540
1451
    if (re1 == re2) return Qtrue;
1541
1452
    if (TYPE(re2) != T_REGEXP) return Qfalse;
1550
1461
}
1551
1462
 
1552
1463
static VALUE
1553
 
rb_reg_match_pos(re, str, pos)
1554
 
    VALUE re, str;
1555
 
    long pos;
 
1464
rb_reg_match_pos(VALUE re, VALUE str, long pos)
1556
1465
{
1557
1466
    if (NIL_P(str)) {
1558
1467
        rb_backref_set(Qnil);
1585
1494
 */
1586
1495
 
1587
1496
VALUE
1588
 
rb_reg_match(re, str)
1589
 
    VALUE re, str;
 
1497
rb_reg_match(VALUE re, VALUE str)
1590
1498
{
1591
1499
    return rb_reg_match_pos(re, str, 0);
1592
1500
}
1610
1518
 */
1611
1519
 
1612
1520
VALUE
1613
 
rb_reg_eqq(re, str)
1614
 
    VALUE re, str;
 
1521
rb_reg_eqq(VALUE re, VALUE str)
1615
1522
{
1616
1523
    long start;
1617
1524
 
1643
1550
 */
1644
1551
 
1645
1552
VALUE
1646
 
rb_reg_match2(re)
1647
 
    VALUE re;
 
1553
rb_reg_match2(VALUE re)
1648
1554
{
1649
1555
    long start;
1650
1556
    VALUE line = rb_lastline_get();
1678
1584
 */
1679
1585
 
1680
1586
static VALUE
1681
 
rb_reg_match_m(argc, argv, re)
1682
 
    int argc;
1683
 
    VALUE *argv;
1684
 
    VALUE re;
 
1587
rb_reg_match_m(int argc, VALUE *argv, VALUE re)
1685
1588
{
1686
1589
    VALUE result, str, initpos;
1687
1590
    long pos;
1735
1638
 */
1736
1639
 
1737
1640
static VALUE
1738
 
rb_reg_initialize_m(argc, argv, self)
1739
 
    int argc;
1740
 
    VALUE *argv;
1741
 
    VALUE self;
 
1641
rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
1742
1642
{
1743
1643
    const char *s;
1744
1644
    long len;
1809
1709
}
1810
1710
 
1811
1711
VALUE
1812
 
rb_reg_quote(str)
1813
 
    VALUE str;
 
1712
rb_reg_quote(VALUE str)
1814
1713
{
1815
1714
    char *s, *send, *t;
1816
1715
    VALUE tmp;
1908
1807
 */
1909
1808
 
1910
1809
static VALUE
1911
 
rb_reg_s_quote(argc, argv)
1912
 
    int argc;
1913
 
    VALUE *argv;
 
1810
rb_reg_s_quote(int argc, VALUE *argv)
1914
1811
{
1915
1812
    VALUE str, kcode;
1916
1813
    int kcode_saved = reg_kcode;
1928
1825
}
1929
1826
 
1930
1827
int
1931
 
rb_kcode()
 
1828
rb_kcode(void)
1932
1829
{
1933
1830
    switch (reg_kcode) {
1934
1831
      case KCODE_EUC:
1944
1841
}
1945
1842
 
1946
1843
static int
1947
 
rb_reg_get_kcode(re)
1948
 
    VALUE re;
 
1844
rb_reg_get_kcode(VALUE re)
1949
1845
{
1950
1846
    switch (RBASIC(re)->flags & KCODE_MASK) {
1951
1847
      case KCODE_NONE:
1962
1858
}
1963
1859
 
1964
1860
int
1965
 
rb_reg_options(re)
1966
 
    VALUE re;
 
1861
rb_reg_options(VALUE re)
1967
1862
{
1968
1863
    int options;
1969
1864
 
1992
1887
 *     Regexp.union(/dogs/, /cats/i)        #=> /(?-mix:dogs)|(?i-mx:cats)/
1993
1888
 */
1994
1889
static VALUE
1995
 
rb_reg_s_union(argc, argv)
1996
 
    int argc;
1997
 
    VALUE *argv;
 
1890
rb_reg_s_union(int argc, VALUE *argv)
1998
1891
{
1999
1892
    if (argc == 0) {
2000
1893
        VALUE args[1];
2069
1962
 
2070
1963
/* :nodoc: */
2071
1964
static VALUE
2072
 
rb_reg_init_copy(copy, re)
2073
 
    VALUE copy, re;
 
1965
rb_reg_init_copy(VALUE copy, VALUE re)
2074
1966
{
2075
1967
    if (copy == re) return copy;
2076
1968
    rb_check_frozen(copy);
2085
1977
}
2086
1978
 
2087
1979
VALUE
2088
 
rb_reg_regsub(str, src, regs)
2089
 
    VALUE str, src;
2090
 
    struct re_registers *regs;
 
1980
rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs)
2091
1981
{
2092
1982
    VALUE val = 0;
2093
1983
    char *p, *s, *e;
2172
2062
}
2173
2063
 
2174
2064
const char*
2175
 
rb_get_kcode()
 
2065
rb_get_kcode(void)
2176
2066
{
2177
2067
    switch (reg_kcode) {
2178
2068
      case KCODE_SJIS:
2187
2077
}
2188
2078
 
2189
2079
static VALUE
2190
 
kcode_getter()
 
2080
kcode_getter(void)
2191
2081
{
2192
2082
    return rb_str_new2(rb_get_kcode());
2193
2083
}
2194
2084
 
2195
2085
void
2196
 
rb_set_kcode(code)
2197
 
    const char *code;
 
2086
rb_set_kcode(const char *code)
2198
2087
{
2199
2088
    if (code == 0) goto set_no_conversion;
2200
2089
 
2227
2116
}
2228
2117
 
2229
2118
static void
2230
 
kcode_setter(val)
2231
 
    VALUE val;
 
2119
kcode_setter(VALUE val)
2232
2120
{
2233
2121
    may_need_recompile = 1;
2234
2122
    rb_set_kcode(StringValuePtr(val));
2235
2123
}
2236
2124
 
2237
2125
static VALUE
2238
 
ignorecase_getter()
 
2126
ignorecase_getter(void)
2239
2127
{
2240
2128
    return ruby_ignorecase?Qtrue:Qfalse;
2241
2129
}
2242
2130
 
2243
2131
static void
2244
 
ignorecase_setter(val, id)
2245
 
    VALUE val;
2246
 
    ID id;
 
2132
ignorecase_setter(VALUE val, ID id)
2247
2133
{
2248
2134
    rb_warn("modifying %s is deprecated", rb_id2name(id));
2249
2135
    may_need_recompile = 1;
2251
2137
}
2252
2138
 
2253
2139
static VALUE
2254
 
match_getter()
 
2140
match_getter(void)
2255
2141
{
2256
2142
    VALUE match = rb_backref_get();
2257
2143
 
2261
2147
}
2262
2148
 
2263
2149
static void
2264
 
match_setter(val)
2265
 
    VALUE val;
 
2150
match_setter(VALUE val)
2266
2151
{
2267
2152
    if (!NIL_P(val)) {
2268
2153
        Check_Type(val, T_MATCH);
2288
2173
 */
2289
2174
 
2290
2175
static VALUE
2291
 
rb_reg_s_last_match(argc, argv)
2292
 
    int argc;
2293
 
    VALUE *argv;
 
2176
rb_reg_s_last_match(int argc, VALUE *argv)
2294
2177
{
2295
2178
    VALUE nth;
2296
2179
 
2312
2195
 */
2313
2196
 
2314
2197
void
2315
 
Init_Regexp()
 
2198
Init_Regexp(void)
2316
2199
{
2317
2200
    rb_eRegexpError = rb_define_class("RegexpError", rb_eStandardError);
2318
2201