Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit c72077c fixed a place where to_byte_substr() fails, but the code continued as if it had succeeded. There is yet another place where the return is not checked. This commit adds a check there. However, it turns out that there is another underlying problem to [perl #114808]. The function to_byte_substr() tries to downgrade the substr fields in the regex program it is passed. If it fails (because something in it is expressible only in UTF-8), it permanently changes that field to point to PL_sv_undef, thus losing the original information. This is fine as long as the program will be used once and discarded. However, there are places where the program is re-used, as in the test case introduced by this commit, and the original value has been lost. To solve this, this commit also changes to_byte_substr() from returning void to instead returning bool, indicating success or failure. On failure, the original substrs are left intact. The calls to this function are correspondingly changed. One of them had a trace statement when the failure happens, I reworded it to be more general and accurate (it was slightly misleading), and added the trace to every such place, not just the one. In addition, I found the use of the same ternary operation in 3 or 4 consecutive lines very hard to understand; and is inefficient unless compiled under C optimization which avoids recalculating things. So I expanded the several nearly identical places in the code that do that so that I could quickly see what is going on.
- Loading branch information
Karl Williamson
committed
Oct 6, 2012
1 parent
c72077c
commit 7e0d5ad
Showing
4 changed files
with
102 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters