Skip to content

Commit

Permalink
[andrey-terekhov#314] Depend on _WIN32 rather than _MSC_VER when chec…
Browse files Browse the repository at this point in the history
…king for Windows
  • Loading branch information
maximmenshikov committed Apr 17, 2022
1 parent b173427 commit 5a7e333
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions libs/compiler/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "syntax.h"
#include "uniio.h"

#ifndef _MSC_VER
#ifndef _WIN32
#include <sys/stat.h>
#include <sys/types.h>
#endif
Expand All @@ -44,7 +44,7 @@ typedef int (*encoder)(const workspace *const ws, syntax *const sx);
/** Make executable actually executable on best-effort basis (if possible) */
static inline void make_executable(const char *const path)
{
#ifndef _MSC_VER
#ifndef _WIN32
struct stat stat_buf;

if (stat(path, &stat_buf))
Expand Down
12 changes: 6 additions & 6 deletions libs/utils/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string.h>
#include "utf8.h"

#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>

static const uint8_t COLOR_TAG = 0x0F;
Expand Down Expand Up @@ -61,7 +61,7 @@ static logger current_note_log = &default_note_log;
static inline void set_color(const uint8_t color)
{
#if defined(NDEBUG) || !defined(__APPLE__)
#ifdef _MSC_VER
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE), color);
#else
fprintf(stderr, "\x1B[1;%im", color);
Expand Down Expand Up @@ -101,7 +101,7 @@ static inline void print_msg(const uint8_t color, const char *const msg)

while (msg[j] != '^')
{
#ifdef _MSC_VER
#ifdef _WIN32
fprintf(stderr, "%c", msg[i++]);
#else
for (size_t k = utf8_symbol_size(msg[i]); k > 0; k--)
Expand All @@ -116,7 +116,7 @@ static inline void print_msg(const uint8_t color, const char *const msg)
set_color(color);
while (msg[j] != '\0')
{
#ifdef _MSC_VER
#ifdef _WIN32
fprintf(stderr, "%c", msg[i++]);
#else
for (size_t k = utf8_symbol_size(msg[i]); k > 0; k--)
Expand Down Expand Up @@ -146,15 +146,15 @@ static inline void default_log(const char *const tag, const char *const msg, con
fprintf(stderr, "%s: ", tag);

set_color(color);
#ifdef _MSC_VER
#ifdef _WIN32
char buffer[MAX_MSG_SIZE];
utf8_to_cp866(tag_log, buffer);
fprintf(stderr, "%s: ", buffer);
#else
fprintf(stderr, "%s: ", tag_log);
#endif

#ifdef _MSC_VER
#ifdef _WIN32
utf8_to_cp866(msg, buffer);
print_msg(color, buffer);
#else
Expand Down
4 changes: 2 additions & 2 deletions libs/utils/uniio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string.h>
#include "workspace.h"

#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>

extern intptr_t _get_osfhandle(int fd);
Expand Down Expand Up @@ -192,7 +192,7 @@ static int out_func_user(universal_io *const io, const char *const format, va_li

static inline size_t io_get_path(FILE *const file, char *const buffer)
{
#ifdef _MSC_VER
#ifdef _WIN32
GetFinalPathNameByHandleA((HANDLE)_get_osfhandle(_fileno(file)), buffer, MAX_PATH, FILE_NAME_NORMALIZED);

size_t ret = 0;
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/workspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "workspace.h"
#include <string.h>

#ifndef _MSC_VER
#ifndef _WIN32
#include <unistd.h>
#else
#define F_OK 0
Expand Down

0 comments on commit 5a7e333

Please sign in to comment.