Expansions: more detail in error messages
[exim.git] / src / src / readconf.c
index 6f97dad69c27f005cc03a25c943a844e5aa3a1e2..e52f45fcaa268b3c6abcdc78533f0355e2229d02 100644 (file)
@@ -4275,7 +4275,7 @@ int indent = 0;
 
 for (i = config_lines; i; i = i->next)
   {
-  const uschar *current;
+  uschar *current;
   uschar *p;
 
   /* skip over to the first non-space */
@@ -4285,7 +4285,23 @@ for (i = config_lines; i; i = i->next)
   if (*current == '\0')
     continue;
 
-  /* TODO: Collapse or insert spaces around the first '=' */
+  /* Collapse runs of spaces. We stop this if we encounter one of the
+   * following characters: "'$, as this may indicate careful formatting */
+  for (p = current; *p; ++p)
+    {
+    uschar *next;
+    if (!isspace(*p)) continue;
+    if (*p != ' ') *p = ' ';
+
+    for (next = p; isspace(*next); ++next)
+      ;
+
+    if (next - p > 1)
+      memmove(p+1, next, strlen(next)+1);
+
+    if (*next == '"' || *next == '\'' || *next == '$')
+      break;
+    }
 
   /* # lines */
   if (current[0] == '#')
@@ -4294,28 +4310,29 @@ for (i = config_lines; i; i = i->next)
   /* begin lines are left aligned */
   else if (Ustrncmp(current, "begin", 5) == 0 && isspace(current[5]))
     {
+    puts("");
     puts(CCS current);
     indent = TS;
     }
 
   /* router/acl/transport block names */
-  else if (current[strlen(current)-1] == ':' && !Ustrchr(current, '='))
+  else if (current[Ustrlen(current)-1] == ':' && !Ustrchr(current, '='))
     {
-    printf("%*s%s\n", TS, "", current);
+    printf("\n%*s%s\n", TS, "", current);
     indent = 2 * TS;
     }
 
-  /* hidden lines (MACROS or prefixed with hide) */
+  /* hidden lines (all MACROS or lines prefixed with "hide") */
   else if (  !admin
          && (  isupper(*current)
             || Ustrncmp(current, "hide", 4) == 0 && isspace(current[4])
             )
          )
     {
-    if (p = Ustrchr(current, '='))
+    if ((p = Ustrchr(current, '=')))
       {
       *p = '\0';
-      printf("%*s%s = %s\n", indent, "", current, hidden);
+      printf("%*s%s= %s\n", indent, "", current, hidden);
       }
     /* e.g.: hide split_spool_directory */
     else