Browse Source

opt: accept newline in help strings

This correctly continues on the next line indented.

Signed-off-by: Luke Dashjr <luke-jr+git@utopios.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Luke Dashjr 12 years ago
parent
commit
13b374859e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      ccan/opt/usage.c

+ 4 - 2
ccan/opt/usage.c

@@ -47,7 +47,7 @@ static size_t consume_words(const char *words, size_t maxlen, size_t *prefix)
 	size_t oldlen, len;
 
 	/* Swallow leading whitespace. */
-	*prefix = strspn(words, " ");
+	*prefix = strspn(words, " \n");
 	words += *prefix;
 
 	/* Use at least one word, even if it takes us over maxlen. */
@@ -55,7 +55,9 @@ static size_t consume_words(const char *words, size_t maxlen, size_t *prefix)
 	while (len <= maxlen) {
 		oldlen = len;
 		len += strspn(words+len, " ");
-		len += strcspn(words+len, " ");
+		if (words[len] == '\n')
+			break;
+		len += strcspn(words+len, " \n");
 		if (len == oldlen)
 			break;
 	}