Mercurial > hg > octave-lojdl
changeset 13958:cb15c5185b6a
mkstemp: open file in binary mode (bug #33669)
* file-io.cc (Fmkstemp): Use mkostemp to open temp file using O_BINARY
option. Add "b" to fopen_mode in call to fdopen. #include <fcntl.h>
for definition of O_BINARY.
* bootstrap.conf (gnulib_modules): Include mkostemp in the list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 29 Nov 2011 04:42:16 -0500 |
parents | c510048901cc |
children | cf8cd43cdeb3 |
files | build-aux/bootstrap.conf src/file-io.cc |
diffstat | 2 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/build-aux/bootstrap.conf +++ b/build-aux/bootstrap.conf @@ -40,6 +40,7 @@ lstat mkdir mkfifo + mkostemp mkstemp mktime nanosleep
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -46,6 +46,7 @@ #include <stack> #include <vector> +#include <fcntl.h> #include <sys/types.h> #include <unistd.h> @@ -1981,7 +1982,7 @@ filename unique. The file is then created with mode read/write and\n\ permissions that are system dependent (on GNU/Linux systems, the permissions\n\ will be 0600 for versions of glibc 2.0.7 and later). The file is opened\n\ -with the @w{@code{O_EXCL}} flag.\n\ +in binary mode and with the @w{@code{O_EXCL}} flag.\n\ \n\ If the optional argument @var{delete} is supplied and is true,\n\ the file will be deleted automatically when Octave exits, or when\n\ @@ -2011,7 +2012,7 @@ OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1); strcpy (tmp, tmpl8.c_str ()); - int fd = gnulib::mkstemp (tmp); + int fd = gnulib::mkostemp (tmp, O_BINARY); if (fd < 0) { @@ -2020,7 +2021,7 @@ } else { - const char *fopen_mode = "w+"; + const char *fopen_mode = "w+b"; FILE *fid = fdopen (fd, fopen_mode);