[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] argp: output formatting, and argp_child interface.

From: Bruno Haible
Subject: Re: [bug-gnulib] argp: output formatting, and argp_child interface.
Date: Mon, 9 Jan 2006 14:42:54 +0100
User-agent: KMail/1.5

Paul Knowles wrote on 2005-12-15:
> ******* Problem #1
> struct argp{
>   ...
>   /* A vector of argp_children structures, terminated by a member with a 0
>      argp field, pointing to child argps should be parsed with this one.  Any
>      conflicts are resolved in favor of this argp, or early argps in the
>      CHILDREN list.  This field is useful if you use libraries that supply
>      their own argp structure, which you want to use in conjunction with your
>      own.  */
>   __const struct argp_child *children;
>   ...
> }
> In my opinion, much better would be 
>     struct argp_child **children;
> for the reason that multiparser structures can then have an easy to
> use, scalable, interface.  By adding a function to add children, much
> of the complexity of the multiparser setup will go away.

Sorry, I don't understand. The argp facility is meant for a set of options
known when the program starts. (Otherwise how do you manage to write a
manual page for the program?) Do you mean to add options dynamically?

> ******* Problem #2
> Word wrapping should look at the COLUMNS environment variable to
> determine word wrap unless rmargin=N was explicitly set by the user in 
> ARGP_HELP_FMT.  It is silly that help text gets garbled and squashed
> up into 79 columns on my 110 column xterms and that the resizing is
> not automagic.

I agree. But you can get the desired behaviour yourself: Put the value
of getenv("COLUMNS") into ARGP_HELP_FMT. Roughly like this:

  const char *columns = getenv ("COLUMNS");
  if (columns != NULL && columns[0] != '\0')
      int icolumns = atoi (columns);
      if (icolumns >= 70) /* argp_help doesn't work well when there are too few 
columns */
          const char *old_fmt = getenv ("ARGP_HELP_FMT");
          char *new_fmt =
            concatenate ("rmargin=", atoi (icolumns),
                         old_fmt != NULL && old_fmt[0] != '\0'
                         ? concatenate (",", old_fmt)
                         : "");
          setenv ("ARGP_HELP_FMT", new_fmt, 1);

> *******  Problem 3;
>  I believe I have also stumbled on an output formatting problem, but
> the code to duplicate a test case of this is not yet ready.

Can you provide the test case, please?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]