config: Allow multi-word config values

None of the presently existing config keys need it, but in order to
support configuring multiple channels of the Aspeed UART-routing mux it
will be useful to be able to have multiple (space-separated) words in a
config value (whereas previously the value was truncated at the first
space).  The '#' comment character is respected as terminating the
value, however.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I2ab6f16efb2f0bed1041d79b1766136df939350d
diff --git a/config.c b/config.c
index 242311e..3b8aef9 100644
--- a/config.c
+++ b/config.c
@@ -70,6 +70,7 @@
 
 	for (p = NULL, line = strtok_r(buf, "\n", &p); line;
 	     line = strtok_r(NULL, "\n", &p)) {
+		char *end;
 		int rc;
 
 		/* trim leading space */
@@ -85,7 +86,7 @@
 		name = malloc(strlen(line));
 		value = malloc(strlen(line));
 		if (name && value) {
-			rc = sscanf(line, "%[^ =] = %s ", name, value);
+			rc = sscanf(line, "%[^ =] = %[^#]s", name, value);
 		} else {
 			rc = -ENOMEM;
 		}
@@ -96,6 +97,12 @@
 			continue;
 		}
 
+		/* trim trailing space */
+		end = value + strlen(value) - 1;
+		while (isspace(*end)) {
+			*end-- = '\0';
+		}
+
 		/* create a new item and add to our list */
 		item = malloc(sizeof(*item));
 		item->name = name;