Backslash-escape /s in the target of a generated s/// expression
Abhijit Menon-Sen [Sat, 29 Aug 2009 07:38:46 +0000 (12:38 +0530)]
Fixes #68840 reported by Guglielmo Bondioni, where a2p incorrectly
translated sub(/foo/,"bar/baz") into s/foo/bar/baz/.

x2p/walk.c

index ef754c5..d3d5f91 100644 (file)
@@ -845,7 +845,7 @@ sub Pick {\n\
            for (t = tmp2str->str_ptr, d=tokenbuf; *t; d++,t++) {
                if (*t == '&')
                    *d++ = '$' + (char)128;
-               else if (*t == '$')
+               else if (*t == '$' || *t == '/')
                    *d++ = '\\' + (char)128;
                *d = *t + 128;
            }