From 4f125d4da840cab8ee5553162dc071ac9486fb53 Mon Sep 17 00:00:00 2001 From: Brodie Thiesfield Date: Mon, 27 Feb 2012 00:19:12 +0000 Subject: Fix a bug reported by andreaplanet in the ICU processing that caused conversion of zero-length strings (like empty values) to fail. See http://www.codeproject.com/Articles/13881/Cross-platform-INI-Configuration-Files-Win32-Un-x?msg=4148327#xx4148327xx --- SimpleIni.h | 10 +++------- package.cmd | 2 +- test1-expected.ini | 3 +++ test1-input.ini | 3 +++ test1.cpp | 3 ++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/SimpleIni.h b/SimpleIni.h index beaa107..4d1d077 100644 --- a/SimpleIni.h +++ b/SimpleIni.h @@ -5,7 +5,7 @@ File SimpleIni.h Author Brodie Thiesfield [code at jellycan dot com] Source http://code.jellycan.com/simpleini/ - Version 4.14 + Version 4.15 Jump to the @link CSimpleIniTempl CSimpleIni @endlink interface documentation. @@ -3039,10 +3039,9 @@ public: } nError = U_ZERO_ERROR; - ucnv_resetToUnicode(m_pConverter); int32_t nLen = ucnv_toUChars(m_pConverter, NULL, 0, a_pInputData, (int32_t) a_uInputDataLen, &nError); - if (nError != U_BUFFER_OVERFLOW_ERROR) { + if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) { return (size_t) -1; } @@ -3079,7 +3078,6 @@ public: } nError = U_ZERO_ERROR; - ucnv_resetToUnicode(m_pConverter); ucnv_toUChars(m_pConverter, a_pOutputData, (int32_t) a_uOutputDataSize, a_pInputData, (int32_t) a_uInputDataLen, &nError); @@ -3114,10 +3112,9 @@ public: } nError = U_ZERO_ERROR; - ucnv_resetFromUnicode(m_pConverter); int32_t nLen = ucnv_fromUChars(m_pConverter, NULL, 0, a_pInputData, -1, &nError); - if (nError != U_BUFFER_OVERFLOW_ERROR) { + if (U_FAILURE(nError) && nError != U_BUFFER_OVERFLOW_ERROR) { return (size_t) -1; } @@ -3153,7 +3150,6 @@ public: } nError = U_ZERO_ERROR; - ucnv_resetFromUnicode(m_pConverter); ucnv_fromUChars(m_pConverter, a_pOutputData, (int32_t) a_uOutputDataSize, a_pInputData, -1, &nError); diff --git a/package.cmd b/package.cmd index f46da2c..2ae29db 100644 --- a/package.cmd +++ b/package.cmd @@ -1,4 +1,4 @@ -set VERSION=4.14 +set VERSION=4.15 set SEVENZIP="C:\Program Files\7-Zip\7z.exe" diff --git a/test1-expected.ini b/test1-expected.ini index ca2216c..dde335d 100644 --- a/test1-expected.ini +++ b/test1-expected.ini @@ -13,6 +13,9 @@ lonely-key = nosection another = nosection either +; This key has no value +empty = + ; This should be joined with the comment below about japanese. ; Another line which will be un-indented. diff --git a/test1-input.ini b/test1-input.ini index 6b5f7fd..6d27681 100644 --- a/test1-input.ini +++ b/test1-input.ini @@ -11,6 +11,9 @@ lonely-key = nosection another = nosection either +; This key has no value +empty = + ; This should be joined with the comment below about japanese. ; Another line which will be un-indented. diff --git a/test1.cpp b/test1.cpp index ef7e336..3dd7800 100644 --- a/test1.cpp +++ b/test1.cpp @@ -10,6 +10,7 @@ #endif #ifdef _WIN32 +# include # define DELETE_FILE DeleteFileA #else # include @@ -121,7 +122,7 @@ bool TestStreams() Test oTest("TestStreams"); - CSimpleIniA ini; + CSimpleIniW ini; ini.SetUnicode(true); ini.SetMultiKey(true); ini.SetMultiLine(true); -- cgit v1.2.3