Index: bregexec.cpp =================================================================== --- bregexec.cpp (リビジョン 1663) +++ bregexec.cpp (作業コピー) @@ -295,10 +295,19 @@ if (s > startpos) s--; while (s < strend) { - if (*s++ == '\n') { + if (*s == '\n') { + ++s; if (s < strend && regtry(prog, s,globalp)) goto got_it; + } else if (*s == '\r') { + ++s; + if (s < strend && *s == '\n') { + ++s; + } + if (s < strend && regtry(prog, s,globalp)) + goto got_it; } + ++s; } } goto phooey; @@ -673,7 +682,7 @@ case BOL: if (locinput == regbol ? regprev == '\n' - : ((localNextchar || locinput < regeol) && locinput[-1] == '\n') ) + : ((localNextchar || locinput < regeol) && (locinput[-1] == '\n' || (locinput[-1] == '\r' && localNextchar != '\n'))) ) { /* regtill = regbol; */ break; @@ -682,7 +691,7 @@ case MBOL: if (locinput == regbol ? regprev == '\n' - : ((localNextchar || locinput < regeol) && locinput[-1] == '\n') ) + : ((localNextchar || locinput < regeol) && (locinput[-1] == '\n' || (locinput[-1] == '\r' && localNextchar != '\n'))) ) { break; } @@ -702,15 +711,19 @@ goto seol; case MEOL: meol: - if ((localNextchar || locinput < regeol) && localNextchar != '\n') + if ((localNextchar || locinput < regeol) && (localNextchar != '\n' && localNextchar != '\r')) sayNO; + if (localNextchar == '\n' && regbol < locinput && locinput[-1] == '\r') + sayNO; break; case SEOL: seol: - if ((localNextchar || locinput < regeol) && localNextchar != '\n') + if ((localNextchar || locinput < regeol) && (localNextchar != '\n' && localNextchar != '\r')) sayNO; - if (regeol - locinput > 1) + if (localNextchar == '\n' && regbol < locinput && locinput[-1] == '\r') sayNO; + if (regeol - locinput > 2) + sayNO; break; case SANY: if (!localNextchar && locinput >= regeol) @@ -721,7 +734,7 @@ localNextchar = *++locinput; break; case ANY: - if (!localNextchar && locinput >= regeol || localNextchar == '\n') + if (!localNextchar && locinput >= regeol || (localNextchar == '\n' || localNextchar == '\r')) sayNO; #ifdef KANJI if (KANJI_MODE && iskanji(localNextchar) && locinput[1]) ++locinput;