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

[Perl/perl5] 8bbdcb: doop.c: Fix typo in comment; add comment

From:
Karl Williamson
Date:
April 2, 2020 15:18
Subject:
[Perl/perl5] 8bbdcb: doop.c: Fix typo in comment; add comment
Message ID:
Perl/perl5/push/refs/heads/blead/846046-33208b@github.com
  Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 8bbdcb372d98806ff15f6de9ae9f263b85265432
      https://github.com/Perl/perl5/commit/8bbdcb372d98806ff15f6de9ae9f263b85265432
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-04-02 (Thu, 02 Apr 2020)

  Changed paths:
    M doop.c

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


  Commit: 9f31bc5d8d184ee704d37590d4271ea43374c6c8
      https://github.com/Perl/perl5/commit/9f31bc5d8d184ee704d37590d4271ea43374c6c8
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-04-02 (Thu, 02 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


  Commit: 33208b8d0dac817fe1bed75f485d65c3cc5a32ab
      https://github.com/Perl/perl5/commit/33208b8d0dac817fe1bed75f485d65c3cc5a32ab
  Author: Karl Williamson <khw@cpan.org>
  Date:   2020-04-02 (Thu, 02 Apr 2020)

  Changed paths:
    M op.c

  Log Message:
  -----------
  op.c: Add, clarify comments


Compare: https://github.com/Perl/perl5/compare/846046eca041...33208b8d0dac



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