These macros evaluate their arguments more than once, so using them
while incrementing a pointer, for example, would introduce bugs.
* src/octhexdigits.h (isoct, fromoct, fromhex): Define as an inline
function instead of a macro.
---
src/octhexdigits.h | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/octhexdigits.h b/src/octhexdigits.h
index fff6866b5..435dc495c 100644
--- a/src/octhexdigits.h
+++ b/src/octhexdigits.h
@@ -1,4 +1,16 @@
-#define isoct(c) ('0' <= (c) && (c) <= '7')
-#define fromoct(c) ((c) - '0')
-#define fromhex(c) ('a' <= (c) && (c) <= 'f' ? (c) - 'a' + 10 : \
- 'A' <= (c) && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0')
+static inline bool _GL_ATTRIBUTE_CONST
+isoct (char c)
+{
+ return '0' <= c && c <= '7';
+}
+static inline int _GL_ATTRIBUTE_CONST
+fromoct (char c)
+{
+ return c - '0';
+}
+static inline int _GL_ATTRIBUTE_CONST
+fromhex (char c)
+{
+ return ('a' <= c && c <= 'f' ? c - 'a' + 10
+ : 'A' <= c && c <= 'F' ? c - 'A' + 10 : c - '0');
+}
--
2.55.0