Permalink
Browse files

Revert to old error code on Windows

The new code only worked on msvc++, not on mingw.
  • Loading branch information...
1 parent bfa1dd7 commit 0839e92a4e156e96287750346da26afc08af8a5e @Leont committed Apr 25, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −0 Changes
  2. +7 −1 lib/File/Map.xs
View
@@ -1,6 +1,7 @@
Revision history for File-Map
{{$NEXT}}
+ Revert to old error code on Windows
0.48 2012-04-23 02:27:01 Europe/Amsterdam
Fix madvice on old cygwin versions
View
@@ -77,7 +77,13 @@ struct mmap_info {
#ifdef WIN32
static void get_sys_error(char* buffer, size_t buffer_size) {
- strerror_s(buffer, buffer_size, errno);
+ DWORD last_error = GetLastError();
+
+ DWORD format_flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
+ int length = FormatMessage(format_flags, NULL, last_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)buffer, buffer_size, NULL);
+ if (buffer[length - 2] == '\r') {
+ buffer[length - 2] = '\0';
+ }
}
static DWORD page_size() {

0 comments on commit 0839e92

Please sign in to comment.