develooper Front page | perl.perl5.changes | Postings from April 2020

[Perl/perl5] d1fb52: doop.c: Fix typo in comment

Karl Williamson
April 1, 2020 12:48
[Perl/perl5] d1fb52: doop.c: Fix typo in comment
Message ID:
  Branch: refs/heads/smoke-me/khw-tr
  Commit: d1fb523143e3daed516fd1c54e973ff6577fb61a
  Author: Karl Williamson <>
  Date:   2020-04-01 (Wed, 01 Apr 2020)

  Changed paths:
    M doop.c

  Log Message:
  doop.c: Fix typo in comment

  Commit: 9c5471a91bd7152ed96d19e6cb15cd1cceeceb50
  Author: Karl Williamson <>
  Date:   2020-04-01 (Wed, 01 Apr 2020)

  Changed paths:
    M op.c
    M t/op/tr.t

  Log Message:
  tr/abc/de/: Properly handle longer lhs in in-place calc

A tr/// can be done in-place if the target string doesn't contain a
character whose transliterated representation is longer than the
original.  Otherwise, writing the new value would destroy the next
character we need to read.

In general, we can't know if a particular string contains such a
character without keeping a list of the problematic characters, and
scanning it ahead of time for occurrences of those.  Instead, we
determine at compilation time if, for a given transliteration, if there
exists any possible target string that could have an overwriting
problem.  If none exist, we edit in place.  Otherwise, we first make a

Prior to this commit, the code failed to account for the case where the
rhs is shorter than the left, so that any unmatched lhs characters map
to the final rhs one.  The reason the code didn't consider this is that
I didn't think of this possibility when writing it.

This fixes #17654 and #17643

Compare: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About