From 2373fca9f98a718f3fb9d3cc0c109c21acf8ecf2 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Tue, 26 Nov 2024 18:27:20 +0100 Subject: Change WIN32 to _WIN32 to check if running on Windows --- src/termcolors.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/termcolors.c') diff --git a/src/termcolors.c b/src/termcolors.c index 5c436f2..798e47a 100644 --- a/src/termcolors.c +++ b/src/termcolors.c @@ -22,7 +22,7 @@ #include "config.h" #endif -#ifdef WIN32 +#ifdef _WIN32 #include #endif @@ -37,7 +37,7 @@ static int use_colors = 0; -#ifdef WIN32 +#ifdef _WIN32 static int WIN32_LEGACY_MODE = 1; static WORD COLOR_RESET_ATTR = 0; static WORD DEFAULT_FG_ATTR = 0; @@ -94,7 +94,7 @@ static int WIN32_LEGACY_MODE = 0; void term_colors_init() { -#ifdef WIN32 +#ifdef _WIN32 DWORD conmode = 0; h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleMode(h_stdout, &conmode); @@ -135,7 +135,7 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) { int res = 0; int colorize = use_colors; -#ifdef WIN32 +#ifdef _WIN32 struct esc_item { int pos; WORD attr; @@ -162,7 +162,7 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) va_end(vargs_copy); // then, we need to remove the escape sequences, if any -#ifdef WIN32 +#ifdef _WIN32 // if colorize is on, we need to keep their positions for later struct esc_item* esc_items = NULL; int attr = 0; @@ -183,7 +183,7 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) if (*p == '\e' && end-p > 2 && *(p+1) == '[') { p+=2; if (*p == 'm') { -#ifdef WIN32 +#ifdef _WIN32 attr = COLOR_RESET_ATTR; #endif int move_by = (p+1)-cur; @@ -197,13 +197,13 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) long lval = strtol(p, &endp, 10); if (!endp || (*endp != ';' && *endp != 'm')) { fprintf(stderr, "\n*** %s: Invalid escape sequence in format string, expected ';' or 'm' ***\n", __func__); -#ifdef WIN32 +#ifdef _WIN32 free(esc_items); #endif free(newbuf); return -1; } -#ifdef WIN32 +#ifdef _WIN32 if (colorize) { if (lval >= 0 && lval <= 8) { /* style attributes */ @@ -249,7 +249,7 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) end -= move_by; p = cur; } -#ifdef WIN32 +#ifdef _WIN32 if (colorize) { esc_items[num_esc].pos = p-start; if (attr & STYLE_DIM) { @@ -268,12 +268,12 @@ int cvfprintf(FILE* stream, const char* fmt, va_list vargs) if (num_esc == 0) { res = fputs(newbuf, stream); free(newbuf); -#ifdef WIN32 +#ifdef _WIN32 free(esc_items); #endif return res; } -#ifdef WIN32 +#ifdef _WIN32 else { p = &newbuf[0]; char* lastp = &newbuf[0]; -- cgit v1.1-32-gdbae