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

Bug#284260: marked as done (manpages-dev: wcrtomb function returns incorrect value)



Your message dated Sun, 27 Aug 2006 20:15:14 +0200
with message-id <20060827181511.GA2634@bode.aurel32.net>
and subject line Bug#284260: glibc: wcrtomb function returns incorrect value
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: glibc
Severity: normal


see the manpage - it says this (and the code behaves that way). But that is
incorrect.  The standard behavior does not ignore the wc parameter when s is
NULL:

       A  third  case  is  when s is NULL. In this case wc is ignored, and the
       function effectively returns  wcrtomb(buf,L'\0',ps)  where  buf  is  an
       internal anonymous buffer.

(And because it's used in ncursesw, that breaks some things that I'll have
to work around ;-)

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.4.27-td2
Locale: LANG=C, LC_CTYPE=C


--- End Message ---
--- Begin Message ---
On Wed, Jan 26, 2005 at 09:54:05AM -0500, Thomas Dickey wrote:
> On Wed, 26 Jan 2005, GOTO Masanori wrote:
> 
> >reassign 284260 manpages-dev
> >retitle 284260 wcrtomb function returns incorrect value
> >thanks
> >
> >At Sat, 04 Dec 2004 19:03:04 -0500,
> >Thomas Dickey wrote:
> >>Package: glibc
> >>Severity: normal
> >>
> >>seethe manpage - it says this (and the code behaves that way). But that is
> >>incorrect.  The standard behavior does not ignore the wc parameter when s 
> >>is
> >>NULL:
> >>
> >>       A  third  case  is  when s is NULL. In this case wc is ignored, 
> >>       and the
> >>       function effectively returns  wcrtomb(buf,L'\0',ps)  where  buf  
> >>       is  an
> >>       internal anonymous buffer.
> >>
> >>(And because it's used in ncursesw, that breaks some things that I'll have
> >>to work around ;-)
> >
> >Glibc does not provide such manpage.  I reassigned it to manpages-dev.
> 
> The function, which is incorrect, is part of glibc.  This is not simply
> a documentation problem.
> 

Both the documentation and the code are correct, see the corresponding 
POSIX definition below (page 1658). It clearly says that when s is NULL,
the function shall return wcrtomb(buf, L'\0', ps), which mean wc is
ignored.

I am therefore closing the bug.

|       NAME
| 50238
|             wcrtomb -- convert a wide-character code to a character (restartable)
| 50239
|       SYNOPSIS
| 50240
|             #include <stdio.h>
| 50241
|             size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps);
| 50242
| 50243 DESCRIPTION
|             The functionality described on this reference page is aligned with the ISO C standard.           Any
| 50244 CX
|             conflict between the requirements described here and the ISO C standard is unintentional.        This
| 50245
|             volume of IEEE Std 1003.1-2001 defers to the ISO C standard.
| 50246
|             If s is a null pointer, the wcrtomb( ) function shall be equivalent to the call:
| 50247
|             wcrtomb(buf, L'\0', ps)
| 50248
|             where buf is an internal buffer.
| 50249
|             If s is not a null pointer, the wcrtomb( ) function shall determine the number of bytes needed to
| 50250
|             represent the character that corresponds to the wide character given by wc (including any shift
| 50251
|             sequences), and store the resulting bytes in the array whose first element is pointed to by s. At
| 50252
|             most {MB_CUR_MAX} bytes are stored. If wc is a null wide character, a null byte shall be stored,
| 50253
|             preceded by any shift sequence needed to restore the initial shift state. The resulting state
| 50254
|             described shall be the initial conversion state.
| 50255
|             If ps is a null pointer, the wcrtomb( ) function shall use its own internal mbstate_t object, which is
| 50256
|             initialized at program start-up to the initial conversion state. Otherwise, the mbstate_t object
| 50257
|             pointed to by ps shall be used to completely describe the current conversion state of the
| 50258
|             associated character sequence. The implementation shall behave as if no function defined in this
| 50259
|             volume of IEEE Std 1003.1-2001 calls wcrtomb( ).
| 50260
|             If the application uses any of the _POSIX_THREAD_SAFE_FUNCTIONS or _POSIX_THREADS
| 50261 CX
|             functions, the application shall ensure that the wcrtomb( ) function is called with a non-NULL ps
| 50262
|             argument.
| 50263
|             The behavior of this function shall be affected by the LC_CTYPE category of the current locale.
| 50264
|       RETURN VALUE
| 50265
|             The wcrtomb( ) function shall return the number of bytes stored in the array object (including any
| 50266
|             shift sequences). When wc is not a valid wide character, an encoding error shall occur. In this
| 50267
|             case, the function shall store the value of the macro [EILSEQ] in errno and shall return (size_t)-1;
| 50268
|             the conversion state shall be undefined.


-- 
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

--- End Message ---

Reply to: