summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-06-13 21:52:14 -0600
committerKarl Williamson <public@khwilliamson.com>2013-07-03 21:09:51 -0600
commit883bb8c0e0c5dc811dd918db6161867eb5f13a53 (patch)
tree210074f4b4ad7270b70648e273a18a22db56dbc5 /sv.c
parent24ecc2e0e8c7a7f9a68ad5f1c33cd4a007ce004d (diff)
downloadperl-883bb8c0e0c5dc811dd918db6161867eb5f13a53.tar.gz
Fix perlguts and comments for how sv_chop() works
There is no 'integer' part of a SVt_PV, contrary to what perlguts said. I also added a couple of comments to sv_chop() as I learned how it really works.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 8d23a3a678..e949b3d0c4 100644
--- a/sv.c
+++ b/sv.c
@@ -5075,8 +5075,14 @@ Perl_sv_chop(pTHX_ SV *const sv, const char *const ptr)
evacp = p - evacn;
#endif
+ /* This sets 'delta' to the accumulated value of all deltas so far */
delta += old_delta;
assert(delta);
+
+ /* If 'delta' fits in a byte, store it just prior to the new beginning of
+ * the string; otherwise store a 0 byte there and store 'delta' just prior
+ * to that, using as many bytes as a STRLEN occupies. Thus it overwrites a
+ * portion of the chopped part of the string */
if (delta < 0x100) {
*--p = (U8) delta;
} else {