[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: Sander Striker <striker_at_apache.org>
Date: 2002-04-14 10:34:06 CEST

> From: Peter Mathiasson [mailto:peter@mathiasson.nu]
> Sent: 14 April 2002 10:18

> 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);

Duh. Sometimes things are so simple, you don't think of them ;)
Thanks Peter.

Sander

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Apr 14 10:27:50 2002

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