Use C99 initialisations for iterators
[exim.git] / src / src / string.c
index 914030775ba660a06ef00c842498a96d8835fc23..739e05fb58784ec03383daa59745d65be7433ba9 100644 (file)
@@ -37,7 +37,6 @@ Returns:    0 if the string is not a textual representation of an IP address
 int
 string_is_ip_address(const uschar *s, int *maskptr)
 {
-int i;
 int yield = 4;
 
 /* If an optional mask is permitted, check for it. If found, pass back the
@@ -60,7 +59,6 @@ if (Ustrchr(s, ':') != NULL)
   {
   BOOL had_double_colon = FALSE;
   BOOL v4end = FALSE;
-  int count = 0;
 
   yield = 6;
 
@@ -73,7 +71,7 @@ if (Ustrchr(s, ':') != NULL)
   may be one and only one appearance of double colon, which implies any number
   of binary zero bits. The number of preceding components is held in count. */
 
-  for (count = 0; count < 8; count++)
+  for (int count = 0; count < 8; count++)
     {
     /* If the end of the string is reached before reading 8 components, the
     address is valid provided a double colon has been read. This also applies
@@ -134,7 +132,7 @@ if (Ustrchr(s, ':') != NULL)
 
 /* Test for IPv4 address, which may be the tail-end of an IPv6 address. */
 
-for (i = 0; i < 4; i++)
+for (int i = 0; i < 4; i++)
   {
   long n;
   uschar * end;
@@ -651,18 +649,16 @@ uschar *t, *yield;
 /* First find the end of the string */
 
 if (*s != '\"')
-  {
   while (*s != 0 && !isspace(*s)) s++;
-  }
 else
   {
   s++;
-  while (*s != 0 && *s != '\"')
+  while (*s && *s != '\"')
     {
     if (*s == '\\') (void)string_interpret_escape(&s);
     s++;
     }
-  if (*s != 0) s++;
+  if (*s) s++;
   }
 
 /* Get enough store to copy into */
@@ -907,7 +903,7 @@ int sep = *separator;
 const uschar *s = *listptr;
 BOOL sep_is_special;
 
-if (s == NULL) return NULL;
+if (!s) return NULL;
 
 /* This allows for a fixed specified separator to be an iscntrl() character,
 but at the time of implementation, this is never the case. However, it's best
@@ -923,19 +919,17 @@ if (sep <= 0)
   if (*s == '<' && (ispunct(s[1]) || iscntrl(s[1])))
     {
     sep = s[1];
-    s += 2;
+    if (*++s) ++s;
     while (isspace(*s) && *s != sep) s++;
     }
   else
-    {
-    sep = (sep == 0)? ':' : -sep;
-    }
+    sep = sep ? -sep : ':';
   *separator = sep;
   }
 
 /* An empty string has no list elements */
 
-if (*s == 0) return NULL;
+if (!*s) return NULL;
 
 /* Note whether whether or not the separator is an iscntrl() character. */
 
@@ -946,20 +940,19 @@ sep_is_special = iscntrl(sep);
 if (buffer)
   {
   int p = 0;
-  for (; *s != 0; s++)
+  for (; *s; s++)
     {
     if (*s == sep && (*(++s) != sep || sep_is_special)) break;
     if (p < buflen - 1) buffer[p++] = *s;
     }
   while (p > 0 && isspace(buffer[p-1])) p--;
-  buffer[p] = 0;
+  buffer[p] = '\0';
   }
 
 /* Handle the case when a buffer is not provided. */
 
 else
   {
-  const uschar *ss;
   gstring * g = NULL;
 
   /* We know that *s != 0 at this point. However, it might be pointing to a
@@ -982,10 +975,11 @@ else
 
   for (;;)
     {
-    for (ss = s + 1; *ss != 0 && *ss != sep; ss++) ;
+    const uschar * ss;
+    for (ss = s + 1; *ss && *ss != sep; ) ss++;
     g = string_catn(g, s, ss-s);
     s = ss;
-    if (*s == 0 || *(++s) != sep || sep_is_special) break;
+    if (!*s || *++s != sep || sep_is_special) break;
     }
   while (g->ptr > 0 && isspace(g->s[g->ptr-1])) g->ptr--;
   buffer = string_from_gstring(g);