/* This is a helper macro to avoid preprocessor issues, replaced by nothing
* unless under DEBUGGING, where it expands to an assert of its argument,
* followed by a comma (hence the comma operator). If we just used a straight
- * assert(), we would get a comma with nothing before it when not DEBUGGING */
-#ifdef DEBUGGING
+ * assert(), we would get a comma with nothing before it when not DEBUGGING.
+ *
+ * We also use empty definition under Coverity since the __ASSERT__
+ * checks often check for things that Really Cannot Happen, and Coverity
+ * detects that and gets all excited. */
+
+#if defined(DEBUGGING) && !defined(__COVERITY__)
# define __ASSERT_(statement) assert(statement),
#else
# define __ASSERT_(statement)
* compiler to optimize it out if possible. This is because Configure makes
* sure that the machine has an 8-bit byte, so if c is stored in a byte, the
* sizeof() guarantees that this evaluates to a constant true at compile time.
+ *
+ * For Coverity, be always true, because otherwise Coverity thinks
+ * it finds several expressions that are always true, independent
+ * of operands. Well, they are, but that is kind of the point.
*/
+#ifndef __COVERITY__
#define FITS_IN_8_BITS(c) ((sizeof(c) == 1) || !(((WIDEST_UTYPE)(c)) & ~0xFF))
+#else
+#define FITS_IN_8_BITS(c) (1)
+#endif
#ifdef EBCDIC
# ifndef _ALL_SOURCE
# define _CC_NON_FINAL_FOLD 21
# define _CC_IS_IN_SOME_FOLD 22
# define _CC_MNEMONIC_CNTRL 23
-/* Unused: 24-31
+
+/* This next group is only used on EBCDIC platforms, so theoretically could be
+ * shared with something entirely different that's only on ASCII platforms */
+# define _CC_UTF8_START_BYTE_IS_FOR_AT_LEAST_SURROGATE 28
+# define _CC_UTF8_IS_START 29
+# define _CC_UTF8_IS_DOWNGRADEABLE_START 30
+# define _CC_UTF8_IS_CONTINUATION 31
+/* Unused: 24-27
* If more bits are needed, one could add a second word for non-64bit
* QUAD_IS_INT systems, using some #ifdefs to distinguish between having a 2nd
* word or not. The IS_IN_SOME_FOLD bit is the most easily expendable, as it
* is used only for optimization (as of this writing), and differs in the
* Latin1 range from the ALPHA bit only in two relatively unimportant
* characters: the masculine and feminine ordinal indicators, so removing it
- * would just cause /i regexes which match them to run less efficiently */
+ * would just cause /i regexes which match them to run less efficiently.
+ * Similarly the EBCDIC-only bits are used just for speed, and could be
+ * replaced by other means */
#if defined(PERL_CORE) || defined(PERL_EXT)
/* An enum version of the character class numbers, to help compilers
* As well as avoiding the need for a run-time check in some cases, it's
* designed to avoid compiler warnings like:
* comparison is always false due to limited range of data type
+ * It's mathematically equivalent to
+ * max(n) * sizeof(t) > MEM_SIZE_MAX
*/
# define _MEM_WRAP_NEEDS_RUNTIME_CHECK(n,t) \
- (sizeof(t) > ((MEM_SIZE)1 << 8*(sizeof(MEM_SIZE) - sizeof(n))))
+ ( sizeof(MEM_SIZE) < sizeof(n) \
+ || sizeof(t) > ((MEM_SIZE)1 << 8*(sizeof(MEM_SIZE) - sizeof(n))))
/* This is written in a slightly odd way to avoid various spurious
* compiler warnings. We *want* to write the expression as