Replace `Nx()` (temp value-assigning) macros with `Nv()` to avoid conflict with `TRACEx()` and for more clarity.

Fortune for naka's current commit: Small curse − 小凶
strings
Avril 3 years ago
parent 158b6e1fd4
commit a826612de5
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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 */

@ -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. */ \

@ -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)

Loading…
Cancel
Save