This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Remove soon-to-be invalid t assumption
authorKarl Williamson <khw@cpan.org>
Mon, 23 Nov 2015 22:00:55 +0000 (15:00 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 25 Nov 2015 22:48:17 +0000 (15:48 -0700)
commitb67fd2c557cdf9bdc899813a5e4f2dee22e4f63e
tree055007b23413908232464966d3435a702fb4424a
parent1d1c12d9a3f5f51cb9639329ae0b854f2dab7b05
toke.c: Remove soon-to-be invalid t assumption

The code in toke.c assumes that the UTF8 expansion of the string
"\x{foo}" takes no more bytes than the original input text, which
includes the 4 bytes of overhead "\x{}".  Similarly for "\o{}".  The
functions that convert to the code point actually now assert for this.
The next commit will make this assumption definitely invalid on EBCDIC
platforms.  Remove the assertions, and actually handle the case
properly.  The other places that call the conversion functions do not
make this assumption, so there is no harm in removing them from there.

Since we believe that this can't happen except on EBCDIC, we
could #ifdef this code and use just an assert on non-EBCDIC.  But it's
easier to maintain if #ifdef's are minimized.  Parsing is not a
time-critical operation, like being in an inner loop, and the extra test
gives a branch prediction hint to the compiler.
dquote.c
dquote_inline.h
toke.c