develooper Front page | perl.perl5.changes | Postings from August 2022

[Perl/perl5] 86868a: sv.c - add support for SVfQUOTEDPREFIX forerror m...

From:
Yves Orton via perl5-changes
Date:
August 1, 2022 14:30
Subject:
[Perl/perl5] 86868a: sv.c - add support for SVfQUOTEDPREFIX forerror m...
Message ID:
Perl/perl5/push/refs/heads/yves/fix_universal_import_fragility/2f6b24-dddfc4@github.com
  Branch: refs/heads/yves/fix_universal_import_fragility
  Home:   https://github.com/Perl/perl5
  Commit: 86868aaf7b1fe2ee1e5e38ace9af826bb14bebd5
      https://github.com/Perl/perl5/commit/86868aaf7b1fe2ee1e5e38ace9af826bb14bebd5
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2022-08-01 (Mon, 01 Aug 2022)

  Changed paths:
    M perl.h
    M pod/perlguts.pod
    M sv.c

  Log Message:
  -----------
  sv.c - add support for SVfQUOTEDPREFIX for error messages.

This new format is intended to be used in error messages where
we want to show the contents of a string without any possible
hidden characters not rendering in the error message, and where
it would be unreasonable to show every character of the string
if it is very long.

A good example would be when we want to say that a class name is illegal.
Consider:

    "Foo\0"->thing()

should not throw an error message about "Foo" being missing, the fact there
is a null in there should be visible to the developer. Similarly if we had

    ("x" x 1000_000)->thing()

we also wouldn't want to throw a 1MB error message. Currently this
patch restricts it to the first 1000 characters, but the docs are such
that we can reduce that if we wish, I suspect something like 100 would
be more reasonable.

Example usage:

    other= newSVpvs("Some\0::Thing\n");
    sv_catpvf(msg_sv,"%" SVfQUOTEDPREFIX, SVfARG(other));

Should append

    "Some\0::Thing\n"

to the msg_sv. If it were very long it would have elipses suffixed:

    "long string...truncat"...

This will be used in a following commit.


  Commit: dddfc4a1df6ec668077667972f02ffc1d880ad39
      https://github.com/Perl/perl5/commit/dddfc4a1df6ec668077667972f02ffc1d880ad39
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2022-08-01 (Mon, 01 Aug 2022)

  Changed paths:
    M universal.c

  Log Message:
  -----------
  universal.c - use the shiny new SVfQUOTEDPREFIX for the error message

And at the same time avoid saying the package name twice. Whats the point
of that?


Compare: https://github.com/Perl/perl5/compare/2f6b24b1db36...dddfc4a1df6e



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