Use correct spacing when printing out config file parsing
authorAlan T. DeKok <aland@freeradius.org>
Sun, 17 Mar 2013 03:50:01 +0000 (23:50 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 17 Mar 2013 03:55:16 +0000 (23:55 -0400)
use spaces, not tabs
use %.*s for CONF_PAIRS, too.  Otherwise their indentation
doesn't match that of the parent CONF_SECTION

src/main/conffile.c

index 13fb3a4..d782b67 100644 (file)
@@ -876,6 +876,8 @@ static const char *cf_expand_variables(const char *cf, int *lineno,
        return output;
 }
 
+static const char *parse_spaces = "                                                                                                                                                                                                                                                                ";
+
 
 /*
  *     Parses an item (not a CONF_ITEM) into the specified format,
@@ -927,12 +929,14 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                        radlog(L_ERR, "Bad value \"%s\" for boolean variable %s", value, name);
                        return -1;
                }
-               cf_log_info(cs, "\t%s = %s", name, value);
+               cf_log_info(cs, "%.*s\t%s = %s",
+                           cs->depth, parse_spaces, name, value);
                break;
 
        case PW_TYPE_INTEGER:
                *(int *)data = strtol(value, 0, 0);
-               cf_log_info(cs, "\t%s = %d", name, *(int *)data);
+               cf_log_info(cs, "%.*s\t%s = %d",
+                           cs->depth, parse_spaces, name, *(int *)data);
                break;
 
        case PW_TYPE_STRING_PTR:
@@ -966,7 +970,8 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                        }
                }
 
-               cf_log_info(cs, "\t%s = \"%s\"", name, value ? value : "(null)");
+               cf_log_info(cs, "%.*s\t%s = \"%s\"",
+                           cs->depth, parse_spaces, name, value ? value : "(null)");
                *q = value ? strdup(value) : NULL;
                break;
 
@@ -1001,7 +1006,8 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                        if (!value) return -1;
                }
 
-               cf_log_info(cs, "\t%s = \"%s\"", name, value ? value : "(null)");
+               cf_log_info(cs, "%.*s\t%s = \"%s\"",
+                           cs->depth, parse_spaces, name, value ? value : "(null)");
                *q = value ? strdup(value) : NULL;
 
                /*
@@ -1032,7 +1038,8 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                 */
                if (strcmp(value, "*") == 0) {
                        *(uint32_t *) data = htonl(INADDR_ANY);
-                       cf_log_info(cs, "\t%s = *", name);
+                       cf_log_info(cs, "%.*s\t%s = *",
+                                   cs->depth, parse_spaces, name);
                        break;
                }
                if (ip_hton(value, AF_INET, &ipaddr) < 0) {
@@ -1041,9 +1048,11 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                }
                
                if (strspn(value, "0123456789.") == strlen(value)) {
-                       cf_log_info(cs, "\t%s = %s", name, value);
+                       cf_log_info(cs, "%.*s\t%s = %s",
+                                   cs->depth, parse_spaces, name, value);
                } else {
-                       cf_log_info(cs, "\t%s = %s IP address [%s]", name, value,
+                       cf_log_info(cs, "%.*s\t%s = %s IP address [%s]",
+                                   cs->depth, parse_spaces, name, value,
                               ip_ntoh(&ipaddr, ipbuf, sizeof(ipbuf)));
                }
                *(uint32_t *) data = ipaddr.ipaddr.ip4addr.s_addr;
@@ -1054,8 +1063,9 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
                        radlog(L_ERR, "Can't find IPv6 address for host %s", value);
                        return -1;
                }
-               cf_log_info(cs, "\t%s = %s IPv6 address [%s]", name, value,
-                              ip_ntoh(&ipaddr, ipbuf, sizeof(ipbuf)));
+               cf_log_info(cs, "%.*s\t%s = %s IPv6 address [%s]",
+                           cs->depth, parse_spaces, name, value,
+                           ip_ntoh(&ipaddr, ipbuf, sizeof(ipbuf)));
                memcpy(data, &ipaddr.ipaddr.ip6addr,
                       sizeof(ipaddr.ipaddr.ip6addr));
                break;
@@ -1078,7 +1088,6 @@ int cf_item_parse(CONF_SECTION *cs, const char *name,
        return rcode;
 }
 
-static const char *parse_spaces = "                                                                                                                                                                                                                                                                ";
 
 /*
  *     A copy of cf_section_parse that initializes pointers before