-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
refactor(dirname): implement pure string manipulation per POSIX #8936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add test_missing_operand to cover error path when dirname called with no arguments (lines 80-82). Add test_multiple_paths_comprehensive to cover loop iteration with mixed edge cases including trailing dot paths, empty strings, and various path types (line 84).
Replace Path::parent() approach with byte-level string operations to avoid path normalization. This ensures dirname behaves as a pure string manipulation tool per POSIX/GNU specifications, correctly handling patterns like foo//., foo/./bar, and preserving /. components in middle of paths. Add comprehensive test coverage for edge cases including multiple slash variations, dot-slash patterns, and component preservation. Addresses issue uutils#8910 with complete POSIX-compliant implementation.
CodSpeed Performance ReportMerging #8936 will not alter performanceComparing Summary
Footnotes
|
GNU testsuite comparison:
|
@naoNao89 please don't start new pr when others started. Contribute to the other instead :) |
GNU testsuite comparison:
|
63fe1ff
to
dc5e0eb
Compare
why draft ? :) |
dc5e0eb
to
2c72ad3
Compare
GNU testsuite comparison:
|
Fixes #8924 by rewriting dirname as pure byte-level string operations, avoiding Path::parent() normalization.
Handles all edge cases: foo//., foo///., foo/./, etc. Implementation uses explicit step-by-step logic without unsafe code, making it maintainable and platform-safe.
Added comprehensive tests for slash variations and dot-slash patterns.
Alternative to #8927 - this approach prioritizes code clarity and safety over conciseness. Both fix the same issues, but this avoids unsafe assumptions about OsStr encoding.