view src/readline-2-history.patch @ 5571:b19fb3ed330c

use cmake command line to set build shared/static options (bug #59373) * Makefile.in (CMAKE_BUILD_SHARED_OR_STATIC): New variable. (build-cmake-toolchain-file): Don't define BUILD_SHARED_LIBS or BUILD_STATIC_LIBS in the toolchain file. * armadillo.mk, cgal.mk, cmake.mk, cminpack.mk, double-conversion.mk, eigen.mk, gdcm.mk, gl2ps.mk, hdf5.mk, lapack.mk, libical.mk, libproxy.mk, of-dicom.mk, openal.mk, opencv.mk, openexr.mk, openscenegraph.mk, physfs.mk, qhull.mk, qjson.mk, rapidjson.mk, suitesparse.mk, sundials-ida.mk, taglib.mk, vigra.mk, vmime.mk, vtk.mk, wt.mk: Use $(CMAKE_BUILD_SHARED_OR_STATIC) on the cmake command line.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Oct 2020 10:06:00 -0400
parents d0a95d2c44bf
children
line wrap: on
line source

diff -ur readline-8.0.eventhook/histfile.c readline-8.0/histfile.c
--- readline-8.0.eventhook/histfile.c	2019-04-03 10:21:42.916563353 -0400
+++ readline-8.0/histfile.c	2019-04-03 16:16:04.605404093 -0400
@@ -107,6 +107,11 @@
 #  define PATH_MAX	1024	/* default */
 #endif
 
+#if defined(_WIN32)
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+#endif
+
 extern void _hs_append_history_line PARAMS((int, const char *));
 
 /* history file version; currently unused */
@@ -139,6 +144,19 @@
 static int histfile_backup PARAMS((const char *, const char *));
 static int histfile_restore PARAMS((const char *, const char *));
 
+static int
+history_rename(const char *from, const char *to)
+{
+#if defined(_WIN32)
+  if (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)) {
+    return -1;
+  }
+  return 0;
+#else
+  return rename(from, to);
+#endif
+}
+
 /* Return the string that should be used in the place of this
    filename.  This only matters when you don't specify the
    filename to read_history (), or write_history (). */
@@ -448,10 +466,10 @@
   if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
     {
       linkbuf[n] = '\0';
-      return (rename (linkbuf, back));
+      return (history_rename (linkbuf, back));
     }
 #endif
-  return (rename (filename, back));
+  return (history_rename (filename, back));
 }
 
 /* Restore ORIG from BACKUP handling case where ORIG is a symlink
@@ -467,10 +485,10 @@
   if ((n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0)
     {
       linkbuf[n] = '\0';
-      return (rename (backup, linkbuf));
+      return (history_rename (backup, linkbuf));
     }
 #endif
-  return (rename (backup, orig));
+  return (history_rename (backup, orig));
 }
 
 /* Truncate the history file FNAME, leaving only LINES trailing lines.