summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-07-18 17:32:50 +0800
committerPeng Wu <alexepico@gmail.com>2011-07-18 17:33:05 +0800
commitc87e5cef11df74817926d4cd097bbb49796684d3 (patch)
tree0acbc3bb2546a94161ae191f2edd89b8c23a99a4 /utils
parentbfeb358622bde2d7bb872840bc28cd5b805549c9 (diff)
downloadlibpinyin-c87e5cef11df74817926d4cd097bbb49796684d3.tar.gz
libpinyin-c87e5cef11df74817926d4cd097bbb49796684d3.tar.xz
libpinyin-c87e5cef11df74817926d4cd097bbb49796684d3.zip
add end-of-file new line detects in segment
Diffstat (limited to 'utils')
-rw-r--r--utils/segment/ngseg.cpp4
-rw-r--r--utils/segment/spseg.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/utils/segment/ngseg.cpp b/utils/segment/ngseg.cpp
index c4853df..1e3f6c5 100644
--- a/utils/segment/ngseg.cpp
+++ b/utils/segment/ngseg.cpp
@@ -138,7 +138,9 @@ int main(int argc, char * argv[]){
size_t size = 0;
ssize_t read;
while( (read = getline(&linebuf, &size, stdin)) != -1 ){
- linebuf[strlen(linebuf) - 1] = '\0';
+ if ( '\n' == linebuf[strlen(linebuf) - 1] ) {
+ linebuf[strlen(linebuf) - 1] = '\0';
+ }
//check non-ucs2 characters
const glong num_of_chars = g_utf8_strlen(linebuf, -1);
diff --git a/utils/segment/spseg.cpp b/utils/segment/spseg.cpp
index 905991f..cec5ba2 100644
--- a/utils/segment/spseg.cpp
+++ b/utils/segment/spseg.cpp
@@ -176,7 +176,9 @@ int main(int argc, char * argv[]){
size_t size = 0;
ssize_t read;
while( (read = getline(&linebuf, &size, stdin)) != -1 ){
- linebuf[strlen(linebuf) - 1] = '\0';
+ if ( '\n' == linebuf[strlen(linebuf) - 1] ) {
+ linebuf[strlen(linebuf) - 1] = '\0';
+ }
//check non-ucs2 characters
const glong num_of_chars = g_utf8_strlen(linebuf, -1);