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

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

From:
Karl Williamson
Date:
April 1, 2020 12:48
Subject:
[Perl/perl5] d1fb52: doop.c: Fix typo in comment
Message ID:
Perl/perl5/push/refs/heads/smoke-me/khw-tr/000000-9c5471@github.com
  Branch: refs/heads/smoke-me/khw-tr
  Home:   https://github.com/Perl/perl5
  Commit: d1fb523143e3daed516fd1c54e973ff6577fb61a
      https://github.com/Perl/perl5/commit/d1fb523143e3daed516fd1c54e973ff6577fb61a
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-04-01 (Wed, 01 Apr 2020)

  Changed paths:
    M doop.c

  Log Message:
  -----------
  doop.c: Fix typo in comment


  Commit: 9c5471a91bd7152ed96d19e6cb15cd1cceeceb50
      https://github.com/Perl/perl5/commit/9c5471a91bd7152ed96d19e6cb15cd1cceeceb50
  Author: Karl Williamson <khw@cpan.org>
  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
copy.

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: https://github.com/Perl/perl5/compare/d1fb523143e3%5E...9c5471a91bd7



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