summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* color: Use an array of extensions instead of for_trie()Tavian Barnes2024-11-041-16/+37
| | | | | This will let us relax for_trie() iteration order so it can use for_varena() internally.
* expr: Get rid of the extra list nodeTavian Barnes2024-11-044-11/+5
| | | | We can now just use for_arena() to iterate over the allocated bfs_exprs.
* alloc: New for_arena() macro to iterate over allocated objectsTavian Barnes2024-11-042-0/+105
|
* alloc: Switch arenas from a freelist to a bitmap allocatorTavian Barnes2024-11-042-90/+262
|
* diag: New bfs_unreachable() and bfs_assume() macrosTavian Barnes2024-11-041-0/+32
|
* alloc: Don't require the old size in varena_realloc()Tavian Barnes2024-11-027-42/+68
| | | | Instead, just look up which arena contains the pointer.
* sanity: Don't mark memory uninit in sanitize_{alloc,free}()Tavian Barnes2024-11-022-9/+11
| | | | | We might want to change the size of an allocated region without changing which bytes are initialized.
* alloc: Stop supporting pathological flexible array ABIsTavian Barnes2024-11-022-18/+29
|
* alloc: Add macro versions of alignment utilsTavian Barnes2024-11-021-3/+12
|
* trie: Fix varena_free() with wrong sizeTavian Barnes2024-11-021-8/+8
| | | | | | | In trie_remove(), clearing the bit before trie_node_collapse() causes us to free the old node with size 1 instead of 2, putting it on the wrong freelist. This is technically safe with the current arena implementation, but not intentional.
* alloc: Don't require size % align == 0Tavian Barnes2024-11-022-30/+19
| | | | | | | | | Allowing unaligned sizes will allow us to allocate aligned slabs with additional metadata in the tail without ballooning the allocation size for large alignments. Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2244.htm#dr_460 Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2072.htm
* color: Handle bfs_check_capabilities error code (-1) in cpath_has_capabilitiesJody Frankowski2024-10-311-1/+1
| | | | | | | | | | | On non-Linux systems, bfs_check_capabilities always returned -1, so cpath_has_capabilities would always return true. If bfs was called with an LS_COLORS containing the `ca` statement, e.g. `ca=30;41`, bfs would color ALL the files. While including the `ca` statement in LS_COLORS on non-Linux systems is unusual, this is not an error and is a valid use-case (e.g. Using GNU ls or lsd). Fixes: 1520d4d3 ("color: Don't color files like directories on ENOTDIR")
* bit: Add bswap() overloads for every primitive typeTavian Barnes2024-10-271-9/+34
| | | | Fixes: https://github.com/tavianator/bfs/issues/145
* dstring: Add an infallible dstrshrink() functionTavian Barnes2024-10-174-9/+47
| | | | And mark the fallible ones with _nodiscard.
* color: Don't color files like directories on ENOTDIRTavian Barnes2024-10-161-114/+230
|
* color: Fix an infinite loop colorizing some invalid pathsTavian Barnes2024-10-131-8/+11
| | | | | | | | | | | | | | Previously, given $ touch file $ ln -s file/file notdir $ bfs notdir/file bfs would loop forever when printing the error message, since it expected stripping the trailing slash from "notdir/" to fix the ENOTDIR error, but the broken symlink still gave the same error. Fixes: b4c3201 ("color: Only highlight the trailing slash on ENOTDIR")
* sighook: Don't forget to reset list->tail on the last sigpop()Tavian Barnes2024-10-101-0/+2
| | | | | | | This was causing a UAF if we ever unregistered the last hook for a signal and then re-registered one. Fixes: 75b7f70 ("sighook: Make sigunhook() O(1)")
* eval: Use xtimer_start() for status bar updatesTavian Barnes2024-10-101-36/+76
|
* xtime: Add a wrapper for timer_create()/setitimer()Tavian Barnes2024-10-102-0/+120
| | | | | | setitimer() is obsolescent in POSIX 2008 and removed from POSIX 2024. However, at least macOS doesn't implement the new timer_create() API, so we still need the setitimer() fallback.
* Adjust in/out parameter docsTavian Barnes2024-10-105-11/+11
|
* Fix some -Wundef-prefix warningsTavian Barnes2024-10-104-6/+14
|
* trie: Switch the tag bits aroundTavian Barnes2024-10-081-31/+28
| | | | | | First of all, almost all checks were !trie_is_leaf(), so it makes sense to use trie_is_node() instead. Secondly, using the tag bit for internal nodes allows us to remove some NULL checks.
* trie: Add some extra bounds checkingTavian Barnes2024-10-081-13/+24
|
* opt: Remove duplicate assignment in canonicalize_not()Tavian Barnes2024-10-041-1/+0
|
* color: Fix an assertion failure with embedded NUL bytesTavian Barnes2024-10-021-0/+10
| | | | | | | | | | | | | Leading NUL bytes (e.g. `*\0.gz=...`) could cause us to insert a non-prefix-free set of strings into the case-insensitive extension trie, which would lead to crashes like bfs: trie_split@src/trie.c:538: Assertion failed: `key_nibble != rep_nibble` and OOB accesses to trie leaf keys. Fix it by ignoring those extensions, since filenames cannot contain NUL bytes. Fixes: 08030aea ("color: Delay the case_sensitive decision")
* Write @arg instead of @param arg in doc commentsTavian Barnes2024-10-0127-367/+367
|
* build: Add -Wundef-prefix=BFS_Tavian Barnes2024-10-012-0/+12
|
* list: Make SLIST_REMOVE() more type-safeTavian Barnes2024-09-301-25/+20
| | | | | | This avoids what might be a strict aliasing violation in some models. Link: https://github.com/llvm/llvm-project/pull/108385#issuecomment-2352938645
* Fix spellingTavian Barnes2024-09-236-6/+6
|
* list: New drain_slist() macroTavian Barnes2024-09-194-39/+49
|
* opt: #include "xspawn.h" before #ifdef POSIX_SPAWN_SETRLIMITTavian Barnes2024-09-171-0/+1
| | | | Fixes: 65a7814 ("opt: Don't raise RLIMIT_NOFILE if it would prevent using posix_spawn()")
* opt: Fix an invalid assertion in sink_not_comma()Tavian Barnes2024-09-171-4/+3
| | | | | | | When optimizing -not \( -a , -b \), the child is a comma expression, not the parent. Fixes: 4a36bb9 ("expr: Make expressions variadic")
* parse: Add a "logo" to bfs --versionTavian Barnes2024-09-141-1/+32
|
* dstring: New dstrepeat() functionTavian Barnes2024-09-142-0/+22
|
* opt: Add missing newline to debug statementTavian Barnes2024-09-121-1/+1
| | | | Fixes: 9b8cf46 ("opt: Warn about all ignored tests")
* Fix includesTavian Barnes2024-08-297-4/+6
|
* build: Move feature test macros to prelude.hTavian Barnes2024-08-2846-69/+57
| | | | | | This replaces the explicit CPPFLAGS list in flags.mk with just `-include src/prelude.h`, shortening our compiler command lines and allowing them to be easily documented.
* prelude: Split bfs-specific utilities into new bfs.h headerTavian Barnes2024-08-2850-194/+339
|
* prelude: Rely more on __has_include()Tavian Barnes2024-08-287-96/+31
| | | | | Rather than a bunch of manual fallback macros, just provide a fallback definition that returns false.
* build: Move tsan/target_clones conflict to the preludeTavian Barnes2024-08-281-1/+3
|
* prelude: Define __SANITIZE_*__Tavian Barnes2024-08-286-24/+21
|
* diag: Get rid of bfs_static_assert()Tavian Barnes2024-08-283-13/+2
| | | | | In most cases, it's not too annoying to specify a message. For tests/bit.c, we can manually polyfill the 1-argument version.
* prelude: Define thread_localTavian Barnes2024-08-282-11/+17
|
* bftw: Handle a hypothetical platform where AT_FDCWD == -1Tavian Barnes2024-08-281-2/+2
|
* prelude: Stub out __has_builtin() if necessaryTavian Barnes2024-08-231-0/+4
| | | | Fixes: c964524 ("atomic: Add a spin_loop() hint")
* eval: Don't warn about suppressed errors without -noerrorTavian Barnes2024-08-191-1/+1
|
* sighook: Fix typo in commentTavian Barnes2024-08-171-1/+1
|
* eval: Capitalize -noerror warning messageTavian Barnes2024-08-171-1/+1
|
* docs: Document the new -mount vs. -xdev behaviourTavian Barnes2024-08-161-2/+1
| | | | Fixes: 33b85e1 ("Implement POSIX 2024's -mount")
* New -noerror option to suppress error messagesTavian Barnes2024-08-163-1/+29
| | | | Closes: https://github.com/tavianator/bfs/issues/142