From a826612de5130c16658269b4dced0a1901ecc6d5 Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 15 Jul 2021 15:02:05 +0100 Subject: [PATCH] Replace `Nx()` (temp value-assigning) macros with `Nv()` to avoid conflict with `TRACEx()` and for more clarity. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for naka's current commit: Small curse − 小凶 --- include/macros.h | 2 +- src/display.c | 10 +++++----- src/str.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/macros.h b/include/macros.h index 9e34e64..77a0b72 100644 --- a/include/macros.h +++ b/include/macros.h @@ -266,6 +266,6 @@ _Static_assert( (VERSION_COMP(VERSION(1,2,3,4), VER_COMP_MIN) >> VER_COMP_MIN) = // Misc. #define PTR_ASSIGN(ptr, val) ( (ptr) ? (*(ptr) = (val), (ptr)) : (ptr) ) -#define PTR_ASSIGNx(ptr, val) ({ let _ptr = (ptr); let _val = (val); PTR_ASSIGN(_ptr, _val); }) +#define PTR_ASSIGNv(ptr, val) ({ let _ptr = (ptr); let _val = (val); PTR_ASSIGN(_ptr, _val); }) #endif /* _MACROS_H */ diff --git a/src/display.c b/src/display.c index 56cf5e6..faec929 100644 --- a/src/display.c +++ b/src/display.c @@ -12,11 +12,11 @@ #define DFLAGSET(f, flagname) FLAGSET(f, DISPF_SHOW_ ## flagname) #define CMP(x,cmp,y) ( (x) cmp (y) ? (x) : (y) ) -#define CMPx(x,cmp,y) ({ let _x = (x); let _y = (y); CMP(_x, cmp, _y); }) +#define CMPv(x,cmp,y) ({ let _x = (x); let _y = (y); CMP(_x, cmp, _y); }) #define MIN(x, y) CMP((x), <, (y)) -#define MINx(x, y) CMPx((x), <, (y)) +#define MINv(x, y) CMPv((x), <, (y)) #define MAX(x, y) CMP((x), >, (y)) -#define MAXx(x, y) CMPx((x), >, (y)) +#define MAXv(x, y) CMPv((x), >, (y)) // Returns number of bytes written to `dest`. Otherwise same as `strncpy()`. static usize strncpy_n(char*pOUT dest, const char* restrict src, usize n) @@ -42,7 +42,7 @@ static usize s_strncpy_n(usize sn, usize dn; char dest[static pOUT dn], usize dn // Will not write past `dn` bytes of `dest`, will not read past `sn` bytes of `src`. Otherwise, same as `strncat_n()`. static inline usize s_strncat_n(usize sn, usize dn; char dest[static pOUT dn], usize dn, const char src[static restrict sn], usize sn) { - usize dl = MINx(strlen(dest), dn); + usize dl = MINv(strlen(dest), dn); return s_strncpy_n(dest + dl, dn - dl, src, sn); } @@ -75,7 +75,7 @@ static usize _display_get_fmt_n(dispflags_t flags, bool matched, usize _n, char //TODO: Fix this... It isn't working... #define ADDSTR(s) do { \ debug_assert((s)); \ - w = MINx(s_strncat_n(str, n, (s), n), n); \ + w = MINv(s_strncat_n(str, n, (s), n), n); \ /* Remove written from `n` */ \ n -= w; \ /* Check if we have written into the limit (if so, w will be equal to n above, since w is high-bounded to n by `MINx()` above. So if n is 0, we have hit the limit. */ \ diff --git a/src/str.c b/src/str.c index c0cea03..b8dc27c 100644 --- a/src/str.c +++ b/src/str.c @@ -106,8 +106,8 @@ static union _str_meta_inner _str_default_meta(enum str_ownership oship, bool *p struct str_meta_owned* o_own = NULL; struct str_meta_derived* o_der = NULL; - // PTR_ASSIGNx always evaluates both args, so this is fine - PTR_ASSIGNx(owned, + // PTR_ASSIGNv always evaluates both args, so this is fine + PTR_ASSIGNv(owned, _str_meta_parts_from(oship, &output, &o_own, &o_der)