[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Lining up option descriptions in cmdline binary help

From: Peter Mathiasson <peter_at_mathiasson.nu>
Date: 2002-04-14 10:18:07 CEST

On Sun, Apr 14, 2002 at 02:04:23AM -0500, cmpilato@collab.net wrote:
> + /* If there exists documentation for the option, add this to the
> + string as well, starting at the sizeof(optsw)'th column. */
> if (doc)
> - opts = apr_pstrcat (pool, opts, ":\t", opt->description, NULL);
> + {
> + int opts_len = strlen (opts);
> + int optsw_len = sizeof (optsw) / sizeof (*optsw);
> + int i;
> +
> + /* Pad the existing OPTS string up to sizeof(optsw) with, well,
> + spaces. */
> + for (i = 0; i < (optsw_len - 1); i++)
> + optsw[i] = ((i < opts_len) ? opts[i] : ' ');
> +
> + optsw[optsw_len - 1] = 0;
> + opts = apr_psprintf (pool, "%s : %s", optsw, opt->description);
> + }

Wouldn't it be easier just to use length specifier with sprintf? (I'm
not familiar with apr_psprintf, but I can't imagine that has been
removed).
Like sprintf("%-50s : %s",optsw,opt->description);

-- 
Peter Mathiasson, peter at mathiasson dot nu, http://www.mathiasson.nu
GPG Fingerprint: A9A7 F8F6 9821 F415 B066 77F1 7FF5 C2E6 7BF2 F228

  • application/pgp-signature attachment: stored
Received on Sun Apr 14 10:19:14 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.