iconv_close (cd);
main (void){  const char *file;  char *mem;  char *umem;  size_t memlen;  int fd;  struct stat st;#ifdef _POSIX_CPUTIME  unsigned int sum = 0;#endif  size_t offset;  int result;  char *inmem;  char *outmem;  size_t inlen;  size_t outlen;  iconv_t cd;  char *expr;  char *uexpr;  mtrace ();  /* Make the content of the file available in memory.  */  file = "../ChangeLog.8";  fd = open (file, O_RDONLY);  if (fd == -1)    error (EXIT_FAILURE, errno, "cannot open %s", basename (file));  if (fstat (fd, &st) != 0)    error (EXIT_FAILURE, errno, "cannot stat %s", basename (file));  memlen = st.st_size;  mem = (char *) malloc (memlen + 1);  if (mem == NULL)    error (EXIT_FAILURE, errno, "while allocating buffer");  if (read (fd, mem, memlen) != memlen)    error (EXIT_FAILURE, 0, "cannot read entire file");  mem[memlen] = '\0';  close (fd);#ifdef _POSIX_CPUTIME  /* If possible we will time the regex calls.  */  use_clock = clock_getcpuclockid (0, &cl) == 0;  /* Now make sure the file is actually loaded.  */  if (use_clock)    {      for (offset = 0; offset < memlen; ++offset)	sum += mem[offset];      /* We print it so that the compiler cannnot optimize the loop away.  */      printf ("sum = %u\n", sum);    }#endif  /* First test: search with an ISO-8859-1 locale.  */  if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)    error (EXIT_FAILURE, 0, "cannot set locale de_DE.ISO-8859-1");  /* This is the expression we'll use.  */  expr = "[]";  puts ("\nTest with 8-bit locale");  result = run_test (expr, mem, memlen);  /* Second test: search with an UTF-8 locale.  */  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)    error (EXIT_FAILURE, 0, "cannot set locale de_DE.UTF-8");  /* For the second test we have to convert the file to UTF-8.  */  umem = (char *) malloc (2 * memlen);  if (umem == NULL)    error (EXIT_FAILURE, errno, "while allocating buffer");  cd = iconv_open ("UTF-8", "ISO-8859-1");  if (cd == (iconv_t) -1)    error (EXIT_FAILURE, errno, "cannot get conversion descriptor");  inmem = mem;  inlen = memlen;  outmem = umem;  outlen = 2 * memlen;  iconv (cd, &inmem, &inlen, &outmem, &outlen);  if (inlen != 0)    error (EXIT_FAILURE, errno, "cannot convert buffer");  inmem = expr;  inlen = strlen (expr);  outlen = inlen * MB_CUR_MAX;  outmem = uexpr = alloca (outlen + 1);  iconv (cd, &inmem, &inlen, &outmem, &outlen);  if (inlen != 0)    error (EXIT_FAILURE, errno, "cannot convert expression");  iconv_close (cd);  /* Run the tests.  */  puts ("\nTest with multi-byte locale");  result |= run_test (uexpr, umem, 2 * memlen - outlen);  /* Free the resources.  */  free (mem);  return result;}