[vlc-commits] [Git][videolan/vlc][3.0.x] logger/console: print messages in system locale on OS/2

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Aug 13 07:10:34 UTC 2021



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
871bb903 by KO Myung-Hun at 2021-08-13T06:55:50+00:00
logger/console: print messages in system locale on OS/2

Signed-off-by: Thomas Guillem <thomas at gllm.fr>
(cherry picked from commit 0adb6dc67ab563f14347bdad6eb2cce3d27432a7)

- - - - -


1 changed file:

- modules/logger/console.c


Changes:

=====================================
modules/logger/console.c
=====================================
@@ -34,6 +34,33 @@
 static const int ptr_width = 2 * /* hex digits */ sizeof (uintptr_t);
 static const char msg_type[4][9] = { "", " error", " warning", " debug" };
 
+#ifdef __OS2__
+#include <vlc_charset.h>
+
+static int OS2ConsoleOutput(FILE *stream, const char *format, va_list ap)
+{
+    char *msg;
+    char *os2msg;
+
+    if (vasprintf(&msg, format, ap) == -1 )
+        return -1;
+
+    if ((os2msg = ToLocale(msg)) == NULL)
+    {
+        free(msg);
+
+        return -1;
+    }
+
+    fputs(os2msg, stream);
+
+    LocaleFree(os2msg);
+    free(msg);
+
+    return 0;
+}
+#endif
+
 #ifndef _WIN32
 # define COL(x,y) "\033[" #x ";" #y "m"
 # define RED      COL(31,1)
@@ -59,6 +86,9 @@ static void LogConsoleColor(void *opaque, int type, const vlc_log_t *meta,
         fprintf(stream, "[%s] ", meta->psz_header);
     fprintf(stream, "%s %s%s: %s", meta->psz_module, meta->psz_object_type,
             msg_type[type], msg_color[type]);
+#ifdef __OS2__
+    if (OS2ConsoleOutput(stream, format, ap) == -1)
+#endif
     vfprintf(stream, format, ap);
     fputs(GRAY"\n", stream);
     funlockfile(stream);
@@ -80,6 +110,9 @@ static void LogConsoleGray(void *opaque, int type, const vlc_log_t *meta,
         fprintf(stream, "[%s] ", meta->psz_header);
     fprintf(stream, "%s %s%s: ", meta->psz_module, meta->psz_object_type,
             msg_type[type]);
+#ifdef __OS2__
+    if (OS2ConsoleOutput(stream, format, ap) == -1)
+#endif
     vfprintf(stream, format, ap);
     putc_unlocked('\n', stream);
     funlockfile(stream);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/871bb9030081dba85f686735e46bca72227b6d81

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/871bb9030081dba85f686735e46bca72227b6d81
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list