summaryrefslogtreecommitdiff
path: root/ext/attributes
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-04-12 16:28:49 +0100
committerNicholas Clark <nick@ccl4.org>2009-04-12 16:30:04 +0100
commitf1a3ce43fb80c48e414d9b35caf0ac62cb80ff4e (patch)
tree791e875cd154b0eb151d6b456d80a77ed5d3d507 /ext/attributes
parentc32124fea7b8ddab6f359599ed11fec4ff102451 (diff)
downloadperl-f1a3ce43fb80c48e414d9b35caf0ac62cb80ff4e.tar.gz
Deprecate using "unique" with the attributes pragma.
Diffstat (limited to 'ext/attributes')
-rw-r--r--ext/attributes/attributes.pm9
-rw-r--r--ext/attributes/attributes.xs25
2 files changed, 10 insertions, 24 deletions
diff --git a/ext/attributes/attributes.pm b/ext/attributes/attributes.pm
index ac5ef09647..e94282c79b 100644
--- a/ext/attributes/attributes.pm
+++ b/ext/attributes/attributes.pm
@@ -18,6 +18,11 @@ sub carp {
goto &Carp::carp;
}
+my %deprecated;
+$deprecated{CODE} = qr/\A-?(locked)\z/;
+$deprecated{ARRAY} = $deprecated{HASH} = $deprecated{SCALAR}
+ = qr/\A-?(unique)\z/;
+
sub _modify_attrs_and_deprecate {
my $svtype = shift;
# Now that we've removed handling of locked from the XS code, we need to
@@ -25,9 +30,9 @@ sub _modify_attrs_and_deprecate {
# XS, we can't control the warning based on *our* caller's lexical settings,
# and the warned line is in this package)
grep {
- $svtype eq 'CODE' && /\A-?locked\z/ ? do {
+ $deprecated{$svtype} && /$deprecated{$svtype}/ ? do {
require warnings;
- warnings::warnif('deprecated', 'Attribute "locked" is deprecated');
+ warnings::warnif('deprecated', "Attribute \"$1\" is deprecated");
0;
} : 1
} _modify_attrs(@_);
diff --git a/ext/attributes/attributes.xs b/ext/attributes/attributes.xs
index dceef68b50..7a86cd76c1 100644
--- a/ext/attributes/attributes.xs
+++ b/ext/attributes/attributes.xs
@@ -68,31 +68,12 @@ modify_SV_attributes(pTHX_ SV *sv, SV **retlist, SV **attrlist, int numattrs)
}
break;
default:
- switch ((int)len) {
- case 6:
- switch (name[5]) {
- case 'd':
- if (memEQ(name, "share", 5)) {
+ if (memEQs(name, 6, "shared")) {
if (negated)
Perl_croak(aTHX_ "A variable may not be unshared");
SvSHARE(sv);
continue;
- }
- break;
- case 'e':
- if (memEQ(name, "uniqu", 5)) {
- if (isGV_with_GP(sv)) {
- if (negated) {
- GvUNIQUE_off(sv);
- } else {
- GvUNIQUE_on(sv);
- }
- }
- /* Hope this came from toke.c if not a GV. */
- continue;
- }
- }
- }
+ }
break;
}
/* anything recognized had a 'continue' above */
@@ -238,4 +219,4 @@ usage:
* End:
*
* ex: set ts=8 sts=4 sw=4 noet:
- */ \ No newline at end of file
+ */