fix sort(1) bug where it incorrectly included the field separator in the comparison if it was >= Runeself
This commit is contained in:
parent
d8999511e0
commit
af0de5ada8
1 changed files with 9 additions and 6 deletions
|
@ -941,13 +941,14 @@ doargs(int argc, char *argv[])
|
||||||
uchar*
|
uchar*
|
||||||
skip(uchar *l, int n1, int n2, int bflag, int endfield)
|
skip(uchar *l, int n1, int n2, int bflag, int endfield)
|
||||||
{
|
{
|
||||||
int i, c, tc;
|
int i, c, ln, tc;
|
||||||
Rune r;
|
Rune r;
|
||||||
|
|
||||||
if(endfield && n1 < 0)
|
if(endfield && n1 < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
c = *l++;
|
c = *l++;
|
||||||
|
ln = 1;
|
||||||
tc = args.tabchar;
|
tc = args.tabchar;
|
||||||
if(tc) {
|
if(tc) {
|
||||||
if(tc < Runeself) {
|
if(tc < Runeself) {
|
||||||
|
@ -962,15 +963,15 @@ skip(uchar *l, int n1, int n2, int bflag, int endfield)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l--;
|
l--;
|
||||||
l += chartorune(&r, (char*)l);
|
l += ln = chartorune(&r, (char*)l);
|
||||||
for(i=n1; i>0; i--) {
|
for(i=n1; i>0; i--) {
|
||||||
while(r != tc) {
|
while(r != tc) {
|
||||||
if(r == '\n')
|
if(r == '\n')
|
||||||
return 0;
|
return 0;
|
||||||
l += chartorune(&r, (char*)l);
|
l += ln = chartorune(&r, (char*)l);
|
||||||
}
|
}
|
||||||
if(!(endfield && i == 1))
|
if(!(endfield && i == 1))
|
||||||
l += chartorune(&r, (char*)l);
|
l += ln = chartorune(&r, (char*)l);
|
||||||
}
|
}
|
||||||
c = r;
|
c = r;
|
||||||
}
|
}
|
||||||
|
@ -987,10 +988,12 @@ skip(uchar *l, int n1, int n2, int bflag, int endfield)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bflag)
|
if(bflag)
|
||||||
while(c == ' ' || c == '\t')
|
while(c == ' ' || c == '\t'){
|
||||||
c = *l++;
|
c = *l++;
|
||||||
|
ln = 1;
|
||||||
|
}
|
||||||
|
|
||||||
l--;
|
l -= ln;
|
||||||
for(i=n2; i>0; i--) {
|
for(i=n2; i>0; i--) {
|
||||||
c = *l;
|
c = *l;
|
||||||
if(c < Runeself) {
|
if(c < Runeself) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue