File urgent-patch-fix-novel-pinyin-first-load.patch of Package novel-pinyin

diff -ur old/novel-pinyin-0.2.3//ChangeLog new/novel-pinyin-0.2.3//ChangeLog
--- old/novel-pinyin-0.2.3//ChangeLog	2008-01-18 17:37:05.000000000 +0800
+++ new/novel-pinyin-0.2.3//ChangeLog	2008-08-25 14:30:19.000000000 +0800
@@ -1,3 +1,11 @@
+2008-08-13  version 0.2.3 <alexepico@gmail.com>
+	* Import the entire scim-pinyin phrases as corpus.
+	* Better HMM parameter adjusts.
+	* Better candidates adjusts.
+	* Add version check.
+	* Add data file corruption detection.
+	* Protect against integer overflow.
+
 2008-01-18  gettextize  <bug-gnu-gettext@gnu.org>
 
 	* Makefile.am (SUBDIRS): Add po.
diff -ur old/novel-pinyin-0.2.3//modules/scim/novel_pinyin_global.cpp new/novel-pinyin-0.2.3//modules/scim/novel_pinyin_global.cpp
--- old/novel-pinyin-0.2.3//modules/scim/novel_pinyin_global.cpp	2008-08-07 12:43:21.000000000 +0800
+++ new/novel-pinyin-0.2.3//modules/scim/novel_pinyin_global.cpp	2008-08-25 15:02:58.000000000 +0800
@@ -38,6 +38,7 @@
 #define Uses_SCIM_CONFIG_PATH
 #define Uses_SCIM_LOOKUP_TABLE
 
+#include <errno.h>
 #include <scim.h>
 #include <glib.h>
 #include "novel_pinyin_private.h"
@@ -168,7 +169,12 @@
 bool PinyinGlobal::clean_old_files(const char * user_dir, const char * filename){
     String fullpathname = String(user_dir) + String(SCIM_PATH_DELIM_STRING) +
 	String(filename);
-    return 0 == unlink(fullpathname.c_str());
+	int retval = unlink(fullpathname.c_str());
+	if ( !retval )
+		return true;
+	if ( retval && ENOENT == errno )
+		return true;
+	return false;
 }
 
 bool PinyinGlobal::mark_version(const char * user_dir){
diff -ur old/novel-pinyin-0.2.3//modules/scim/novel_pinyin_imengine.cpp new/novel-pinyin-0.2.3//modules/scim/novel_pinyin_imengine.cpp
--- old/novel-pinyin-0.2.3//modules/scim/novel_pinyin_imengine.cpp	2008-08-07 12:32:55.000000000 +0800
+++ new/novel-pinyin-0.2.3//modules/scim/novel_pinyin_imengine.cpp	2008-08-25 15:21:36.000000000 +0800
@@ -179,7 +179,9 @@
 		     String(".scim") +
 		     String(SCIM_PATH_DELIM_STRING) +
 		     String("novel-pinyin"));
-
+    
+    mkdir(user_dir.c_str(), 0700);
+    
     if (!m_pinyin_global.check_version(user_dir.c_str())){
 	fprintf(stderr, "data file format updated, clean old files.\n");
 	if (!m_pinyin_global.clean_old_files(user_dir.c_str(), GB_PHRASE_FILENAME) ){
@@ -200,8 +202,6 @@
 	}
     }
 
-    mkdir(user_dir.c_str(), 0700);
-
     String user_bigram (user_dir + 
 			String(SCIM_PATH_DELIM_STRING) +
 			String(BIGRAM_FILENAME));
openSUSE Build Service is sponsored by