diff options
| author | watiko <service@mail.watiko.net> | 2016-01-15 15:06:12 +0900 | 
|---|---|---|
| committer | watiko <service@mail.watiko.net> | 2016-02-01 03:47:08 +0900 | 
| commit | a5f361e470c816ec9258fb815befafdef52b000b (patch) | |
| tree | c35c74316b7a4f1a6aa486d41eaf9fae3b122f45 /src/nvim/ex_cmds.c | |
| parent | 7fc996abf6151364ec045607a6e1ab51e32920e5 (diff) | |
| download | rneovim-a5f361e470c816ec9258fb815befafdef52b000b.tar.gz rneovim-a5f361e470c816ec9258fb815befafdef52b000b.tar.bz2 rneovim-a5f361e470c816ec9258fb815befafdef52b000b.zip | |
vim-patch:7.4.1027
Problem:    No support for binary numbers.
Solution:   Add "bin" to nrformats. (Jason Schulz)
https://github.com/vim/vim/commit/887c1fea4a114e7170091942d0446c8882701b5b
Diffstat (limited to 'src/nvim/ex_cmds.c')
| -rw-r--r-- | src/nvim/ex_cmds.c | 35 | 
1 files changed, 20 insertions, 15 deletions
| diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 5cabb9b820..a517037431 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -342,27 +342,27 @@ void ex_sort(exarg_T *eap)    char_u      *s;    char_u      *s2;    char_u c;                             // temporary character storage -  int unique = false; +  bool unique = false;    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 +  int sort_what = 0;    // Sorting one line is really quick!    if (count <= 1) {      return;    } -  if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL) +  if (u_save((linenr_T)(eap->line1 - 1), (linenr_T)(eap->line2 + 1)) == FAIL) {      return; +  }    sortbuf1 = NULL;    sortbuf2 = NULL;    regmatch.regprog = NULL;    sorti_T *nrs = xmalloc(count * sizeof(sorti_T)); -  sort_abort = sort_ic = sort_rx = sort_nr = sort_bin = sort_oct = sort_hex = 0; +  sort_abort = sort_ic = sort_rx = sort_nr = 0; +  size_t format_found = 0;    for (p = eap->arg; *p != NUL; ++p) {      if (ascii_iswhite(*p)) { @@ -372,12 +372,16 @@ void ex_sort(exarg_T *eap)        sort_rx = true;      } else if (*p == 'n') {        sort_nr = 2; +      format_found++;      } else if (*p == 'b') { -      sort_bin = 2; +      sort_what = STR2NR_BIN + STR2NR_FORCE; +      format_found++;      } else if (*p == 'o') { -      sort_oct = 2; +      sort_what = STR2NR_OCT + STR2NR_FORCE; +      format_found++;      } else if (*p == 'x') { -      sort_hex = 2; +      sort_what = STR2NR_HEX + STR2NR_FORCE; +      format_found++;      } else if (*p == 'u') {        unique = true;      } else if (*p == '"') { @@ -415,13 +419,13 @@ void ex_sort(exarg_T *eap)    }    // Can only have one of 'n', 'b', 'o' and 'x'. -  if (sort_nr + sort_bin + sort_oct + sort_hex > 2) { +  if (format_found > 1) {      EMSG(_(e_invarg));      goto sortend;    }    // From here on "sort_nr" is used as a flag for any number sorting. -  sort_nr += sort_bin + sort_oct + sort_hex; +  sort_nr += sort_what;    // Make an array with all line numbers.  This avoids having to copy all    // the lines into allocated memory. @@ -457,21 +461,22 @@ void ex_sort(exarg_T *eap)        *s2 = NUL;        // Sorting on number: Store the number itself.        p = s + start_col; -      if (sort_hex) { +      if (sort_what & STR2NR_HEX) {          s = skiptohex(p); -      } else if (sort_bin) { +      } else if (sort_what & STR2NR_BIN) {          s = (char_u*) skiptobin((char*) p);        } else {          s = skiptodigit(p);        }        if (s > p && s[-1] == '-') { -        --s;          // include preceding negative sign +        // include preceding negative sign +        s--;        }        if (*s == NUL) {          // empty line should sort before any number          nrs[lnum - eap->line1].start_col_nr = -MAXLNUM;        } else { -        vim_str2nr(s, NULL, NULL, sort_bin, sort_oct, sort_hex, +        vim_str2nr(s, NULL, NULL, sort_what,                     &nrs[lnum - eap->line1].start_col_nr, NULL, 0);        }        *s2 = c; | 
