summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_index.cpp
diff options
context:
space:
mode:
authorWeixuan XIAO <veyx.shaw@gmail.com>2020-11-22 19:02:36 +0100
committerPeng Wu <alexepico@gmail.com>2020-11-26 11:00:51 +0800
commit76108f9b60e521af2d716b22dd5dd99d62609e72 (patch)
tree235f28e9cde82a342cf47390e4eb3e079002cb76 /src/storage/phrase_index.cpp
parentf1e88a707de818277e937fb77d3d9c737e470377 (diff)
downloadlibpinyin-76108f9b60e521af2d716b22dd5dd99d62609e72.tar.gz
libpinyin-76108f9b60e521af2d716b22dd5dd99d62609e72.tar.xz
libpinyin-76108f9b60e521af2d716b22dd5dd99d62609e72.zip
Fix delimiter for reading table files on macOS
On macOS under llvm/clang++, the default delimiter for format string is weird: it cannot read full CJK characters from the table files. This patch adds macOS-specified code to make "\t" and " " the implicit delimiter. Ref: https://stackoverflow.com/questions/12885628/changing-the-scanf-delimiter
Diffstat (limited to 'src/storage/phrase_index.cpp')
-rw-r--r--src/storage/phrase_index.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp
index 06b613f..36cb149 100644
--- a/src/storage/phrase_index.cpp
+++ b/src/storage/phrase_index.cpp
@@ -527,8 +527,13 @@ bool FacadePhraseIndex::load_text(guint8 phrase_index, FILE * infile,
phrase_token_t cur_token = 0;
while (!feof(infile)){
+#ifdef __APPLE__
+ int num = fscanf(infile, "%255s %255[^ \t] %u %ld",
+ pinyin, phrase, &token, &freq);
+#else
int num = fscanf(infile, "%255s %255s %u %ld",
pinyin, phrase, &token, &freq);
+#endif
if (4 != num)
continue;