anthy-unicode/anthy-unicode-HEAD.patch

132 lines
4.3 KiB
Diff
Raw Normal View History

2019-10-21 08:21:24 +00:00
From 0d057d4927820e1138af9045be98eddff99fb43f Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Mon, 21 Oct 2019 15:14:39 +0900
Subject: [PATCH] test: Add prediction and test-matrix in Makefile
---
test/Makefile.am | 6 +++++-
test/prediction.c | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/Makefile.am b/test/Makefile.am
index 628a0d7..946d4d3 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,12 +5,16 @@ EXTRA_DIST = test.txt test.exp prediction.c test-matrix.c
INCLUDES = -I$(top_srcdir)/ -DSRCDIR=\"$(srcdir)\" \
-DTEST_HOME=\""`pwd`"\"
-noinst_PROGRAMS = anthy checklib
+noinst_PROGRAMS = anthy checklib prediction test-matrix
anthy_SOURCES = main.c
checklib_SOURCES = check.c
+prediction_SOURCES = prediction.c
+test_matrix_SOURCES = test-matrix.c
anthy_LDADD = ../src-util/libconvdb.la ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la
checklib_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la
+prediction_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la
+test_matrix_LDADD = ../src-main/libanthy-unicode.la ../src-worddic/libanthydic-unicode.la
mostlyclean-local:
-rm -rf .anthy*
diff --git a/test/prediction.c b/test/prediction.c
index 421a7c5..74f7140 100644
--- a/test/prediction.c
+++ b/test/prediction.c
@@ -3,7 +3,7 @@
#include <anthy/anthy.h>
-/* Makefile $B$N(B $(srcdir) ($B@EE*%G!<%?%U%!%$%k$N4p=`%G%#%l%/%H%j(B) */
+/* Makefile の $(srcdir) (静的データファイルの基準ディレクトリ) */
#ifndef SRCDIR
# define SRCDIR "."
#endif
@@ -11,7 +11,7 @@
static void
init_lib(void)
{
- /* $B4{$K%$%s%9%H!<%k$5$l$F$$$k%U%!%$%k$N1F6A$r<u$1$J$$$h$&$K$9$k(B */
+ /* 既にインストールされているファイルの影響を受けないようにする */
anthy_conf_override("CONFFILE", "../anthy-unicode.conf");
anthy_conf_override("DEPWORD", "master.depword");
anthy_conf_override("DEPGRAPH", "../depgraph/anthy.dep");
--
2.21.0
From c7039a1834adb4e1a3dd2b6b93f5f124a5991b5f Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Mon, 21 Oct 2019 16:26:10 +0900
Subject: [PATCH] src-worddic: Fix buffer overflow in record_stat.base_fn
test/anthy causes a buffer overflow in anthy_quit() in Fedora build
because ENCODING_SUFFIX will be appended to base_fn.
---
src-worddic/record.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-worddic/record.c b/src-worddic/record.c
index 6572536..5d71f88 100644
--- a/src-worddic/record.c
+++ b/src-worddic/record.c
@@ -2021,7 +2021,7 @@ static void
setup_filenames(const char *id, struct record_stat *rst)
{
const char *home = anthy_get_user_dir(0);
- int base_len = strlen(home) + strlen(id) + 5;
+ int base_len = strlen (home) + strlen (id) + strlen (ENCODING_SUFFIX) + 1;
/* 基本ファイル */
rst->base_fn = (char*) malloc(base_len +
--
2.21.0
From 686845b1e40e51a543fd24284ba4f5cbc3df643b Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Mon, 21 Oct 2019 17:07:25 +0900
Subject: [PATCH] test: Fix to run check in build
When I tried to fix an unused return variable, I deleted anthy_get_stat()
by mistake and revert it now.
Also set a local DIC_FILE for the build.
---
test/check.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/test/check.c b/test/check.c
index 02cf08e..f67dbac 100644
--- a/test/check.c
+++ b/test/check.c
@@ -9,6 +9,9 @@ init(void)
{
int res;
+ anthy_conf_override("CONFFILE", "../anthy-unicode.conf");
+ anthy_conf_override("HOME", TEST_HOME);
+ anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic");
res = anthy_init();
if (res) {
printf("failed to init\n");
@@ -16,6 +19,9 @@ init(void)
}
anthy_quit();
/* init again */
+ anthy_conf_override("CONFFILE", "../anthy-unicode.conf");
+ anthy_conf_override("HOME", TEST_HOME);
+ anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic");
res = anthy_init();
if (res) {
printf("failed to init\n");
@@ -85,6 +91,7 @@ shake_test(const char *str)
for (i = 0; i < 50; i++) {
int nth, rsz;
struct anthy_conv_stat cs;
+ anthy_get_stat(ac, &cs);
nth = rand() % cs.nr_segment;
rsz = (rand() % 3) - 1;
anthy_resize_segment(ac, nth, rsz);
--
2.21.0