light cleaning
This commit is contained in:
parent
d99ecf1094
commit
24a3de9d6a
22
src/str.c
22
src/str.c
@ -27,8 +27,8 @@ static struct {
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int ctype;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if(argc < 3){
|
||||
error: write(2, "Usage: ", 7);
|
||||
@ -39,21 +39,17 @@ error: write(2, "Usage: ", 7);
|
||||
|
||||
/* We could skip checking the first two characters and replace it with
|
||||
* a single if(argv[1][0] == 'i' && argv[1][1] == 's') or something
|
||||
* but it's simpler to just waste the cycles. */
|
||||
* but it's simpler to just waste the cycles. Plus this doesn't assume
|
||||
* every ctype starts with "is". */
|
||||
|
||||
/* slow but for our purposes this is fine */
|
||||
for(i = 0; i < ARRAYLEN(ctypes); ++i)
|
||||
if(strcmp(argv[1], ctypes[i].name) == 0){
|
||||
i *= -1;
|
||||
break;
|
||||
}
|
||||
if(i > 0)
|
||||
for(ctype = 0; ctype < ARRAYLEN(ctypes); ++ctype)
|
||||
if(strcmp(argv[1], ctypes[ctype].name) == 0)
|
||||
goto pass;
|
||||
goto error;
|
||||
i *= -1;
|
||||
|
||||
for(argv += 2; *argv != NULL; ++argv)
|
||||
for(j = 0; argv[0][j] != '\0'; ++j)
|
||||
if(!ctypes[i].f(argv[0][j]))
|
||||
pass: for(argv += 2; *argv != NULL; ++argv)
|
||||
for(i = 0; argv[0][i] != '\0'; ++i)
|
||||
if(!ctypes[ctype].f(argv[0][i]))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user