diff options
-rw-r--r-- | utils/segment/ngseg.cpp | 4 | ||||
-rw-r--r-- | utils/segment/spseg.cpp | 4 |
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); |