Mercurial > hg > octave-terminal
changeset 8792:bbb3fa6778f3
use mkstemps as replacement for mkstemp on mingw32
author | Benjamin Lindner <lindnerb@users.sourceforge.net> |
---|---|
date | Wed, 18 Feb 2009 00:55:32 -0500 |
parents | d943e26d30e2 |
children | 4c989d52f35c |
files | ChangeLog configure.in src/ChangeLog src/file-io.cc |
diffstat | 4 files changed, 42 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-17 Benjamin Lindner <lindnerb@users.sourceforge.net> + + * configure.in: Check for mkstemps on MinGW platform + (HAVE_MKSTEMPS): Define if mkstsmps is avilable in libiberty. + 2009-02-17 Jaroslav Hajek <highegg@gmail.com> * NEWS: Mention cummin and cummax
--- a/configure.in +++ b/configure.in @@ -1580,6 +1580,28 @@ _chmod _snprintf x_utime _utime32) case "$canonical_host_type" in + *-*-mingw*) + ## MinGW does not provide a mkstemp function. However, it provides + ## the mkstemps function in libiberty. + AC_MSG_CHECKING(for mkstemps in libiberty) + save_LIBS="$LIBS" + LIBS="-liberty $LIBS" + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[int mkstemps (char *pattern, int suffix_len);]], + [[mkstemps ("XXXXXX", 0);]] + )], + [AC_MSG_RESULT(yes) + HAVE_MKSTEMPS=yes + AC_DEFINE(HAVE_MKSTEMPS, 1, [Define if mkstemps is available in libiberty.]) + ], + [AC_MSG_RESULT(no) + HAVE_MKSTEMPS=no + LIBS="$save_LIBS" + ]) + ;; +esac + +case "$canonical_host_type" in *-*-msdosmsvc) ## The %T format specifier for strftime is reportedly broken, ## so use our version. We could use an actual configure test
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-02-17 Benjamin Lindner <lindnerb@users.sourceforge.net> + + * file-io.cc: (Fmkstemp): Use mkstemps if it is available and + mkstemp is missing. + 2009-02-17 Olaf Till <olaf.till@uni-jena.de> * DLD-FUNCTIONS/lsode.cc, DLD-FUNCTIONS/daspk.cc,
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -1907,6 +1907,11 @@ return retval; } +#if defined (HAVE_MKSTEMPS) +// Prototype for mkstemps in libiberty +extern "C" int mkstemps (char *pattern, int suffix_len); +#endif + DEFUN (mkstemp, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {[@var{fid}, @var{name}, @var{msg}] =} mkstemp (@var{template}, @var{delete})\n\ @@ -1935,7 +1940,7 @@ retval(1) = std::string (); retval(0) = -1; -#if defined (HAVE_MKSTEMP) +#if defined (HAVE_MKSTEMP) || defined (HAVE_MKSTEMPS) int nargin = args.length (); @@ -1948,7 +1953,11 @@ OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1); strcpy (tmp, tmpl8.c_str ()); +#if defined (HAVE_MKSTEMP) int fd = mkstemp (tmp); +#else + int fd = mkstemps (tmp, 0); +#endif if (fd < 0) {