~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to iconvdata/bug-iconv8.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// BZ 12601
2
 
#include <stdio.h>
3
 
#include <errno.h>
4
 
#include <iconv.h>
5
 
 
6
 
static int
7
 
do_test (void)
8
 
{
9
 
   iconv_t cd;
10
 
   char in[] = "\x83\xd9";
11
 
   char out[256];
12
 
   char *inbuf;
13
 
   size_t inbytesleft;
14
 
   char *outbuf;
15
 
   size_t outbytesleft;
16
 
   size_t ret;
17
 
 
18
 
   inbuf = in;
19
 
   inbytesleft = sizeof(in) - 1;
20
 
   outbuf = out;
21
 
   outbytesleft = sizeof(out);
22
 
 
23
 
   cd = iconv_open("utf-8", "cp932");
24
 
   ret = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
25
 
   iconv_close(cd);
26
 
 
27
 
   printf("result: %ld %d %ld %d\n", ret, errno, inbytesleft, inbuf[0]);
28
 
 
29
 
   /*
30
 
    * result: -1 84 0 0        (84=EILSEQ)
31
 
    *
32
 
    * Error is returnd but inbuf is consumed.
33
 
    *
34
 
    * \x83\xd9 is valid shift-jis sequence but no character is assigned
35
 
    * to it.
36
 
    */
37
 
 
38
 
   return (ret != -1 || errno != EILSEQ
39
 
           || inbytesleft != 2 || inbuf[0] != in[0]);
40
 
}
41
 
 
42
 
#define TEST_FUNCTION do_test ()
43
 
#include "../test-skeleton.c"