summaryrefslogtreecommitdiff
path: root/proto.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-26 15:20:52 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-01 12:51:51 -0700
commitbd8446cfdeebd0d46fb2f59b7a8ad1ef248ac0d3 (patch)
treeace7e1e997d57a7d3244790bd83c72e3d1fe03f5 /proto.h
parent57e30c7a9fde9284d1ac854d4d6f97863ff461f5 (diff)
downloadperl-bd8446cfdeebd0d46fb2f59b7a8ad1ef248ac0d3.tar.gz
Deprecate mg_length; make it return bytes
mg_length returns the number of bytes if a scalar has length magic, but the number of characters otherwise. sv_len_utf8 used to assume that mg_length would return bytes. The first mistake was added in commit b76347f2eb, which assumed that mg_length would return characters. But it was #ifdeffed out until commit ffc61ed20e. Later, commit 5636d518683 met sv_len_utf8’s assumptions by making mg_length return the length in characters, without accounting for sv_len, which also used mg_length. So we ended up with a buggy sv_len that would return a character count for scalars with get- but not length-magic, and a byte count otherwise. In the previous commit, I fixed sv_len not to use mg_length at all. I plan shortly to remove any use of mg_length (the one remaining use is in sv_len_utf8, which is currently not called on magical values). The reason for removing all calls to mg_length is that the returned length cannot be converted to characters without access to the PV as well, which requires get-magic. So length magic on scalars makes no sense since the advent of utf8. This commit restore mg_length to its old behaviour and lists it as deprecated. This is mostly cosmetic, as there are no CPAN users. But it is in the API, and I don’t know whether we can easily remove it.
Diffstat (limited to 'proto.h')
-rw-r--r--proto.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/proto.h b/proto.h
index fa69fa96fe..f104a223d4 100644
--- a/proto.h
+++ b/proto.h
@@ -2372,6 +2372,7 @@ PERL_CALLCONV int Perl_mg_get(pTHX_ SV* sv)
assert(sv)
PERL_CALLCONV U32 Perl_mg_length(pTHX_ SV* sv)
+ __attribute__deprecated__
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_MG_LENGTH \
assert(sv)