Skip to content

WIP: winx3-parser — parser family fixes for #1301–#1306 (verification pending) - #1391

Merged
caomengxuan666 merged 11 commits into
mainfrom
fix/winx3-parser
Oct 27, 2026
Merged

caomengxuan666 merged 11 commits into
mainfrom
fix/winx3-parser

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP draft — parser family fixes, not yet verified. Published early so the line is visible; do not merge until verification lands on this branch.

Coverage (one commit per issue)

Each commit carries its regression tests. Two issue-text corrections are baked in: #1306's diff -cu expectation in the issue text is wrong (GNU diffutils: rc2 + diff: conflicting output style options); #1302's fix is at the parser layer (message form differs from GNU grep's own string — see open items).

Current progress

Open items (awaiting main-session adjudication, deliberately not expanded here)

  1. [parser] Int long option with empty = value (--opt=) consumes the next argv #1302: align the diagnostic verbatim with GNU grep (invalid max count) down in the grep handler?
  2. [diagnostics] Option-error shapes diverge from GNU: grep/sed usage tails missing; unknown --opt=value truncated in message #1305: sed error tail is WinuxCmd's own help text (structurally complete, not GNU-verbatim) — accept, or file a copy task?
  3. [parser] Bundled short flags break when a shared meta carries an optional argument (uniq -Dc proven; diff -cu, split -dl same pattern) #1306: three message-form residuals — accept "behavior right, message slightly off", or file polish work?
  4. i18n catalog sync rides integration or a separate i18n-repo PR.
  5. POSIXLY_CORRECT caliber: this branch uses glibc presence-counts (incl. empty value); the dispatcher's existing is_posixly_correct() requires non-empty — sync it or not (affects nohup/echo, separate evaluation).

