From 7faf6f57472ee0247c757f12aff56faf2c2c4919 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Mon, 3 Aug 2015 21:04:10 +0200 Subject: [PATCH 2/4] Fix bug in nibbled1 and use character types throughout * ini.h (nibbled1): Fix a thinko in this macro that made the result always zero. (hexnibble, nibbled1, b64url, b64d1, b64d2, b64d3): Make all calculation constants dealing with characters character literals. Remove trailing semicolons. --- ChangeLog | 7 +++++++ ini.h | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f8cd2b4..ef3a733 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2015-08-03 Achim Gratz + * ini.h (nibbled1): Fix a thinko in this macro that made the result always zero. + (hexnibble, nibbled1, b64url, b64d1, b64d2, b64d3): Make all + calculation constants dealing with characters character literals. + Remove trailing semicolons. + +2015-08-03 Achim Gratz + * csu_util/MD5Sum.cc (str): The stream modifiers are not sticky and must be applied for each conversion. diff --git a/ini.h b/ini.h index 164e3d2..7f6db22 100644 --- a/ini.h +++ b/ini.h @@ -59,16 +59,16 @@ extern int yyerror_count; /* number of parse errors */ /* The following definitions are used in the parser implementation */ -#define hexnibble(val) (255 & (val > '9') ? val - 'a' + 10 : val - '0'); -#define nibbled1(v1,v2) (255 & ((v1 << 4) & v2)); +#define hexnibble(val) ('\xff' & (val > '9') ? val - 'a' + 10 : val - '0') +#define nibbled1(v1,v2) ('\xff' & ((v1 << 4) | v2)) #define b64url(val) \ - (63 & (( val == '_') ? 63 \ - : (val == '-') ? 62 \ - : (val >= 'a') ? val - 'a' + 26 \ - : (val >= 'A') ? val - 'A' + 0 \ - : val - '0' + 52)) -#define b64d1(v1,v2,v3,v4) (255 & ((v1 << 2) | (v2 >> 4))); -#define b64d2(v1,v2,v3,v4) (255 & ((v2 << 4) | (v3 >> 2))); -#define b64d3(v1,v2,v3,v4) (255 & ((v3 << 6) | v4)); + ('\x3f' & (( val == '_') ? '\x3f' \ + : (val == '-') ? '\x3e' \ + : (val >= 'a') ? val - 'a' + '\x1a' \ + : (val >= 'A') ? val - 'A' + '\x00' \ + : val - '0' + '\x34')) +#define b64d1(v1,v2,v3,v4) ('\xff' & ((v1 << 2) | (v2 >> 4))) +#define b64d2(v1,v2,v3,v4) ('\xff' & ((v2 << 4) | (v3 >> 2))) +#define b64d3(v1,v2,v3,v4) ('\xff' & ((v3 << 6) | v4)) #endif /* SETUP_INI_H */ -- 2.4.6