Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nccf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
702
Provoz
nccf
Commits
b93acabd
Commit
b93acabd
authored
2 years ago
by
Yorhel
Browse files
Options
Downloads
Patches
Plain Diff
Add --(enable|disable)-natsort options
Backport of zig/
46b88bcb
parent
960661e9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/ncdu.pod
+4
-0
4 additions, 0 deletions
doc/ncdu.pod
src/dirlist.c
+3
-2
3 additions, 2 deletions
src/dirlist.c
src/dirlist.h
+2
-0
2 additions, 0 deletions
src/dirlist.h
src/main.c
+2
-0
2 additions, 0 deletions
src/main.c
with
11 additions
and
2 deletions
doc/ncdu.pod
+
4
−
0
View file @
b93acabd
...
@@ -238,6 +238,10 @@ The column can be suffixed with I<-asc> or I<-desc> to set the order to
...
@@ -238,6 +238,10 @@ The column can be suffixed with I<-asc> or I<-desc> to set the order to
ascending or descending, respectively. e.g. C<--sort=name-desc> will sort by
ascending or descending, respectively. e.g. C<--sort=name-desc> will sort by
name in descending order.
name in descending order.
=item B<--enable-natsort>, B<--disable-natsort>
Enable (default) or disable natural sort when sorting by file name.
=item B<--group-directories-first>, B<--no-group-directories-first>
=item B<--group-directories-first>, B<--no-group-directories-first>
Sort (or not) directories before files.
Sort (or not) directories before files.
...
...
This diff is collapsed.
Click to expand it.
src/dirlist.c
+
3
−
2
View file @
b93acabd
...
@@ -39,7 +39,8 @@ int64_t dirlist_maxs = 0,
...
@@ -39,7 +39,8 @@ int64_t dirlist_maxs = 0,
int
dirlist_sort_desc
=
1
,
int
dirlist_sort_desc
=
1
,
dirlist_sort_col
=
DL_COL_SIZE
,
dirlist_sort_col
=
DL_COL_SIZE
,
dirlist_sort_df
=
0
,
dirlist_sort_df
=
0
,
dirlist_hidden
=
0
;
dirlist_hidden
=
0
,
dirlist_natsort
=
1
;
/* private state vars */
/* private state vars */
static
struct
dir
*
parent_alloc
,
*
head
,
*
head_real
,
*
selected
,
*
top
=
NULL
;
static
struct
dir
*
parent_alloc
,
*
head
,
*
head_real
,
*
selected
,
*
top
=
NULL
;
...
@@ -80,7 +81,7 @@ static int dirlist_cmp(struct dir *x, struct dir *y) {
...
@@ -80,7 +81,7 @@ static int dirlist_cmp(struct dir *x, struct dir *y) {
*
*
* Note that the method used below is supposed to be fast, not readable :-)
* Note that the method used below is supposed to be fast, not readable :-)
*/
*/
#define CMP_NAME strnatcmp(x->name, y->name)
#define CMP_NAME
(dirlist_natsort ?
strnatcmp(x->name, y->name)
: strcmp(x->name, y->name))
#define CMP_SIZE (x->size > y->size ? 1 : (x->size == y->size ? 0 : -1))
#define CMP_SIZE (x->size > y->size ? 1 : (x->size == y->size ? 0 : -1))
#define CMP_ASIZE (x->asize > y->asize ? 1 : (x->asize == y->asize ? 0 : -1))
#define CMP_ASIZE (x->asize > y->asize ? 1 : (x->asize == y->asize ? 0 : -1))
#define CMP_ITEMS (x->items > y->items ? 1 : (x->items == y->items ? 0 : -1))
#define CMP_ITEMS (x->items > y->items ? 1 : (x->items == y->items ? 0 : -1))
...
...
This diff is collapsed.
Click to expand it.
src/dirlist.h
+
2
−
0
View file @
b93acabd
...
@@ -78,6 +78,8 @@ extern int dirlist_sort_desc, dirlist_sort_col, dirlist_sort_df;
...
@@ -78,6 +78,8 @@ extern int dirlist_sort_desc, dirlist_sort_col, dirlist_sort_df;
/* set with dirlist_set_hidden() */
/* set with dirlist_set_hidden() */
extern
int
dirlist_hidden
;
extern
int
dirlist_hidden
;
extern
int
dirlist_natsort
;
/* maximum size of an item in the opened dir */
/* maximum size of an item in the opened dir */
extern
int64_t
dirlist_maxs
,
dirlist_maxa
;
extern
int64_t
dirlist_maxs
,
dirlist_maxa
;
...
...
This diff is collapsed.
Click to expand it.
src/main.c
+
2
−
0
View file @
b93acabd
...
@@ -219,6 +219,8 @@ static int arg_option(void) {
...
@@ -219,6 +219,8 @@ static int arg_option(void) {
else
if
(
OPT
(
"--hide-percent"
))
graph
&=
1
;
else
if
(
OPT
(
"--hide-percent"
))
graph
&=
1
;
else
if
(
OPT
(
"--group-directories-first"
))
dirlist_sort_df
=
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
(
"--no-group-directories-first"
))
dirlist_sort_df
=
0
;
else
if
(
OPT
(
"--enable-natsort"
))
dirlist_natsort
=
1
;
else
if
(
OPT
(
"--disable-natsort"
))
dirlist_natsort
=
0
;
else
if
(
OPT
(
"--sort"
))
{
else
if
(
OPT
(
"--sort"
))
{
arg
=
ARG
;
arg
=
ARG
;
tmp
=
strrchr
(
arg
,
'-'
);
tmp
=
strrchr
(
arg
,
'-'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment