Commit graph

513 commits

Author SHA1 Message Date
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
Yorhel
3942722eba Revert default --graph-style to "hash"
Because, even in 2022, there are systems where the libc locale is not,
in fact, UTF-8. Fixes #186.
2022-03-16 09:53:02 +01:00
Yorhel
1a3de55e68 Still accept "eigth-block" typo argument for compat 2022-03-14 15:58:41 +01:00
Phil Jones
1f46dacf12 Fix typo in --graph-style option
Change "eigth-block" to "eighth-block"
2022-03-14 13:31:01 +00:00
Yorhel
35dd631e55 Version 2.1; remove 1.x changes from the ChangeLog 2022-02-07 13:59:22 +01:00
Yorhel
f79ae654f3 Fix compilation on 32bit systems
Broken in 7d2905952d
2022-02-07 13:59:22 +01:00
Yorhel
e42db579a0 scan: Add UI message when counting hard links
That *usually* doesn't take longer than a few milliseconds, but it can
take a few seconds for some extremely large dirs, on very slow computers
or with optimizations disabled. Better display a message than make it
seem as if ncdu has stopped doing anything.
2022-02-05 09:19:15 +01:00
Yorhel
7d2905952d Add --graph-style option and Unicode graph drawing
And also adjust the graph width calculation to do a better job when the
largest item is smaller than the number of columns used for the graph,
which would previously draw either nothing (if size = 0) or a full bar
(if size > 0).

Fixes #172.
2022-02-03 16:10:18 +01:00
Yorhel
edf48f6f11 Use natsort when sorting by name
Fixes #181, now also for Zig.
2022-02-03 10:59:44 +01:00
Yorhel
41f7ecafcb Mention --ignore-config flag when reading config fails 2022-02-02 12:32:41 +01:00
Yorhel
f46c7ec65d Ignore ENOTDIR when trying to open config files 2022-02-02 11:49:04 +01:00
Yorhel
1b918a5a74 browser: Fix long file name overflow + unique size display glitch 2022-02-02 10:30:36 +01:00
Yorhel
01f1e9188a Version 2.0.1 + copyright year bump 2022-01-01 16:01:47 +01:00
Yorhel
ba26e6621b Makefile: Add ZIG_FLAGS variable
Fixes #185
2022-01-01 15:49:50 +01:00
Yorhel
2b23951e4f ui.zig: Really fix import of wcwidth() this time
Fixes #183
2021-12-26 11:02:42 +01:00
Yorhel
a6f5678088 ui.zig: Fix typo in setting _XOPEN_SOURCE feature test macro 2021-12-21 15:20:07 +01:00
Yorhel
23c59f2874 Version 2.0
I'm tagging this as a "stable" 2.0 release because the 2.0-beta#
numbering will get confusing when I'm working on new features and fixes.
It's still only usable for people who can use the particular Zig version
that's required (0.9.0 currently) and it will certainly break on
different Zig versions. But once you have a working binary for a
supported arch, it's perfectly stable.
2021-12-21 10:56:51 +01:00
Yorhel
6a68cd9b89 Fixes and updates for Zig 0.9.0 2021-12-21 10:34:44 +01:00
Yorhel
14b90444c9 Version 2.0-beta3 2021-11-09 09:11:35 +01:00
Yorhel
5b462cfb7a Fix export feature
...by making sure that Context.parents is properly initialized to null
when not scanning to RAM.

Fixes #179.
2021-11-02 15:29:12 +01:00
Yorhel
7efd2c6251 Make options, keys and file flags bold in man page
Port of 96a9231927
2021-10-07 10:33:01 +02:00
Yorhel
90873ef956 Fix defaults of scan_ui and --enable-* flags
Bit pointless to make these options nullable when you never assign null
to them.
2021-10-06 15:32:49 +02:00
Yorhel
8a23525cac Fix double-slash prefix in path display when scanning root 2021-10-06 14:49:40 +02:00
Yorhel
929cc75675 Fix import of "special" dirs and excluded items 2021-10-06 14:32:02 +02:00
Yorhel
fdb93bb9e6 Fix use-after-free in argument parsing
Introduced in 53d3e4c112
2021-10-06 14:06:50 +02:00
Yorhel
d1adcde15c Add --ignore-config command line option 2021-10-06 13:59:14 +02:00
Yorhel
39a137c132 Add reference to "man ncdu" in --help text
Not going to bloat the help output with all those settings...
2021-10-06 13:52:08 +02:00