This is the mail archive of the libc-alpha@sourceware.cygnus.com 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]

assertion failed in mbsnrtowcs



In glibc-2000-04-12, there is a bug in mbsnrtowcs: The test program

====================== test_utf8_mbsnrtowcs.c =============================
/* Test restarting behaviour of mbsnrtowcs. */

#define _GNU_SOURCE /* needed for mbsnrtowcs declaration */
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>

#define show(expr)  printf(#expr " -> %d",expr); printf(", wc = %u, src = buf+%d\n",wc,src-(const char *)buf);

int main ()
{
  unsigned char buf [6] = { 0x25,  0xe2, 0x82, 0xac,  0xce, 0xbb };
  mbstate_t state;
  const char * src;
  wchar_t wc = 42;

  setlocale(LC_CTYPE,"de_DE.UTF-8");
  memset(&state,0,sizeof(state));
  src = (const char *) buf;
  show(mbsnrtowcs(&wc,&src,1,1,&state));
  show(mbsnrtowcs(&wc,&src,3,1,&state));
  show(mbsnrtowcs(&wc,&src,1,1,&state));
  show(mbsnrtowcs(&wc,&src,1,1,&state));

  return 0;
}

/* Expected output:

mbsnrtowcs(&wc,&src,1,1,&state) -> 1, wc = 37, src = buf+1
mbsnrtowcs(&wc,&src,3,1,&state) -> 1, wc = 8364, src = buf+4
mbsnrtowcs(&wc,&src,1,1,&state) -> 0, wc = 8364, src = buf+5
mbsnrtowcs(&wc,&src,1,1,&state) -> 1, wc = 955, src = buf+6

*/
===========================================================================

$ localedef -c -f UTF8 -i de_DE de_DE.UTF-8
$ ./test_utf8_mbsnrtowcs

gives

test_utf8_mbsnrtowcs: mbsnrtowcs.c:119: __mbsnrtowcs: Assertion `status == __GCONV_OK || status != __GCONV_EMPTY_INPUT || status == __GCONV_ILLEGAL_INPUT || status == __GCONV_INCOMPLETE_INPUT || status == __GCONV_FULL_OUTPUT' failed.
Aborted (core dumped)

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