aboutsummaryrefslogtreecommitdiff
path: root/src/include/regex/regcustom.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/regex/regcustom.h')
-rw-r--r--src/include/regex/regcustom.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/regex/regcustom.h b/src/include/regex/regcustom.h
index 3f1d14e1908..60034daee83 100644
--- a/src/include/regex/regcustom.h
+++ b/src/include/regex/regcustom.h
@@ -68,6 +68,17 @@ typedef int celt; /* type to hold chr, or NOCELT */
#define CHR_MAX 0x7ffffffe /* CHR_MAX-CHR_MIN+1 must fit in an int, and
* CHR_MAX+1 must fit in both chr and celt */
+/*
+ * Check if a chr value is in range. Ideally we'd just write this as
+ * ((c) >= CHR_MIN && (c) <= CHR_MAX)
+ * However, if chr is unsigned and CHR_MIN is zero, the first part of that
+ * is a no-op, and certain overly-nannyish compilers give warnings about it.
+ * So we leave that out here. If you want to make chr signed and/or CHR_MIN
+ * not zero, redefine this macro as above. Callers should assume that the
+ * macro may multiply evaluate its argument, even though it does not today.
+ */
+#define CHR_IS_IN_RANGE(c) ((c) <= CHR_MAX)
+
/* functions operating on chr */
#define iscalnum(x) pg_wc_isalnum(x)
#define iscalpha(x) pg_wc_isalpha(x)