Commit graph

489 commits

Author SHA1 Message Date
Yorhel
f4f4af4ee5 gitignore: Also ignore the newer .zig-cache/ 2024-07-12 09:26:37 +02:00
Yorhel
6db150cc98 Fix crash on invalid utf8 when scanning in -1 UI mode 2024-05-26 11:16:22 +02:00
Yorhel
a4484f27f3 Build: remove preferred_optimize_mode
Fixes #238
2024-04-25 14:15:46 +02:00
Yorhel
d0d064aaf9 Version 2.4 2024-04-21 10:58:35 +02:00
Yorhel
0e54ca775c Add "test" target for some linting; reorder man page sections 2024-04-20 15:56:12 +02:00
Yorhel
d60bcb2113 Copyright: remove year & use alias
Tired of bumping files every year and slowly moving stuff to my alias.
2024-04-20 15:49:51 +02:00
Yorhel
e1818430b7 Set default --color to "off" 2024-04-20 15:45:37 +02:00
Yorhel
29bbab64b3 Update Zig requirement in README + set preferred build mode
+ minor irrelevant build system changes.
2024-04-20 15:40:53 +02:00
Eric Joldasov
5944b738d0
build.zig: update to Zig 0.12.0-dev.3643+10ff81c26
* LazyPath now stores `Build` owner inside in
 https://github.com/ziglang/zig/pull/19623 and
 https://github.com/ziglang/zig/pull/19597 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-04-12 12:52:22 +05:00
Eric Joldasov
946d2a0316
src: update to standard library changes in Zig 0.12.0-dev.3385+3a836b480
* rearrangment of entries in `std.os` and `std.c`, `std.posix`
 finally extracted in https://github.com/ziglang/zig/pull/19354 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:06:20 +05:00
Eric Joldasov
8ce5bae872
src/ui.zig: update to language changes in Zig 0.12.0-dev.2150+63de8a598
* `name` field of std.builtin.Type struct changed type from `[]const u8` to `[:0]const u8`:
 https://github.com/ziglang/zig/pull/18470 .

 * New `'comptime var' is redundant in comptime scope` error
 introduced in https://github.com/ziglang/zig/pull/18242 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:06:14 +05:00
Eric Joldasov
c41e3f5828
build.zig: update to Zig 0.12.0-dev.2018+9a56228c2
* ZBS was reorganized around `Module` struct:
 https://www.github.com/ziglang/zig/pull/18160 .
 * Changes for ReleaseSafe: error return tracing is now off by default.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:02:48 +05:00
Eric Joldasov
1fa40ae498
src/ui.zig: update to language changes in Zig 0.12.0-dev.1808+69195d0cd
* New `redundant inline keyword in comptime scope` error
 introduced in https://github.com/ziglang/zig/pull/18227 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:02:42 +05:00
Eric Joldasov
f03eee5443
src: update to stdlib changes in Zig 0.12.0-dev.1710+2bffd8101
* std.fs.Dir/IterableDir separation was reverted in https://www.github.com/ziglang/zig/pull/18076 ,
 fix breaks ability to compile with Zig 0.11.0. It was planned since at least October, 16th:
 https://github.com/ziglang/zig/pull/12060#issuecomment-1763671541 .

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-03-20 23:02:38 +05:00
Yorhel
491988d9a5 Rewrite man page in mdoc
Still not a fan of roff, but even less a fan of build system stuff and a
dependency on a tool that is getting less ubiquitous over time.

I've removed the "hard links" section from the man page for now. Such a
section might be useful, but much of it was outdated.
2024-01-21 09:51:42 +01:00
Yorhel
a2eb84e7d3 Update parent dir suberr on refresh
Fixes #233
2023-12-05 12:06:14 +01:00
Eric Joldasov
c83159f076
fix new "var never mutated" error on Zig 0.12.0-dev.1663+6b1a823b2
Fixes these errors (introduced in https://github.com/ziglang/zig/pull/18017
and 6b1a823b2b ):

```
src/main.zig:290:13: error: local variable is never mutated
        var line_ = line_fbs.getWritten();
            ^~~~~
src/main.zig:290:13: note: consider using 'const'
src/main.zig:450:17: error: local variable is never mutated
            var path = std.fs.path.joinZ(allocator, &.{p, "ncdu", "config"}) catch unreachable;
                ^~~~
src/main.zig:450:17: note: consider using 'const'

...
```

