-u triggers setvbuf with _IONBF
This commit is contained in:
parent
57d260971d
commit
0fa85040b3
1 changed files with 7 additions and 12 deletions
15
cat.c
15
cat.c
|
@ -18,16 +18,16 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
if(using_unbuffered_output) {
|
||||
setvbuf(stdin, NULL, _IONBF, 15);
|
||||
setvbuf(stdout, NULL, _IONBF, 15);
|
||||
}
|
||||
|
||||
if(argc == 1 || optind == argc) {
|
||||
cur_in_file = stdin;
|
||||
for(c = fgetc(cur_in_file); c != EOF; c = fgetc(cur_in_file)) {
|
||||
if(using_unbuffered_output) {
|
||||
write(1, &c, 1);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%c", c);
|
||||
}
|
||||
}
|
||||
fclose(cur_in_file);
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,8 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
for(c = fgetc(cur_in_file); c != EOF; c = fgetc(cur_in_file)) {
|
||||
if(using_unbuffered_output) {
|
||||
write(1, &c, 1);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%c", c);
|
||||
}
|
||||
}
|
||||
fclose(cur_in_file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue