-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHOPT_OPTIMIZE: Do not optimize namerefs in for loops
Reproducer: one=1 bar=2 baz=3 nameref vv for vv in one bar baz do print -n -- "$vv" done Expected output: 123 Actual output: 111 This is another bug in the loop invariants optimiser. Research on the abandoned AT&T betas shows this bug was fixed in ksh 93v- 2013-02-13 (tagged as 2013-02-14 in the ksh93-history repo). The 93v- fix involves the sh_exec() TFOR code in xec.c temporarily setting the NV_TABLE attribute for namerefs, then adding a check for it in nv_create() so optimisation is disabled for namerefs. This commit backports that fix. For code legibility's sake, in this commit I'm aliasing NV_TABLE to NV_NOOPTIMIZE. This also allows us to define it as 0 when SHOPT_OPTIMIZE is disabled at compile time, so the compiler optimises out the new code. (It makes sense to (ab)use NV_TABLE for this purpose as it is never normally set for namerefs, plus, tables (as in .foo.bar-style variables, name starting with dot) aren't optimised either.) Thanks to @ormaaj for the bug report. Resolves: #704
- Loading branch information
Showing
7 changed files
with
83 additions
and
3 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
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