e$B$J$+$@$G$9!#e(B
At Tue, 25 Sep 2007 21:12:42 +0900,
Yukihiro M. wrote in [ruby-dev:31855]:
|> e$B0J2<$N$h$&$K$9$k$He(B 1.8 e$B!"e(B1.9 e$B6&$KMn$A$^$9!#e(B
|> ALLOCA_N e$B$,860x$N$h$&$G$9!#e(B
|
|e$B$5$9$,$K!“e(B1MBe$B$r1[$($k%(%i!<%a%C%;!<%8$,=P$F$/$l$F$b$”$^$j$&$l$7e(B
|e$B$/$J$$$N$G$O!#e(B
e$B$G$7$g$&$M!#$J$+$@$5$s$N%Q%C%A$r%3%_%C%H$7$F$/$@$5$$$^$;$s$+!)e(B
1.8e$B$N$[$&$O$I$&$7$^$7$g$&$+!#e(Brb_enc_prev_char()e$BAjEv$,$J$$$N$G!"e(B
re_adjust_startpos()e$B$+$iN.MQ$9$k$J$i0J2<$N$h$&$J46$8$G$9!#e(B
e$B$H$$$&$+!"<j85$G$Oe(B[ruby-talk:247595]e$B$,Ev$?$C$?$^$^$@$C$?$N$G!"$=e(B
e$B$b$=$be(B"memory exhausted"e$B<+BN$,H/@8$7$J$+$C$?$N$G$9$,!#e(B
Index: parse.y
— parse.y (revision 13508)
+++ parse.y (working copy)
@@ -2517,5 +2517,7 @@ yyerror(msg)
const char *msg;
{
- const int max_line_margin = 30;
- const char *p, *pe;
- char *buf;
int len, i;
@@ -2536,15 +2538,30 @@ yyerror(msg)
len = pe - p;
if (len > 4) {
- char *p2;
- const char *pre = “”, *post = “”;
-
- if (len > max_line_margin * 2 + 10) {
-
int re_mbc_startpos _((const char *, int, int, int));
-
if ((len = lex_p - p) > max_line_margin) {
- p = p + re_mbc_startpos(p, len, len - max_line_margin, 0);
- pre = “…”;
-
}
-
if ((len = pe - lex_p) > max_line_margin) {
- pe = lex_p + re_mbc_startpos(lex_p, len, max_line_margin, 1);
- post = “…”;
-
}
-
len = pe - p;
- }
buf = ALLOCA_N(char, len+2);
MEMCPY(buf, p, char, len);
buf[len] = ‘\0’;
- rb_compile_error_append("%s", buf);
- p2 = buf; pe = buf + len;
- while (p2 < pe) {
-
if (*p2 != '\t') *p2 = ' ';
-
p2++;
}
buf[i] = ‘^’;
Index: regex.c
===================================================================
— regex.c (revision 13508)
+++ regex.c (working copy)
@@ -3110,4 +3110,26 @@ re_compile_fastmap(bufp)
/* adjust startpos value to the position between characters. */
int
+re_mbc_startpos(string, size, startpos, range)
-
const char *string;
-
int size, startpos, range;
+{
+int
re_adjust_startpos(bufp, string, size, startpos, range)
struct re_pattern_buffer bufp;
@@ -3122,18 +3144,5 @@ re_adjust_startpos(bufp, string, size, s
/ Adjust startpos for mbc string */
if (current_mbctype && startpos>0 &&
!(bufp->options&RE_OPTIMIZE_BMATCH)) {
- int i = mbc_startpos(string, startpos);
-
- if (i < startpos) {
-
if (range > 0) {
- startpos = i + mbclen(string[i]);
-
}
-
else {
- int len = mbclen(string[i]);
- if (i + len <= startpos)
- startpos = i + len;
- else
- startpos = i;
-
}
- }
- startpos = re_mbc_startpos(string, size, startpos, range);
}
return startpos;