From 30f9f20e235269181da5b29aee917ea1987420ba Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Wed, 17 Mar 2021 18:10:47 +0100 Subject: [PATCH] Ensure xrdb code is compiled only on unix --- src/main.c | 2 +- src/xrdb_parse.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index dc3abda1..0024a717 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,7 @@ static double get_scale(void) { float dpi; SDL_GetDisplayDPI(0, NULL, &dpi, NULL); return dpi / 96.0; -#elif __linux__ +#elif __unix__ int xft_dpi = xrdb_find_dpi(); if (xft_dpi > 0) { return xft_dpi / 96.0; diff --git a/src/xrdb_parse.c b/src/xrdb_parse.c index 197bb60d..2c90de9d 100644 --- a/src/xrdb_parse.c +++ b/src/xrdb_parse.c @@ -1,3 +1,5 @@ +#ifdef __unix__ + #include #include #include @@ -25,16 +27,15 @@ static int xrdb_popen (int *pid_ptr) { int fd[2]; pipe(fd); - int read_fd = fd[STDIN_FILENO]; - int write_fd = fd[STDOUT_FILENO]; - - char *path = getenv("PATH"); + int read_fd = fd[0]; + int write_fd = fd[1]; int pid = fork(); if (pid == 0) { close(read_fd); dup2(write_fd, STDOUT_FILENO); close(write_fd); + char *path = getenv("PATH"); char xrdb_filename[256]; while (path) { char *xrgb_argv[3] = {"xrdb", "-query", NULL}; @@ -93,6 +94,7 @@ static int xrdb_parse_for_dpi(int read_fd) { xrdb_complete_reading(read_fd); return dpi_read; } + /* doesn't match: position after newline to search again */ line_start = nlptr + 1; } else { /* No newline found: copy the remaining part at the beginning of buf @@ -137,3 +139,5 @@ int xrdb_find_dpi() { } return -1; } + +#endif