str(1): formatting
This commit is contained in:
parent
49031102f2
commit
3c243e4a09
28
src/str.c
28
src/str.c
@ -50,26 +50,32 @@ int main(int argc, char *argv[]){
|
||||
int r;
|
||||
|
||||
if (argc >= 3) {
|
||||
for(ctype = 0; ctype < (sizeof ctypes) / (sizeof *ctypes);
|
||||
++ctype)
|
||||
if(strcmp(argv[1], ctypes[ctype].name) == 0)
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user