kernel32-UTF7_Support: Replace do{}while loop with while loop, remove assertion.

This commit is contained in:
Sebastian Lackner 2014-10-09 05:58:22 +02:00
parent 04467e7e68
commit 413b5ee73f
3 changed files with 17 additions and 20 deletions

View File

@ -1,17 +1,17 @@
From 87874c02de939388405ebfcb752918c1a764a516 Mon Sep 17 00:00:00 2001
From e0751978c723a0b402d238cc46fee336136e1aca Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Wed, 8 Oct 2014 21:16:37 -0600
Subject: kernel32: Support UTF-7 in MultiByteToWideChar.
---
dlls/kernel32/locale.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 157 insertions(+), 4 deletions(-)
dlls/kernel32/locale.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 154 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 730574b..a5d4403 100644
index 730574b..d0ed6ed 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -1954,6 +1954,160 @@ BOOL WINAPI EnumSystemCodePagesW( CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD fla
@@ -1954,6 +1954,157 @@ BOOL WINAPI EnumSystemCodePagesW( CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD fla
/***********************************************************************
@ -89,13 +89,10 @@ index 730574b..a5d4403 100644
+ DWORD byte_pair = 0;
+ short offset = 0;
+
+ /* MultiByteToWideChar guarantees that srclen > 0 */
+ assert(srclen > 0);
+
+ if (!dstlen)
+ dst = NULL;
+
+ do
+ while (src < source_end)
+ {
+ if (*src == '+')
+ {
@ -110,7 +107,7 @@ index 730574b..a5d4403 100644
+ continue;
+ }
+
+ do
+ while (src < source_end)
+ {
+ WCHAR sextet = *src;
+ if (sextet == '-')
@ -154,7 +151,7 @@ index 730574b..a5d4403 100644
+
+ /* this sextet is done */
+ src++;
+ } while (src < source_end);
+ }
+ }
+ else
+ {
@ -163,7 +160,7 @@ index 730574b..a5d4403 100644
+ return -1;
+ src++;
+ }
+ } while (src < source_end);
+ }
+
+ return dest_index;
+}
@ -172,7 +169,7 @@ index 730574b..a5d4403 100644
* MultiByteToWideChar (KERNEL32.@)
*
* Convert a multibyte character string into a Unicode string.
@@ -1963,7 +2117,7 @@ BOOL WINAPI EnumSystemCodePagesW( CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD fla
@@ -1963,7 +2114,7 @@ BOOL WINAPI EnumSystemCodePagesW( CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD fla
* flags [I] Character mapping flags
* src [I] Source string buffer
* srclen [I] Length of src (in bytes), or -1 if src is NUL terminated
@ -181,7 +178,7 @@ index 730574b..a5d4403 100644
* dstlen [I] Length of dst (in WCHARs), or 0 to compute the required length
*
* RETURNS
@@ -2006,9 +2160,8 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
@@ -2006,9 +2157,8 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}

View File

@ -1,4 +1,4 @@
From eb7a37bf7d71cfa8696185047483fbe02d01a5d1 Mon Sep 17 00:00:00 2001
From 9c7a0f4d74ad66075cf2490a5b4315f59597d0db Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Wed, 8 Oct 2014 21:18:22 -0600
Subject: kernel32: Support UTF-7 in WideCharToMultiByte.
@ -8,10 +8,10 @@ Subject: kernel32: Support UTF-7 in WideCharToMultiByte.
1 file changed, 142 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index a5d4403..fc0a7ad 100644
index d0ed6ed..29069d3 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2201,6 +2201,145 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
@@ -2198,6 +2198,145 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
/***********************************************************************
@ -157,7 +157,7 @@ index a5d4403..fc0a7ad 100644
* WideCharToMultiByte (KERNEL32.@)
*
* Convert a Unicode character string into a multibyte string.
@@ -2210,7 +2349,7 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
@@ -2207,7 +2346,7 @@ INT WINAPI MultiByteToWideChar( UINT page, DWORD flags, LPCSTR src, INT srclen,
* flags [I] Mapping Flags (MB_ constants from "winnls.h").
* src [I] Source string buffer
* srclen [I] Length of src (in WCHARs), or -1 if src is NUL terminated
@ -166,7 +166,7 @@ index a5d4403..fc0a7ad 100644
* dstlen [I] Length of dst (in bytes), or 0 to compute the required length
* defchar [I] Default character to use for conversion if no exact
* conversion can be made
@@ -2267,9 +2406,8 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
@@ -2264,9 +2403,8 @@ INT WINAPI WideCharToMultiByte( UINT page, DWORD flags, LPCWSTR src, INT srclen,
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}

View File

@ -1,4 +1,4 @@
From 2197e9d68f4400b5c30fbbe787ac308bc8a94908 Mon Sep 17 00:00:00 2001
From 017281b13109dc960dc4a928068853ccc8852f77 Mon Sep 17 00:00:00 2001
From: Alex Henrie <alexhenrie24@gmail.com>
Date: Wed, 8 Oct 2014 19:52:55 -0600
Subject: kernel32/tests: Add tests for UTF-7 conversion.