Commit Graph

33 Commits

Author SHA1 Message Date
MacDue
281e46e8b3 grep: Fix out of bounds StringView indexing
This is another case of out of bounds indexing exposed by 13406b8.
2022-07-27 22:51:54 +00:00
Tim Schumacher
3d51642037 LibCore: Replace the ArgsParser option argument setting with an enum
Replacement conditions for `requires_argument` have been chosen based
on what would be most convenient for implementing an eventual optional
argument mode.
2022-07-14 00:24:24 +01:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Sam Atkins
f0aba519c3 Utilities: Read positional arguments as Strings not char*s
This is a pretty trivial change so they're all batched together.
2022-04-11 21:09:42 +02:00
Brian Gianforcaro
af3751e4dd Utilities: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Tim Schumacher
4a5d1db7f6 grep: Recognize mode based on the program name 2022-03-20 11:50:47 -07:00
Tim Schumacher
21bbff0349 grep: Properly update match state when handling files 2022-03-19 22:05:40 +01:00
Tim Schumacher
c1004b095e grep: Adapt maximum line size depending on file size
Otherwise, we would never stop trying to fetch new lines if the next
newline is found beyond a range that the (default sized) buffer can
hold.
2022-03-19 22:05:40 +01:00
Lucas CHOLLET
c2e7acc8bb grep: Port to LibMain 2022-01-14 19:42:19 +02:00
Tim Schumacher
6fe37a1e52 Utilities/grep: Implement using multiple patterns 2021-11-13 11:42:26 +01:00
Tim Schumacher
c81cef614a Utilities/grep: Implement line-counting mode 2021-11-12 21:29:18 +00:00
Andreas Kling
a54be656ae LibRegex: Don't push LibRegex's "Error" into the global namespace 2021-11-08 00:35:27 +01:00
Ben Wiederhake
1d777073fd grep: Add ability to output line numbers 2021-11-06 08:57:05 -07:00
Ben Wiederhake
b9a270e5e7 grep: Simplify lambda signature for readability
Those 'optional' arguments are always supplied anyway. Making them
compulsory means there's one thing fewer to keep track of.
2021-11-06 08:57:05 -07:00
Marco Cutecchia
0086466b61 Utilities: Add option to suppress errors to grep 2021-10-31 14:18:29 +03:30
Marco Cutecchia
647f89f15e Utilities: Add 'quiet' mode to grep 2021-10-31 14:18:29 +03:30
Andreas Kling
6ad427993a Everywhere: Behaviour => Behavior 2021-09-07 13:53:14 +02:00
Karol Kosek
791309a3d2 Utilities: Support grepping recursively from paths in the argument
Previously, the recursive flag always searched for file contents from
the current directory, ignoring the path argument entirely.
2021-09-04 15:36:31 +04:30
TheFightingCatfish
fdde19d616 Utilities: Add option to control when to use colored output for grep
Fixes #9351.
2021-08-12 18:57:21 +02:00
Ali Mohammad Pur
eca74088a0 grep: Use Basic POSIX regexps by default and make -E not the default 2021-07-10 13:33:08 +02:00
Gunnar Beutner
3bbe86d8ea Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Sahan Fernando
7ee73b3721 Userland: Fix double line spacing in grep 2021-06-14 16:27:02 +02:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
r-paiva
68de9008e7 Utilities: Fix grep match when reading from stdin
When reading from stdin, grep discards the last character,
even if that character is not \n.

This commit changes grep to no longer discard the last character from
a line.
2021-05-20 23:53:06 +02:00
Jean-Baptiste Boric
3038edab00 Utilities: Correct non-standard assert macros includes 2021-05-17 18:14:05 +01:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01: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
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest
6f9e6e63b6 grep: Exit with 1 if nothing matches 2021-02-15 17:32:56 +01:00
Andrew Kaster
258a3b27ac Userland: Implement grep -v (invert-match)
This will make grep output every line that doesn't have
any matches of the given regular expression
2021-01-25 09:41:19 +01:00
Andrew Kaster
036828ff43 Userland: Use getline instead of Core::File::standard_input in grep
Core::IODevice (which Core::File inherits from) does not have a
reasonable way to block for a line. grep was spinning on
IODevice::read_line, passing endless empty strings to the matcher
lambda. Use getline instead, which will at least block in the Kernel for
characters to be available on stdin and only return full lines (or eof)
2021-01-25 09:41:19 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00