Will be included in future Zig 0.12, this fix is backward compatible:
ncdu still builds and runs fine on Zig 0.11.0.

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-11-20 14:45:02 +06:00
Eric Joldasov
115de253a8
replace ncurses_refs.c workaround with pure Zig workaround
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-11-19 14:37:52 +06:00
Yorhel
a71bc6eca5 Add --quit-after-scan CLI flag for benchmarking 2023-08-08 10:30:33 +02:00
Yorhel
ec99218645 Version 2.3 2023-08-04 16:05:31 +02:00
Yorhel
83d3630ca7 Makefile: Honor ZIG variable + fix static build for x86 2023-08-04 12:43:27 +02:00
Eric Joldasov
ab6dc5be75
Update to Zig 0.11.0
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-08-04 14:41:49 +06:00
Eric Joldasov
0d99781c67
build.zig: add option for building PIE
Might be useful for package maintainers.

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-04-09 21:41:06 +06:00
Yorhel
e6cfacfa06 scan.zig: Add explicit cast for struct statfs.f_type
Hopefully fixes #221.
2023-04-02 11:58:41 +02:00
Florian Schmaus
74be277249 Makefile: Add ZIG variable and build target
The ZIG variable helps to test ncdu with different zig installations,
and it allows Gentoo to inject the zig version that should be used to
build zig into the Makefile.

Also add a phony 'build' target as first target to the Makefile so
that it becomes the default target. This allows the Gentoo package to
use the default src_compile() function.

See also https://bugs.gentoo.org/900547
2023-03-09 16:01:40 +01:00
Yorhel
46b88bcb5c Add --(enable|disable)-natsort options 2023-03-05 08:31:31 +01:00
Yorhel
ca1f293310 UI: Add * indicator to apparent size/disk usage selection + spacing
More visible than just bold.
2023-03-03 08:42:09 +01:00
Carlo Cabrera
07a13d9c73
Set headerpad_max_install_names on Darwin
This is useful for building binary distributions because it allows
references to library dependendencies on the build machine to be
rewritten appropriately upon installation on the user's machine.

Zig also does this in their `build.zig`:

    b52be973df/build.zig (L551-L554)
2023-02-22 13:51:08 +08:00
Yorhel
54d50e0443 Oops, forgot to update the README 2023-01-19 08:14:55 +01:00
Yorhel
ec233ff33a Version 2.2.2 + copyright year bump 2023-01-19 08:00:27 +01:00
Yorhel
c002d9fa92 Work around a Zig ReleaseSafe mode performance regression
With a little help from IRC:

<ifreund> Ayo: its probaly stupidly copying that array to the stack to do the
          safety check, pretty sure there's an open issue on this still
<ifreund> you may be able to work around the compiler's stupidity by using a
          pointer to the array or slice or something
<Ayo> ifreund: Yup, (&self.rdbuf)[self.rdoff] does the trick, thanks.
<ifreund> no problem! should get fixed eventually
2023-01-11 10:39:49 +01:00
Yorhel
cebaaf0972 Minor doc formatting fix & error message fix 2023-01-11 08:42:54 +01:00
Yorhel
4d124c7c3d Fix struct copy and invalid pointer access in Link.path()
Interesting case of
https://ziglang.org/download/0.10.0/release-notes.html#Escaped-Pointer-to-Parameter
2022-11-02 14:52:41 +01:00
Yorhel
890e5a4af7 Slightly less hacky Entry struct allocation and initialization 2022-11-02 14:39:05 +01:00
Yorhel
91281ef11f Use extern instead of packed structs for the data model
Still using a few embedded packed structs for those fields that benefit
from bit packing. This isn't much cleaner than using packed structs for
everything, but it does have better semantics. In particular, all fields
(except those inside nested packed structs) are now guaranteed to be
byte-aligned and I don't have to worry about the memory representation
of integers when pointer-casting between the different Entry types.
2022-11-02 11:32:35 +01:00
Yorhel
1452b91032 Some fixes for building with Zig stage2
Building is currently broken on packed struct alignment issues. :/
2022-10-26 13:34:27 +02:00
Yorhel
f7e774ee6e Fixes for stdlib changes 2022-10-26 13:34:06 +02:00
Yorhel
f37362af36 Version 2.2.1 2022-10-25 08:14:36 +02:00
Yorhel
0d16b9f33e Fix colors on FreeBSD (and MacOS?) again
Broken in 1548f9276f because I'm an idiot.

