aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 34c25589d4..22b243957c 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -348,6 +348,7 @@ void ex_sort(exarg_T *eap)
long deleted;
colnr_T start_col;
colnr_T end_col;
+ int sort_bin; /* sort on bin number */
int sort_oct; /* sort on octal number */
int sort_hex; /* sort on hex number */
@@ -362,7 +363,7 @@ void ex_sort(exarg_T *eap)
regmatch.regprog = NULL;
sorti_T *nrs = xmalloc(count * sizeof(sorti_T));
- sort_abort = sort_ic = sort_rx = sort_nr = sort_oct = sort_hex = 0;
+ sort_abort = sort_ic = sort_rx = sort_nr = sort_bin = sort_oct = sort_hex = 0;
for (p = eap->arg; *p != NUL; ++p) {
if (ascii_iswhite(*p))
@@ -373,6 +374,8 @@ void ex_sort(exarg_T *eap)
sort_rx = TRUE;
else if (*p == 'n')
sort_nr = 2;
+ else if (*p == 'b')
+ sort_bin = 2;
else if (*p == 'o')
sort_oct = 2;
else if (*p == 'x')
@@ -410,14 +413,14 @@ void ex_sort(exarg_T *eap)
}
}
- /* Can only have one of 'n', 'o' and 'x'. */
- if (sort_nr + sort_oct + sort_hex > 2) {
+ /* Can only have one of 'n', 'b', 'o' and 'x'. */
+ if (sort_nr + sort_bin + sort_oct + sort_hex > 2) {
EMSG(_(e_invarg));
goto sortend;
}
/* From here on "sort_nr" is used as a flag for any number sorting. */
- sort_nr += sort_oct + sort_hex;
+ sort_nr += sort_bin + sort_oct + sort_hex;
/*
* Make an array with all line numbers. This avoids having to copy all
@@ -454,6 +457,8 @@ void ex_sort(exarg_T *eap)
p = s + start_col;
if (sort_hex)
s = skiptohex(p);
+ else if (sort_bin)
+ s = skiptobin(p);
else
s = skiptodigit(p);
if (s > p && s[-1] == '-')
@@ -462,7 +467,7 @@ void ex_sort(exarg_T *eap)
/* empty line should sort before any number */
nrs[lnum - eap->line1].start_col_nr = -MAXLNUM;
else
- vim_str2nr(s, NULL, NULL, sort_oct, sort_hex,
+ vim_str2nr(s, NULL, NULL, sort_bin, sort_oct, sort_hex,
&nrs[lnum - eap->line1].start_col_nr, NULL);
*s2 = c;
} else {