* expr: Fix regex escape logic
We have to track if the previous character was already escaped to determine
if the '\' character should be interpreted as an escape character.
* expr: Fix parsing caret (^) as character class negation token
* expr: Add tests for parsing carets in regex
* expr: Add missing semicolon
* expr: Simplify boolean assignment
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* id: The `--real` flag should only affect `-u`, `-g`, and `-U`
* id: Test output with different UID and EUID
* id: Simplify testing different UID and EUID
* id: Compile preload file for test using cc instead of gcc
* id: Remove test for different UID and EUID
The test is incompatible with some CI/CD targets.
This reverts the following commits:
- 8efcbf9ada
- 208fa8e7f8
- a498a2722d
* update chrono crate version and switch to new_lenient use
* bring back custom_tz_fmt and update test
* update chrono version in fuzz lock file
* replace boxing with parse_to_owned
* expr: Escape anchor characters within the core pattern
The anchor characters `^` and `$` are not considered special characters by `expr`
unless they are used as expected on the start or end of the pattern.
The previously used `REGEX_OPTION_NONE` allowed anchors (^) and ($) to match across newlines.
New anchor behaviors:
- `^` matches the start of the entire string (`\A`)
- `$` matches the end of the entire string (`\Z`)
* id: Handle NULL pointer gracefully within `cstr2cow` macro
> getlogin() returns a pointer to a string containing the name of the user logged in on the controlling terminal of the process, or a NULL pointer if this information cannot be determined.
Ref: https://linux.die.net/man/3/getlogin
* id: Remove redundant std::ffi:: prefix from CStr
* id: Add comment for the null check
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
* id: Remove skip for test that should not segfault anymore
Segfault fixed by 292fb92423
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Instead of recreating the formatter over and over again, keep
it pre-parsed in a variable in TimeStyler class.
Also, avoid calling `now` over and over again, that's also slow.
Improves performance by about 6%.
Cache even numerical strings (numeric_uid_gid) in the HashMap,
this makes very little difference performance wise.
However, this allows us to return a reference to a String instead
of making a clone.
Saves about 2-3% on `ls -lR /var/lib .git` (and `ls -lRn`).
Also, add a note that HashMap might not be the most optimal choice.
Easier to reason about than the LazyLock/Mutex encapsulated
static variables.
Performance difference is not measurable, but this drops uneeded
Mutex lock/unlock that were seen in samply output.