Browse Source

In case the file open failed we have no need to set the IO buffer size.

And this should also not be done with a NULL pointer into setvbuf.
pre-master-46
dwarning 8 years ago
committed by Holger Vogt
parent
commit
f0f19f87a3
  1. 3
      src/frontend/runcoms.c
  2. 7
      src/frontend/runcoms2.c

3
src/frontend/runcoms.c

@ -282,12 +282,11 @@ dosim(
/*---------------------------------------------------------------------------*/
#else
else if (!(rawfileFp = fopen(wl->wl_word, "w"))) {
rawfileFp = stdout; /* If fopen has failed, we have to proceed with stdout */
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;
}
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
#endif /* __MINGW32__ */
rawfileBinary = !ascii;
} else {

7
src/frontend/runcoms2.c

@ -110,28 +110,27 @@ com_resume(wordlist *wl)
/* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */
else if (ascii) {
if ((rawfileFp = fopen(last_used_rawfile, "a")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
} else if (!ascii) {
if ((rawfileFp = fopen(last_used_rawfile, "ab")) == NULL) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
}
/*---------------------------------------------------------------------------*/
#else
else if (!(rawfileFp = fopen(last_used_rawfile, "a"))) {
rawfileFp = stdout; /* If fopen has failed, we have to proceed with stdout */
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(last_used_rawfile);
ft_setflag = FALSE;
return;
}
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
#endif
rawfileBinary = !ascii;
} else {

Loading…
Cancel
Save