Skip to content

Commit

Permalink
2005-08-04 Jim Huang <[email protected]>
Browse files Browse the repository at this point in the history
        * src/hanyupinying.c (InitMap):
        Add failback routines.

        * src/Makefile.am:
        Add CHEWING_DATADIR macro.

        * data/Makefile.am:
        Remove pinyin.tab from CLEANFILES.


git-svn-id: https://svn.csie.net/chewing/libchewing/trunk@230 ac1be623-90ea-0310-9410-ba68b2efa777
  • Loading branch information
jserv committed Aug 4, 2005
1 parent 84b4449 commit 3c7f984
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2005-08-04 Jim Huang <[email protected]>

* src/hanyupinying.c (InitMap):
Add failback routines.

* src/Makefile.am:
Add CHEWING_DATADIR macro.

* data/Makefile.am:
Remove pinyin.tab from CLEANFILES.

2005-04-07 Jim Huang <[email protected]>

* src/private.h,
Expand Down
9 changes: 7 additions & 2 deletions data/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
tooldir = $(top_builddir)/src/tools
datas = us_freq.dat ch_index.dat dict.dat ph_index.dat fonetree.dat pinyin.tab
datas = \
us_freq.dat \
ch_index.dat \
dict.dat \
ph_index.dat \
fonetree.dat
all: gendata
gendata: phone.cin tsi.src
$(tooldir)/sort_word
$(tooldir)/sort_dic tsi.src
$(tooldir)/maketree
-rm -f phoneid.dic
install-data-local: $(datas)
install-data-local: $(datas) pinyin.tab
$(mkinstalldirs) $(DESTDIR)/$(datadir)/chewing
$(INSTALL_DATA) $(datas) $(DESTDIR)/$(datadir)/chewing
CLEANFILES = $(datas)
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SUBDIRS = common tools
INCLUDES = -I$(top_builddir)/include
INCLUDES = \
-I$(top_builddir)/include \
-DCHEWING_DATADIR=\"$(datadir)/chewing\"

lib_LTLIBRARIES = libchewing.la
libchewing_la_SOURCES = \
Expand Down
11 changes: 10 additions & 1 deletion src/hanyupinying.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "hanyupinying.h"
#include "hash.h"
#include "private.h"
Expand Down Expand Up @@ -109,7 +110,15 @@ static void InitMap()
char *filedir = strcat( getenv( "HOME" ), CHEWING_HASH_PATH );
char *filepath = strcat( filedir, "/pinyin.tab" );

fd = fopen( filepath, "r" );
if (access(filepath, R_OK) == 0) {
/* Use user-defined tables */
fd = fopen( filepath, "r" );
}
else {
/* Failback */
fd = fopen( CHEWING_DATADIR "/pinyin.tab", "r");
}

if ( fd ) {
addTerminateService( FreeMap );
fscanf( fd, "%d", &HANYU_INITIALS );
Expand Down

0 comments on commit 3c7f984

Please sign in to comment.