[-]
[+]
|
Changed |
_service:tar_git:ncdu.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/sailfishos-chum/ncdu</param>
<param name="branch"></param>
- <param name="revision">1.17+git1</param>
+ <param name="revision">1.18+git2</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:ncdu-1.17+git1.tar.gz/upstream/deps/yopt.h
^
|
@@ -1,198 +0,0 @@
-/* Copyright (c) 2012-2013 Yoran Heling
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-/* This is a simple command-line option parser. Operation is similar to
- * getopt_long(), except with a cleaner API.
- *
- * This is implemented in a single header file, as it's pretty small and you
- * generally only use an option parser in a single .c file in your program.
- *
- * Supports (examples from GNU tar(1)):
- * "--gzip"
- * "--file <arg>"
- * "--file=<arg>"
- * "-z"
- * "-f <arg>"
- * "-f<arg>"
- * "-zf <arg>"
- * "-zf<arg>"
- * "--" (To stop looking for further options)
- * "<arg>" (Non-option arguments)
- *
- * Issues/non-features:
- * - An option either requires an argument or it doesn't.
- * - No way to specify how often an option can/should be used.
- * - No way to specify the type of an argument (filename/integer/enum/whatever)
- */
-
-
-#ifndef YOPT_H
-#define YOPT_H
-
-
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-
-typedef struct {
- /* Value yopt_next() will return for this option */
- int val;
- /* Whether this option needs an argument */
- int needarg;
- /* Name(s) of this option, prefixed with '-' or '--' and separated by a
- * comma. E.g. "-z", "--gzip", "-z,--gzip".
- * An option can have any number of aliases.
- */
- const char *name;
-} yopt_opt_t;
-
-
-typedef struct {
- int argc;
- int cur;
- int argsep; /* '--' found */
- char **argv;
- char *sh;
- const yopt_opt_t *opts;
- char errbuf[128];
-} yopt_t;
-
-
-/* opts must be an array of options, terminated with an option with val=0 */
-static inline void yopt_init(yopt_t *o, int argc, char **argv, const yopt_opt_t *opts) {
- o->argc = argc;
- o->argv = argv;
- o->opts = opts;
- o->cur = 0;
- o->argsep = 0;
- o->sh = NULL;
-}
-
-
-static inline const yopt_opt_t *_yopt_find(const yopt_opt_t *o, const char *v) {
- const char *tn, *tv;
-
- for(; o->val; o++) {
- tn = o->name;
- while(*tn) {
- tv = v;
- while(*tn && *tn != ',' && *tv && *tv != '=' && *tn == *tv) {
- tn++;
- tv++;
- }
- if(!(*tn && *tn != ',') && !(*tv && *tv != '='))
- return o;
- while(*tn && *tn != ',')
- tn++;
- while(*tn == ',')
- tn++;
- }
- }
-
- return NULL;
-}
-
-
-static inline int _yopt_err(yopt_t *o, char **val, const char *fmt, ...) {
- va_list va;
- va_start(va, fmt);
- vsnprintf(o->errbuf, sizeof(o->errbuf), fmt, va);
- va_end(va);
- *val = o->errbuf;
- return -2;
-}
-
-
-/* Return values:
- * 0 -> Non-option argument, val is its value
- * -1 -> Last argument has been processed
- * -2 -> Error, val will contain the error message.
- * x -> Option with val = x found. If the option requires an argument, its
- * value will be in val.
- */
-static inline int yopt_next(yopt_t *o, char **val) {
- const yopt_opt_t *opt;
- char sh[3];
-
- *val = NULL;
- if(o->sh)
- goto inshort;
-
- if(++o->cur >= o->argc)
- return -1;
-
- if(!o->argsep && o->argv[o->cur][0] == '-' && o->argv[o->cur][1] == '-' && o->argv[o->cur][2] == 0) {
- o->argsep = 1;
- if(++o->cur >= o->argc)
- return -1;
- }
-
- if(o->argsep || *o->argv[o->cur] != '-') {
- *val = o->argv[o->cur];
- return 0;
- }
-
- if(o->argv[o->cur][1] != '-') {
- o->sh = o->argv[o->cur]+1;
- goto inshort;
- }
-
- /* Now we're supposed to have a long option */
- if(!(opt = _yopt_find(o->opts, o->argv[o->cur])))
- return _yopt_err(o, val, "Unknown option '%s'", o->argv[o->cur]);
- if((*val = strchr(o->argv[o->cur], '=')) != NULL)
- (*val)++;
- if(!opt->needarg && *val)
- return _yopt_err(o, val, "Option '%s' does not accept an argument", o->argv[o->cur]);
- if(opt->needarg && !*val) {
- if(o->cur+1 >= o->argc)
- return _yopt_err(o, val, "Option '%s' requires an argument", o->argv[o->cur]);
- *val = o->argv[++o->cur];
- }
- return opt->val;
-
- /* And here we're supposed to have a short option */
-inshort:
- sh[0] = '-';
- sh[1] = *o->sh;
- sh[2] = 0;
- if(!(opt = _yopt_find(o->opts, sh)))
- return _yopt_err(o, val, "Unknown option '%s'", sh);
- o->sh++;
- if(opt->needarg && *o->sh)
- *val = o->sh;
- else if(opt->needarg) {
- if(++o->cur >= o->argc)
- return _yopt_err(o, val, "Option '%s' requires an argument", sh);
- *val = o->argv[o->cur];
- }
- if(!*o->sh || opt->needarg)
- o->sh = NULL;
- return opt->val;
-}
-
-
-#endif
-
-/* vim: set noet sw=4 ts=4: */
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/ChangeLog
^
|
@@ -1,3 +1,18 @@
+1.18 - 2022-12-06
+ - Fix 'dark-bg' color scheme to actually have a dark background
+ - Backport configuration file support from 2.x
+ - Backport many new CLI options from 2.x
+ - Negation of existing flags: --no-si, --no-confirm-quit, --no-follow-symlinks, --include-caches, --include-kernfs
+ - --[no-]extended in addition to -e
+ - --one-file-system and --cross-file-system in addition to -x
+ - --slow-ui-updates, --fast-ui-updates in addition to -q
+ - Column visibility options: --(show|hide)-(hidden|itemcount|mtime|graph|percent)
+ - Sorting: --sort, --[no-]group-directories-first
+ - Feature selection: --(enable|disable)-(shell|delete|refresh)
+ - Deletion confirmation: --[no-]confirm-delete
+ - Hidden file visibility: --show-hidden, --hide-hidden
+ - Size display: --apparent-size, --disk-usage
+
1.17 - 2022-04-28
- Add 'dark-bg' color scheme and use that by default
- Use natural sort order when sorting by file name
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/Makefile.am
^
|
@@ -21,7 +21,6 @@
noinst_HEADERS=\
- deps/yopt.h\
deps/khashl.h\
deps/strnatcmp.h\
src/browser.h\
@@ -49,6 +48,5 @@
# dependencies have minor ncdu-specific changes.
update-deps:
wget -q https://raw.github.com/attractivechaos/klib/master/khashl.h -O "$(srcdir)/deps/khashl.h"
- wget -q http://g.blicky.net/ylib.git/plain/yopt.h -O "$(srcdir)/deps/yopt.h"
wget -q https://raw.githubusercontent.com/sourcefrog/natsort/master/strnatcmp.h -O "$(srcdir)/deps/strnatcmp.h"
wget -q https://raw.githubusercontent.com/sourcefrog/natsort/master/strnatcmp.c -O "$(srcdir)/deps/strnatcmp.c"
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/README
^
|
@@ -1,4 +1,4 @@
-ncdu 1.17
+ncdu 1.18
=========
DESCRIPTION
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/configure.ac
^
|
@@ -1,5 +1,5 @@
-AC_INIT([ncdu],[1.17],[projects@yorhel.nl])
+AC_INIT([ncdu],[1.18],[projects@yorhel.nl])
AC_CONFIG_SRCDIR([src/global.h])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign std-options subdir-objects])
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/doc/ncdu.pod
^
|
@@ -54,12 +54,12 @@
gzip. This scales linearly, so be prepared to handle a few tens of megabytes
when dealing with millions of files.
-=item B<-e>
+=item B<-e>, B<--extended>, B<--no-extended>
-Enable extended information mode. This will, in addition to the usual file
-information, also read the ownership, permissions and last modification time
-for each file. This will result in higher memory usage (by roughly ~30%) and in
-a larger output file when exporting.
+Enable/disable extended information mode. This will, in addition to the usual
+file information, also read the ownership, permissions and last modification
+time for each file. This will result in higher memory usage (by roughly ~30%)
+and in a larger output file when exporting.
When using the file export/import function, this flag will need to be added
both when exporting (to make sure the information is added to the export), and
@@ -70,6 +70,66 @@
This enables viewing and sorting by the latest child mtime, or modified time,
using 'm' and 'M', respectively.
+=item B<--ignore-config>
+
+Do not attempt to load any configuration files.
+
+=back
+
+=head2 Scan Options
+
+These options affect the scanning progress, and have no effect when importing
+directory information from a file.
+
+=over
+
+=item B<-x>, B<--one-file-system>
+
+Do not cross filesystem boundaries, i.e. only count files and directories on
+the same filesystem as the directory being scanned.
+
+=item B<--cross-file-system>
+
+Do cross filesystem boundaries. This is the default, but can be specified to
+overrule a previously given C<-x>.
+
+=item B<--exclude> I<PATTERN>
+
+Exclude files that match I<PATTERN>. The files will still be displayed by
+default, but are not counted towards the disk usage statistics. This argument
+can be added multiple times to add more patterns.
+
+=item B<-X> I<FILE>, B<--exclude-from> I<FILE>
+
+Exclude files that match any pattern in I<FILE>. Patterns should be separated
+by a newline.
+
+=item B<--include-caches>, B<--exclude-caches>
+
+Include (default) or exclude directories containing CACHEDIR.TAG. The
+directories will still be displayed, but their contents will not be scanned or
+counted towards the disk usage statistics.
+L<http://www.brynosaurus.com/cachedir/>
+
+=item B<-L>, B<--follow-symlinks>, B<--no-follow-symlinks>
+
+Follow (or not) symlinks and count the size of the file they point to. As of
+ncdu 1.14, this option will not follow symlinks to directories and will count
+each symlinked file as a unique file (i.e. unlike how hard links are handled).
+This is subject to change in later versions.
+
+=item B<--exclude-firmlinks>, B<--follow-firmlinks>
+
+(MacOS only) Exclude or follow firmlinks.
+
+=item B<--include-kernfs>, B<--exclude-kernfs>
+
+(Linux only) Include (default) or exclude Linux pseudo filesystems, e.g. /proc
+(procfs), /sys (sysfs).
+
+The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup,
+cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace.
+
=back
=head2 Interface options
@@ -99,103 +159,133 @@
a file. This is the only interface that provides feedback on any non-fatal
errors while scanning.
-=item B<-q>
+=item B<-q>, B<--slow-ui-updates>, B<--fast-ui-updates>
-Quiet mode. While scanning or importing the directory, ncdu will update the
-screen 10 times a second by default, this will be decreased to once every 2
-seconds in quiet mode. Use this feature to save bandwidth over remote
-connections. This option has no effect when C<-0> is used.
+Change the UI update interval while scanning or importing. Ncdu will update the
+screen 10 times a second by default (C<--fast-ui-updates>), this can be
+decreased to once every 2 seconds with C<-q> or C<--slow-ui-updates>. This
+feature can be used to save bandwidth over remote connections. This option has
+no effect when C<-0> is used.
-=item B<-r>
+=item B<--enable-shell>, B<--disable-shell>
-Read-only mode. This will disable the built-in file deletion feature. This
-option has no effect when C<-o> is used, because there will not be a browser
-interface in that case. It has no effect when C<-f> is used, either, because
-the deletion feature is disabled in that case anyway.
-
-WARNING: This option will only prevent deletion through the file browser. It is
-still possible to spawn a shell from ncdu and delete or modify files from
-there. To disable that feature as well, pass the C<-r> option twice (see
-C<-rr>).
+Enable or disable shell spawning from the browser. This feature is enabled by
+default when scanning a live directory and disabled when importing from file.
-=item B<-rr>
+=item B<--enable-delete>, B<--disable-delete>
-In addition to C<-r>, this will also disable the shell spawning feature of the
-file browser.
+Enable or disable the built-in file deletion feature. This feature is enabled
+by default when scanning a live directory and disabled when importing from
+file. Explicitly disabling the deletion feature can work as a safeguard to
+prevent accidental data loss.
-=item B<--si>
+=item B<--enable-refresh>, B<--disable-refresh>
+
+Enable or disable directory refreshing from the browser. This feature is
+enabled by default when scanning a live directory and disabled when importing
+from file.
+
+=item B<-r>
+
+Read-only mode. When given once, this is an alias for C<--disable-delete>, when
+given twice it will also add C<--disable-shell>, thus ensuring that there is no
+way to modify the file system from within ncdu.
+
+=item B<--si>, B<--no-si>
List sizes using base 10 prefixes, that is, powers of 1000 (KB, MB, etc), as
defined in the International System of Units (SI), instead of the usual base 2
prefixes, that is, powers of 1024 (KiB, MiB, etc).
-=item B<--confirm-quit>
+=item B<--disk-usage>, B<--apparent-size>
-Requires a confirmation before quitting ncdu. Very helpful when you
-accidentally press 'q' during or after a very long scan.
+Select whether to display disk usage (default) or apparent sizes. Can also be
+toggled in the browser with the 'a' key.
-=item B<--color> I<SCHEME>
+=item B<--show-hidden>, B<--hide-hidden>
-Select a color scheme. The following schemes are recognized: I<off> to disable
-colors, I<dark> for a color scheme intended for dark backgrounds and I<dark-bg>
-for a variation of the I<dark> color scheme that also works in terminals with a
-light background.
+Show (default) or hide "hidden" and excluded files. Can also be toggled in the
+browser with the 'e' key.
-The default is I<dark-bg> unless the C<NO_COLOR> environment variable is set.
+=item B<--show-itemcount>, B<--hide-itemcount>
-=back
+Show or hide (default) the item counts column. Can also be toggled in the
+browser with the 'c' key.
-=head2 Scan Options
+=item B<--show-mtime>, B<--hide-mtime>
-These options affect the scanning progress, and have no effect when importing
-directory information from a file.
+Show or hide (default) the last modification time column. Can also be toggled
+in the browser with the 'm' key. This option is ignored when not in extended
+mode (see C<-e>).
-=over
+=item B<--show-graph>, B<--hide-graph>
-=item B<-x>
+Show (default) or hide the relative size bar column. Can also be toggled in the
+browser with the 'g' key.
-Do not cross filesystem boundaries, i.e. only count files and directories on
-the same filesystem as the directory being scanned.
+=item B<--show-percent>, B<--hide-percent>
-=item B<--exclude> I<PATTERN>
+Show (default) or hide the relative size percent column. Can also be toggled in
+the browser with the 'g' key.
-Exclude files that match I<PATTERN>. The files will still be displayed by
-default, but are not counted towards the disk usage statistics. This argument
-can be added multiple times to add more patterns.
+=item B<--sort> I<COLUMN>
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/browser.c
^
|
@@ -31,7 +31,7 @@
#include <time.h>
-static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0, show_items = 0, show_mtime = 0;
+static int info_show = 0, info_page = 0, info_start = 0;
static const char *message = NULL;
@@ -256,7 +256,7 @@
}
-void browse_draw() {
+void browse_draw(void) {
struct dir *t;
const char *tmp;
int selected = 0, i;
@@ -272,7 +272,7 @@
addstrc(UIC_HD, " for help");
if(dir_import_active)
mvaddstr(0, wincols-10, "[imported]");
- else if(read_only)
+ else if(!can_delete)
mvaddstr(0, wincols-11, "[read-only]");
/* second line - the path */
@@ -323,7 +323,7 @@
if(message) {
nccreate(6, 60, "Message");
ncaddstr(2, 2, message);
- ncaddstr(4, 34, "Press any key to continue");
+ ncaddstr(4, 33, "Press any key to continue");
}
/* draw information window */
@@ -488,8 +488,8 @@
/* and other stuff */
case 'r':
- if(dir_import_active) {
- message = "Directory imported from file, won't refresh.";
+ if(!can_refresh) {
+ message = "Directory refresh feature disabled.";
break;
}
if(dirlist_par) {
@@ -527,14 +527,12 @@
info_show = 0;
break;
case 'd':
- if(read_only >= 1 || dir_import_active) {
- message = read_only >= 1
- ? "File deletion disabled in read-only mode."
- : "File deletion not available for imported directories.";
- break;
- }
if(sel == NULL || sel == dirlist_parent)
break;
+ if(!can_delete) {
+ message = "Deletion feature disabled.";
+ break;
+ }
info_show = 0;
if((t = dirlist_get(1)) == sel)
if((t = dirlist_get(-1)) == sel || t == dirlist_parent)
@@ -542,10 +540,8 @@
delete_init(sel, t);
break;
case 'b':
- if(read_only >= 2 || dir_import_active) {
- message = read_only >= 2
- ? "Shell feature disabled in read-only mode."
- : "Shell feature not available for imported directories.";
+ if(!can_shell) {
+ message = "Shell feature disabled.";
break;
}
shell_init();
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/delete.c
^
|
@@ -35,9 +35,10 @@
#define DS_PROGRESS 1
#define DS_FAILED 2
+int delete_confirm = 1;
static struct dir *root, *nextsel, *curdir;
-static char noconfirm = 0, ignoreerr = 0, state;
+static char ignoreerr = 0, state;
static signed char seloption;
static int lasterrno;
@@ -98,7 +99,7 @@
}
-void delete_draw() {
+void delete_draw(void) {
browse_draw();
switch(state) {
case DS_CONFIRM: delete_draw_confirm(); break;
@@ -126,7 +127,7 @@
if(seloption == 1)
return 1;
if(seloption == 2)
- noconfirm++;
+ delete_confirm = 0;
state = DS_PROGRESS;
break;
case 'q':
@@ -211,12 +212,12 @@
}
-void delete_process() {
+void delete_process(void) {
struct dir *par;
/* confirm */
seloption = 1;
- while(state == DS_CONFIRM && !noconfirm)
+ while(state == DS_CONFIRM && delete_confirm)
if(input_handle(0)) {
browse_init(root->parent);
return;
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/delete.h
^
|
@@ -28,6 +28,8 @@
#include "global.h"
+extern int delete_confirm;
+
void delete_process(void);
int delete_key(int);
void delete_draw(void);
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/dir_common.c
^
|
@@ -35,7 +35,7 @@
char *dir_curpath; /* Full path of the last seen item. */
struct dir_output dir_output;
char *dir_fatalerr; /* Error message on a fatal error. (NULL if there was no fatal error) */
-int dir_ui; /* User interface to use */
+int dir_ui = -1; /* User interface to use */
static int confirm_quit_while_scanning_stage_1_passed; /* Additional check before quitting */
static char *lasterr; /* Path where the last error occurred. */
static int curpathl; /* Allocated length of dir_curpath */
@@ -65,7 +65,7 @@
/* removes last component from dir_curpath */
-void dir_curpath_leave() {
+void dir_curpath_leave(void) {
char *tmp;
if((tmp = strrchr(dir_curpath, '/')) == NULL)
strcpy(dir_curpath, "/");
@@ -180,7 +180,7 @@
}
-void dir_draw() {
+void dir_draw(void) {
float f;
const char *unit;
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/exclude.c
^
|
@@ -46,8 +46,7 @@
n = &((*n)->next);
*n = (struct exclude *) xcalloc(1, sizeof(struct exclude));
- (*n)->pattern = (char *) xmalloc(strlen(pat)+1);
- strcpy((*n)->pattern, pat);
+ (*n)->pattern = xstrdup(pat);
}
@@ -89,7 +88,7 @@
}
-void exclude_clear() {
+void exclude_clear(void) {
struct exclude *n, *l;
for(n=excludes; n!=NULL; n=l) {
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/global.h
^
|
@@ -95,8 +95,10 @@
/* program state */
extern int pstate;
-/* read-only flag, 1+ = disable deletion, 2+ = also disable shell */
-extern int read_only;
+/* enabled features */
+extern int can_delete;
+extern int can_shell;
+extern int can_refresh;
/* minimum screen update interval when calculating, in ms */
extern long update_delay;
/* filter directories with CACHEDIR.TAG */
@@ -109,6 +111,16 @@
extern int follow_symlinks;
/* flag whether we want to follow firmlinks */
extern int follow_firmlinks;
+/* display SI units */
+extern int si;
+/* show apparent sizes */
+extern int show_as;
+/* graph display setting */
+extern int graph;
+/* column visibility */
+extern int show_items;
+extern int show_mtime;
+
/* handle input from keyboard and update display */
int input_handle(int);
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/help.c
^
|
@@ -70,7 +70,7 @@
"F", "Excluded firmlink",
};
-void help_draw() {
+void help_draw(void) {
int i, line;
browse_draw();
@@ -203,7 +203,7 @@
}
-void help_init() {
+void help_init(void) {
page = 1;
start = 0;
pstate = ST_HELP;
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/main.c
^
|
@@ -33,17 +33,22 @@
#include <unistd.h>
#include <sys/time.h>
-#include <yopt.h>
-
int pstate;
-int read_only = 0;
+int can_delete = -1;
+int can_shell = -1;
+int can_refresh = -1;
long update_delay = 100;
int cachedir_tags = 0;
int extended_info = 0;
int follow_symlinks = 0;
int follow_firmlinks = 1;
int confirm_quit = 0;
+int si = 0;
+int show_as = 0;
+int graph = 1;
+int show_items = 0;
+int show_mtime = 0;
static int min_rows = 17, min_cols = 60;
static int ncurses_init = 0;
@@ -113,153 +118,296 @@
}
-/* parse command line */
-static void argv_parse(int argc, char **argv) {
- yopt_t yopt;
- int v;
- char *val;
- char *export = NULL;
- char *import = NULL;
- char *dir = NULL;
+/* This is a backport of the argument parser in the Zig version.
+ * Minor differences in that this implementation can modify argv in-place and has a slightly different API. */
+struct argparser {
+ int argc;
+ char **argv;
+ char *shortopt;
+ char *last;
+ char *last_arg;
+ char shortbuf[2];
+ char argsep;
+} argparser_state;
+
+static char *argparser_pop(struct argparser *p) {
+ char *a;
+ if(p->argc == 0) return NULL;
+ a = *p->argv;
+ p->argv++;
+ p->argc--;
+ return a;
+}
+
+static int argparser_shortopt(struct argparser *p, char *buf) {
+ p->shortbuf[0] = '-';
+ p->shortbuf[1] = *buf;
+ p->shortopt = buf[1] ? buf+1 : NULL;
+ p->last = p->shortbuf;
+ return 1;
+}
- static yopt_opt_t opts[] = {
- { 'h', 0, "-h,-?,--help" },
- { 'q', 0, "-q" },
- { 'v', 0, "-v,-V,--version" },
- { 'x', 0, "-x" },
- { 'e', 0, "-e" },
- { 'r', 0, "-r" },
- { 'o', 1, "-o" },
- { 'f', 1, "-f" },
- { '0', 0, "-0" },
- { '1', 0, "-1" },
- { '2', 0, "-2" },
- { 1, 1, "--exclude" },
- { 'X', 1, "-X,--exclude-from" },
- { 'L', 0, "-L,--follow-symlinks" },
- { 'C', 0, "--exclude-caches" },
- { 2, 0, "--exclude-kernfs" },
- { 3, 0, "--follow-firmlinks" }, /* undocumented, this behavior is the current default */
- { 4, 0, "--exclude-firmlinks" },
- { 's', 0, "--si" },
- { 'Q', 0, "--confirm-quit" },
- { 'c', 1, "--color" },
- {0,0,NULL}
- };
+/* Returns 0 when done, 1 if there's an option, 2 if there's a positional argument. */
+static int argparser_next(struct argparser *p) {
+ if(p->last_arg) die("Option '%s' does not expect an argument.\n", p->last);
+ if(p->shortopt) return argparser_shortopt(p, p->shortopt);
+ p->last = argparser_pop(p);
+ if(!p->last) return 0;
+ if(p->argsep || !*p->last || *p->last != '-') return 2;
+ if(!p->last[1]) die("Invalid option '-'.\n");
+ if(p->last[1] == '-' && !p->last[2]) { /* '--' argument separator */
+ p->argsep = 1;
+ return argparser_next(p);
+ }
+ if(p->last[1] == '-') { /* long option */
+ p->last_arg = strchr(p->last, '=');
+ if(p->last_arg) {
+ *p->last_arg = 0;
+ p->last_arg++;
+ }
+ return 1;
+ }
+ /* otherwise: short option */
+ return argparser_shortopt(p, p->last+1);
+}
- uic_theme = getenv("NO_COLOR") ? 0 : 2;
+static char *argparser_arg(struct argparser *p) {
+ char *tmp;
+ if(p->shortopt) {
+ tmp = p->shortopt;
+ p->shortopt = NULL;
+ return tmp;
+ }
+ if(p->last_arg) {
+ tmp = p->last_arg;
+ p->last_arg = NULL;
+ return tmp;
+ }
+ tmp = argparser_pop(p);
+ if(!tmp) die("Option '%s' requires an argument.\n", p->last);
+ return tmp;
+}
- dir_ui = -1;
- si = 0;
+#define OPT(_s) (strcmp(argparser_state.last, (_s)) == 0)
+#define ARG (argparser_arg(&argparser_state))
+
+static int arg_option(void) {
+ char *arg, *tmp;
+ if(OPT("-q") || OPT("--slow-ui-updates")) update_delay = 2000;
+ else if(OPT("--fast-ui-updates")) update_delay = 100;
+ else if(OPT("-x") || OPT("--one-file-system")) dir_scan_smfs = 1;
+ else if(OPT("--cross-file-system")) dir_scan_smfs = 0;
+ else if(OPT("-e") || OPT("--extended")) extended_info = 1;
+ else if(OPT("--no-extended")) extended_info = 0;
+ else if(OPT("-r") && !can_delete) can_shell = 0;
+ else if(OPT("-r")) can_delete = 0;
+ else if(OPT("--enable-shell")) can_shell = 1;
+ else if(OPT("--disable-shell")) can_shell = 0;
+ else if(OPT("--enable-delete")) can_delete = 1;
+ else if(OPT("--disable-delete")) can_delete = 0;
+ else if(OPT("--enable-refresh")) can_refresh = 1;
+ else if(OPT("--disable-refresh")) can_refresh = 0;
+ else if(OPT("--show-hidden")) dirlist_hidden = 0;
+ else if(OPT("--hide-hidden")) dirlist_hidden = 1;
+ else if(OPT("--show-itemcount")) show_items = 1;
+ else if(OPT("--hide-itemcount")) show_items = 0;
+ else if(OPT("--show-mtime")) show_mtime = 1;
+ else if(OPT("--hide-mtime")) show_mtime = 0;
+ else if(OPT("--show-graph")) graph |= 1;
+ else if(OPT("--hide-graph")) graph &= 2;
+ else if(OPT("--show-percent")) graph |= 2;
+ else if(OPT("--hide-percent")) graph &= 1;
+ else if(OPT("--group-directories-first")) dirlist_sort_df = 1;
+ else if(OPT("--no-group-directories-first")) dirlist_sort_df = 0;
+ else if(OPT("--sort")) {
+ arg = ARG;
+ tmp = strrchr(arg, '-');
+ if(tmp && (strcmp(tmp, "-asc") == 0 || strcmp(tmp, "-desc") == 0)) *tmp = 0;
+
+ if(strcmp(arg, "name") == 0) {
+ dirlist_sort_col = DL_COL_NAME;
+ dirlist_sort_desc = 0;
+ } else if(strcmp(arg, "disk-usage") == 0) {
+ dirlist_sort_col = DL_COL_SIZE;
+ dirlist_sort_desc = 1;
+ } else if(strcmp(arg, "apparent-size") == 0) {
+ dirlist_sort_col = DL_COL_ASIZE;
+ dirlist_sort_desc = 1;
+ } else if(strcmp(arg, "itemcount") == 0) {
+ dirlist_sort_col = DL_COL_ITEMS;
+ dirlist_sort_desc = 1;
+ } else if(strcmp(arg, "mtime") == 0) {
+ dirlist_sort_col = DL_COL_MTIME;
+ dirlist_sort_desc = 0;
+ } else die("Invalid argument to --sort: '%s'.\n", arg);
+
+ if(tmp && !*tmp) dirlist_sort_desc = tmp[1] == 'd';
+ } else if(OPT("--apparent-size")) show_as = 1;
+ else if(OPT("--disk-usage")) show_as = 0;
+ else if(OPT("-0")) dir_ui = 0;
+ else if(OPT("-1")) dir_ui = 1;
+ else if(OPT("-2")) dir_ui = 2;
+ else if(OPT("--si")) si = 1;
+ else if(OPT("--no-si")) si = 0;
+ else if(OPT("-L") || OPT("--follow-symlinks")) follow_symlinks = 1;
+ else if(OPT("--no-follow-symlinks")) follow_symlinks = 0;
+ else if(OPT("--exclude")) exclude_add(ARG);
+ else if(OPT("-X") || OPT("--exclude-form")) {
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/quit.c
^
|
@@ -38,13 +38,13 @@
return 0;
}
-void quit_draw() {
+void quit_draw(void) {
browse_draw();
nccreate(4,30, "ncdu confirm quit");
ncaddstr(2,2, "Really quit? (y/N)");
}
-void quit_init() {
+void quit_init(void) {
pstate = ST_QUIT;
}
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/shell.c
^
|
@@ -51,7 +51,7 @@
done++;
}
-void shell_draw() {
+void shell_draw(void) {
const char *full_path;
int res;
@@ -95,6 +95,6 @@
pstate = ST_BROWSE;
}
-void shell_init() {
+void shell_init(void) {
pstate = ST_SHELL;
}
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/util.c
^
|
@@ -37,10 +37,18 @@
int uic_theme;
int winrows, wincols;
int subwinr, subwinc;
-int si;
static char thou_sep;
+void die(const char *fmt, ...) {
+ va_list arg;
+ va_start(arg, fmt);
+ vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ exit(1);
+}
+
+
char *cropstr(const char *from, int s) {
static char dat[4096];
int i, j, o = strlen(from);
@@ -146,7 +154,7 @@
}
-void read_locale() {
+void read_locale(void) {
#ifdef HAVE_LOCALE_H
char *locale_thou_sep;
#endif
@@ -267,7 +275,7 @@
{0,0,0}
};
-void uic_init() {
+void uic_init(void) {
size_t i, j;
start_color();
@@ -441,3 +449,9 @@
void *xmalloc(size_t size) { wrap_oom(malloc(size)) }
void *xcalloc(size_t n, size_t size) { wrap_oom(calloc(n, size)) }
void *xrealloc(void *mem, size_t size) { wrap_oom(realloc(mem, size)) }
+
+char *xstrdup(const char *str) {
+ char *r = xmalloc(strlen(str)+1);
+ strcpy(r, str);
+ return r;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu-1.18+git2.tar.gz/upstream/src/util.h
^
|
@@ -30,6 +30,9 @@
#include <ncurses.h>
+void die(const char *, ...);
+
+
/* UI colors: (foreground, background, attrs)
* NAME OFF DARK DARK-BG */
#define UI_COLORS \
@@ -185,5 +188,7 @@
void *xcalloc(size_t, size_t);
void *xrealloc(void *, size_t);
+char *xstrdup(const char *);
+
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:ncdu.yaml
^
|
@@ -1,7 +1,7 @@
Name: ncdu
Summary: NCurses Disk Usage
# Careful: 2.x versions are written in zig, not C.
-Version: 1.17
+Version: 1.18
Release: 0
Group: Applications
URL: https://dev.yorhel.nl/ncdu
@@ -16,11 +16,11 @@
and provides a fast way to see what directories are using your disk space.
%if "%{?vendor}" == "chum"
+ PackageName: ncdu
Type: console-application
PackagerName: nephros
Categories:
- Utility
- - ConsoleOnly
Custom:
Repo: https://g.blicky.net/ncdu.git
PackagingRepo: https://github.com/sailfishos-chum/ncdu
|