Sophie

Sophie

distrib > Fedora > 16 > x86_64 > media > updates-src > by-pkgid > 14581e0ac2ff0255c5364b51dc98bd35 > files > 1

libchewing-0.3.3-5.fc16.src.rpm

diff -up ./data/Makefile.am.orig ./data/Makefile.am
--- ./data/Makefile.am.orig	2012-07-19 13:51:44.417897943 +1000
+++ ./data/Makefile.am	2012-07-19 15:00:08.067960510 +1000
@@ -9,8 +9,11 @@ datas = \
 	us_freq.dat \
 	dict.dat \
 	ph_index.dat \
-	fonetree.dat \
 	$(chindexs)
+
+datas_lib = \
+	fonetree.dat
+
 generated_header = $(top_builddir)/src/chewing-definition.h
 
 all: checkdata_stamp gendata_stamp
@@ -37,4 +40,7 @@ install-data-local: $(datas) pinyin.tab
 	$(mkinstalldirs) $(DESTDIR)/$(datadir)/chewing
 	$(INSTALL_DATA) $(datas) pinyin.tab swkb.dat symbols.dat \
 		$(DESTDIR)/$(datadir)/chewing
-CLEANFILES = $(datas) gendata_stamp checkdata_stamp $(generated_header)
+	$(mkinstalldirs) $(DESTDIR)/$(libdir)/chewing
+	$(INSTALL_DATA) $(datas_lib) $(DESTDIR)/$(libdir)/chewing
+
+CLEANFILES = $(datas) $(datas_lib) gendata_stamp checkdata_stamp $(generated_header)
diff -up ./src/Makefile.am.orig ./src/Makefile.am
--- ./src/Makefile.am.orig	2012-07-19 13:52:45.633807454 +1000
+++ ./src/Makefile.am	2012-07-19 15:01:05.563605235 +1000
@@ -1,3 +1,5 @@
+AM_CPPFLAGS = ${CFLAGS} -DLIBDIR=\"${libdir}\"
+
 SUBDIRS = porting_layer
 INCLUDES = \
 	-I$(top_srcdir)/include \
diff -up ./src/tree.c.orig ./src/tree.c
--- ./src/tree.c.orig	2012-07-19 13:52:04.111868256 +1000
+++ ./src/tree.c	2012-07-19 15:16:55.864761600 +1000
@@ -114,7 +114,7 @@ void InitTree( const char *prefix )
 	int i;
 #endif
 
-	sprintf( filename, "%s" PLAT_SEPARATOR "%s", prefix, PHONE_TREE_FILE );
+	sprintf( filename, "%s" PLAT_SEPARATOR "chewing" PLAT_SEPARATOR "%s", LIBDIR, PHONE_TREE_FILE );
 #ifdef USE_BINARY_DATA
 	plat_mmap_set_invalid( &tree_mmap );
 	tree_size = plat_mmap_create( &tree_mmap, filename, FLAG_ATTRIBUTE_READ );
@@ -151,10 +151,10 @@ static int CheckBreakpoint( int from, in
 	return 1;
 }
 
