From: Tanaka Akira Date: 2008-02-25T17:53:49+09:00 Subject: Re: possible bug in regexp lexing In article <87d4qpw02t.fsf@fsij.org>, Tanaka Akira writes: > Isn't it the current behavior? (c != '\\' || c != term) is same as (c != '\\' || term != '\\'). So the condition is always true except term is '\\' as: %r\abc\. However tokadd_escape is not called if term is '\\' because tokadd_string tests c == term for termination before calling tokadd_escape. So, (c != '\\' || c != term) is always true. > An refactoring is good to do, though. Index: parse.y =================================================================== --- parse.y (revision 15595) +++ parse.y (working copy) @@ -2890,8 +2890,7 @@ read_escape() } static int -tokadd_escape(term) - int term; +tokadd_escape() { int c; @@ -2956,7 +2955,7 @@ tokadd_escape(term) tokadd('\\'); tokadd('c'); escaped: if ((c = nextc()) == '\\') { - return tokadd_escape(term); + return tokadd_escape(); } else if (c == -1) goto eof; tokadd(c); @@ -2968,8 +2967,7 @@ tokadd_escape(term) return -1; default: - if (c != '\\' || c != term) - tokadd('\\'); + tokadd('\\'); tokadd(c); } return 0; @@ -3089,7 +3087,7 @@ tokadd_string(func, term, paren, nest) default: if (func & STR_FUNC_REGEXP) { pushback(c); - if (tokadd_escape(term) < 0) + if (tokadd_escape() < 0) return -1; continue; } -- Tanaka Akira