]> granicus.if.org Git - graphviz/commitdiff
Catch case where pattern match reports success but with an empty string. This probably
authorEmden R. Gansner <erg@research.att.com>
Tue, 13 Aug 2013 00:41:02 +0000 (20:41 -0400)
committerEmden R. Gansner <erg@research.att.com>
Tue, 13 Aug 2013 00:41:02 +0000 (20:41 -0400)
corresponds to ill-specified pattern such as '&'

lib/expr/exeval.c

index 29dfaeba0ddb462d60dedfd95dddab2d70b4078d..5301e58d55ba588227297f5187c174bc1bf74b76 100644 (file)
@@ -828,6 +828,11 @@ exsub(Expr_t * ex, register Exnode_t * expr, void *env, int global)
                v.string = vmstrdup(ex->ve, str);
                return v;
        }
+    if (sub[0] == sub[1]) {
+               exwarn("pattern match of empty string - ill-specified pattern \"%s\"?", pat);
+               v.string = vmstrdup(ex->ve, str);
+               return v;
+    } 
        sfwrite(ex->tmp, str, sub[0]);
        if (repl)
                replace(ex->tmp, str, repl, ng, sub);