|
From: Seth D. <set...@us...> - 2004-12-12 03:30:05
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv727 Modified Files: langregexp.c Log Message: Double backslashes in the replacement parameter should be compacted into single backslashes. regexpscanreplacement() was only eating backslashes before named/numbered references. This has been fixed, but it is shut off unless you add "#define REGEX_COMPACT_SLASHES 1". Full comments, with one-line test script, at top of regexscanreplacement. Index: langregexp.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langregexp.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** langregexp.c 31 Oct 2004 13:19:30 -0000 1.6 --- langregexp.c 12 Dec 2004 03:29:51 -0000 1.7 *************** *** 1523,1526 **** --- 1523,1542 ---- + /* + 12/11/2004 smd: + regexpscanreplacement() should be converting double backslashes + to single backslashes, but isn't. In the replacement pattern, + double backslashes should be collapsed to single backslashes. + + This line: + msg( re.replace( re.compile( "(a)(b)" ), "\\1\\\\\\2", "ab" ) ) + + should display "a\b" but is instead showing "a\\b". There's no way + to "insert" a single (or any odd number) of backslashes to the result. + I've fixed it, but Andre is worried that it could cause breakage. + To make it work, uncomment the following line. + */ + /*#define REGEX_COMPACT_BACKSLASHES 1*/ + static boolean regexpscanreplacement (const char *pstart, long len, bigstring bserror, tyreplscanliteralcallback literalfunc, *************** *** 1614,1617 **** --- 1630,1645 ---- } } + #ifdef REGEX_COMPACT_BACKSLASHES + else if (*p1 == '\\') { + /* 2004/12/11 smd: double backslashes should be collapsed into singles */ + + if (!literalfunc (plast - pstart, (p - plast) + 1, bserror, refcon)) + return (false); + + p = plast = p1 + 1; + + continue; /*avoid incrementation of p*/ + } + #endif else if (isdigit (*p1)) { |