Skip to content

Preserve custom prefixes when expanding compound arguments - #438

Merged
p-ranav merged 1 commit into
p-ranav:masterfrom
fhgffy:fix/compound-custom-prefix
Oct 5, 2026
Merged

p-ranav merged 1 commit into
p-ranav:masterfrom
fhgffy:fix/compound-custom-prefix

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Compound arguments recognize configured prefix characters but expand each short option using a hard-coded -. With set_prefix_chars("+"), +ab therefore fails to find +a and +b. If both - and + options are registered, it can silently activate the wrong options instead.

Preserve the compound token's actual prefix in both parse_args and parse_known_args. Add regression coverage for default, plus and slash prefixes, value consumption, cross-prefix isolation, unknown arguments, and exact-name precedence.

Validation on master 4dbc0ffd3d5f83941eab12e73966724d8931ae07, GCC 14.2/C++17:

  • Three regression cases fail against the original header
  • Full suite: 278 cases and 1,022 assertions pass; one existing version test remains explicitly skipped
  • Focused ASan/UBSan: seven cases and 49 assertions pass
  • Independent review: 41 additional scenarios pass, including argc/argv, subparsers, multi-value compounds, missing values, and disabled prefixes
  • git diff --check passes

Leak detection was disabled because LeakSanitizer cannot run under this environment's ptrace. Clang/MSVC and clang-tidy were not run locally.

@fhgffy
fhgffy marked this pull request as ready for review October 3, 2026 23:18
@p-ranav
p-ranav merged commit 7d093f8 into p-ranav:master Oct 5, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants