Tease apart the keyword/subroutine test in S_checkcomma.
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index d87f7da..11fcb65 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1089,15 +1089,10 @@ S_check_uni(pTHX)
     if ((t = strchr(s, '(')) && t < PL_bufptr)
        return;
 
-    /* XXX Things like this are just so nasty.  We shouldn't be modifying
-    source code, even if we realquick set it back. */
     if (ckWARN_d(WARN_AMBIGUOUS)){
-       const char ch = *s;
-        *s = '\0';
         Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
-                  "Warning: Use of \"%s\" without parentheses is ambiguous",
-                  PL_last_uni);
-        *s = ch;
+                  "Warning: Use of \"%.*s\" without parentheses is ambiguous",
+                  (int)(s - PL_last_uni), PL_last_uni);
     }
 }
 
@@ -10207,11 +10202,17 @@ S_checkcomma(pTHX_ register char *s, const char *name, const char *what)
            s++;
        if (*s == ',') {
            I32 kw;
+           CV *cv;
            *s = '\0'; /* XXX If we didn't do this, we could const a lot of toke.c */
-           kw = keyword(w, s - w) || get_cv(w, FALSE) != 0;
+           kw = keyword(w, s - w);
            *s = ',';
            if (kw)
                return;
+           *s = '\0';
+           cv = get_cv(w, FALSE);
+           *s = ',';
+           if (cv)
+               return;
            Perl_croak(aTHX_ "No comma allowed after %s", what);
        }
     }