[vlc-commits] [Git][videolan/vlc][master] 3 commits: core: condition the use of isatty to HAVE_ISATTY
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Jan 11 10:09:18 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
c7901734 by Steve Lhomme at 2023-01-11T09:46:11+00:00
core: condition the use of isatty to HAVE_ISATTY
It's more logical, especially since it's available on Windows.
- - - - -
3e255598 by Steve Lhomme at 2023-01-11T09:46:11+00:00
interface: use isatty on Windows if HAVE_ISATTY is defined
- - - - -
31ead65b by Steve Lhomme at 2023-01-11T09:46:11+00:00
console logger: use isatty on Windows if it's available
- - - - -
4 changed files:
- modules/logger/console.c
- src/config/cmdline.c
- src/config/help.c
- src/interface/interface.c
Changes:
=====================================
modules/logger/console.c
=====================================
@@ -26,6 +26,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <inttypes.h>
+#ifdef _WIN32
+# include <io.h> // isatty()
+#endif
#include <unistd.h> /* isatty(), STDERR_FILNO */
#include <vlc_common.h>
@@ -62,7 +65,6 @@ static int OS2ConsoleOutput(FILE *stream, const char *format, va_list ap)
}
#endif
-#ifndef _WIN32
# define COL(x,y) "\033[" #x ";" #y "m"
# define RED COL(31,1)
# define GREEN COL(32,1)
@@ -100,7 +102,6 @@ static const struct vlc_logger_operations color_ops =
LogConsoleColor,
NULL
};
-#endif /* !_WIN32 */
static void LogConsoleGray(void *opaque, int type, const vlc_log_t *meta,
const char *format, va_list ap)
@@ -154,7 +155,7 @@ static const struct vlc_logger_operations *Open(vlc_object_t *obj,
*sysp = verbosities + verbosity;
-#if defined (HAVE_ISATTY) && !defined (_WIN32)
+#if defined (HAVE_ISATTY)
if (isatty(STDERR_FILENO) && var_InheritBool(obj, "color"))
return &color_ops;
#endif
=====================================
src/config/cmdline.c
=====================================
@@ -271,7 +271,7 @@ int config_LoadCmdLine( libvlc_int_t *p_this, int i_argc,
int ret = -1;
bool color = false;
-#ifndef _WIN32
+#ifdef HAVE_ISATTY
color = (isatty(STDERR_FILENO));
#endif
=====================================
src/config/help.c
=====================================
@@ -42,9 +42,8 @@
#if defined( _WIN32 )
# define wcwidth(cp) ((void)(cp), 1) /* LOL */
-#else
-# include <unistd.h>
#endif
+#include <unistd.h>
#if defined( _WIN32 ) && !defined( VLC_WINSTORE_APP )
static void ShowConsole (void);
@@ -583,7 +582,7 @@ static void Usage (libvlc_int_t *p_this, char const *psz_search)
}
bool color = false;
-#ifndef _WIN32
+#ifdef HAVE_ISATTY
if (isatty(STDOUT_FILENO))
color = var_InheritBool(p_this, "color");
#endif
@@ -645,7 +644,7 @@ static void ListModules (libvlc_int_t *p_this, bool b_verbose)
bool color = false;
ShowConsole();
-#ifndef _WIN32
+#ifdef HAVE_ISATTY
if (isatty(STDOUT_FILENO))
color = var_InheritBool(p_this, "color");
#else
=====================================
src/interface/interface.c
=====================================
@@ -147,7 +147,7 @@ int intf_Create( libvlc_int_t *libvlc, const char *chain )
vlc_value_t val;
var_Create( p_intf, "intf-add", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
var_Change( p_intf, "intf-add", VLC_VAR_SETTEXT, _("Add Interface") );
-#if !defined(_WIN32) && defined(HAVE_ISATTY)
+#if defined(HAVE_ISATTY)
if( isatty( 0 ) )
#endif
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6424f5452e6b34f4a9c88d8d89adcab7145d20a0...31ead65b87ce57207983bceb0c5e50feb490acd3
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6424f5452e6b34f4a9c88d8d89adcab7145d20a0...31ead65b87ce57207983bceb0c5e50feb490acd3
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list