Mercurial > octave
changeset 21991:80659e58609f
provide wrapper for tmpfile (bug #48337)
* liboctave/wrappers/tmpfile-wrapper.h,
liboctave/wrappers/tmpfile-wrapper.c: New files.
* liboctave/wrappers/module.mk: Update.
* file-io.cc, gl2ps-print.cc: Use octave_tmpfile_wrapper instead of
std::tmpfile.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 29 Jun 2016 11:51:42 -0400 |
parents | efce657ceb86 |
children | 03c692adf563 |
files | libinterp/corefcn/file-io.cc libinterp/corefcn/gl2ps-print.cc liboctave/wrappers/module.mk liboctave/wrappers/tmpfile-wrapper.c liboctave/wrappers/tmpfile-wrapper.h |
diffstat | 5 files changed, 90 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/file-io.cc Wed Jun 29 08:50:09 2016 -0700 +++ b/libinterp/corefcn/file-io.cc Wed Jun 29 11:51:42 2016 -0400 @@ -58,6 +58,7 @@ #include "mkostemp-wrapper.h" #include "oct-env.h" #include "oct-locbuf.h" +#include "tmpfile-wrapper.h" #include "unistd-wrappers.h" #include "defun.h" @@ -2839,7 +2840,7 @@ octave_value_list retval; - FILE *fid = std::tmpfile (); + FILE *fid = octave_tmpfile_wrapper (); if (fid) {
--- a/libinterp/corefcn/gl2ps-print.cc Wed Jun 29 08:50:09 2016 -0700 +++ b/libinterp/corefcn/gl2ps-print.cc Wed Jun 29 11:51:42 2016 -0400 @@ -38,6 +38,7 @@ #include "lo-mappers.h" #include "oct-locbuf.h" +#include "tmpfile-wrapper.h" #include "unistd-wrappers.h" #include "unwind-prot.h" @@ -197,7 +198,7 @@ gl2ps_sort = GL2PS_SIMPLE_SORT; // Use a temporary file in case an overflow happens - FILE* tmpf = std::tmpfile (); + FILE* tmpf = octave_tmpfile_wrapper (); if (! tmpf) error ("gl2ps_renderer::draw: couldn't open temporary file for printing");
--- a/liboctave/wrappers/module.mk Wed Jun 29 08:50:09 2016 -0700 +++ b/liboctave/wrappers/module.mk Wed Jun 29 11:51:42 2016 -0400 @@ -22,6 +22,7 @@ liboctave/wrappers/strmode-wrapper.h \ liboctave/wrappers/strptime-wrapper.h \ liboctave/wrappers/time-wrappers.h \ + liboctave/wrappers/tmpfile-wrapper.h \ liboctave/wrappers/uname-wrapper.h \ liboctave/wrappers/unistd-wrappers.h \ liboctave/wrappers/unsetenv-wrapper.h \ @@ -53,6 +54,7 @@ liboctave/wrappers/strmode-wrapper.c \ liboctave/wrappers/strptime-wrapper.c \ liboctave/wrappers/time-wrappers.c \ + liboctave/wrappers/tmpfile-wrapper.c \ liboctave/wrappers/uname-wrapper.c \ liboctave/wrappers/unistd-wrappers.c \ liboctave/wrappers/unsetenv-wrapper.c \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/wrappers/tmpfile-wrapper.c Wed Jun 29 11:51:42 2016 -0400 @@ -0,0 +1,39 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +// tmpfile may be provided by gnulib. We don't include gnulib headers +// directly in Octave's C++ source files to avoid problems that may be +// caused by the way that gnulib overrides standard library functions. + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +#include <stdio.h> + +#include "tmpfile-wrapper.h" + +FILE * +octave_tmpfile_wrapper (void) +{ + return tmpfile (); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/liboctave/wrappers/tmpfile-wrapper.h Wed Jun 29 11:51:42 2016 -0400 @@ -0,0 +1,45 @@ +/* + +Copyright (C) 2016 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#if ! defined (octave_tmpfile_wrapper_h) +#define octave_tmpfile_wrapper_h 1 + +#if defined __cplusplus +# include <cstdio> +#else +# include <stdio.h> +#endif + +#if defined __cplusplus +extern "C" { +#endif + +// c++11 provides std::tmpfile but it appears to fail on 64-bit +// Windows systems. + +extern FILE *octave_tmpfile_wrapper (void); + +#if defined __cplusplus +} +#endif + +#endif