From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8684 invoked by alias); 26 Apr 2012 17:28:33 -0000 Received: (qmail 8667 invoked by uid 22791); 26 Apr 2012 17:28:32 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 Apr 2012 17:28:19 +0000 From: "mark-sourceware at glines dot org" To: glibc-bugs@sources.redhat.com Subject: [Bug libc/14024] argp: mis-formatted --help output Date: Thu, 26 Apr 2012 17:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark-sourceware at glines dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00348.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=14024 --- Comment #3 from Mark Glines 2012-04-26 17:28:13 UTC --- I've done some preliminary analysis of this issue. It appears that __argp_fmtstream_update attempts to insert leading whitespace to indent the remainder of an option's description (argp/argp-fmtstream.c:131). However, when the buffer does not have enough space for the additional whitespace, the whitespace is instead printed directly to the output stream (argp/argp-fmtstream.c:144). When the buffer contained previous data that had not been written to the output stream yet, this results in the output being printed out of order, appearing mis-formatted to the user. It's not immediately clear how to solve this. The issue seems to be that __argp_fmtstream_update can insert data into the buffer, but has no means to grow the buffer if necessary. The normal means of growing the buffer (__argp_fmtstream_ensure) is a caller of __argp_fmtstream_update. One option to fix this would be to flush the formatted output from the buffer (if any), and then try again. A second option would be to allocate a larger buffer, either duplicating the buffer-expansion code in __argp_fmtstream_ensure, or splitting it out into a third function which both can use. A third option would be to change __argp_fmtstream_update to return an int (currently it returns void), and have it return the amount of formatted text in this case, so that __argp_fmtstream_ensure can only write the formatted subset of the data in the buffer. This option seems like it would have a higher impact, as __argp_fmtstream_update has multiple callers. File names and line numbers in the above text are referring to the argp code as it was in today's git, revision 0ac229c819afd15ba323838ba72d0a409f16acc4. -- 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.