Browse Source

bfg_strerror: Trim C whitespace off the right of FormatMessage output, since Windows can add \r\n

Luke Dashjr 12 years ago
parent
commit
dd4c063fc2
2 changed files with 7 additions and 1 deletions
  1. 1 1
      libblkmaker
  2. 6 0
      util.c

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 8f4bb3ee9f43405203fef6f64ca938dc7933a060
+Subproject commit bca8f6f5e56c547e9bbc808fb644152e44f3344d

+ 6 - 0
util.c

@@ -2349,7 +2349,13 @@ const char *bfg_strerror(int e, enum bfg_strerror_type type)
 			if (*msg)
 			if (*msg)
 				LocalFree(*msg);
 				LocalFree(*msg);
 			if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, (LPSTR)msg, 0, 0))
 			if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, e, 0, (LPSTR)msg, 0, 0))
+			{
+				LPSTR msgp = *msg;
+				size_t n = strlen(msgp);
+				while (isCspace(msgp[--n]))
+					msgp[n] = '\0';
 				return *msg;
 				return *msg;
+			}
 			*msg = NULL;
 			*msg = NULL;
 			
 			
 			break;
 			break;