AmendHub

Download:

jcs

/

subtext

/

amendments

/

161

util: Add macros for combining char bytes to long/short

This should be easy but doing so from signed chars causes problems,
so casting to unsigned char is needed, but then each needs to be cast
to a long before shifting.

jcs made amendment 161 over 2 years ago
--- util.h Tue Jun 21 14:29:38 2022 +++ util.h Wed Jun 22 17:16:04 2022 @@ -41,6 +41,15 @@ } \ } +#define CHARS_TO_LONG(a,b,c,d) (unsigned long)(\ + ((unsigned long)((unsigned char)(a)) << 24) | \ + ((unsigned long)((unsigned char)(b)) << 16) | \ + ((unsigned long)((unsigned char)(c)) << 8) | \ + (unsigned long)((unsigned char)(d)) ) +#define CHARS_TO_SHORT(a,b) (unsigned short)(\ + ((unsigned short)((unsigned char)(a)) << 8) | \ + (unsigned short)((unsigned char)(b)) ) + #define SCROLLBAR_WIDTH 16 /* GetMBarHeight() is not very useful */