summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2014-02-07 16:41:03 +0000
committerRusty Russell <rusty@rustcorp.com.au>2014-02-11 13:09:25 +1030
commit13b374859ed7564c5945ff9e18c7bc0e98d7532e (patch)
tree13cd9856c14ea34124d12c11b2e92851df64ddb0
parent2e26b06e6384c4483dde844cf8991846075e552c (diff)
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>
-rw-r--r--ccan/opt/usage.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ccan/opt/usage.c b/ccan/opt/usage.c
index ff054559..494b179b 100644
--- a/ccan/opt/usage.c
+++ b/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;
}