Repository navigation
diff: accept -W N, -WN, --width N and --tabsize N option forms - #424
yunusarda-sudo wants to merge 2 commits into
Conversation
Accept separate arguments (-W N, --width N, --tabsize N) and attached short option (-WN) in addition to attached long options (--width=N, --tabsize=N). Fixes uutils#396
Merging this PR will improve performance by 33.71%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing |
| /// `long` is given, if `param` is that option. | ||
| fn option_argument<'a>(param: &'a OsStr, short: &str, long: &str) -> Option<OptionArgument<'a>> { | ||
| if param == short || param == long { | ||
| if (!short.is_empty() && param == short) || (!long.is_empty() && param == long) { |
There was a problem hiding this comment.
could be simpler with short: Option<&str> instead of the empty-string checks, no?
| .args(&["w1", "w2"]) | ||
| .succeeds() | ||
| .stderr_is("") | ||
| .stdout_contains("x ") |
There was a problem hiding this comment.
please check the exact output with stdout_is, "x " is a weak check
Accept separate argument forms (
-W N,--width N,--tabsize N) and attached short option (-WN) in addition to attached long option formats (--width=N,--tabsize=N), matching GNU diff.Changes
--width=Nand--tabsize=Nwithoption_argumentandargument_value.option_argumentso emptyshort/longprefixes do not inadvertently match.src/params.rsfor all argument forms and error cases.tests/by-util/test_diff.rscovering option forms and missing/invalid arguments.Fixes #396