/* 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 */
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
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. */
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. */
for (;;)
{
- for (ss = s + 1; *ss != 0 && *ss != sep; 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);
{
/* Avoid string_copyn() due to COMPILE_UTILITY */
if (g->ptr >= lim - 1)
- if (extend) gstring_grow(g, g->ptr, 1); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, 1);
+ lim = g->size - 1;
+ }
g->s[g->ptr++] = (uschar) *fp++;
continue;
}
case 'X':
width = length > L_LONG ? 24 : 12;
if (g->ptr >= lim - width)
- if (extend) gstring_grow(g, g->ptr, width); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, width);
+ lim = g->size - 1;
+ gp = CS g->s + g->ptr;
+ }
strncpy(newformat, item_start, fp - item_start);
newformat[fp - item_start] = 0;
{
void * ptr;
if (g->ptr >= lim - 24)
- if (extend) gstring_grow(g, g->ptr, 24); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, 24);
+ lim = g->size - 1;
+ gp = CS g->s + g->ptr;
+ }
/* sprintf() saying "(nil)" for a null pointer seems unreliable.
Handle it explicitly. */
if ((ptr = va_arg(ap, void *)))
case 'G':
if (precision < 0) precision = 6;
if (g->ptr >= lim - precision - 8)
- if (extend) gstring_grow(g, g->ptr, precision+8); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, precision+8);
+ lim = g->size - 1;
+ gp = CS g->s + g->ptr;
+ }
strncpy(newformat, item_start, fp - item_start);
newformat[fp-item_start] = 0;
if (length == L_LONGDOUBLE)
case '%':
if (g->ptr >= lim - 1)
- if (extend) gstring_grow(g, g->ptr, 1); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, 1);
+ lim = g->size - 1;
+ }
g->s[g->ptr++] = (uschar) '%';
break;
case 'c':
if (g->ptr >= lim - 1)
- if (extend) gstring_grow(g, g->ptr, 1); else return NULL;
+ {
+ if (!extend) return NULL;
+ gstring_grow(g, g->ptr, 1);
+ lim = g->size - 1;
+ }
g->s[g->ptr++] = (uschar) va_arg(ap, int);
break;
}
}
else if (g->ptr >= lim - width)
- gstring_grow(g, g->ptr, width);
+ {
+ gstring_grow(g, g->ptr, width - (lim - g->ptr));
+ lim = g->size - 1;
+ gp = CS g->s + g->ptr;
+ }
g->ptr += sprintf(gp, "%*.*s", width, precision, s);
if (fp[-1] == 'S')