This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Remove unused param from static function
authorKarl Williamson <khw@cpan.org>
Wed, 1 Feb 2017 20:15:00 +0000 (13:15 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 2 Feb 2017 03:45:08 +0000 (20:45 -0700)
commitc9470cf1abc4cc21f63ba5222f7860ec1175adfc
treef28dbf2eea18c8d7c77435f4aade0bf263b4447d
parent720a74f8122cba995eee9ee7761fcc3275387435
toke.c: Remove unused param from static function

Commit d2067945159644d284f8064efbd41024f9e8448a reverted commit
b5248d1e210c2a723adae8e9b7f5d17076647431.  b5248 removed a parameter
from S_scan_ident, and changed its interior to use PL_bufend instead of
that parameter.  The parameter had been used to limit how far into the
string being parsed scan_ident could look.  In all calls to scan_ident
but one, the parameter was already PL_bufend.  In the one call where it
wasn't, b5248 compensated by temporarily changing PL_bufend around the
call, running afoul, eventually, of the expectation that PL_bufend
points to a NUL.

I would have expected the reversion to add back both the parameter and
the uses of it, but apparently the function interior has changed enough
since the original commit, that it didn't even think there were
conflicts.  As a result the parameter got added back, but not the uses
of it.

I tried both approaches to fix this:
    1) to change the function to use the parameter;
    2) to simply delete the parameter.
Only the latter passed the test suite without error.

I then tried to understand why the parameter in the first place, and why
the kludge introduced by b5248 to work around removing it.  It appears
to me that this is for the benefit of the intuit_more function to enable
it to discern $] from a $ ending a bracketed character class, by ending
the scan before the ']' when in a pattern.

The trouble is that modern scan_ident versions do not view themselves as
constrained by PL_bufend.  If that is reached at a point where white
space is allowed, it will try appending the next input line and
continuing, thus changing PL_bufend.  Thus the kludge in b5248 wouldn't
necessarily do the expected limiting anyway.  The reason the approach
"1)" I tried didn't work was that the function continued to use the
original value, even after it had read in new things, instead of
accounting for those.

Hence approach "2)" is used.  I'm a little nervous about this, as it may
lead to intuit_more() (which uses heuristics) having more cases where it
makes the wrong choice about $] vs [...$].  But I don't see a way around
this, and the pre-existing code could fail anyway.

Spotted by Dave Mitchell.
embed.fnc
embed.h
proto.h
toke.c