> -----Original Message----- > From: Chet Ramey [mailto:[email protected]] > Sent: Wednesday, April 03, 2019 4:29 PM > To: JohnD; [email protected] > Cc: [email protected] > Subject: Re: [Bug-readline] readline 8.0 in windows > > On 4/3/19 4:03 PM, JohnD wrote: > > > > Version: 8.0-release > > Windows 10, mingw64-w64. > > > > I'm attempting to use readline in a mingw compiled project and am seeing > > that the history save is failing. If the history file doesn't exist it is > > working, on having a history file, it fails. > > > > Previously I was using v6.2 without any issues > > > > Printing the status out in the sources to find out where it fails, it is > > failing in histfile_restore when calling the rename function, which looks to > > have been added for version 7.0 > > > > > > According to http://www.cplusplus.com/reference/cstdio/rename/ if the dest > > file already exists, the function may either fail or override the existing > > file, depending on the specific system and library implementation. > > Well, those are terrible semantics. So much for atomic rename and leaving > newpath in place on a file system error. > > I don't use Windows, but you could try adding > > unlink(linkbuf); > or > unlink(orig); > > before the calls to rename() (or, if you're using a version of readline > distributed by MinGW, file a bug report with them). Let me know if it > works. > > Chet > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
Msys2 recently went to 8.0 https://github.com/msys2/MINGW-packages/pull/5011 I'll verify it doesn’t work there and let them know For reference, Windoze does have its own 'rename' like function https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-movefileexa So I was going to try adding something like: 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 } And change the rename calls to history_rename _______________________________________________ Bug-readline mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-readline
