author | Rich Burridge <rich.burridge@oracle.com> |
Fri, 06 Feb 2015 12:30:31 -0800 | |
changeset 3744 | a74b6fa1af7a |
parent 402 | 94ae4d75524c |
permissions | -rw-r--r-- |
402
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
1 |
--- stdcxx-4.2.1/src/wcodecvt.cpp 2008-04-24 17:25:19.000000000 -0700 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
2 |
+++ stdcxx-4.2.1/src/wcodecvt.cpp 2011-02-04 07:26:31.881614906 -0800 |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
3 |
@@ -351,6 +351,8 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
4 |
wchar_t *to_limit, |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
5 |
wchar_t* &to_next) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
6 |
{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
7 |
+ int save_errno; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
8 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
9 |
_RWSTD_ASSERT (from <= from_end); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
10 |
_RWSTD_ASSERT (to <= to_limit); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
11 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
12 |
@@ -371,7 +373,9 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
13 |
_RWSTD_SIZE_T nbytes; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
14 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
15 |
#ifndef _RWSTD_NO_MBRTOWC |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
16 |
+ errno = 0; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
17 |
nbytes = mbrtowc (pdst, psrc, src_len, &state); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
18 |
+ save_errno = errno; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
19 |
#elif !defined (_RWSTD_NO_MBTOWC) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
20 |
nbytes = mbtowc (pdst, psrc, src_len); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
21 |
#else |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
22 |
@@ -379,7 +383,7 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
23 |
#endif |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
24 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
25 |
// -1 indicates an invalid sequence (i.e., error) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
26 |
- if (nbytes == (_RWSTD_SIZE_T)(-1)) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
27 |
+ if ((nbytes == (_RWSTD_SIZE_T)(-1)) || (EILSEQ == save_errno)) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
28 |
res = _STD::codecvt_base::error; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
29 |
break; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
30 |
} |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
31 |
@@ -428,6 +432,8 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
32 |
char *to_limit, |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
33 |
char* &to_next) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
34 |
{ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
35 |
+ int save_errno; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
36 |
+ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
37 |
_RWSTD_ASSERT (from <= from_end); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
38 |
_RWSTD_ASSERT (to <= to_limit); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
39 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
40 |
@@ -476,10 +482,12 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
41 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
42 |
#ifndef _RWSTD_NO_WCRTOMB |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
43 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
44 |
+ errno = 0; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
45 |
// convert the next source character (note that it would be |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
46 |
// unsafe to use wcsrtombs() since the source sequence may |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
47 |
// not be NUL terminated) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
48 |
dst_len = wcrtomb (tmpdst, *from_next, &state); |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
49 |
+ save_errno = errno; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
50 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
51 |
#elif !defined (_RWSTD_NO_WCTOMB) |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
52 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
53 |
@@ -494,7 +502,7 @@ |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
54 |
#endif // _RWSTD_NO_WCRTOMB, _RWSTD_NO_WCTOMB |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
55 |
|
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
56 |
// -1 is returned as an indication of an illegal sequence |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
57 |
- if (_RWSTD_SIZE_MAX == dst_len) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
58 |
+ if (((_RWSTD_SIZE_T) (-1) == dst_len) || (EILSEQ == save_errno)) { |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
59 |
res = _STD::codecvt_base::error; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
60 |
break; |
94ae4d75524c
7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff
changeset
|
61 |
} |