1
0

clarify str(1) behavior

This commit is contained in:
dtb 2022-10-23 01:57:45 -04:00
parent 1f9786233d
commit c1f1794863
3 changed files with 8 additions and 7 deletions

View File

@ -1,4 +0,0 @@
all: ;
clean: ;
sane: ;
.PHONY: all clean sane

View File

@ -18,6 +18,8 @@ Str tests each character in an arbitrary quantity of string arguments against th
Str exits successfully if all tests pass and unsuccessfully if a test failed. Str exits successfully if all tests pass and unsuccessfully if a test failed.
.PP .PP
Str will exit unsuccessfully if a string is empty, as none of its contents passed the test.
.PP
Str will print a message to standard error and exit unsuccessfully if used improperly. Str will print a message to standard error and exit unsuccessfully if used improperly.
.SH BUGS .SH BUGS

View File

@ -31,6 +31,7 @@ static struct {
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
int ctype; int ctype;
int i; int i;
int r;
if(argc < 3){ if(argc < 3){
usage: fprintf(stderr, "Usage: %s [type] [string...]\n", usage: fprintf(stderr, "Usage: %s [type] [string...]\n",
@ -44,10 +45,12 @@ usage: fprintf(stderr, "Usage: %s [type] [string...]\n",
goto pass; goto pass;
goto usage; goto usage;
pass: for(argv += 2; *argv != NULL; ++argv) pass: for(argv += 2, r = 1; *argv != NULL; ++argv)
for(i = 0; argv[0][i] != '\0'; ++i) for(i = 0; argv[0][i] != '\0'; ++i)
if(!ctypes[ctype].f(argv[0][i])) if(!ctypes[ctype].f(argv[0][i]))
return 1; return 1;
else
r = 0;
return 0; return r;
} }