diff options
author | Jason Schulz <jason@schulz.name> | 2015-12-29 15:17:16 -0800 |
---|---|---|
committer | Jason Schulz <jason@schulz.name> | 2016-01-15 18:21:06 -0800 |
commit | 7ad3f077dc68a83b2cdfb7b1d04de9266d7978a9 (patch) | |
tree | aaa485d0853be6b46865cf2d87064ec0299f0cde /src/nvim/ex_cmds.c | |
parent | dddbf9c5fa061cb03d6b6240ac6610b68b9304f5 (diff) | |
download | rneovim-7ad3f077dc68a83b2cdfb7b1d04de9266d7978a9.tar.gz rneovim-7ad3f077dc68a83b2cdfb7b1d04de9266d7978a9.tar.bz2 rneovim-7ad3f077dc68a83b2cdfb7b1d04de9266d7978a9.zip |
Add support for binary numbers
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 15 |
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 { |