aboutsummaryrefslogtreecommitdiff
path: root/textproc/stardict3/files
diff options
context:
space:
mode:
authorVanilla I. Shu <vanilla@FreeBSD.org>2003-05-13 01:23:45 +0000
committerVanilla I. Shu <vanilla@FreeBSD.org>2003-05-13 01:23:45 +0000
commit36b51565fd334bf323bed0c6c4ec82f13cd695a7 (patch)
tree7807a7eeb59a027ffcdf3ff8b3613041758e2cc3 /textproc/stardict3/files
parent14eeb3f72c5095639159c26191ce44a00b203476 (diff)
downloadports-36b51565fd334bf323bed0c6c4ec82f13cd695a7.tar.gz
ports-36b51565fd334bf323bed0c6c4ec82f13cd695a7.zip
Add stardict2 2.0.0, english-Chinese dictionary.
PR: 51185 Submitted by: Shen Chuan-Hsing <statue@freebsd.sinica.edu.tw>
Notes
Notes: svn path=/head/; revision=80865
Diffstat (limited to 'textproc/stardict3/files')
-rw-r--r--textproc/stardict3/files/patch-src::tools::olddic2newdic.c157
-rw-r--r--textproc/stardict3/files/patch-src::tools::oxford2dic.c64
-rw-r--r--textproc/stardict3/files/patch-src::tools::pydict2dic.c64
3 files changed, 285 insertions, 0 deletions
diff --git a/textproc/stardict3/files/patch-src::tools::olddic2newdic.c b/textproc/stardict3/files/patch-src::tools::olddic2newdic.c
new file mode 100644
index 000000000000..f888334a040f
--- /dev/null
+++ b/textproc/stardict3/files/patch-src::tools::olddic2newdic.c
@@ -0,0 +1,157 @@
+--- src/tools/olddic2newdic.c.orig Sat May 3 18:48:30 2003
++++ src/tools/olddic2newdic.c Mon May 5 04:05:05 2003
+@@ -52,28 +52,54 @@
+ void convert(char *filename,char *idxheadfilename)
+ {
+ struct stat stats;
++ FILE *idxheadfile;
++ gchar *buffer;
++ FILE *idxfile,*dicfile;
++ gchar str[256],basename[256];
++ long wordcount_offset;
++ glong tmpglong=0;
++ gboolean sametypesequence = FALSE;
++ int fd;
++ struct stat stStat;
++ int iFileSize;
++ unsigned int iCapacity,iStyle;
++ unsigned char cIndex, cWord, cMeaning, cMark;
++ caddr_t pFileMem;
++ caddr_t p=pFileMem;
++ caddr_t pMeaning, pMark;
++ gchar *utf8_str;
++ gsize write_size;
++ long tmp_long,wordcount=0;
++ int word_len, meaning_len,mark_len=0;
++ int iLength=0;
++ GArray *array;
++ struct _worditem worditem;
++ glong old_size;
++ long offset_old=0;
++ int i;
++ gchar *previous_word = g_strdup(""); //there should have no word equal this.
++ glong previous_datasize = 0;
++ gchar *previous_data = g_strdup("");
++ struct _worditem *pworditem;
++
++
+ if (stat (idxheadfilename, &stats) == -1)
+ {
+ printf("idxhead file not exist!\n");
+ return;
+ }
+
+- FILE *idxheadfile;
+ idxheadfile = fopen(idxheadfilename,"r");
+- gchar *buffer;
+ buffer = (gchar *)g_malloc (stats.st_size + 1);
+ fread (buffer, 1, stats.st_size, idxheadfile);
+ fclose (idxheadfile);
+ buffer[stats.st_size] = '\0';
+- gboolean sametypesequence = FALSE;
+ if (strstr(buffer,"sametypesequence="))
+ sametypesequence = TRUE;
+
+ //in the next code we will always treat sametypesequence to be TRUE.
+ //as now all old stardict dictionaries use these two feature.
+
+- FILE *idxfile,*dicfile;
+- gchar str[256],basename[256];
+
+ strcpy(basename,idxheadfilename);
+ basename[strlen(idxheadfilename)-8]='\0';
+@@ -86,11 +112,10 @@
+ fwrite(buffer, 1, stats.st_size, idxfile);
+ g_free(buffer);
+
+- long wordcount_offset = ftell(idxfile);
+- glong tmpglong=0;
++ wordcount_offset = ftell(idxfile);
+ fwrite(&(tmpglong),sizeof(glong),1,idxfile);
+
+- int fd=open(filename,O_RDONLY);
++ fd=open(filename,O_RDONLY);
+ if(fd==-1)
+ {
+ g_print("open fail\n");
+@@ -98,17 +123,15 @@
+ }
+
+ // get length of dicfile.
+- struct stat stStat;
+ if(fstat(fd,&stStat)!=0)
+ {
+ g_print("stat fail\n");
+ return;
+ }
+- int iFileSize=stStat.st_size;
++ iFileSize=stStat.st_size;
+
+ // get item count
+ lseek(fd,0-sizeof(int)*2,SEEK_END);
+- unsigned int iCapacity,iStyle;
+ read(fd,&iCapacity,sizeof(int));
+ read(fd,&iStyle,sizeof(int));
+ //disable the next two line when the convert file is from the same arch machine.
+@@ -117,14 +140,14 @@
+ vConvertEndian(&iStyle);
+ #endif
+
+- unsigned char cIndex=(unsigned char)(iStyle>>24);
+- unsigned char cWord=(unsigned char)(iStyle>>16);
+- unsigned char cMeaning=(unsigned char)(iStyle>>8);
+- unsigned char cMark=(unsigned char)iStyle;
++ cIndex=(unsigned char)(iStyle>>24);
++ cWord=(unsigned char)(iStyle>>16);
++ cMeaning=(unsigned char)(iStyle>>8);
++ cMark=(unsigned char)iStyle;
+ g_print("flag: %c %c %c\n",cIndex,cWord,cMeaning);
+
+ // mmap the file to memory
+- caddr_t pFileMem=(caddr_t)mmap( (caddr_t)0,iFileSize-sizeof(int)*2,
++ pFileMem=(caddr_t)mmap( (caddr_t)0,iFileSize-sizeof(int)*2,
+ PROT_READ,MAP_SHARED|MAP_NORESERVE,fd,0 );
+ if(pFileMem==MAP_FAILED)
+ {
+@@ -133,9 +156,7 @@
+ }
+
+ // begin to read items.
+- caddr_t p=pFileMem;
+- caddr_t pMeaning, pMark;
+- gchar *utf8_str;
++ p=pFileMem;
+ #ifndef DISABLE_CONVERT_LOCALE
+ gchar *locale_str;
+ gsize locale_write_size;
+@@ -157,14 +178,7 @@
+ return;*/
+
+ #endif
+- gsize write_size;
+- long tmp_long,wordcount=0;
+- int word_len, meaning_len,mark_len=0;
+- int iLength=0;
+-
+- GArray *array = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),iCapacity);
+- struct _worditem worditem;
+- glong old_size;
++ array = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),iCapacity);
+
+ while(p<pFileMem+iFileSize-sizeof(int)*2 && iLength<iCapacity)
+ {
+@@ -303,14 +317,6 @@
+ //g_qsort_with_data(parray->pdata,parray->len,sizeof(gpointer),comparefunc,NULL);
+ g_array_sort(array,comparefunc);
+
+- long offset_old=0;
+-
+- int i;
+-
+- gchar *previous_word = g_strdup(""); //there should have no word equal this.
+- glong previous_datasize = 0;
+- gchar *previous_data = g_strdup("");
+- struct _worditem *pworditem;
+ for (i=0;i<array->len;i++)
+ {
+ pworditem = &g_array_index(array, struct _worditem, i);
diff --git a/textproc/stardict3/files/patch-src::tools::oxford2dic.c b/textproc/stardict3/files/patch-src::tools::oxford2dic.c
new file mode 100644
index 000000000000..8529786c8474
--- /dev/null
+++ b/textproc/stardict3/files/patch-src::tools::oxford2dic.c
@@ -0,0 +1,64 @@
+--- src/tools/oxford2dic.c.orig Mon May 5 04:05:50 2003
++++ src/tools/oxford2dic.c Mon May 5 04:08:14 2003
+@@ -24,6 +24,19 @@
+ {
+ struct stat stats;
+ FILE *oxfile,*idxfile,*dicfile;
++ gchar *buffer;
++ gchar *p1,*p2;
++ glong line_num = 0;
++ gchar *utf_str;
++ gsize write_size;
++ struct _worditem worditem;
++ GArray *array;
++ glong tmpglong=0;
++ long offset_old;
++ glong wordcount;
++ glong i;
++ gchar *previous_word = "";
++ struct _worditem *pworditem;
+
+ if (stat (filename, &stats) == -1)
+ {
+@@ -32,21 +45,15 @@
+ }
+ oxfile = fopen(filename,"r");
+
+- gchar *buffer;
+ buffer = (gchar *)g_malloc (stats.st_size + 2);
+ fread (buffer, 1, stats.st_size, oxfile);
+ fclose (oxfile);
+ buffer[stats.st_size] = '\n';
+ buffer[stats.st_size+1] = '\0';
+
+- GArray *array = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),39000); //oxford.txt have 77304 lines.
+- struct _worditem worditem;
++ array = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),39000); //oxford.txt have 77304 lines.
+
+- gchar *p1,*p2;
+- glong line_num = 0;
+ p1 = buffer;
+- gchar *utf_str;
+- gsize write_size;
+
+ while (1) {
+ if (*p1=='\0') {
+@@ -91,17 +98,11 @@
+ idxfile = fopen("oxford.idxdata","w");
+ dicfile = fopen("oxford.dict","w");
+
+- glong tmpglong=0;
+ fwrite(&(tmpglong),sizeof(glong),1,idxfile);
+
+
+
+- long offset_old;
+-
+- glong wordcount = array->len;
+- glong i;
+- gchar *previous_word = "";
+- struct _worditem *pworditem;
++ wordcount = array->len;
+ for (i=0;i<array->len;i++)
+ {
+ pworditem = &g_array_index(array, struct _worditem, i);
diff --git a/textproc/stardict3/files/patch-src::tools::pydict2dic.c b/textproc/stardict3/files/patch-src::tools::pydict2dic.c
new file mode 100644
index 000000000000..59016223c047
--- /dev/null
+++ b/textproc/stardict3/files/patch-src::tools::pydict2dic.c
@@ -0,0 +1,64 @@
+--- src/tools/pydict2dic.c.orig Fri Apr 25 18:55:55 2003
++++ src/tools/pydict2dic.c Mon May 5 04:10:27 2003
+@@ -24,6 +24,20 @@
+ {
+ struct stat stats;
+ FILE *pyfile,*ecidxfile,*ecdicfile,*ceidxfile,*cedicfile;
++ gchar *buffer;
++ GArray *ecarray;
++ struct _worditem ecworditem;
++ GArray *cearray;
++ struct _worditem ceworditem;
++ gchar *p1,*p2,*p3,*p4;
++ gchar *utf_str;
++ gsize write_size;
++ glong word_len;
++ long offset_old;
++ glong wordcount;
++ glong i;
++ gchar *previous_word = "";
++ struct _worditem *pworditem;
+
+ if (stat (filename, &stats) == -1)
+ {
+@@ -32,24 +46,17 @@
+ }
+ pyfile = fopen(filename,"r");
+
+- gchar *buffer;
+ buffer = (gchar *)g_malloc (stats.st_size + 2);
+ fread (buffer, 1, stats.st_size, pyfile);
+ fclose (pyfile);
+ buffer[stats.st_size] = '\n';
+ buffer[stats.st_size+1] = '\0';
+
+- GArray *ecarray = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),177785); //pydict.lib have 177785 lines.
+- struct _worditem ecworditem;
+- GArray *cearray = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),177785);
+- struct _worditem ceworditem;
++ ecarray = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),177785); //pydict.lib have 177785 lines.
++ cearray = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),177785);
+
+- gchar *p1,*p2,*p3,*p4;
+ p1 = buffer;
+- gchar *utf_str;
+- gsize write_size;
+- glong word_len;
+-
++
+ while (1) {
+ if (*p1=='\0') {
+ g_print("over\n");
+@@ -142,12 +149,6 @@
+ fprintf(ceidxfile,"stardict's idx file\ndictfile=pydict-big5-ce.dict\nbookname=pydict-big5-ce\nbeigin:\n");
+ */
+
+- long offset_old;
+-
+- glong wordcount;
+- glong i;
+- gchar *previous_word = "";
+- struct _worditem *pworditem;
+
+ wordcount = ecarray->len;
+ for (i=0;i<ecarray->len;i++)