Bug 106240 - Popt wide character handling for --help is wrong
Summary: Popt wide character handling for --help is wrong
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: popt
Version: GinGin64
Hardware: All
OS: Linux
medium
low
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-10-03 21:21 UTC by Alan Cox
Modified: 2007-04-18 16:58 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-12-30 20:02:28 UTC
Embargoed:


Attachments (Terms of Use)

Description Alan Cox 2003-10-03 21:21:50 UTC
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 14:43:17 UTC
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 15:38:05 UTC
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 14:13:53 UTC
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 16:09:42 UTC
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 17:00:29 UTC
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 17:04:33 UTC
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 18:53:18 UTC
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 20:02:28 UTC
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.