[Groonga-commit] groonga/groonga at 6f6cbf0 [master] windows: remove a trailing new line from system error message

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 14 22:45:01 JST 2015


Kouhei Sutou	2015-01-14 22:45:01 +0900 (Wed, 14 Jan 2015)

  New Revision: 6f6cbf09a10113792694a395a3beea3d1df16426
  https://github.com/groonga/groonga/commit/6f6cbf09a10113792694a395a3beea3d1df16426

  Message:
    windows: remove a trailing new line from system error message

  Modified files:
    lib/error.c

  Modified: lib/error.c (+19 -8)
===================================================================
--- lib/error.c    2015-01-14 22:25:20 +0900 (0d9a425)
+++ lib/error.c    2015-01-14 22:45:01 +0900 (e14ef37)
@@ -30,15 +30,26 @@ grn_current_error_message(void)
 # define ERROR_MESSAGE_BUFFER_SIZE 4096
   int error_code = GetLastError();
   static char message[ERROR_MESSAGE_BUFFER_SIZE];
+  DWORD written_bytes;
 
-  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
-                FORMAT_MESSAGE_IGNORE_INSERTS,
-                NULL,
-                error_code,
-                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                message,
-                ERROR_MESSAGE_BUFFER_SIZE,
-                NULL);
+  written_bytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+                                FORMAT_MESSAGE_IGNORE_INSERTS,
+                                NULL,
+                                error_code,
+                                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                                message,
+                                ERROR_MESSAGE_BUFFER_SIZE,
+                                NULL);
+  if (written_bytes >= 2) {
+    if (message[written_bytes - 1] == '\n') {
+      message[written_bytes - 1] = '\0';
+      written_bytes--;
+    }
+    if (message[written_bytes - 1] == '\r') {
+      message[written_bytes - 1] = '\0';
+      written_bytes--;
+    }
+  }
 
   return message;
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index