Tidying
[exim.git] / src / src / expand.c
index b96b2897a7061b8d56ca85b16f5008470e508f55..4eb1818f10ab859e9b61a1c9908c2485b3d85626 100644 (file)
@@ -680,6 +680,7 @@ static var_entry var_table[] = {
   { "smtp_active_hostname", vtype_stringptr,  &smtp_active_hostname },
   { "smtp_command",        vtype_stringptr,   &smtp_cmd_buffer },
   { "smtp_command_argument", vtype_stringptr, &smtp_cmd_argument },
+  { "smtp_command_history", vtype_string_func, &smtp_cmd_hist },
   { "smtp_count_at_connection_start", vtype_int, &smtp_accept_count },
   { "smtp_notquit_reason", vtype_stringptr,   &smtp_notquit_reason },
   { "sn0",                 vtype_filter_int,  &filter_sn[0] },
@@ -1554,11 +1555,9 @@ for (i = 0; i < 2; i++)
   int size = 0;
   header_line *h;
 
-  for (h = header_list; size < header_insert_maxlen && h != NULL; h = h->next)
-    {
-    if (h->type != htype_old && h->text != NULL)  /* NULL => Received: placeholder */
-      {
-      if (name == NULL || (len <= h->slen && strncmpic(name, h->text, len) == 0))
+  for (h = header_list; size < header_insert_maxlen && h; h = h->next)
+    if (h->type != htype_old && h->text)  /* NULL => Received: placeholder */
+      if (!name || (len <= h->slen && strncmpic(name, h->text, len) == 0))
         {
         int ilen;
         uschar *t;
@@ -1580,7 +1579,7 @@ for (i = 0; i < 2; i++)
         that contains an address list, except when asked for raw headers. Only
         need to do this once. */
 
-        if (!want_raw && name != NULL && comma == 0 &&
+        if (!want_raw && name && comma == 0 &&
             Ustrchr("BCFRST", h->type) != NULL)
           comma = 1;
 
@@ -1613,8 +1612,6 @@ for (i = 0; i < 2; i++)
             }
           }
         }
-      }
-    }
 
   /* At end of first pass, return NULL if no header found. Then truncate size
   if necessary, and get the buffer to hold the data, returning the buffer size.
@@ -1632,9 +1629,7 @@ for (i = 0; i < 2; i++)
 /* That's all we do for raw header expansion. */
 
 if (want_raw)
-  {
   *ptr = 0;
-  }
 
 /* Otherwise, remove a final newline and a redundant added comma. Then we do
 RFC 2047 decoding, translating the charset if requested. The rfc2047_decode2()
@@ -1838,7 +1833,7 @@ switch (vp->type)
   case vtype_msgbody:                        /* Pointer to msgbody string */
   case vtype_msgbody_end:                    /* Ditto, the end of the msg */
     ss = (uschar **)(val);
-    if (*ss == NULL && deliver_datafile >= 0)  /* Read body when needed */
+    if (!*ss && deliver_datafile >= 0)  /* Read body when needed */
       {
       uschar *body;
       off_t start_offset = SPOOL_DATA_START_OFFSET;
@@ -1871,7 +1866,7 @@ switch (vp->type)
            { if (body[--len] == '\n' || body[len] == 0) body[len] = ' '; }
        }
       }
-    return (*ss == NULL)? US"" : *ss;
+    return *ss ? *ss : US"";
 
   case vtype_todbsdin:                       /* BSD inbox time of day */
     return tod_stamp(tod_bsdin);
@@ -5991,7 +5986,9 @@ while (*s != 0)
         {
        uschar * dstitem;
        uschar * newlist = NULL;
+       int size = 0, len = 0;
        uschar * newkeylist = NULL;
+       int ksize = 0, klen = 0;
        uschar * srcfield;
 
         DEBUG(D_expand) debug_printf_indent("%s: $item = \"%s\"\n", name, srcitem);
@@ -6036,33 +6033,33 @@ while (*s != 0)
            /* New-item sorts before this dst-item.  Append new-item,
            then dst-item, then remainder of dst list. */
 
-           newlist = string_append_listele(newlist, sep, srcitem);
-           newkeylist = string_append_listele(newkeylist, sep, srcfield);
+           newlist = string_append_listele(newlist, &size, &len, sep, srcitem);
+           newkeylist = string_append_listele(newkeylist, &ksize, &klen, sep, srcfield);
            srcitem = NULL;
 
-           newlist = string_append_listele(newlist, sep, dstitem);
-           newkeylist = string_append_listele(newkeylist, sep, dstfield);
+           newlist = string_append_listele(newlist, &size, &len, sep, dstitem);
+           newkeylist = string_append_listele(newkeylist, &ksize, &klen, sep, dstfield);
 
            while ((dstitem = string_nextinlist(&dstlist, &sep, NULL, 0)))
              {
              if (!(dstfield = string_nextinlist(&dstkeylist, &sep, NULL, 0)))
                goto sort_mismatch;
-             newlist = string_append_listele(newlist, sep, dstitem);
-             newkeylist = string_append_listele(newkeylist, sep, dstfield);
+             newlist = string_append_listele(newlist, &size, &len, sep, dstitem);
+             newkeylist = string_append_listele(newkeylist, &ksize, &klen, sep, dstfield);
              }
 
            break;
            }
 
-         newlist = string_append_listele(newlist, sep, dstitem);
-         newkeylist = string_append_listele(newkeylist, sep, dstfield);
+         newlist = string_append_listele(newlist, &size, &len, sep, dstitem);
+         newkeylist = string_append_listele(newkeylist, &ksize, &klen, sep, dstfield);
          }
 
        /* If we ran out of dstlist without consuming srcitem, append it */
        if (srcitem)
          {
-         newlist = string_append_listele(newlist, sep, srcitem);
-         newkeylist = string_append_listele(newkeylist, sep, srcfield);
+         newlist = string_append_listele(newlist, &size, &len, sep, srcitem);
+         newkeylist = string_append_listele(newkeylist, &ksize, &klen, sep, srcfield);
          }
 
        dstlist = newlist;