From: Luke Dashjr Date: Fri, 7 Feb 2014 16:41:03 +0000 (+0000) Subject: opt: accept newline in help strings X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=13b374859ed7564c5945ff9e18c7bc0e98d7532e opt: accept newline in help strings This correctly continues on the next line indented. Signed-off-by: Luke Dashjr Signed-off-by: Rusty Russell --- 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; }