Fixes build on some situations:

* use C++ style header files
* fixes bogus NULL usage, as Integer 0.
This commit is contained in:
obache 2013-03-20 05:25:58 +00:00
parent 40efcbd2dd
commit 0dfa5c9f89
5 changed files with 101 additions and 4 deletions

View file

@ -1,9 +1,12 @@
$NetBSD: distinfo,v 1.1.1.1 2009/11/24 12:13:02 obache Exp $
$NetBSD: distinfo,v 1.2 2013/03/20 05:25:58 obache Exp $
SHA1 (novel-pinyin-0.2.5.tar.gz) = d973b122aed8b844806948e5081f342945df75ff
RMD160 (novel-pinyin-0.2.5.tar.gz) = 61107040664ddf76a26191401a750ae60397fa4e
Size (novel-pinyin-0.2.5.tar.gz) = 6006453 bytes
SHA1 (patch-aa) = bacaf491f7e7a9085fff5eb1ea15a73e0638c00c
SHA1 (patch-ab) = 7e50761959a6b17480d524b22cb265cacca44332
SHA1 (patch-ac) = a88eab51d41129afdfb2efab0ea6eb1c60ce369f
SHA1 (patch-ac) = c48bb8217c590b545a494bfed95b1130a164bb5f
SHA1 (patch-ad) = 16648a1a547982eac40676d40ed1c9b978476df5
SHA1 (patch-modules_scim_novel__pinyin__imengine.cpp) = 1a4e139d37139d82a62e7ed720ac13540b75cefa
SHA1 (patch-src_lookup_lookup.h) = aed5a9b28eb7ac050f3b1c0ea0f2de4b09d596c5
SHA1 (patch-src_lookup_pinyin__lookup.cpp) = 708b78d362f3339e511fb8f9ef97fa8cf4aa832f

View file

@ -1,6 +1,7 @@
$NetBSD: patch-ac,v 1.1.1.1 2009/11/24 12:13:02 obache Exp $
$NetBSD: patch-ac,v 1.2 2013/03/20 05:25:58 obache Exp $
Use C++ way for getline(3) less platforms.
* Use C++ way for getline(3) less platforms.
* fixes bogus NULL usage as Integer 0.
--- tests/lookup/test_simple_lookup.cpp.orig 2008-07-21 12:39:27.000000000 +0000
+++ tests/lookup/test_simple_lookup.cpp
@ -19,3 +20,12 @@ Use C++ way for getline(3) less platforms.
linebuf[strlen(linebuf)-1] = '\0';
if ( strcmp ( linebuf, "quit" ) == 0)
break;
@@ -91,7 +93,7 @@ int main( int argc, char * argv[]){
print_time(start_time, times);
for ( size_t i = 0; i < results->len; ++i){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
- if ( NULL == *token)
+ if ( 0 == *token)
continue;
printf("pos:%d,token:%d\t", i, *token);
}

View file

@ -0,0 +1,24 @@
$NetBSD: patch-modules_scim_novel__pinyin__imengine.cpp,v 1.1 2013/03/20 05:25:58 obache Exp $
* fixes bogus NULL usage, as Integer 0.
--- modules/scim/novel_pinyin_imengine.cpp.orig 2008-10-05 07:55:31.000000000 +0000
+++ modules/scim/novel_pinyin_imengine.cpp
@@ -1690,7 +1690,7 @@ PinyinInstance::calc_lookup_table (){
}
}
}else
- last_token = NULL;
+ last_token = 0;
PhraseItemWithFreq item;
@@ -1782,7 +1782,7 @@ PinyinInstance::calc_lookup_table (){
}
}
g_array_sort(m_phrase_items_with_freq, lookup_table_sort);
- phrase_token_t last_token = NULL;
+ phrase_token_t last_token = 0;
for ( size_t m = 0; m < m_phrase_items_with_freq->len; ++m){
PhraseItemWithFreq * item = &g_array_index(m_phrase_items_with_freq, PhraseItemWithFreq, m);
if ( last_token != item->m_token )

View file

@ -0,0 +1,15 @@
$NetBSD: patch-src_lookup_lookup.h,v 1.1 2013/03/20 05:25:58 obache Exp $
* fixes bogus NULL usage, as Integer 0.
--- src/lookup/lookup.h.orig 2008-07-30 12:38:00.000000000 +0000
+++ src/lookup/lookup.h
@@ -42,7 +42,7 @@ struct lookup_value_t{
gfloat m_poss;
gint32 m_last_step;
lookup_value_t(gfloat poss = FLT_MAX){
- m_handles[0] = NULL; m_handles[1] = NULL;
+ m_handles[0] = 0; m_handles[1] = 0;
m_poss = poss;
m_last_step = -1;
}

View file

@ -0,0 +1,45 @@
$NetBSD: patch-src_lookup_pinyin__lookup.cpp,v 1.1 2013/03/20 05:25:58 obache Exp $
* use C++ style include files.
* fixes bogus NULL usage, as Integer 0.
--- src/lookup/pinyin_lookup.cpp.orig 2009-03-08 03:43:51.000000000 +0000
+++ src/lookup/pinyin_lookup.cpp
@@ -20,8 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <math.h>
-#include <assert.h>
+#include <cmath>
+#include <cassert>
#include <iostream>
#include "stl_lite.h"
#include "novel_types.h"
@@ -379,7 +379,7 @@ bool PinyinLookup::final_step(MatchResul
g_array_set_size(results, m_steps_content->len);
for ( size_t i = 0 ; i < m_steps_content->len ; ++i){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
- *token = NULL;
+ *token = 0;
}
//find max element
size_t last_step_pos = m_steps_content->len - 1;
@@ -430,7 +430,7 @@ bool PinyinLookup::train_result(PinyinKe
guint32 train_factor = 23;
for ( size_t i = 0; i < constraints->len; ++i){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
- if ( *token == NULL )
+ if ( *token == 0 )
continue;
lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i);
if (train_next || CONSTRAINT_ONESTEP == constraint->m_type ){
@@ -484,7 +484,7 @@ bool PinyinLookup::convert_to_utf8(Match
result_string = g_strdup("");
for ( size_t i = 0; i < results->len; ++i){
phrase_token_t * token = &g_array_index(results, phrase_token_t, i);
- if ( NULL == *token )
+ if ( 0 == *token )
continue;
m_phrase_index->get_phrase_item(*token, m_cache_phrase_item);
utf16_t buffer[MAX_PHRASE_LENGTH];