Perl 5.6.0, 5.7.0 ... vms/test.com to eliminate spurious NL's in test output
[p5sagit/p5-mst-13.2.git] / ext / attrs / attrs.xs
index f34ac85..4c00cd7 100644 (file)
@@ -1,10 +1,10 @@
+#define PERL_NO_GET_CONTEXT
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
 
 static cv_flags_t
-get_flag(attr)
-char *attr;
+get_flag(char *attr)
 {
     if (strnEQ(attr, "method", 6))
        return CVf_METHOD;
@@ -17,18 +17,23 @@ char *attr;
 MODULE = attrs         PACKAGE = attrs
 
 void
-import(class, ...)
-char * class
+import(Class, ...)
+char * Class
     ALIAS:
        unimport = 1
     PREINIT:
        int i;
        CV *cv;
     PPCODE:
-       if (!compcv || !(cv = CvOUTSIDE(compcv)))
+       if (!PL_compcv || !(cv = CvOUTSIDE(PL_compcv)))
            croak("can't set attributes outside a subroutine scope");
+       if (ckWARN(WARN_DEPRECATED))
+           Perl_warner(aTHX_ WARN_DEPRECATED,
+                       "pragma \"attrs\" is deprecated, "
+                       "use \"sub NAME : ATTRS\" instead");
        for (i = 1; i < items; i++) {
-           char *attr = SvPV(ST(i), na);
+           STRLEN n_a;
+           char *attr = SvPV(ST(i), n_a);
            cv_flags_t flag = get_flag(attr);
            if (!flag)
                croak("invalid attribute name %s", attr);
@@ -48,13 +53,14 @@ SV *        sub
                sub = Nullsv;
        }
        else {
-           char *name = SvPV(sub, na);
+           STRLEN n_a;
+           char *name = SvPV(sub, n_a);
            sub = (SV*)perl_get_cv(name, FALSE);
        }
        if (!sub)
            croak("invalid subroutine reference or name");
        if (CvFLAGS(sub) & CVf_METHOD)
-           XPUSHs(sv_2mortal(newSVpv("method", 0)));
+           XPUSHs(sv_2mortal(newSVpvn("method", 6)));
        if (CvFLAGS(sub) & CVf_LOCKED)
-           XPUSHs(sv_2mortal(newSVpv("locked", 0)));
+           XPUSHs(sv_2mortal(newSVpvn("locked", 6)));