1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: Yuxuan Shui <yshuiv7@gmail.com>
Date: Sat, 14 Apr 2018 21:29:42 -0400
Subject: pytrie_gen.cpp: cast "-1" to iconv_t before comparison
this kills the errors like
src/lexicon/pytrie_gen.cpp:103:19: error: ISO C++ forbids comparison
between pointer and integer
---
src/lexicon/pytrie_gen.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/lexicon/pytrie_gen.cpp b/src/lexicon/pytrie_gen.cpp
index d3d62a2..fa9e4ab 100644
--- a/src/lexicon/pytrie_gen.cpp
+++ b/src/lexicon/pytrie_gen.cpp
@@ -94,15 +94,15 @@ isCorrectConverted(const char* utf8, iconv_t ic, iconv_t ric)
unsigned
getPureGBEncoding(const char* utf8str)
{
- static iconv_t ic_gb = iconv_open("GB2312", "UTF-8");
- static iconv_t ic_gbk = iconv_open("GBK", "UTF-8");
- static iconv_t ric_gb = iconv_open("UTF-8", "GB2312");
- static iconv_t ric_gbk = iconv_open("UTF-8", "GBK");
-
+ static const iconv_t e = reinterpret_cast<iconv_t>(-1);
+ static const iconv_t ic_gb = iconv_open("GB2312", "UTF-8");
+ static const iconv_t ic_gbk = iconv_open("GBK", "UTF-8");
+ static const iconv_t ric_gb = iconv_open("UTF-8", "GB2312");
+ static const iconv_t ric_gbk = iconv_open("UTF-8", "GBK");
// FIXME
- if (ic_gb == -1 || ic_gbk == -1 || ric_gb == -1 || ric_gbk == -1) return 3;
- unsigned ret = 0;
+ if (ic_gb == e || ic_gbk == e || ric_gb == e || ric_gbk == e) return 3;
+ unsigned ret = 0;
if (!isCorrectConverted(utf8str, ic_gb, ric_gb)) {
ret = 1; // at least it is contains some GBK char
if (!isCorrectConverted(utf8str, ic_gbk, ric_gbk))
|