summaryrefslogtreecommitdiff
path: root/icu4c
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2022-03-15 15:18:46 +0000
committerVictor Chang <vichang@google.com>2022-03-15 15:19:37 +0000
commit5b2b1456781e821611c3c1fda5f34b1bd1e79fb7 (patch)
tree0b5c5b18996a7029e978199f767a7dc9625c07f4 /icu4c
parent1e86dda59e13e0363ac94d8e34654dcf1cba7ba9 (diff)
downloadicu-5b2b1456781e821611c3c1fda5f34b1bd1e79fb7.tar.gz
Cherry-pick: ICU-21793 Fix ucptrietest golden diff
Upstream commit: https://github.com/unicode-org/icu/commit/698efda42bb21a9da1c92348d3e73466c8a528fe Bug: 213284403 Test: Push the test binary onto the device and run the following command ./cintltst64 -w /tsutil/ucptrietest/TrieTestSet1 Change-Id: Ib03ae93aa8638f1a1e68d639e5eaf9fe92a5781f
Diffstat (limited to 'icu4c')
-rw-r--r--icu4c/source/tools/toolutil/toolutil.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/icu4c/source/tools/toolutil/toolutil.cpp b/icu4c/source/tools/toolutil/toolutil.cpp
index 1fc68aa69..a9dc37377 100644
--- a/icu4c/source/tools/toolutil/toolutil.cpp
+++ b/icu4c/source/tools/toolutil/toolutil.cpp
@@ -228,18 +228,19 @@ uprv_compareGoldenFiles(
std::ifstream ifs(goldenFilePath, std::ifstream::in);
int32_t pos = 0;
char c;
- while ((c = ifs.get()) != std::char_traits<char>::eof() && pos < bufferLen) {
+ while (ifs.get(c) && pos < bufferLen) {
if (c != buffer[pos]) {
// Files differ at this position
- return pos;
+ break;
}
pos++;
}
- if (pos < bufferLen || c != std::char_traits<char>::eof()) {
- // Files are different lengths
- return pos;
+ if (pos == bufferLen && ifs.eof()) {
+ // Files are same lengths
+ pos = -1;
}
- return -1;
+ ifs.close();
+ return pos;
}
/*U_CAPI UDate U_EXPORT2