changeset 7997:0d66b44689ee HEAD

Fixed compiling on some older pre-C99 compilers.
author Timo Sirainen <tss@iki.fi>
date Sat, 12 Jul 2008 16:24:47 +0300
parents fa90c913eae4
children c69ccedfaf4a
files configure.in src/lib-imap/imap-match.c src/lib/str-find.c
diffstat 3 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Sat Jul 12 16:16:19 2008 +0300
+++ b/configure.in	Sat Jul 12 16:24:47 2008 +0300
@@ -1020,6 +1020,25 @@
   AC_DEFINE(TIME_T_SIGNED,, Define if your time_t is signed)
 fi
 
+dnl Our implementation of AC_C_FLEXIBLE_ARRAY_MEMBER.
+dnl Use it until autoconf 2.61+ becomes more widely used
+AC_MSG_CHECKING([if we can use C99-like flexible array members])
+AC_TRY_COMPILE([
+  struct foo {
+    int x;
+    char y[];
+  };
+], [
+  struct foo foo;
+], [
+  flexible_value=""
+  AC_MSG_RESULT(yes)
+], [
+  flexible_value=1
+  AC_MSG_RESULT(no)
+])
+AC_DEFINE_UNQUOTED(FLEXIBLE_ARRAY_MEMBER, $flexible_value, How to define flexible array members in structs)
+
 dnl * do we have struct iovec
 AC_MSG_CHECKING([for struct iovec])
 AC_CACHE_VAL(i_cv_struct_iovec,
--- a/src/lib-imap/imap-match.c	Sat Jul 12 16:16:19 2008 +0300
+++ b/src/lib-imap/imap-match.c	Sat Jul 12 16:24:47 2008 +0300
@@ -19,7 +19,7 @@
 	struct imap_match_pattern *patterns;
 
 	char sep;
-	char patterns_data[];
+	char patterns_data[FLEXIBLE_ARRAY_MEMBER];
 };
 
 struct imap_match_context {
--- a/src/lib/str-find.c	Sat Jul 12 16:16:19 2008 +0300
+++ b/src/lib/str-find.c	Sat Jul 12 16:24:47 2008 +0300
@@ -14,7 +14,7 @@
 	unsigned int match_count;
 
 	int badtab[UCHAR_MAX+1];
-	int goodtab[];
+	int goodtab[FLEXIBLE_ARRAY_MEMBER];
 };
 
 static void init_badtab(struct str_find_context *ctx)