[vlc-commits] contrib: live555: FormatMessageA is always available

Steve Lhomme git at videolan.org
Tue Mar 19 11:50:48 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Mar 19 10:04:32 2019 +0100| [2ca0611aef1cd69eca3dce37ac18ad64581e4cae] | committer: Steve Lhomme

contrib: live555: FormatMessageA is always available

And no need to redefine snprintf for one call.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ca0611aef1cd69eca3dce37ac18ad64581e4cae
---

 contrib/src/live555/live555-formatmessage.patch | 31 +++++++++++++++++++++++++
 contrib/src/live555/rules.mak                   |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/contrib/src/live555/live555-formatmessage.patch b/contrib/src/live555/live555-formatmessage.patch
new file mode 100644
index 0000000000..ee02d1d04d
--- /dev/null
+++ b/contrib/src/live555/live555-formatmessage.patch
@@ -0,0 +1,31 @@
+--- live555/BasicUsageEnvironment/BasicUsageEnvironment0.cpp.unicode	2019-03-19 10:00:21.845187700 +0100
++++ live555/BasicUsageEnvironment/BasicUsageEnvironment0.cpp	2019-03-19 09:59:40.204996800 +0100
+@@ -19,9 +19,6 @@ along with this library; if not, write t
+ 
+ #include "BasicUsageEnvironment0.hh"
+ #include <stdio.h>
+-#if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE)
+-#define snprintf _snprintf
+-#endif
+ 
+ 
+ ////////// BasicUsageEnvironment //////////
+@@ -68,7 +65,6 @@ void BasicUsageEnvironment0::setResultEr
+ 
+   if (err == 0) err = getErrno();
+ #if defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_WCE)
+-#ifndef _UNICODE
+   char errMsg[RESULT_MSG_BUFFER_MAX] = "\0";
+   if (0 != FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, errMsg, sizeof(errMsg)/sizeof(errMsg[0]), NULL)) {
+     // Remove all trailing '\r', '\n' and '.'
+@@ -76,9 +72,8 @@ void BasicUsageEnvironment0::setResultEr
+       *p = '\0';
+     }
+   } else
+-    snprintf(errMsg, sizeof(errMsg)/sizeof(errMsg[0]), "error %d", err);
++    _snprintf(errMsg, sizeof(errMsg)/sizeof(errMsg[0]), "error %d", err);
+   appendToResultMsg(errMsg);
+-#endif
+ #else
+   appendToResultMsg(strerror(err));
+ #endif
diff --git a/contrib/src/live555/rules.mak b/contrib/src/live555/rules.mak
index 366c1bf8a6..4f9b70d452 100644
--- a/contrib/src/live555/rules.mak
+++ b/contrib/src/live555/rules.mak
@@ -79,6 +79,8 @@ endif
 	$(APPLY) $(SRC)/live555/expose_server_string.patch
 	# Fix creating static libs on mingw
 	$(APPLY) $(SRC)/live555/mingw-static-libs.patch
+	# FormatMessageA is available on all Windows versions, even WinRT
+	$(APPLY) $(SRC)/live555/live555-formatmessage.patch
 ifdef HAVE_ANDROID
 	# Fix in_addr.s_addr field access
 	$(APPLY) $(SRC)/live555/in_addr-s_addr-field.patch



More information about the vlc-commits mailing list