…irst operand (#1304)

glibc rule: mere presence of the variable counts (empty value too).
Parser-side: OptionParsePolicy gains posixly_correct; parse_command_runtime
narrows the stop to 1 and funnels both positional push sites through
push_positional. Non-getopt commands (find/test/[/expr/true/false/dd)
opt out in option_policy_for_command. The dispatcher pre-passes share
the flag via classify_args_for_dispatch (lands with #1303).

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
…reviation expansion (#1303)

New classify_args_for_dispatch walk: only real option tokens are
expanded or intercepted, so values (grep --label --help, cp --suffix
--ver) and wrapped-command operands (xargs/timeout/env/find -exec)
keep their spelling. Single argv-order scan for --help/--version
(first match wins, as GNU). The scan also rejects --help=/--version=
with the doesn't-allow-an-argument error (dispatcher side of #1301;
parser side follows in #1301). env gains stop_options_after_positionals=1.

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
Both long branches (and the single-dash long form) now report
"option '--<name>' doesn't allow an argument" instead of silently
ignoring the value (grep --count=x used to hang). i18n translate_error
gains the common.error.option_no_argument pattern. Dispatcher
--help=/--version= rejection landed with the #1303 scan rewrite.

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
… argv (#1302)

Long and single-dash-long Int branches now test has_inline_value:
an explicit empty value fails as invalid argument '' instead of
consuming the next argv as the value. String branches already used
has_inline_value and are untouched.

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
grep gets its one-line Usage before Try; sed gets its full help
instead of the Try line (Registry::get_help, new); unknown long
options keep the full --unknown=x token in the diagnostic
(ambiguous keeps the bare name, as GNU). The #1303 scan's
no-argument error path is gated through print_parse_error_tail.

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
…sing; -NUM for uniq/diff/split (#1306)

OptionalInt/OptionalString in a cluster now record presence and let
the rest of the cluster parse (uniq -Dc, diff -cu, split -dl) for
commands that opt out via allow_optional_short_attached_values=false
(uniq/diff/split only; sed -i.bak etc. keep attached values). Digit
runs in a cluster are the command's -NUM option (diff -c5/-5c,
uniq -D5, split -d5). diff/uniq gain hidden -NUM metas; diff
reports conflicting output style options (rc2) for two different
styles including --normal and -D/--ifdef.

WIP: harness build + repro verification still pending (mini build queued in the build-slot queue); published early per the no-local-only-work rule, verification to follow on this branch.
The enclosing 'export namespace WinuxCmd' already exports these
using-declarations; a second 'export' on them is ill-formed and GCC 16
rejects it ('export' may only occur once in an export declaration).
MSVC accepts the redundant form, so official builds never exposed this.

This is the GCC-portability fix for the mingw+Wine local verification
route only. It is unrelated to #1301-#1306 and touches no parser,
dispatcher, or command code.

Refs #1401
…CC modules

GCC module build of utils:regex failed with 'size_t' does not name a
type when PCRE2 is off: the global module fragment was empty and
'import std' does not provide unqualified ::size_t under strict GCC
module semantics (same shape as gnu_float80.cppm, which includes
<cstddef> in its global fragment and builds).

Refs #1406. One file only; unrelated to #1301-#1306 and to the #1401
version.cppm fix. Verification pending: mini build [93/93], repro.sh
and REPORT section 9 gates to follow; Fixes not used until gates pass.
caomengxuan666 and others added 2 commits October 26, 2026 23:35
# Conflicts:
#	src/utils/i18n.cppm
#	tests/unit/cat/cat_unit_test.cpp
#	tests/unit/find/find_unit_test.cpp
#	tests/unit/grep/grep_unit_test.cpp
#	tests/unit/sed/sed_unit_test.cpp
#	tests/unit/split/split_unit_test.cpp
#	tests/unit/uniq/uniq_unit_test.cpp
#	tests/unit/xargs/xargs_unit_test.cpp
@caomengxuan666

Copy link
Copy Markdown
Member Author

Verification landed (merge af5ca1e brings origin/main in; conflicts resolved in src/utils/i18n.cppm + 6 test files, both-sides-kept).

  • MSVC Debug build (scripts/build-with-vs.ps1, winuxcmd-tests target): green
  • ctest full suite: 3256 tests; the only 11 failures reproduce identically on a clean origin/main build (wt-main-verify @ beb5655), so they are pre-existing/environmental, not branch regressions:
    • cksum/md5sum/du issue_1288 deep-path tests — machine has LongPathsEnabled=0
    • xargs -p interactive tests ×4 — require CONIN$, no console under ctest runner
    • find.issue_1309_ls + 3 xargs tests — genuine pre-existing main failures worth a follow-up issue

@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 03:26
@caomengxuan666
caomengxuan666 merged commit b4f2f83 into main Oct 27, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/winx3-parser branch October 27, 2026 07:38
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
…#1407/#1412)

The four filed walls were fixed per-file via PR #1391 (version.cppm
inner export, regex/string size_t, utf8 PCH/std conflict), but the full
GCC build was never re-run to completion afterwards (build15 died on a
missing Wine interpreter with zero files compiled). Re-running it on
current main shows the defects were one class, not four files: module
global fragments that are not self-sufficient under GCC — a C++ header
must be seen before the windows.h chain so c++config.h's std
declarations land with C++ linkage (#1412 mechanism), and bare
size_t/uint64_t/_fileno must come from their own headers instead of
MSVC header-chain leaks (#1406/#1407 mechanism).

A keep-going (-k 0) GCC 16.2 build of the whole tree enumerates every
remaining instance; this commit fixes the class in one pass:
- #1412 guard (pre-include <cstddef> + #undef NOMINMAX) for every
  pch-first fragment lacking it: native_path (the wall the baseline
  build actually stops at), cmd_meta, console, file_io, i18n, pager,
  wildcard, win32 (its second include is aclapi.h, another windows
  header — no C++ header precedes pch.h there either).
- i18n: add <cstdint> (bare uint64_t in legacy_key; pristine-file probe
  shows both errors, the guard alone leaves this one).
- console: add <stdio.h> (_fileno).
- text_io: it has no global fragment at all and uses bare size_t;
  add the fragment with <cstddef>.

Refs #1401
Refs #1406
Refs #1407
Refs #1412
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
…#1407/#1412)

The four filed walls were fixed per-file via PR #1391 (version.cppm
inner export, regex/string size_t, utf8 PCH/std conflict), but the full
GCC build was never re-run to completion afterwards (build15 died on a
missing Wine interpreter with zero files compiled). Re-running it on
current main shows the defects were one class, not four files: module
global fragments that are not self-sufficient under GCC — a C++ header
must be seen before the windows.h chain so c++config.h's std
declarations land with C++ linkage (#1412 mechanism), and bare
size_t/uint64_t/_fileno must come from their own headers instead of
MSVC header-chain leaks (#1406/#1407 mechanism).

A keep-going (-k 0) GCC 16.2 build of the whole tree enumerates every
remaining instance; this commit fixes the class in one pass:
- #1412 guard (pre-include <cstddef> + #undef NOMINMAX) for every
  pch-first fragment lacking it: native_path (the wall the baseline
  build actually stops at), cmd_meta, console, file_io, i18n, pager,
  wildcard, win32 (its second include is aclapi.h, another windows
  header — no C++ header precedes pch.h there either).
- i18n: add <cstdint> (bare uint64_t in legacy_key; pristine-file probe
  shows both errors, the guard alone leaves this one).
- console: add <stdio.h> (_fileno).
- text_io: it has no global fragment at all and uses bare size_t;
  add the fragment with <cstddef>.

Refs #1401
Refs #1406
Refs #1407
Refs #1412
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
#1406/#1407/#1412)

The four filed walls were fixed per-file via PR #1391 (version.cppm
inner export, regex/string size_t, utf8 PCH/std conflict), but the full
GCC build was never re-run to completion afterwards (build15 died on a
missing Wine interpreter with zero files compiled). Re-running it on
current main shows the defects were one class, not four files: module
units that are not self-sufficient under GCC — a C++ header must be
seen before the windows.h chain so c++config.h's std declarations land
with C++ linkage (#1412 mechanism); bare size_t/uint64_t/_fileno must
come from their own headers instead of MSVC header-chain leaks
(#1406/#1407 mechanism); and names re-exported with 'export using'
must have external linkage, i.e. be exported at their declarations,
not merely declared in the purview (#1401 mechanism).

A keep-going (-k 0) GCC 16.2 build of the whole tree enumerates every
remaining instance; this commit fixes the class in one pass:
- #1412 guard (pre-include <cstddef> + #undef NOMINMAX) for every
  pch-first fragment lacking it: native_path (the wall the baseline
  build actually stops at), cmd_meta, console, file_io, i18n, pager,
  wildcard, win32 (its second include is aclapi.h, another windows
  header — no C++ header precedes pch.h there either).
- i18n: add <cstdint> (bare uint64_t in legacy_key; pristine-file probe
  shows both errors, the guard alone leaves this one).
- console: add <stdio.h> (_fileno).
- text_io: it has no global fragment at all and uses bare size_t;
  add the fragment with <cstddef>.
- cppbar: export the terminal namespace and the color/style entities
  (RGB, apply_color, reset_color, StyleConfig, Style) at their
  declarations so the trailing export-using block names only entities
  with external linkage, exactly as Color/ProgressBar already did.
  This TU was unreachable in every earlier build (it imports :console).

Refs #1401
Refs #1406
Refs #1407
Refs #1412
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
#1406/#1407/#1412)

The four filed walls were fixed per-file via PR #1391 (version.cppm
inner export, regex/string size_t, utf8 PCH/std conflict), but the full
GCC build was never re-run to completion afterwards (build15 died on a
missing Wine interpreter with zero files compiled). Re-running it on
current main shows the defects were one class, not four files: module
units that are not self-sufficient under GCC — a C++ header must be
seen before the windows.h chain so c++config.h's std declarations land
with C++ linkage (#1412 mechanism); bare size_t/uint64_t/_fileno/
_fdopen must come from their own headers instead of MSVC header-chain
leaks (#1406/#1407 mechanism); and exports must be well-formed —
no 'export' inside an export block/namespace, and 'export using' may
only name entities exported at their declarations (#1401 mechanism).

A keep-going (-k 0) GCC 16.2 build of the whole tree enumerates every
remaining instance; this commit fixes the class in one pass:
- #1412 guard (pre-include <cstddef> + #undef NOMINMAX) for every
  pch-first fragment lacking it: native_path (the wall the baseline
  build actually stops at), cmd_meta, console, file_io, i18n, pager,
  wildcard, win32 (its second include is aclapi.h, another windows
  header — no C++ header precedes pch.h there either), childproc
  (its <filesystem> sits after pch.h, too late to serve as the guard).
- i18n: add <cstdint> (bare uint64_t in legacy_key; pristine-file probe
  shows both errors, the guard alone leaves this one).
- console: add <stdio.h> (_fileno). file_io: add <stdio.h> (_fdopen).
- text_io: it has no global fragment at all and uses bare size_t;
  add the fragment with <cstddef>.
- file_io: remove the six inner 'export' keywords inside
  'export namespace file_io' (the version.cppm shape, with a NOTE).
- cppbar: export the terminal namespace and the color/style entities
  (RGB, apply_color, reset_color, StyleConfig, Style) at their
  declarations so the trailing export-using block names only entities
  with external linkage, exactly as Color/ProgressBar already did.
  This TU was unreachable in every earlier build (it imports :console).

Refs #1401
Refs #1406
Refs #1407
Refs #1412
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.

1 participant