Probably also fixes #210, but I don't have a Mac to test.
2022-10-23 09:16:05 +02:00
Yorhel
34dafffc62 Version 2.2 2022-10-17 12:37:59 +02:00
Yorhel
1548f9276f Fix type signature of ncdu_init_pair() 2022-10-16 08:49:47 +02:00
Torbjörn Lönnemark
d6728bca95 Fix incorrect format string causing invalid export files
Zig requires alignment to be specified when specifying a fill character,
as otherwise digits specified after ':' are interpreted as part of the
field width.

The missing alignment specifier caused character codes < 0x10 to be
serialized incorrectly, producing an export file ncdu could not import.

For example, a character with code 1 would be serialized as '\u00 1'
instead of '\u0001'.

A directory of test files can be generated using:

    mkdir test_files; i=1; while [ $i -le 255 ]; do c="$(printf "$(printf "\\\\x%02xZ" "$i")")"; c="${c%Z}"; touch "test_files/$c"; i=$((i+1)); done
2022-10-15 21:00:17 +02:00
Yorhel
d523a77fdc Improve exclude pattern matching performance (and behavior, a bit)
Behavioral changes:
- A single wildcard ('*') does not cross directory boundary anymore.
  Previously 'a*b' would also match 'a/b', but no other tool that I am
  aware of matches paths that way. This change breaks compatibility with
  old exclude patterns but improves consistency with other tools.
- Patterns with a trailing '/' now prevent recursing into the directory.
  Previously any directory excluded with such a pattern would show up as
  a regular directory with all its contents excluded, but now the
  directory entry itself shows up as excluded.
- If the path given to ncdu matches one of the exclude patterns, the old
  implementation would exclude every file/dir being read, this new
  implementation would instead ignore the rule. Not quite sure how to
  best handle this case, perhaps just exit with an error message?

Performance wise, I haven't yet found a scenario where this
implementation is slower than the old one and it's *significantly*
faster in some cases - in particular when using a large amount of
patterns, especially with literal paths and file names.

That's not to say this implementation is anywhere near optimal:
- A list of relevant patterns is constructed for each directory being
  scanned. It may be possible to merge pattern lists that share
  the same prefix, which could both reduce memory use and the number of
  patterns that need to be matched upon entering a directory.
- A hash table with dynamic arrays as values is just garbage from a
  memory allocation point of view.
- This still uses libc fnmatch(), but there's an opportunity to
  precompile patterns for faster matching.
2022-08-10 09:46:39 +02:00
Yorhel
f0764ea24e Fix unreferenced test in model.zig
The other files were already indirectly referenced, but it's good to
make it explicit.
2022-08-08 18:23:53 +02:00
Yorhel
058b26bf9a Set default attributes to the whole window during curses init
Based on #204.
2022-06-15 06:17:38 +02:00
Yorhel
e6806059e6 Version 2.1.2 2022-04-28 11:19:43 +02:00
Yorhel
bb98939e24 Fix build with zig 0.10.0-dev.1946+6f4343b61
I wasn't planning on (publicly) keeping up with Zig master before the
next release, but it's looking like 0.10 will mainly focus on the new
stage2 compiler and there might not be any significant language/stdlib
changes. If that's the case, might as well pull in this little change in
order to increase chances of ncdu working out of the box when 0.10 is
out.
2022-04-28 11:03:19 +02:00
Yorhel
0fc14173f2 Fix panic when shortening strings with unicode variation selectors
Fixes #199.
That's not to say it handles variation selectors or combining marks
well, though. This is kind of messy. :(
2022-04-16 20:05:43 +02:00
Yorhel
2e4f0f0bce Version 2.1.1 2022-03-25 12:38:47 +01:00
Yorhel
5f383966a9 Fix bad assertion in scan.zig:addSpecial()
While it's true that the root item can't be a special, the first item to
be added is not necessarily the root item. In particular, it isn't when
refreshing.

Probably fixes #194
2022-03-24 07:32:55 +01:00