From 963014459c5eb54b1317c688f9e2dfbac44a672d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 21 Apr 2022 11:48:49 +0200 Subject: [PATCH] cursor: convert macros to functions Improves readability since there's no need for so many parentheses anymore, adds type safety. The compiler will inline the function automatically as necessary. Signed-off-by: Simon Ser --- cursor/xcursor.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cursor/xcursor.c b/cursor/xcursor.c index e4b9a9d1..0a7dfecb 100644 --- a/cursor/xcursor.c +++ b/cursor/xcursor.c @@ -379,7 +379,11 @@ xcursor_file_read_chunk_header(struct xcursor_file *file, return true; } -#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a)) +static uint32_t +dist(uint32_t a, uint32_t b) +{ + return a > b ? a - b : b - a; +} static uint32_t xcursor_file_best_size(struct xcursor_file_header *fileHeader, @@ -728,8 +732,17 @@ xcursor_next_path(const char *path) return colon + 1; } -#define xcursor_white(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') -#define xcursor_sep(c) ((c) == ';' || (c) == ',') +static bool +xcursor_white(char c) +{ + return c == ' ' || c == '\t' || c == '\n'; +} + +static bool +xcursor_sep(char c) +{ + return c == ';' || c == ','; +} static char * xcursor_theme_inherits(const char *full)