vms-e76: SORT honors /KEY=(POSITION:n,SIZE:m) field-based sort (facade-risk -> real) - #1050
Merged
Conversation
…e-risk -> real) Compat register facade-risk row utilities$sort: cmd_sort (src/vmsdcl/dcl_cmd_misc.c) did a whole-line case-insensitive qsort and IGNORED /KEY entirely -- SORT/KEY of a keyed file silently produced whole-line order while reporting success. The SORT verb did not even declare a KEY qualifier. Fix: - Declare KEY on the SORT verb as CDU_VT_LIST (q_sort, dcl_builtin.c), so /KEY=(POSITION:n,SIZE:m) parses and validates. - cmd_sort parses the /KEY value (POSITION/SIZE, optional DESCENDING; parens and ':' vs '=' tolerated) and, when present, sorts on the [pos,size] field via a key comparator (1-based VMS column, case-insensitive, /REVERSE XOR DESCENDING). No /KEY keeps the whole-line path unchanged. Ground-source: tests/dcl/test_sort_key.sh (run by the DCL conformance harness) sorts an input whose whole-line order (by column 1) DIFFERS from its keyed order (by the digit at column 5), and asserts the keyed sort yields zzz,mmm,aaa while the whole-line sort yields aaa,mmm,zzz -- so the old ignore-/KEY behaviour reddens the keyed assertion. The parse + field-extraction + comparator were also verified with a standalone harness (single key, descending, alt POS=/SIZE= spellings, non-key reject). Register: utilities$sort partial/facade-risk -> implemented/real. Documented follow-ups (not facades): secondary keys / multiple /KEY tie-breaking use the first key only, and MERGE is a separate absent utility (vms-a85a). Surface regenerated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
baron-3dl
force-pushed
the
work/sort-key
branch
from
September 2, 2026 20:23
fe1ef4e to
9c1457e
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Compat register facade-risk → real for
utilities$sort.cmd_sortdid a whole-line case-insensitiveqsortand ignored/KEYentirely —SORT/KEYof a keyed file silently produced whole-line order while reporting success. The SORT verb did not even declare aKEYqualifier.Fix
KEYon the SORT verb asCDU_VT_LIST(q_sort,dcl_builtin.c), so/KEY=(POSITION:n,SIZE:m)parses and validates.cmd_sorthonors/KEY: parses the value (POSITION/SIZE, optionalDESCENDING; parens and:/=tolerated) and sorts on the[pos,size]field via a key comparator (1-based VMS column, case-insensitive,/REVERSEXORDESCENDING). No/KEYkeeps the whole-line path unchanged.Ground-source
tests/dcl/test_sort_key.sh(DCL conformance harness) sorts an input whose whole-line order (by column 1) differs from its keyed order (by the digit at column 5) and asserts the keyed sort yieldszzz,mmm,aaawhile the whole-line sort yieldsaaa,mmm,zzz— so the old ignore-/KEYbehaviour reddens the keyed assertion. The parse + field-extraction + comparator were additionally verified with a standalone harness (single key, descending, alternatePOS=/SIZE=spellings, non-key reject).Register
utilities$sort: partial/facade-risk → implemented/real. Documented follow-ups (not facades): secondary keys / multiple/KEYtie-breaking use the first key only, and MERGE is a separate absent utility (vms-a85a). Surface regenerated. Off-cluster, self-contained.🤖 Generated with Claude Code