# HG changeset patch # User Benjamin Lindner # Date 1234936532 18000 # Node ID bbb3fa6778f365e6d4794a2cb49f259e0b2c210b # Parent d943e26d30e2c27eaeb7a79b1583d03a03e08ce4 use mkstemps as replacement for mkstemp on mingw32 diff -r d943e26d30e2 -r bbb3fa6778f3 ChangeLog --- a/ChangeLog Wed Feb 18 00:47:48 2009 -0500 +++ b/ChangeLog Wed Feb 18 00:55:32 2009 -0500 @@ -1,3 +1,8 @@ +2009-02-17 Benjamin Lindner + + * configure.in: Check for mkstemps on MinGW platform + (HAVE_MKSTEMPS): Define if mkstsmps is avilable in libiberty. + 2009-02-17 Jaroslav Hajek * NEWS: Mention cummin and cummax diff -r d943e26d30e2 -r bbb3fa6778f3 configure.in --- a/configure.in Wed Feb 18 00:47:48 2009 -0500 +++ b/configure.in Wed Feb 18 00:55:32 2009 -0500 @@ -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 diff -r d943e26d30e2 -r bbb3fa6778f3 src/ChangeLog --- a/src/ChangeLog Wed Feb 18 00:47:48 2009 -0500 +++ b/src/ChangeLog Wed Feb 18 00:55:32 2009 -0500 @@ -1,3 +1,8 @@ +2009-02-17 Benjamin Lindner + + * file-io.cc: (Fmkstemp): Use mkstemps if it is available and + mkstemp is missing. + 2009-02-17 Olaf Till * DLD-FUNCTIONS/lsode.cc, DLD-FUNCTIONS/daspk.cc, diff -r d943e26d30e2 -r bbb3fa6778f3 src/file-io.cc --- a/src/file-io.cc Wed Feb 18 00:47:48 2009 -0500 +++ b/src/file-io.cc Wed Feb 18 00:55:32 2009 -0500 @@ -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) {