Bug 106240 - Popt wide character handling for --help is wrong
Popt wide character handling for --help is wrong
Status: CLOSED NEXTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: popt (Show other bugs)
GinGin64
All Linux
medium Severity low
: ---
: ---
Assigned To: Jeff Johnson
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-03 17:21 EDT by Alan Cox
Modified: 2007-04-18 12:58 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-12-30 15:02:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alan Cox 2003-10-03 17:21:50 EDT
popt misformats --help output when the help data includes multibyte characters
(eg redhat-config-date in Welsh). It looks like popt is using strlen() to work
out the amount of padding to use rather than wcslen()
Comment 1 Jeff Johnson 2003-12-28 09:43:17 EST
You're correct that popt does not use wcslen().

Hmmm, any suggestions for a CLI executable to try
   LANG=cy_CY foo --help
testing? That appears not to be system-config-date.
Comment 2 Alan Cox 2003-12-28 10:38:05 EST
I don't have a handy cy_GB.UTF-8 one for testing. I'll ask Dafydd for
suggestions.
Comment 3 Alan Cox 2003-12-29 09:13:53 EST
Test case courtesy of Telsa

LANG=cy_GB.UTF-8 gnome-terminal

and look at the entry

"--screen=SGRÎN"

Comment 4 Jeff Johnson 2003-12-30 11:09:42 EST
Thanks Telsa.

What is failure case? Alignment looks OK (as I would expect from
utf-8). I do not see SGRIN rendered properly. That's the failure?
Comment 5 Alan Cox 2003-12-30 12:00:29 EST
Stick the terminal you are running it in into UTF8 first and you
should see the SGRÎN rendered correctly and the position now wrong. If
your terminal is in an old 8bit mode it'll render the UTF8 multibyte
symbol as 2 chars so hide the real bug
Comment 6 Jeff Johnson 2003-12-30 12:04:33 EST
Thanks for confirm. Now to see if I can
get this bug pasted against popt so I can find
Comment 7 Jeff Johnson 2003-12-30 13:53:18 EST
Hmmm, some cures are worse than the disease, I feel a twinge
of BCE tickling my brain stem:

OK, I have display width calculated independently of strlen by doing
(per info libc):

    /* XXX Calculate no. of display characters. */
    if (argDescrip) {
        const char * scopy = argDescrip;
        mbstate_t t;
                                                                     
          
        memset (&t, '\0', sizeof (t));  /* In initial state.  */
        /* Determine number of characters.  */
        len += sizeof("=")-1;
        len += mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
    }

This does not catch the different display size of the SGRIN string
(but does fire on a different case). To be specific, mbsrtowcs and
strlen are returning identical values.

So is there a chance that the display size table for those
multi-byte cy_GB.UTF-8 characters might be wrong?
Comment 8 Jeff Johnson 2003-12-30 15:02:28 EST
Hmmm, --screen (and also the other case, --role) now
align. In CVS, should be in popt-1.8.2-0.9 and later.

Note You need to log in before you can comment on or make changes to this bug.