pcre.c, etc.: Support the PCRE2 library.
[anag] / anag.h
diff --git a/anag.h b/anag.h
index e16a3ae..32b5ea5 100644 (file)
--- a/anag.h
+++ b/anag.h
 #include <stdlib.h>
 #include <string.h>
 
+/*----- Preliminaries -----------------------------------------------------*/
+
+#if defined(__GNUC__)
+#  define GCC_VERSION_P(maj, min)                                       \
+       (__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
+#else
+#  define GCC_VERSION_P(maj, min) 0
+#endif
+
+#ifdef __clang__
+#  define CLANG_VERSION_P(maj, min)                                     \
+       (__clang_major__ > (maj) || (__clang_major__ == (maj) &&        \
+                                    __clang_minor__ >= (min)))
+#else
+#  define CLANG_VERSION_P(maj, min) 0
+#endif
+
+#if GCC_VERSION_P(2, 5) || CLANG_VERSION_P(3, 3)
+#  define NORETURN __attribute__((noreturn))
+#  define PRINTF_LIKE(fix, aix) __attribute__((format(printf, fix, aix)))
+#endif
+
+#ifndef NORETURN
+#  define NORETURN
+#endif
+
+#ifndef PRINTF_LIKE
+#  define PRINTF_LIKE
+#endif
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct node {
@@ -65,8 +95,12 @@ extern node *subgram(const char *const */*av*/);
 extern node *wildcard(const char *const */*av*/);
 extern node *trackword(const char *const */*av*/);
 extern node *mono(const char *const */*av*/);
-extern node *regexp(const char *const */*av*/);
-extern node *pcrenode(const char *const */*av*/);
+#ifdef HAVE_REGCOMP
+  extern node *regexp(const char *const */*av*/);
+#endif
+#if defined(HAVE_PCRE) || defined(HAVE_PCRE2)
+  extern node *pcrenode(const char *const */*av*/);
+#endif
 extern node *longest(const char *const */*av*/);
 extern node *shortest(const char *const */*av*/);
 
@@ -114,7 +148,7 @@ extern int pquis(FILE */*fp*/, const char */*p*/);
  * Use:                Reports an error and exits.
  */
 
-extern void die(const char */*f*/, ...);
+extern PRINTF_LIKE(1, 2) NORETURN void die(const char */*f*/, ...);
 
 /*----- Memory allocation -------------------------------------------------*/