1
0

return nonzero if any writes failed

This commit is contained in:
dtb 2024-01-15 14:24:44 -07:00
parent 9bc77a8ec4
commit d46a6aac3c

12
mm/mm.c
View File

@ -244,12 +244,10 @@ usage(char *s){
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
int c; int c;
FILE *f;
size_t i; size_t i;
struct Io io[2]; /* {read, write, error} */ struct Io io[2]; /* {read, write, error} */
struct Io_ex io_ex[2]; struct Io_ex io_ex[2];
FILE *lf; int o;
char *ln;
char unbuffered; char unbuffered;
if(argc < 2){ /* simple invocation */ if(argc < 2){ /* simple invocation */
@ -323,18 +321,18 @@ int main(int argc, char *argv[]){
io[0].s = 1; io[0].s = 1;
if(io[1].s == -1) if(io[1].s == -1)
io[1].s = 1; io[1].s = 1;
o = io[1].s;
lf = NULL;
for(i = 0; i < io[0].s; ++i){ for(i = 0; i < io[0].s; ++i){
while((c = getc(io[0].files[i])) != EOF) while((c = getc(io[0].files[i])) != EOF)
if(Io_fputc(&io[1], c) == EOF){ /* notebook's full */ if(Io_fputc(&io[1], c) == EOF){ /* notebook's full */
terminate(io); terminate(io);
return EX_OK; return 1;
} }
} }
o = io[1].s == o;
terminate(io); terminate(io);
return EX_OK; return o;
} }