diff --git a/src/str.c b/src/str.c index b4725eb..73bb911 100644 --- a/src/str.c +++ b/src/str.c @@ -29,7 +29,7 @@ static char *program_name = "str"; static struct { char *name; int (*f)(int); -}ctypes[] = { +} ctypes[] = { { "isalnum", isalnum }, { "isalpha", isalpha }, { "isblank", isblank }, @@ -49,27 +49,33 @@ int main(int argc, char *argv[]){ int i; int r; - if(argc >= 3){ - for(ctype = 0; ctype < (sizeof ctypes) / (sizeof *ctypes); - ++ctype) - if(strcmp(argv[1], ctypes[ctype].name) == 0) + if (argc >= 3) { + for (ctype = 0; ctype < (sizeof ctypes) / (sizeof *ctypes); ++ctype) { + if(strcmp(argv[1], ctypes[ctype].name) == 0) { goto pass; + } + } } - fprintf(stderr, "Usage: %s type string...\n", - argv[0] == NULL ? program_name : argv[0]); + fprintf( + stderr, + "Usage: %s type string...\n", + argv[0] == NULL ? program_name : argv[0] + ); return EX_USAGE; -pass: for(argv += 2, r = 1; *argv != NULL; ++argv) - for(i = 0; argv[0][i] != '\0'; ++i) +pass: for (argv += 2, r = 1; *argv != NULL; ++argv) { + for (i = 0; argv[0][i] != '\0'; ++i) { /* First checks if argv[0][i] is valid ASCII; ctypes(3) * don't handle non-ASCII. * This is bad. */ - if((unsigned char)argv[0][i] < 0x80 && !ctypes[ctype].f(argv[0][i])) - return 1; - else - r = 0; + if( + (unsigned char)argv[0][i] < 0x80 && !ctypes[ctype].f(argv[0][i]) + ) { return 1; } + else { r = 0; } + } + } return r; }