add ck_sysread() for better sysread/read/recv sanity
Gurusamy Sarathy [Sun, 5 Jul 1998 06:27:37 +0000 (06:27 +0000)]
p4raw-id: //depot/perl@1319

ObjXSub.h
embed.h
global.sym
globals.c
objpp.h
op.c
opcode.h
opcode.pl
proto.h

index 6cb2baa..7b81c60 100644 (file)
--- a/ObjXSub.h
+++ b/ObjXSub.h
 #define ck_subr             pPerl->Perl_ck_subr
 #undef  ck_svconst
 #define ck_svconst          pPerl->Perl_ck_svconst
+#undef  ck_sysread
+#define ck_sysread          pPerl->Perl_ck_sysread
 #undef  ck_trunc
 #define ck_trunc            pPerl->Perl_ck_trunc
 #undef  condpair_magic
diff --git a/embed.h b/embed.h
index 01813c9..222dc93 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define ck_split               Perl_ck_split
 #define ck_subr                        Perl_ck_subr
 #define ck_svconst             Perl_ck_svconst
+#define ck_sysread             Perl_ck_sysread
 #define ck_trunc               Perl_ck_trunc
 #define compl_amg              Perl_compl_amg
 #define concat_amg             Perl_concat_amg
index 44c8dbc..2690ea8 100644 (file)
@@ -232,6 +232,7 @@ ck_spair
 ck_split
 ck_subr
 ck_svconst
+ck_sysread
 ck_trunc
 condpair_magic
 convert
index 1daf4f1..217ac6d 100644 (file)
--- a/globals.c
+++ b/globals.c
@@ -898,17 +898,17 @@ OP * (CPERLscope(*check)[]) _((OP *op)) = {
        ck_select,      /* sselect */
        ck_select,      /* select */
        ck_eof,         /* getc */
-       ck_fun,         /* read */
+       ck_sysread,     /* read */
        ck_fun,         /* enterwrite */
        ck_null,        /* leavewrite */
        ck_listiob,     /* prtf */
        ck_listiob,     /* print */
        ck_fun,         /* sysopen */
        ck_fun,         /* sysseek */
-       ck_fun,         /* sysread */
+       ck_sysread,     /* sysread */
        ck_fun,         /* syswrite */
        ck_fun,         /* send */
-       ck_fun,         /* recv */
+       ck_sysread,     /* recv */
        ck_eof,         /* eof */
        ck_fun,         /* tell */
        ck_fun,         /* seek */
diff --git a/objpp.h b/objpp.h
index 469fefc..89551d4 100644 (file)
--- a/objpp.h
+++ b/objpp.h
 #define ck_subr           CPerlObj::Perl_ck_subr
 #undef  ck_svconst
 #define ck_svconst        CPerlObj::Perl_ck_svconst
+#undef  ck_sysread
+#define ck_sysread        CPerlObj::Perl_ck_sysread
 #undef  ck_trunc
 #define ck_trunc          CPerlObj::Perl_ck_trunc
 #undef  convert
diff --git a/op.c b/op.c
index 1af6d96..fa5a60b 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4863,6 +4863,29 @@ ck_svconst(OP *o)
 }
 
 OP *
+ck_sysread(OP *o)
+{
+    if (o->op_flags & OPf_KIDS) {
+       /* get past pushmark */
+       OP *kid = cLISTOPo->op_first->op_sibling;
+       if (kid && (kid = kid->op_sibling)) {
+           switch (kid->op_type) {
+           case OP_HELEM:
+           case OP_AELEM:
+           case OP_SASSIGN:
+           case OP_AELEMFAST:
+           case OP_RV2SV:
+           case OP_PADSV:
+               break;
+           default:
+               bad_type(2, "scalar", op_desc[o->op_type], kid);
+           }
+       }
+    }
+    return ck_fun(o);
+}
+
+OP *
 ck_trunc(OP *o)
 {
     if (o->op_flags & OPf_KIDS) {
@@ -4974,7 +4997,7 @@ peep(register OP *o)
 
        case OP_PADAV:
            if (o->op_next->op_type == OP_RV2AV
-               && (o->op_next->op_flags && OPf_REF))
+               && (o->op_next->op_flags & OPf_REF))
            {
                null(o->op_next);
                o->op_next = o->op_next->op_next;
@@ -4983,7 +5006,7 @@ peep(register OP *o)
        
        case OP_PADHV:
            if (o->op_next->op_type == OP_RV2HV
-               && (o->op_next->op_flags && OPf_REF))
+               && (o->op_next->op_flags & OPf_REF))
            {
                null(o->op_next);
                o->op_next = o->op_next->op_next;
index 47dd777..435b7d2 100644 (file)
--- a/opcode.h
+++ b/opcode.h
@@ -1095,6 +1095,7 @@ OP *      ck_spair        _((OP* o));
 OP *   ck_split        _((OP* o));
 OP *   ck_subr         _((OP* o));
 OP *   ck_svconst      _((OP* o));
+OP *   ck_sysread      _((OP* o));
 OP *   ck_trunc        _((OP* o));
 
 OP *   pp_null         _((ARGSproto));
@@ -2009,17 +2010,17 @@ EXT OP * (CPERLscope(*check)[]) _((OP *op)) = {
        ck_select,      /* sselect */
        ck_select,      /* select */
        ck_eof,         /* getc */
-       ck_fun,         /* read */
+       ck_sysread,     /* read */
        ck_fun,         /* enterwrite */
        ck_null,        /* leavewrite */
        ck_listiob,     /* prtf */
        ck_listiob,     /* print */
        ck_fun,         /* sysopen */
        ck_fun,         /* sysseek */
-       ck_fun,         /* sysread */
+       ck_sysread,     /* sysread */
        ck_fun,         /* syswrite */
        ck_fun,         /* send */
-       ck_fun,         /* recv */
+       ck_sysread,     /* recv */
        ck_eof,         /* eof */
        ck_fun,         /* tell */
        ck_fun,         /* seek */
index 5891139..6a1275d 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -496,7 +496,7 @@ sselect             select system call      ck_select       t@      S S S S
 select         select                  ck_select       st@     F?
 
 getc           getc                    ck_eof          st%     F?
-read           read                    ck_fun          imst@   F R S S?
+read           read                    ck_sysread      imst@   F R S S?
 enterwrite     write                   ck_fun          dis%    F?
 leavewrite     write exit              ck_null         1       
 
@@ -505,11 +505,11 @@ print             print                   ck_listiob      ims@    F? L
 
 sysopen                sysopen                 ck_fun          s@      F S S S?
 sysseek                sysseek                 ck_fun          s@      F S S
-sysread                sysread                 ck_fun          imst@   F R S S?
+sysread                sysread                 ck_sysread      imst@   F R S S?
 syswrite       syswrite                ck_fun          imst@   F S S S?
 
 send           send                    ck_fun          imst@   F S S S?
-recv           recv                    ck_fun          imst@   F R S S
+recv           recv                    ck_sysread      imst@   F R S S
 
 eof            eof                     ck_eof          is%     F?
 tell           tell                    ck_fun          st%     F?
diff --git a/proto.h b/proto.h
index a74dc60..933942f 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -1205,6 +1205,7 @@ OP *ck_sort _((OP *o));
 OP *ck_split _((OP *o));
 OP *ck_subr _((OP *o));
 OP *ck_svconst _((OP *o));
+OP *ck_sysread _((OP *o));
 OP *ck_trunc _((OP *o));
 void unwind_handler_stack _((void *p));
 void restore_magic _((void *p));