[win32] maintpatch
Hugo van der Sanden [Mon, 13 Oct 1997 11:23:56 +0000 (12:23 +0100)]
    #73:  "Fix order of warnings for misplaced subscripts"
 Msg-ID:  <199710131023.LAA16796@crypt.compulink.co.uk>
  Files:  op.c

p4raw-id: //depot/win32/perl@639

op.c

diff --git a/op.c b/op.c
index f6857af..fec6705 100644 (file)
--- a/op.c
+++ b/op.c
@@ -86,9 +86,17 @@ assertref(OP *o)
     int type = o->op_type;
     if (type != OP_AELEM && type != OP_HELEM) {
        yyerror(form("Can't use subscript on %s", op_desc[type]));
-       if (type == OP_ENTERSUB || type == OP_RV2HV || type == OP_PADHV)
-           warn("(Did you mean $ or @ instead of %c?)\n",
-                type == OP_ENTERSUB ? '&' : '%');
+       if (type == OP_ENTERSUB || type == OP_RV2HV || type == OP_PADHV) {
+           SV *msg = sv_2mortal(
+                       newSVpvf("(Did you mean $ or @ instead of %c?)\n",
+                                type == OP_ENTERSUB ? '&' : '%'));
+           if (in_eval & 2)
+               warn("%_", msg);
+           else if (in_eval)
+               sv_catsv(GvSV(errgv), msg);
+           else
+               PerlIO_write(PerlIO_stderr(), SvPVX(msg), SvCUR(msg));
+       }
     }
 }