Repository navigation
#1488 wave3a: seq fold paste tee fmt stat touch ln (240-case differential gate) - #1560
Merged
Merged
Conversation
Port of coreutils 9.4 seq.c, probed byte-for-byte against WSL GNU: - seq_fast(): decimal string increment for all-digit operands with step 1..=200 (arbitrary precision, probed 1e20..1e20+100), leading-zero trim, inf end value, per seq.c's all_digits_p/SEQ_FAST_STEP_LIMIT gates - long-double path: scan_arg() width/precision port, default %.PRECf / %Lg formats, -w width arithmetic, print_numbers() extra-number fixup (seq 0 0.000001 0.000003 case) - -f format validation (no %/ends in %/unknown %c/too many %) and a C printf engine covering flags -+ #0' width.precision eEfgGA, glibc-style %a normalization (1 -> 0x8p-3) - error order matches seq.c main(): missing/extra operand, format validation, -w/-f conflict, operand scan (GNU probed rc 1 shapes) - 50 strict gate cases, all byte-equal to GNU; C++ parity 46/50
Function-by-function port of coreutils 9.4 fold.c, byte-equal to WSL GNU: - adjust_column(): tab to next 8-stop, backspace -1, CR resets; -b counts plain bytes. GNU fold is NOT multibyte-aware and neither is this port (probed: -w 3 splits UTF-8 inside a code point) - fold rule: column > width breaks; -s finds the last blank, emits the line up to AND including it, reprocesses the current byte; an over-wide byte on an empty line is kept (tab case, probed) - width parsing reproduces xdectoumax(1, SIZE_MAX-9): 0 -> '...: Numerical result out of range', non-number -> no suffix, huge -> 'Value too large', rc 1; -1..-9 short options with fold.c's getopt pointer trick (-40 -> 40) - 26 strict gate cases, all byte-equal to GNU; C++ parity 26/26
…#1488) Port of coreutils 9.4 paste.c, byte-equal to WSL GNU: - parallel: delimiter list resets per output line and advances per file boundary (probed -dabc on 3 files); a closed file's delimiter is stashed in delbuf and flushed before the next open file's data; last-file missing newline is added (POSIX) - serial: delimiters cycle within a file, reset per file; empty file still emits one bare newline (probed) - collapse_escapes: \0 \b \f \n \r \t \v \\, trailing backslash error rc 1; -d '' becomes the NUL list; -z zero line delimiter - repeated '-' operands share one stream position via a per-slot closed flag over an Rc stream (paste - - reads once, probed); parallel open failure aborts immediately (EXIT_FAILURE), serial continues - 38 gate cases (37 strict); C++ parity 38/38
Port of coreutils 9.4 tee.c: - all outputs open before reading (-a appends); a failed open reports and drops that output while the rest run, rc 1 - stdin streams in chunks to stdout first then each file; a failed write drops that output. Default output-error=sigpipe: broken-pipe class failures are silent and do not fail (tee.c fail_output), other errors report and set rc 1; -p/--output-error select warn/exit nopipe modes - -i accepted (SIGINT does not apply on Windows); '-' is a literal file name per POSIX (GNU comment: do not treat - specially); /dev/null maps to the NUL device like the 1.x C++ native_path layer - 24 gate cases (21 strict); C++ parity 22/24
Function-by-function port of coreutils 9.4 fmt.c, byte-equal to WSL GNU: - words carry paren/period/punct/final attributes (emacs sentence rules); fmt_paragraph() computes the optimal break chain with fmt.c's exact costs: SHORT_COST (10n)^2, RAGGED half, LINE_COST 70^2, SENTENCE_BONUS 50^2, NOBREAK 600^2, WIDOW/ORPHAN 200^2|150^2/(n+2), PAREN/PUNCT 40^2, goal = width*187/200; a sentinel word slot mirrors fmt.c's word_limit - modes: -s (line = paragraph), -c crown, -t tagged, -u uniform spacing, -p prefix (leading spaces counted, trailing kept in full_length), tabs re-emitted in runs once seen (put_space); blank/non-paragraph lines copied verbatim via copy_rest - old -WIDTH first-argument syntax; digits as later options give GNU's '-WIDTH is recognized only when it is the first option' error; -w/-g ranges via xdectoumax(0, MAXCHARS/2) with GNU error shapes - documented divergence: GNU flushes partial paragraphs at 5000 chars / 1000 words; this port buffers the whole paragraph - 26 gate cases (25 strict); C++ parity 25/26
Raw kernel32/advapi32 declarations in the same family the 1.x C++ applets use (src/utils/win32.cppm), zero crates: - FILETIME <-> epoch helpers; naive local times through TzSpecificLocalTimeToSystemTime so DST conversion never touches the CRT global timezone (touch's owner directive) - file_meta(): CreateFileW(FILE_FLAG_BACKUP_SEMANTICS [+ OPEN_REPARSE_POINT for lstat]) -> GetFileInformationByHandleEx(FileBasicInfo) for the four timestamps, GetFileInformationByHandle for size/links/volume serial/file index; dangling-symlink lstat falls back to FindFirstFileW - owner/group via GetNamedSecurityInfoW + LookupAccountSidW with the 1.x id formula (0x30000+RID domain, 0x60000+RID authority 16, else RID) - CreateHardLinkW; CreateSymbolicLinkW with SYMBOLIC_LINK_FLAG_ALLOW_ UNPRIVILEGED_CREATE (Developer Mode) - the 1.x C++ lacks this flag, which is the documented ln22/24/25 note divergence - SetFileTime with zero-FT = keep; device mapping /dev/null -> NUL
- -c/--printf engine: flags/width/precision directives, unknown directive prints '?' with rc kept 0 (GNU probed); --printf processes backslash escapes and adds no newline, -c adds one per operand - default format is GNU stat.c's byte-shape (File/Size/Device/Access lines + four timestamps), -t the 16-field terse line; values are the Windows model of the 1.x applets via fs_win (uid 0x30000+RID, mode words 81a4/41ed/a1ff, volume-serial device, 4096 IO block, 512-byte blocks) - lstat by default (-L follows); symlink operand reports the link with the target-name length as size; missing operand: cannot statx ... rc 1, later operands still processed - %C prints '?' plus GNU's security-context stderr line: GNU rc 0, the 1.x C++ exits rc 1 - the recorded st10 note (Rust follows GNU) - -f renders the containing volume in GNU's shape (NTFS values) - 22 gate cases (9 strict, 11 win, 1 note); C++ parity 14/22
…#1488) - times set through SetFileTime on a FILE_WRITE_ATTRIBUTES handle (zero FT = keep); -h/--no-dereference opens reparse points; naive dates convert via TzSpecificLocalTimeToSystemTime - the CRT global timezone is never touched - -a/-m select which of the two times the source applies to; -r copies both from the reference; missing files created unless -c; errors keep processing later operands, rc 1 - -d subset probed against GNU 9.4: ISO 8601 with T or space separator, date-only, time-only (today), @epoch with fraction, trailing +HHMM/+HH:MM/+HH/Z/UTC/GMT zones; EMPTY date is today at local midnight rc 0 (GNU probed); relative forms report GNU's invalid date format rc 1 (documented subset) - -t [[CC]YY]MMDDhhmm[.ss]: YY 69-99 -> 19xx, 12-digit CCYY literal (9904 stays 9904), .ss exactly two digits 0-60 (.99 rejected, probed); Feb 29 on non-leap years rejected like GNU - 29 gate cases (28 strict); C++ parity 27/29
…e3a #1488) - hard links via CreateHardLinkW; -s via CreateSymbolicLinkW with the ALLOW_UNPRIVILEGED_CREATE flag, so symlink creation succeeds under Developer Mode where the 1.x C++ fails (ln22/24/25 notes: GNU rc 0, Rust rc 0, C++ rc 1); privilege failure reports GNU's shape with errno text Operation not permitted (1314), rc 1 - operand grammar per ln.c: 2 operands, >2 require an existing directory (target 'X': No such file or directory), 1 operand links into '.' (the same-file error GNU gives), -t/-T pin the destination; -T with 3+ operands is extra operand rc 1 - -f removes a non-directory dst via symlink_metadata (a symlink-to-dir is still removed); -i prompts on STDERR - ln: replace 'X'? - and an 'n' answer fails rc 1 silently (GNU probed); -b/--backup/-S simple ~, numbered .~N~, existing; -v on stdout: hard 'dst' => 'src', symlink 'dst' -> 'src' (byte-equal to GNU, strict-gated) - directory hard links refused: X: hard link not allowed for directory - 25 gate cases (19 strict, 1 exit, 2 win, 3 note); C++ parity 21/25
caomengxuan666
force-pushed
the
rust2/wave3a
branch
from
November 10, 2026 14:41
b31ebef to
71493f7
Compare
This was referenced Nov 11, 2026
Merged
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.
Closes part of #1488 (wave3a of the 2.0 Rust replacement).
8 commands:
seq fold paste tee fmt stat touch lnLibrary-form modules under
rust2/crates/winux-cmds/src/(std-only, zero deps), each ported from the GNU coreutils 9.4 source and probed byte-for-byte against WSL coreutils 9.4:-4/-40, xdectoumax error shapes-literal filename, /dev/null → NULThree-way gate (
bash rust2/gate/run-gate.sh seq fold paste tee fmt stat touch ln)240 cases; GNU-gated + win-gated all GREEN; 4 notes (documented 1.x C++ deviations from GNU that Rust intentionally does not inherit:
stat -c %Crc, unprivileged symlink creation ×3). C++ parity 219/240.Notes/known divergences (documented in module headers and GATE-REPORT.md):
Tests:
cargo test -p winux-cmds --lib182 passed;cargo fmtclean.