1
0

light cleaning

This commit is contained in:
dtb 2022-08-22 16:04:36 -04:00
parent d99ecf1094
commit 24a3de9d6a

View File

@ -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)
goto error;
i *= -1;
for(ctype = 0; ctype < ARRAYLEN(ctypes); ++ctype)
if(strcmp(argv[1], ctypes[ctype].name) == 0)
goto pass;
goto error;
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;