diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-09-26 15:20:52 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-10-01 12:51:51 -0700 |
commit | bd8446cfdeebd0d46fb2f59b7a8ad1ef248ac0d3 (patch) | |
tree | ace7e1e997d57a7d3244790bd83c72e3d1fe03f5 /embed.fnc | |
parent | 57e30c7a9fde9284d1ac854d4d6f97863ff461f5 (diff) | |
download | perl-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 'embed.fnc')
-rw-r--r-- | embed.fnc | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -797,7 +797,7 @@ ApdR |MAGIC* |mg_findext |NULLOK const SV* sv|int type|NULLOK const MGVTBL *vtbl Apd |int |mg_free |NN SV* sv Apd |void |mg_free_type |NN SV* sv|int how Apd |int |mg_get |NN SV* sv -Apd |U32 |mg_length |NN SV* sv +ApdD |U32 |mg_length |NN SV* sv Apd |void |mg_magical |NN SV* sv Apd |int |mg_set |NN SV* sv Ap |I32 |mg_size |NN SV* sv |