mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
sort: Allow multi-character separators to be given with the -t
option
This commit is contained in:
parent
e6112446db
commit
94b247ec3c
|
@ -57,7 +57,7 @@ struct Options {
|
||||||
bool numeric { false };
|
bool numeric { false };
|
||||||
bool reverse { false };
|
bool reverse { false };
|
||||||
bool zero_terminated { false };
|
bool zero_terminated { false };
|
||||||
StringView separator { "\0", 1 };
|
StringView separator {};
|
||||||
Vector<DeprecatedString> files;
|
Vector<DeprecatedString> files;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ static ErrorOr<void> load_file(Options const& options, StringView filename, Stri
|
||||||
DeprecatedString line { TRY(file->read_until(buffer, line_delimiter)) };
|
DeprecatedString line { TRY(file->read_until(buffer, line_delimiter)) };
|
||||||
StringView key = line;
|
StringView key = line;
|
||||||
if (options.key_field != 0) {
|
if (options.key_field != 0) {
|
||||||
auto split = (options.separator[0])
|
auto split = (!options.separator.is_empty())
|
||||||
? line.split_view(options.separator[0])
|
? key.split_view(options.separator)
|
||||||
: line.split_view(is_ascii_space);
|
: key.split_view_if(is_ascii_space);
|
||||||
if (options.key_field - 1 >= split.size()) {
|
if (options.key_field - 1 >= split.size()) {
|
||||||
key = ""sv;
|
key = ""sv;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue