Changes to perlfaq8 "How do I find out if I'm running interactively
[p5sagit/p5-mst-13.2.git] / op.c
diff --git a/op.c b/op.c
index 86d01d4..ec4cb3a 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5399,13 +5399,13 @@ Perl_newCONSTSUB(pTHX_ HV *stash, const char *name, SV *sv)
     CV* cv;
 #ifdef USE_ITHREADS
     const char *const temp_p = CopFILE(PL_curcop);
-    const STRLEN len = strlen(temp_p);
+    const STRLEN len = temp_p ? strlen(temp_p) : 0;
 #else
     SV *const temp_sv = CopFILESV(PL_curcop);
     STRLEN len;
     const char *const temp_p = temp_sv ? SvPV_const(temp_sv, len) : NULL;
 #endif
-    char *const file = temp_p ? savepvn(temp_p, len) : NULL;
+    char *const file = savepvn(temp_p, temp_p ? len : 0);
 
     ENTER;
 
@@ -7231,7 +7231,7 @@ Perl_ck_subr(pTHX_ OP *o)
             ? cUNOPo : ((UNOP*)cUNOPo->op_first))->op_first;
     OP *o2 = prev->op_sibling;
     OP *cvop;
-    char *proto = NULL;
+    const char *proto = NULL;
     const char *proto_end = NULL;
     CV *cv = NULL;
     GV *namegv = NULL;
@@ -7381,15 +7381,13 @@ Perl_ck_subr(pTHX_ OP *o)
                     break;
                case ']':
                     if (contextclass) {
-                        /* XXX We shouldn't be modifying proto, so we can const proto */
-                        char *p = proto;
-                        const char s = *p;
+                        const char *p = proto;
+                        const char *const end = proto;
                         contextclass = 0;
-                        *p = '\0';
                         while (*--p != '[');
-                        bad_type(arg, Perl_form(aTHX_ "one of %s", p),
-                                gv_ename(namegv), o3);
-                        *proto = s;
+                        bad_type(arg, Perl_form(aTHX_ "one of %.*s",
+                                                (int)(end - p), p),
+                                 gv_ename(namegv), o3);
                     } else
                          goto oops;
                     break;