Commit Graph

24 Commits

Author SHA1 Message Date
Kyle Lanmon
e09245badd cut: Add -c,--characters option 2024-02-08 07:20:50 -07:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Tim Ledbetter
dedbc17160 cut: Add -s option to suppress lines without field delimiters
If this option is not specified, lines that contain to field
delimiters will be printed unmodified.
2023-06-26 19:49:34 +02:00
Tim Ledbetter
e740489abd cut: Ignore trailing newline if present 2023-06-26 19:49:34 +02:00
Tim Ledbetter
da67d593d8 cut: Treat a range containing consecutive commas or dashes as invalid 2023-06-26 19:49:34 +02:00
Tim Ledbetter
bc56d71252 cut: Print the entire line if it contains no field delimiters 2023-06-26 19:49:34 +02:00
Tim Ledbetter
230a873e0e cut: Don't ignore empty fields 2023-06-26 19:49:34 +02:00
Lucas CHOLLET
14826ced68 cut: Use the Stream API instead of a FILE * 2023-06-09 17:24:59 +02:00
Ali Mohammad Pur
db886fe18b Userland+AK: Stop using getopt() for ArgsParser
This commit moves the implementation of getopt into AK, and converts its
API to understand and use StringView instead of char*.
Everything else is caught in the crossfire of making
Option::accept_value() take a StringView instead of a char const*.

With this, we must now pass a Span<StringView> to ArgsParser::parse(),
applications using LibMain are unaffected, but anything not using that
or taking its own argc/argv has to construct a Vector<StringView> for
this method.
2023-02-28 15:52:24 +03:30
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Kenneth Myhra
5c15b97ca4 cut: Port to LibMain :^) 2021-12-11 15:10:42 -08:00
Andreas Kling
f1cc3d0fc4 Userland: Use Core::ArgsParser's Vector<StringView> API everywhere
...and remove the Vector<String> variant since there are no remaining
users of this API.
2021-11-26 23:27:57 +01:00
Tim Schumacher
ba29798039 Utilities: cut: Implement field-based cutting 2021-11-11 09:47:41 +01:00
Tim Schumacher
96ea4f71bd Utilities: cut: Split up into file and line processing 2021-11-11 09:47:41 +01:00
Tim Schumacher
4d18b21fb5 Utilities: cut: Work exclusively with ranges 2021-11-11 09:47:41 +01:00
Tim Schumacher
ed3a5f6b9d Utilities: cut: Move string splitting into expand_list 2021-11-11 09:47:41 +01:00
Tim Schumacher
2358f6cbda Utilities: cut: Migrate to ArgsParser 2021-11-11 09:47:41 +01:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00