This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/14024] New: argp: mis-formatted --help output


http://sourceware.org/bugzilla/show_bug.cgi?id=14024

             Bug #: 14024
           Summary: argp: mis-formatted --help output
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: mark-sourceware@glines.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Apologies if this is logged against the wrong component, please reassign as
needed.

The argp feature can sometimes generate mis-formatted --help output.  I've
reproduced this in glibc 2.3.4 (RHEL), libc6 2.13-20 (Ubuntu), and in the git
master branch (as of 2012-04-26).  A combination of conditions seem to be
needed to trigger the problem:

* Manual line wrapping must occur due to the option description containing a
newline
* Automatic line wrapping of an option description must occur due to the
remaining text going past the right margin
* The argp_fmtstream_t buffer must be too small (or have too much preceding
text in it) for the new prefix whitespace to fit

I will attach a test program that triggers the issue.  I will also provide more
details of how it goes wrong - I've done some analysis of the problem but not
enough to know the best way to fix it.

The mis-formatted output looks like:

$ ./test
Usage: test [OPTION...] 
tttttttttttttttttt

      --a                    bbbbbbbbbbbbbbbbb
      --cc                             =d                 eeeeeeeeeeeeeeeee
  -f, --g                    hhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
                             jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
  -?, --help                 Give this help list
      --usage                Give a short usage message


The expected output should be:

$ ./test
Usage: test [OPTION...] 
tttttttttttttttttt

      --a                    bbbbbbbbbbbbbbbbb
      --cc=d                 eeeeeeeeeeeeeeeee
  -f, --g                    hhhhhhhhhhhhhhhhhhhh
                             iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
                             jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
  -?, --help                 Give this help list
      --usage                Give a short usage message


When the problem occurs, the prefix whitespace for the "i" line has been moved
to appear between "--cc" and "=d".  Shortening any of the text strings causes
the correct output to be emitted.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]