]> git.draconx.ca Git - dxcommon.git/blobdiff - src/help.c
help_print_desc: Simplify implementation.
[dxcommon.git] / src / help.c
index 4b77b2ce2e78587df19e0548ee2dea49bb4b9d1b..3aa083003a03710560976034a209cc44b2f5cb3a 100644 (file)
@@ -202,17 +202,11 @@ void help_print_desc(const struct option *opt, const char *s, int i, int w)
        if (opt)
                s = pgettext_expr(opt->name, s);
 
-       if (i && s[0] == '\0')
-               putchar('\n');
-
-       for (; *s; w = 0) {
-               const char *nl = strchr(s, '\n');
-               int n = (nl ? nl-s : -1);
+       do {
+               size_t n = strcspn(s, "\n");
 
-               printf("%*s%.*s\n", i-w, "", n, s);
-               if (!nl)
-                       break;
-
-               s = nl+1;
-       }
+               printf("%*s%.*s\n", n ? i-w : 0, "", (int)n, s);
+               s += n + (s[n] != '\0');
+               w = 0;
+       } while (*s);
 }