-static int CheckUserChoose( 
+static int CheckUserChoose(
 		uint16 *new_phoneSeq, int from , int to,
-		Phrase **pp_phr, 
-		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
+		Phrase **pp_phr,
+		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ],
 		IntervalType selectInterval[], int nSelect )
 {
 	IntervalType inte, c;
@@ -191,9 +191,9 @@ static int CheckUserChoose(
 			c = selectInterval[ chno ];
 
 			if ( IsContain( inte, c ) ) {
-				/* 
-				 * find a phrase of ph_id where the text contains 
-				 * 'selectStr[chno]' test if not ok then return 0, 
+				/*
+				 * find a phrase of ph_id where the text contains
+				 * 'selectStr[chno]' test if not ok then return 0,
 				 * if ok then continue to test. */
 				len = c.to - c.from;
 				if ( memcmp(
@@ -218,19 +218,19 @@ static int CheckUserChoose(
 		}
 	} while ( ( pUserPhraseData = UserGetPhraseNext( new_phoneSeq ) ) != NULL );
 
-	if ( p_phr->freq != -1 ) 
+	if ( p_phr->freq != -1 )
 		return 1;
-		
+
 	free( p_phr );
 	return 0;
 }
 
 /*
- * phrase is said to satisfy a choose interval if 
+ * phrase is said to satisfy a choose interval if
  * their intersections are the same */
 static int CheckChoose(
-		int ph_id, int from, int to, Phrase **pp_phr, 
-		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
+		int ph_id, int from, int to, Phrase **pp_phr,
+		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ],
 		IntervalType selectInterval[], int nSelect )
 {
 	IntervalType inte, c;
@@ -249,8 +249,8 @@ static int CheckChoose(
 			c = selectInterval[ chno ];
 
 			if ( IsContain( inte, c ) ) {
-				/* find a phrase of ph_id where the text contains 
-				 * 'selectStr[chno]' test if not ok then return 0, if ok 
+				/* find a phrase of ph_id where the text contains
+				 * 'selectStr[chno]' test if not ok then return 0, if ok
 				 * then continue to test
 				 */
 				len = c.to - c.from;
@@ -263,7 +263,7 @@ static int CheckChoose(
 			else if ( IsIntersect( inte, selectInterval[ chno ] ) ) {
 				free( phrase );
 				return 0;
-			} 
+			}
 		}
 		if ( chno == nSelect ) {
 			*pp_phr = phrase;
@@ -283,7 +283,7 @@ int TreeFindPhrase( int begin, int end,
 
 	tree_p = 0;
 	for ( i = begin; i <= end; i++ ) {
-		for ( 
+		for (
 			child = tree[ tree_p ].child_begin;
 			child != -1 && child <= tree[ tree_p ].child_end;
 			child++ ) {
@@ -304,7 +304,7 @@ int TreeFindPhrase( int begin, int end,
 }
 
 static void AddInterval(
-		TreeDataType *ptd, int begin , int end, 
+		TreeDataType *ptd, int begin , int end,
 		int p_id, Phrase *p_phrase, int dict_or_user )
 {
 	ptd->interval[ ptd->nInterval ].from = begin;
@@ -344,9 +344,9 @@ static void internal_release_Phrase( Use
 }
 
 static void FindInterval(
-		uint16 *phoneSeq, int nPhoneSeq, 
-		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
-		IntervalType selectInterval[], int nSelect, 
+		uint16 *phoneSeq, int nPhoneSeq,
+		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ],
+		IntervalType selectInterval[], int nSelect,
 		int bArrBrkpt[], TreeDataType *ptd )
 {
 	int end, begin, pho_id;
@@ -360,9 +360,9 @@ static void FindInterval(
 				continue;
 
 			/* set new_phoneSeq */
-			memcpy( 
-				new_phoneSeq, 
-				&phoneSeq[ begin ], 
+			memcpy(
+				new_phoneSeq,
+				&phoneSeq[ begin ],
 				sizeof( uint16 ) * ( end - begin + 1 ) );
 			new_phoneSeq[ end - begin + 1 ] = 0;
 			puserphrase = pdictphrase = NULL;
@@ -370,24 +370,24 @@ static void FindInterval(
 
 			/* check user phrase */
 			if ( UserGetPhraseFirst( new_phoneSeq ) &&
-					CheckUserChoose( new_phoneSeq, begin, end + 1, 
+					CheckUserChoose( new_phoneSeq, begin, end + 1,
 					&p_phrase, selectStr, selectInterval, nSelect ) ) {
 				puserphrase = p_phrase;
 			}
 
 			/* check dict phrase */
 			pho_id = TreeFindPhrase( begin, end, phoneSeq );
-			if ( 
-				( pho_id != -1 ) && 
-				CheckChoose( 
-					pho_id, begin, end + 1, 
-					&p_phrase, selectStr, 
+			if (
+				( pho_id != -1 ) &&
+				CheckChoose(
+					pho_id, begin, end + 1,
+					&p_phrase, selectStr,
 					selectInterval, nSelect ) ) {
 				pdictphrase = p_phrase;
 			}
 
 			/* add only one interval, which has the largest freqency
-			 * but when the phrase is the same, the user phrase overrides 
+			 * but when the phrase is the same, the user phrase overrides
 			 * static dict
 			 */
 			if ( puserphrase != NULL && pdictphrase == NULL ) {
@@ -399,7 +399,7 @@ static void FindInterval(
 			else if ( puserphrase != NULL && pdictphrase != NULL ) {
 				/* the same phrase, userphrase overrides */
 				if ( ! strcmp(
-					puserphrase->phrase, 
+					puserphrase->phrase,
 					pdictphrase->phrase ) ) {
 					i_used_phrase = USED_PHRASE_USER;
 				}
@@ -475,7 +475,7 @@ static int CompFrom( IntervalType *pa, I
 }
 #endif
 
-/* 
+/*
  * First we compare the 'nMatchCnnct'.
  * If the values are the same, we will compare the 'score'
  */
@@ -497,32 +497,32 @@ static void Discard1( TreeDataType *ptd
 
 	memset( failflag, 0, sizeof( failflag ) );
 	for ( a = 0; a < ptd->nInterval; a++ ) {
-		if ( failflag[ a ] ) 
+		if ( failflag[ a ] )
 			continue;
 		for ( b = 0; b < ptd->nInterval; b++ ) {
 			if ( a == b || failflag[ b ] )
 				continue ;
-			if ( ptd->interval[ b ].from >= ptd->interval[ a ].from && 
+			if ( ptd->interval[ b ].from >= ptd->interval[ a ].from &&
 				ptd->interval[ b ].to <= ptd->interval[ a ].to )
 				continue;
-			if ( ptd->interval[ b ].from <= ptd->interval[ a ].from && 
+			if ( ptd->interval[ b ].from <= ptd->interval[ a ].from &&
 				ptd->interval[ b ].to <= ptd->interval[ a ].from )
 				continue;
-			if ( ptd->interval[ b ].from >= ptd->interval[ a ].to && 
+			if ( ptd->interval[ b ].from >= ptd->interval[ a ].to &&
 				ptd->interval[ b ].to >= ptd->interval[ a ].to )
 				continue;
 			break;
 		}
-		/* if any other interval b is inside or leftside or rightside the 
+		/* if any other interval b is inside or leftside or rightside the
 		 * interval a */
 		if ( b >= ptd->nInterval ) {
 			/* then kill all the intervals inside the interval a */
 			int i;
 			for ( i = 0; i < ptd->nInterval; i++ )  {
-				if ( 
+				if (
 					! failflag[ i ] && i != a &&
-					ptd->interval[ i ].from >= 
-						ptd->interval[ a ].from && 
+					ptd->interval[ i ].from >=
+						ptd->interval[ a ].from &&
 					ptd->interval[ i ].to <= ptd->interval[ a ].to ) {
 					failflag[ i ] = 1;
 				}
@@ -559,14 +559,14 @@ static void Discard2( TreeDataType *ptd
 		for ( j = 0; j < ptd->nInterval; j++ ) {
 			if ( j == i )
 				continue;
-			memset( 
+			memset(
 				&overwrite[ ptd->interval[ j ].from ],
-				1, 
+				1,
 				ptd->interval[ j ].to - ptd->interval[ j ].from );
 		}
-		if ( memchr( 
+		if ( memchr(
 			&overwrite[ ptd->interval[ i ].from ],
-			1,	
+			1,
 			ptd->interval[ i ].to - ptd->interval[ i ].from ) )
 			failflag[ i ] = 1;
 	}
@@ -594,9 +594,9 @@ static void LoadChar( char *buf, int buf
 /* kpchen said, record is the index array of interval */
 static void OutputRecordStr(
 		char *out_buf, int out_buf_len,
-		int *record, int nRecord, 
-		uint16 phoneSeq[], int nPhoneSeq, 
-		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
+		int *record, int nRecord,
+		uint16 phoneSeq[], int nPhoneSeq,
+		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ],
 		IntervalType selectInterval[],
 		int nSelect, TreeDataType *ptd )
 {
@@ -664,7 +664,7 @@ static int rule_largest_freqsum( int *re
 	for ( i = 0; i < nRecord; i++ ) {
 		inter = ptd->interval[ record[ i ] ];
 		assert( inter.p_phr );
-		
+
 		/* We adjust the 'freq' of One-word Phrase */
 		score += ( inter.to - inter.from == 1 ) ?
 			( inter.p_phr->freq / 512 ) :
@@ -691,19 +691,19 @@ static int IsRecContain( int *intA, int
 	int big, sml;
 
 	for ( big = 0, sml = 0; sml < nB; sml++ ) {
-		while ( 
-			( big < nA ) && 
-			ptd->interval[ intA[ big ] ].from < 
+		while (
+			( big < nA ) &&
+			ptd->interval[ intA[ big ] ].from <
 				ptd->interval[ intB[ sml ] ].to ) {
 			if ( PhraseIntervalContain(
-				ptd->interval[ intA[ big ] ], 
+				ptd->interval[ intA[ big ] ],
 				ptd->interval[ intB[ sml ] ] ) )
 				break;
 			big++;
 		}
-		if ( 
-			( big >= nA ) || 
-			ptd->interval[ intA[ big ] ].from >= 
+		if (
+			( big >= nA ) ||
+			ptd->interval[ intA[ big ] ].from >=
 				ptd->interval[ intB[ sml ] ].to )
 			return 0;
 	}
@@ -715,9 +715,9 @@ static void SortListByScore( TreeDataTyp
 	int i, listLen;
 	RecordNode *p, **arr;
 
-	for ( 
-		listLen = 0, p = ptd->phList; 
-		p; 
+	for (
+		listLen = 0, p = ptd->phList;
+		p;
 		listLen++, p = p->next )
 		;
 	ptd->nPhListLen = listLen;
@@ -725,7 +725,7 @@ static void SortListByScore( TreeDataTyp
 	arr = ALC( RecordNode *, listLen );
 	assert( arr );
 
-	for ( 
+	for (
 		i = 0, p = ptd->phList;
 		i < listLen;
 		p = p->next, i++ ) {
@@ -755,23 +755,23 @@ static void SaveRecord( int *record, int
 	pre = NULL;
 	for ( p = ptd->phList; p; ) {
 		/* if  'p' contains 'record', then discard 'record'. */
-		if ( IsRecContain( p->arrIndex, p->nInter, record, nInter, ptd ) ) 
+		if ( IsRecContain( p->arrIndex, p->nInter, record, nInter, ptd ) )
 			return;
 
-		/* if 'record' contains 'p', then discard 'p' 
+		/* if 'record' contains 'p', then discard 'p'
 		 * -- We must deal with the linked list. */
 		if ( IsRecContain( record, nInter, p->arrIndex, p->nInter, ptd ) ) {
 			RecordNode *tp = p;
 
-			if ( pre ) 
+			if ( pre )
 				pre->next = p->next;
 			else
 				ptd->phList = ptd->phList->next;
 			p = p->next;
-			free( tp->arrIndex );			
+			free( tp->arrIndex );
 			free( tp );
 		}
-		else 
+		else
 			pre = p, p = p->next;
 	}
 	now = ALC( RecordNode, 1 );
@@ -780,7 +780,7 @@ static void SaveRecord( int *record, int
 	now->arrIndex = ALC( int, nInter );
 	assert( now->arrIndex );
 	now->nInter = nInter;
-	memcpy( now->arrIndex, record, nInter * sizeof( int ) );	
+	memcpy( now->arrIndex, record, nInter * sizeof( int ) );
 	ptd->phList = now;
 }
 
@@ -788,9 +788,9 @@ static void RecursiveSave( int depth, in
 {
 	int first, i;
 	/* to find first interval */
-	for ( 
-		first = record[ depth - 1 ] + 1; 
-		ptd->interval[ first ].from < to && first < ptd->nInterval; 
+	for (
+		first = record[ depth - 1 ] + 1;
+		ptd->interval[ first ].from < to && first < ptd->nInterval;
 		first++ )
 		;
 
@@ -801,10 +801,10 @@ static void RecursiveSave( int depth, in
 	record[ depth ] = first;
 	RecursiveSave( depth + 1, ptd->interval[ first ].to, record, ptd );
 	/* for each interval which intersects first */
-	for ( 
-		i= first + 1; 
+	for (
+		i= first + 1;
 		PhraseIntervalIntersect(
-			ptd->interval[ first ], 
+			ptd->interval[ first ],
 			ptd->interval[ i ] ) && i < ptd->nInterval;
 			i++ ) {
 		record[ depth ] = i;
@@ -816,10 +816,10 @@ static void SaveList( TreeDataType *ptd
 {
 	int record[ MAX_PHONE_SEQ_LEN + 1 ] = { -1 };
 
-	RecursiveSave( 1, 0, record, ptd );	
+	RecursiveSave( 1, 0, record, ptd );
 }
 
-static void InitPhrasing( TreeDataType *ptd ) 
+static void InitPhrasing( TreeDataType *ptd )
 {
 	memset( ptd, 0, sizeof( TreeDataType ) );
 }
@@ -829,9 +829,9 @@ static void SaveDispInterval( PhrasingOu
 	int i;
 
 	for ( i = 0; i < ptd->phList->nInter; i++ ) {
-		ppo->dispInterval[ i ].from = 
+		ppo->dispInterval[ i ].from =
 			ptd->interval[ ptd->phList->arrIndex[ i ] ].from;
-		ppo->dispInterval[ i ].to = 
+		ppo->dispInterval[ i ].to =
 			ptd->interval[ ptd->phList->arrIndex[ i ] ].to;
 	}
 	ppo->nDispInterval = ptd->phList->nInter;
@@ -864,11 +864,11 @@ static void CountMatchCnnct( TreeDataTyp
 	for ( p = ptd->phList; p; p = p->next ) {
 		/* for each record, count its 'nMatchCnnct' */
 		for ( sum = 0, i = 1; i < nPhoneSeq; i++ ) {
-			if ( !bUserArrCnnct[ i ] ) 
+			if ( !bUserArrCnnct[ i ] )
 				continue;
 			/* check if matching 'cnnct' */
 			for ( k = 0; k < p->nInter; k++ ) {
-				if ( 
+				if (
 					ptd->interval[ p->arrIndex[ k ] ].from < i &&
 					ptd->interval[ p->arrIndex[ k ] ].to > i ) {
 					sum++;
@@ -891,7 +891,7 @@ static void ShowList( TreeDataType *ptd
 		DEBUG_OUT( "  interval : " );
 		for ( i = 0; i < p->nInter; i++ ) {
 			DEBUG_OUT(
-				"[%d %d] ", 
+				"[%d %d] ",
 				ptd->interval[ p->arrIndex[ i ] ].from,
 				ptd->interval[ p->arrIndex[ i ] ].to );
 		}
@@ -937,17 +937,17 @@ static RecordNode* NextCut( TreeDataType
 }
 
 int Phrasing(
-		PhrasingOutput *ppo, uint16 phoneSeq[], int nPhoneSeq, 
-		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ], 
-		IntervalType selectInterval[], int nSelect, 
-		int bArrBrkpt[], int bUserArrCnnct[] ) 
+		PhrasingOutput *ppo, uint16 phoneSeq[], int nPhoneSeq,
+		char selectStr[][ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ],
+		IntervalType selectInterval[], int nSelect,
+		int bArrBrkpt[], int bUserArrCnnct[] )
 {
 	TreeDataType treeData;
 
 	InitPhrasing( &treeData );
 
-	FindInterval( 
-		phoneSeq, nPhoneSeq, selectStr, selectInterval, nSelect, 
+	FindInterval(
+		phoneSeq, nPhoneSeq, selectStr, selectInterval, nSelect,
 		bArrBrkpt, &treeData );
 	SetInfo( nPhoneSeq, &treeData );
 	Discard1( &treeData );
@@ -965,10 +965,10 @@ int Phrasing(
 	/* set phrasing output */
 	OutputRecordStr(
 		ppo->chiBuf, sizeof(ppo->chiBuf),
-		( treeData.phList )->arrIndex, 
-		( treeData.phList )->nInter, 
-		phoneSeq, 
-		nPhoneSeq, 
+		( treeData.phList )->arrIndex,
+		( treeData.phList )->nInter,
+		phoneSeq,
+		nPhoneSeq,
 		selectStr, selectInterval, nSelect, &treeData );
 	SaveDispInterval( ppo, &treeData );