mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
look: fix case sensitivity when using base > 10
Old attempt at this did not make any sense. Also fix the reference to look in ascii(1) to be more correct.
This commit is contained in:
parent
dc318a6471
commit
f3f659b54b
2 changed files with 8 additions and 5 deletions
|
@ -35,6 +35,10 @@ ascii, unicode \- interpret ASCII, Unicode characters
|
|||
.I characters
|
||||
.PP
|
||||
.B look
|
||||
.B -t
|
||||
.I ';'
|
||||
.B -b
|
||||
.I 16
|
||||
.I hex
|
||||
.B /lib/ucd/UnicodeData.txt
|
||||
.SH DESCRIPTION
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define tolower(r) ((r)-'A'+'a')
|
||||
|
||||
#define sgn(v) ((v) < 0 ? -1 : ((v) > 0 ? 1 : 0))
|
||||
#define notcase(v) (v != L'a'-L'A' && v != L'A'-L'a')
|
||||
|
||||
#define WORDSIZ 4000
|
||||
char *filename = "/lib/words";
|
||||
|
@ -86,6 +85,8 @@ main(int argc, char *argv[])
|
|||
ARGBEGIN{
|
||||
case 'b':
|
||||
base = atoi(EARGF(usage()));
|
||||
if(base > 10)
|
||||
fold++;
|
||||
compare = ncomp;
|
||||
break;
|
||||
case 'd':
|
||||
|
@ -305,7 +306,7 @@ ncomp(Rune *s, Rune *t)
|
|||
a = 0;
|
||||
if(ssgn == tsgn)
|
||||
while(it>t && is>s)
|
||||
if((b = *--it - *--is) && notcase(b))
|
||||
if(b = *--it - *--is)
|
||||
a = b;
|
||||
while(is > s)
|
||||
if(*--is != '0')
|
||||
|
@ -321,7 +322,7 @@ ncomp(Rune *s, Rune *t)
|
|||
t++;
|
||||
if(ssgn == tsgn)
|
||||
while(isdigit(*s) && isdigit(*t))
|
||||
if((a = *t++ - *s++) && notcase(a))
|
||||
if(a = *t++ - *s++)
|
||||
return sgn(a)*ssgn;
|
||||
while(isdigit(*s))
|
||||
if(*s++ != '0')
|
||||
|
@ -361,8 +362,6 @@ isdigit(Rune r)
|
|||
v = r - L'0';
|
||||
else if(L'a'<=r && r<=L'z')
|
||||
v = r - L'a' + 10;
|
||||
else if(L'A'<=r && r<=L'Z')
|
||||
v = r - L'A' + 10;
|
||||
if(v < base)
|
||||
return 1;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue