Back to index

glibc  2.9
Functions
tst-mbswcs6.c File Reference
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>

Go to the source code of this file.

Functions

static int do_test (const char *loc)
int main (void)

Function Documentation

static int do_test ( const char *  loc) [static]

Definition at line 29 of file tst-mbswcs6.c.

{
  char buf[100];
  size_t n;
  mbstate_t state;
  const char *nloc;
  int res;

  nloc = setlocale (LC_ALL, loc);
  if (nloc == NULL)
    {
      printf ("could not set locale \"%s\"\n", loc);
      return 1;
    }
  printf ("new locale: %s\n", nloc);

  memset (&state, '\0', sizeof (state));
  errno = 0;
  n = wcrtomb (buf, (wchar_t) -15l, &state);

  printf ("n = %zd, errno = %d (%s)\n", n, errno, strerror (errno));

  res = n != (size_t) -1 || errno != EILSEQ;
  if (res)
    puts ("*** FAIL");
  putchar ('\n');

  return res;
}

Here is the call graph for this function:

int main ( void  )

Definition at line 61 of file tst-mbswcs6.c.

{
  int res;

  res = do_test ("C");
  res |= do_test ("de_DE.ISO-8859-1");
  res |= do_test ("de_DE.UTF-8");
  res |= do_test ("en_US.ANSI_X3.4-1968");
  res |= do_test ("ja_JP.EUC-JP");
  res |= do_test ("hr_HR.ISO-8859-2");
  //res |= do_test ("ru_RU.KOI8-R");

  return res;
}