0
0
mirror of https://github.com/vim/vim.git synced 2025-10-12 06:44:06 -04:00

patch 7.4.1027

Problem:    No support for binary numbers.
Solution:   Add "bin" to nrformats. (Jason Schulz)
This commit is contained in:
Bram Moolenaar
2016-01-02 17:56:35 +01:00
parent acf92d27c9
commit 887c1fea4a
19 changed files with 489 additions and 79 deletions

View File

@@ -365,8 +365,8 @@ ex_sort(eap)
long deleted;
colnr_T start_col;
colnr_T end_col;
int sort_oct; /* sort on octal number */
int sort_hex; /* sort on hex number */
int sort_what = 0;
int format_found = 0;
/* Sorting one line is really quick! */
if (count <= 1)
@@ -381,7 +381,7 @@ ex_sort(eap)
if (nrs == NULL)
goto sortend;
sort_abort = sort_ic = sort_rx = sort_nr = sort_oct = sort_hex = 0;
sort_abort = sort_ic = sort_rx = sort_nr = 0;
for (p = eap->arg; *p != NUL; ++p)
{
@@ -392,11 +392,25 @@ ex_sort(eap)
else if (*p == 'r')
sort_rx = TRUE;
else if (*p == 'n')
{
sort_nr = 2;
++format_found;
}
else if (*p == 'b')
{
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 == '"') /* comment start */
@@ -439,15 +453,15 @@ ex_sort(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 (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_oct + sort_hex;
sort_nr += sort_what;
/*
* Make an array with all line numbers. This avoids having to copy all
@@ -489,8 +503,10 @@ ex_sort(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_what & STR2NR_BIN)
s = skiptobin(p);
else
s = skiptodigit(p);
if (s > p && s[-1] == '-')
@@ -499,8 +515,8 @@ ex_sort(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,
&nrs[lnum - eap->line1].start_col_nr, NULL, 0);
vim_str2nr(s, NULL, NULL, sort_what,
&nrs[lnum - eap->line1].start_col_nr, NULL, 0);
*s2 = c;
}
else