7129 lines
264 KiB
Diff
7129 lines
264 KiB
Diff
From c9f365df28640b1e5dd518f532e77e33fcb4451c Mon Sep 17 00:00:00 2001
|
||
From: fujiwarat <takao.fujiwara1@gmail.com>
|
||
Date: Tue, 13 Jul 2021 08:34:34 +0900
|
||
Subject: [PATCH] Code reviews
|
||
|
||
---
|
||
anthy/corpus.h | 1 +
|
||
anthy/logger.h | 1 +
|
||
anthy/matrix.h | 1 +
|
||
calctrans/calctrans.c | 57 +++++++++++---
|
||
calctrans/corpus.c | 44 +++++++++--
|
||
calctrans/input_set.c | 74 +++++++++++++++---
|
||
calctrans/input_set.h | 1 +
|
||
configure.ac | 2 +
|
||
depgraph/mkdepgraph.c | 68 ++++++++++++++--
|
||
mkanthydic/mkfiledic.c | 16 +++-
|
||
mkworddic/calcfreq.c | 26 +++++--
|
||
mkworddic/mkdic.c | 160 +++++++++++++++++++++++++++-----------
|
||
mkworddic/mkdic.h | 1 +
|
||
mkworddic/mkudic.c | 31 +++++++-
|
||
mkworddic/writewords.c | 3 +-
|
||
src-diclib/conf.c | 22 ++++--
|
||
src-diclib/diclib_inner.h | 2 +-
|
||
src-diclib/file_dic.c | 2 +-
|
||
src-diclib/filemap.c | 8 +-
|
||
src-diclib/logger.c | 23 ++++++
|
||
src-diclib/ruleparser.c | 11 ++-
|
||
src-diclib/xstr.c | 84 +++++++++++++++++---
|
||
src-main/context.c | 102 ++++++++++++++++--------
|
||
src-main/main.c | 10 +--
|
||
src-ordering/candswap.c | 23 +++++-
|
||
src-ordering/relation.c | 6 +-
|
||
src-splitter/compose.c | 84 +++++++++++++++-----
|
||
src-splitter/depgraph.c | 15 +++-
|
||
src-splitter/lattice.c | 54 ++++++++++---
|
||
src-splitter/metaword.c | 22 ++++--
|
||
src-splitter/segclass.c | 4 +-
|
||
src-splitter/splitter.c | 6 ++
|
||
src-util/agent.c | 52 ++++++++++---
|
||
src-util/convdb.c | 8 +-
|
||
src-util/dic-tool.c | 86 +++++++++++++++++---
|
||
src-util/egg.c | 9 +++
|
||
src-util/input.c | 87 +++++++++++++++++----
|
||
src-util/rkconv.c | 46 ++++++++---
|
||
src-worddic/dic_util.c | 28 +++++--
|
||
src-worddic/ext_ent.c | 38 +++++++--
|
||
src-worddic/feature_set.c | 7 ++
|
||
src-worddic/matrix.c | 75 +++++++++++++++---
|
||
src-worddic/priv_dic.c | 56 ++++++++-----
|
||
src-worddic/record.c | 30 +++++--
|
||
src-worddic/textdict.c | 31 +++++---
|
||
src-worddic/texttrie.c | 63 ++++++++++-----
|
||
src-worddic/word_dic.c | 20 ++++-
|
||
src-worddic/word_lookup.c | 7 +-
|
||
test/check.c | 30 +++++--
|
||
test/main.c | 15 +++-
|
||
test/test-matrix.c | 7 ++
|
||
51 files changed, 1314 insertions(+), 345 deletions(-)
|
||
|
||
diff --git a/anthy/corpus.h b/anthy/corpus.h
|
||
index 0a4a8e0..eedc41f 100644
|
||
--- a/anthy/corpus.h
|
||
+++ b/anthy/corpus.h
|
||
@@ -21,5 +21,6 @@ void corpus_build(struct corpus *c);
|
||
void corpus_dump(struct corpus *c);
|
||
void corpus_write_bucket(FILE *fp, struct corpus *c);
|
||
void corpus_write_array(FILE *fp, struct corpus *c);
|
||
+void corpus_free(struct corpus *c);
|
||
|
||
#endif
|
||
diff --git a/anthy/logger.h b/anthy/logger.h
|
||
index a80fb5f..7d0f08a 100644
|
||
--- a/anthy/logger.h
|
||
+++ b/anthy/logger.h
|
||
@@ -4,5 +4,6 @@
|
||
|
||
void anthy_do_set_logger(void (*)(int , const char*), int lv);
|
||
void anthy_log(int lv, const char *, ...);
|
||
+const char * anthy_strerror(int errnum);
|
||
|
||
#endif
|
||
diff --git a/anthy/matrix.h b/anthy/matrix.h
|
||
index f424048..8245dca 100644
|
||
--- a/anthy/matrix.h
|
||
+++ b/anthy/matrix.h
|
||
@@ -22,5 +22,6 @@ void anthy_sparse_matrix_make_matrix(struct sparse_matrix *m);
|
||
struct matrix_image *anthy_matrix_image_new(struct sparse_matrix *s);
|
||
/* 行列イメージにアクセスするAPI(配列はnetwork byte order) */
|
||
int anthy_matrix_image_peek(int *im, int row, int col);
|
||
+void anthy_sparse_matrix_free(struct sparse_matrix *m);
|
||
|
||
#endif
|
||
diff --git a/calctrans/calctrans.c b/calctrans/calctrans.c
|
||
index 2855b7c..a5782c6 100644
|
||
--- a/calctrans/calctrans.c
|
||
+++ b/calctrans/calctrans.c
|
||
@@ -14,6 +14,7 @@
|
||
*
|
||
* Copyright (C) 2006 HANAOKA Toshiyuki
|
||
* Copyright (C) 2006-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -31,17 +32,19 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <math.h>
|
||
|
||
#include <anthy/anthy.h>
|
||
-#include <anthy/xstr.h>
|
||
-#include <anthy/feature_set.h>
|
||
+#include <anthy/corpus.h>
|
||
#include <anthy/diclib.h>
|
||
+#include <anthy/feature_set.h>
|
||
+#include <anthy/logger.h>
|
||
+#include <anthy/xstr.h>
|
||
#include "input_set.h"
|
||
-#include <anthy/corpus.h>
|
||
|
||
#define FEATURE_SET_SIZE NR_EM_FEATURES
|
||
|
||
@@ -155,7 +158,7 @@ static void
|
||
parse_indep(struct input_info *m, struct sentence_info *sinfo,
|
||
char *line, char *buf, int error_class)
|
||
{
|
||
- struct array features;
|
||
+ struct array features = { 0, };
|
||
char *s;
|
||
int weight = 1;
|
||
/**/
|
||
@@ -341,6 +344,7 @@ dump_features(FILE *ofp, struct input_set *is)
|
||
for (i = 0; i < nr; i++) {
|
||
dump_line(ofp, lines[i]);
|
||
}
|
||
+ free(lines);
|
||
}
|
||
|
||
static void
|
||
@@ -372,7 +376,8 @@ convert_line(FILE *ofp, char *buf)
|
||
}
|
||
|
||
static void
|
||
-convert_file(FILE *ifp)
|
||
+convert_file(FILE *ifp,
|
||
+ const char *ifn)
|
||
{
|
||
char buf[1024];
|
||
FILE *ofp = NULL;
|
||
@@ -400,6 +405,10 @@ convert_file(FILE *ifp)
|
||
write_nl(ofp, 0);
|
||
}
|
||
} else {
|
||
+ if (!ofp) {
|
||
+ anthy_log(0, "section could not found in %s\n", ifn);
|
||
+ continue;
|
||
+ }
|
||
convert_line(ofp, buf);
|
||
}
|
||
}
|
||
@@ -420,7 +429,7 @@ convert_data(int nr_fn, char **fns)
|
||
fprintf(stderr, "failed to open (%s)\n", fns[i]);
|
||
continue;
|
||
}
|
||
- convert_file(ifp);
|
||
+ convert_file(ifp, fns[i]);
|
||
fclose(ifp);
|
||
}
|
||
}
|
||
@@ -468,7 +477,10 @@ static void
|
||
string_pool_sort(struct string_pool *sp)
|
||
{
|
||
int idx, h;
|
||
- sp->array = malloc(sizeof(struct string_node *) * sp->nr);
|
||
+ if (!(sp->array = malloc(sizeof(struct string_node *) * sp->nr))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (idx = 0, h = 0; h < STRING_HASH_SIZE; h++) {
|
||
struct string_node *node;
|
||
for (node = sp->hash[h].next_hash; node; node = node->next_hash) {
|
||
@@ -494,6 +506,7 @@ static unsigned int
|
||
string_hash(const unsigned char *str)
|
||
{
|
||
unsigned int h = 0;
|
||
+ assert(str);
|
||
while (*str) {
|
||
h += *str;
|
||
h *= 13;
|
||
@@ -526,10 +539,20 @@ static void
|
||
flush_extract_stat(struct extract_stat *es, struct string_pool *sp)
|
||
{
|
||
int i;
|
||
+ assert(es);
|
||
+ if (es->nr > 0)
|
||
+ assert(es->info);
|
||
for (i = 0; i < es->nr; i++) {
|
||
if (es->info[i].valid) {
|
||
struct string_node *node;
|
||
node = find_string_node(sp, es->info[i].indep);
|
||
+ if (!node) {
|
||
+ anthy_log(0, "Failed malloc at %d/%d in %s:%d\n",
|
||
+ i, es->nr, __FILE__, __LINE__);
|
||
+ free(es->info[i].indep);
|
||
+ es->info[i].indep = NULL;
|
||
+ continue;
|
||
+ }
|
||
if (node->key == 0) {
|
||
xstr *xs = anthy_cstr_to_xstr(node->str, ANTHY_EUC_JP_ENCODING);
|
||
node->key = anthy_xstr_hash(xs);
|
||
@@ -585,6 +608,8 @@ static void
|
||
fill_missed_word(struct extract_stat *es, char *buf)
|
||
{
|
||
char *c = get_indep_part(buf);
|
||
+ assert(es);
|
||
+ assert(es->info);
|
||
if (!c) {
|
||
return ;
|
||
}
|
||
@@ -669,6 +694,10 @@ proc_corpus(int nr_fn, char **fns, FILE *ofp)
|
||
fprintf(stderr, " %d sentences\n", m->nr_sentences);
|
||
fprintf(stderr, " %d connections\n", m->nr_connections);
|
||
fprintf(stderr, " %d segments\n", m->nr_connections - m->nr_sentences);
|
||
+ input_set_free(m->seg_is);
|
||
+ input_set_free(m->cand_is);
|
||
+ corpus_free(m->indep_corpus);
|
||
+ free(m);
|
||
}
|
||
|
||
int
|
||
@@ -682,7 +711,10 @@ main(int argc, char **argv)
|
||
int extract = 0;
|
||
|
||
ofp = NULL;
|
||
- input_files = malloc(sizeof(char *) * argc);
|
||
+ if (!(input_files = malloc(sizeof(char *) * argc))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 1;
|
||
+ }
|
||
|
||
for (i = 1; i < argc; i++) {
|
||
char *arg = argv[i];
|
||
@@ -700,15 +732,17 @@ main(int argc, char **argv)
|
||
extract = 1;
|
||
} else {
|
||
input_files[nr_input] = arg;
|
||
- nr_input ++;
|
||
+ nr_input++;
|
||
}
|
||
}
|
||
if (extract) {
|
||
printf(" -- extracting missed words\n");
|
||
- if (!ofp) {
|
||
+ if (!ofp)
|
||
ofp = stdout;
|
||
- }
|
||
extract_word(nr_input, input_files, ofp);
|
||
+ free(input_files);
|
||
+ if (ofp != stdout)
|
||
+ fclose(ofp);
|
||
return 0;
|
||
}
|
||
if (ofp) {
|
||
@@ -720,6 +754,7 @@ main(int argc, char **argv)
|
||
printf(" -- converting dictionary from text to binary form\n");
|
||
convert_data(nr_input, input_files);
|
||
}
|
||
+ free(input_files);
|
||
|
||
return 0;
|
||
}
|
||
diff --git a/calctrans/corpus.c b/calctrans/corpus.c
|
||
index 42f07ef..0b441e3 100644
|
||
--- a/calctrans/corpus.c
|
||
+++ b/calctrans/corpus.c
|
||
@@ -3,7 +3,7 @@
|
||
* 現時点では例文をすべて入れているが、そのうちフィルターすることも考えられる
|
||
*
|
||
* Copyright (C) 2007 TABATA Yusuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -20,11 +20,13 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
|
||
#include <anthy/corpus.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
#define MAX_NR_VAL 8
|
||
#define BUCKET_SIZE 8192
|
||
@@ -95,6 +97,10 @@ struct corpus *
|
||
corpus_new(void)
|
||
{
|
||
struct corpus *c = malloc(sizeof(*c));
|
||
+ if (!c) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
c->nr_node = 0;
|
||
c->array_size = 0;
|
||
c->array = NULL;
|
||
@@ -154,7 +160,11 @@ corpus_build_flatten(struct corpus *c)
|
||
int i, j;
|
||
int idx = 0;
|
||
int nr_valid_elms = count_nr_valid_values(c);
|
||
- c->elms = malloc(sizeof(struct element) * nr_valid_elms);
|
||
+ assert(c);
|
||
+ if (!(c->elms = calloc(nr_valid_elms, sizeof(struct element)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (i = 0; i < c->nr_node; i++) {
|
||
struct node *nd = &c->array[i];
|
||
if (nd->flags & ELM_INVALID) {
|
||
@@ -164,9 +174,8 @@ corpus_build_flatten(struct corpus *c)
|
||
c->elms[idx].val = nd->val[j];
|
||
c->elms[idx].next_idx = -1;
|
||
c->elms[idx].flags = nd->flags;
|
||
- if (j == 0) {
|
||
- c->elms[idx].flags |= ELM_WORD_BORDER;
|
||
- }
|
||
+ if (j == 0)
|
||
+ c->elms[idx].flags |= ELM_WORD_BORDER;
|
||
c->elms[idx].idx = idx;
|
||
idx++;
|
||
}
|
||
@@ -177,7 +186,10 @@ static struct bucket *
|
||
find_bucket(struct corpus *c, int val)
|
||
{
|
||
int i;
|
||
- int h = val % c->nr_buckets;
|
||
+ int h;
|
||
+ assert(c);
|
||
+ assert(c->buckets);
|
||
+ h = val % c->nr_buckets;
|
||
for (i = 0; i < MAX_COLLISION; i++) {
|
||
struct bucket *bkt = &c->buckets[h];
|
||
if (bkt->key == val) {
|
||
@@ -188,10 +200,10 @@ find_bucket(struct corpus *c, int val)
|
||
return bkt;
|
||
}
|
||
/**/
|
||
- h ++;
|
||
+ h++;
|
||
h %= c->nr_buckets;
|
||
}
|
||
- c->bucket_collision ++;
|
||
+ c->bucket_collision++;
|
||
return NULL;
|
||
}
|
||
|
||
@@ -199,6 +211,11 @@ static void
|
||
corpus_build_link(struct corpus *c)
|
||
{
|
||
int i;
|
||
+ assert(c);
|
||
+ if (!(c->elms)) {
|
||
+ anthy_log(0, "c->elms should not be null.\n");
|
||
+ return;
|
||
+ }
|
||
for (i = 0; i < c->nr_values; i++) {
|
||
struct element *elm = &c->elms[i];
|
||
struct bucket *bkt = find_bucket(c, elm->val);
|
||
@@ -275,3 +292,14 @@ corpus_write_array(FILE *fp, struct corpus *c)
|
||
c->elms[i].next_idx);
|
||
}
|
||
}
|
||
+
|
||
+void
|
||
+corpus_free (struct corpus *c)
|
||
+{
|
||
+ if (!c)
|
||
+ return;
|
||
+ free (c->array);
|
||
+ free (c->elms);
|
||
+ free (c->buckets);
|
||
+ free (c);
|
||
+}
|
||
diff --git a/calctrans/input_set.c b/calctrans/input_set.c
|
||
index 0a880b2..ccf108d 100644
|
||
--- a/calctrans/input_set.c
|
||
+++ b/calctrans/input_set.c
|
||
@@ -2,14 +2,18 @@
|
||
*
|
||
* Copyright (C) 2006 HANAOKA Toshiyuki
|
||
* Copyright (C) 2006-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
* Special Thanks: Google Summer of Code Program 2006
|
||
*
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <math.h>
|
||
+
|
||
+#include <anthy/logger.h>
|
||
#include "input_set.h"
|
||
|
||
#define HASH_SIZE 1024
|
||
@@ -75,11 +79,18 @@ add_line(struct input_set *is, int *features, int nr)
|
||
{
|
||
int i, h;
|
||
struct input_line *il;
|
||
- il = malloc(sizeof(struct input_line));
|
||
+ if (!(il = malloc(sizeof(struct input_line)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
il->nr_features = nr;
|
||
- il->features = malloc(sizeof(int) * nr);
|
||
- for (i = 0; i < nr; i++) {
|
||
- il->features[i] = features[i];
|
||
+ if (!(il->features = malloc(sizeof(int) * nr))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ il->nr_features = nr = 0;
|
||
+ } else {
|
||
+ for (i = 0; i < nr; i++) {
|
||
+ il->features[i] = features[i];
|
||
+ }
|
||
}
|
||
il->weight = 0;
|
||
il->negative_weight = 0;
|
||
@@ -114,9 +125,10 @@ input_set_set_features(struct input_set *is, int *features,
|
||
|
||
/**/
|
||
il = find_same_line(is, features, nr);
|
||
- if (!il) {
|
||
+ if (!il)
|
||
il = add_line(is, features, nr);
|
||
- }
|
||
+ if (!il)
|
||
+ return;
|
||
/**/
|
||
if (weight > 0) {
|
||
il->weight += weight;
|
||
@@ -132,7 +144,10 @@ input_set_create(void)
|
||
{
|
||
int i;
|
||
struct input_set *is;
|
||
- is = malloc(sizeof(struct input_set));
|
||
+ if (!(is = malloc(sizeof(struct input_set)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
is->lines = NULL;
|
||
/**/
|
||
for (i = 0; i < HASH_SIZE; i++) {
|
||
@@ -185,13 +200,46 @@ input_set_output_feature_freq(FILE *fp, struct input_set *is)
|
||
}
|
||
}
|
||
|
||
+static void
|
||
+input_line_free (struct input_line **il)
|
||
+{
|
||
+ assert (il);
|
||
+ if (!(*il))
|
||
+ return;
|
||
+ free ((*il)->features);
|
||
+ input_line_free (&((*il)->next_line));
|
||
+ free (*il);
|
||
+ *il = NULL;
|
||
+}
|
||
+
|
||
+void
|
||
+input_set_free (struct input_set *is)
|
||
+{
|
||
+ int i;
|
||
+ if (!is)
|
||
+ return;
|
||
+ input_line_free (&is->lines);
|
||
+ for (i = 0; i < HASH_SIZE; i++)
|
||
+ free (is->feature_freq->hash_head[i].next);
|
||
+ free (is->feature_freq->hash_head);
|
||
+ free (is->feature_freq);
|
||
+ free (is);
|
||
+}
|
||
+
|
||
struct int_map *
|
||
int_map_new(void)
|
||
{
|
||
int i;
|
||
struct int_map *im = malloc(sizeof(struct int_map));
|
||
+ if (!im) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
im->nr = 0;
|
||
- im->hash_head = malloc(sizeof(struct int_map_node) * HASH_SIZE);
|
||
+ if (!(im->hash_head = malloc(sizeof(struct int_map_node) * HASH_SIZE))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return im;
|
||
+ }
|
||
for (i = 0; i < HASH_SIZE; i++) {
|
||
im->hash_head[i].next = NULL;
|
||
}
|
||
@@ -234,17 +282,20 @@ int_map_set(struct int_map *im, int idx, int val)
|
||
int h;
|
||
if (node) {
|
||
node->val = val;
|
||
- return ;
|
||
+ return;
|
||
}
|
||
/**/
|
||
- node = malloc(sizeof(struct int_map_node));
|
||
+ if (!(node = malloc(sizeof(struct int_map_node)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
node->key = idx;
|
||
node->val = val;
|
||
h = node_index(idx);
|
||
node->next = im->hash_head[h].next;
|
||
im->hash_head[h].next = node;
|
||
/**/
|
||
- im->nr ++;
|
||
+ im->nr++;
|
||
}
|
||
|
||
void
|
||
@@ -253,6 +304,7 @@ int_map_flatten(struct int_map *im)
|
||
int i;
|
||
struct int_map_node *node;
|
||
int max_n = 0;
|
||
+ assert(im->hash_head);
|
||
/* 配列を準備する */
|
||
im->array_size = im->nr * 2;
|
||
im->array = malloc(sizeof(struct int_map_node *) *
|
||
diff --git a/calctrans/input_set.h b/calctrans/input_set.h
|
||
index 45d5931..8d1f875 100644
|
||
--- a/calctrans/input_set.h
|
||
+++ b/calctrans/input_set.h
|
||
@@ -27,6 +27,7 @@ struct input_set *input_set_filter(struct input_set *is,
|
||
void input_set_output_feature_freq(FILE *fp, struct input_set *is);
|
||
/**/
|
||
struct input_line *input_set_get_input_line(struct input_set *is);
|
||
+void input_set_free(struct input_set *is);
|
||
|
||
|
||
struct int_map *int_map_new(void);
|
||
diff --git a/configure.ac b/configure.ac
|
||
index 7b011ec..270c3f2 100644
|
||
--- a/configure.ac
|
||
+++ b/configure.ac
|
||
@@ -22,6 +22,8 @@ AC_PROG_CPP
|
||
AM_PROG_LIBTOOL
|
||
AM_PATH_LISPDIR
|
||
|
||
+AC_CHECK_FUNCS([strerror_r])
|
||
+
|
||
AM_CONDITIONAL(ELISP, test x$lispdir != x)
|
||
|
||
dnl without emacs. install-lispLISP does mkdir /anthy
|
||
diff --git a/depgraph/mkdepgraph.c b/depgraph/mkdepgraph.c
|
||
index 5a63d5b..b627283 100644
|
||
--- a/depgraph/mkdepgraph.c
|
||
+++ b/depgraph/mkdepgraph.c
|
||
@@ -1,6 +1,7 @@
|
||
/*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
* Copyright (C) 2004-2006 YOSHIDA Yuichi
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
* 付属語グラフをバイナリ化する
|
||
@@ -23,6 +24,7 @@
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
@@ -54,7 +56,11 @@ static int nrRules;
|
||
static int
|
||
get_node_id_by_name(const char *name)
|
||
{
|
||
+ struct dep_node *tmp = NULL;
|
||
+ char **tmp2 = NULL;
|
||
int i;
|
||
+ if (nrNodes > 0)
|
||
+ assert(gNodeNames);
|
||
/* 登録済みのものから探す */
|
||
for (i = 0; i < nrNodes; i++) {
|
||
if (!strcmp(name,gNodeNames[i])) {
|
||
@@ -62,8 +68,24 @@ get_node_id_by_name(const char *name)
|
||
}
|
||
}
|
||
/* なかったので作る */
|
||
- gNodes = realloc(gNodes, sizeof(struct dep_node)*(nrNodes+1));
|
||
- gNodeNames = realloc(gNodeNames, sizeof(char*)*(nrNodes+1));
|
||
+ if (!(tmp = realloc(gNodes, sizeof(struct dep_node)*(nrNodes+1)))) {
|
||
+ anthy_log(0, "Could not realloc gNodes.\n");
|
||
+ free(gNodes);
|
||
+ gNodes = NULL;
|
||
+ nrNodes = 0;
|
||
+ return 0;
|
||
+ }
|
||
+ gNodes = tmp;
|
||
+ if (!(tmp2 = realloc(gNodeNames, sizeof(char*)*(nrNodes+1)))) {
|
||
+ anthy_log(0, "Could not realloc gNodeNames.\n");
|
||
+ free(gNodes);
|
||
+ gNodes = NULL;
|
||
+ free(gNodeNames);
|
||
+ gNodeNames = NULL;
|
||
+ nrNodes = 0;
|
||
+ return 0;
|
||
+ }
|
||
+ gNodeNames = tmp2;
|
||
gNodes[nrNodes].nr_branch = 0;
|
||
gNodes[nrNodes].branch = 0;
|
||
gNodeNames[nrNodes] = strdup(name);
|
||
@@ -78,6 +100,7 @@ find_branch(struct dep_node *node, xstr **strs, int nr_strs)
|
||
{
|
||
struct dep_branch *db;
|
||
int i, j;
|
||
+ assert(node);
|
||
/* 同じ遷移条件のブランチを探す */
|
||
for (i = 0; i < node->nr_branch; i++) {
|
||
db = &node->branch[i];
|
||
@@ -188,12 +211,15 @@ parse_dep(char **tokens, int nr)
|
||
struct dep_branch *db;
|
||
struct dep_node *dn;
|
||
int nr_strs;
|
||
- xstr **strs = alloca(sizeof(xstr*) * nr);
|
||
|
||
+ assert(gNodes);
|
||
+ xstr **strs = alloca(sizeof(xstr*) * nr);
|
||
/* ノードとそのidを確保 */
|
||
id = get_node_id_by_name(tokens[row]);
|
||
+ assert(id < nrNodes);
|
||
dn = &gNodes[id];
|
||
- row ++;
|
||
+ row++;
|
||
+ assert(dn);
|
||
|
||
nr_strs = 0;
|
||
|
||
@@ -236,9 +262,14 @@ static void
|
||
check_nodes(void)
|
||
{
|
||
int i;
|
||
+ if (nrNodes > 0) {
|
||
+ assert(gNodes);
|
||
+ assert(gNodeNames);
|
||
+ }
|
||
for (i = 1; i < nrNodes; i++) {
|
||
if (gNodes[i].nr_branch == 0) {
|
||
- anthy_log(0, "node %s has no branch.\n", gNodeNames);
|
||
+ anthy_log(0, "node %s has no branch.\n",
|
||
+ gNodeNames ? gNodeNames[i] : "(null)");
|
||
}
|
||
}
|
||
}
|
||
@@ -278,12 +309,28 @@ init_depword_tab(void)
|
||
static void
|
||
parse_indep(char **tokens, int nr)
|
||
{
|
||
+ struct wordseq_rule *tmp = NULL;
|
||
if (nr < 2) {
|
||
printf("Syntex error in indepword defs"
|
||
" :%d.\n", anthy_get_line_number());
|
||
return ;
|
||
}
|
||
- gRules = realloc(gRules, sizeof(struct wordseq_rule)*(nrRules+1));
|
||
+ if (!(tmp = realloc(gRules, sizeof(struct wordseq_rule)*(nrRules+1)))) {
|
||
+ anthy_log(0, "Could not realloc gRules.\n");
|
||
+ /* CPPCHECK_WARNING and CLANG_WARNING are conflicted.
|
||
+ * CPPCHECK_WARNING reports: Common realloc mistake:
|
||
+ * 'gRules' nulled but not freed upon failure
|
||
+ * also CLANG_WARNING reports: Potential leak of memory ponted to by
|
||
+ * 'gRules'
|
||
+ * On the other hand,
|
||
+ * CLANG_WARNING reports: 'gRules' is freed twice.
|
||
+ */
|
||
+ free(gRules);
|
||
+ gRules = NULL;
|
||
+ nrRules = 0;
|
||
+ return;
|
||
+ }
|
||
+ gRules= tmp;
|
||
|
||
/* 行の先頭には品詞の名前が入っている */
|
||
gRules[nrRules].wt = anthy_init_wtype_by_name(tokens[0]);
|
||
@@ -295,7 +342,7 @@ parse_indep(char **tokens, int nr)
|
||
printf("%d (%s)\n", nrRules, tokens[0]);
|
||
}
|
||
|
||
- nrRules ++;
|
||
+ nrRules++;
|
||
}
|
||
|
||
/** 自立語からの遷移表 */
|
||
@@ -405,6 +452,11 @@ write_file(const char* file_name)
|
||
FILE* fp = fopen(file_name, "w");
|
||
int* node_offset = malloc(sizeof(int) * nrNodes); /* gNodesのファイル上の位置 */
|
||
|
||
+ if (!fp) {
|
||
+ anthy_log(0, "Could not write-open %s.\n", file_name);
|
||
+ free(node_offset);
|
||
+ return;
|
||
+ }
|
||
/* 各ルール */
|
||
write_nl(fp, nrRules);
|
||
for (i = 0; i < nrRules; ++i) {
|
||
@@ -414,6 +466,8 @@ write_file(const char* file_name)
|
||
|
||
write_nl(fp, nrNodes);
|
||
|
||
+ if (nrNodes > 0)
|
||
+ assert(gNodes);
|
||
for (i = 0; i < nrNodes; ++i) {
|
||
write_node(fp, &gNodes[i]);
|
||
}
|
||
diff --git a/mkanthydic/mkfiledic.c b/mkanthydic/mkfiledic.c
|
||
index 8611dae..f3e502b 100644
|
||
--- a/mkanthydic/mkfiledic.c
|
||
+++ b/mkanthydic/mkfiledic.c
|
||
@@ -18,7 +18,7 @@
|
||
*
|
||
* Copyright (C) 2005-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2006-2007 TABATA Yusuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -40,8 +40,9 @@
|
||
#include <stdlib.h>
|
||
#include <sys/stat.h>
|
||
|
||
-#include <anthy/xstr.h>
|
||
#include <anthy/diclib.h>
|
||
+#include <anthy/logger.h>
|
||
+#include <anthy/xstr.h>
|
||
|
||
#define SECTION_ALIGNMENT 64
|
||
#define DIC_NAME "anthy.dic"
|
||
@@ -64,9 +65,10 @@ static int
|
||
get_file_size(const char* fn)
|
||
{
|
||
struct stat st;
|
||
- if (stat(fn, &st) < 0) {
|
||
+ if (!fn)
|
||
+ return -1;
|
||
+ if (stat(fn, &st) < 0)
|
||
return -1;
|
||
- }
|
||
return (st.st_size + SECTION_ALIGNMENT - 1) & (-SECTION_ALIGNMENT);
|
||
}
|
||
|
||
@@ -74,6 +76,10 @@ static char *
|
||
get_file_name(const char *prefix, struct header_entry* entry)
|
||
{
|
||
char *fn = malloc(strlen(prefix) + strlen(entry->file_name) + 4);
|
||
+ if (!fn) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
sprintf(fn, "%s/%s", prefix, entry->file_name);
|
||
return fn;
|
||
}
|
||
@@ -157,6 +163,8 @@ write_contents(FILE* fp, const char *prefix,
|
||
FILE* in_fp;
|
||
char *fn = get_file_name(prefix, &entries[i]);
|
||
|
||
+ if (!fn)
|
||
+ break;
|
||
in_fp = fopen(fn, "r");
|
||
if (in_fp == NULL) {
|
||
printf("failed to open %s\n", fn);
|
||
diff --git a/mkworddic/calcfreq.c b/mkworddic/calcfreq.c
|
||
index bb72b60..7743e16 100644
|
||
--- a/mkworddic/calcfreq.c
|
||
+++ b/mkworddic/calcfreq.c
|
||
@@ -1,5 +1,11 @@
|
||
-/* ñ<><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>٤<EFBFBD><D9A4><EFBFBD><D7BB><EFBFBD><EFBFBD><EFBFBD> */
|
||
+/* 単語の頻度を計算する
|
||
+ *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
+ */
|
||
+
|
||
#include <stdlib.h>
|
||
+
|
||
+#include <anthy/logger.h>
|
||
#include "mkdic.h"
|
||
|
||
static int
|
||
@@ -16,10 +22,11 @@ count_nr_words(struct yomi_entry_list *yl)
|
||
static struct word_entry **
|
||
make_word_array(struct yomi_entry_list *yl, int nr)
|
||
{
|
||
- struct word_entry **array = malloc(sizeof(struct word_entry *) *
|
||
- nr);
|
||
+ struct word_entry **array;
|
||
int nth = 0;
|
||
struct yomi_entry *ye;
|
||
+ if (!(array = malloc(sizeof(struct word_entry *) * nr)))
|
||
+ return NULL;
|
||
for (ye = yl->head; ye; ye = ye->next) {
|
||
int i;
|
||
for (i = 0; i < ye->nr_entries; i++) {
|
||
@@ -30,7 +37,7 @@ make_word_array(struct yomi_entry_list *yl, int nr)
|
||
return array;
|
||
}
|
||
|
||
-/** qsort<72>Ѥ<EFBFBD><D1A4><EFBFBD><EFBFBD>Ӵؿ<D3B4> */
|
||
+/** qsort用の比較関数 */
|
||
static int
|
||
compare_word_entry_by_freq(const void *p1, const void *p2)
|
||
{
|
||
@@ -47,7 +54,11 @@ set_freq(struct word_entry **array, int nr)
|
||
percent = percent ? percent : 1;
|
||
for (i = 0; i < nr; i++) {
|
||
struct word_entry *we = array[i];
|
||
- we->freq = 99 - (i / percent);
|
||
+ /* Effect よのなかほんとうにべんりになった in test/test.txt
|
||
+ * 便利 vs 弁理
|
||
+ * べんり #T05*300 便利 #T35*180 弁理 in alt-cannadic/gcanna.ctd
|
||
+ */
|
||
+ we->freq = (int)(99.0 - ((double)i / percent));
|
||
if (we->freq < 1) {
|
||
we->freq = 1;
|
||
}
|
||
@@ -66,7 +77,10 @@ calc_freq(struct yomi_entry_list *yl)
|
||
struct word_entry **we;
|
||
/**/
|
||
nr = count_nr_words(yl);
|
||
- we = make_word_array(yl, nr);
|
||
+ if (!(we = make_word_array(yl, nr))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
/**/
|
||
qsort(we, nr,
|
||
sizeof(struct word_entry *),
|
||
diff --git a/mkworddic/mkdic.c b/mkworddic/mkdic.c
|
||
index eb042e4..b0f9f4c 100644
|
||
--- a/mkworddic/mkdic.c
|
||
+++ b/mkworddic/mkdic.c
|
||
@@ -6,6 +6,7 @@
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
* Copyright (C) 2005 YOSHIDA Yuichi
|
||
* Copyright (C) 2001-2002 TAKAI Kousuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
* 辞書は読みをindexとし、品詞や変換後の単語(=entry)を検索
|
||
@@ -34,20 +35,22 @@
|
||
|
||
#include <sys/types.h>
|
||
#include <unistd.h>
|
||
+#include <assert.h>
|
||
+#include <errno.h>
|
||
+#include <ctype.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
-#include <errno.h>
|
||
-#include <ctype.h>
|
||
|
||
#include <config.h>
|
||
|
||
#include <anthy/anthy.h>
|
||
-#include <anthy/xstr.h>
|
||
-#include <anthy/wtype.h>
|
||
+#include <anthy/diclib.h>
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/ruleparser.h>
|
||
#include <anthy/word_dic.h>
|
||
-#include <anthy/diclib.h>
|
||
+#include <anthy/wtype.h>
|
||
+#include <anthy/xstr.h>
|
||
#include "mkdic.h"
|
||
|
||
#define MAX_LINE_LEN 10240
|
||
@@ -104,31 +107,32 @@ static void
|
||
open_output_files(void)
|
||
{
|
||
struct file_section *fs;
|
||
+ char *tmpdir = getenv("TMPDIR");
|
||
+ tmpdir = tmpdir ? strdup (tmpdir) : strdup ("/tmp");
|
||
for (fs = file_array; fs->fpp; fs ++) {
|
||
- char *tmpdir = getenv("TMPDIR");
|
||
+ char buf[256];
|
||
+ int fd = -1;
|
||
+ /* tmpfile()がTMPDIRを見ないため、TMPDIRを指定された場合mkstempを使う。
|
||
+ * tmpfile() creates files with predictable names, which is unsafe and
|
||
+ * is not recommended.
|
||
+ */
|
||
fs->fn = NULL;
|
||
- if (tmpdir) {
|
||
- /* tmpfile()がTMPDIRを見ないため、TMPDIRを指定された場合mkstempを使う。*/
|
||
- char buf[256];
|
||
- int fd = -1;
|
||
- snprintf(buf, sizeof(buf), "%s/mkanthydic.XXXXXX", tmpdir);
|
||
- fd = mkstemp(buf);
|
||
- if (fd == -1) {
|
||
- *(fs->fpp) = NULL;
|
||
- } else {
|
||
- *(fs->fpp) = fdopen(fd, "w+");
|
||
- fs->fn = strdup(buf);
|
||
- }
|
||
+ snprintf(buf, sizeof(buf), "%s/mkanthydic.XXXXXX", tmpdir);
|
||
+ fd = mkstemp(buf);
|
||
+ if (fd == -1) {
|
||
+ *(fs->fpp) = NULL;
|
||
} else {
|
||
- *(fs->fpp) = tmpfile();
|
||
+ *(fs->fpp) = fdopen(fd, "w+");
|
||
+ fs->fn = strdup(buf);
|
||
}
|
||
/**/
|
||
if (!(*(fs->fpp))) {
|
||
fprintf (stderr, "%s: cannot open temporary file: %s\n",
|
||
- progname, strerror (errno));
|
||
+ progname, strerror (errno));
|
||
exit (2);
|
||
}
|
||
}
|
||
+ free(tmpdir);
|
||
}
|
||
|
||
/* fflushする */
|
||
@@ -214,6 +218,7 @@ get_entry_from_line(char *buf)
|
||
{
|
||
char *sp;
|
||
sp = strchr(buf, ' ');
|
||
+ assert(sp);
|
||
while(*sp == ' ') {
|
||
sp ++;
|
||
}
|
||
@@ -275,7 +280,7 @@ push_back_word_entry(struct mkdic_stat *mds,
|
||
s = strdup(word);
|
||
}
|
||
ye->entries[ye->nr_entries].word_utf8 = s;
|
||
- ye->nr_entries ++;
|
||
+ ye->nr_entries++;
|
||
}
|
||
|
||
static int
|
||
@@ -432,8 +437,8 @@ static int
|
||
check_same_word(struct yomi_entry *ye, int idx)
|
||
{
|
||
struct word_entry *base = &ye->entries[idx];
|
||
- int i;
|
||
- for (i = idx -1; i >= 0; i--) {
|
||
+ int i = idx - 1;
|
||
+ if (i >= 0) {
|
||
struct word_entry *cur = &ye->entries[i];
|
||
if (base->raw_freq != cur->raw_freq) {
|
||
return 0;
|
||
@@ -535,7 +540,7 @@ find_yomi_entry(struct yomi_entry_list *yl, xstr *index, int create)
|
||
ye->next = yl->head;
|
||
yl->head = ye;
|
||
|
||
- yl->nr_entries ++;
|
||
+ yl->nr_entries++;
|
||
|
||
return ye;
|
||
}
|
||
@@ -563,7 +568,10 @@ mk_yomi_hash(FILE *yomi_hash_out, struct yomi_entry_list *yl)
|
||
unsigned char *hash_array;
|
||
int i;
|
||
struct yomi_entry *ye;
|
||
- hash_array = (unsigned char *)malloc(YOMI_HASH_ARRAY_SIZE);
|
||
+ if (!(hash_array = (unsigned char *)malloc(YOMI_HASH_ARRAY_SIZE))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (i = 0; i < YOMI_HASH_ARRAY_SIZE; i++) {
|
||
hash_array[i] = 0;
|
||
}
|
||
@@ -574,7 +582,7 @@ mk_yomi_hash(FILE *yomi_hash_out, struct yomi_entry_list *yl)
|
||
fwrite(hash_array, YOMI_HASH_ARRAY_SIZE, 1, yomi_hash_out);
|
||
printf("generated yomi hash bitmap (%d collisions/%d entries)\n",
|
||
yomi_hash_collision, yl->nr_valid_entries);
|
||
-
|
||
+ free(hash_array);
|
||
}
|
||
|
||
static struct adjust_command *
|
||
@@ -590,22 +598,20 @@ parse_modify_freq_command (const char *buf,
|
||
wt = strtok (NULL, " ");
|
||
word = strtok (NULL, " ");
|
||
type_str = strtok (NULL, " ");
|
||
- if (!yomi || !wt || !word || !type_str) {
|
||
+ if (!yomi || !wt || !word || !type_str)
|
||
return NULL;
|
||
- }
|
||
- if (!strcmp (type_str, "up")) {
|
||
+ if (!strcmp (type_str, "up"))
|
||
type = ADJUST_FREQ_UP;
|
||
- }
|
||
- if (!strcmp (type_str, "down")) {
|
||
+ if (!strcmp (type_str, "down"))
|
||
type = ADJUST_FREQ_DOWN;
|
||
- }
|
||
- if (!strcmp (type_str, "kill")) {
|
||
+ if (!strcmp (type_str, "kill"))
|
||
type = ADJUST_FREQ_KILL;
|
||
- }
|
||
- if (!type) {
|
||
+ if (!type)
|
||
+ return NULL;
|
||
+ if (!(cmd = malloc (sizeof (struct adjust_command)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
return NULL;
|
||
}
|
||
- cmd = malloc (sizeof (struct adjust_command));
|
||
cmd->type = type;
|
||
cmd->yomi = anthy_cstr_to_xstr (yomi, mds->input_encoding);
|
||
cmd->wt = get_wt_name(wt);
|
||
@@ -691,8 +697,9 @@ apply_adjust_command(struct yomi_entry_list *yl,
|
||
{
|
||
struct adjust_command *cmd;
|
||
for (cmd = ac_list->next; cmd; cmd = cmd->next) {
|
||
- struct word_entry *we = find_word_entry(yl, cmd->yomi,
|
||
- cmd->wt, cmd->word);
|
||
+ struct word_entry *we;
|
||
+ assert(cmd);
|
||
+ we = find_word_entry(yl, cmd->yomi, cmd->wt, cmd->word);
|
||
if (!we) {
|
||
char *yomi = anthy_xstr_to_cstr(cmd->yomi, ANTHY_UTF8_ENCODING);
|
||
printf("failed to find target of adjust command (%s, %s, %s)\n",
|
||
@@ -732,11 +739,14 @@ sort_word_dict(struct yomi_entry_list *yl)
|
||
struct yomi_entry *ye;
|
||
yl->nr_valid_entries = 0;
|
||
/* 単語を持つ読みだけを yl->ye_arrayに詰め直す */
|
||
- yl->ye_array = malloc(sizeof(struct yomi_entry *) * yl->nr_entries);
|
||
+ if (!(yl->ye_array = malloc(sizeof(struct yomi_entry *) * yl->nr_entries))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (i = 0, ye = yl->head; i < yl->nr_entries; i++, ye = ye->next) {
|
||
if (ye->nr_entries > 0) {
|
||
yl->ye_array[yl->nr_valid_entries] = ye;
|
||
- yl->nr_valid_entries ++;
|
||
+ yl->nr_valid_entries++;
|
||
}
|
||
}
|
||
/**/
|
||
@@ -984,7 +994,10 @@ build_reverse_dict(struct mkdic_stat *mds)
|
||
/* コピーする
|
||
* (元の辞書中のポインタはreallocで動くのでコピーが必要)
|
||
*/
|
||
- we_array = malloc(sizeof(struct word_entry )* n);
|
||
+ if (!(we_array = malloc(sizeof(struct word_entry )* n))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
n = 0;
|
||
for (ye = mds->yl.head; ye; ye = ye->next) {
|
||
for (i = 0; i < ye->nr_entries; i++) {
|
||
@@ -1041,12 +1054,32 @@ static void
|
||
set_exclude_wtypes(struct mkdic_stat *mds, int nr, char **tokens)
|
||
{
|
||
int i;
|
||
+ assert(nr > 0);
|
||
mds->nr_excluded = nr - 1;
|
||
- mds->excluded_wtypes = malloc(sizeof(char *) * (nr - 1));
|
||
+ if (nr == 1) {
|
||
+ anthy_log(0, "nr == 1 in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
+ if (!(mds->excluded_wtypes = malloc(sizeof(char *) * (nr - 1)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ mds->nr_excluded = 0;
|
||
+ return;
|
||
+ }
|
||
/**/
|
||
- for (i = 1; i < nr; i++) {
|
||
+ mds->excluded_wtypes[0] = NULL;
|
||
+ for (i = 1; i < nr; i++)
|
||
mds->excluded_wtypes[i - 1] = strdup(tokens[i]);
|
||
+}
|
||
+
|
||
+static void
|
||
+free_exclude_wtypes(struct mkdic_stat *mds)
|
||
+{
|
||
+ int i;
|
||
+ for (i = 0; i < mds->nr_excluded; i++) {
|
||
+ free (mds->excluded_wtypes[i]);
|
||
}
|
||
+ free (mds->excluded_wtypes);
|
||
+ mds->excluded_wtypes = NULL;
|
||
}
|
||
|
||
static void
|
||
@@ -1098,14 +1131,18 @@ show_command(char **tokens, int nr)
|
||
static int
|
||
execute_batch(struct mkdic_stat *mds, const char *fn)
|
||
{
|
||
- int nr;
|
||
- char **tokens;
|
||
+ int nr = 0;
|
||
+ char **tokens = NULL;
|
||
if (anthy_open_file(fn)) {
|
||
printf("mkanthydic: failed to open %s\n", fn);
|
||
return 1;
|
||
}
|
||
while (!anthy_read_line(&tokens, &nr)) {
|
||
- char *cmd = tokens[0];
|
||
+ char *cmd;
|
||
+ if (!nr)
|
||
+ break;
|
||
+ assert(nr > 0);
|
||
+ cmd = tokens[0];
|
||
show_command(tokens, nr);
|
||
if (!strcmp(cmd, "read") && nr == 2) {
|
||
read_dict_file(mds, tokens[1]);
|
||
@@ -1160,6 +1197,29 @@ init_mds(struct mkdic_stat *mds)
|
||
mds->excluded_wtypes = NULL;
|
||
}
|
||
|
||
+static void
|
||
+free_yomi_entry_list(struct yomi_entry_list *yl)
|
||
+{
|
||
+ struct yomi_entry *ye, *ye_prev;
|
||
+ int i;
|
||
+
|
||
+ free (yl->ye_array);
|
||
+ yl->ye_array = NULL;
|
||
+ for (i = 0, ye = yl->head; ye && (i < yl->nr_entries); i++) {
|
||
+ free (ye->index_xstr->str);
|
||
+ free (ye->index_xstr);
|
||
+ ye->index_xstr = NULL;
|
||
+ free (ye->index_str);
|
||
+ ye->index_str = NULL;
|
||
+ free (ye->entries);
|
||
+ ye->entries = NULL;
|
||
+ ye->hash_next = NULL;
|
||
+ ye_prev = ye;
|
||
+ ye = ye->next;
|
||
+ free (ye_prev);
|
||
+ }
|
||
+}
|
||
+
|
||
/* libanthyの使用する部分だけを初期化する */
|
||
static void
|
||
init_libs(void)
|
||
@@ -1180,6 +1240,7 @@ main(int argc, char **argv)
|
||
int i;
|
||
char *script_fn = NULL;
|
||
int help_mode = 0;
|
||
+ int retval;
|
||
|
||
anthy_init_wtypes();
|
||
init_libs();
|
||
@@ -1200,5 +1261,10 @@ main(int argc, char **argv)
|
||
print_usage();
|
||
}
|
||
|
||
- return execute_batch(&mds, script_fn);
|
||
+ retval = execute_batch(&mds, script_fn);
|
||
+ free_yomi_entry_list(&mds.yl);
|
||
+ free_exclude_wtypes(&mds);
|
||
+ free_uc_dict(mds.ud);
|
||
+ mds.ud = NULL;
|
||
+ return retval;
|
||
}
|
||
diff --git a/mkworddic/mkdic.h b/mkworddic/mkdic.h
|
||
index 3885c4f..ec09ec0 100644
|
||
--- a/mkworddic/mkdic.h
|
||
+++ b/mkworddic/mkdic.h
|
||
@@ -85,6 +85,7 @@ const char *get_wt_name(const char *name);
|
||
* 用例辞書を作る */
|
||
struct uc_dict *create_uc_dict(void);
|
||
void read_uc_file(struct uc_dict *ud, const char *fn);
|
||
+void free_uc_dict(struct uc_dict *dict);
|
||
void make_ucdict(FILE *out, struct uc_dict *uc);
|
||
/**/
|
||
|
||
diff --git a/mkworddic/mkudic.c b/mkworddic/mkudic.c
|
||
index 1bdf6ee..12d0a78 100644
|
||
--- a/mkworddic/mkudic.c
|
||
+++ b/mkworddic/mkudic.c
|
||
@@ -2,11 +2,13 @@
|
||
* 用例辞書を作る
|
||
*
|
||
* Copyright (C) 2003-2005 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <stdio.h>
|
||
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/matrix.h>
|
||
#include "mkdic.h"
|
||
|
||
@@ -54,7 +56,10 @@ commit_uc(struct uc_dict *dict, int x, int y)
|
||
if (x < 0 || y < 0) {
|
||
return ;
|
||
}
|
||
- uc = malloc(sizeof(struct use_case));
|
||
+ if (!(uc = malloc(sizeof(struct use_case)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
uc->id[0] = x;
|
||
uc->id[1] = y;
|
||
/**/
|
||
@@ -68,6 +73,10 @@ struct uc_dict *
|
||
create_uc_dict(void)
|
||
{
|
||
struct uc_dict *dict = malloc(sizeof(struct uc_dict));
|
||
+ if (!dict) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
dict->uc_head.next = NULL;
|
||
dict->nr_ucs = 0;
|
||
@@ -120,6 +129,22 @@ read_uc_file(struct uc_dict *dict, const char *fn)
|
||
}
|
||
off ++;
|
||
}
|
||
+ fclose(uc_file);
|
||
+}
|
||
+
|
||
+void
|
||
+free_uc_dict(struct uc_dict *dict)
|
||
+{
|
||
+ struct use_case *uc, *prev_uc;
|
||
+
|
||
+ if (!dict)
|
||
+ return;
|
||
+ for (uc = dict->uc_head.next; uc; ) {
|
||
+ prev_uc = uc;
|
||
+ uc = uc->next;
|
||
+ free (prev_uc);
|
||
+ }
|
||
+ free (dict);
|
||
}
|
||
|
||
/* 用例辞書をファイルに書き出す */
|
||
@@ -148,5 +173,7 @@ make_ucdict(FILE *uc_out, struct uc_dict *dict)
|
||
} else {
|
||
printf("udic: no use examples.\n");
|
||
}
|
||
-
|
||
+ anthy_sparse_matrix_free(sm);
|
||
+ free(mi->image);
|
||
+ free(mi);
|
||
}
|
||
diff --git a/mkworddic/writewords.c b/mkworddic/writewords.c
|
||
index d8eead7..e6e767c 100644
|
||
--- a/mkworddic/writewords.c
|
||
+++ b/mkworddic/writewords.c
|
||
@@ -7,6 +7,7 @@
|
||
* output_word_dict()が呼び出される
|
||
*
|
||
* Copyright (C) 2000-2006 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -126,7 +127,7 @@ static int
|
||
common_len(xstr *s1, xstr *s2)
|
||
{
|
||
int m,i;
|
||
- if (!s1 || !s2) {
|
||
+ if ((!s1) || (!s2)) {
|
||
return 0;
|
||
}
|
||
if (s1->len < s2->len) {
|
||
diff --git a/src-diclib/conf.c b/src-diclib/conf.c
|
||
index 810bf80..271052d 100644
|
||
--- a/src-diclib/conf.c
|
||
+++ b/src-diclib/conf.c
|
||
@@ -4,6 +4,7 @@
|
||
* 変数の関係に注意
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -20,6 +21,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <unistd.h>
|
||
#include <pwd.h>
|
||
#include <time.h>
|
||
@@ -89,7 +91,13 @@ get_subst(const char *s)
|
||
strchr(s, '}')) {
|
||
struct val_ent *val;
|
||
char *var = strdup(&s[2]);
|
||
- char *k = strchr(var, '}');
|
||
+ char *k;
|
||
+ if (!var) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
+ k = strchr(var, '}');
|
||
+ assert(k);
|
||
*k = 0;
|
||
val = find_val_ent(var);
|
||
free(var);
|
||
@@ -125,7 +133,10 @@ expand_string(const char *s)
|
||
struct expand_buf eb;
|
||
char *res;
|
||
eb.size = 256;
|
||
- eb.buf = malloc(eb.size);
|
||
+ if (!(eb.buf = malloc(eb.size))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
eb.cur = eb.buf;
|
||
eb.len = 0;
|
||
|
||
@@ -139,13 +150,14 @@ expand_string(const char *s)
|
||
eb.cur += len;
|
||
eb.len += len;
|
||
s = strchr(s, '}');
|
||
- s ++;
|
||
+ assert(s);
|
||
+ s++;
|
||
} else {
|
||
*eb.cur = *s;
|
||
/**/
|
||
- eb.cur ++;
|
||
+ eb.cur++;
|
||
s++;
|
||
- eb.len ++;
|
||
+ eb.len++;
|
||
}
|
||
/**/
|
||
ensure_buffer(&eb, 256);
|
||
diff --git a/src-diclib/diclib_inner.h b/src-diclib/diclib_inner.h
|
||
index 9da45ab..1b0f277 100644
|
||
--- a/src-diclib/diclib_inner.h
|
||
+++ b/src-diclib/diclib_inner.h
|
||
@@ -17,7 +17,7 @@ typedef enum
|
||
/* file_dic.h */
|
||
int anthy_init_file_dic(void);
|
||
void anthy_quit_file_dic(void);
|
||
-
|
||
+int anthy_file_test(const char *filename, AnthyFileTest test);
|
||
|
||
/* xchar.c */
|
||
void anthy_init_xchar_tab(void);
|
||
diff --git a/src-diclib/file_dic.c b/src-diclib/file_dic.c
|
||
index 2869648..5602ff0 100644
|
||
--- a/src-diclib/file_dic.c
|
||
+++ b/src-diclib/file_dic.c
|
||
@@ -121,7 +121,7 @@ anthy_path_skip_root (const char *file_name)
|
||
/* anthy_file_test:
|
||
* Copy from g_file_test()
|
||
*/
|
||
-static int
|
||
+int
|
||
anthy_file_test (const char *filename,
|
||
AnthyFileTest test)
|
||
{
|
||
diff --git a/src-diclib/filemap.c b/src-diclib/filemap.c
|
||
index c810719..1e228eb 100644
|
||
--- a/src-diclib/filemap.c
|
||
+++ b/src-diclib/filemap.c
|
||
@@ -4,7 +4,7 @@
|
||
* *将来的には一つのファイルを複数の目的にmapすることも考慮
|
||
*
|
||
* Copyright (C) 2005 TABATA Yusuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -89,7 +89,11 @@ anthy_mmap(const char *fn, int wr)
|
||
}
|
||
|
||
/* mmapに成功したので情報を返す */
|
||
- m = malloc(sizeof(struct filemapping));
|
||
+ if (!(m = malloc(sizeof(struct filemapping)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ munmap(ptr, st.st_size);
|
||
+ return NULL;
|
||
+ }
|
||
m->size = st.st_size;
|
||
m->ptr = ptr;
|
||
m->wr = wr;
|
||
diff --git a/src-diclib/logger.c b/src-diclib/logger.c
|
||
index 6e6d402..233a488 100644
|
||
--- a/src-diclib/logger.c
|
||
+++ b/src-diclib/logger.c
|
||
@@ -1,9 +1,11 @@
|
||
/*
|
||
* ログの出力
|
||
* $Id: logger.c,v 1.8 2002/05/14 13:24:47 yusuke Exp $
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
#include <stdio.h>
|
||
#include <stdarg.h>
|
||
+#include <string.h>
|
||
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/logger.h>
|
||
@@ -46,3 +48,24 @@ anthy_set_logger(anthy_logger lg, int level)
|
||
{
|
||
anthy_do_set_logger(lg, level);
|
||
}
|
||
+
|
||
+const char *
|
||
+anthy_strerror (int errnum)
|
||
+{
|
||
+ const char *msg;
|
||
+ static char buf[1024];
|
||
+
|
||
+#if defined(HAVE_STRERROR_R)
|
||
+# if defined(__GLIBC__) && !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
|
||
+ msg = strerror_r (errnum, buf, sizeof (buf));
|
||
+# else
|
||
+ strerror_r (errnum, buf, sizeof (buf));
|
||
+ msg = buf;
|
||
+# endif /* HAVE_STRERROR_R */
|
||
+#else
|
||
+ strncpy (buf, strerror (errnum), sizeof (buf));
|
||
+ buf[sizeof (buf) - 1] = '\0';
|
||
+ msg = buf;
|
||
+#endif
|
||
+ return msg;
|
||
+}
|
||
diff --git a/src-diclib/ruleparser.c b/src-diclib/ruleparser.c
|
||
index d83deac..7a40e37 100644
|
||
--- a/src-diclib/ruleparser.c
|
||
+++ b/src-diclib/ruleparser.c
|
||
@@ -3,6 +3,7 @@
|
||
* 汎用のファイル読み込みモジュール
|
||
*
|
||
* Copyright (C) 2000-2006 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -21,6 +22,7 @@
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
#include <ctype.h>
|
||
+#include <limits.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
@@ -137,9 +139,11 @@ get_token_in(struct line_stat *ls)
|
||
}
|
||
/* トークンが始まるまで空白を読み飛ばす */
|
||
do {
|
||
+ /* tainted cc should be sanitized */
|
||
+ cc = 0;
|
||
esc = mygetc(&cc);
|
||
- } while (cc > 0 && myisblank(cc) && esc == 0);
|
||
- if (cc == -1) {
|
||
+ } while (cc != EOF && cc > 0 && cc < INT_MAX && myisblank(cc) && esc == 0);
|
||
+ if (cc == EOF) {
|
||
return NULL;
|
||
}
|
||
if (cc == '\n'){
|
||
@@ -209,7 +213,8 @@ proc_include(void)
|
||
anthy_log(0, "Syntax error in include directive.\n");
|
||
return ;
|
||
}
|
||
- if (g_ps.cur_fpp > MAX_INCLUDE_DEPTH - 1) {
|
||
+ /* (i + 1) should < MAX_INCLUDE_DEPTH for g_ps.fp_stack[i + 1] */
|
||
+ if (g_ps.cur_fpp >= MAX_INCLUDE_DEPTH - 1) {
|
||
anthy_log(0, "Too deep include.\n");
|
||
return ;
|
||
}
|
||
diff --git a/src-diclib/xstr.c b/src-diclib/xstr.c
|
||
index 018a63d..21f3e04 100644
|
||
--- a/src-diclib/xstr.c
|
||
+++ b/src-diclib/xstr.c
|
||
@@ -11,7 +11,7 @@
|
||
* cstrはCの普通のEUC文字列
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -28,6 +28,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
@@ -35,6 +36,7 @@
|
||
#include "config.h"
|
||
/* for ANTHY_*_ENCODING */
|
||
#include <anthy/anthy.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
#include <anthy/xstr.h>
|
||
#include <anthy/xchar.h>
|
||
@@ -217,7 +219,8 @@ anthy_xstr_to_cstr(xstr *s, int encoding)
|
||
l++;
|
||
}
|
||
}
|
||
- p = (char *)malloc(l + 1);
|
||
+ if (!(p = (char *)malloc(l + 1)))
|
||
+ return NULL;
|
||
p[l] = 0;
|
||
j = 0;
|
||
for (i = 0; i < s->len; i++) {
|
||
@@ -240,9 +243,13 @@ anthy_xstr_dup(xstr *s)
|
||
{
|
||
int i;
|
||
xstr *x = (xstr *)malloc(sizeof(xstr));
|
||
+ if (!x)
|
||
+ return NULL;
|
||
x->len = s->len;
|
||
if (s->len) {
|
||
- x->str = malloc(sizeof(xchar)*s->len);
|
||
+ assert(s->str);
|
||
+ if (!(x->str = malloc(sizeof(xchar)*s->len)))
|
||
+ return x;
|
||
}else{
|
||
x->str = NULL;
|
||
}
|
||
@@ -258,8 +265,10 @@ anthy_xstr_dup_str(xstr *s)
|
||
xchar *c;
|
||
int i;
|
||
if (s->len) {
|
||
- c = malloc(sizeof(xchar)*s->len);
|
||
- }else{
|
||
+ assert(s->str);
|
||
+ if (!(c = malloc(sizeof(xchar)*s->len)))
|
||
+ return NULL;
|
||
+ } else {
|
||
c = 0;
|
||
}
|
||
for (i = 0; i < s->len; i++) {
|
||
@@ -443,8 +452,11 @@ xstr *
|
||
anthy_xstrcat(xstr *s, xstr *a)
|
||
{
|
||
int i, l;
|
||
+ xchar *xch;
|
||
if (!s) {
|
||
s = malloc(sizeof(xstr));
|
||
+ if (!s)
|
||
+ return NULL;
|
||
s->str = NULL;
|
||
s->len = 0;
|
||
}
|
||
@@ -457,7 +469,16 @@ anthy_xstrcat(xstr *s, xstr *a)
|
||
return s;
|
||
}
|
||
|
||
+ xch = s->str;
|
||
s->str = realloc(s->str, sizeof(xchar)*l);
|
||
+ if (!s->str) {
|
||
+ anthy_log(0, "Failed realloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ s->str = xch;
|
||
+ s->len = l - a->len;
|
||
+ return s;
|
||
+ }
|
||
+ if (a->len)
|
||
+ assert(a->str);
|
||
for (i = 0; i < a->len; i ++) {
|
||
s->str[s->len+i] = a->str[i];
|
||
}
|
||
@@ -480,14 +501,14 @@ long long
|
||
anthy_xstrtoll(xstr *x)
|
||
{
|
||
xchar c;
|
||
- int i;
|
||
+ int i, t = XCT_NONE;
|
||
long long n = 0;/* 数 */
|
||
- if (!x->len || x->len > 16) {
|
||
+ if (!x->len || x->len > 16)
|
||
return -1;
|
||
- }
|
||
- if ((!anthy_get_xstr_type(x)) & (XCT_NUM | XCT_WIDENUM)) {
|
||
+ for (i = 0; i < x->len; i++)
|
||
+ t |= anthy_get_xchar_type(x->str[i]);
|
||
+ if (!(t & (XCT_NUM | XCT_WIDENUM)))
|
||
return -1;
|
||
- }
|
||
for (i = 0; i < x->len; i++) {
|
||
c = x->str[i];
|
||
n *= 10;
|
||
@@ -503,7 +524,15 @@ anthy_xstr_wide_num_to_num(xstr* src_xs)
|
||
{
|
||
int i;
|
||
xstr *dst_xs;
|
||
- dst_xs = anthy_xstr_dup(src_xs);
|
||
+ if (!(dst_xs = anthy_xstr_dup(src_xs))) {
|
||
+ anthy_log(0, "Failed anthy_xstr_dup() in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
+ assert(src_xs);
|
||
+ if (src_xs->len) {
|
||
+ assert(src_xs->str);
|
||
+ assert(dst_xs->str);
|
||
+ }
|
||
for (i = 0; i < src_xs->len; ++i) {
|
||
dst_xs->str[i] = anthy_xchar_wide_num_to_num(src_xs->str[i]);
|
||
}
|
||
@@ -518,6 +547,15 @@ anthy_xstr_hira_to_kata(xstr *src_xs)
|
||
xstr *dst_xs;
|
||
int i, j;
|
||
dst_xs = anthy_xstr_dup(src_xs);
|
||
+ if (!dst_xs) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
+ if (dst_xs->len && !dst_xs->str) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ dst_xs->len = 0;
|
||
+ return dst_xs;
|
||
+ }
|
||
|
||
for (i = 0 ,j = 0; i < dst_xs->len; i++, j++) {
|
||
/* 「う゛」のチェック */
|
||
@@ -553,8 +591,20 @@ anthy_xstr_hira_to_half_kata(xstr *src_xs)
|
||
}
|
||
}
|
||
xs = malloc(sizeof(xstr));
|
||
+ if (!xs) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
xs->len = len;
|
||
xs->str = malloc(sizeof(xchar) * len);
|
||
+ if (len) {
|
||
+ assert(src_xs->str);
|
||
+ if (!xs->str) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ xs->len = 0;
|
||
+ return xs;
|
||
+ }
|
||
+ }
|
||
j = 0;
|
||
for (i = 0; i < src_xs->len; i++) {
|
||
const struct half_kana_table *tab = anthy_find_half_kana(src_xs->str[i]);
|
||
@@ -583,6 +633,18 @@ anthy_conv_half_wide(xstr *xs)
|
||
}
|
||
}
|
||
res = anthy_xstr_dup(xs);
|
||
+ if (!res) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
+ if (xs->len > 0) {
|
||
+ assert(xs->str);
|
||
+ if (!res->str) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ res->len = 0;
|
||
+ return res;
|
||
+ }
|
||
+ }
|
||
for (i = 0; i < xs->len; i++) {
|
||
res->str[i] = anthy_lookup_half_wide(xs->str[i]);
|
||
}
|
||
diff --git a/src-main/context.c b/src-main/context.c
|
||
index 1b211db..20dde71 100644
|
||
--- a/src-main/context.c
|
||
+++ b/src-main/context.c
|
||
@@ -8,6 +8,7 @@
|
||
*
|
||
* Funded by IPA未踏ソフトウェア創造事業 2001 10/29
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
* $Id: context.c,v 1.26 2002/11/17 14:45:47 yusuke Exp $
|
||
*/
|
||
@@ -26,16 +27,20 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
+#include <fcntl.h>
|
||
#include <sys/types.h>
|
||
#include <sys/stat.h>
|
||
#include <unistd.h>
|
||
|
||
+#include <errno.h>
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/alloc.h>
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/record.h>
|
||
#include <anthy/ordering.h>
|
||
#include <anthy/splitter.h>
|
||
@@ -81,10 +86,15 @@ release_segment(struct seg_ent *s)
|
||
anthy_release_cand_ent(s->cands[i]);
|
||
}
|
||
free (s->cands);
|
||
- }
|
||
- if (s->mw_array) {
|
||
- free(s->mw_array);
|
||
- }
|
||
+ s->cands = NULL;
|
||
+ }
|
||
+ free(s->mw_array);
|
||
+ s->mw_array = NULL;
|
||
+ s->best_mw = NULL;
|
||
+ s->str.str = NULL;
|
||
+ s->str.len = 0;
|
||
+ s->next = NULL;
|
||
+ s->prev = NULL;
|
||
free(s);
|
||
|
||
}
|
||
@@ -96,12 +106,13 @@ pop_back_seg_ent(struct anthy_context *c)
|
||
struct seg_ent *s;
|
||
s = c->seg_list.list_head.prev;
|
||
if (s == &c->seg_list.list_head) {
|
||
- return ;
|
||
+ return;
|
||
}
|
||
s->prev->next = s->next;
|
||
s->next->prev = s->prev;
|
||
+ c->seg_list.list_head.prev = s->next->prev;
|
||
release_segment(s);
|
||
- c->seg_list.nr_segments --;
|
||
+ c->seg_list.nr_segments--;
|
||
}
|
||
|
||
|
||
@@ -174,7 +185,10 @@ create_segment(struct anthy_context *ac, int from, int len,
|
||
struct meta_word* best_mw)
|
||
{
|
||
struct seg_ent* s;
|
||
- s = (struct seg_ent *)malloc(sizeof(struct seg_ent));
|
||
+ if (!(s = (struct seg_ent *)malloc(sizeof(struct seg_ent)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
s->str.str = &ac->str.str[from];
|
||
s->str.len = len;
|
||
s->from = from;
|
||
@@ -191,6 +205,7 @@ create_segment(struct anthy_context *ac, int from, int len,
|
||
static void
|
||
push_back_segment(struct anthy_context *ac, struct seg_ent *se)
|
||
{
|
||
+ assert(se);
|
||
se->next = &ac->seg_list.list_head;
|
||
se->prev = ac->seg_list.list_head.prev;
|
||
ac->seg_list.list_head.prev->next = se;
|
||
@@ -236,7 +251,10 @@ anthy_do_create_context(int encoding)
|
||
return NULL;
|
||
}
|
||
|
||
- ac = (struct anthy_context *)anthy_smalloc(context_ator);
|
||
+ if (!(ac = (struct anthy_context *)anthy_smalloc(context_ator))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
ac->str.str = NULL;
|
||
ac->str.len = 0;
|
||
ac->seg_list.nr_segments = 0;
|
||
@@ -383,15 +401,20 @@ anthy_do_resize_segment(struct anthy_context *ac,
|
||
|
||
/* resizeが可能か検査する */
|
||
if (nth >= ac->seg_list.nr_segments) {
|
||
- return ;
|
||
+ return;
|
||
}
|
||
index = get_nth_segment_index(ac, nth);
|
||
len = get_nth_segment_len(ac, nth);
|
||
if (index + len + resize > ac->str.len) {
|
||
- return ;
|
||
+ return;
|
||
}
|
||
if (len + resize < 1) {
|
||
- return ;
|
||
+ return;
|
||
+ }
|
||
+ if (index < 0) {
|
||
+ anthy_log(0, "Wrong segment index for %dth %s:%d\n",
|
||
+ nth, __FILE__, __LINE__);
|
||
+ return;
|
||
}
|
||
|
||
/* nth以降のseg_entを解放する */
|
||
@@ -454,7 +477,7 @@ anthy_do_set_prediction_str(struct anthy_context *ac, xstr* xs)
|
||
}
|
||
}
|
||
|
||
- prediction->str.str = (xchar*)malloc(sizeof(xchar*)*(xs->len+1));
|
||
+ prediction->str.str = (xchar*)malloc(sizeof(xchar) * (xs->len + 1));
|
||
anthy_xstrcpy(&prediction->str, xs);
|
||
prediction->str.str[xs->len]=0;
|
||
|
||
@@ -497,30 +520,31 @@ get_change_state(struct anthy_context *ac)
|
||
}
|
||
|
||
static void
|
||
-write_history(FILE *fp, struct anthy_context *ac)
|
||
+write_history(int fd,
|
||
+ struct anthy_context *ac)
|
||
{
|
||
int i;
|
||
/* 読み */
|
||
- fprintf(fp, "|");
|
||
+ dprintf(fd, "|");
|
||
for (i = 0; i < ac->seg_list.nr_segments; i++) {
|
||
struct seg_ent *s = anthy_get_nth_segment(&ac->seg_list, i);
|
||
char *c = anthy_xstr_to_cstr(&s->str, ANTHY_EUC_JP_ENCODING);
|
||
- fprintf(fp, "%s|", c);
|
||
+ dprintf(fd, "%s|", c);
|
||
free(c);
|
||
}
|
||
- fprintf(fp, " |");
|
||
+ dprintf(fd, " |");
|
||
/* 結果 */
|
||
for (i = 0; i < ac->seg_list.nr_segments; i++) {
|
||
struct seg_ent *s = anthy_get_nth_segment(&ac->seg_list, i);
|
||
char *c;
|
||
/**/
|
||
if (s->committed < 0) {
|
||
- fprintf(fp, "?|");
|
||
+ dprintf(fd, "?|");
|
||
continue ;
|
||
}
|
||
c = anthy_xstr_to_cstr(&s->cands[s->committed]->str,
|
||
ANTHY_EUC_JP_ENCODING);
|
||
- fprintf(fp, "%s|", c);
|
||
+ dprintf(fd, "%s|", c);
|
||
free(c);
|
||
}
|
||
}
|
||
@@ -528,28 +552,37 @@ write_history(FILE *fp, struct anthy_context *ac)
|
||
void
|
||
anthy_save_history(const char *fn, struct anthy_context *ac)
|
||
{
|
||
- FILE *fp;
|
||
+ int fd;
|
||
struct stat st;
|
||
if (!fn) {
|
||
- return ;
|
||
+ return;
|
||
}
|
||
- fp = fopen(fn, "a");
|
||
- if (!fp) {
|
||
- return ;
|
||
+ /* TOCTOU: Use fchmod() and fstat(). chmod() after stat() can cause a
|
||
+ * time-of-check, time-of-use race condition.
|
||
+ */
|
||
+ errno = 0;
|
||
+ fd = open(fn, O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
|
||
+ if (fd == -1) {
|
||
+ anthy_log(0, "Failed to open %s: %s\n", fn, anthy_strerror(errno));
|
||
+ return;
|
||
}
|
||
- if (stat(fn, &st) ||
|
||
+ if (fstat(fd, &st) ||
|
||
st.st_size > HISTORY_FILE_LIMIT) {
|
||
- fclose(fp);
|
||
- return ;
|
||
+ close(fd);
|
||
+ return;
|
||
}
|
||
/**/
|
||
- fprintf(fp, "anthy-%s ", anthy_get_version_string());
|
||
- fprintf(fp, "%s ", get_change_state(ac));
|
||
- write_history(fp, ac);
|
||
- fprintf(fp, "\n");
|
||
- fclose(fp);
|
||
+ dprintf(fd, "anthy-%s ", anthy_get_version_string());
|
||
+ dprintf(fd, "%s ", get_change_state(ac));
|
||
+ write_history(fd, ac);
|
||
+ dprintf(fd, "\n");
|
||
/**/
|
||
- chmod(fn, S_IREAD | S_IWRITE);
|
||
+ errno = 0;
|
||
+ if (fchmod(fd, S_IREAD | S_IWRITE)) {
|
||
+ anthy_log(0, "Failed chmod in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, anthy_strerror(errno));
|
||
+ }
|
||
+ close(fd);
|
||
}
|
||
|
||
/** 候補を表示する */
|
||
@@ -674,7 +707,10 @@ anthy_do_set_personality(const char *id)
|
||
if (!id || strchr(id, '/')) {
|
||
return -1;
|
||
}
|
||
- current_personality = strdup(id);
|
||
+ if (!(current_personality = strdup(id))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return -1;
|
||
+ }
|
||
anthy_dic_set_personality(current_personality);
|
||
return 0;
|
||
}
|
||
diff --git a/src-main/main.c b/src-main/main.c
|
||
index f492737..ae5c805 100644
|
||
--- a/src-main/main.c
|
||
+++ b/src-main/main.c
|
||
@@ -12,7 +12,7 @@
|
||
* Copyright (C) 2004-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2000-2007 KMC(Kyoto University Micro Computer Club)
|
||
* Copyright (C) 2001-2002 TAKAI Kosuke, Nobuoka Takahiro
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -202,7 +202,7 @@ int
|
||
anthy_set_string(struct anthy_context *ac, const char *s)
|
||
{
|
||
xstr *xs;
|
||
- int retval;
|
||
+ int retval = 0;
|
||
|
||
if (!ac) {
|
||
return -1;
|
||
@@ -227,7 +227,7 @@ anthy_set_string(struct anthy_context *ac, const char *s)
|
||
/**/
|
||
if (!need_reconvert(ac, xs)) {
|
||
/* 普通に変換する */
|
||
- retval = anthy_do_context_set_str(ac, xs, 0);
|
||
+ retval |= anthy_do_context_set_str(ac, xs, 0);
|
||
} else {
|
||
/* 漢字やカタカナが混じっていたら再変換してみる */
|
||
struct anthy_conv_stat stat;
|
||
@@ -235,7 +235,7 @@ anthy_set_string(struct anthy_context *ac, const char *s)
|
||
int i;
|
||
xstr* hira_xs;
|
||
/* 与えられた文字列に変換をかける */
|
||
- retval = anthy_do_context_set_str(ac, xs, 1);
|
||
+ retval |= anthy_do_context_set_str(ac, xs, 1);
|
||
|
||
/* 各文節の第一候補を取得して平仮名列を得る */
|
||
anthy_get_stat(ac, &stat);
|
||
@@ -246,7 +246,7 @@ anthy_set_string(struct anthy_context *ac, const char *s)
|
||
}
|
||
/* 改めて変換を行なう */
|
||
anthy_release_segment_list(ac);
|
||
- retval = anthy_do_context_set_str(ac, hira_xs, 0);
|
||
+ retval |= anthy_do_context_set_str(ac, hira_xs, 0);
|
||
anthy_free_xstr(hira_xs);
|
||
}
|
||
|
||
diff --git a/src-ordering/candswap.c b/src-ordering/candswap.c
|
||
index d2b2767..a512b24 100644
|
||
--- a/src-ordering/candswap.c
|
||
+++ b/src-ordering/candswap.c
|
||
@@ -8,9 +8,13 @@
|
||
* 自立語部:「田端」->「田畑」
|
||
* の二つのエントリを追加する
|
||
*
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
+ *
|
||
*/
|
||
#include <stdlib.h>
|
||
+#include <stdio.h>
|
||
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/record.h>
|
||
#include <anthy/segment.h>
|
||
/* for OCHAIRE_SCORE */
|
||
@@ -106,10 +110,22 @@ prepare_swap_candidate(xstr *target)
|
||
}
|
||
|
||
if (!anthy_xstrcmp(target, n)) {
|
||
+ int i;
|
||
+ char buff[256];
|
||
/* 第一候補 -> xs -> n で n = 第一候補のループ */
|
||
- anthy_select_row(target, 0);
|
||
+ if (anthy_select_row(target, 0)) {
|
||
+ for (i = 0; i < 3 && i < target->len; i++)
|
||
+ sprintf (buff + i * 6, "%04X, ", target->str[i]);
|
||
+ anthy_log(0, "No current selection or Could not find %s in %s:%d.\n",
|
||
+ buff, __FILE__, __LINE__);
|
||
+ }
|
||
anthy_release_row();
|
||
- anthy_select_row(xs, 0);
|
||
+ if (anthy_select_row(xs, 0)) {
|
||
+ for (i = 0; i < 3 && i < xs->len; i++)
|
||
+ sprintf (buff + i * 6, "%04X, ", xs->str[i]);
|
||
+ anthy_log(0, "No current selection or Could not find %s in %s:%d.\n",
|
||
+ buff, __FILE__, __LINE__);
|
||
+ }
|
||
anthy_release_row();
|
||
/* 第一候補 -> xs を消して、交換の必要は無し */
|
||
return NULL;
|
||
@@ -157,7 +173,8 @@ proc_swap_candidate_indep(struct seg_ent *se)
|
||
}
|
||
|
||
/**/
|
||
- anthy_select_section("INDEPPAIR", 1);
|
||
+ if (anthy_select_section("INDEPPAIR", 1))
|
||
+ anthy_log(0, "Failed to save INDEPPAIR in %s:%d.\n", __FILE__, __LINE__);
|
||
xs = prepare_swap_candidate(&key);
|
||
free(key.str);
|
||
if (!xs) {
|
||
diff --git a/src-ordering/relation.c b/src-ordering/relation.c
|
||
index 3db183a..651f48e 100644
|
||
--- a/src-ordering/relation.c
|
||
+++ b/src-ordering/relation.c
|
||
@@ -2,9 +2,9 @@
|
||
* 文節の関係を処理する
|
||
* Copyright (C) 2006 Higashiyama Masahiko (thanks google summer of code program)
|
||
* Copyright (C) 2002-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
* anthy_reorder_candidates_by_relation()
|
||
- *
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -427,10 +427,8 @@ anthy_relation_init(void)
|
||
{
|
||
corpus_info.corpus_array = anthy_file_dic_get_section("corpus_array");
|
||
corpus_info.corpus_bucket = anthy_file_dic_get_section("corpus_bucket");
|
||
- if (!corpus_info.corpus_array ||
|
||
- !corpus_info.corpus_array) {
|
||
+ if (!corpus_info.corpus_array || !corpus_info.corpus_bucket)
|
||
return ;
|
||
- }
|
||
corpus_info.array_size = ntohl(((int *)corpus_info.corpus_array)[1]);
|
||
corpus_info.bucket_size = ntohl(((int *)corpus_info.corpus_bucket)[1]);
|
||
corpus_info.array = &(((int *)corpus_info.corpus_array)[16]);
|
||
diff --git a/src-splitter/compose.c b/src-splitter/compose.c
|
||
index 998a157..70b841a 100644
|
||
--- a/src-splitter/compose.c
|
||
+++ b/src-splitter/compose.c
|
||
@@ -13,6 +13,7 @@
|
||
* Copyright (C) 2000-2005 TABATA Yusuke
|
||
* Copyright (C) 2004-2005 YOSHIDA Yuichi
|
||
* Copyright (C) 2002 UGAWA Tomoharu
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
* $Id: compose.c,v 1.25 2005/08/19 04:20:25 oxy Exp $
|
||
*/
|
||
@@ -31,11 +32,13 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
|
||
#include <anthy/dic.h>
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/splitter.h>
|
||
#include <anthy/segment.h>
|
||
#include "wordborder.h"
|
||
@@ -45,7 +48,10 @@ static struct cand_ent *
|
||
alloc_cand_ent(void)
|
||
{
|
||
struct cand_ent *ce;
|
||
- ce = (struct cand_ent *)malloc(sizeof(struct cand_ent));
|
||
+ if (!(ce = (struct cand_ent *)malloc(sizeof(struct cand_ent)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
ce->nr_words = 0;
|
||
ce->elm = NULL;
|
||
ce->mw = NULL;
|
||
@@ -62,18 +68,22 @@ dup_candidate(struct cand_ent *ce)
|
||
{
|
||
struct cand_ent *ce_new;
|
||
int i;
|
||
- ce_new = alloc_cand_ent();
|
||
+ if (!(ce_new = alloc_cand_ent()))
|
||
+ return NULL;
|
||
ce_new->nr_words = ce->nr_words;
|
||
ce_new->str.len = ce->str.len;
|
||
ce_new->str.str = anthy_xstr_dup_str(&ce->str);
|
||
- ce_new->elm = malloc(sizeof(struct cand_elm)*ce->nr_words);
|
||
+ if (!(ce_new->elm = malloc(sizeof(struct cand_elm)*ce->nr_words))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ ce_new->nr_words = 0;
|
||
+ }
|
||
ce_new->flag = ce->flag;
|
||
ce_new->core_elm_index = ce->core_elm_index;
|
||
ce_new->mw = ce->mw;
|
||
ce_new->score = ce->score;
|
||
ce_new->dep_word_hash = ce->dep_word_hash;
|
||
|
||
- for (i = 0 ; i < ce->nr_words ; i++) {
|
||
+ for (i = 0 ; i < ce_new->nr_words ; i++) {
|
||
ce_new->elm[i] = ce->elm[i];
|
||
}
|
||
return ce_new;
|
||
@@ -84,9 +94,16 @@ static void
|
||
push_back_candidate(struct seg_ent *seg, struct cand_ent *ce)
|
||
{
|
||
/* seg_entに候補ceを追加 */
|
||
+ struct cand_ent **cands = seg->cands;
|
||
seg->nr_cands++;
|
||
seg->cands = (struct cand_ent **)
|
||
realloc(seg->cands, sizeof(struct cand_ent *) * seg->nr_cands);
|
||
+ if (!seg->cands) {
|
||
+ anthy_log(0, "Failed realloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ seg->cands = cands;
|
||
+ seg->nr_cands--;
|
||
+ return;
|
||
+ }
|
||
seg->cands[seg->nr_cands - 1] = ce;
|
||
/**/
|
||
if (anthy_splitter_debug_flags() & SPLITTER_DEBUG_CAND) {
|
||
@@ -143,6 +160,9 @@ enum_candidates(struct seg_ent *seg,
|
||
}
|
||
return 1;
|
||
}
|
||
+ /* ce->nr_words == ce->mw->nr_parts from make_candidate_from_simple_metaword()
|
||
+ */
|
||
+ assert(n < ce->nr_words);
|
||
|
||
p = anthy_get_nr_dic_ents(ce->elm[n].se, &ce->elm[n].str);
|
||
|
||
@@ -160,7 +180,11 @@ enum_candidates(struct seg_ent *seg,
|
||
|
||
yomi.len = ce->elm[n].str.len;
|
||
yomi.str = &seg->str.str[from];
|
||
- cand = dup_candidate(ce);
|
||
+ if (!(cand = dup_candidate(ce))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 0;
|
||
+ }
|
||
+ assert(n < cand->nr_words);
|
||
anthy_get_nth_dic_ent_str(cand->elm[n].se,
|
||
&yomi, i, &word);
|
||
cand->elm[n].nth = i;
|
||
@@ -183,7 +207,11 @@ enum_candidates(struct seg_ent *seg,
|
||
xstr xs;
|
||
xs.len = ce->elm[n].str.len;
|
||
xs.str = &seg->str.str[from];
|
||
- cand = dup_candidate(ce);
|
||
+ if (!(cand = dup_candidate(ce))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 0;
|
||
+ }
|
||
+ assert(n < cand->nr_words);
|
||
cand->elm[n].nth = -1;
|
||
cand->elm[n].id = -1;
|
||
anthy_xstrcat(&cand->str, &xs);
|
||
@@ -286,19 +314,21 @@ make_cand_elem_from_word_list(struct seg_ent *se,
|
||
/* 長さの無いpartは無視する */
|
||
continue;
|
||
}
|
||
- if (i == PART_CORE) {
|
||
- ce->core_elm_index = i + index;
|
||
- }
|
||
core_xs.str = &se->str.str[from];
|
||
core_xs.len = part->len;
|
||
if (i == PART_DEPWORD) {
|
||
ce->dep_word_hash = anthy_dep_word_hash(&core_xs);
|
||
}
|
||
- ce->elm[i + index].se = anthy_get_seq_ent_from_xstr(&core_xs, is_reverse);
|
||
- ce->elm[i + index].str.str = core_xs.str;
|
||
- ce->elm[i + index].str.len = core_xs.len;
|
||
- ce->elm[i + index].wt = part->wt;
|
||
- ce->elm[i + index].ratio = RATIO_BASE * wl->len;
|
||
+ if ((i + index) < ce->nr_words) {
|
||
+ if (i == PART_CORE)
|
||
+ ce->core_elm_index = i + index;
|
||
+ assert(ce->elm);
|
||
+ ce->elm[i + index].se = anthy_get_seq_ent_from_xstr(&core_xs, is_reverse);
|
||
+ ce->elm[i + index].str.str = core_xs.str;
|
||
+ ce->elm[i + index].str.len = core_xs.len;
|
||
+ ce->elm[i + index].wt = part->wt;
|
||
+ ce->elm[i + index].ratio = RATIO_BASE * wl->len;
|
||
+ }
|
||
from += part->len;
|
||
}
|
||
}
|
||
@@ -321,7 +351,10 @@ make_candidate_from_simple_metaword(struct seg_ent *se,
|
||
ce->nr_words = mw->nr_parts;
|
||
ce->str.str = NULL;
|
||
ce->str.len = 0;
|
||
- ce->elm = calloc(sizeof(struct cand_elm),ce->nr_words);
|
||
+ if (!(ce->elm = calloc(sizeof(struct cand_elm),ce->nr_words))) {
|
||
+ anthy_log(0, "Failed calloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ ce->nr_words = 0;
|
||
+ }
|
||
ce->mw = mw;
|
||
ce->score = 0;
|
||
|
||
@@ -352,12 +385,19 @@ make_candidate_from_combined_metaword(struct seg_ent *se,
|
||
struct cand_ent *ce;
|
||
|
||
/* 複数(1も含む)の単語で構成される文節に単語を割当てていく */
|
||
- ce = alloc_cand_ent();
|
||
+ if (!(ce = alloc_cand_ent())) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
ce->nr_words = mw->nr_parts;
|
||
ce->score = 0;
|
||
ce->str.str = NULL;
|
||
ce->str.len = 0;
|
||
- ce->elm = calloc(sizeof(struct cand_elm),ce->nr_words);
|
||
+ if (!(ce->elm = calloc(sizeof(struct cand_elm),ce->nr_words))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(ce);
|
||
+ return;
|
||
+ }
|
||
ce->mw = top_mw;
|
||
|
||
/* 接頭辞, 自立語部, 接尾辞, 付属語 */
|
||
@@ -409,7 +449,10 @@ proc_splitter_info(struct seg_ent *se,
|
||
/* 連文節の葉 */
|
||
{
|
||
struct cand_ent *ce;
|
||
- ce = alloc_cand_ent();
|
||
+ if (!(ce = alloc_cand_ent())) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ break;
|
||
+ }
|
||
ce->str.str = anthy_xstr_dup_str(&mw->cand_hint);
|
||
ce->str.len = mw->cand_hint.len;
|
||
ce->flag = CEF_COMPOUND;
|
||
@@ -425,7 +468,10 @@ proc_splitter_info(struct seg_ent *se,
|
||
/* metawordを持たない候補文字列が
|
||
直接に指定された */
|
||
struct cand_ent *ce;
|
||
- ce = alloc_cand_ent();
|
||
+ if (!(ce = alloc_cand_ent())) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ break;
|
||
+ }
|
||
ce->str.str = anthy_xstr_dup_str(&mw->cand_hint);
|
||
ce->str.len = mw->cand_hint.len;
|
||
ce->mw = top_mw;
|
||
diff --git a/src-splitter/depgraph.c b/src-splitter/depgraph.c
|
||
index 118791a..c9ab36c 100644
|
||
--- a/src-splitter/depgraph.c
|
||
+++ b/src-splitter/depgraph.c
|
||
@@ -18,7 +18,9 @@
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
* Copyright (C) 2006 YOSHIDA Yuichi
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
@@ -247,10 +249,14 @@ static void
|
||
read_node(struct dep_dic* ddic, struct dep_node* node, int* offset)
|
||
{
|
||
int i;
|
||
+ assert(offset);
|
||
node->nr_branch = anthy_dic_ntohl(*(int*)&ddic->file_ptr[*offset]);
|
||
*offset += sizeof(int);
|
||
|
||
- node->branch = malloc(sizeof(struct dep_branch) * node->nr_branch);
|
||
+ if (!(node->branch = malloc(sizeof(struct dep_branch) * node->nr_branch))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ node->nr_branch = 0;
|
||
+ }
|
||
for (i = 0; i < node->nr_branch; ++i) {
|
||
read_branch(ddic, &node->branch[i], offset);
|
||
}
|
||
@@ -277,7 +283,10 @@ read_file(void)
|
||
offset += sizeof(int);
|
||
|
||
/* 各ノードを読み込む */
|
||
- ddic.nodes = malloc(sizeof(struct dep_node) * ddic.nrNodes);
|
||
+ if (!(ddic.nodes = malloc(sizeof(struct dep_node) * ddic.nrNodes))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ ddic.nrNodes = 0;
|
||
+ }
|
||
for (i = 0; i < ddic.nrNodes; ++i) {
|
||
read_node(&ddic, &ddic.nodes[i], &offset);
|
||
}
|
||
@@ -313,6 +322,8 @@ anthy_quit_depword_tab(void)
|
||
for (i = 0; i < ddic.nrNodes; i++) {
|
||
struct dep_node* node = &ddic.nodes[i];
|
||
free(node->branch);
|
||
+ node->branch = NULL;
|
||
}
|
||
free(ddic.nodes);
|
||
+ ddic.nodes = NULL;
|
||
}
|
||
diff --git a/src-splitter/lattice.c b/src-splitter/lattice.c
|
||
index cc6c8f2..72cd599 100644
|
||
--- a/src-splitter/lattice.c
|
||
+++ b/src-splitter/lattice.c
|
||
@@ -9,7 +9,7 @@
|
||
* Copyright (C) 2006-2007 TABATA Yusuke
|
||
* Copyright (C) 2004-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2006 HANAOKA Toshiyuki
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -37,17 +37,19 @@
|
||
* (2) グラフを後ろ(右)からたどって最適なパスを求める
|
||
*
|
||
*/
|
||
+#include <assert.h>
|
||
+#include <math.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
-#include <math.h>
|
||
|
||
#include <anthy/alloc.h>
|
||
-#include <anthy/xstr.h>
|
||
+#include <anthy/diclib.h>
|
||
+#include <anthy/feature_set.h>
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/segclass.h>
|
||
#include <anthy/splitter.h>
|
||
-#include <anthy/feature_set.h>
|
||
-#include <anthy/diclib.h>
|
||
+#include <anthy/xstr.h>
|
||
#include "wordborder.h"
|
||
|
||
static float anthy_normal_length = 20.0; /* 文節の期待される長さ */
|
||
@@ -82,6 +84,7 @@ struct lattice_info {
|
||
struct splitter_context *sc;
|
||
/* ノードのアロケータ */
|
||
allocator node_allocator;
|
||
+ int lattice_node_len;
|
||
};
|
||
|
||
/*
|
||
@@ -210,6 +213,8 @@ get_transition_probability(struct lattice_node *node)
|
||
probability = calc_probability(node->seg_class, &features);
|
||
anthy_feature_list_free(&features);
|
||
|
||
+ if (!(node->mw))
|
||
+ return probability;
|
||
/* 文節の形に対する評価 */
|
||
probability *= get_form_bias(node->mw);
|
||
return probability;
|
||
@@ -223,9 +228,15 @@ alloc_lattice_info(struct splitter_context *sc, int size)
|
||
info->sc = sc;
|
||
info->lattice_node_list = (struct node_list_head*)
|
||
malloc((size + 1) * sizeof(struct node_list_head));
|
||
- for (i = 0; i < size + 1; i++) {
|
||
- info->lattice_node_list[i].head = NULL;
|
||
- info->lattice_node_list[i].nr_nodes = 0;
|
||
+ if (!(info->lattice_node_list)) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ info->lattice_node_len = 0;
|
||
+ } else {
|
||
+ info->lattice_node_len = size + 1;
|
||
+ for (i = 0; i < size + 1; i++) {
|
||
+ info->lattice_node_list[i].head = NULL;
|
||
+ info->lattice_node_list[i].nr_nodes = 0;
|
||
+ }
|
||
}
|
||
info->node_allocator = anthy_create_allocator(sizeof(struct lattice_node),
|
||
NULL);
|
||
@@ -235,6 +246,7 @@ alloc_lattice_info(struct splitter_context *sc, int size)
|
||
static void
|
||
calc_node_parameters(struct lattice_node *node)
|
||
{
|
||
+ assert(node);
|
||
/* 対応するmetawordが無い場合は文頭と判断する */
|
||
node->seg_class = node->mw ? node->mw->seg_class : SEG_HEAD;
|
||
|
||
@@ -345,6 +357,8 @@ cmp_node(struct lattice_node *lhs, struct lattice_node *rhs)
|
||
}
|
||
|
||
/* 最後に遷移確率を見る */
|
||
+ assert(lhs);
|
||
+ assert(rhs);
|
||
if (lhs->adjusted_probability > rhs->adjusted_probability) {
|
||
return 1;
|
||
} else if (lhs->adjusted_probability < rhs->adjusted_probability) {
|
||
@@ -368,11 +382,16 @@ push_node(struct lattice_info* info, struct lattice_node* new_node,
|
||
print_lattice_node(info, new_node);
|
||
}
|
||
|
||
+ assert(position >= 0);
|
||
+ if (position >= info->lattice_node_len) {
|
||
+ anthy_log(0, "info->lattice_node_list[%d] is not allocated\n", position);
|
||
+ return;
|
||
+ }
|
||
/* 先頭のnodeが無ければ無条件に追加 */
|
||
node = info->lattice_node_list[position].head;
|
||
if (!node) {
|
||
info->lattice_node_list[position].head = new_node;
|
||
- info->lattice_node_list[position].nr_nodes ++;
|
||
+ info->lattice_node_list[position].nr_nodes++;
|
||
return;
|
||
}
|
||
|
||
@@ -406,7 +425,7 @@ push_node(struct lattice_info* info, struct lattice_node* new_node,
|
||
|
||
/* 最後のノードの後ろに追加 */
|
||
node->next = new_node;
|
||
- info->lattice_node_list[position].nr_nodes ++;
|
||
+ info->lattice_node_list[position].nr_nodes++;
|
||
}
|
||
|
||
/* 一番確率の低いノードを消去する*/
|
||
@@ -418,6 +437,10 @@ remove_min_node(struct lattice_info *info, struct node_list_head *node_list)
|
||
struct lattice_node* min_node = node;
|
||
struct lattice_node* previous_min_node = NULL;
|
||
|
||
+ if (!min_node) {
|
||
+ anthy_log(0, "No min_node\n");
|
||
+ return;
|
||
+ }
|
||
/* 一番確率の低いノードを探す */
|
||
while (node) {
|
||
if (cmp_node(node, min_node) < 0) {
|
||
@@ -435,7 +458,7 @@ remove_min_node(struct lattice_info *info, struct node_list_head *node_list)
|
||
node_list->head = min_node->next;
|
||
}
|
||
release_lattice_node(info, min_node);
|
||
- node_list->nr_nodes --;
|
||
+ node_list->nr_nodes--;
|
||
}
|
||
|
||
/* いわゆるビタビアルゴリズムを使用して経路を選ぶ */
|
||
@@ -446,6 +469,10 @@ choose_path(struct lattice_info* info, int to)
|
||
struct lattice_node* node;
|
||
struct lattice_node* best_node = NULL;
|
||
int last = to;
|
||
+ if (last >= info->lattice_node_len) {
|
||
+ anthy_log(0, "info->lattice_node_list[%d] is not allocated\n", last);
|
||
+ return;
|
||
+ }
|
||
while (!info->lattice_node_list[last].head) {
|
||
/* 最後の文字まで遷移していなかったら後戻り */
|
||
--last;
|
||
@@ -492,6 +519,11 @@ build_graph(struct lattice_info* info, int from, int to)
|
||
* indexからの遷移が入っているのではない
|
||
*/
|
||
|
||
+ if (to >= info->lattice_node_len || from < 0) {
|
||
+ anthy_log(0, "info->lattice_node_list[%d] is not allocated: %d\n",
|
||
+ to, from);
|
||
+ return;
|
||
+ }
|
||
/* 全ての遷移を左から試す */
|
||
for (i = from; i < to; ++i) {
|
||
for (left_node = info->lattice_node_list[i].head; left_node;
|
||
diff --git a/src-splitter/metaword.c b/src-splitter/metaword.c
|
||
index ad98d36..4a5cc0c 100644
|
||
--- a/src-splitter/metaword.c
|
||
+++ b/src-splitter/metaword.c
|
||
@@ -10,6 +10,7 @@
|
||
* Copyright (C) 2000-2006 TABATA Yusuke
|
||
* Copyright (C) 2004-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2000-2003 UGAWA Tomoharu
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
@@ -462,10 +463,15 @@ try_combine_number(struct splitter_context *sc,
|
||
/* #NNは対象外 */
|
||
if (scos2 == SCOS_NONE) return;
|
||
/*
|
||
- 左mwの種類によって、後ろにつくことができる右mwの種類が変わる
|
||
- 例えば一〜九の後ろには万〜九万、億〜九億しかつくことができないが、
|
||
- 十〜九十の後ろには、あわせて一〜九などもつくことができる
|
||
+ * 左mwの種類によって、後ろにつくことができる右mwの種類が変わる
|
||
+ * 例えば一〜九の後ろには万〜九万、億〜九億しかつくことができないが、
|
||
+ * 十〜九十の後ろには、あわせて一〜九などもつくことができる
|
||
+ * 漢数字、アラビア数字、全角半角切替え
|
||
+ * GCC 11.0.1 reports this statement may fall through because of no break
|
||
+ * in case statement with "-Wimplicit-fallthrough" option.
|
||
*/
|
||
+#pragma GCC diagnostic push
|
||
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||
switch (scos1) {
|
||
case SCOS_N1:
|
||
if (scos2 == SCOS_N1) return; /* 後ろに一〜九がついてはいけない */
|
||
@@ -482,6 +488,7 @@ try_combine_number(struct splitter_context *sc,
|
||
default:
|
||
return;
|
||
}
|
||
+#pragma GCC diagnostic pop
|
||
|
||
if (recursive) {
|
||
combined_mw = anthy_do_cons_metaword(sc, MW_NUMBER, mw1, mw2);
|
||
@@ -569,9 +576,6 @@ make_dummy_metaword(struct splitter_context *sc, int from,
|
||
n->from = from;
|
||
n->len = len;
|
||
n->score = 3 * score * len / orig_len;
|
||
- if (mw) {
|
||
- mw->nr_parts = 0;
|
||
- }
|
||
anthy_commit_meta_word(sc, n);
|
||
}
|
||
|
||
@@ -695,8 +699,10 @@ make_ochaire_metaword_all(struct splitter_context *sc)
|
||
len = key->len;
|
||
|
||
make_ochaire_metaword(sc, i, len);
|
||
- /* 今回見つかった meta_word の次の文字から始める */
|
||
- i += len - 1;
|
||
+ /* 今回見つかった meta_word の次の文字から始める
|
||
+ * `i` should not be touched if `break` is called.
|
||
+ */
|
||
+ /* i += len - 1; */
|
||
break;
|
||
}
|
||
}
|
||
diff --git a/src-splitter/segclass.c b/src-splitter/segclass.c
|
||
index 3176a42..363efc4 100644
|
||
--- a/src-splitter/segclass.c
|
||
+++ b/src-splitter/segclass.c
|
||
@@ -1,3 +1,6 @@
|
||
+/*
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
+ */
|
||
#include <string.h>
|
||
|
||
#include <anthy/splitter.h>
|
||
@@ -31,7 +34,6 @@ anthy_set_seg_class(struct word_list* wl)
|
||
|
||
head_pos = wl->head_pos;
|
||
dc = wl->part[PART_DEPWORD].dc;
|
||
- seg_class = SEG_HEAD;
|
||
|
||
if (wl->part[PART_CORE].len == 0) {
|
||
seg_class = SEG_BUNSETSU;
|
||
diff --git a/src-splitter/splitter.c b/src-splitter/splitter.c
|
||
index d35ea19..bccaab8 100644
|
||
--- a/src-splitter/splitter.c
|
||
+++ b/src-splitter/splitter.c
|
||
@@ -13,6 +13,7 @@
|
||
* Copyright (C) 2004 YOSHIDA Yuichi
|
||
* Copyright (C) 2000-2004 TABATA Yusuke
|
||
* Copyright (C) 2000-2001 UGAWA Tomoharu
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
* $Id: splitter.c,v 1.48 2002/11/18 11:39:18 yusuke Exp $
|
||
*/
|
||
@@ -93,6 +94,10 @@ alloc_char_ent(xstr *xs, struct splitter_context *sc)
|
||
sc->char_count = xs->len;
|
||
sc->ce = (struct char_ent*)
|
||
malloc(sizeof(struct char_ent)*(xs->len + 1));
|
||
+ if (!sc->ce) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (i = 0; i <= xs->len; i++) {
|
||
sc->ce[i].c = &xs->str[i];
|
||
sc->ce[i].seg_border = 0;
|
||
@@ -303,6 +308,7 @@ anthy_init_splitter(void)
|
||
/* 付属語グラフの初期化 */
|
||
if (anthy_init_depword_tab()) {
|
||
anthy_log(0, "Failed to init dependent word table.\n");
|
||
+ anthy_quit_depword_tab();
|
||
return -1;
|
||
}
|
||
/**/
|
||
diff --git a/src-util/agent.c b/src-util/agent.c
|
||
index bb4c2a7..407e046 100644
|
||
--- a/src-util/agent.c
|
||
+++ b/src-util/agent.c
|
||
@@ -6,6 +6,7 @@
|
||
* Funded by IPA未踏ソフトウェア創造事業 2002 2/26
|
||
* Copyright (C) 2001-2002 UGAWA Tomoharu
|
||
* Copyright (C) 2002-2004 TABATA Yusuke,
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
* *マルチコンテキストの扱いを決めかねている
|
||
@@ -23,6 +24,7 @@
|
||
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/input.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
#include "rkconv.h"
|
||
|
||
@@ -374,9 +376,6 @@ make_hl_command(char *buf)
|
||
cmd->arg[i] = encode_command_arg(p);
|
||
}
|
||
while ((p = strtok(NULL, " \t\r"))) {
|
||
- if (!p) {
|
||
- break;
|
||
- }
|
||
cmd->n_arg++;
|
||
cmd->arg = (char**) realloc(cmd->arg, sizeof(char*) * cmd->n_arg);
|
||
cmd->arg[cmd->n_arg - 1] = encode_command_arg(p);
|
||
@@ -516,9 +515,12 @@ proc_connection(void)
|
||
FD_SET(daemon_sock, &rfds);
|
||
}
|
||
max_fd = MAX(conn->rfd, max_fd);
|
||
+ assert(conn->rfd >= 0);
|
||
FD_SET(conn->rfd, &rfds);
|
||
+ assert(conn->rfd >= 0);
|
||
if (conn->n_wbuf > 0) {
|
||
max_fd = MAX(conn->wfd, max_fd);
|
||
+ assert(conn->wfd >= 0);
|
||
FD_SET(conn->wfd, &wfds);
|
||
}
|
||
|
||
@@ -569,7 +571,6 @@ AGAIN:
|
||
}
|
||
|
||
while (1) {
|
||
-
|
||
char* p;
|
||
for (p = conn->rbuf; p < conn->rbuf + conn->n_rbuf; p++) {
|
||
if (*p == '\n') {
|
||
@@ -583,11 +584,9 @@ AGAIN:
|
||
}
|
||
}
|
||
}
|
||
-
|
||
if (proc_connection() == -1) {
|
||
return NULL;
|
||
}
|
||
-
|
||
}
|
||
}
|
||
|
||
@@ -750,6 +749,10 @@ new_input_context(int id)
|
||
|
||
ictxl =
|
||
(struct input_context_list*) malloc(sizeof (struct input_context_list));
|
||
+ if (!ictxl) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
ictxl->id = id;
|
||
ictxl->ictx = anthy_input_create_context(config);
|
||
ictxl->next = ictx_list;
|
||
@@ -762,6 +765,8 @@ get_current_input_context(void)
|
||
if (ictx_list == NULL)
|
||
new_input_context(0);
|
||
|
||
+ if (!ictx_list)
|
||
+ return NULL;
|
||
return ictx_list->ictx;
|
||
}
|
||
|
||
@@ -817,9 +822,16 @@ cmdh_release_input_context(struct command* cmd)
|
||
static void
|
||
cmdh_change_toggle(struct command *cmd)
|
||
{
|
||
- int toggle = cmd->arg[0][0];
|
||
+ int toggle;
|
||
int ret;
|
||
|
||
+ assert(cmd->arg);
|
||
+ if (!cmd->arg[0]) {
|
||
+ anthy_log(0, "cmdh_change_toggle should have one argument.\n");
|
||
+ send_error();
|
||
+ return;
|
||
+ }
|
||
+ toggle = cmd->arg[0][0];
|
||
ret = anthy_input_edit_toggle_config(config, toggle);
|
||
|
||
if (ret != 0) {
|
||
@@ -833,6 +845,7 @@ cmdh_change_toggle(struct command *cmd)
|
||
static void
|
||
cmdh_map_clear(struct command *cmd)
|
||
{
|
||
+ assert(cmd->arg);
|
||
anthy_input_clear_rk_config(config, atoi(cmd->arg[0]));
|
||
anthy_input_change_config(config);
|
||
send_ok();
|
||
@@ -841,6 +854,7 @@ cmdh_map_clear(struct command *cmd)
|
||
static void
|
||
cmdh_set_break_into_roman(struct command *cmd)
|
||
{
|
||
+ assert(cmd->arg);
|
||
anthy_input_break_into_roman_config(config, atoi(cmd->arg[0]));
|
||
anthy_input_change_config(config);
|
||
send_ok();
|
||
@@ -849,6 +863,7 @@ cmdh_set_break_into_roman(struct command *cmd)
|
||
static void
|
||
cmdh_set_preedit_mode(struct command *cmd)
|
||
{
|
||
+ assert(cmd->arg);
|
||
anthy_input_preedit_mode_config(config, atoi(cmd->arg[0]));
|
||
anthy_input_change_config(config);
|
||
send_ok();
|
||
@@ -857,10 +872,12 @@ cmdh_set_preedit_mode(struct command *cmd)
|
||
static void
|
||
cmdh_map_edit(struct command* cmd)
|
||
{
|
||
- /* MAP,from,to */
|
||
- int map_no = atoi(cmd->arg[0]);
|
||
+ int map_no;
|
||
int ret;
|
||
|
||
+ assert(cmd->arg);
|
||
+ /* MAP,from,to */
|
||
+ map_no = atoi(cmd->arg[0]);
|
||
ret = anthy_input_edit_rk_config(config, map_no,
|
||
cmd->arg[1], cmd->arg[2], NULL);
|
||
|
||
@@ -879,6 +896,7 @@ cmdh_map_select(struct anthy_input_context* ictx,
|
||
char* map_name;
|
||
int map_no;
|
||
|
||
+ assert(cmd->arg);
|
||
map_name = cmd->arg[0];
|
||
if (strcmp(map_name, "alphabet") == 0)
|
||
map_no = ANTHY_INPUT_MAP_ALPHABET;
|
||
@@ -906,6 +924,7 @@ cmdh_get_candidate(struct anthy_input_context* ictx,
|
||
struct anthy_input_segment* seg;
|
||
int cand_no;
|
||
|
||
+ assert(cmd->arg);
|
||
cand_no = atoi(cmd->arg[0]);
|
||
|
||
seg = anthy_input_get_candidate(ictx, cand_no);
|
||
@@ -924,6 +943,7 @@ cmdh_select_candidate(struct anthy_input_context* ictx,
|
||
int ret;
|
||
int cand_no;
|
||
|
||
+ assert(cmd->arg);
|
||
cand_no = atoi(cmd->arg[0]);
|
||
ret = anthy_input_select_candidate(ictx, cand_no);
|
||
if (ret < 0) {
|
||
@@ -937,20 +957,25 @@ static void
|
||
cmd_shift_arrow(struct anthy_input_context* ictx,
|
||
struct command* cmd)
|
||
{
|
||
- int lr = atoi(cmd->arg[0]);
|
||
+ int lr;
|
||
+ assert(cmd->arg);
|
||
+ lr = atoi(cmd->arg[0]);
|
||
anthy_input_resize(ictx, lr);
|
||
}
|
||
|
||
static void
|
||
cmd_arrow(struct anthy_input_context* ictx, struct command* cmd)
|
||
{
|
||
- int lr = atoi(cmd->arg[0]);
|
||
+ int lr;
|
||
+ assert(cmd->arg);
|
||
+ lr = atoi(cmd->arg[0]);
|
||
anthy_input_move(ictx, lr);
|
||
}
|
||
|
||
static void
|
||
cmd_key(struct anthy_input_context* ictx, struct command* cmd)
|
||
{
|
||
+ assert(cmd->arg);
|
||
anthy_input_str(ictx, cmd->arg[0]);
|
||
}
|
||
|
||
@@ -1137,7 +1162,10 @@ main(int argc, char **argv)
|
||
anthy_quit();
|
||
} else {
|
||
config = anthy_input_create_config();
|
||
- conn = (struct connection*) malloc(sizeof(struct connection));
|
||
+ if (!(conn = (struct connection*) malloc(sizeof(struct connection)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 1;
|
||
+ }
|
||
conn->rbuf = NULL;
|
||
conn->n_rbuf = 0;
|
||
conn->s_rbuf = 0;
|
||
diff --git a/src-util/convdb.c b/src-util/convdb.c
|
||
index 0d9dd1d..df240d6 100644
|
||
--- a/src-util/convdb.c
|
||
+++ b/src-util/convdb.c
|
||
@@ -2,6 +2,7 @@
|
||
* 変換エンジンの内部情報を使うため、意図的に
|
||
* layer violationを放置している。
|
||
*
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
@@ -77,8 +78,8 @@ do_find_conv_res(struct res_db *db, const char *src, const char *res)
|
||
|
||
for (cr = db->res_list.next; cr; cr = cr->next) {
|
||
if (((!cr->res_str && !res) ||
|
||
- !strcmp(cr->res_str, res)) &&
|
||
- !strcmp(cr->src_str, src)) {
|
||
+ (cr->res_str && res && !strcmp(cr->res_str, res))) &&
|
||
+ (cr->src_str && src && !strcmp(cr->src_str, src))) {
|
||
return cr;
|
||
}
|
||
}
|
||
@@ -235,6 +236,7 @@ read_db(struct res_db *db, const char *fn)
|
||
while (fgets(line, 1024, fp)) {
|
||
parse_line(db, line);
|
||
}
|
||
+ fclose(fp);
|
||
}
|
||
|
||
static void
|
||
@@ -461,7 +463,7 @@ print_segment_info(int is_negative,
|
||
struct feature_list fl;
|
||
struct cand_ent *ce = selected_candidate(seg);
|
||
int nr_indep = 0;
|
||
- const char *prefix = get_prefix(is_negative);
|
||
+ const char *prefix = NULL;
|
||
|
||
anthy_feature_list_init(&fl);
|
||
set_features(&fl, prev_seg, seg);
|
||
diff --git a/src-util/dic-tool.c b/src-util/dic-tool.c
|
||
index d7f8b2e..78d01bc 100644
|
||
--- a/src-util/dic-tool.c
|
||
+++ b/src-util/dic-tool.c
|
||
@@ -14,7 +14,7 @@
|
||
* Funded by IPA未踏ソフトウェア創造事業 2001 9/22
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
- * Copyright (C) 2020 Takao Fujiwara
|
||
+ * Copyright (C) 2020-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -31,6 +31,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <errno.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
@@ -40,6 +41,7 @@
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/diclib.h>
|
||
#include <anthy/dicutil.h>
|
||
+#include <anthy/logger.h>
|
||
/**/
|
||
#include <anthy/textdict.h>
|
||
#include <anthy/xstr.h>
|
||
@@ -121,16 +123,25 @@ static FILE *
|
||
open_typetab(void)
|
||
{
|
||
FILE *fp;
|
||
- char *fn;
|
||
+ char *fn, *tmp;
|
||
fp = fopen(TYPETAB, "r");
|
||
if (fp) {
|
||
return fp;
|
||
}
|
||
- fn = strdup(anthy_dic_util_get_anthydir());
|
||
- fn = realloc(fn, strlen(fn) + strlen(TYPETAB) + 4);
|
||
+ if (!(fn = strdup(anthy_dic_util_get_anthydir()))) {
|
||
+ anthy_log(0, "Could not find ANTHYDIR in conf file.\n");
|
||
+ return NULL;
|
||
+ }
|
||
+ if (!(tmp = realloc(fn, strlen(fn) + strlen(TYPETAB) + 4))) {
|
||
+ anthy_log(0, "Could not realloc TYPETAB.\n");
|
||
+ /* free(fn) is freed twice. */
|
||
+ return NULL;
|
||
+ }
|
||
+ fn = tmp;
|
||
strcat(fn, "/");
|
||
strcat(fn, TYPETAB);
|
||
fp = fopen(fn, "r");
|
||
+ free(fn);
|
||
return fp;
|
||
}
|
||
|
||
@@ -142,11 +153,27 @@ open_usage_file(void)
|
||
fp = fopen(USAGE_TEXT, "r");
|
||
if (!fp) {
|
||
/* インストールされたものを使用 */
|
||
- char *fn;
|
||
- fn = strdup(anthy_dic_util_get_anthydir());
|
||
- fn = realloc(fn, strlen(fn) + strlen(USAGE_TEXT) + 10);
|
||
+ char *fn = NULL, *tmp;
|
||
+ if (!(fn = strdup(anthy_dic_util_get_anthydir()))) {
|
||
+ anthy_log(0, "Could not find ANTHYDIR in conf file.\n");
|
||
+ return NULL;
|
||
+ }
|
||
+ if (!(tmp = realloc(fn, strlen(fn) + strlen(USAGE_TEXT) + 10))) {
|
||
+ anthy_log(0, "Could not realloc USAGE_TEXT.\n");
|
||
+ /* CPPCHECK_WARNING and CLANG_WARNING are conflicted.
|
||
+ * CPPCHECK_WARNING reports: Common realloc mistake:
|
||
+ * 'fn' nulled but not freed upon failure
|
||
+ * also CLANG_WARNING reports: Potential leak of memory ponted to by 'fn'
|
||
+ * On the other hand,
|
||
+ * CLANG_WARNING reports: 'fn' is freed twice.
|
||
+ */
|
||
+ free(fn);
|
||
+ return NULL;
|
||
+ }
|
||
+ fn = tmp;
|
||
strcat(fn, "/" USAGE_TEXT);
|
||
fp = fopen(fn, "r");
|
||
+ free(fn);
|
||
}
|
||
return fp;
|
||
}
|
||
@@ -263,7 +290,10 @@ read_typetab_var(struct var *head, FILE *fp, int table)
|
||
return -1;
|
||
}
|
||
|
||
- v = malloc(sizeof(struct var));
|
||
+ if (!(v = malloc(sizeof(struct var)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return -1;
|
||
+ }
|
||
if (encoding == ANTHY_EUC_JP_ENCODING && table) {
|
||
/* UTF-8 */
|
||
v->var_name = anthy_conv_utf8_to_euc(var);
|
||
@@ -281,6 +311,22 @@ read_typetab_var(struct var *head, FILE *fp, int table)
|
||
return 0;
|
||
}
|
||
|
||
+static void
|
||
+free_typetab_var (struct var *head)
|
||
+{
|
||
+ struct var *v = head;
|
||
+ while (v) {
|
||
+ struct var *prev;
|
||
+ free (v->var_name);
|
||
+ free (v->val);
|
||
+ prev = v;
|
||
+ v = v->next;
|
||
+ /* head is not allocated */
|
||
+ if (prev != head)
|
||
+ free (prev);
|
||
+ }
|
||
+}
|
||
+
|
||
static int
|
||
read_typetab_entry(FILE *fp)
|
||
{
|
||
@@ -315,6 +361,7 @@ read_typetab(void)
|
||
exit(1);
|
||
}
|
||
while (!read_typetab_entry(fp));
|
||
+ fclose(fp);
|
||
}
|
||
|
||
static struct trans_tab *
|
||
@@ -416,13 +463,16 @@ find_wt(void)
|
||
struct var v;
|
||
struct trans_tab *t;
|
||
v.next = 0;
|
||
+ memset(&v, 0, sizeof(struct var));
|
||
while(!read_typetab_var(&v, fp_in, 0));
|
||
for (t = trans_tab_list.next; t; t = t->next) {
|
||
if (var_list_subset_p(&t->var_list, &v) &&
|
||
- var_list_subset_p(&v, &t->var_list)) {
|
||
+ var_list_subset_p(&v, &t->var_list)) {
|
||
+ free_typetab_var(&v);
|
||
return t->type_name;
|
||
}
|
||
}
|
||
+ free_typetab_var(&v);
|
||
return NULL;
|
||
}
|
||
|
||
@@ -493,17 +543,29 @@ load_text_dic (void)
|
||
return;
|
||
}
|
||
do {
|
||
- yomi = strdup (anthy_priv_dic_get_index (buf, LINE_SIZE));
|
||
+ if (!(yomi = strdup (anthy_priv_dic_get_index (buf, LINE_SIZE)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ continue;
|
||
+ }
|
||
if (*yomi == '#') {
|
||
free (yomi);
|
||
continue;
|
||
}
|
||
if (!dict_head) {
|
||
- d = dict_head = calloc (sizeof (struct dict_entry), 1);
|
||
+ if (!(d = dict_head = calloc (sizeof (struct dict_entry), 1))) {
|
||
+ anthy_log(0, "Failed calloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(yomi);
|
||
+ break;
|
||
+ }
|
||
} else {
|
||
- d->next = calloc (sizeof (struct dict_entry), 1);
|
||
+ if (!(d->next = calloc (sizeof (struct dict_entry), 1))) {
|
||
+ anthy_log(0, "Failed calloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(yomi);
|
||
+ break;
|
||
+ }
|
||
d = d->next;
|
||
}
|
||
+ assert(d);
|
||
d->yomi = yomi;
|
||
d->word = strdup (anthy_priv_dic_get_word (buf, LINE_SIZE));
|
||
d->wtype = strdup (anthy_priv_dic_get_wtype (buf, LINE_SIZE));
|
||
diff --git a/src-util/egg.c b/src-util/egg.c
|
||
index f9cdb0a..b1ca871 100644
|
||
--- a/src-util/egg.c
|
||
+++ b/src-util/egg.c
|
||
@@ -1,5 +1,6 @@
|
||
/*
|
||
* Copyright (C) 2002 The Free Software Initiative of Japan
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
* Author: NIIBE Yutaka
|
||
*/
|
||
|
||
@@ -7,11 +8,14 @@
|
||
* ANTHY Low Level Agent
|
||
*/
|
||
|
||
+#include <limits.h>
|
||
+#include <stdint.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
|
||
#include <anthy/anthy.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
#include "config.h"
|
||
|
||
@@ -126,6 +130,11 @@ begin_conversion (struct context *c, const char *input)
|
||
seg_num = get_number_of_segments (c);
|
||
if (seg_num >= c->sellen) {
|
||
c->sellen *= 2;
|
||
+ if (sizeof(int) * c->sellen >= INT_MAX || c->sellen < 0) {
|
||
+ anthy_log(0, "Exceed max allocation size: %lu >= %d\n",
|
||
+ (unsigned long)sizeof(int) * c->sellen, INT_MAX);
|
||
+ return -1;
|
||
+ }
|
||
c->selection = realloc (c->selection, c->sellen);
|
||
if (c->selection == NULL) { /* Fatal */
|
||
c->sellen = -1;
|
||
diff --git a/src-util/input.c b/src-util/input.c
|
||
index 5626115..030e3d8 100644
|
||
--- a/src-util/input.c
|
||
+++ b/src-util/input.c
|
||
@@ -5,6 +5,7 @@
|
||
*
|
||
* Funded by IPA未踏ソフトウェア創造事業 2002 1/23
|
||
* Copyright (C) 2001-2002 UGAWA Tomoharu
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmai.com>
|
||
*
|
||
* $Id: input.c,v 1.25 2002/11/16 03:35:21 yusuke Exp $
|
||
*
|
||
@@ -21,6 +22,7 @@
|
||
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/input.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
#include "rkconv.h"
|
||
#include "rkhelper.h"
|
||
@@ -332,6 +334,10 @@ cmdh_get_candidate(struct anthy_input_context* ictx, int cand_no)
|
||
|
||
seg = (struct anthy_input_segment*)
|
||
malloc(sizeof(struct anthy_input_segment));
|
||
+ if (!seg) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
len = anthy_get_segment(ictx->actx, cs->index, cand_no, NULL, 0);
|
||
seg->str = (char*) malloc(len + 1);
|
||
anthy_get_segment(ictx->actx, cs->index, cand_no, seg->str, len + 1);
|
||
@@ -394,6 +400,10 @@ do_cmd_push_key(struct anthy_input_context* ictx, const char* str)
|
||
{
|
||
const char* p;
|
||
|
||
+ if (!str) {
|
||
+ anthy_log(0, "str should not be null in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
for (p = str; *p; p++) {
|
||
if (isspace((int)(unsigned char) *p) && *p != ' ')
|
||
continue;
|
||
@@ -551,7 +561,10 @@ cmd_resize(struct anthy_input_context* ictx, int d)
|
||
if (as->next == NULL) {
|
||
struct a_segment* as2;
|
||
|
||
- as2 = (struct a_segment*) malloc(sizeof(struct a_segment));
|
||
+ if (!(as2 = (struct a_segment*) malloc(sizeof(struct a_segment)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ break;
|
||
+ }
|
||
as2->index = i;
|
||
as2->prev = as;
|
||
as->next = as2;
|
||
@@ -773,6 +786,10 @@ anthy_input_create_context(struct anthy_input_config* cfg)
|
||
|
||
ictx =
|
||
(struct anthy_input_context*) malloc(sizeof(struct anthy_input_context));
|
||
+ if (!ictx) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
ictx->state = ANTHY_INPUT_ST_NONE;
|
||
ictx->rkctx = rk_context_create(cfg->break_into_roman);
|
||
for (i = 0; i < NR_RKMAP; i++)
|
||
@@ -1180,6 +1197,8 @@ alloc_segment(int flag, int len, int noconv_len)
|
||
struct anthy_input_segment *seg;
|
||
seg = (struct anthy_input_segment*)
|
||
malloc(sizeof(struct anthy_input_segment));
|
||
+ if (!seg)
|
||
+ return NULL;
|
||
seg->flag = flag;
|
||
seg->cand_no = -1;
|
||
seg->nr_cand = -1;
|
||
@@ -1207,6 +1226,11 @@ get_edit_mode_preedit(struct anthy_input_context* ictx,
|
||
if (ictx->n_hbuf > 0) {
|
||
*p = alloc_segment(ANTHY_INPUT_SF_EDITING, ictx->n_hbuf + 1,
|
||
ictx->n_hbuf);
|
||
+ if (!(*p) || !((*p)->str)) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ ictx->n_hbuf = 0;
|
||
+ return;
|
||
+ }
|
||
|
||
memcpy((*p)->str, ictx->hbuf, ictx->n_hbuf);
|
||
(*p)->str[ictx->n_hbuf] = '\0';
|
||
@@ -1216,7 +1240,11 @@ get_edit_mode_preedit(struct anthy_input_context* ictx,
|
||
if (ictx->cfg->preedit_mode) {
|
||
len = rk_partial_result(ictx->rkctx, NULL, 0);
|
||
if (len > 1) {
|
||
- *p = alloc_segment(ANTHY_INPUT_SF_PENDING, len, len - 1);
|
||
+ if (!(*p = alloc_segment(ANTHY_INPUT_SF_PENDING, len, len - 1))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ pedit->cur_segment = NULL;
|
||
+ return;
|
||
+ }
|
||
|
||
rk_partial_result(ictx->rkctx, (*p)->str, len);
|
||
p = &(*p)->next;
|
||
@@ -1224,7 +1252,11 @@ get_edit_mode_preedit(struct anthy_input_context* ictx,
|
||
} else {
|
||
len = rk_get_pending_str(ictx->rkctx, NULL, 0);
|
||
if (len > 1) {
|
||
- *p = alloc_segment(ANTHY_INPUT_SF_PENDING, len, len - 1);
|
||
+ if (!(*p = alloc_segment(ANTHY_INPUT_SF_PENDING, len, len - 1))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ pedit->cur_segment = NULL;
|
||
+ return;
|
||
+ }
|
||
|
||
rk_get_pending_str(ictx->rkctx, (*p)->str, len);
|
||
p = &(*p)->next;
|
||
@@ -1232,7 +1264,11 @@ get_edit_mode_preedit(struct anthy_input_context* ictx,
|
||
}
|
||
|
||
/* cursor */
|
||
- *p = alloc_segment(ANTHY_INPUT_SF_CURSOR, 0, 0);
|
||
+ if (!(*p = alloc_segment(ANTHY_INPUT_SF_CURSOR, 0, 0))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ pedit->cur_segment = NULL;
|
||
+ return;
|
||
+ }
|
||
pedit->cur_segment = *p;
|
||
p = &(*p)->next;
|
||
|
||
@@ -1241,8 +1277,12 @@ get_edit_mode_preedit(struct anthy_input_context* ictx,
|
||
*p = alloc_segment(ANTHY_INPUT_SF_EDITING,
|
||
ictx->n_hbuf_follow + 1,
|
||
ictx->n_hbuf_follow);
|
||
- memcpy((*p)->str, ictx->hbuf_follow, ictx->n_hbuf_follow);
|
||
- (*p)->str[ictx->n_hbuf_follow] = '\0';
|
||
+ if (!(*p) || !((*p)->str)) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ } else {
|
||
+ memcpy((*p)->str, ictx->hbuf_follow, ictx->n_hbuf_follow);
|
||
+ (*p)->str[ictx->n_hbuf_follow] = '\0';
|
||
+ }
|
||
}
|
||
}
|
||
|
||
@@ -1253,14 +1293,21 @@ anthy_input_get_preedit(struct anthy_input_context* ictx)
|
||
|
||
pedit = (struct anthy_input_preedit*)
|
||
malloc(sizeof(struct anthy_input_preedit));
|
||
+ if (!pedit) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
pedit->state = ictx->state;
|
||
|
||
/* 未コミットの文字列 */
|
||
if (ictx->n_commit > 0) {
|
||
- pedit->commit = (char*) malloc(ictx->n_commit + 1);
|
||
- memcpy(pedit->commit, ictx->commit, ictx->n_commit);
|
||
- pedit->commit[ictx->n_commit] = '\0';
|
||
+ if (!(pedit->commit = (char*) malloc(ictx->n_commit + 1))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ } else {
|
||
+ memcpy(pedit->commit, ictx->commit, ictx->n_commit);
|
||
+ pedit->commit[ictx->n_commit] = '\0';
|
||
+ }
|
||
ictx->n_commit = 0;
|
||
} else {
|
||
pedit->commit = NULL;
|
||
@@ -1268,9 +1315,12 @@ anthy_input_get_preedit(struct anthy_input_context* ictx)
|
||
|
||
/* カットバッファの文字列 */
|
||
if(ictx->n_cut > 0) {
|
||
- pedit->cut_buf = (char*) malloc(ictx->n_cut + 1);
|
||
- memcpy(pedit->cut_buf, ictx->cut, ictx->n_cut);
|
||
- pedit->cut_buf[ictx->n_cut] = '\0';
|
||
+ if (!(pedit->cut_buf = (char*) malloc(ictx->n_cut + 1))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ } else {
|
||
+ memcpy(pedit->cut_buf, ictx->cut, ictx->n_cut);
|
||
+ pedit->cut_buf[ictx->n_cut] = '\0';
|
||
+ }
|
||
ictx->n_cut = 0;
|
||
} else {
|
||
pedit->cut_buf = NULL;
|
||
@@ -1299,7 +1349,10 @@ anthy_input_get_preedit(struct anthy_input_context* ictx)
|
||
NTH_UNCONVERTED_CANDIDATE,
|
||
NULL, 0);
|
||
len = anthy_get_segment(ictx->actx, as->index, as->cand, NULL, 0);
|
||
- *p = alloc_segment(ANTHY_INPUT_SF_NONE, len + 1, noconv_len);
|
||
+ if (!(*p = alloc_segment(ANTHY_INPUT_SF_NONE, len + 1, noconv_len))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return pedit;
|
||
+ }
|
||
|
||
anthy_get_segment(ictx->actx, as->index, as->cand, (*p)->str, len + 1);
|
||
(*p)->cand_no = as->cand;
|
||
@@ -1324,6 +1377,10 @@ anthy_input_get_preedit(struct anthy_input_context* ictx)
|
||
|
||
p = &(*p)->next;
|
||
*p = alloc_segment(ANTHY_INPUT_SF_FOLLOWING, len + 1, len);
|
||
+ if (!(*p) || !((*p)->str)) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ break;
|
||
+ }
|
||
for (as1 = as->next, s = (*p)->str; as1; as1 = as1->next) {
|
||
anthy_get_segment(ictx->actx, as1->index,
|
||
NTH_UNCONVERTED_CANDIDATE,
|
||
@@ -1490,6 +1547,10 @@ anthy_input_create_config(void)
|
||
struct anthy_input_config* cfg;
|
||
|
||
cfg = (struct anthy_input_config*) malloc(sizeof(struct anthy_input_config));
|
||
+ if (!cfg) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
cfg->rk_option = anthy_input_create_rk_option();
|
||
cfg->break_into_roman = 0;
|
||
diff --git a/src-util/rkconv.c b/src-util/rkconv.c
|
||
index acbb1ef..435dc6b 100644
|
||
--- a/src-util/rkconv.c
|
||
+++ b/src-util/rkconv.c
|
||
@@ -7,12 +7,16 @@
|
||
* $Id: rkconv.c,v 1.16 2002/11/16 03:35:21 yusuke Exp $
|
||
*
|
||
* Copyright (C) 2001-2002 UGAWA Tomoharu
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
|
||
+#include <anthy/logger.h>
|
||
+
|
||
#include "rkconv.h"
|
||
|
||
#define MAX_CONV_CHARS 1024
|
||
@@ -193,7 +197,7 @@ rk_slr_closure_create(struct rk_rule_set* rs,
|
||
struct rk_rule* r;
|
||
int c;
|
||
r = rs->rules + i;
|
||
- if (pflen > 0 && strncmp(prefix, r->lhs, pflen) != 0)
|
||
+ if (pflen > 0 && strncmp(prefix ? prefix : "", r->lhs, pflen) != 0)
|
||
continue;
|
||
|
||
c = r->lhs[pflen] & 0x7f;
|
||
@@ -341,9 +345,13 @@ rk_convert_iterative(struct rk_conv_context* cc, int c,
|
||
static void
|
||
brk_roman_init(struct rk_conv_context *rkctx)
|
||
{
|
||
- rkctx->brk_roman= (struct break_roman *)malloc(sizeof(struct break_roman));
|
||
- rkctx->brk_roman->pending=NULL;
|
||
- rkctx->brk_roman->pending_size=0;
|
||
+ rkctx->brk_roman = (struct break_roman *)malloc(sizeof(struct break_roman));
|
||
+ if (!rkctx->brk_roman) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
+ rkctx->brk_roman->pending = NULL;
|
||
+ rkctx->brk_roman->pending_size = 0;
|
||
}
|
||
|
||
static void
|
||
@@ -354,10 +362,10 @@ brk_roman_free(struct rk_conv_context *rkctx)
|
||
if(!br)
|
||
return;
|
||
|
||
- if (br->pending) {
|
||
- free(br->pending);
|
||
- }
|
||
+ free(br->pending);
|
||
+ br->pending = NULL;
|
||
free(br);
|
||
+ rkctx->brk_roman = NULL;
|
||
}
|
||
|
||
|
||
@@ -374,8 +382,7 @@ brk_roman_save_pending(struct rk_conv_context *rkctx)
|
||
|
||
if(br->pending_size < len){
|
||
br->pending_size=len;
|
||
- if(br->pending)
|
||
- free(br->pending);
|
||
+ free(br->pending);
|
||
br->pending=(char *)malloc(len);
|
||
}
|
||
|
||
@@ -386,7 +393,12 @@ brk_roman_save_pending(struct rk_conv_context *rkctx)
|
||
static void
|
||
brk_roman_set_decided_len(struct rk_conv_context *rkctx,int len)
|
||
{
|
||
- struct break_roman *br=rkctx->brk_roman;
|
||
+ struct break_roman *br;
|
||
+ if (!rkctx) {
|
||
+ anthy_log(0, "Failed rkctx != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
+ br=rkctx->brk_roman;
|
||
|
||
if(!br)
|
||
return;
|
||
@@ -447,6 +459,10 @@ int
|
||
rk_push_key(struct rk_conv_context* cc, int c)
|
||
{
|
||
int increased_length;
|
||
+ if (!cc) {
|
||
+ anthy_log(0, "Failed cc != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return -1;
|
||
+ }
|
||
c &= 0x7f;
|
||
if (cc->cur_state == NULL)
|
||
return -1;
|
||
@@ -527,6 +543,10 @@ rk_select_map(struct rk_conv_context* cc, struct rk_map* map)
|
||
{
|
||
struct rk_map* old_map;
|
||
|
||
+ if (!cc) {
|
||
+ anthy_log(0, "Failed cc != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
cc->old_map_no = cc->map_no;
|
||
old_map = cc->map;
|
||
if (old_map) {
|
||
@@ -557,6 +577,10 @@ rk_get_pending_str(struct rk_conv_context* cc, char* buf, int size)
|
||
|
||
if (size <= 0)
|
||
return strlen(p) + 1;
|
||
+ if (!buf) {
|
||
+ anthy_log(0, "Failed buf != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 0;
|
||
+ }
|
||
|
||
q = buf;
|
||
end = buf + size - 1;
|
||
@@ -588,6 +612,7 @@ rk_register_map(struct rk_conv_context* cc, int mapn, struct rk_map* map)
|
||
void
|
||
rk_select_registered_map(struct rk_conv_context* cc, int mapn)
|
||
{
|
||
+ assert(cc);
|
||
if (0 <= mapn && mapn < 0 + MAX_MAP_PALETTE) {
|
||
rk_select_map(cc, cc->map_palette[mapn]);
|
||
cc->map_no = mapn;
|
||
@@ -663,7 +688,6 @@ rk_sort_rule(const struct rk_rule *src)
|
||
ERROR:
|
||
rules[i].lhs = NULL;
|
||
rk_rules_free(rules);
|
||
- free(rules);
|
||
return NULL;
|
||
}
|
||
|
||
diff --git a/src-worddic/dic_util.c b/src-worddic/dic_util.c
|
||
index 3963e8f..9eae864 100644
|
||
--- a/src-worddic/dic_util.c
|
||
+++ b/src-worddic/dic_util.c
|
||
@@ -17,6 +17,7 @@
|
||
* Funded by IPA未踏ソフトウェア創造事業 2001 10/24
|
||
*
|
||
* Copyright (C) 2001-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -34,6 +35,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
@@ -41,9 +43,10 @@
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/conf.h>
|
||
#include <anthy/dic.h>
|
||
-#include <anthy/texttrie.h>
|
||
-#include <anthy/textdict.h>
|
||
#include <anthy/dicutil.h>
|
||
+#include <anthy/logger.h>
|
||
+#include <anthy/textdict.h>
|
||
+#include <anthy/texttrie.h>
|
||
|
||
#include "dic_main.h"
|
||
#include "dic_personality.h"
|
||
@@ -291,6 +294,10 @@ anthy_priv_dic_get_index(char *buf, int len)
|
||
} else {
|
||
src_buf = strdup(src_buf);
|
||
}
|
||
+ if (!src_buf) {
|
||
+ anthy_log(0, "Failed src_buf != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
/* 最初の空白か\0までをコピーする */
|
||
for (i = 0; src_buf[i] && src_buf[i] != ' '; i++) {
|
||
if (i >= len - 1) {
|
||
@@ -356,6 +363,7 @@ anthy_priv_dic_get_word(char *buf, int len)
|
||
}
|
||
/* 品詞の後ろにある単語を取り出す */
|
||
s = strchr(v, ' ');
|
||
+ assert(s);
|
||
s++;
|
||
if (!word_iterator.in_tt && dic_util_encoding == ANTHY_EUC_JP_ENCODING) {
|
||
s = anthy_conv_utf8_to_euc(s);
|
||
@@ -441,6 +449,10 @@ find_same_word(char *idx_buf, const char *yomi,
|
||
const char *word, const char *wt_name, int yomi_len)
|
||
{
|
||
int found = 0;
|
||
+ if (!idx_buf) {
|
||
+ anthy_log(0, "Failed idx_buf != NULL in %s:%d\n", __FILE__, __LINE__);
|
||
+ return found;
|
||
+ }
|
||
sprintf(idx_buf, "%s%s ",
|
||
encoding_prefix(dic_util_encoding),
|
||
yomi);
|
||
@@ -456,6 +468,13 @@ find_same_word(char *idx_buf, const char *yomi,
|
||
break;
|
||
}
|
||
/* texttrieにアクセスして、見出語以外も一致しているかをチェック */
|
||
+ /* 単語を読み出して登録
|
||
+ * GCC 11.0.1 reports double-'free' of 'v'
|
||
+ * in case statement with "-Wanalyzer-double-free" option
|
||
+ * but 'v' is always allocated newly.
|
||
+ */
|
||
+#pragma GCC diagnostic push
|
||
+#pragma GCC diagnostic ignored "-Wanalyzer-double-free"
|
||
v = anthy_trie_find(anthy_private_tt_dic, idx_buf);
|
||
if (v) {
|
||
found = dup_word_check(v, word, wt_name);
|
||
@@ -464,6 +483,7 @@ find_same_word(char *idx_buf, const char *yomi,
|
||
break;
|
||
}
|
||
}
|
||
+#pragma GCC diagnostic pop
|
||
} while (anthy_trie_find_next_key(anthy_private_tt_dic,
|
||
idx_buf, yomi_len + 12));
|
||
|
||
@@ -565,9 +585,7 @@ do_search(FILE *fp, const char *word)
|
||
continue;
|
||
}
|
||
if (!strncasecmp(buf, word, len)) {
|
||
- if (res) {
|
||
- free(res);
|
||
- }
|
||
+ free(res);
|
||
res = strdup(buf);
|
||
}
|
||
}
|
||
diff --git a/src-worddic/ext_ent.c b/src-worddic/ext_ent.c
|
||
index 45ecdd3..8701d43 100644
|
||
--- a/src-worddic/ext_ent.c
|
||
+++ b/src-worddic/ext_ent.c
|
||
@@ -5,6 +5,7 @@
|
||
*
|
||
* Copyright (C) 2001-2005 TABATA Yusuke
|
||
* Copyright (C) 2004-2005 YOSHIDA Yuichi
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -22,11 +23,13 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <stdio.h>
|
||
#include <anthy/anthy.h> /* for ANTHY_*_ENCODING */
|
||
#include <anthy/conf.h>
|
||
+#include <anthy/logger.h>
|
||
#include <anthy/xstr.h>
|
||
#include <anthy/xchar.h>
|
||
#include "dic_main.h"
|
||
@@ -201,6 +204,8 @@ compose_num_component(xstr *xs, long long num)
|
||
{
|
||
int n[4],i;
|
||
int a[4] = { 0 , KJ_10, KJ_100, KJ_1000};
|
||
+ xstr *tmp;
|
||
+ assert(xs);
|
||
for (i = 0; i < 4; i++) {
|
||
n[i] = num-(num/10)*10;
|
||
num /= 10;
|
||
@@ -209,14 +214,17 @@ compose_num_component(xstr *xs, long long num)
|
||
for (i = 3; i > 0; i--) {
|
||
if (n[i] > 0) {
|
||
if (n[i] > 1) {
|
||
- anthy_xstrappend(xs, get_kj_num(n[i]));
|
||
+ tmp = anthy_xstrappend(xs, get_kj_num(n[i]));
|
||
+ assert(tmp == xs);
|
||
}
|
||
- anthy_xstrappend(xs, a[i]);
|
||
+ tmp = anthy_xstrappend(xs, a[i]);
|
||
+ assert(tmp == xs);
|
||
}
|
||
}
|
||
/* 1の位 */
|
||
if (n[0]) {
|
||
- anthy_xstrappend(xs, get_kj_num(n[0]));
|
||
+ tmp = anthy_xstrappend(xs, get_kj_num(n[0]));
|
||
+ assert(tmp == xs);
|
||
}
|
||
}
|
||
|
||
@@ -339,16 +347,20 @@ gen_separated_num(long long num, xstr *dest, int full)
|
||
|
||
/* 桁数を数える */
|
||
for (tmp = num; tmp != 0; tmp /= 10) {
|
||
- width ++;
|
||
+ width++;
|
||
}
|
||
/* 点の数 */
|
||
dot_count = (width - 1) / 3;
|
||
/* 格納するのに必要な文字列を用意する */
|
||
dest->len = dot_count + width;
|
||
- dest->str = malloc(sizeof(xchar)*dest->len);
|
||
+ if (!(dest->str = malloc(sizeof(xchar)*dest->len))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ dest->len = 0;
|
||
+ return -1;
|
||
+ }
|
||
|
||
/* 右の桁から順に決めていく */
|
||
- for (i = 0, pos = dest->len - 1; i < width; i++, pos --) {
|
||
+ for (i = 0, (pos = dest->len - 1) && (pos >= 0); i < width; i++, pos--) {
|
||
int n = num % 10;
|
||
/* カンマを追加 */
|
||
if (i > 0 && (i % 3) == 0) {
|
||
@@ -357,7 +369,11 @@ gen_separated_num(long long num, xstr *dest, int full)
|
||
} else {
|
||
dest->str[pos] = ',';
|
||
}
|
||
- pos --;
|
||
+ pos--;
|
||
+ }
|
||
+ if (pos < 0) {
|
||
+ anthy_log(0, "pos %d < 0 in %s:%d\n", pos, __FILE__, __LINE__);
|
||
+ break;
|
||
}
|
||
if (full) {
|
||
/* 全角数字 */
|
||
@@ -396,7 +412,12 @@ anthy_get_nth_dic_ent_str_of_ext_ent(seq_ent_t se, xstr *xs,
|
||
if (anthy_get_xstr_type(xs) & (XCT_NUM|XCT_WIDENUM)) {
|
||
long long num = anthy_xstrtoll(xs);
|
||
const int base_ents = get_nr_num_ents(num); /* 3桁郵便番号への対応 */
|
||
- /* 漢数字、アラビア数字、全角半角切替え */
|
||
+ /* 漢数字、アラビア数字、全角半角切替え
|
||
+ * GCC 11.0.1 reports this statement may fall through because of no break
|
||
+ * in case statement with "-Wimplicit-fallthrough" option.
|
||
+ */
|
||
+#pragma GCC diagnostic push
|
||
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
||
switch(nth) {
|
||
case 1:
|
||
/* 全角半角を入れ換えたもの */
|
||
@@ -431,6 +452,7 @@ anthy_get_nth_dic_ent_str_of_ext_ent(seq_ent_t se, xstr *xs,
|
||
}
|
||
break;
|
||
}
|
||
+#pragma GCC diagnostic pop
|
||
return -1;
|
||
}
|
||
return 0;
|
||
diff --git a/src-worddic/feature_set.c b/src-worddic/feature_set.c
|
||
index 0af964e..36576e4 100644
|
||
--- a/src-worddic/feature_set.c
|
||
+++ b/src-worddic/feature_set.c
|
||
@@ -3,6 +3,7 @@
|
||
* 素性の番号と意味を隠蔽して管理する
|
||
*
|
||
* Copyright (C) 2006-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -20,6 +21,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
@@ -232,6 +234,11 @@ anthy_find_feature_freq(const void *image,
|
||
|
||
/* 配列にコピーする */
|
||
nr = anthy_feature_list_nr(fl);
|
||
+ /* From anthy_feature_list_add(), nr should <= NR_EM_FEATURES.
|
||
+ * And i should be < NR_EM_FEATURES for anthy_feature_list_nth()
|
||
+ * which accesses fl->u.index[i].
|
||
+ */
|
||
+ assert(nr <= NR_EM_FEATURES);
|
||
for (i = 0; i < NR_EM_FEATURES + 2; i++) {
|
||
if (i < nr) {
|
||
f[i] = anthy_feature_list_nth(fl, i);
|
||
diff --git a/src-worddic/matrix.c b/src-worddic/matrix.c
|
||
index d4627fe..ba65c66 100644
|
||
--- a/src-worddic/matrix.c
|
||
+++ b/src-worddic/matrix.c
|
||
@@ -44,6 +44,7 @@
|
||
* image[2+image[0] ~ 2+image[0]+image[1]-1] : hashed row array
|
||
*
|
||
* Copyright (C) 2005 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
/*
|
||
@@ -61,12 +62,14 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
|
||
#include <anthy/diclib.h>
|
||
/* public APIs */
|
||
#include <anthy/matrix.h>
|
||
+#include <anthy/logger.h>
|
||
|
||
/* maximum length allowed for hash chain */
|
||
#define MAX_FAILURE 50
|
||
@@ -114,6 +117,8 @@ sparse_array_new(void)
|
||
a->head.next = NULL;
|
||
a->head.orig_next = NULL;
|
||
a->head.index = -1;
|
||
+ a->head.ptr = NULL;
|
||
+ a->head.value = 0;
|
||
/**/
|
||
a->array_len = 0;
|
||
a->array = NULL;
|
||
@@ -182,7 +187,10 @@ sparse_array_try_make_array(struct sparse_array *s)
|
||
struct list_elm *e;
|
||
/* initialize */
|
||
free(s->array);
|
||
- s->array = malloc(sizeof(struct array_elm) * s->array_len);
|
||
+ if (!(s->array = malloc(sizeof(struct array_elm) * s->array_len))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return 1;
|
||
+ }
|
||
for (i = 0; i < s->array_len; i++) {
|
||
s->array[i].index = -1;
|
||
}
|
||
@@ -193,6 +201,7 @@ sparse_array_try_make_array(struct sparse_array *s)
|
||
int n = 0;
|
||
do {
|
||
int h = hash(e->index, s->array_len, n);
|
||
+ assert((h >= 0) && (h < s->array_len));
|
||
if (s->array[h].index == -1) {
|
||
/* find unused element in this array */
|
||
ok = 1;
|
||
@@ -201,7 +210,7 @@ sparse_array_try_make_array(struct sparse_array *s)
|
||
s->array[h].ptr = e->ptr;
|
||
} else {
|
||
/* collision */
|
||
- n ++;
|
||
+ n++;
|
||
if (n > MAX_FAILURE) {
|
||
/* too much collision */
|
||
return 1;
|
||
@@ -246,7 +255,7 @@ sparse_array_get(struct sparse_array *s, int index, struct array_elm *arg)
|
||
}
|
||
}
|
||
} else {
|
||
- struct list_elm *e = e = s->head.next;
|
||
+ struct list_elm *e = s->head.next;
|
||
while (e) {
|
||
if (e->index == index) {
|
||
arg->value = e->value;
|
||
@@ -287,6 +296,32 @@ sparse_array_get_ptr(struct sparse_array *s, int index)
|
||
return NULL;
|
||
}
|
||
|
||
+static void
|
||
+sparse_array_free (struct sparse_array **array)
|
||
+{
|
||
+ struct list_elm *e;
|
||
+
|
||
+ assert(array);
|
||
+ if (!(*array))
|
||
+ return;
|
||
+ free ((*array)->array);
|
||
+ (*array)->array = NULL;
|
||
+ for (e = (*array)->head.next; e;) {
|
||
+ struct list_elm *next = e->next;
|
||
+ struct sparse_array *sub = e->ptr;
|
||
+ sparse_array_free (&sub);
|
||
+ e->ptr = NULL;
|
||
+ e->next = NULL;
|
||
+ free (e);
|
||
+ e = next;
|
||
+ }
|
||
+ (*array)->head.next = NULL;
|
||
+ if (!(*array))
|
||
+ return;
|
||
+ free (*array);
|
||
+ *array = NULL;
|
||
+}
|
||
+
|
||
/**/
|
||
struct sparse_matrix {
|
||
/**/
|
||
@@ -320,7 +355,7 @@ find_row(struct sparse_matrix *m, int row, int create)
|
||
/* allocate a new row */
|
||
a = sparse_array_new();
|
||
sparse_array_set(m->row_array, row, 0, a);
|
||
- m->nr_rows ++;
|
||
+ m->nr_rows++;
|
||
return a;
|
||
}
|
||
|
||
@@ -339,11 +374,10 @@ int
|
||
anthy_sparse_matrix_get_int(struct sparse_matrix *m, int row, int column)
|
||
{
|
||
struct sparse_array *a;
|
||
- struct list_elm *e;
|
||
+ struct list_elm *e = NULL;
|
||
a = find_row(m, row, 1);
|
||
- if (!a) {
|
||
+ if (!a)
|
||
return 0;
|
||
- }
|
||
for (e = &a->head; e; e = e->next) {
|
||
if (e->index == column) {
|
||
return e->value;
|
||
@@ -378,6 +412,14 @@ anthy_sparse_matrix_make_matrix(struct sparse_matrix *m)
|
||
m->array_length = offset;
|
||
}
|
||
|
||
+/* API */
|
||
+void
|
||
+anthy_sparse_matrix_free (struct sparse_matrix *m)
|
||
+{
|
||
+ sparse_array_free (&m->row_array);
|
||
+ free (m);
|
||
+}
|
||
+
|
||
/* API */
|
||
struct matrix_image *
|
||
anthy_matrix_image_new(struct sparse_matrix *s)
|
||
@@ -386,15 +428,24 @@ anthy_matrix_image_new(struct sparse_matrix *s)
|
||
int i;
|
||
int offset;
|
||
/**/
|
||
- mi = malloc(sizeof(struct matrix_image));
|
||
+ assert(s && s->row_array);
|
||
+ if (!(mi = malloc(sizeof(struct matrix_image)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
mi->size = 2 + s->row_array->array_len * 2 + s->array_length * 2;
|
||
- mi->image = malloc(sizeof(int) * mi->size);
|
||
+ if (!(mi->image = malloc(sizeof(int) * mi->size))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(mi);
|
||
+ return NULL;
|
||
+ }
|
||
mi->image[0] = s->row_array->array_len;
|
||
mi->image[1] = s->array_length;
|
||
/* row index */
|
||
offset = 2;
|
||
for (i = 0; i < s->row_array->array_len; i++) {
|
||
struct array_elm *ae;
|
||
+ assert(s->row_array->array);
|
||
ae = &s->row_array->array[i];
|
||
mi->image[offset + i*2] = ae->index;
|
||
mi->image[offset + i*2 + 1] = ae->value;
|
||
@@ -405,6 +456,7 @@ anthy_matrix_image_new(struct sparse_matrix *s)
|
||
struct array_elm *ae;
|
||
struct sparse_array *sa;
|
||
int j;
|
||
+ assert(s->row_array->array);
|
||
ae = &s->row_array->array[i];
|
||
if (ae->index == -1) {
|
||
continue;
|
||
@@ -414,7 +466,10 @@ anthy_matrix_image_new(struct sparse_matrix *s)
|
||
continue;
|
||
}
|
||
for (j = 0; j < sa->array_len; j++) {
|
||
- struct array_elm *cell = &sa->array[j];
|
||
+ struct array_elm *cell;
|
||
+ assert(sa->array);
|
||
+ cell = &sa->array[j];
|
||
+ assert(cell);
|
||
mi->image[offset] = cell->index;
|
||
if (cell->index == -1) {
|
||
mi->image[offset + 1] = -1;
|
||
diff --git a/src-worddic/priv_dic.c b/src-worddic/priv_dic.c
|
||
index ce0693d..3c3c268 100644
|
||
--- a/src-worddic/priv_dic.c
|
||
+++ b/src-worddic/priv_dic.c
|
||
@@ -5,6 +5,7 @@
|
||
* 未知語を自動的に学習して管理するAPIも持つ。
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -21,6 +22,7 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <errno.h>
|
||
#include <sys/types.h>
|
||
#include <sys/stat.h>
|
||
#include <dirent.h>
|
||
@@ -44,6 +46,7 @@
|
||
#include <anthy/word_dic.h>
|
||
#include "dic_main.h"
|
||
#include "dic_ent.h"
|
||
+#include <src-diclib/diclib_inner.h>
|
||
|
||
/* 個人辞書 */
|
||
struct text_trie *anthy_private_tt_dic;
|
||
@@ -82,17 +85,26 @@ anthy_get_user_dir(int is_old)
|
||
|
||
if (is_old) {
|
||
hd = anthy_conf_get_str("HOME");
|
||
- old_anthy_private_dir = malloc(strlen(hd) + 10);
|
||
+ if (!(old_anthy_private_dir = malloc(strlen(hd) + 10))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
sprintf(old_anthy_private_dir, "%s/.anthy", hd);
|
||
return old_anthy_private_dir;
|
||
}
|
||
xdg = anthy_conf_get_str("XDG_CONFIG_HOME");
|
||
if (xdg && xdg[0]) {
|
||
- anthy_private_dir = malloc(strlen(xdg) + 10);
|
||
+ if (!(anthy_private_dir = malloc(strlen(xdg) + 10))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
sprintf(anthy_private_dir, "%s/anthy", xdg);
|
||
} else {
|
||
hd = anthy_conf_get_str("HOME");
|
||
- anthy_private_dir = malloc(strlen(hd) + 15);
|
||
+ if (!(anthy_private_dir = malloc(strlen(hd) + 15))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
sprintf(anthy_private_dir, "%s/.config/anthy", hd);
|
||
}
|
||
return anthy_private_dir;
|
||
@@ -102,20 +114,18 @@ anthy_get_user_dir(int is_old)
|
||
void
|
||
anthy_check_user_dir(void)
|
||
{
|
||
- struct stat st;
|
||
const char *dn = anthy_get_user_dir(0);
|
||
- if (stat(dn, &st) || !S_ISDIR(st.st_mode)) {
|
||
+ /* Use anthy_file_test() and anthy_mkdir_with_parents() since
|
||
+ * chmod() after stat() causes a a time-of-check, * time-of-use race
|
||
+ * condition (TOCTOU).
|
||
+ */
|
||
+ if (!anthy_file_test (dn, ANTHY_FILE_TEST_EXISTS | ANTHY_FILE_TEST_IS_DIR)) {
|
||
int r;
|
||
- /*fprintf(stderr, "Anthy: Failed to open anthy directory(%s).\n", dn);*/
|
||
+ errno = 0;
|
||
r = anthy_mkdir_with_parents(dn, S_IRWXU);
|
||
if (r == -1){
|
||
- anthy_log(0, "Failed to create profile directory\n");
|
||
- return ;
|
||
- }
|
||
- /*fprintf(stderr, "Anthy: Created\n");*/
|
||
- r = chmod(dn, S_IRUSR | S_IWUSR | S_IXUSR);
|
||
- if (r == -1) {
|
||
- anthy_log(0, "But failed to change permission.\n");
|
||
+ anthy_log(0, "Failed to create profile directory: %s\n", strerror(errno));
|
||
+ return;
|
||
}
|
||
}
|
||
}
|
||
@@ -238,12 +248,15 @@ copy_words_from_tt(struct seq_ent *seq, xstr *xs,
|
||
tt_dic = old_anthy_private_tt_dic;
|
||
else
|
||
tt_dic = anthy_private_tt_dic;
|
||
- if (!tt_dic) {
|
||
- return ;
|
||
- }
|
||
+ if (!tt_dic)
|
||
+ return;
|
||
key = anthy_xstr_to_cstr(xs, encoding);
|
||
key_len = strlen(key);
|
||
- key_buf = malloc(key_len + 12);
|
||
+ if (!(key_buf = malloc(key_len + 12))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(key);
|
||
+ return;
|
||
+ }
|
||
/* 辞書中には各単語が「見出し XXXX」(XXXXはランダムな文字列)を
|
||
* キーとして保存されているので列挙する
|
||
*/
|
||
@@ -255,12 +268,19 @@ copy_words_from_tt(struct seq_ent *seq, xstr *xs,
|
||
/* 「見出し 」で始まっていないので対象外 */
|
||
break;
|
||
}
|
||
- /* 単語を読み出して登録 */
|
||
+ /* 単語を読み出して登録
|
||
+ * GCC 11.0.1 reports double-'free' of 'v'
|
||
+ * in case statement with "-Wanalyzer-double-free" option
|
||
+ * but 'v' is always allocated newly.
|
||
+ */
|
||
+#pragma GCC diagnostic push
|
||
+#pragma GCC diagnostic ignored "-Wanalyzer-double-free"
|
||
v = anthy_trie_find(tt_dic, key_buf);
|
||
if (v) {
|
||
add_to_seq_ent(v, encoding, seq);
|
||
}
|
||
free(v);
|
||
+#pragma GCC diagnostic pop
|
||
/**/
|
||
} while (anthy_trie_find_next_key(tt_dic,
|
||
key_buf, key_len + 8));
|
||
diff --git a/src-worddic/record.c b/src-worddic/record.c
|
||
index 5d71f88..edd487f 100644
|
||
--- a/src-worddic/record.c
|
||
+++ b/src-worddic/record.c
|
||
@@ -30,18 +30,20 @@
|
||
* Copyright (C) 2000-2006 TABATA Yusuke
|
||
* Copyright (C) 2000-2003 UGAWA Tomoharu
|
||
* Copyright (C) 2001-2002 TAKAI Kosuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
* パーソナリティ""は匿名パーソナリティであり,
|
||
* ファイルへの読み書きは行わない.
|
||
*/
|
||
-#include <sys/types.h>
|
||
-#include <sys/stat.h>
|
||
+#include <assert.h>
|
||
#include <errno.h>
|
||
-#include <unistd.h>
|
||
-#include <string.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
+#include <string.h>
|
||
+#include <sys/types.h>
|
||
+#include <sys/stat.h>
|
||
+#include <unistd.h>
|
||
|
||
#include "config.h"
|
||
#include <anthy/anthy.h>
|
||
@@ -580,6 +582,7 @@ trie_remove(struct trie_root *root, xstr *key,
|
||
r = s;
|
||
s = trie_key_nth_bit(key, r->bit) ? r->r : r->l;
|
||
}
|
||
+ assert(pp);
|
||
*pp = (p->r == q) ? p->l : p->r;
|
||
p->l = q->l;
|
||
p->r = q->r;
|
||
@@ -1182,13 +1185,20 @@ read_journal_record(struct record_stat* rs)
|
||
fclose(fp);
|
||
return ;
|
||
}
|
||
+ errno = 0;
|
||
if (st.st_size < rs->last_update) {
|
||
|
||
/* ファイルサイズが小さくなっているので、
|
||
* 最初から読み込む */
|
||
- fseek(fp, 0, SEEK_SET);
|
||
+ if (fseek(fp, 0, SEEK_SET)) {
|
||
+ anthy_log(0, "Failed fseek in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, anthy_strerror(errno));
|
||
+ }
|
||
} else {
|
||
- fseek(fp, rs->last_update, SEEK_SET);
|
||
+ if (fseek(fp, rs->last_update, SEEK_SET)) {
|
||
+ anthy_log(0, "Failed fseek in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, anthy_strerror(errno));
|
||
+ }
|
||
}
|
||
rs->journal_timestamp = st.st_mtime;
|
||
while (!feof(fp)) {
|
||
@@ -2026,11 +2036,19 @@ setup_filenames(const char *id, struct record_stat *rst)
|
||
/* 基本ファイル */
|
||
rst->base_fn = (char*) malloc(base_len +
|
||
strlen("/last-record1_"));
|
||
+ if (!rst->base_fn) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
sprintf(rst->base_fn, "%s/last-record1_%s",
|
||
home, id);
|
||
/* 差分ファイル */
|
||
rst->journal_fn = (char*) malloc(base_len +
|
||
strlen("/last-record2_"));
|
||
+ if (!rst->journal_fn) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
sprintf(rst->journal_fn, "%s/last-record2_%s",
|
||
home, id);
|
||
}
|
||
diff --git a/src-worddic/textdict.c b/src-worddic/textdict.c
|
||
index ca5592a..7015664 100644
|
||
--- a/src-worddic/textdict.c
|
||
+++ b/src-worddic/textdict.c
|
||
@@ -1,5 +1,7 @@
|
||
/*
|
||
* ソートされたテキストから検索を行う
|
||
+ *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -16,6 +18,8 @@
|
||
License along with this library; if not, write to the Free Software
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
+#include <assert.h>
|
||
+#include <errno.h>
|
||
#include <unistd.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
@@ -177,10 +181,12 @@ anthy_textdict_delete_line(struct textdict *td, int offset)
|
||
}
|
||
len = strlen(buf);
|
||
fclose(fp);
|
||
- update_mapping(td);
|
||
- if (!td->mapping) {
|
||
+ if (update_mapping(td))
|
||
return -1;
|
||
- }
|
||
+ /* anthy_mmap() should make td->ptr if td->mapping is not null
|
||
+ * in update_mapping().
|
||
+ */
|
||
+ assert(td->ptr);
|
||
size = anthy_mmap_size(td->mapping);
|
||
memmove(&td->ptr[offset], &td->ptr[offset+len], size - offset - len);
|
||
unmap(td);
|
||
@@ -188,7 +194,11 @@ anthy_textdict_delete_line(struct textdict *td, int offset)
|
||
unlink(td->fn);
|
||
return 0;
|
||
}
|
||
- truncate(td->fn, size - len);
|
||
+ errno = 0;
|
||
+ if (truncate(td->fn, size - len)) {
|
||
+ anthy_log(0, "Failed truncate in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, strerror(errno));
|
||
+ }
|
||
return 0;
|
||
}
|
||
|
||
@@ -198,13 +208,16 @@ anthy_textdict_insert_line(struct textdict *td, int offset,
|
||
{
|
||
int len = strlen(line);
|
||
int size;
|
||
- if (!td) {
|
||
+ if (!td)
|
||
return -1;
|
||
- }
|
||
- if (expand_file(td, len)) {
|
||
+ if (expand_file(td, len))
|
||
return -1;
|
||
- }
|
||
- update_mapping(td);
|
||
+ if (update_mapping(td))
|
||
+ return -1;
|
||
+ /* anthy_mmap() should make td->ptr if td->mapping is not null
|
||
+ * in update_mapping().
|
||
+ */
|
||
+ assert(td->ptr);
|
||
size = anthy_mmap_size(td->mapping);
|
||
memmove(&td->ptr[offset+len], &td->ptr[offset], size - offset - len);
|
||
memcpy(&td->ptr[offset], line, len);
|
||
diff --git a/src-worddic/texttrie.c b/src-worddic/texttrie.c
|
||
index 9497a02..38576d8 100644
|
||
--- a/src-worddic/texttrie.c
|
||
+++ b/src-worddic/texttrie.c
|
||
@@ -31,7 +31,7 @@
|
||
* anthy_trie_print_array()
|
||
*
|
||
* Copyright (C) 2005-2006 TABATA Yusuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -49,17 +49,20 @@
|
||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
*/
|
||
/* open & mmap */
|
||
-#include <unistd.h>
|
||
-#include <sys/types.h>
|
||
-#include <sys/stat.h>
|
||
#include <fcntl.h>
|
||
+#include <sys/stat.h>
|
||
+#include <sys/types.h>
|
||
+#include <unistd.h>
|
||
/**/
|
||
+#include <assert.h>
|
||
+#include <ctype.h>
|
||
+#include <errno.h>
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
-#include <ctype.h>
|
||
-#include <anthy/texttrie.h>
|
||
#include <anthy/filemap.h>
|
||
+#include <anthy/texttrie.h>
|
||
+#include <anthy/logger.h>
|
||
#include "dic_main.h"
|
||
|
||
/* configs */
|
||
@@ -224,9 +227,10 @@ path_setup(struct path *path, const char *key, int len, int *buf)
|
||
path->len = 0;
|
||
path->cur = 0;
|
||
/**/
|
||
- while (*p) {
|
||
+ assert(p);
|
||
+ while ((*p) && (path->len < path->max_len)) {
|
||
path->path[path->len] = p[0] * 256 + p[1];
|
||
- path->len ++;
|
||
+ path->len++;
|
||
p++;
|
||
if (p[0]) {
|
||
p++;
|
||
@@ -288,7 +292,7 @@ encode_super(struct cell *c, char *buf)
|
||
buf += sput_int(buf, c->u.super.root_cell);
|
||
buf += sput_int(buf, c->u.super.first_unused);
|
||
buf += sput_int(buf, c->u.super.serial);
|
||
- buf += sput_int(buf, LINE_LEN);
|
||
+ sput_int(buf, LINE_LEN);
|
||
}
|
||
|
||
static void
|
||
@@ -299,7 +303,7 @@ encode_node(struct cell *c, char *buf)
|
||
buf += sput_int(buf, c->u.node.parent);
|
||
buf += sput_int(buf, c->u.node.next);
|
||
buf += sput_int(buf, c->u.node.child);
|
||
- buf += sput_int(buf, c->u.node.body);
|
||
+ sput_int(buf, c->u.node.body);
|
||
}
|
||
|
||
static void
|
||
@@ -316,7 +320,7 @@ static void
|
||
encode_unused(struct cell *c, char *buf)
|
||
{
|
||
buf += sprintf(buf, "-next=");
|
||
- buf += sput_int(buf, c->u.next_unused);
|
||
+ sput_int(buf, c->u.next_unused);
|
||
}
|
||
|
||
static void
|
||
@@ -378,7 +382,11 @@ write_back_cell(struct text_trie *tt, struct cell *c, int idx)
|
||
if (anthy_mmap_is_writable(tt->mapping)) {
|
||
memcpy(&tt->ptr[idx*LINE_LEN], buf, LINE_LEN);
|
||
} else {
|
||
- fseek(tt->wfp, idx*LINE_LEN, SEEK_SET);
|
||
+ errno = 0;
|
||
+ if (fseek(tt->wfp, idx*LINE_LEN, SEEK_SET)) {
|
||
+ anthy_log(0, "Failed fseek in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, anthy_strerror(errno));
|
||
+ }
|
||
fwrite(buf, LINE_LEN, 1, tt->wfp);
|
||
fflush(tt->wfp);
|
||
}
|
||
@@ -442,7 +450,7 @@ decode_super(struct cell *c, char *buf)
|
||
buf = sget_int(buf, &c->u.super.size);
|
||
buf = sget_int(buf, &c->u.super.root_cell);
|
||
buf = sget_int(buf, &c->u.super.first_unused);
|
||
- buf = sget_int(buf, &c->u.super.serial);
|
||
+ sget_int(buf, &c->u.super.serial);
|
||
return 0;
|
||
}
|
||
|
||
@@ -451,7 +459,7 @@ decode_unuse(struct cell *c, char *buf)
|
||
{
|
||
c->type = TT_UNUSED;
|
||
buf = pass_str(buf, "-next=");
|
||
- buf = sget_int(buf, &c->u.next_unused);
|
||
+ sget_int(buf, &c->u.next_unused);
|
||
return 0;
|
||
}
|
||
|
||
@@ -464,7 +472,7 @@ decode_node(struct cell *c, char *buf)
|
||
buf = sget_int(buf, &c->u.node.parent);
|
||
buf = sget_int(buf, &c->u.node.next);
|
||
buf = sget_int(buf, &c->u.node.child);
|
||
- buf = sget_int(buf, &c->u.node.body);
|
||
+ sget_int(buf, &c->u.node.body);
|
||
return 0;
|
||
}
|
||
|
||
@@ -507,6 +515,11 @@ decode_nth_cell(struct text_trie *tt, struct cell *c, int nth)
|
||
(nth + 1)) {
|
||
return NULL;
|
||
}
|
||
+ /* GCC 11.0.1 reports dereference of NULL 'buf'
|
||
+ * in case statement with "-Wanalyzer-null-dereference" option.
|
||
+ */
|
||
+#pragma GCC diagnostic push
|
||
+#pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
|
||
buf = &tt->ptr[nth*LINE_LEN];
|
||
|
||
res = -1;
|
||
@@ -533,6 +546,7 @@ decode_nth_cell(struct text_trie *tt, struct cell *c, int nth)
|
||
/*printf("decode fail (nth=%d::%s).\n", nth, buf);*/
|
||
;
|
||
}
|
||
+#pragma GCC diagnostic pop
|
||
if (res) {
|
||
c->type = TT_UNUSED;
|
||
}
|
||
@@ -606,7 +620,11 @@ set_file_size(struct text_trie *tt, int len)
|
||
return 0;
|
||
}
|
||
if (cur_size > size) {
|
||
- truncate(tt->fn, size);
|
||
+ errno = 0;
|
||
+ if (truncate(tt->fn, size)) {
|
||
+ anthy_log(0, "Failed truncate in %s:%d: %s\n",
|
||
+ __FILE__, __LINE__, strerror(errno));
|
||
+ }
|
||
} else {
|
||
err = expand_file(tt, (size - cur_size) / LINE_LEN);
|
||
if (!err) {
|
||
@@ -817,7 +835,10 @@ static struct text_trie *
|
||
alloc_tt(const char *fn, FILE *wfp)
|
||
{
|
||
struct text_trie *tt;
|
||
- tt = malloc(sizeof(struct text_trie));
|
||
+ if (!(tt = malloc(sizeof(struct text_trie)))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
tt->fatal = 0;
|
||
tt->wfp = wfp;
|
||
tt->valid_super = 0;
|
||
@@ -1018,7 +1039,11 @@ trie_search_rec(struct text_trie *tt, struct path *p,
|
||
int parent_idx, int create)
|
||
{
|
||
int child_idx;
|
||
- int key = p->path[p->cur];
|
||
+ int key;
|
||
+ assert(p);
|
||
+ assert(p->path);
|
||
+ assert((p->cur < p->max_len) && (p->cur >= 0));
|
||
+ key = p->path[p->cur];
|
||
/* special case */
|
||
if (p->cur == p->len) {
|
||
return parent_idx;
|
||
@@ -1459,7 +1484,7 @@ disconnect(struct text_trie *tt, int parent_idx, int target_idx)
|
||
/* not 1st child */
|
||
int child_idx = parent_cell.u.node.child;
|
||
while (child_idx) {
|
||
- struct cell cur;
|
||
+ struct cell cur = { 0, };
|
||
if (!decode_nth_cell(tt, &cur, child_idx)) {
|
||
return ;
|
||
}
|
||
diff --git a/src-worddic/word_dic.c b/src-worddic/word_dic.c
|
||
index 70d9376..cc2cf89 100644
|
||
--- a/src-worddic/word_dic.c
|
||
+++ b/src-worddic/word_dic.c
|
||
@@ -5,7 +5,7 @@
|
||
*
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
* Copyright (C) 2005-2006 YOSHIDA Yuichi
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -120,8 +120,17 @@ convert_vu(xstr *xs)
|
||
}
|
||
if (v > 0) {
|
||
xstr *nx = malloc(sizeof(xstr));
|
||
+ if (!nx) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return NULL;
|
||
+ }
|
||
nx->len = xs->len + v;
|
||
nx->str = malloc(sizeof(xchar)*nx->len);
|
||
+ if (!nx->str) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ free(nx);
|
||
+ return NULL;
|
||
+ }
|
||
j = 0;
|
||
/* 「ヴ」を「う゛」に変換しつつコピーする */
|
||
for (i = 0; i < xs->len; i++) {
|
||
@@ -325,10 +334,17 @@ do_gang_load_dic(xstr *sentence, int is_reverse)
|
||
nr += find_gang_elm(ator, &head, &xs);
|
||
}
|
||
}
|
||
- array = malloc(sizeof(struct gang_elm *) * nr);
|
||
+ if (!(array = malloc(sizeof(struct gang_elm *) * nr))) {
|
||
+ anthy_log(0, "Failed malloc in %s:%d\n", __FILE__, __LINE__);
|
||
+ return;
|
||
+ }
|
||
cur = head.tmp.next;
|
||
for (i = 0; i < nr; i++) {
|
||
array[i] = cur;
|
||
+ if (!cur) {
|
||
+ anthy_log(0, "gang_elm is null at %dth loop\n", i);
|
||
+ break;
|
||
+ }
|
||
cur = cur->tmp.next;
|
||
}
|
||
qsort(array, nr, sizeof(struct gang_elm *), gang_elm_compare_func);
|
||
diff --git a/src-worddic/word_lookup.c b/src-worddic/word_lookup.c
|
||
index 79725e2..e0d53dc 100644
|
||
--- a/src-worddic/word_lookup.c
|
||
+++ b/src-worddic/word_lookup.c
|
||
@@ -14,7 +14,7 @@
|
||
* Copyright (C) 2000-2007 TABATA Yusuke
|
||
* Copyright (C) 2005-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2001-2002 TAKAI Kosuke
|
||
- *
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*/
|
||
/*
|
||
This library is free software; you can redistribute it and/or
|
||
@@ -333,6 +333,7 @@ add_compound_ent(struct seq_ent *seq, struct wt_stat *ws,
|
||
static void
|
||
init_wt_stat(struct wt_stat *ws, char *line)
|
||
{
|
||
+ memset(&ws->wt, 0, sizeof(wtype_t));
|
||
ws->wt_name = NULL;
|
||
ws->freq = 0;
|
||
ws->feature = 0;
|
||
@@ -342,7 +343,7 @@ init_wt_stat(struct wt_stat *ws, char *line)
|
||
ws->encoding = ANTHY_EUC_JP_ENCODING;
|
||
if (*(ws->line) == 'u') {
|
||
ws->encoding = ANTHY_UTF8_ENCODING;
|
||
- ws->line ++;
|
||
+ ws->line++;
|
||
}
|
||
}
|
||
|
||
@@ -372,7 +373,7 @@ fill_dic_ent(char *line, struct seq_ent *seq,
|
||
ws.offset += add_dic_ent(seq, &ws, yomi,
|
||
is_reverse);
|
||
if (ws.order_bonus > 0) {
|
||
- ws.order_bonus --;
|
||
+ ws.order_bonus--;
|
||
}
|
||
}
|
||
if (ws.line[ws.offset] == ' ') {
|
||
diff --git a/test/check.c b/test/check.c
|
||
index f67dbac..24163ca 100644
|
||
--- a/test/check.c
|
||
+++ b/test/check.c
|
||
@@ -1,6 +1,8 @@
|
||
/* リリース前のチェックを行う */
|
||
+#include <assert.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
+#include <time.h>
|
||
#include <anthy/anthy.h>
|
||
#include <anthy/xstr.h>
|
||
|
||
@@ -48,7 +50,7 @@ test1(void)
|
||
{
|
||
anthy_context_t ac;
|
||
char buf[100];
|
||
- xstr *xs;
|
||
+ xstr *xs, *xs2;
|
||
ac = anthy_create_context();
|
||
if (!ac) {
|
||
printf("failed to create context\n");
|
||
@@ -71,11 +73,29 @@ test1(void)
|
||
}
|
||
anthy_release_context(ac);
|
||
xs = anthy_cstr_to_xstr("あいうえおがぎぐげご", ANTHY_UTF8_ENCODING);
|
||
- xs = anthy_xstr_hira_to_half_kata(xs);
|
||
- anthy_putxstrln(xs);
|
||
+ xs2 = anthy_xstr_hira_to_half_kata(xs);
|
||
+ anthy_putxstrln(xs2);
|
||
+ anthy_free_xstr(xs);
|
||
+ anthy_free_xstr(xs2);
|
||
return 0;
|
||
}
|
||
|
||
+/* compliant_rand:
|
||
+ * dont_call: "rand" should not be used for security-related applications,
|
||
+ * because linear congruential algorithms are too easy to break
|
||
+ * but we don't need the strict randoms here.
|
||
+ */
|
||
+static long int
|
||
+compliant_rand(void)
|
||
+{
|
||
+ struct timespec ts = { 0, };
|
||
+ if (!timespec_get (&ts, TIME_UTC)) {
|
||
+ printf("Failed timespec_get\n");
|
||
+ assert(0);
|
||
+ }
|
||
+ return ts.tv_nsec;
|
||
+}
|
||
+
|
||
static int
|
||
shake_test(const char *str)
|
||
{
|
||
@@ -92,8 +112,8 @@ shake_test(const char *str)
|
||
int nth, rsz;
|
||
struct anthy_conv_stat cs;
|
||
anthy_get_stat(ac, &cs);
|
||
- nth = rand() % cs.nr_segment;
|
||
- rsz = (rand() % 3) - 1;
|
||
+ nth = compliant_rand() % cs.nr_segment;
|
||
+ rsz = (compliant_rand() % 3) - 1;
|
||
anthy_resize_segment(ac, nth, rsz);
|
||
}
|
||
anthy_release_context(ac);
|
||
diff --git a/test/main.c b/test/main.c
|
||
index 0c01755..6442257 100644
|
||
--- a/test/main.c
|
||
+++ b/test/main.c
|
||
@@ -16,6 +16,7 @@
|
||
* Copyright (C) 2000-2006 TABATA Yusuke
|
||
* Copyright (C) 2004-2006 YOSHIDA Yuichi
|
||
* Copyright (C) 2001-2002 TAKAI Kosuke
|
||
+ * Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
*
|
||
*/
|
||
|
||
@@ -40,7 +41,7 @@
|
||
|
||
/* テストデータとなる変換前の文字列 */
|
||
#define TESTDATA "test.txt"
|
||
-const char *testdata = SRCDIR "/" TESTDATA;
|
||
+static char *testdata; /* = SRCDIR "/" TESTDATA */
|
||
|
||
/* 変換後の文字列が妥当かどうかをチェックするためのデータ */
|
||
#define EXPDATA "test.exp"
|
||
@@ -151,6 +152,7 @@ parse_args(struct condition *cond, int argc, char **argv)
|
||
{
|
||
int i;
|
||
char *arg;
|
||
+ testdata = strdup(SRCDIR "/" TESTDATA);
|
||
for (i = 1; i < argc; i++) {
|
||
arg = argv[i];
|
||
if (!strncmp(arg, "--", 2)) {
|
||
@@ -195,6 +197,7 @@ parse_args(struct condition *cond, int argc, char **argv)
|
||
} else {
|
||
char *buf = alloca(strlen(SRCDIR)+strlen(arg) + 10);
|
||
sprintf(buf, SRCDIR "/%s.txt", arg);
|
||
+ free(testdata);
|
||
testdata = strdup(buf);
|
||
}
|
||
}
|
||
@@ -306,6 +309,7 @@ save_db(const char *fn, struct res_db *db)
|
||
for (cr = db->res_list.next; cr; cr = cr->next) {
|
||
dump_res(fp, cr);
|
||
}
|
||
+ fclose(fp);
|
||
}
|
||
|
||
static void
|
||
@@ -316,7 +320,8 @@ ask_results(struct res_db *db)
|
||
if (cr->check == CHK_UNKNOWN && cr->used == 1) {
|
||
char buf[256];
|
||
printf("%s -> %s (y/n/d/q)\n", cr->src_str, cr->res_str);
|
||
- fgets(buf, 256, stdin);
|
||
+ if (!fgets(buf, 256, stdin))
|
||
+ printf("Failed fgets in %s:%d\n", __FILE__, __LINE__);
|
||
if (buf[0] == 'y') {
|
||
cr->check = CHK_OK;
|
||
} else if (buf[0] == 'n') {
|
||
@@ -376,7 +381,7 @@ main(int argc,char **argv)
|
||
int line = 1;
|
||
|
||
cur_input.serial = 0;
|
||
- cur_input.str = 0;
|
||
+ cur_input.str = NULL;
|
||
init_condition(&cond);
|
||
|
||
parse_args(&cond, argc, argv);
|
||
@@ -392,6 +397,7 @@ main(int argc,char **argv)
|
||
printf("failed to open %s.\n", testdata);
|
||
return 0;
|
||
}
|
||
+ free(testdata);
|
||
|
||
ac = init_lib(cond.use_utf8);
|
||
|
||
@@ -408,6 +414,9 @@ main(int argc,char **argv)
|
||
}
|
||
line++;
|
||
}
|
||
+ fclose(fp);
|
||
+ free(cur_input.str);
|
||
+ cur_input.str = NULL;
|
||
|
||
anthy_release_context(ac);
|
||
anthy_quit();
|
||
diff --git a/test/test-matrix.c b/test/test-matrix.c
|
||
index 0bb9917..13edcc2 100644
|
||
--- a/test/test-matrix.c
|
||
+++ b/test/test-matrix.c
|
||
@@ -1,4 +1,5 @@
|
||
/* 疎行列のテスト用コード */
|
||
+#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <anthy/dic.h>
|
||
#include <anthy/diclib.h>
|
||
@@ -26,6 +27,9 @@ zero_matrix(void)
|
||
im = mi->image;
|
||
e = anthy_matrix_image_peek(im, 0, 0);
|
||
printf("zero matrix: size=%d (0,0)=%d\n", mi->size, e);
|
||
+ free(mi->image);
|
||
+ free(mi);
|
||
+ anthy_sparse_matrix_free(m);
|
||
}
|
||
|
||
static void
|
||
@@ -61,6 +65,9 @@ dense_matrix(void)
|
||
}
|
||
}
|
||
printf("%d errors in desnse matrix\n", fail);
|
||
+ free(mi->image);
|
||
+ free(mi);
|
||
+ anthy_sparse_matrix_free(m);
|
||
}
|
||
|
||
int
|
||
--
|
||
2.28.0
|
||
|
||
From 1873b393c0b2954173537d1e58320381b0ad60da Mon Sep 17 00:00:00 2001
|
||
From: masanari iida <masanari.iida@hpe.com>
|
||
Date: Fri, 22 Oct 2021 11:45:30 +0900
|
||
Subject: [PATCH] alt-cannadic: Update gcanna.ctd with Shubitai
|
||
|
||
BUG=rhbz#2007482
|
||
---
|
||
alt-cannadic/gcanna.ctd | 3 ++-
|
||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
||
diff --git a/alt-cannadic/gcanna.ctd b/alt-cannadic/gcanna.ctd
|
||
index b7af83a..2499a0f 100644
|
||
--- a/alt-cannadic/gcanna.ctd
|
||
+++ b/alt-cannadic/gcanna.ctd
|
||
@@ -54166,7 +54166,8 @@
|
||
しゅびがわ #T35*200 守備側
|
||
しゅびき #T30*80 朱引
|
||
しゅびじん #T35*200 守備陣
|
||
-しゅびたい #T17*200 守備的 #T35*200 守備隊
|
||
+しゅびたい #T35*200 守備隊
|
||
+しゅびてき #T17*200 守備的
|
||
しゅびはんい #T35*250 守備範囲
|
||
しゅびょう #T35*250 種苗
|
||
しゅびりょく #T35*200 守備力
|
||
--
|
||
2.28.0
|
||
|
||
From c5a26435be5bec2da2fe62f5ee0d6bce2758aa88 Mon Sep 17 00:00:00 2001
|
||
From: Shinji Tamura <stamura@kvj.biglobe.ne.jp>
|
||
Date: Fri, 22 Oct 2021 11:45:33 +0900
|
||
Subject: [PATCH 1/4] src-util: Convert ISO-2022-JP to UTF-8 in *.el
|
||
|
||
iconv -f ISO-2022-JP -o anthy-unicode.el anthy.el
|
||
|
||
BUG=rhbz#1998727
|
||
---
|
||
src-util/anthy-azik.el | 233 ------------------
|
||
src-util/anthy-conf.el | 122 ---------
|
||
src-util/anthy-kyuri.el | 210 ----------------
|
||
src-util/anthy-unicode-azik.el | 233 ++++++++++++++++++
|
||
src-util/anthy-unicode-conf.el | 122 +++++++++
|
||
.../{anthy-dic.el => anthy-unicode-dic.el} | 58 ++---
|
||
...hy-isearch.el => anthy-unicode-isearch.el} | 10 +-
|
||
src-util/anthy-unicode-kyuri.el | 210 ++++++++++++++++
|
||
src-util/{anthy.el => anthy-unicode.el} | 188 +++++++-------
|
||
9 files changed, 693 insertions(+), 693 deletions(-)
|
||
delete mode 100644 src-util/anthy-azik.el
|
||
delete mode 100644 src-util/anthy-conf.el
|
||
delete mode 100644 src-util/anthy-kyuri.el
|
||
create mode 100644 src-util/anthy-unicode-azik.el
|
||
create mode 100644 src-util/anthy-unicode-conf.el
|
||
rename src-util/{anthy-dic.el => anthy-unicode-dic.el} (59%)
|
||
rename src-util/{anthy-isearch.el => anthy-unicode-isearch.el} (91%)
|
||
create mode 100644 src-util/anthy-unicode-kyuri.el
|
||
rename src-util/{anthy.el => anthy-unicode.el} (82%)
|
||
|
||
diff --git a/src-util/anthy-azik.el b/src-util/anthy-azik.el
|
||
deleted file mode 100644
|
||
index 53e5d3e..0000000
|
||
--- a/src-util/anthy-azik.el
|
||
+++ /dev/null
|
||
@@ -1,233 +0,0 @@
|
||
-;; anthy-azik.el
|
||
-
|
||
-;; Copyright (C) 2004
|
||
-;; Author: Yutaka Hara<yhara@kmc.gr.jp>
|
||
-
|
||
-;; add following 2 lines to ~/.emacs
|
||
-;; (load-library "anthy-azik")
|
||
-;; (anthy-azik-mode)
|
||
-;;
|
||
-
|
||
-(defvar anthy-azik-mode-hiragana-map
|
||
- '(
|
||
- (";" . "$B$C(B") ("x;" . ";") ("b." . "$B$V(B") ("bd" . "$B$Y$s(B") ("bh" . "$B$V$&(B")
|
||
- ("bj" . "$B$V$s(B") ("bk" . "$B$S$s(B") ("bl" . "$B$\$s(B") ("bn" . "$B$P$s(B") ("bp" . "$B$\$&(B")
|
||
- ("bq" . "$B$P$$(B") ("br" . "$B$P$i(B") ("bt" . "$B$S$H(B") ("bw" . "$B$Y$$(B") ("bx" . "$B$Y$$(B")
|
||
- ("byd" . "$B$S$'$s(B") ("byh" . "$B$S$e$&(B") ("byj" . "$B$S$e$s(B") ("byl" . "$B$S$g$s(B") ("byn" . "$B$S$c$s(B")
|
||
- ("byp" . "$B$S$g$&(B") ("byq" . "$B$S$c$$(B") ("byw" . "$B$S$'$$(B") ("byz" . "$B$S$c$s(B") ("bz" . "$B$P$s(B")
|
||
- ("ca" . "$B$A$c(B") ("cc" . "$B$A$c(B") ("cd" . "$B$A$'$s(B") ("ce" . "$B$A$'(B") ("cf" . "$B$A$'(B")
|
||
- ("ch" . "$B$A$e$&(B") ("ci" . "$B$A(B") ("cj" . "$B$A$e$s(B") ("ck" . "$B$A$s(B") ("cl" . "$B$A$g$s(B")
|
||
- ("cn" . "$B$A$c$s(B") ("co" . "$B$A$g(B") ("cp" . "$B$A$g$&(B") ("cq" . "$B$A$c$$(B") ("cu" . "$B$A$e(B")
|
||
- ("cv" . "$B$A$c$$(B") ("cw" . "$B$A$'$$(B") ("cx" . "$B$A$'$$(B") ("cz" . "$B$A$c$s(B") ("dch" . "$B$G$e!<(B")
|
||
- ("dci" . "$B$G$#(B") ("dck" . "$B$G$#$s(B") ("dcp" . "$B$I$%!<(B") ("dcu" . "$B$G$e(B") ("dd" . "$B$G$s(B")
|
||
- ("df" . "$B$G(B") ("dg" . "$B$@$,(B") ("dh" . "$B$E$&(B") ("dj" . "$B$E$s(B") ("dk" . "$B$B$s(B")
|
||
- ("dl" . "$B$I$s(B") ("dm" . "$B$G$b(B") ("dn" . "$B$@$s(B") ("dp" . "$B$I$&(B") ("dq" . "$B$@$$(B")
|
||
- ("dr" . "$B$G$"$k(B") ("ds" . "$B$G$9(B") ("dt" . "$B$@$A(B") ("dv" . "$B$G$s(B") ("dw" . "$B$G$$(B")
|
||
- ("dy" . "$B$G$#(B") ("dz" . "$B$@$s(B") ("fd" . "$B$U$'$s(B") ("fh" . "$B$U$&(B") ("fj" . "$B$U$s(B")
|
||
- ("fk" . "$B$U$#$s(B") ("fl" . "$B$U$)$s(B") ("fm" . "$B$U$`(B") ("fn" . "$B$U$!$s(B") ("fp" . "$B$U$)!<(B")
|
||
- ("fq" . "$B$U$!$$(B") ("fr" . "$B$U$k(B") ("fs" . "$B$U$!$$(B") ("fw" . "$B$U$'$$(B") ("fz" . "$B$U$!$s(B")
|
||
- ("gd" . "$B$2$s(B") ("gh" . "$B$0$&(B") ("gj" . "$B$0$s(B") ("gk" . "$B$.$s(B") ("gl" . "$B$4$s(B")
|
||
- ("gn" . "$B$,$s(B") ("gp" . "$B$4$&(B") ("gq" . "$B$,$$(B") ("gr" . "$B$,$i(B") ("gt" . "$B$4$H(B")
|
||
- ("gw" . "$B$2$$(B") ("gyd" . "$B$.$'$s(B") ("gyh" . "$B$.$e$&(B") ("gyj" . "$B$.$e$s(B") ("gyl" . "$B$.$g$s(B")
|
||
- ("gyn" . "$B$.$c$s(B") ("gyp" . "$B$.$g$&(B") ("gyq" . "$B$.$c$$(B") ("gyw" . "$B$.$'$$(B") ("gyz" . "$B$.$c$s(B")
|
||
- ("gz" . "$B$,$s(B") ("hd" . "$B$X$s(B") ("hf" . "$B$U(B") ("hga" . "$B$R$c(B") ("hgd" . "$B$R$'$s(B")
|
||
- ("hge" . "$B$R$'(B") ("hgh" . "$B$R$e$&(B") ("hgj" . "$B$R$e$s(B") ("hgl" . "$B$R$g$s(B") ("hgn" . "$B$R$c$s(B")
|
||
- ("hgo" . "$B$R$g(B") ("hgp" . "$B$R$g$&(B") ("hgq" . "$B$R$c$$(B") ("hgu" . "$B$R$e(B") ("hgw" . "$B$R$'$$(B")
|
||
- ("hgz" . "$B$R$c$s(B") ("hh" . "$B$U$&(B") ("hj" . "$B$U$s(B") ("hk" . "$B$R$s(B") ("hl" . "$B$[$s(B")
|
||
- ("hn" . "$B$O$s(B") ("hp" . "$B$[$&(B") ("hq" . "$B$O$$(B") ("ht" . "$B$R$H(B") ("hw" . "$B$X$$(B")
|
||
- ("hyd" . "$B$R$'$s(B") ("hyh" . "$B$R$e$&(B") ("hyl" . "$B$R$g$s(B") ("hyp" . "$B$R$g$&(B") ("hyq" . "$B$R$c$$(B")
|
||
- ("hyw" . "$B$R$'$$(B") ("hyz" . "$B$R$c$s(B") ("hz" . "$B$O$s(B") ("jd" . "$B$8$'$s(B") ("jf" . "$B$8$e(B")
|
||
- ("jh" . "$B$8$e$&(B") ("jj" . "$B$8$e$s(B") ("jk" . "$B$8$s(B") ("jl" . "$B$8$g$s(B") ("jn" . "$B$8$c$s(B")
|
||
- ("jp" . "$B$8$g$&(B") ("jq" . "$B$8$c$$(B") ("jv" . "$B$8$e$&(B") ("jw" . "$B$8$'$$(B") ("jz" . "$B$8$c$s(B")
|
||
- ("kA" . "$B%u(B") ("kE" . "$B%v(B") ("kd" . "$B$1$s(B") ("kf" . "$B$-(B") ("kga" . "$B$-$c(B")
|
||
- ("kgd" . "$B$-$'$s(B") ("kge" . "$B$-$'(B") ("kgh" . "$B$-$e$&(B") ("kgl" . "$B$-$g$s(B") ("kgn" . "$B$-$c$s(B")
|
||
- ("kgo" . "$B$-$g(B") ("kgp" . "$B$-$g$&(B") ("kgq" . "$B$-$c$$(B") ("kgu" . "$B$-$e(B") ("kgw" . "$B$-$'$$(B")
|
||
- ("kgz" . "$B$-$c$s(B") ("kh" . "$B$/$&(B") ("kj" . "$B$/$s(B") ("kk" . "$B$-$s(B") ("kl" . "$B$3$s(B")
|
||
- ("km" . "$B$-(B") ("kn" . "$B$+$s(B") ("kp" . "$B$3$&(B") ("kq" . "$B$+$$(B") ("kr" . "$B$+$i(B")
|
||
- ("kt" . "$B$3$H(B") ("kv" . "$B$-$s(B") ("kw" . "$B$1$$(B") ("kyd" . "$B$-$'$s(B") ("kyh" . "$B$-$e$&(B")
|
||
- ("kyj" . "$B$-$e$s(B") ("kyl" . "$B$-$g$s(B") ("kyn" . "$B$-$c$s(B") ("kyp" . "$B$-$g$&(B") ("kyq" . "$B$-$c$$(B")
|
||
- ("kyw" . "$B$-$'$$(B") ("kyz" . "$B$-$c$s(B") ("kz" . "$B$+$s(B") ("m." . "$B$`(B") ("md" . "$B$a$s(B")
|
||
- ("mf" . "$B$`(B") ("mga" . "$B$_$c(B") ("mgd" . "$B$_$'$s(B") ("mge" . "$B$_$'(B") ("mgh" . "$B$_$e$&(B")
|
||
- ("mgj" . "$B$_$e$s(B") ("mgl" . "$B$_$g$s(B") ("mgn" . "$B$_$c$s(B") ("mgo" . "$B$_$g(B") ("mgp" . "$B$_$g$&(B")
|
||
- ("mgq" . "$B$_$c$$(B") ("mgu" . "$B$_$e(B") ("mgw" . "$B$_$'$$(B") ("mgz" . "$B$_$c$s(B") ("mh" . "$B$`$&(B")
|
||
- ("mj" . "$B$`$s(B") ("mk" . "$B$_$s(B") ("ml" . "$B$b$s(B") ("mn" . "$B$b$N(B") ("mp" . "$B$b$&(B")
|
||
- ("mq" . "$B$^$$(B") ("mr" . "$B$^$k(B") ("ms" . "$B$^$9(B") ("mt" . "$B$^$?(B") ("mv" . "$B$`$s(B")
|
||
- ("mw" . "$B$a$$(B") ("myd" . "$B$_$'$s(B") ("myh" . "$B$_$e$&(B") ("myj" . "$B$_$e$s(B") ("myl" . "$B$_$g$s(B")
|
||
- ("myn" . "$B$_$c$s(B") ("myp" . "$B$_$g$&(B") ("myq" . "$B$_$c$$(B") ("myw" . "$B$_$'$$(B") ("myz" . "$B$_$c$s(B")
|
||
- ("mz" . "$B$^$s(B") ("n." . "$B$L(B") ("nb" . "$B$M$P(B") ("nd" . "$B$M$s(B") ("nf" . "$B$L(B")
|
||
- ("nga" . "$B$K$c(B") ("ngd" . "$B$K$'$s(B") ("nge" . "$B$K$'(B") ("ngh" . "$B$K$e$&(B") ("ngj" . "$B$K$e$s(B")
|
||
- ("ngl" . "$B$K$g$s(B") ("ngn" . "$B$K$c$s(B") ("ngo" . "$B$K$g(B") ("ngp" . "$B$K$g$&(B") ("ngq" . "$B$K$c$$(B")
|
||
- ("ngu" . "$B$K$e(B") ("ngw" . "$B$K$'$$(B") ("ngz" . "$B$K$c$s(B") ("nh" . "$B$L$&(B") ("nj" . "$B$L$s(B")
|
||
- ("nk" . "$B$K$s(B") ("nl" . "$B$N$s(B") ("np" . "$B$N$&(B") ("nq" . "$B$J$$(B") ("nr" . "$B$J$k(B")
|
||
- ("nt" . "$B$K$A(B") ("nv" . "$B$L$s(B") ("nw" . "$B$M$$(B") ("nyd" . "$B$K$'$s(B") ("nyh" . "$B$K$e$&(B")
|
||
- ("nyj" . "$B$K$e$s(B") ("nyl" . "$B$K$g$s(B") ("nyn" . "$B$K$c$s(B") ("nyp" . "$B$K$g$&(B") ("nyq" . "$B$K$c$$(B")
|
||
- ("nyw" . "$B$K$'$$(B") ("nyz" . "$B$K$c$s(B") ("nz" . "$B$J$s(B") ("pd" . "$B$Z$s(B") ("pf" . "$B$]$s(B")
|
||
- ("pga" . "$B$T$c(B") ("pgd" . "$B$T$'$s(B") ("pge" . "$B$T$'(B") ("pgh" . "$B$T$e$&(B") ("pgj" . "$B$T$e$s(B")
|
||
- ("pgl" . "$B$T$g$s(B") ("pgn" . "$B$T$c$s(B") ("pgo" . "$B$T$g(B") ("pgp" . "$B$T$g$&(B") ("pgq" . "$B$T$c$$(B")
|
||
- ("pgu" . "$B$T$e(B") ("pgw" . "$B$T$'$$(B") ("pgz" . "$B$T$c$s(B") ("ph" . "$B$W$&(B") ("pj" . "$B$W$s(B")
|
||
- ("pk" . "$B$T$s(B") ("pl" . "$B$]$s(B") ("pn" . "$B$Q$s(B") ("pp" . "$B$]$&(B") ("pq" . "$B$Q$$(B")
|
||
- ("pv" . "$B$]$&(B") ("pw" . "$B$Z$$(B") ("pyd" . "$B$T$'$s(B") ("pyh" . "$B$T$e$&(B") ("pyj" . "$B$T$e$s(B")
|
||
- ("pyl" . "$B$T$g$s(B") ("pyn" . "$B$T$c$s(B") ("pyp" . "$B$T$g$&(B") ("pyq" . "$B$T$c$$(B") ("pyw" . "$B$T$'$$(B")
|
||
- ("pyz" . "$B$T$c$s(B") ("pz" . "$B$Q$s(B") ("q" . "$B$s(B") ("rd" . "$B$l$s(B") ("rh" . "$B$k$&(B")
|
||
- ("rj" . "$B$k$s(B") ("rk" . "$B$j$s(B") ("rl" . "$B$m$s(B") ("rn" . "$B$i$s(B") ("rp" . "$B$m$&(B")
|
||
- ("rq" . "$B$i$$(B") ("rr" . "$B$i$l(B") ("rw" . "$B$l$$(B") ("ryd" . "$B$j$'$s(B") ("ryh" . "$B$j$e$&(B")
|
||
- ("ryj" . "$B$j$e$s(B") ("ryk" . "$B$j$g$/(B") ("ryl" . "$B$j$g$s(B") ("ryn" . "$B$j$c$s(B") ("ryp" . "$B$j$g$&(B")
|
||
- ("ryq" . "$B$j$c$$(B") ("ryw" . "$B$j$'$$(B") ("ryz" . "$B$j$c$s(B") ("rz" . "$B$i$s(B") ("sd" . "$B$;$s(B")
|
||
- ("sf" . "$B$5$$(B") ("sh" . "$B$9$&(B") ("sj" . "$B$9$s(B") ("sk" . "$B$7$s(B") ("sl" . "$B$=$s(B")
|
||
- ("sm" . "$B$7$b(B") ("sn" . "$B$5$s(B") ("sp" . "$B$=$&(B") ("sq" . "$B$5$$(B") ("sr" . "$B$9$k(B")
|
||
- ("ss" . "$B$;$$(B") ("st" . "$B$7$?(B") ("sv" . "$B$5$$(B") ("sw" . "$B$;$$(B") ("syd" . "$B$7$'$s(B")
|
||
- ("syh" . "$B$7$e$&(B") ("syj" . "$B$7$e$s(B") ("syl" . "$B$7$g$s(B") ("syp" . "$B$7$g$&(B") ("syq" . "$B$7$c$$(B")
|
||
- ("syw" . "$B$7$'$$(B") ("syz" . "$B$7$c$s(B") ("sz" . "$B$5$s(B") ("tU" . "$B$C(B") ("tb" . "$B$?$S(B")
|
||
- ("td" . "$B$F$s(B") ("tgh" . "$B$F$e!<(B") ("tgi" . "$B$F$#(B") ("tgk" . "$B$F$#$s(B") ("tgp" . "$B$H$%!<(B")
|
||
- ("tgu" . "$B$F$e(B") ("th" . "$B$D$&(B") ("tj" . "$B$D$s(B") ("tk" . "$B$A$s(B") ("tl" . "$B$H$s(B")
|
||
- ("tm" . "$B$?$a(B") ("tn" . "$B$?$s(B") ("tp" . "$B$H$&(B") ("tq" . "$B$?$$(B") ("tr" . "$B$?$i(B")
|
||
- ("tsU" . "$B$C(B") ("tsa" . "$B$D$!(B") ("tse" . "$B$D$'(B") ("tsi" . "$B$D$#(B") ("tso" . "$B$D$)(B")
|
||
- ("tt" . "$B$?$A(B") ("tw" . "$B$F$$(B") ("tyd" . "$B$A$'$s(B") ("tyh" . "$B$A$e$&(B") ("tyj" . "$B$A$e$s(B")
|
||
- ("tyl" . "$B$A$g$s(B") ("tyn" . "$B$A$c$s(B") ("typ" . "$B$A$g$&(B") ("tyq" . "$B$A$c$$(B") ("tyw" . "$B$A$'$$(B")
|
||
- ("tyz" . "$B$A$c$s(B") ("tz" . "$B$?$s(B") ("vd" . "$B$&!+$'$s(B") ("vk" . "$B$&!+$#$s(B") ("vl" . "$B$&!+$)$s(B")
|
||
- ("vn" . "$B$&!+$!$s(B") ("vp" . "$B$&!+$)!<(B") ("vq" . "$B$&!+$!$$(B") ("vw" . "$B$&!+$'$$(B") ("vya" . "$B$&!+$c(B")
|
||
- ("vye" . "$B$&!+$'(B") ("vyo" . "$B$&!+$g(B") ("vyu" . "$B$&!+$e(B") ("vz" . "$B$&!+$!$s(B") ("wA" . "$B$n(B")
|
||
- ("wd" . "$B$&$'$s(B") ("wf" . "$B$o(B") ("wha" . "$B$&$!(B") ("whe" . "$B$&$'(B") ("whi" . "$B$&$#(B")
|
||
- ("who" . "$B$&$)(B") ("whu" . "$B$&(B") ("wk" . "$B$&$#$s(B") ("wl" . "$B$&$)$s(B") ("wn" . "$B$o$s(B")
|
||
- ("wp" . "$B$&$)!<(B") ("wq" . "$B$o$$(B") ("wr" . "$B$o$l(B") ("wso" . "$B$&$)(B") ("wt" . "$B$o$?(B")
|
||
- ("wz" . "$B$o$s(B") ("xa" . "$B$7$c(B") ("xc" . "$B$7$c(B") ("xd" . "$B$7$'$s(B") ("xe" . "$B$7$'(B")
|
||
- ("xf" . "$B$7$'$$(B") ("xh" . "$B$7$e$&(B") ("xi" . "$B$7(B") ("xj" . "$B$7$e$s(B") ("xk" . "$B$7$s(B")
|
||
- ("xl" . "$B$7$g$s(B") ("xn" . "$B$7$c$s(B") ("xo" . "$B$7$g(B") ("xp" . "$B$7$g$&(B") ("xq" . "$B$7$c$$(B")
|
||
- ("xt" . "$B$7$e$D(B") ("xu" . "$B$7$e(B") ("xv" . "$B$7$c$$(B") ("xw" . "$B$7$'$$(B") ("xxa" . "$B$!(B")
|
||
- ("xxe" . "$B$'(B") ("xxi" . "$B$#(B") ("xxo" . "$B$)(B") ("xxu" . "$B$%(B") ("xxh" . "$B"+(B")
|
||
- ("xxj" . "$B"-(B") ("xxk" . "$B",(B") ("xxl" . "$B"*(B") ("xz" . "$B$7$c$s(B") ("y<" . "$B"+(B")
|
||
- ("y>" . "$B"*(B") ("y^" . "$B",(B") ("yf" . "$B$f(B") ("yh" . "$B$f$&(B") ("yi" . "$B$p(B")
|
||
- ("yj" . "$B$f$s(B") ("yl" . "$B$h$s(B") ("yn" . "$B$d$s(B") ("yp" . "$B$h$&(B") ("yq" . "$B$d$$(B")
|
||
- ("yr" . "$B$h$k(B") ("yv" . "$B$f$&(B") ("yz" . "$B$d$s(B") ("z." . "$B$:(B") ("zc" . "$B$6(B")
|
||
- ("zd" . "$B$<$s(B") ("zf" . "$B$<(B") ("zh" . "$B$:$&(B") ("zj" . "$B$:$s(B") ("zk" . "$B$8$s(B")
|
||
- ("zl" . "$B$>$s(B") ("zn" . "$B$6$s(B") ("zp" . "$B$>$&(B") ("zq" . "$B$6$$(B") ("zr" . "$B$6$k(B")
|
||
- ("zv" . "$B$6$$(B") ("zw" . "$B$<$$(B") ("zx" . "$B$<$$(B") ("zyd" . "$B$8$'$s(B") ("zyh" . "$B$8$e$&(B")
|
||
- ("zyj" . "$B$8$e$s(B") ("zyl" . "$B$8$g$s(B") ("zyn" . "$B$8$c$s(B") ("zyp" . "$B$8$g$&(B") ("zyq" . "$B$8$c$$(B")
|
||
- ("zyw" . "$B$8$'$$(B") ("zyz" . "$B$8$c$s(B") ("zz" . "$B$6$s(B") ("bx" . "$B$S$g$&(B") ("bx" . "$B$S$g$&(B")
|
||
- ("dx" . "$B$B$g$&(B") ("gx" . "$B$.$g$&(B") ("hx" . "$B$R$g$&(B") ("kx" . "$B$-$g$&(B") ("mx" . "$B$_$g$&(B")
|
||
- ("nx" . "$B$K$g$&(B") ("px" . "$B$T$g$&(B") ("rx" . "$B$j$g$&(B") ("sx" . "$B$7$g$&(B") ("bv" . "$B$S$e$&(B")
|
||
- ("dv" . "$B$B$e$&(B") ("fv" . "$B$U$e!<(B") ("gv" . "$B$.$e$&(B") ("hv" . "$B$R$e$&(B") ("kv" . "$B$-$e$&(B")
|
||
- ("mv" . "$B$_$e$&(B") ("nv" . "$B$K$e$&(B") ("pv" . "$B$T$e$&(B") ("rv" . "$B$j$e$&(B") ("sv" . "$B$7$e$&(B")
|
||
- ("vv" . "$B$&!+$e!<(B")
|
||
- ))
|
||
-
|
||
-; (defvar anthy-azik-mode-katakana-map
|
||
-; '(
|
||
-; (";" . "$B%C(B") ("x;" . ";") ("b." . "$B%V(B") ("bd" . "$B%Y%s(B") ("bh" . "$B%V%&(B")
|
||
-; ("bj" . "$B%V%s(B") ("bk" . "$B%S%s(B") ("bl" . "$B%%(Bs") ("bn" . "$B%P%s(B") ("bp" . "$B%%(B&")
|
||
-; ("bq" . "$B%P%$(B") ("br" . "$B%P%i(B") ("bt" . "$B%S%H(B") ("bw" . "$B%Y%$(B") ("bx" . "$B%Y%$(B")
|
||
-; ("byd" . "$B%S%'%s(B") ("byh" . "$B%S%e%&(B") ("byj" . "$B%S%e%s(B") ("byl" . "$B%S%g%s(B") ("byn" . "$B%S%c%s(B")
|
||
-; ("byp" . "$B%S%g%&(B") ("byq" . "$B%S%c%$(B") ("byw" . "$B%S%'%$(B") ("byz" . "$B%S%c%s(B") ("bz" . "$B%P%s(B")
|
||
-; ("ca" . "$B%A%c(B") ("cc" . "$B%A%c(B") ("cd" . "$B%A%'%s(B") ("ce" . "$B%A%'(B") ("cf" . "$B%A%'(B")
|
||
-; ("ch" . "$B%A%e%&(B") ("ci" . "$B%A(B") ("cj" . "$B%A%e%s(B") ("ck" . "$B%A%s(B") ("cl" . "$B%A%g%s(B")
|
||
-; ("cn" . "$B%A%c%s(B") ("co" . "$B%A%g(B") ("cp" . "$B%A%g%&(B") ("cq" . "$B%A%c%$(B") ("cu" . "$B%A%e(B")
|
||
-; ("cv" . "$B%A%c%$(B") ("cw" . "$B%A%'%$(B") ("cx" . "$B%A%'%$(B") ("cz" . "$B%A%c%s(B") ("dch" . "$B%G%e!<(B")
|
||
-; ("dci" . "$B%G%#(B") ("dck" . "$B%G%#%s(B") ("dcp" . "$B%I%%!<(B") ("dcu" . "$B%G%e(B") ("dd" . "$B%G%s(B")
|
||
-; ("df" . "$B%G(B") ("dg" . "$B%@%,(B") ("dh" . "$B%E%&(B") ("dj" . "$B%E%s(B") ("dk" . "$B%B%s(B")
|
||
-; ("dl" . "$B%I%s(B") ("dm" . "$B%G%b(B") ("dn" . "$B%@%s(B") ("dp" . "$B%I%&(B") ("dq" . "$B%@%$(B")
|
||
-; ("dr" . "$B%G%"%k(B") ("ds" . "$B%G%9(B") ("dt" . "$B%@%A(B") ("dv" . "$B%G%s(B") ("dw" . "$B%G%$(B")
|
||
-; ("dy" . "$B%G%#(B") ("dz" . "$B%@%s(B") ("fd" . "$B%U%'%s(B") ("fh" . "$B%U%&(B") ("fj" . "$B%U%s(B")
|
||
-; ("fk" . "$B%U%#%s(B") ("fl" . "$B%U%)%s(B") ("fm" . "$B%U%`(B") ("fn" . "$B%U%!%s(B") ("fp" . "$B%U%)!<(B")
|
||
-; ("fq" . "$B%U%!%$(B") ("fr" . "$B%U%k(B") ("fs" . "$B%U%!%$(B") ("fw" . "$B%U%'%$(B") ("fz" . "$B%U%!%s(B")
|
||
-; ("gd" . "$B%2%s(B") ("gh" . "$B%0%&(B") ("gj" . "$B%0%s(B") ("gk" . "$B%.%s(B") ("gl" . "$B%4%s(B")
|
||
-; ("gn" . "$B%,%s(B") ("gp" . "$B%4%&(B") ("gq" . "$B%,%$(B") ("gr" . "$B%,%i(B") ("gt" . "$B%4%H(B")
|
||
-; ("gw" . "$B%2%$(B") ("gyd" . "$B%.%'%s(B") ("gyh" . "$B%.%e%&(B") ("gyj" . "$B%.%e%s(B") ("gyl" . "$B%.%g%s(B")
|
||
-; ("gyn" . "$B%.%c%s(B") ("gyp" . "$B%.%g%&(B") ("gyq" . "$B%.%c%$(B") ("gyw" . "$B%.%'%$(B") ("gyz" . "$B%.%c%s(B")
|
||
-; ("gz" . "$B%,%s(B") ("hd" . "$B%X%s(B") ("hf" . "$B%U(B") ("hga" . "$B%R%c(B") ("hgd" . "$B%R%'%s(B")
|
||
-; ("hge" . "$B%R%'(B") ("hgh" . "$B%R%e%&(B") ("hgj" . "$B%R%e%s(B") ("hgl" . "$B%R%g%s(B") ("hgn" . "$B%R%c%s(B")
|
||
-; ("hgo" . "$B%R%g(B") ("hgp" . "$B%R%g%&(B") ("hgq" . "$B%R%c%$(B") ("hgu" . "$B%R%e(B") ("hgw" . "$B%R%'%$(B")
|
||
-; ("hgz" . "$B%R%c%s(B") ("hh" . "$B%U%&(B") ("hj" . "$B%U%s(B") ("hk" . "$B%R%s(B") ("hl" . "$B%[%s(B")
|
||
-; ("hn" . "$B%O%s(B") ("hp" . "$B%[%&(B") ("hq" . "$B%O%$(B") ("ht" . "$B%R%H(B") ("hw" . "$B%X%$(B")
|
||
-; ("hyd" . "$B%R%'%s(B") ("hyh" . "$B%R%e%&(B") ("hyl" . "$B%R%g%s(B") ("hyp" . "$B%R%g%&(B") ("hyq" . "$B%R%c%$(B")
|
||
-; ("hyw" . "$B%R%'%$(B") ("hyz" . "$B%R%c%s(B") ("hz" . "$B%O%s(B") ("jd" . "$B%8%'%s(B") ("jf" . "$B%8%e(B")
|
||
-; ("jh" . "$B%8%e%&(B") ("jj" . "$B%8%e%s(B") ("jk" . "$B%8%s(B") ("jl" . "$B%8%g%s(B") ("jn" . "$B%8%c%s(B")
|
||
-; ("jp" . "$B%8%g%&(B") ("jq" . "$B%8%c%$(B") ("jv" . "$B%8%e%&(B") ("jw" . "$B%8%'%$(B") ("jz" . "$B%8%c%s(B")
|
||
-; ("kA" . "$B%u(B") ("kE" . "$B%v(B") ("kd" . "$B%1%s(B") ("kf" . "$B%-(B") ("kga" . "$B%-%c(B")
|
||
-; ("kgd" . "$B%-%'%s(B") ("kge" . "$B%-%'(B") ("kgh" . "$B%-%e%&(B") ("kgl" . "$B%-%g%s(B") ("kgn" . "$B%-%c%s(B")
|
||
-; ("kgo" . "$B%-%g(B") ("kgp" . "$B%-%g%&(B") ("kgq" . "$B%-%c%$(B") ("kgu" . "$B%-%e(B") ("kgw" . "$B%-%'%$(B")
|
||
-; ("kgz" . "$B%-%c%s(B") ("kh" . "$B%/%&(B") ("kj" . "$B%/%s(B") ("kk" . "$B%-%s(B") ("kl" . "$B%3%s(B")
|
||
-; ("km" . "$B%-(B") ("kn" . "$B%+%s(B") ("kp" . "$B%3%&(B") ("kq" . "$B%+%$(B") ("kr" . "$B%+%i(B")
|
||
-; ("kt" . "$B%3%H(B") ("kv" . "$B%-%s(B") ("kw" . "$B%1%$(B") ("kyd" . "$B%-%'%s(B") ("kyh" . "$B%-%e%&(B")
|
||
-; ("kyj" . "$B%-%e%s(B") ("kyl" . "$B%-%g%s(B") ("kyn" . "$B%-%c%s(B") ("kyp" . "$B%-%g%&(B") ("kyq" . "$B%-%c%$(B")
|
||
-; ("kyw" . "$B%-%'%$(B") ("kyz" . "$B%-%c%s(B") ("kz" . "$B%+%s(B") ("m." . "$B%`(B") ("md" . "$B%a%s(B")
|
||
-; ("mf" . "$B%`(B") ("mga" . "$B%_%c(B") ("mgd" . "$B%_%'%s(B") ("mge" . "$B%_%'(B") ("mgh" . "$B%_%e%&(B")
|
||
-; ("mgj" . "$B%_%e%s(B") ("mgl" . "$B%_%g%s(B") ("mgn" . "$B%_%c%s(B") ("mgo" . "$B%_%g(B") ("mgp" . "$B%_%g%&(B")
|
||
-; ("mgq" . "$B%_%c%$(B") ("mgu" . "$B%_%e(B") ("mgw" . "$B%_%'%$(B") ("mgz" . "$B%_%c%s(B") ("mh" . "$B%`%&(B")
|
||
-; ("mj" . "$B%`%s(B") ("mk" . "$B%_%s(B") ("ml" . "$B%b%s(B") ("mn" . "$B%b%N(B") ("mp" . "$B%b%&(B")
|
||
-; ("mq" . "$B%^%$(B") ("mr" . "$B%^%k(B") ("ms" . "$B%^%9(B") ("mt" . "$B%^%?(B") ("mv" . "$B%`%s(B")
|
||
-; ("mw" . "$B%a%$(B") ("myd" . "$B%_%'%s(B") ("myh" . "$B%_%e%&(B") ("myj" . "$B%_%e%s(B") ("myl" . "$B%_%g%s(B")
|
||
-; ("myn" . "$B%_%c%s(B") ("myp" . "$B%_%g%&(B") ("myq" . "$B%_%c%$(B") ("myw" . "$B%_%'%$(B") ("myz" . "$B%_%c%s(B")
|
||
-; ("mz" . "$B%^%s(B") ("n." . "$B%L(B") ("nb" . "$B%M%P(B") ("nd" . "$B%M%s(B") ("nf" . "$B%L(B")
|
||
-; ("nga" . "$B%K%c(B") ("ngd" . "$B%K%'%s(B") ("nge" . "$B%K%'(B") ("ngh" . "$B%K%e%&(B") ("ngj" . "$B%K%e%s(B")
|
||
-; ("ngl" . "$B%K%g%s(B") ("ngn" . "$B%K%c%s(B") ("ngo" . "$B%K%g(B") ("ngp" . "$B%K%g%&(B") ("ngq" . "$B%K%c%$(B")
|
||
-; ("ngu" . "$B%K%e(B") ("ngw" . "$B%K%'%$(B") ("ngz" . "$B%K%c%s(B") ("nh" . "$B%L%&(B") ("nj" . "$B%L%s(B")
|
||
-; ("nk" . "$B%K%s(B") ("nl" . "$B%N%s(B") ("np" . "$B%N%&(B") ("nq" . "$B%J%$(B") ("nr" . "$B%J%k(B")
|
||
-; ("nt" . "$B%K%A(B") ("nv" . "$B%L%s(B") ("nw" . "$B%M%$(B") ("nyd" . "$B%K%'%s(B") ("nyh" . "$B%K%e%&(B")
|
||
-; ("nyj" . "$B%K%e%s(B") ("nyl" . "$B%K%g%s(B") ("nyn" . "$B%K%c%s(B") ("nyp" . "$B%K%g%&(B") ("nyq" . "$B%K%c%$(B")
|
||
-; ("nyw" . "$B%K%'%$(B") ("nyz" . "$B%K%c%s(B") ("nz" . "$B%J%s(B") ("pd" . "$B%Z%s(B") ("pf" . "$B%]%s(B")
|
||
-; ("pga" . "$B%T%c(B") ("pgd" . "$B%T%'%s(B") ("pge" . "$B%T%'(B") ("pgh" . "$B%T%e%&(B") ("pgj" . "$B%T%e%s(B")
|
||
-; ("pgl" . "$B%T%g%s(B") ("pgn" . "$B%T%c%s(B") ("pgo" . "$B%T%g(B") ("pgp" . "$B%T%g%&(B") ("pgq" . "$B%T%c%$(B")
|
||
-; ("pgu" . "$B%T%e(B") ("pgw" . "$B%T%'%$(B") ("pgz" . "$B%T%c%s(B") ("ph" . "$B%W%&(B") ("pj" . "$B%W%s(B")
|
||
-; ("pk" . "$B%T%s(B") ("pl" . "$B%]%s(B") ("pn" . "$B%Q%s(B") ("pp" . "$B%]%&(B") ("pq" . "$B%Q%$(B")
|
||
-; ("pv" . "$B%]%&(B") ("pw" . "$B%Z%$(B") ("pyd" . "$B%T%'%s(B") ("pyh" . "$B%T%e%&(B") ("pyj" . "$B%T%e%s(B")
|
||
-; ("pyl" . "$B%T%g%s(B") ("pyn" . "$B%T%c%s(B") ("pyp" . "$B%T%g%&(B") ("pyq" . "$B%T%c%$(B") ("pyw" . "$B%T%'%$(B")
|
||
-; ("pyz" . "$B%T%c%s(B") ("pz" . "$B%Q%s(B") ("q" . "$B%s(B") ("rd" . "$B%l%s(B") ("rh" . "$B%k%&(B")
|
||
-; ("rj" . "$B%k%s(B") ("rk" . "$B%j%s(B") ("rl" . "$B%m%s(B") ("rn" . "$B%i%s(B") ("rp" . "$B%m%&(B")
|
||
-; ("rq" . "$B%i%$(B") ("rr" . "$B%i%l(B") ("rw" . "$B%l%$(B") ("ryd" . "$B%j%'%s(B") ("ryh" . "$B%j%e%&(B")
|
||
-; ("ryj" . "$B%j%e%s(B") ("ryk" . "$B%j%g%/(B") ("ryl" . "$B%j%g%s(B") ("ryn" . "$B%j%c%s(B") ("ryp" . "$B%j%g%&(B")
|
||
-; ("ryq" . "$B%j%c%$(B") ("ryw" . "$B%j%'%$(B") ("ryz" . "$B%j%c%s(B") ("rz" . "$B%i%s(B") ("sd" . "$B%;%s(B")
|
||
-; ("sf" . "$B%5%$(B") ("sh" . "$B%9%&(B") ("sj" . "$B%9%s(B") ("sk" . "$B%7%s(B") ("sl" . "$B%=%s(B")
|
||
-; ("sm" . "$B%7%b(B") ("sn" . "$B%5%s(B") ("sp" . "$B%=%&(B") ("sq" . "$B%5%$(B") ("sr" . "$B%9%k(B")
|
||
-; ("ss" . "$B%;%$(B") ("st" . "$B%7%?(B") ("sv" . "$B%5%$(B") ("sw" . "$B%;%$(B") ("syd" . "$B%7%'%s(B")
|
||
-; ("syh" . "$B%7%e%&(B") ("syj" . "$B%7%e%s(B") ("syl" . "$B%7%g%s(B") ("syp" . "$B%7%g%&(B") ("syq" . "$B%7%c%$(B")
|
||
-; ("syw" . "$B%7%'%$(B") ("syz" . "$B%7%c%s(B") ("sz" . "$B%5%s(B") ("tU" . "$B%C(B") ("tb" . "$B%?%S(B")
|
||
-; ("td" . "$B%F%s(B") ("tgh" . "$B%F%e!<(B") ("tgi" . "$B%F%#(B") ("tgk" . "$B%F%#%s(B") ("tgp" . "$B%H%%!<(B")
|
||
-; ("tgu" . "$B%F%e(B") ("th" . "$B%D%&(B") ("tj" . "$B%D%s(B") ("tk" . "$B%A%s(B") ("tl" . "$B%H%s(B")
|
||
-; ("tm" . "$B%?%a(B") ("tn" . "$B%?%s(B") ("tp" . "$B%H%&(B") ("tq" . "$B%?%$(B") ("tr" . "$B%?%i(B")
|
||
-; ("tsU" . "$B%C(B") ("tsa" . "$B%D%!(B") ("tse" . "$B%D%'(B") ("tsi" . "$B%D%#(B") ("tso" . "$B%D%)(B")
|
||
-; ("tt" . "$B%?%A(B") ("tw" . "$B%F%$(B") ("tyd" . "$B%A%'%s(B") ("tyh" . "$B%A%e%&(B") ("tyj" . "$B%A%e%s(B")
|
||
-; ("tyl" . "$B%A%g%s(B") ("tyn" . "$B%A%c%s(B") ("typ" . "$B%A%g%&(B") ("tyq" . "$B%A%c%$(B") ("tyw" . "$B%A%'%$(B")
|
||
-; ("tyz" . "$B%A%c%s(B") ("tz" . "$B%?%s(B") ("vd" . "$B%t%'%s(B") ("vk" . "$B%t%#%s(B") ("vl" . "$B%t%)%s(B")
|
||
-; ("vn" . "$B%t%!%s(B") ("vp" . "$B%t%)!<(B") ("vq" . "$B%t%!%$(B") ("vw" . "$B%t%'%$(B") ("vya" . "$B%t%c(B")
|
||
-; ("vye" . "$B%t%'(B") ("vyo" . "$B%t%g(B") ("vyu" . "$B%t%e(B") ("vz" . "$B%t%!%s(B") ("wA" . "$B%n(B")
|
||
-; ("wd" . "$B%&%'%s(B") ("wf" . "$B%o(B") ("wha" . "$B%&%!(B") ("whe" . "$B%&%'(B") ("whi" . "$B%&%#(B")
|
||
-; ("who" . "$B%&%)(B") ("whu" . "$B%&(B") ("wk" . "$B%&%#%s(B") ("wl" . "$B%&%)%s(B") ("wn" . "$B%o%s(B")
|
||
-; ("wp" . "$B%&%)!<(B") ("wq" . "$B%o%$(B") ("wr" . "$B%o%l(B") ("wso" . "$B%&%)(B") ("wt" . "$B%o%?(B")
|
||
-; ("wz" . "$B%o%s(B") ("xa" . "$B%7%c(B") ("xc" . "$B%7%c(B") ("xd" . "$B%7%'%s(B") ("xe" . "$B%7%'(B")
|
||
-; ("xf" . "$B%7%'%$(B") ("xh" . "$B%7%e%&(B") ("xi" . "$B%7(B") ("xj" . "$B%7%e%s(B") ("xk" . "$B%7%s(B")
|
||
-; ("xl" . "$B%7%g%s(B") ("xn" . "$B%7%c%s(B") ("xo" . "$B%7%g(B") ("xp" . "$B%7%g%&(B") ("xq" . "$B%7%c%$(B")
|
||
-; ("xt" . "$B%7%e%D(B") ("xu" . "$B%7%e(B") ("xv" . "$B%7%c%$(B") ("xw" . "$B%7%'%$(B") ("xxa" . "$B%!(B")
|
||
-; ("xxe" . "$B%'(B") ("xxi" . "$B%#(B") ("xxo" . "$B%)(B") ("xxu" . "$B%%(B") ("xxh" . "$B"+(B")
|
||
-; ("xxj" . "$B"-(B") ("xxk" . "$B",(B") ("xxl" . "$B"*(B") ("xz" . "$B%7%c%s(B") ("y<" . "$B"+(B")
|
||
-; ("y>" . "$B"*(B") ("y^" . "$B",(B") ("yf" . "$B%f(B") ("yh" . "$B%f%&(B") ("yi" . "$B%p(B")
|
||
-; ("yj" . "$B%f%s(B") ("yl" . "$B%h%s(B") ("yn" . "$B%d%s(B") ("yp" . "$B%h%&(B") ("yq" . "$B%d%$(B")
|
||
-; ("yr" . "$B%h%k(B") ("yv" . "$B%f%&(B") ("yz" . "$B%d%s(B") ("z." . "$B%:(B") ("zc" . "$B%6(B")
|
||
-; ("zd" . "$B%<%s(B") ("zf" . "$B%<(B") ("zh" . "$B%:%&(B") ("zj" . "$B%:%s(B") ("zk" . "$B%8%s(B")
|
||
-; ("zl" . "$B%>%s(B") ("zn" . "$B%6%s(B") ("zp" . "$B%>%&(B") ("zq" . "$B%6%$(B") ("zr" . "$B%6%k(B")
|
||
-; ("zv" . "$B%6%$(B") ("zw" . "$B%<%$(B") ("zx" . "$B%<%$(B") ("zyd" . "$B%8%'%s(B") ("zyh" . "$B%8%e%&(B")
|
||
-; ("zyj" . "$B%8%e%s(B") ("zyl" . "$B%8%g%s(B") ("zyn" . "$B%8%c%s(B") ("zyp" . "$B%8%g%&(B") ("zyq" . "$B%8%c%$(B")
|
||
-; ("zyw" . "$B%8%'%$(B") ("zyz" . "$B%8%c%s(B") ("zz" . "$B%6%s(B") ("bx" . "$B%S%g%&(B") ("bx" . "$B%S%g%&(B")
|
||
-; ("dx" . "$B%B%g%&(B") ("gx" . "$B%.%g%&(B") ("hx" . "$B%R%g%&(B") ("kx" . "$B%-%g%&(B") ("mx" . "$B%_%g%&(B")
|
||
-; ("nx" . "$B%K%g%&(B") ("px" . "$B%T%g%&(B") ("rx" . "$B%j%g%&(B") ("sx" . "$B%7%g%&(B") ("bv" . "$B%S%e%&(B")
|
||
-; ("dv" . "$B%B%e%&(B") ("fv" . "$B%U%e!<(B") ("gv" . "$B%.%e%&(B") ("hv" . "$B%R%e%&(B") ("kv" . "$B%-%e%&(B")
|
||
-; ("mv" . "$B%_%e%&(B") ("nv" . "$B%K%e%&(B") ("pv" . "$B%T%e%&(B") ("rv" . "$B%j%e%&(B") ("sv" . "$B%7%e%&(B")
|
||
-; ("vv" . "$B%&!+%e!<(B")
|
||
-; ))
|
||
-
|
||
-(defun anthy-azik-mode ()
|
||
- (interactive)
|
||
- (setq anthy-rkmap-keybind
|
||
- '(
|
||
- ;; \C-p
|
||
- (("hiragana" . 16) . "katakana")
|
||
- (("katakana" . 16) . "hiragana")))
|
||
-; (define-key anthy-mode-map (char-to-string 16) 'anthy-insert)
|
||
- (anthy-send-change-toggle-command "!")
|
||
- (mapcar (lambda (x)
|
||
- (anthy-change-hiragana-map (car x) (cdr x)))
|
||
- anthy-azik-mode-hiragana-map)
|
||
- (anthy-hiragana-map))
|
||
-; (mapcar (lambda (x)
|
||
-; (anthy-change-katakana-map (car x) (cdr x)))
|
||
-; anthy-azik-mode-katakana-map)
|
||
-
|
||
diff --git a/src-util/anthy-conf.el b/src-util/anthy-conf.el
|
||
deleted file mode 100644
|
||
index 3d6fbf7..0000000
|
||
--- a/src-util/anthy-conf.el
|
||
+++ /dev/null
|
||
@@ -1,122 +0,0 @@
|
||
-;; anthy-conf.el -- Anthy
|
||
-
|
||
-
|
||
-;; Copyright (C) 2002
|
||
-;; Author: Yusuke Tabata<yusuke@kmc.gr.jp>
|
||
-
|
||
-;; This file is part of Anthy
|
||
-
|
||
-;;; Commentary:
|
||
-;;
|
||
-
|
||
-(defvar anthy-alt-char-map
|
||
- '(("," "$B!$(B")
|
||
- ("." "$B!%(B")))
|
||
-
|
||
-(defvar anthy-kana-mode-hiragana-map
|
||
- '(
|
||
- ("3" . "$B$"(B") ("e" . "$B$$(B") ("4" . "$B$&(B") ("5" . "$B$((B") ("6" . "$B$*(B")
|
||
- ("#" . "$B$!(B") ("E" . "$B$#(B") ("$" . "$B$%(B") ("%" . "$B$'(B") ("&" . "$B$)(B")
|
||
- ("t" . "$B$+(B") ("g" . "$B$-(B") ("h" . "$B$/(B") (":" . "$B$1(B") ("b" . "$B$3(B")
|
||
- ("t@" . "$B$,(B") ("g@" . "$B$.(B") ("h@" . "$B$0(B") (":@" . "$B$2(B") ("b@" . "$B$4(B")
|
||
- ("x" . "$B$5(B") ("d" . "$B$7(B") ("r" . "$B$9(B") ("p" . "$B$;(B") ("c" . "$B$=(B")
|
||
- ("x@" . "$B$6(B") ("d@" . "$B$8(B") ("r@" . "$B$:(B") ("p@" . "$B$<(B") ("c@" . "$B$>(B")
|
||
- ("q" . "$B$?(B") ("a" . "$B$A(B") ("z" . "$B$D(B") ("w" . "$B$F(B") ("s" . "$B$H(B")
|
||
- ("q@" . "$B$@(B") ("a@" . "$B$B(B") ("z@" . "$B$E(B") ("w@" . "$B$G(B") ("s@" . "$B$I(B")
|
||
- ("u" . "$B$J(B") ("i" . "$B$K(B") ("1" . "$B$L(B") ("," . "$B$M(B") ("k" . "$B$N(B")
|
||
- ("f" . "$B$O(B") ("v" . "$B$R(B") ("2" . "$B$U(B") ("^" . "$B$X(B") ("-" . "$B$[(B")
|
||
- ("f@" . "$B$P(B") ("v@" . "$B$S(B") ("2@" . "$B$V(B") ("^@" . "$B$Y(B") ("-@" . "$B$\(B")
|
||
- ("f[" . "$B$Q(B") ("v[" . "$B$T(B") ("2[" . "$B$W(B") ("^[" . "$B$Z(B") ("-[" . "$B$](B")
|
||
- ("j" . "$B$^(B") ("n" . "$B$_(B") ("]" . "$B$`(B") ("/" . "$B$a(B") ("m" . "$B$b(B")
|
||
- ("7" . "$B$d(B") ("8" . "$B$f(B") ("9" . "$B$h(B")
|
||
- ("'" . "$B$c(B") ("(" . "$B$e(B") (")" . "$B$g(B")
|
||
- ("o" . "$B$i(B") ("l" . "$B$j(B") ("." . "$B$k(B") (";" . "$B$l(B") ("\\" . "$B$m(B")
|
||
- ("0" . "$B$o(B") ("~" . "$B$r(B")
|
||
-
|
||
- ;; $B:$$C$?$3$H$K(B $B%P%C%/%9%i%C%7%e$H1_$r6hJL$9$kJ}K!$,$o$+$i$J$$(B
|
||
- ("|" . "$B!<(B") ("_" . "$B!<(B") ("<" . "$B!"(B") (">" . "$B!#(B")
|
||
- ("Z" . "$B$C(B") ("y" . "$B$s(B")
|
||
- ))
|
||
-
|
||
-(defvar anthy-kana-mode-katakana-map
|
||
- '(
|
||
- ("3" . "$B%"(B") ("e" . "$B%$(B") ("4" . "$B%&(B") ("5" . "$B%((B") ("6" . "$B%*(B")
|
||
- ("#" . "$B%!(B") ("E" . "$B%#(B") ("$" . "$B%%(B") ("%" . "$B%'(B") ("&" . "$B%)(B")
|
||
- ("t" . "$B%+(B") ("g" . "$B%-(B") ("h" . "$B%/(B") (":" . "$B%1(B") ("b" . "$B%3(B")
|
||
- ("t@" . "$B%,(B") ("g@" . "$B%.(B") ("h@" . "$B%0(B") (":@" . "$B%2(B") ("b@" . "$B%4(B")
|
||
- ("x" . "$B%5(B") ("d" . "$B%7(B") ("r" . "$B%9(B") ("p" . "$B%;(B") ("c" . "$B%=(B")
|
||
- ("x@" . "$B%6(B") ("d@" . "$B%8(B") ("r@" . "$B%:(B") ("p@" . "$B%<(B") ("c@" . "$B%>(B")
|
||
- ("q" . "$B%?(B") ("a" . "$B%A(B") ("z" . "$B%D(B") ("w" . "$B%F(B") ("s" . "$B%H(B")
|
||
- ("q@" . "$B%@(B") ("a@" . "$B%B(B") ("z@" . "$B%E(B") ("w@" . "$B%G(B") ("s@" . "$B%I(B")
|
||
- ("u" . "$B%J(B") ("i" . "$B%K(B") ("1" . "$B%L(B") ("," . "$B%M(B") ("k" . "$B%N(B")
|
||
- ("f" . "$B%O(B") ("v" . "$B%R(B") ("2" . "$B%U(B") ("^" . "$B%X(B") ("-" . "$B%[(B")
|
||
- ("f@" . "$B%P(B") ("v@" . "$B%S(B") ("2@" . "$B%V(B") ("^@" . "$B%Y(B") ("-@" . "$B%\(B")
|
||
- ("f[" . "$B%Q(B") ("v[" . "$B%T(B") ("2[" . "$B%W(B") ("^[" . "$B%Z(B") ("-[" . "$B%](B")
|
||
- ("j" . "$B%^(B") ("n" . "$B%_(B") ("]" . "$B%`(B") ("/" . "$B%a(B") ("m" . "$B%b(B")
|
||
- ("7" . "$B%d(B") ("8" . "$B%f(B") ("9" . "$B%h(B")
|
||
- ("'" . "$B%c(B") ("(" . "$B%e(B") (")" . "$B%g(B")
|
||
- ("o" . "$B%i(B") ("l" . "$B%j(B") ("." . "$B%k(B") (";" . "$B%l(B") ("\\" . "$B%m(B")
|
||
- ("0" . "$B%o(B") ("~" . "$B%r(B")
|
||
-
|
||
- ;; $B:$$C$?$3$H$K(B $B%P%C%/%9%i%C%7%e$H1_$r6hJL$9$kJ}K!$,$o$+$i$J$$(B
|
||
- ("|" . "$B!<(B") ("_" . "$B!<(B") ("<" . "$B!"(B") (">" . "$B!#(B")
|
||
- ("Z" . "$B%C(B") ("y" . "$B%s(B")
|
||
- ))
|
||
-
|
||
-;;
|
||
-;; map$B$NJQ99(B
|
||
-;;
|
||
-(defun anthy-send-map-edit-command (mapno key str)
|
||
- (if (not (stringp key))
|
||
- (setq key (char-to-string key)))
|
||
- (if (not (stringp str))
|
||
- (setq str (char-to-string str)))
|
||
- (anthy-send-recv-command
|
||
- (concat " MAP_EDIT " (int-to-string mapno)
|
||
- " " key " " str "\n")))
|
||
-(defun anthy-change-hiragana-map (key str)
|
||
- (anthy-send-map-edit-command 2 key str))
|
||
-(defun anthy-change-katakana-map (key str)
|
||
- (anthy-send-map-edit-command 3 key str))
|
||
-(defun anthy-load-hiragana-map (map)
|
||
- (mapcar (lambda (x)
|
||
- (let ((key (car x))
|
||
- (str (cadr x)))
|
||
- (anthy-change-hiragana-map key str))) map))
|
||
-(defun anthy-clear-map ()
|
||
- (anthy-send-recv-command
|
||
- " MAP_CLEAR 0\n"))
|
||
-;;
|
||
-;; toggle$B$NJQ99(B
|
||
-;;
|
||
-(defun anthy-send-change-toggle-command (str)
|
||
- (anthy-send-recv-command
|
||
- (concat " CHANGE_TOGGLE " str "\n")))
|
||
-
|
||
-;; should disable toggle
|
||
-;; ($B%m!<%^;z$G$O$J$/$F(B)$B$+$J%b!<%I$K$9$k(B
|
||
-(defun anthy-kana-map-mode ()
|
||
- (setq anthy-rkmap-keybind
|
||
- '(
|
||
- ;; \C-p
|
||
- (("hiragana" . 16) . "katakana")
|
||
- (("katakana" . 16) . "hiragana")))
|
||
- (define-key anthy-mode-map (char-to-string 16) 'anthy-insert)
|
||
- (anthy-send-recv-command " SET_PREEDIT_MODE 1\n")
|
||
- (anthy-send-change-toggle-command "!")
|
||
- (anthy-clear-map)
|
||
- (mapcar (lambda (x)
|
||
- (anthy-change-hiragana-map (car x) (cdr x)))
|
||
- anthy-kana-mode-hiragana-map)
|
||
- (mapcar (lambda (x)
|
||
- (anthy-change-katakana-map (car x) (cdr x)))
|
||
- anthy-kana-mode-katakana-map))
|
||
-;;
|
||
-(defun anthy-set-break-into-roman (flag)
|
||
- "$BFI$_$rF~NOCf$K%P%C%/%9%Z!<%9$rBG$D$H%m!<%^;z$^$G%P%i%P%i$K$9$k(B"
|
||
- (anthy-send-recv-command
|
||
- (if flag
|
||
- " BREAK_INTO_ROMAN 1\n"
|
||
- " BREAK_INTO_ROMAN 0\n")))
|
||
-
|
||
-(provide 'anthy-conf)
|
||
diff --git a/src-util/anthy-kyuri.el b/src-util/anthy-kyuri.el
|
||
deleted file mode 100644
|
||
index ddbcbd8..0000000
|
||
--- a/src-util/anthy-kyuri.el
|
||
+++ /dev/null
|
||
@@ -1,210 +0,0 @@
|
||
-;; anthy-kyuri.el
|
||
-
|
||
-;; Copyright (C) 2005
|
||
-;; Author: Yukihiro Matsumoto <matz@ruby-lang.org>
|
||
-
|
||
-(require 'anthy)
|
||
-
|
||
-(setq anthy-kyuri-mode-hiragana-map
|
||
- '(
|
||
- ("bh" . "$B$!(B") ("h" . "$B$"(B") ("bk" . "$B$#(B") ("k" . "$B$$(B") ("bj" . "$B$%(B")
|
||
- ("j" . "$B$&(B") ("yj" . "$B$&!+(B") ("yh" . "$B$&!+$!(B") ("yk" . "$B$&!+$#(B") ("y;" . "$B$&!+$'(B")
|
||
- ("yl" . "$B$&!+$)(B") ("b;" . "$B$'(B") (";" . "$B$((B") ("bl" . "$B$)(B") ("l" . "$B$*(B")
|
||
- ("dh" . "$B$+(B") ("qh" . "$B$,(B") ("dk" . "$B$-(B") ("du" . "$B$-$c(B") ("di" . "$B$-$e(B") ("do" . "$B$-$g(B")
|
||
- ("duu" . "$B$-$c$"(B") ("dii" . "$B$-$e$&(B") ("doo" . "$B$-$g$&(B")
|
||
- ("qk" . "$B$.(B") ("qu" . "$B$.$c(B") ("qi" . "$B$.$e(B") ("qo" . "$B$.$g(B")
|
||
- ("quu" . "$B$.$c$"(B") ("qii" . "$B$.$e$&(B") ("qoo" . "$B$.$g$&(B")
|
||
- ("dj" . "$B$/(B") ("qj" . "$B$0(B") ("d;" . "$B$1(B") ("q;" . "$B$2(B") ("dl" . "$B$3(B") ("ql" . "$B$4(B")
|
||
- ("fh" . "$B$5(B") ("zh" . "$B$6(B") ("fk" . "$B$7(B")
|
||
- ("fu" . "$B$7$c(B") ("fi" . "$B$7$e(B") ("fo" . "$B$7$g(B") ("fb;" . "$B$7$'(B")
|
||
- ("fuu" . "$B$7$c$"(B") ("fii" . "$B$7$e$&(B") ("foo" . "$B$7$g$&(B")
|
||
- ("zk" . "$B$8(B") ("zu" . "$B$8$c(B") ("zi" . "$B$8$e(B") ("zo" . "$B$8$g(B")
|
||
- ("zuu" . "$B$8$c$"(B") ("zii" . "$B$8$e$&(B") ("zoo" . "$B$8$g$&(B")
|
||
- ("fj" . "$B$9(B") ("zj" . "$B$:(B") ("f;" . "$B$;(B") ("z;" . "$B$<(B") ("fl" . "$B$=(B") ("zl" . "$B$>(B")
|
||
- ("gh" . "$B$?(B") ("vh" . "$B$@(B") ("gk" . "$B$A(B")
|
||
- ("gu" . "$B$A$c(B") ("gi" . "$B$A$e(B") ("go" . "$B$A$g(B") ("gb;" . "$B$A$'(B")
|
||
- ("guu" . "$B$A$c$"(B") ("gii" . "$B$A$e$&(B") ("goo" . "$B$A$g$&(B")
|
||
- ("vk" . "$B$B(B") ("vu" . "$B$B$c(B") ("vi" . "$B$B$e(B") ("vo" . "$B$B$g(B") ("vb;" . "$B$B$'(B")
|
||
- ("vuu" . "$B$B$c$"(B") ("vii" . "$B$B$e$&(B")
|
||
- ("voo" . "$B$B$g$&(B") ("m" . "$B$C(B") ("ddh" . "$B$C$+(B") ("qqh" . "$B$C$,(B") ("ddk" . "$B$C$-(B")
|
||
- ("ddu" . "$B$C$-$c(B") ("ddi" . "$B$C$-$e(B") ("ddo" . "$B$C$-$g(B")
|
||
- ("dduu" . "$B$C$-$c$"(B") ("ddii" . "$B$C$-$e$&(B") ("ddoo" . "$B$C$-$g$&(B")
|
||
- ("qqk" . "$B$C$.(B") ("qqu" . "$B$C$.$c(B") ("qqi" . "$B$C$.$e(B") ("qqo" . "$B$C$.$g(B")
|
||
- ("qquu" . "$B$C$.$c$"(B") ("qqii" . "$B$C$.$e$&(B") ("qqoo" . "$B$C$.$g$&(B")
|
||
- ("ddj" . "$B$C$/(B") ("dd;" . "$B$C$1(B") ("ddl" . "$B$C$3(B")
|
||
- ("qqj" . "$B$C$0(B") ("qq;" . "$B$C$2(B") ("qql" . "$B$C$4(B")
|
||
- ("ffh" . "$B$C$5(B") ("zzh" . "$B$C$6(B") ("ffk" . "$B$C$7(B")
|
||
- ("ffu" . "$B$C$7$c(B") ("ffi" . "$B$C$7$e(B") ("ffo" . "$B$C$7$g(B")
|
||
- ("ffuu" . "$B$C$7$c$"(B") ("ffii" . "$B$C$7$e$&(B") ("ffoo" . "$B$C$7$g$&(B")
|
||
- ("zzk" . "$B$C$8(B")
|
||
- ("zzu" . "$B$C$8$c(B") ("zzi" . "$B$C$8$e(B") ("zzo" . "$B$C$8$g(B")
|
||
- ("zzuu" . "$B$C$8$c$"(B") ("zzii" . "$B$C$8$e$&(B") ("zzoo" . "$B$C$8$g$&(B")
|
||
- ("ffj" . "$B$C$9(B") ("zzj" . "$B$C$:(B") ("ff;" . "$B$C$;(B") ("zz;" . "$B$C$<(B") ("ffl" . "$B$C$=(B")
|
||
- ("zzl" . "$B$C$>(B") ("ggh" . "$B$C$?(B") ("vvh" . "$B$C$@(B") ("ggk" . "$B$C$A(B")
|
||
- ("ggu" . "$B$C$A$c(B") ("ggi" . "$B$C$A$e(B") ("ggo" . "$B$C$A$g(B") ("ggb;" . "$B$C$A$'(B")
|
||
- ("gguu" . "$B$C$A$c$"(B") ("ggii" . "$B$C$A$e$&(B") ("ggoo" . "$B$C$A$g$&(B")
|
||
- ("vvk" . "$B$C$B(B")
|
||
- ("vvu" . "$B$C$B$c(B") ("vvi" . "$B$C$B$e(B") ("vvoo" . "$B$C$B$g(B")
|
||
- ("vvuu" . "$B$C$B$c$"(B") ("vvii" . "$B$C$B$e$&(B") ("vvoo" . "$B$C$B$g$&(B")
|
||
- ("ggj" . "$B$C$D(B") ("gg;" . "$B$C$F(B") ("ggl" . "$B$C$H(B")
|
||
- ("vvj" . "$B$C$E(B") ("vv;" . "$B$C$G(B") ("vvl" . "$B$C$I(B")
|
||
- ("ssh" . "$B$C$O(B") ("cch" . "$B$C$P(B") ("tth" . "$B$C$Q(B")
|
||
- ("ttk" . "$B$C$R(B")
|
||
- ("ssu" . "$B$C$R$c(B") ("ssi" . "$B$C$R$e(B") ("sso" . "$B$C$R$g(B")
|
||
- ("ssuu" . "$B$C$R$c$"(B") ("ssii" . "$B$C$R$e$&(B") ("ssoo" . "$B$C$R$g$&(B")
|
||
- ("cck" . "$B$C$S(B")
|
||
- ("ccu" . "$B$C$S$c(B") ("ccii" . "$B$C$S$e(B") ("cco" . "$B$C$S$g(B")
|
||
- ("ccuu" . "$B$C$S$c$"(B") ("ccii" . "$B$C$S$e$&(B") ("ccoo" . "$B$C$S$g$&(B")
|
||
- ("ttk" . "$B$C$T(B")
|
||
- ("ttu" . "$B$C$T$c(B") ("tti" . "$B$C$T$e(B") ("tto" . "$B$C$T$g(B")
|
||
- ("ttuu" . "$B$C$T$c$"(B") ("ttii" . "$B$C$T$e$&(B") ("ttoo" . "$B$C$T$g$&(B")
|
||
- ("ssj" . "$B$C$U(B")
|
||
- ("ssbh" . "$B$C$U$!(B") ("ssbk" . "$B$C$U$#(B") ("ssb;" . "$B$C$U$'(B") ("ssbl" . "$B$C$U$)(B")
|
||
- ("ccj" . "$B$C$V(B") ("ttj" . "$B$C$W(B") ("ss;" . "$B$C$X(B") ("cc;" . "$B$C$Y(B") ("tt;" . "$B$C$Z(B")
|
||
- ("ssl" . "$B$C$[(B") ("ccl" . "$B$C$\(B") ("ttl" . "$B$C$](B") ("aah" . "$B$C$d(B") ("aaj" . "$B$C$f(B")
|
||
- ("yyo" . "$B$C$h(B") ("rra" . "$B$C$i(B") ("rri" . "$B$C$j(B")
|
||
- ("rru" . "$B$C$j$c(B") ("rri" . "$B$C$j$e(B") ("rro" . "$B$C$j$g(B")
|
||
- ("rruu" . "$B$C$j$c$"(B") ("rrii" . "$B$C$j$e$&(B") ("rroo" . "$B$C$j$g$&(B")
|
||
- ("rrj" . "$B$C$k(B") ("rr;" . "$B$C$l(B") ("rrl" . "$B$C$m(B")
|
||
- ("gj" . "$B$D(B") ("vj" . "$B$E(B") ("g;" . "$B$F(B") ("v;" . "$B$G(B")
|
||
- ("vbu" . "$B$G$c(B") ("vbk" . "$B$G$#(B") ("vbj" . "$B$G$e(B") ("vb;" . "$B$G$'(B") ("vbo" . "$B$G$g(B")
|
||
- ("gbu" . "$B$F$c(B") ("gbk" . "$B$F$#(B") ("gbj" . "$B$F$e(B") ("gbo" . "$B$F$g(B")
|
||
- ("gl" . "$B$H(B") ("vl" . "$B$I(B") ("eh" . "$B$J(B") ("ek" . "$B$K(B")
|
||
- ("eu" . "$B$K$c(B") ("ei" . "$B$K$e(B") ("eo" . "$B$K$g(B")
|
||
- ("euu" . "$B$K$c$"(B") ("eii" . "$B$K$e$&(B") ("eoo" . "$B$K$g$&(B")
|
||
- ("ej" . "$B$L(B") ("e;" . "$B$M(B") ("el" . "$B$N(B")
|
||
- ("sh" . "$B$O(B") ("ch" . "$B$P(B") ("th" . "$B$Q(B") ("sk" . "$B$R(B")
|
||
- ("su" . "$B$R$c(B") ("si" . "$B$R$e(B") ("so" . "$B$R$g(B") ("sb;" . "$B$R$'(B")
|
||
- ("suu" . "$B$R$c$"(B") ("sii" . "$B$R$e$&(B") ("soo" . "$B$R$g$&(B")
|
||
- ("ck" . "$B$S(B")
|
||
- ("cu" . "$B$S$c(B") ("ci" . "$B$S$e(B") ("co" . "$B$S$g(B") ("cb;" . "$B$R$g(B")
|
||
- ("cuu" . "$B$S$c$"(B") ("cii" . "$B$S$e$&(B") ("coo" . "$B$S$g$&(B")
|
||
- ("tk" . "$B$T(B")
|
||
- ("tu" . "$B$T$c(B") ("ti" . "$B$T$e(B") ("to" . "$B$T$g(B") ("tb;" . "$B$T$'(B")
|
||
- ("tuu" . "$B$T$c$"(B") ("tii" . "$B$T$e$&(B") ("too" . "$B$T$g$&(B")
|
||
- ("sj" . "$B$U(B")
|
||
- ("sbh" . "$B$U$!(B") ("sbk" . "$B$U$#(B") ("sbj" . "$B$U$%(B") ("sb;" . "$B$U$'(B") ("sbl" . "$B$U$)(B")
|
||
- ("cj" . "$B$V(B")
|
||
- ("cbh" . "$B$V$!(B") ("cbk" . "$B$V$#(B") ("cbj" . "$B$V$%(B") ("cb;" . "$B$V$'(B") ("cbl" . "$B$V$)(B")
|
||
- ("tj" . "$B$W(B")
|
||
- ("tbh" . "$B$W$!(B") ("tbk" . "$B$W$#(B") ("tbj" . "$B$W$%(B") ("tb;" . "$B$W$'(B") ("tbl" . "$B$W$)(B")
|
||
- ("s;" . "$B$X(B") ("c;" . "$B$Y(B") ("t;" . "$B$Z(B")
|
||
- ("sl" . "$B$[(B") ("cl" . "$B$\(B") ("tl" . "$B$](B")
|
||
- ("wh" . "$B$^(B") ("wk" . "$B$_(B")
|
||
- ("wu" . "$B$_$c(B") ("wi" . "$B$_$e(B") ("wo" . "$B$_$g(B")
|
||
- ("wuu" . "$B$_$c$"(B") ("wii" . "$B$_$e$&(B") ("woo" . "$B$_$g$&(B")
|
||
- ("wj" . "$B$`(B") ("w;" . "$B$a(B") ("wl" . "$B$b(B")
|
||
- ("u" . "$B$c(B") ("ah" . "$B$d(B") ("i" . "$B$e(B") ("aj" . "$B$f(B") ("o" . "$B$g(B")
|
||
- ("al" . "$B$h(B")
|
||
- ("rh" . "$B$i(B") ("rk" . "$B$j(B")
|
||
- ("ru" . "$B$j$c(B") ("ri" . "$B$j$e(B") ("ro" . "$B$j$g(B")
|
||
- ("ruu" . "$B$j$c$"(B") ("rii" . "$B$j$e$&(B") ("roo" . "$B$j$g$&(B")
|
||
- ("rj" . "$B$k(B") ("r;" . "$B$l(B") ("rl" . "$B$m(B")
|
||
- ("bxh" . "$B$n(B") ("xh" . "$B$o(B") ("xk" . "$B$p(B") ("x;" . "$B$q(B")
|
||
- ("xbk" . "$B$&$#(B") ("xb;" . "$B$&$'(B")
|
||
- ("xl" . "$B$r(B") ("n" . "$B$s(B")
|
||
- ("p" . "$B!<(B") ("zb;" . "$B$8$'(B")
|
||
- ("zp" . "$B!A(B") ("z/" . "$B!&(B") ("zx" . "^^;;;")
|
||
-
|
||
- ("[" . "$B!V(B") ("]" . "$B!W(B") ("{" . "$B!X(B") ("}" . "$B!Y(B")
|
||
- ("X1" . "$B!{(B") ("X!" . "$B!|(B") ("X2" . "$B"&(B") ("X@" . "$B"'(B") ("X3" . "$B"$(B")
|
||
- ("X#" . "$B"%(B") ("X4" . "$B""(B") ("X$" . "$B"#(B") ("X5" . "$B!~(B") ("X%" . "$B"!(B")
|
||
- ("X6" . "$B!y(B") ("X^" . "$B!z(B") ("X7" . "$B!}(B") ("X&" . "$B!r(B") ("X8" . "$B!q(B")
|
||
- ("X*" . "$B!_(B") ("X9" . "$B!i(B") ("X(" . "$B!Z(B") ("X0" . "$B!j(B") ("X)" . "$B![(B")
|
||
- ("X-" . "$B!A(B") ("X_" . "$B!h(B") ("X=" . "$B"b(B") ("X+" . "$B!^(B") ("X\\" . "$B!@(B")
|
||
- ("X|" . "$B!B(B") ("X\`" . "$B!-(B") ("X~" . "$B!/(B") ("Xq" . "$B!T(B") ("XQ" . "$B!R(B")
|
||
- ("Xw" . "$B!U(B") ("XW" . "$B!S(B") ("Xe" . "$B!9(B") ("XR" . "$B!8(B") ("Xt" . "$B!:(B")
|
||
- ("XT" . "$B!x(B") ("Xp" . "$B")(B") ("XP" . "$B",(B") ("X[" . "$B!X(B") ("X]" . "$B!Y(B")
|
||
- ("X{" . "$B!L(B") ("X}" . "$B!M(B") ("Xs" . "$B!3(B") ("XS" . "$B!4(B") ("Xd" . "$B!5(B")
|
||
- ("XD" . "$B!6(B") ("Xf" . "$B!7(B") ("XF" . "$B"*(B") ("Xg" . "$B!>(B") ("Xj" . "$B"-(B")
|
||
- ("XG" . "$B!=(B") ("Xh" . "$B"+(B") ("Xk" . "$B",(B") ("Xl" . "$B"*(B") ("X:" . "$B!,(B")
|
||
- ("X\'" . "$B!F(B") ("X\"" . "$B!H(B") ("Xx" . ":-") ("XX" . ":-)")
|
||
- ("Xc" . "$B!;(B") ("XC" . "$B!n(B") ("Xv" . "$B"((B") ("XV" . "$B!`(B") ("Xb" . "$B!k(B")
|
||
- ("XB" . "$B"+(B") ("Xn" . "$B!l(B") ("XN" . "$B"-(B") ("X$B$C(B" . "$B!m(B") ("XM" . "$B".(B")
|
||
- ("X," . "$B!E(B") ("X<" . "$B!e(B") ("X." . "$B!D(B") ("X>" . "$B!f(B") ("X/" . "$B!&(B")
|
||
- ("X?" . "$B!g(B") ("z1" . "$B!{(B") ("z!" . "$B!|(B") ("z2" . "$B"&(B") ("z@" . "$B"'(B")
|
||
- ("z3" . "$B"$(B") ("z#" . "$B"%(B") ("z4" . "$B""(B") ("z$" . "$B"#(B") ("z5" . "$B!~(B")
|
||
- ("z%" . "$B"!(B") ("z6" . "$B!y(B") ("z^" . "$B!z(B") ("z7" . "$B!}(B") ("z&" . "$B!r(B")
|
||
- ("z8" . "$B!q(B") ("z*" . "$B!_(B") ("z9" . "$B!i(B") ("z(" . "$B!Z(B") ("z0" . "$B!j(B")
|
||
- ("z)" . "$B![(B") ("zp" . "$B!A(B") ("z_" . "$B!h(B") ("z=" . "$B!b(B") ("z+" . "$B!^(B")
|
||
- ("z\\" . "$B!@(B") ("z|" . "$B!B(B") ("z\`" . "$B!-(B") ("z~" . "$B!/(B") ("z:" . "$B!,(B")
|
||
- ("z\'" . "$B!F(B") ("z\"" . "$B!H(B") ("z," . "$B!E(B") ("z<" . "$B!e(B") ("z." . "$B!D(B")
|
||
- ("z>" . "$B!f(B") ("z/" . "$B!&(B") ("z?" . "$B!g(B") ("z[" . "$B!X(B") ("z]" . "$B!Y(B")
|
||
- ("z{" . "$B!L(B") ("z}" . "$B!M(B") ("zx" . "^^;;;") ("zX" . "(^^)") ("zs" . "$B!!(B")
|
||
- ("@ " . "$B!!(B") ("@/" . "$B!?(B") ("@\\" . "$B!@(B") ("@@" . "$B!w(B") ("@," . "$B!$(B")
|
||
- ("@." . "$B!%(B") ("@~" . "$B!A(B") ("@-" . "$B!=(B") ("@||" . "$B!B(B") ("@|" . "$B!C(B")
|
||
- ("@\"" . "$B!7(B") ("@*" . "$B!_(B") ("@=" . "$B".(B") ("@3" . "$B!D(B") ("@2" . "$B!E(B")
|
||
- ("@0" . "$B!{(B") ("@[" . "$B!N(B") ("@]" . "$B!O(B") ("@{" . "$B!P(B") ("@}" . "$B!Q(B")
|
||
- ("@<" . "$B!T(B") ("@>" . "$B!U(B")
|
||
-
|
||
- ("Z0" . "$B#0(B") ("Z1" . "$B#1(B") ("Z2" . "$B#2(B") ("Z3" . "$B#3(B") ("Z4" . "$B#4(B")
|
||
- ("Z5" . "$B#5(B") ("Z6" . "$B#6(B") ("Z7" . "$B#7(B") ("Z8" . "$B#8(B") ("Z9" . "$B#9(B")
|
||
- ("ZA" . "$B#A(B") ("ZB" . "$B#B(B") ("ZC" . "$B#C(B") ("ZD" . "$B#D(B") ("ZE" . "$B#E(B") ("ZF" . "$B#F(B")
|
||
- ("ZG" . "$B#G(B") ("ZH" . "$B#H(B") ("ZI" . "$B#I(B") ("ZJ" . "$B#J(B") ("ZK" . "$B#K(B") ("ZL" . "$B#L(B")
|
||
- ("ZM" . "$B#M(B") ("ZN" . "$B#N(B") ("ZO" . "$B#O(B") ("ZP" . "$B#P(B") ("ZQ" . "$B#Q(B") ("ZR" . "$B#R(B")
|
||
- ("ZS" . "$B#S(B") ("ZT" . "$B#T(B") ("ZU" . "$B#U(B") ("ZV" . "$B#V(B") ("ZW" . "$B#W(B") ("ZX" . "$B#X(B")
|
||
- ("ZY" . "$B#Y(B") ("ZZ" . "$B#Z(B")
|
||
- ("Za" . "$B#a(B") ("Zb" . "$B#b(B") ("Zc" . "$B#c(B") ("Zd" . "$B#d(B") ("Ze" . "$B#e(B") ("Zf" . "$B#f(B")
|
||
- ("Zg" . "$B#g(B") ("Zh" . "$B#h(B") ("Zi" . "$B#i(B") ("Zj" . "$B#j(B") ("Zk" . "$B#k(B") ("Zl" . "$B#l(B")
|
||
- ("Zm" . "$B#m(B") ("Zn" . "$B#n(B") ("Zo" . "$B#o(B") ("Zp" . "$B#p(B") ("Zq" . "$B#q(B") ("Zr" . "$B#r(B")
|
||
- ("Zs" . "$B#s(B") ("Zt" . "$B#t(B") ("Zu" . "$B#u(B") ("Zv" . "$B#v(B") ("Zw" . "$B#w(B") ("Zx" . "$B#x(B")
|
||
- ("Zy" . "$B#y(B") ("Zz" . "$B#z(B")
|
||
- ("Z!" . "$B!*(B") ("Z@" . "$B!w(B") ("Z#" . "$B!t(B") ("Z$" . "$B!p(B") ("Z%" . "$B!s(B")
|
||
- ("Z^" . "$B!0(B") ("Z&" . "$B!u(B") ("Z*" . "$B!v(B") ("Z(" . "$B!J(B") ("Z)" . "$B!K(B") ("Z-" . "$B!](B")
|
||
- ("Z=" . "$B!a(B") ("Z`" . "$B!.(B") ("Z\\" . "$B!o(B") ("Z|" . "$B!C(B") ("Z_" . "$B!2(B") ("Z+" . "$B!\(B")
|
||
- ("Z~" . "$B!1(B") ("Z[" . "$B!N(B") ("Z]" . "$B!O(B") ("Z{" . "$B!P(B") ("Z}" . "$B!Q(B") ("Z:" . "$B!'(B")
|
||
- ("Z;" . "$B!((B") ("Z\"" . "$B!I(B") ("Z\\'" . "$B!G(B") ("Z<" . "$B!c(B") ("Z>" . "$B!d(B") ("Z?" . "$B!)(B")
|
||
- ("Z/" . "$B!?(B") ("Z," . "$B!$(B") ("Z." . "$B!%(B")
|
||
-
|
||
- ("!" . "!") ("\"" . "\"") ("#" . "#") ("$" . "$") ("%" . "%") ("&" . "&")
|
||
- ("'" . "'") ("(" . "(") (")" . ")") ("|" . "|")
|
||
- ("*" . "*") ("+" . "+") ("`" . "`") ("-" . "-") ("/" . "/")
|
||
- (":" . ":") ("<" . "<") ("=" . "=") (">" . ">") ("@" . "@")
|
||
- ("0" . "0") ("1" . "1") ("2" . "2") ("3" . "3") ("4" . "4")
|
||
- ("5" . "5") ("6" . "6") ("7" . "7") ("8" . "8") ("9" . "9")
|
||
- ))
|
||
-
|
||
-;;
|
||
-;; toggle$B$NJQ99(B
|
||
-;;
|
||
-(defun anthy-send-change-toggle-command (str)
|
||
- (anthy-send-recv-command
|
||
- (concat " CHANGE_TOGGLE ~\n")))
|
||
-
|
||
-(defun anthy-kyuri ()
|
||
- (setq anthy-rkmap-keybind nil)
|
||
- (anthy-send-recv-command " SET_PREEDIT_MODE 0\n")
|
||
- (anthy-set-break-into-roman t)
|
||
- (anthy-send-change-toggle-command "~")
|
||
- (anthy-clear-map)
|
||
- (mapcar (lambda (x)
|
||
- (anthy-change-hiragana-map (car x) (cdr x)))
|
||
- anthy-kyuri-mode-hiragana-map)
|
||
- )
|
||
-
|
||
-(define-key anthy-mode-map (char-to-string 10) 'newline-and-indent)
|
||
-(define-key anthy-mode-map (char-to-string 17) 'quoted-insert)
|
||
-
|
||
-(anthy-kyuri)
|
||
-
|
||
-(defun anthy-on ()
|
||
- (interactive)
|
||
- (anthy-mode-on))
|
||
-
|
||
-(defun anthy-off ()
|
||
- (interactive)
|
||
- (anthy-mode-off))
|
||
-
|
||
-(defun anthy-force-off ()
|
||
- (interactive)
|
||
- (anthy-handle-normal-key "(enter)")
|
||
- (anthy-off))
|
||
-
|
||
-(global-set-key "\C-o" 'anthy-on)
|
||
-(global-set-key "\C-z" 'anthy-off)
|
||
-(global-set-key "\C-c\C-t" 'anthy-add-word-interactive)
|
||
-(define-key anthy-preedit-keymap "\C-z" 'anthy-force-off)
|
||
-(setq anthy-wide-space " ")
|
||
-(setq anthy-use-hankaku-kana nil)
|
||
-
|
||
-
|
||
diff --git a/src-util/anthy-unicode-azik.el b/src-util/anthy-unicode-azik.el
|
||
new file mode 100644
|
||
index 0000000..935d4d8
|
||
--- /dev/null
|
||
+++ b/src-util/anthy-unicode-azik.el
|
||
@@ -0,0 +1,233 @@
|
||
+;; anthy-azik.el
|
||
+
|
||
+;; Copyright (C) 2004
|
||
+;; Author: Yutaka Hara<yhara@kmc.gr.jp>
|
||
+
|
||
+;; add following 2 lines to ~/.emacs
|
||
+;; (load-library "anthy-azik")
|
||
+;; (anthy-azik-mode)
|
||
+;;
|
||
+
|
||
+(defvar anthy-azik-mode-hiragana-map
|
||
+ '(
|
||
+ (";" . "っ") ("x;" . ";") ("b." . "ぶ") ("bd" . "べん") ("bh" . "ぶう")
|
||
+ ("bj" . "ぶん") ("bk" . "びん") ("bl" . "ぼん") ("bn" . "ばん") ("bp" . "ぼう")
|
||
+ ("bq" . "ばい") ("br" . "ばら") ("bt" . "びと") ("bw" . "べい") ("bx" . "べい")
|
||
+ ("byd" . "びぇん") ("byh" . "びゅう") ("byj" . "びゅん") ("byl" . "びょん") ("byn" . "びゃん")
|
||
+ ("byp" . "びょう") ("byq" . "びゃい") ("byw" . "びぇい") ("byz" . "びゃん") ("bz" . "ばん")
|
||
+ ("ca" . "ちゃ") ("cc" . "ちゃ") ("cd" . "ちぇん") ("ce" . "ちぇ") ("cf" . "ちぇ")
|
||
+ ("ch" . "ちゅう") ("ci" . "ち") ("cj" . "ちゅん") ("ck" . "ちん") ("cl" . "ちょん")
|
||
+ ("cn" . "ちゃん") ("co" . "ちょ") ("cp" . "ちょう") ("cq" . "ちゃい") ("cu" . "ちゅ")
|
||
+ ("cv" . "ちゃい") ("cw" . "ちぇい") ("cx" . "ちぇい") ("cz" . "ちゃん") ("dch" . "でゅー")
|
||
+ ("dci" . "でぃ") ("dck" . "でぃん") ("dcp" . "どぅー") ("dcu" . "でゅ") ("dd" . "でん")
|
||
+ ("df" . "で") ("dg" . "だが") ("dh" . "づう") ("dj" . "づん") ("dk" . "ぢん")
|
||
+ ("dl" . "どん") ("dm" . "でも") ("dn" . "だん") ("dp" . "どう") ("dq" . "だい")
|
||
+ ("dr" . "である") ("ds" . "です") ("dt" . "だち") ("dv" . "でん") ("dw" . "でい")
|
||
+ ("dy" . "でぃ") ("dz" . "だん") ("fd" . "ふぇん") ("fh" . "ふう") ("fj" . "ふん")
|
||
+ ("fk" . "ふぃん") ("fl" . "ふぉん") ("fm" . "ふむ") ("fn" . "ふぁん") ("fp" . "ふぉー")
|
||
+ ("fq" . "ふぁい") ("fr" . "ふる") ("fs" . "ふぁい") ("fw" . "ふぇい") ("fz" . "ふぁん")
|
||
+ ("gd" . "げん") ("gh" . "ぐう") ("gj" . "ぐん") ("gk" . "ぎん") ("gl" . "ごん")
|
||
+ ("gn" . "がん") ("gp" . "ごう") ("gq" . "がい") ("gr" . "がら") ("gt" . "ごと")
|
||
+ ("gw" . "げい") ("gyd" . "ぎぇん") ("gyh" . "ぎゅう") ("gyj" . "ぎゅん") ("gyl" . "ぎょん")
|
||
+ ("gyn" . "ぎゃん") ("gyp" . "ぎょう") ("gyq" . "ぎゃい") ("gyw" . "ぎぇい") ("gyz" . "ぎゃん")
|
||
+ ("gz" . "がん") ("hd" . "へん") ("hf" . "ふ") ("hga" . "ひゃ") ("hgd" . "ひぇん")
|
||
+ ("hge" . "ひぇ") ("hgh" . "ひゅう") ("hgj" . "ひゅん") ("hgl" . "ひょん") ("hgn" . "ひゃん")
|
||
+ ("hgo" . "ひょ") ("hgp" . "ひょう") ("hgq" . "ひゃい") ("hgu" . "ひゅ") ("hgw" . "ひぇい")
|
||
+ ("hgz" . "ひゃん") ("hh" . "ふう") ("hj" . "ふん") ("hk" . "ひん") ("hl" . "ほん")
|
||
+ ("hn" . "はん") ("hp" . "ほう") ("hq" . "はい") ("ht" . "ひと") ("hw" . "へい")
|
||
+ ("hyd" . "ひぇん") ("hyh" . "ひゅう") ("hyl" . "ひょん") ("hyp" . "ひょう") ("hyq" . "ひゃい")
|
||
+ ("hyw" . "ひぇい") ("hyz" . "ひゃん") ("hz" . "はん") ("jd" . "じぇん") ("jf" . "じゅ")
|
||
+ ("jh" . "じゅう") ("jj" . "じゅん") ("jk" . "じん") ("jl" . "じょん") ("jn" . "じゃん")
|
||
+ ("jp" . "じょう") ("jq" . "じゃい") ("jv" . "じゅう") ("jw" . "じぇい") ("jz" . "じゃん")
|
||
+ ("kA" . "ヵ") ("kE" . "ヶ") ("kd" . "けん") ("kf" . "き") ("kga" . "きゃ")
|
||
+ ("kgd" . "きぇん") ("kge" . "きぇ") ("kgh" . "きゅう") ("kgl" . "きょん") ("kgn" . "きゃん")
|
||
+ ("kgo" . "きょ") ("kgp" . "きょう") ("kgq" . "きゃい") ("kgu" . "きゅ") ("kgw" . "きぇい")
|
||
+ ("kgz" . "きゃん") ("kh" . "くう") ("kj" . "くん") ("kk" . "きん") ("kl" . "こん")
|
||
+ ("km" . "き") ("kn" . "かん") ("kp" . "こう") ("kq" . "かい") ("kr" . "から")
|
||
+ ("kt" . "こと") ("kv" . "きん") ("kw" . "けい") ("kyd" . "きぇん") ("kyh" . "きゅう")
|
||
+ ("kyj" . "きゅん") ("kyl" . "きょん") ("kyn" . "きゃん") ("kyp" . "きょう") ("kyq" . "きゃい")
|
||
+ ("kyw" . "きぇい") ("kyz" . "きゃん") ("kz" . "かん") ("m." . "む") ("md" . "めん")
|
||
+ ("mf" . "む") ("mga" . "みゃ") ("mgd" . "みぇん") ("mge" . "みぇ") ("mgh" . "みゅう")
|
||
+ ("mgj" . "みゅん") ("mgl" . "みょん") ("mgn" . "みゃん") ("mgo" . "みょ") ("mgp" . "みょう")
|
||
+ ("mgq" . "みゃい") ("mgu" . "みゅ") ("mgw" . "みぇい") ("mgz" . "みゃん") ("mh" . "むう")
|
||
+ ("mj" . "むん") ("mk" . "みん") ("ml" . "もん") ("mn" . "もの") ("mp" . "もう")
|
||
+ ("mq" . "まい") ("mr" . "まる") ("ms" . "ます") ("mt" . "また") ("mv" . "むん")
|
||
+ ("mw" . "めい") ("myd" . "みぇん") ("myh" . "みゅう") ("myj" . "みゅん") ("myl" . "みょん")
|
||
+ ("myn" . "みゃん") ("myp" . "みょう") ("myq" . "みゃい") ("myw" . "みぇい") ("myz" . "みゃん")
|
||
+ ("mz" . "まん") ("n." . "ぬ") ("nb" . "ねば") ("nd" . "ねん") ("nf" . "ぬ")
|
||
+ ("nga" . "にゃ") ("ngd" . "にぇん") ("nge" . "にぇ") ("ngh" . "にゅう") ("ngj" . "にゅん")
|
||
+ ("ngl" . "にょん") ("ngn" . "にゃん") ("ngo" . "にょ") ("ngp" . "にょう") ("ngq" . "にゃい")
|
||
+ ("ngu" . "にゅ") ("ngw" . "にぇい") ("ngz" . "にゃん") ("nh" . "ぬう") ("nj" . "ぬん")
|
||
+ ("nk" . "にん") ("nl" . "のん") ("np" . "のう") ("nq" . "ない") ("nr" . "なる")
|
||
+ ("nt" . "にち") ("nv" . "ぬん") ("nw" . "ねい") ("nyd" . "にぇん") ("nyh" . "にゅう")
|
||
+ ("nyj" . "にゅん") ("nyl" . "にょん") ("nyn" . "にゃん") ("nyp" . "にょう") ("nyq" . "にゃい")
|
||
+ ("nyw" . "にぇい") ("nyz" . "にゃん") ("nz" . "なん") ("pd" . "ぺん") ("pf" . "ぽん")
|
||
+ ("pga" . "ぴゃ") ("pgd" . "ぴぇん") ("pge" . "ぴぇ") ("pgh" . "ぴゅう") ("pgj" . "ぴゅん")
|
||
+ ("pgl" . "ぴょん") ("pgn" . "ぴゃん") ("pgo" . "ぴょ") ("pgp" . "ぴょう") ("pgq" . "ぴゃい")
|
||
+ ("pgu" . "ぴゅ") ("pgw" . "ぴぇい") ("pgz" . "ぴゃん") ("ph" . "ぷう") ("pj" . "ぷん")
|
||
+ ("pk" . "ぴん") ("pl" . "ぽん") ("pn" . "ぱん") ("pp" . "ぽう") ("pq" . "ぱい")
|
||
+ ("pv" . "ぽう") ("pw" . "ぺい") ("pyd" . "ぴぇん") ("pyh" . "ぴゅう") ("pyj" . "ぴゅん")
|
||
+ ("pyl" . "ぴょん") ("pyn" . "ぴゃん") ("pyp" . "ぴょう") ("pyq" . "ぴゃい") ("pyw" . "ぴぇい")
|
||
+ ("pyz" . "ぴゃん") ("pz" . "ぱん") ("q" . "ん") ("rd" . "れん") ("rh" . "るう")
|
||
+ ("rj" . "るん") ("rk" . "りん") ("rl" . "ろん") ("rn" . "らん") ("rp" . "ろう")
|
||
+ ("rq" . "らい") ("rr" . "られ") ("rw" . "れい") ("ryd" . "りぇん") ("ryh" . "りゅう")
|
||
+ ("ryj" . "りゅん") ("ryk" . "りょく") ("ryl" . "りょん") ("ryn" . "りゃん") ("ryp" . "りょう")
|
||
+ ("ryq" . "りゃい") ("ryw" . "りぇい") ("ryz" . "りゃん") ("rz" . "らん") ("sd" . "せん")
|
||
+ ("sf" . "さい") ("sh" . "すう") ("sj" . "すん") ("sk" . "しん") ("sl" . "そん")
|
||
+ ("sm" . "しも") ("sn" . "さん") ("sp" . "そう") ("sq" . "さい") ("sr" . "する")
|
||
+ ("ss" . "せい") ("st" . "した") ("sv" . "さい") ("sw" . "せい") ("syd" . "しぇん")
|
||
+ ("syh" . "しゅう") ("syj" . "しゅん") ("syl" . "しょん") ("syp" . "しょう") ("syq" . "しゃい")
|
||
+ ("syw" . "しぇい") ("syz" . "しゃん") ("sz" . "さん") ("tU" . "っ") ("tb" . "たび")
|
||
+ ("td" . "てん") ("tgh" . "てゅー") ("tgi" . "てぃ") ("tgk" . "てぃん") ("tgp" . "とぅー")
|
||
+ ("tgu" . "てゅ") ("th" . "つう") ("tj" . "つん") ("tk" . "ちん") ("tl" . "とん")
|
||
+ ("tm" . "ため") ("tn" . "たん") ("tp" . "とう") ("tq" . "たい") ("tr" . "たら")
|
||
+ ("tsU" . "っ") ("tsa" . "つぁ") ("tse" . "つぇ") ("tsi" . "つぃ") ("tso" . "つぉ")
|
||
+ ("tt" . "たち") ("tw" . "てい") ("tyd" . "ちぇん") ("tyh" . "ちゅう") ("tyj" . "ちゅん")
|
||
+ ("tyl" . "ちょん") ("tyn" . "ちゃん") ("typ" . "ちょう") ("tyq" . "ちゃい") ("tyw" . "ちぇい")
|
||
+ ("tyz" . "ちゃん") ("tz" . "たん") ("vd" . "う゛ぇん") ("vk" . "う゛ぃん") ("vl" . "う゛ぉん")
|
||
+ ("vn" . "う゛ぁん") ("vp" . "う゛ぉー") ("vq" . "う゛ぁい") ("vw" . "う゛ぇい") ("vya" . "う゛ゃ")
|
||
+ ("vye" . "う゛ぇ") ("vyo" . "う゛ょ") ("vyu" . "う゛ゅ") ("vz" . "う゛ぁん") ("wA" . "ゎ")
|
||
+ ("wd" . "うぇん") ("wf" . "わ") ("wha" . "うぁ") ("whe" . "うぇ") ("whi" . "うぃ")
|
||
+ ("who" . "うぉ") ("whu" . "う") ("wk" . "うぃん") ("wl" . "うぉん") ("wn" . "わん")
|
||
+ ("wp" . "うぉー") ("wq" . "わい") ("wr" . "われ") ("wso" . "うぉ") ("wt" . "わた")
|
||
+ ("wz" . "わん") ("xa" . "しゃ") ("xc" . "しゃ") ("xd" . "しぇん") ("xe" . "しぇ")
|
||
+ ("xf" . "しぇい") ("xh" . "しゅう") ("xi" . "し") ("xj" . "しゅん") ("xk" . "しん")
|
||
+ ("xl" . "しょん") ("xn" . "しゃん") ("xo" . "しょ") ("xp" . "しょう") ("xq" . "しゃい")
|
||
+ ("xt" . "しゅつ") ("xu" . "しゅ") ("xv" . "しゃい") ("xw" . "しぇい") ("xxa" . "ぁ")
|
||
+ ("xxe" . "ぇ") ("xxi" . "ぃ") ("xxo" . "ぉ") ("xxu" . "ぅ") ("xxh" . "←")
|
||
+ ("xxj" . "↓") ("xxk" . "↑") ("xxl" . "→") ("xz" . "しゃん") ("y<" . "←")
|
||
+ ("y>" . "→") ("y^" . "↑") ("yf" . "ゆ") ("yh" . "ゆう") ("yi" . "ゐ")
|
||
+ ("yj" . "ゆん") ("yl" . "よん") ("yn" . "やん") ("yp" . "よう") ("yq" . "やい")
|
||
+ ("yr" . "よる") ("yv" . "ゆう") ("yz" . "やん") ("z." . "ず") ("zc" . "ざ")
|
||
+ ("zd" . "ぜん") ("zf" . "ぜ") ("zh" . "ずう") ("zj" . "ずん") ("zk" . "じん")
|
||
+ ("zl" . "ぞん") ("zn" . "ざん") ("zp" . "ぞう") ("zq" . "ざい") ("zr" . "ざる")
|
||
+ ("zv" . "ざい") ("zw" . "ぜい") ("zx" . "ぜい") ("zyd" . "じぇん") ("zyh" . "じゅう")
|
||
+ ("zyj" . "じゅん") ("zyl" . "じょん") ("zyn" . "じゃん") ("zyp" . "じょう") ("zyq" . "じゃい")
|
||
+ ("zyw" . "じぇい") ("zyz" . "じゃん") ("zz" . "ざん") ("bx" . "びょう") ("bx" . "びょう")
|
||
+ ("dx" . "ぢょう") ("gx" . "ぎょう") ("hx" . "ひょう") ("kx" . "きょう") ("mx" . "みょう")
|
||
+ ("nx" . "にょう") ("px" . "ぴょう") ("rx" . "りょう") ("sx" . "しょう") ("bv" . "びゅう")
|
||
+ ("dv" . "ぢゅう") ("fv" . "ふゅー") ("gv" . "ぎゅう") ("hv" . "ひゅう") ("kv" . "きゅう")
|
||
+ ("mv" . "みゅう") ("nv" . "にゅう") ("pv" . "ぴゅう") ("rv" . "りゅう") ("sv" . "しゅう")
|
||
+ ("vv" . "う゛ゅー")
|
||
+ ))
|
||
+
|
||
+; (defvar anthy-azik-mode-katakana-map
|
||
+; '(
|
||
+; (";" . "ッ") ("x;" . ";") ("b." . "ブ") ("bd" . "ベン") ("bh" . "ブウ")
|
||
+; ("bj" . "ブン") ("bk" . "ビン") ("bl" . "ゥs") ("bn" . "バン") ("bp" . "ゥ&")
|
||
+; ("bq" . "バイ") ("br" . "バラ") ("bt" . "ビト") ("bw" . "ベイ") ("bx" . "ベイ")
|
||
+; ("byd" . "ビェン") ("byh" . "ビュウ") ("byj" . "ビュン") ("byl" . "ビョン") ("byn" . "ビャン")
|
||
+; ("byp" . "ビョウ") ("byq" . "ビャイ") ("byw" . "ビェイ") ("byz" . "ビャン") ("bz" . "バン")
|
||
+; ("ca" . "チャ") ("cc" . "チャ") ("cd" . "チェン") ("ce" . "チェ") ("cf" . "チェ")
|
||
+; ("ch" . "チュウ") ("ci" . "チ") ("cj" . "チュン") ("ck" . "チン") ("cl" . "チョン")
|
||
+; ("cn" . "チャン") ("co" . "チョ") ("cp" . "チョウ") ("cq" . "チャイ") ("cu" . "チュ")
|
||
+; ("cv" . "チャイ") ("cw" . "チェイ") ("cx" . "チェイ") ("cz" . "チャン") ("dch" . "デュー")
|
||
+; ("dci" . "ディ") ("dck" . "ディン") ("dcp" . "ドゥー") ("dcu" . "デュ") ("dd" . "デン")
|
||
+; ("df" . "デ") ("dg" . "ダガ") ("dh" . "ヅウ") ("dj" . "ヅン") ("dk" . "ヂン")
|
||
+; ("dl" . "ドン") ("dm" . "デモ") ("dn" . "ダン") ("dp" . "ドウ") ("dq" . "ダイ")
|
||
+; ("dr" . "デアル") ("ds" . "デス") ("dt" . "ダチ") ("dv" . "デン") ("dw" . "デイ")
|
||
+; ("dy" . "ディ") ("dz" . "ダン") ("fd" . "フェン") ("fh" . "フウ") ("fj" . "フン")
|
||
+; ("fk" . "フィン") ("fl" . "フォン") ("fm" . "フム") ("fn" . "ファン") ("fp" . "フォー")
|
||
+; ("fq" . "ファイ") ("fr" . "フル") ("fs" . "ファイ") ("fw" . "フェイ") ("fz" . "ファン")
|
||
+; ("gd" . "ゲン") ("gh" . "グウ") ("gj" . "グン") ("gk" . "ギン") ("gl" . "ゴン")
|
||
+; ("gn" . "ガン") ("gp" . "ゴウ") ("gq" . "ガイ") ("gr" . "ガラ") ("gt" . "ゴト")
|
||
+; ("gw" . "ゲイ") ("gyd" . "ギェン") ("gyh" . "ギュウ") ("gyj" . "ギュン") ("gyl" . "ギョン")
|
||
+; ("gyn" . "ギャン") ("gyp" . "ギョウ") ("gyq" . "ギャイ") ("gyw" . "ギェイ") ("gyz" . "ギャン")
|
||
+; ("gz" . "ガン") ("hd" . "ヘン") ("hf" . "フ") ("hga" . "ヒャ") ("hgd" . "ヒェン")
|
||
+; ("hge" . "ヒェ") ("hgh" . "ヒュウ") ("hgj" . "ヒュン") ("hgl" . "ヒョン") ("hgn" . "ヒャン")
|
||
+; ("hgo" . "ヒョ") ("hgp" . "ヒョウ") ("hgq" . "ヒャイ") ("hgu" . "ヒュ") ("hgw" . "ヒェイ")
|
||
+; ("hgz" . "ヒャン") ("hh" . "フウ") ("hj" . "フン") ("hk" . "ヒン") ("hl" . "ホン")
|
||
+; ("hn" . "ハン") ("hp" . "ホウ") ("hq" . "ハイ") ("ht" . "ヒト") ("hw" . "ヘイ")
|
||
+; ("hyd" . "ヒェン") ("hyh" . "ヒュウ") ("hyl" . "ヒョン") ("hyp" . "ヒョウ") ("hyq" . "ヒャイ")
|
||
+; ("hyw" . "ヒェイ") ("hyz" . "ヒャン") ("hz" . "ハン") ("jd" . "ジェン") ("jf" . "ジュ")
|
||
+; ("jh" . "ジュウ") ("jj" . "ジュン") ("jk" . "ジン") ("jl" . "ジョン") ("jn" . "ジャン")
|
||
+; ("jp" . "ジョウ") ("jq" . "ジャイ") ("jv" . "ジュウ") ("jw" . "ジェイ") ("jz" . "ジャン")
|
||
+; ("kA" . "ヵ") ("kE" . "ヶ") ("kd" . "ケン") ("kf" . "キ") ("kga" . "キャ")
|
||
+; ("kgd" . "キェン") ("kge" . "キェ") ("kgh" . "キュウ") ("kgl" . "キョン") ("kgn" . "キャン")
|
||
+; ("kgo" . "キョ") ("kgp" . "キョウ") ("kgq" . "キャイ") ("kgu" . "キュ") ("kgw" . "キェイ")
|
||
+; ("kgz" . "キャン") ("kh" . "クウ") ("kj" . "クン") ("kk" . "キン") ("kl" . "コン")
|
||
+; ("km" . "キ") ("kn" . "カン") ("kp" . "コウ") ("kq" . "カイ") ("kr" . "カラ")
|
||
+; ("kt" . "コト") ("kv" . "キン") ("kw" . "ケイ") ("kyd" . "キェン") ("kyh" . "キュウ")
|
||
+; ("kyj" . "キュン") ("kyl" . "キョン") ("kyn" . "キャン") ("kyp" . "キョウ") ("kyq" . "キャイ")
|
||
+; ("kyw" . "キェイ") ("kyz" . "キャン") ("kz" . "カン") ("m." . "ム") ("md" . "メン")
|
||
+; ("mf" . "ム") ("mga" . "ミャ") ("mgd" . "ミェン") ("mge" . "ミェ") ("mgh" . "ミュウ")
|
||
+; ("mgj" . "ミュン") ("mgl" . "ミョン") ("mgn" . "ミャン") ("mgo" . "ミョ") ("mgp" . "ミョウ")
|
||
+; ("mgq" . "ミャイ") ("mgu" . "ミュ") ("mgw" . "ミェイ") ("mgz" . "ミャン") ("mh" . "ムウ")
|
||
+; ("mj" . "ムン") ("mk" . "ミン") ("ml" . "モン") ("mn" . "モノ") ("mp" . "モウ")
|
||
+; ("mq" . "マイ") ("mr" . "マル") ("ms" . "マス") ("mt" . "マタ") ("mv" . "ムン")
|
||
+; ("mw" . "メイ") ("myd" . "ミェン") ("myh" . "ミュウ") ("myj" . "ミュン") ("myl" . "ミョン")
|
||
+; ("myn" . "ミャン") ("myp" . "ミョウ") ("myq" . "ミャイ") ("myw" . "ミェイ") ("myz" . "ミャン")
|
||
+; ("mz" . "マン") ("n." . "ヌ") ("nb" . "ネバ") ("nd" . "ネン") ("nf" . "ヌ")
|
||
+; ("nga" . "ニャ") ("ngd" . "ニェン") ("nge" . "ニェ") ("ngh" . "ニュウ") ("ngj" . "ニュン")
|
||
+; ("ngl" . "ニョン") ("ngn" . "ニャン") ("ngo" . "ニョ") ("ngp" . "ニョウ") ("ngq" . "ニャイ")
|
||
+; ("ngu" . "ニュ") ("ngw" . "ニェイ") ("ngz" . "ニャン") ("nh" . "ヌウ") ("nj" . "ヌン")
|
||
+; ("nk" . "ニン") ("nl" . "ノン") ("np" . "ノウ") ("nq" . "ナイ") ("nr" . "ナル")
|
||
+; ("nt" . "ニチ") ("nv" . "ヌン") ("nw" . "ネイ") ("nyd" . "ニェン") ("nyh" . "ニュウ")
|
||
+; ("nyj" . "ニュン") ("nyl" . "ニョン") ("nyn" . "ニャン") ("nyp" . "ニョウ") ("nyq" . "ニャイ")
|
||
+; ("nyw" . "ニェイ") ("nyz" . "ニャン") ("nz" . "ナン") ("pd" . "ペン") ("pf" . "ポン")
|
||
+; ("pga" . "ピャ") ("pgd" . "ピェン") ("pge" . "ピェ") ("pgh" . "ピュウ") ("pgj" . "ピュン")
|
||
+; ("pgl" . "ピョン") ("pgn" . "ピャン") ("pgo" . "ピョ") ("pgp" . "ピョウ") ("pgq" . "ピャイ")
|
||
+; ("pgu" . "ピュ") ("pgw" . "ピェイ") ("pgz" . "ピャン") ("ph" . "プウ") ("pj" . "プン")
|
||
+; ("pk" . "ピン") ("pl" . "ポン") ("pn" . "パン") ("pp" . "ポウ") ("pq" . "パイ")
|
||
+; ("pv" . "ポウ") ("pw" . "ペイ") ("pyd" . "ピェン") ("pyh" . "ピュウ") ("pyj" . "ピュン")
|
||
+; ("pyl" . "ピョン") ("pyn" . "ピャン") ("pyp" . "ピョウ") ("pyq" . "ピャイ") ("pyw" . "ピェイ")
|
||
+; ("pyz" . "ピャン") ("pz" . "パン") ("q" . "ン") ("rd" . "レン") ("rh" . "ルウ")
|
||
+; ("rj" . "ルン") ("rk" . "リン") ("rl" . "ロン") ("rn" . "ラン") ("rp" . "ロウ")
|
||
+; ("rq" . "ライ") ("rr" . "ラレ") ("rw" . "レイ") ("ryd" . "リェン") ("ryh" . "リュウ")
|
||
+; ("ryj" . "リュン") ("ryk" . "リョク") ("ryl" . "リョン") ("ryn" . "リャン") ("ryp" . "リョウ")
|
||
+; ("ryq" . "リャイ") ("ryw" . "リェイ") ("ryz" . "リャン") ("rz" . "ラン") ("sd" . "セン")
|
||
+; ("sf" . "サイ") ("sh" . "スウ") ("sj" . "スン") ("sk" . "シン") ("sl" . "ソン")
|
||
+; ("sm" . "シモ") ("sn" . "サン") ("sp" . "ソウ") ("sq" . "サイ") ("sr" . "スル")
|
||
+; ("ss" . "セイ") ("st" . "シタ") ("sv" . "サイ") ("sw" . "セイ") ("syd" . "シェン")
|
||
+; ("syh" . "シュウ") ("syj" . "シュン") ("syl" . "ション") ("syp" . "ショウ") ("syq" . "シャイ")
|
||
+; ("syw" . "シェイ") ("syz" . "シャン") ("sz" . "サン") ("tU" . "ッ") ("tb" . "タビ")
|
||
+; ("td" . "テン") ("tgh" . "テュー") ("tgi" . "ティ") ("tgk" . "ティン") ("tgp" . "トゥー")
|
||
+; ("tgu" . "テュ") ("th" . "ツウ") ("tj" . "ツン") ("tk" . "チン") ("tl" . "トン")
|
||
+; ("tm" . "タメ") ("tn" . "タン") ("tp" . "トウ") ("tq" . "タイ") ("tr" . "タラ")
|
||
+; ("tsU" . "ッ") ("tsa" . "ツァ") ("tse" . "ツェ") ("tsi" . "ツィ") ("tso" . "ツォ")
|
||
+; ("tt" . "タチ") ("tw" . "テイ") ("tyd" . "チェン") ("tyh" . "チュウ") ("tyj" . "チュン")
|
||
+; ("tyl" . "チョン") ("tyn" . "チャン") ("typ" . "チョウ") ("tyq" . "チャイ") ("tyw" . "チェイ")
|
||
+; ("tyz" . "チャン") ("tz" . "タン") ("vd" . "ヴェン") ("vk" . "ヴィン") ("vl" . "ヴォン")
|
||
+; ("vn" . "ヴァン") ("vp" . "ヴォー") ("vq" . "ヴァイ") ("vw" . "ヴェイ") ("vya" . "ヴャ")
|
||
+; ("vye" . "ヴェ") ("vyo" . "ヴョ") ("vyu" . "ヴュ") ("vz" . "ヴァン") ("wA" . "ヮ")
|
||
+; ("wd" . "ウェン") ("wf" . "ワ") ("wha" . "ウァ") ("whe" . "ウェ") ("whi" . "ウィ")
|
||
+; ("who" . "ウォ") ("whu" . "ウ") ("wk" . "ウィン") ("wl" . "ウォン") ("wn" . "ワン")
|
||
+; ("wp" . "ウォー") ("wq" . "ワイ") ("wr" . "ワレ") ("wso" . "ウォ") ("wt" . "ワタ")
|
||
+; ("wz" . "ワン") ("xa" . "シャ") ("xc" . "シャ") ("xd" . "シェン") ("xe" . "シェ")
|
||
+; ("xf" . "シェイ") ("xh" . "シュウ") ("xi" . "シ") ("xj" . "シュン") ("xk" . "シン")
|
||
+; ("xl" . "ション") ("xn" . "シャン") ("xo" . "ショ") ("xp" . "ショウ") ("xq" . "シャイ")
|
||
+; ("xt" . "シュツ") ("xu" . "シュ") ("xv" . "シャイ") ("xw" . "シェイ") ("xxa" . "ァ")
|
||
+; ("xxe" . "ェ") ("xxi" . "ィ") ("xxo" . "ォ") ("xxu" . "ゥ") ("xxh" . "←")
|
||
+; ("xxj" . "↓") ("xxk" . "↑") ("xxl" . "→") ("xz" . "シャン") ("y<" . "←")
|
||
+; ("y>" . "→") ("y^" . "↑") ("yf" . "ユ") ("yh" . "ユウ") ("yi" . "ヰ")
|
||
+; ("yj" . "ユン") ("yl" . "ヨン") ("yn" . "ヤン") ("yp" . "ヨウ") ("yq" . "ヤイ")
|
||
+; ("yr" . "ヨル") ("yv" . "ユウ") ("yz" . "ヤン") ("z." . "ズ") ("zc" . "ザ")
|
||
+; ("zd" . "ゼン") ("zf" . "ゼ") ("zh" . "ズウ") ("zj" . "ズン") ("zk" . "ジン")
|
||
+; ("zl" . "ゾン") ("zn" . "ザン") ("zp" . "ゾウ") ("zq" . "ザイ") ("zr" . "ザル")
|
||
+; ("zv" . "ザイ") ("zw" . "ゼイ") ("zx" . "ゼイ") ("zyd" . "ジェン") ("zyh" . "ジュウ")
|
||
+; ("zyj" . "ジュン") ("zyl" . "ジョン") ("zyn" . "ジャン") ("zyp" . "ジョウ") ("zyq" . "ジャイ")
|
||
+; ("zyw" . "ジェイ") ("zyz" . "ジャン") ("zz" . "ザン") ("bx" . "ビョウ") ("bx" . "ビョウ")
|
||
+; ("dx" . "ヂョウ") ("gx" . "ギョウ") ("hx" . "ヒョウ") ("kx" . "キョウ") ("mx" . "ミョウ")
|
||
+; ("nx" . "ニョウ") ("px" . "ピョウ") ("rx" . "リョウ") ("sx" . "ショウ") ("bv" . "ビュウ")
|
||
+; ("dv" . "ヂュウ") ("fv" . "フュー") ("gv" . "ギュウ") ("hv" . "ヒュウ") ("kv" . "キュウ")
|
||
+; ("mv" . "ミュウ") ("nv" . "ニュウ") ("pv" . "ピュウ") ("rv" . "リュウ") ("sv" . "シュウ")
|
||
+; ("vv" . "ウ゛ュー")
|
||
+; ))
|
||
+
|
||
+(defun anthy-azik-mode ()
|
||
+ (interactive)
|
||
+ (setq anthy-rkmap-keybind
|
||
+ '(
|
||
+ ;; \C-p
|
||
+ (("hiragana" . 16) . "katakana")
|
||
+ (("katakana" . 16) . "hiragana")))
|
||
+; (define-key anthy-mode-map (char-to-string 16) 'anthy-insert)
|
||
+ (anthy-send-change-toggle-command "!")
|
||
+ (mapcar (lambda (x)
|
||
+ (anthy-change-hiragana-map (car x) (cdr x)))
|
||
+ anthy-azik-mode-hiragana-map)
|
||
+ (anthy-hiragana-map))
|
||
+; (mapcar (lambda (x)
|
||
+; (anthy-change-katakana-map (car x) (cdr x)))
|
||
+; anthy-azik-mode-katakana-map)
|
||
+
|
||
diff --git a/src-util/anthy-unicode-conf.el b/src-util/anthy-unicode-conf.el
|
||
new file mode 100644
|
||
index 0000000..7b7d7c2
|
||
--- /dev/null
|
||
+++ b/src-util/anthy-unicode-conf.el
|
||
@@ -0,0 +1,122 @@
|
||
+;; anthy-conf.el -- Anthy
|
||
+
|
||
+
|
||
+;; Copyright (C) 2002
|
||
+;; Author: Yusuke Tabata<yusuke@kmc.gr.jp>
|
||
+
|
||
+;; This file is part of Anthy
|
||
+
|
||
+;;; Commentary:
|
||
+;;
|
||
+
|
||
+(defvar anthy-alt-char-map
|
||
+ '(("," ",")
|
||
+ ("." ".")))
|
||
+
|
||
+(defvar anthy-kana-mode-hiragana-map
|
||
+ '(
|
||
+ ("3" . "あ") ("e" . "い") ("4" . "う") ("5" . "え") ("6" . "お")
|
||
+ ("#" . "ぁ") ("E" . "ぃ") ("$" . "ぅ") ("%" . "ぇ") ("&" . "ぉ")
|
||
+ ("t" . "か") ("g" . "き") ("h" . "く") (":" . "け") ("b" . "こ")
|
||
+ ("t@" . "が") ("g@" . "ぎ") ("h@" . "ぐ") (":@" . "げ") ("b@" . "ご")
|
||
+ ("x" . "さ") ("d" . "し") ("r" . "す") ("p" . "せ") ("c" . "そ")
|
||
+ ("x@" . "ざ") ("d@" . "じ") ("r@" . "ず") ("p@" . "ぜ") ("c@" . "ぞ")
|
||
+ ("q" . "た") ("a" . "ち") ("z" . "つ") ("w" . "て") ("s" . "と")
|
||
+ ("q@" . "だ") ("a@" . "ぢ") ("z@" . "づ") ("w@" . "で") ("s@" . "ど")
|
||
+ ("u" . "な") ("i" . "に") ("1" . "ぬ") ("," . "ね") ("k" . "の")
|
||
+ ("f" . "は") ("v" . "ひ") ("2" . "ふ") ("^" . "へ") ("-" . "ほ")
|
||
+ ("f@" . "ば") ("v@" . "び") ("2@" . "ぶ") ("^@" . "べ") ("-@" . "ぼ")
|
||
+ ("f[" . "ぱ") ("v[" . "ぴ") ("2[" . "ぷ") ("^[" . "ぺ") ("-[" . "ぽ")
|
||
+ ("j" . "ま") ("n" . "み") ("]" . "む") ("/" . "め") ("m" . "も")
|
||
+ ("7" . "や") ("8" . "ゆ") ("9" . "よ")
|
||
+ ("'" . "ゃ") ("(" . "ゅ") (")" . "ょ")
|
||
+ ("o" . "ら") ("l" . "り") ("." . "る") (";" . "れ") ("\\" . "ろ")
|
||
+ ("0" . "わ") ("~" . "を")
|
||
+
|
||
+ ;; 困ったことに バックスラッシュと円を区別する方法がわからない
|
||
+ ("|" . "ー") ("_" . "ー") ("<" . "、") (">" . "。")
|
||
+ ("Z" . "っ") ("y" . "ん")
|
||
+ ))
|
||
+
|
||
+(defvar anthy-kana-mode-katakana-map
|
||
+ '(
|
||
+ ("3" . "ア") ("e" . "イ") ("4" . "ウ") ("5" . "エ") ("6" . "オ")
|
||
+ ("#" . "ァ") ("E" . "ィ") ("$" . "ゥ") ("%" . "ェ") ("&" . "ォ")
|
||
+ ("t" . "カ") ("g" . "キ") ("h" . "ク") (":" . "ケ") ("b" . "コ")
|
||
+ ("t@" . "ガ") ("g@" . "ギ") ("h@" . "グ") (":@" . "ゲ") ("b@" . "ゴ")
|
||
+ ("x" . "サ") ("d" . "シ") ("r" . "ス") ("p" . "セ") ("c" . "ソ")
|
||
+ ("x@" . "ザ") ("d@" . "ジ") ("r@" . "ズ") ("p@" . "ゼ") ("c@" . "ゾ")
|
||
+ ("q" . "タ") ("a" . "チ") ("z" . "ツ") ("w" . "テ") ("s" . "ト")
|
||
+ ("q@" . "ダ") ("a@" . "ヂ") ("z@" . "ヅ") ("w@" . "デ") ("s@" . "ド")
|
||
+ ("u" . "ナ") ("i" . "ニ") ("1" . "ヌ") ("," . "ネ") ("k" . "ノ")
|
||
+ ("f" . "ハ") ("v" . "ヒ") ("2" . "フ") ("^" . "ヘ") ("-" . "ホ")
|
||
+ ("f@" . "バ") ("v@" . "ビ") ("2@" . "ブ") ("^@" . "ベ") ("-@" . "ボ")
|
||
+ ("f[" . "パ") ("v[" . "ピ") ("2[" . "プ") ("^[" . "ペ") ("-[" . "ポ")
|
||
+ ("j" . "マ") ("n" . "ミ") ("]" . "ム") ("/" . "メ") ("m" . "モ")
|
||
+ ("7" . "ヤ") ("8" . "ユ") ("9" . "ヨ")
|
||
+ ("'" . "ャ") ("(" . "ュ") (")" . "ョ")
|
||
+ ("o" . "ラ") ("l" . "リ") ("." . "ル") (";" . "レ") ("\\" . "ロ")
|
||
+ ("0" . "ワ") ("~" . "ヲ")
|
||
+
|
||
+ ;; 困ったことに バックスラッシュと円を区別する方法がわからない
|
||
+ ("|" . "ー") ("_" . "ー") ("<" . "、") (">" . "。")
|
||
+ ("Z" . "ッ") ("y" . "ン")
|
||
+ ))
|
||
+
|
||
+;;
|
||
+;; mapの変更
|
||
+;;
|
||
+(defun anthy-send-map-edit-command (mapno key str)
|
||
+ (if (not (stringp key))
|
||
+ (setq key (char-to-string key)))
|
||
+ (if (not (stringp str))
|
||
+ (setq str (char-to-string str)))
|
||
+ (anthy-send-recv-command
|
||
+ (concat " MAP_EDIT " (int-to-string mapno)
|
||
+ " " key " " str "\n")))
|
||
+(defun anthy-change-hiragana-map (key str)
|
||
+ (anthy-send-map-edit-command 2 key str))
|
||
+(defun anthy-change-katakana-map (key str)
|
||
+ (anthy-send-map-edit-command 3 key str))
|
||
+(defun anthy-load-hiragana-map (map)
|
||
+ (mapcar (lambda (x)
|
||
+ (let ((key (car x))
|
||
+ (str (cadr x)))
|
||
+ (anthy-change-hiragana-map key str))) map))
|
||
+(defun anthy-clear-map ()
|
||
+ (anthy-send-recv-command
|
||
+ " MAP_CLEAR 0\n"))
|
||
+;;
|
||
+;; toggleの変更
|
||
+;;
|
||
+(defun anthy-send-change-toggle-command (str)
|
||
+ (anthy-send-recv-command
|
||
+ (concat " CHANGE_TOGGLE " str "\n")))
|
||
+
|
||
+;; should disable toggle
|
||
+;; (ローマ字ではなくて)かなモードにする
|
||
+(defun anthy-kana-map-mode ()
|
||
+ (setq anthy-rkmap-keybind
|
||
+ '(
|
||
+ ;; \C-p
|
||
+ (("hiragana" . 16) . "katakana")
|
||
+ (("katakana" . 16) . "hiragana")))
|
||
+ (define-key anthy-mode-map (char-to-string 16) 'anthy-insert)
|
||
+ (anthy-send-recv-command " SET_PREEDIT_MODE 1\n")
|
||
+ (anthy-send-change-toggle-command "!")
|
||
+ (anthy-clear-map)
|
||
+ (mapcar (lambda (x)
|
||
+ (anthy-change-hiragana-map (car x) (cdr x)))
|
||
+ anthy-kana-mode-hiragana-map)
|
||
+ (mapcar (lambda (x)
|
||
+ (anthy-change-katakana-map (car x) (cdr x)))
|
||
+ anthy-kana-mode-katakana-map))
|
||
+;;
|
||
+(defun anthy-set-break-into-roman (flag)
|
||
+ "読みを入力中にバックスペースを打つとローマ字までバラバラにする"
|
||
+ (anthy-send-recv-command
|
||
+ (if flag
|
||
+ " BREAK_INTO_ROMAN 1\n"
|
||
+ " BREAK_INTO_ROMAN 0\n")))
|
||
+
|
||
+(provide 'anthy-conf)
|
||
diff --git a/src-util/anthy-dic.el b/src-util/anthy-unicode-dic.el
|
||
similarity index 59%
|
||
rename from src-util/anthy-dic.el
|
||
rename to src-util/anthy-unicode-dic.el
|
||
index 07cfc7b..5920451 100644
|
||
--- a/src-util/anthy-dic.el
|
||
+++ b/src-util/anthy-unicode-dic.el
|
||
@@ -11,7 +11,7 @@
|
||
;; tooo experimental
|
||
;;
|
||
;;
|
||
-;; Funded by IPA$BL$F'%=%U%H%&%'%"AOB$;v6H(B 2001 11/10
|
||
+;; Funded by IPA未踏ソフトウェア創造事業 2001 11/10
|
||
|
||
;;; Code
|
||
(defvar anthy-dic-util-command "anthy-dic-tool")
|
||
@@ -54,44 +54,44 @@
|
||
|
||
(defun anthy-dic-get-noun-category (word)
|
||
(let
|
||
- ((res '(("$BIJ;l(B" "$BL>;l(B")))
|
||
- (na (y-or-n-p (concat "$B!V(B" word "$B$J!W$H8@$$$^$9$+(B? ")))
|
||
- (sa (y-or-n-p (concat "$B!V(B" word "$B$5!W$H8@$$$^$9$+(B? ")))
|
||
- (suru (y-or-n-p (concat "$B!V(B" word "$B$9$k!W$H8@$$$^$9$+(B? ")))
|
||
- (ind (y-or-n-p (concat "$B!V(B" word "$B!W$OC1FH$GJ8@a$K$J$j$^$9$+(B? ")))
|
||
- (kaku (y-or-n-p (concat "$B!V(B" word "$B$H!W$H8@$$$^$9$+(B? "))))
|
||
- (setq res (cons `("$B$J@\B3(B" ,na) res))
|
||
- (setq res (cons `("$B$5@\B3(B" ,sa) res))
|
||
- (setq res (cons `("$B$9$k@\B3(B" ,suru) res))
|
||
- (setq res (cons `("$B8l44$N$_$GJ8@a(B" ,ind) res))
|
||
- (setq res (cons `("$B3J=u;l@\B3(B" ,kaku) res))
|
||
+ ((res '(("品詞" "名詞")))
|
||
+ (na (y-or-n-p (concat "「" word "な」と言いますか? ")))
|
||
+ (sa (y-or-n-p (concat "「" word "さ」と言いますか? ")))
|
||
+ (suru (y-or-n-p (concat "「" word "する」と言いますか? ")))
|
||
+ (ind (y-or-n-p (concat "「" word "」は単独で文節になりますか? ")))
|
||
+ (kaku (y-or-n-p (concat "「" word "と」と言いますか? "))))
|
||
+ (setq res (cons `("な接続" ,na) res))
|
||
+ (setq res (cons `("さ接続" ,sa) res))
|
||
+ (setq res (cons `("する接続" ,suru) res))
|
||
+ (setq res (cons `("語幹のみで文節" ,ind) res))
|
||
+ (setq res (cons `("格助詞接続" ,kaku) res))
|
||
res))
|
||
|
||
(defun anthy-dic-get-special-noun-category (word)
|
||
(let
|
||
((res '())
|
||
(cat (string-to-int
|
||
- (read-from-minibuffer "1:$B?ML>(B 2:$BCOL>(B: "))))
|
||
+ (read-from-minibuffer "1:人名 2:地名: "))))
|
||
(cond ((= cat 1)
|
||
- (setq res '(("$BIJ;l(B" "$B?ML>(B"))))
|
||
+ (setq res '(("品詞" "人名"))))
|
||
((= cat 2)
|
||
- (setq res '(("$BIJ;l(B" "$BCOL>(B")))))
|
||
+ (setq res '(("品詞" "地名")))))
|
||
res))
|
||
|
||
(defun anthy-dic-get-adjective-category (word)
|
||
- '(("$BIJ;l(B" "$B7AMF;l(B")))
|
||
+ '(("品詞" "形容詞")))
|
||
|
||
(defun anthy-dic-get-av-category (word)
|
||
(let
|
||
- ((res '(("$BIJ;l(B" "$BI{;l(B")))
|
||
- (to (y-or-n-p (concat "$B!V(B" word "$B$H!W$H8@$$$^$9$+(B?")))
|
||
- (taru (y-or-n-p (concat "$B!V(B" word "$B$?$k!W$H8@$$$^$9$+(B?")))
|
||
- (suru (y-or-n-p (concat "$B!V(B" word "$B$9$k!W$H8@$$$^$9$+(B?")))
|
||
- (ind (y-or-n-p (concat "$B!V(B" word "$B!W$OC1FH$GJ8@a$K$J$j$^$9$+(B?"))))
|
||
- (setq res (cons `("$B$H@\B3(B" ,to) res))
|
||
- (setq res (cons `("$B$?$k@\B3(B" ,taru) res))
|
||
- (setq res (cons `("$B$9$k@\B3(B" ,suru) res))
|
||
- (setq res (cons `("$B8l44$N$_$GJ8@a(B" ,ind) res))
|
||
+ ((res '(("品詞" "副詞")))
|
||
+ (to (y-or-n-p (concat "「" word "と」と言いますか?")))
|
||
+ (taru (y-or-n-p (concat "「" word "たる」と言いますか?")))
|
||
+ (suru (y-or-n-p (concat "「" word "する」と言いますか?")))
|
||
+ (ind (y-or-n-p (concat "「" word "」は単独で文節になりますか?"))))
|
||
+ (setq res (cons `("と接続" ,to) res))
|
||
+ (setq res (cons `("たる接続" ,taru) res))
|
||
+ (setq res (cons `("する接続" ,suru) res))
|
||
+ (setq res (cons `("語幹のみで文節" ,ind) res))
|
||
res))
|
||
|
||
;; taken from tooltip.el
|
||
@@ -111,11 +111,11 @@
|
||
""))
|
||
yomi cat)
|
||
(and (string= word "")
|
||
- (setq word (read-from-minibuffer "$BC18l(B($B8l44$N$_(B): ")))
|
||
- (setq yomi (read-from-minibuffer (concat "$BFI$_(B (" word "): ")))
|
||
+ (setq word (read-from-minibuffer "単語(語幹のみ): ")))
|
||
+ (setq yomi (read-from-minibuffer (concat "読み (" word "): ")))
|
||
(setq cat (string-to-int
|
||
(read-from-minibuffer
|
||
- "$B%+%F%4%j!<(B 1:$B0lHLL>;l(B 2:$B$=$NB>$NL>;l(B 3:$B7AMF;l(B 4:$BI{;l(B: ")))
|
||
+ "カテゴリー 1:一般名詞 2:その他の名詞 3:形容詞 4:副詞: ")))
|
||
(cond ((= cat 1)
|
||
(setq param (anthy-dic-get-noun-category word)))
|
||
((= cat 2)
|
||
@@ -127,6 +127,6 @@
|
||
(if param
|
||
(setq res (anthy-add-word yomi 1 word param)))
|
||
(if res
|
||
- (message (concat word "(" yomi ")$B$rEPO?$7$^$7$?(B")))))
|
||
+ (message (concat word "(" yomi ")を登録しました")))))
|
||
|
||
(provide 'anthy-dic)
|
||
diff --git a/src-util/anthy-isearch.el b/src-util/anthy-unicode-isearch.el
|
||
similarity index 91%
|
||
rename from src-util/anthy-isearch.el
|
||
rename to src-util/anthy-unicode-isearch.el
|
||
index 46d186f..85077cc 100644
|
||
--- a/src-util/anthy-isearch.el
|
||
+++ b/src-util/anthy-unicode-isearch.el
|
||
@@ -15,20 +15,20 @@
|
||
|
||
(defvar anthy-isearch-mode-map nil)
|
||
|
||
-;; $B8!:wBP>]$NJ8;zNs$H%W%j%(%G%#%C%H$rF~$l$k%P%C%U%!(B
|
||
+;; 検索対象の文字列とプリエディットを入れるバッファ
|
||
(defconst anthy-isearch-working-buffer " *anthy-isearch*")
|
||
|
||
-;; $B8!:wBP>]$NJ8;zNs$r<hF@$9$k(B
|
||
+;; 検索対象の文字列を取得する
|
||
(defun anthy-isearch-search-string ()
|
||
(with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
|
||
(if (string-equal anthy-preedit "")
|
||
- ;; $B%W%j%(%G%#%C%H$,L5$$;~$O(B
|
||
+ ;; プリエディットが無い時は
|
||
(buffer-string)
|
||
(save-restriction
|
||
(narrow-to-region (point-min) anthy-preedit-start)
|
||
(buffer-string)))))
|
||
|
||
-;; $B8!:wBP>]$NJ8;zNs(B + $BF~NOESCf$NJ8;zNs(B
|
||
+;; 検索対象の文字列 + 入力途中の文字列
|
||
(defun anthy-isearch-search-message ()
|
||
(with-current-buffer (get-buffer-create anthy-isearch-working-buffer)
|
||
(buffer-string)))
|
||
@@ -82,7 +82,7 @@
|
||
map))
|
||
|
||
(defun anthy-isearch-mode-setup ()
|
||
- ;; $B:G=i$O%-!<%^%C%W$r=`Hw$9$k(B
|
||
+ ;; 最初はキーマップを準備する
|
||
(or (keymapp anthy-isearch-mode-map)
|
||
(setq anthy-isearch-mode-map
|
||
(anthy-isearch-setup-keymap (copy-keymap isearch-mode-map))))
|
||
diff --git a/src-util/anthy-unicode-kyuri.el b/src-util/anthy-unicode-kyuri.el
|
||
new file mode 100644
|
||
index 0000000..6fb2575
|
||
--- /dev/null
|
||
+++ b/src-util/anthy-unicode-kyuri.el
|
||
@@ -0,0 +1,210 @@
|
||
+;; anthy-kyuri.el
|
||
+
|
||
+;; Copyright (C) 2005
|
||
+;; Author: Yukihiro Matsumoto <matz@ruby-lang.org>
|
||
+
|
||
+(require 'anthy)
|
||
+
|
||
+(setq anthy-kyuri-mode-hiragana-map
|
||
+ '(
|
||
+ ("bh" . "ぁ") ("h" . "あ") ("bk" . "ぃ") ("k" . "い") ("bj" . "ぅ")
|
||
+ ("j" . "う") ("yj" . "う゛") ("yh" . "う゛ぁ") ("yk" . "う゛ぃ") ("y;" . "う゛ぇ")
|
||
+ ("yl" . "う゛ぉ") ("b;" . "ぇ") (";" . "え") ("bl" . "ぉ") ("l" . "お")
|
||
+ ("dh" . "か") ("qh" . "が") ("dk" . "き") ("du" . "きゃ") ("di" . "きゅ") ("do" . "きょ")
|
||
+ ("duu" . "きゃあ") ("dii" . "きゅう") ("doo" . "きょう")
|
||
+ ("qk" . "ぎ") ("qu" . "ぎゃ") ("qi" . "ぎゅ") ("qo" . "ぎょ")
|
||
+ ("quu" . "ぎゃあ") ("qii" . "ぎゅう") ("qoo" . "ぎょう")
|
||
+ ("dj" . "く") ("qj" . "ぐ") ("d;" . "け") ("q;" . "げ") ("dl" . "こ") ("ql" . "ご")
|
||
+ ("fh" . "さ") ("zh" . "ざ") ("fk" . "し")
|
||
+ ("fu" . "しゃ") ("fi" . "しゅ") ("fo" . "しょ") ("fb;" . "しぇ")
|
||
+ ("fuu" . "しゃあ") ("fii" . "しゅう") ("foo" . "しょう")
|
||
+ ("zk" . "じ") ("zu" . "じゃ") ("zi" . "じゅ") ("zo" . "じょ")
|
||
+ ("zuu" . "じゃあ") ("zii" . "じゅう") ("zoo" . "じょう")
|
||
+ ("fj" . "す") ("zj" . "ず") ("f;" . "せ") ("z;" . "ぜ") ("fl" . "そ") ("zl" . "ぞ")
|
||
+ ("gh" . "た") ("vh" . "だ") ("gk" . "ち")
|
||
+ ("gu" . "ちゃ") ("gi" . "ちゅ") ("go" . "ちょ") ("gb;" . "ちぇ")
|
||
+ ("guu" . "ちゃあ") ("gii" . "ちゅう") ("goo" . "ちょう")
|
||
+ ("vk" . "ぢ") ("vu" . "ぢゃ") ("vi" . "ぢゅ") ("vo" . "ぢょ") ("vb;" . "ぢぇ")
|
||
+ ("vuu" . "ぢゃあ") ("vii" . "ぢゅう")
|
||
+ ("voo" . "ぢょう") ("m" . "っ") ("ddh" . "っか") ("qqh" . "っが") ("ddk" . "っき")
|
||
+ ("ddu" . "っきゃ") ("ddi" . "っきゅ") ("ddo" . "っきょ")
|
||
+ ("dduu" . "っきゃあ") ("ddii" . "っきゅう") ("ddoo" . "っきょう")
|
||
+ ("qqk" . "っぎ") ("qqu" . "っぎゃ") ("qqi" . "っぎゅ") ("qqo" . "っぎょ")
|
||
+ ("qquu" . "っぎゃあ") ("qqii" . "っぎゅう") ("qqoo" . "っぎょう")
|
||
+ ("ddj" . "っく") ("dd;" . "っけ") ("ddl" . "っこ")
|
||
+ ("qqj" . "っぐ") ("qq;" . "っげ") ("qql" . "っご")
|
||
+ ("ffh" . "っさ") ("zzh" . "っざ") ("ffk" . "っし")
|
||
+ ("ffu" . "っしゃ") ("ffi" . "っしゅ") ("ffo" . "っしょ")
|
||
+ ("ffuu" . "っしゃあ") ("ffii" . "っしゅう") ("ffoo" . "っしょう")
|
||
+ ("zzk" . "っじ")
|
||
+ ("zzu" . "っじゃ") ("zzi" . "っじゅ") ("zzo" . "っじょ")
|
||
+ ("zzuu" . "っじゃあ") ("zzii" . "っじゅう") ("zzoo" . "っじょう")
|
||
+ ("ffj" . "っす") ("zzj" . "っず") ("ff;" . "っせ") ("zz;" . "っぜ") ("ffl" . "っそ")
|
||
+ ("zzl" . "っぞ") ("ggh" . "った") ("vvh" . "っだ") ("ggk" . "っち")
|
||
+ ("ggu" . "っちゃ") ("ggi" . "っちゅ") ("ggo" . "っちょ") ("ggb;" . "っちぇ")
|
||
+ ("gguu" . "っちゃあ") ("ggii" . "っちゅう") ("ggoo" . "っちょう")
|
||
+ ("vvk" . "っぢ")
|
||
+ ("vvu" . "っぢゃ") ("vvi" . "っぢゅ") ("vvoo" . "っぢょ")
|
||
+ ("vvuu" . "っぢゃあ") ("vvii" . "っぢゅう") ("vvoo" . "っぢょう")
|
||
+ ("ggj" . "っつ") ("gg;" . "って") ("ggl" . "っと")
|
||
+ ("vvj" . "っづ") ("vv;" . "っで") ("vvl" . "っど")
|
||
+ ("ssh" . "っは") ("cch" . "っば") ("tth" . "っぱ")
|
||
+ ("ttk" . "っひ")
|
||
+ ("ssu" . "っひゃ") ("ssi" . "っひゅ") ("sso" . "っひょ")
|
||
+ ("ssuu" . "っひゃあ") ("ssii" . "っひゅう") ("ssoo" . "っひょう")
|
||
+ ("cck" . "っび")
|
||
+ ("ccu" . "っびゃ") ("ccii" . "っびゅ") ("cco" . "っびょ")
|
||
+ ("ccuu" . "っびゃあ") ("ccii" . "っびゅう") ("ccoo" . "っびょう")
|
||
+ ("ttk" . "っぴ")
|
||
+ ("ttu" . "っぴゃ") ("tti" . "っぴゅ") ("tto" . "っぴょ")
|
||
+ ("ttuu" . "っぴゃあ") ("ttii" . "っぴゅう") ("ttoo" . "っぴょう")
|
||
+ ("ssj" . "っふ")
|
||
+ ("ssbh" . "っふぁ") ("ssbk" . "っふぃ") ("ssb;" . "っふぇ") ("ssbl" . "っふぉ")
|
||
+ ("ccj" . "っぶ") ("ttj" . "っぷ") ("ss;" . "っへ") ("cc;" . "っべ") ("tt;" . "っぺ")
|
||
+ ("ssl" . "っほ") ("ccl" . "っぼ") ("ttl" . "っぽ") ("aah" . "っや") ("aaj" . "っゆ")
|
||
+ ("yyo" . "っよ") ("rra" . "っら") ("rri" . "っり")
|
||
+ ("rru" . "っりゃ") ("rri" . "っりゅ") ("rro" . "っりょ")
|
||
+ ("rruu" . "っりゃあ") ("rrii" . "っりゅう") ("rroo" . "っりょう")
|
||
+ ("rrj" . "っる") ("rr;" . "っれ") ("rrl" . "っろ")
|
||
+ ("gj" . "つ") ("vj" . "づ") ("g;" . "て") ("v;" . "で")
|
||
+ ("vbu" . "でゃ") ("vbk" . "でぃ") ("vbj" . "でゅ") ("vb;" . "でぇ") ("vbo" . "でょ")
|
||
+ ("gbu" . "てゃ") ("gbk" . "てぃ") ("gbj" . "てゅ") ("gbo" . "てょ")
|
||
+ ("gl" . "と") ("vl" . "ど") ("eh" . "な") ("ek" . "に")
|
||
+ ("eu" . "にゃ") ("ei" . "にゅ") ("eo" . "にょ")
|
||
+ ("euu" . "にゃあ") ("eii" . "にゅう") ("eoo" . "にょう")
|
||
+ ("ej" . "ぬ") ("e;" . "ね") ("el" . "の")
|
||
+ ("sh" . "は") ("ch" . "ば") ("th" . "ぱ") ("sk" . "ひ")
|
||
+ ("su" . "ひゃ") ("si" . "ひゅ") ("so" . "ひょ") ("sb;" . "ひぇ")
|
||
+ ("suu" . "ひゃあ") ("sii" . "ひゅう") ("soo" . "ひょう")
|
||
+ ("ck" . "び")
|
||
+ ("cu" . "びゃ") ("ci" . "びゅ") ("co" . "びょ") ("cb;" . "ひょ")
|
||
+ ("cuu" . "びゃあ") ("cii" . "びゅう") ("coo" . "びょう")
|
||
+ ("tk" . "ぴ")
|
||
+ ("tu" . "ぴゃ") ("ti" . "ぴゅ") ("to" . "ぴょ") ("tb;" . "ぴぇ")
|
||
+ ("tuu" . "ぴゃあ") ("tii" . "ぴゅう") ("too" . "ぴょう")
|
||
+ ("sj" . "ふ")
|
||
+ ("sbh" . "ふぁ") ("sbk" . "ふぃ") ("sbj" . "ふぅ") ("sb;" . "ふぇ") ("sbl" . "ふぉ")
|
||
+ ("cj" . "ぶ")
|
||
+ ("cbh" . "ぶぁ") ("cbk" . "ぶぃ") ("cbj" . "ぶぅ") ("cb;" . "ぶぇ") ("cbl" . "ぶぉ")
|
||
+ ("tj" . "ぷ")
|
||
+ ("tbh" . "ぷぁ") ("tbk" . "ぷぃ") ("tbj" . "ぷぅ") ("tb;" . "ぷぇ") ("tbl" . "ぷぉ")
|
||
+ ("s;" . "へ") ("c;" . "べ") ("t;" . "ぺ")
|
||
+ ("sl" . "ほ") ("cl" . "ぼ") ("tl" . "ぽ")
|
||
+ ("wh" . "ま") ("wk" . "み")
|
||
+ ("wu" . "みゃ") ("wi" . "みゅ") ("wo" . "みょ")
|
||
+ ("wuu" . "みゃあ") ("wii" . "みゅう") ("woo" . "みょう")
|
||
+ ("wj" . "む") ("w;" . "め") ("wl" . "も")
|
||
+ ("u" . "ゃ") ("ah" . "や") ("i" . "ゅ") ("aj" . "ゆ") ("o" . "ょ")
|
||
+ ("al" . "よ")
|
||
+ ("rh" . "ら") ("rk" . "り")
|
||
+ ("ru" . "りゃ") ("ri" . "りゅ") ("ro" . "りょ")
|
||
+ ("ruu" . "りゃあ") ("rii" . "りゅう") ("roo" . "りょう")
|
||
+ ("rj" . "る") ("r;" . "れ") ("rl" . "ろ")
|
||
+ ("bxh" . "ゎ") ("xh" . "わ") ("xk" . "ゐ") ("x;" . "ゑ")
|
||
+ ("xbk" . "うぃ") ("xb;" . "うぇ")
|
||
+ ("xl" . "を") ("n" . "ん")
|
||
+ ("p" . "ー") ("zb;" . "じぇ")
|
||
+ ("zp" . "〜") ("z/" . "・") ("zx" . "^^;;;")
|
||
+
|
||
+ ("[" . "「") ("]" . "」") ("{" . "『") ("}" . "』")
|
||
+ ("X1" . "○") ("X!" . "●") ("X2" . "▽") ("X@" . "▼") ("X3" . "△")
|
||
+ ("X#" . "▲") ("X4" . "□") ("X$" . "■") ("X5" . "◇") ("X%" . "◆")
|
||
+ ("X6" . "☆") ("X^" . "★") ("X7" . "◎") ("X&" . "£") ("X8" . "¢")
|
||
+ ("X*" . "×") ("X9" . "♂") ("X(" . "【") ("X0" . "♀") ("X)" . "】")
|
||
+ ("X-" . "〜") ("X_" . "∴") ("X=" . "≒") ("X+" . "±") ("X\\" . "\")
|
||
+ ("X|" . "‖") ("X\`" . "´") ("X~" . "¨") ("Xq" . "《") ("XQ" . "〈")
|
||
+ ("Xw" . "》") ("XW" . "〉") ("Xe" . "々") ("XR" . "仝") ("Xt" . "〆")
|
||
+ ("XT" . "§") ("Xp" . "〒") ("XP" . "↑") ("X[" . "『") ("X]" . "』")
|
||
+ ("X{" . "〔") ("X}" . "〕") ("Xs" . "ヽ") ("XS" . "ヾ") ("Xd" . "ゝ")
|
||
+ ("XD" . "ゞ") ("Xf" . "〃") ("XF" . "→") ("Xg" . "‐") ("Xj" . "↓")
|
||
+ ("XG" . "―") ("Xh" . "←") ("Xk" . "↑") ("Xl" . "→") ("X:" . "゜")
|
||
+ ("X\'" . "‘") ("X\"" . "“") ("Xx" . ":-") ("XX" . ":-)")
|
||
+ ("Xc" . "〇") ("XC" . "℃") ("Xv" . "※") ("XV" . "÷") ("Xb" . "°")
|
||
+ ("XB" . "←") ("Xn" . "′") ("XN" . "↓") ("Xっ" . "″") ("XM" . "〓")
|
||
+ ("X," . "‥") ("X<" . "≦") ("X." . "…") ("X>" . "≧") ("X/" . "・")
|
||
+ ("X?" . "∞") ("z1" . "○") ("z!" . "●") ("z2" . "▽") ("z@" . "▼")
|
||
+ ("z3" . "△") ("z#" . "▲") ("z4" . "□") ("z$" . "■") ("z5" . "◇")
|
||
+ ("z%" . "◆") ("z6" . "☆") ("z^" . "★") ("z7" . "◎") ("z&" . "£")
|
||
+ ("z8" . "¢") ("z*" . "×") ("z9" . "♂") ("z(" . "【") ("z0" . "♀")
|
||
+ ("z)" . "】") ("zp" . "〜") ("z_" . "∴") ("z=" . "≠") ("z+" . "±")
|
||
+ ("z\\" . "\") ("z|" . "‖") ("z\`" . "´") ("z~" . "¨") ("z:" . "゜")
|
||
+ ("z\'" . "‘") ("z\"" . "“") ("z," . "‥") ("z<" . "≦") ("z." . "…")
|
||
+ ("z>" . "≧") ("z/" . "・") ("z?" . "∞") ("z[" . "『") ("z]" . "』")
|
||
+ ("z{" . "〔") ("z}" . "〕") ("zx" . "^^;;;") ("zX" . "(^^)") ("zs" . " ")
|
||
+ ("@ " . " ") ("@/" . "/") ("@\\" . "\") ("@@" . "@") ("@," . ",")
|
||
+ ("@." . ".") ("@~" . "〜") ("@-" . "―") ("@||" . "‖") ("@|" . "|")
|
||
+ ("@\"" . "〃") ("@*" . "×") ("@=" . "〓") ("@3" . "…") ("@2" . "‥")
|
||
+ ("@0" . "○") ("@[" . "[") ("@]" . "]") ("@{" . "{") ("@}" . "}")
|
||
+ ("@<" . "《") ("@>" . "》")
|
||
+
|
||
+ ("Z0" . "0") ("Z1" . "1") ("Z2" . "2") ("Z3" . "3") ("Z4" . "4")
|
||
+ ("Z5" . "5") ("Z6" . "6") ("Z7" . "7") ("Z8" . "8") ("Z9" . "9")
|
||
+ ("ZA" . "A") ("ZB" . "B") ("ZC" . "C") ("ZD" . "D") ("ZE" . "E") ("ZF" . "F")
|
||
+ ("ZG" . "G") ("ZH" . "H") ("ZI" . "I") ("ZJ" . "J") ("ZK" . "K") ("ZL" . "L")
|
||
+ ("ZM" . "M") ("ZN" . "N") ("ZO" . "O") ("ZP" . "P") ("ZQ" . "Q") ("ZR" . "R")
|
||
+ ("ZS" . "S") ("ZT" . "T") ("ZU" . "U") ("ZV" . "V") ("ZW" . "W") ("ZX" . "X")
|
||
+ ("ZY" . "Y") ("ZZ" . "Z")
|
||
+ ("Za" . "a") ("Zb" . "b") ("Zc" . "c") ("Zd" . "d") ("Ze" . "e") ("Zf" . "f")
|
||
+ ("Zg" . "g") ("Zh" . "h") ("Zi" . "i") ("Zj" . "j") ("Zk" . "k") ("Zl" . "l")
|
||
+ ("Zm" . "m") ("Zn" . "n") ("Zo" . "o") ("Zp" . "p") ("Zq" . "q") ("Zr" . "r")
|
||
+ ("Zs" . "s") ("Zt" . "t") ("Zu" . "u") ("Zv" . "v") ("Zw" . "w") ("Zx" . "x")
|
||
+ ("Zy" . "y") ("Zz" . "z")
|
||
+ ("Z!" . "!") ("Z@" . "@") ("Z#" . "#") ("Z$" . "$") ("Z%" . "%")
|
||
+ ("Z^" . "^") ("Z&" . "&") ("Z*" . "*") ("Z(" . "(") ("Z)" . ")") ("Z-" . "−")
|
||
+ ("Z=" . "=") ("Z`" . "`") ("Z\\" . "¥") ("Z|" . "|") ("Z_" . "_") ("Z+" . "+")
|
||
+ ("Z~" . " ̄") ("Z[" . "[") ("Z]" . "]") ("Z{" . "{") ("Z}" . "}") ("Z:" . ":")
|
||
+ ("Z;" . ";") ("Z\"" . "”") ("Z\\'" . "’") ("Z<" . "<") ("Z>" . ">") ("Z?" . "?")
|
||
+ ("Z/" . "/") ("Z," . ",") ("Z." . ".")
|
||
+
|
||
+ ("!" . "!") ("\"" . "\"") ("#" . "#") ("$" . "$") ("%" . "%") ("&" . "&")
|
||
+ ("'" . "'") ("(" . "(") (")" . ")") ("|" . "|")
|
||
+ ("*" . "*") ("+" . "+") ("`" . "`") ("-" . "-") ("/" . "/")
|
||
+ (":" . ":") ("<" . "<") ("=" . "=") (">" . ">") ("@" . "@")
|
||
+ ("0" . "0") ("1" . "1") ("2" . "2") ("3" . "3") ("4" . "4")
|
||
+ ("5" . "5") ("6" . "6") ("7" . "7") ("8" . "8") ("9" . "9")
|
||
+ ))
|
||
+
|
||
+;;
|
||
+;; toggleの変更
|
||
+;;
|
||
+(defun anthy-send-change-toggle-command (str)
|
||
+ (anthy-send-recv-command
|
||
+ (concat " CHANGE_TOGGLE ~\n")))
|
||
+
|
||
+(defun anthy-kyuri ()
|
||
+ (setq anthy-rkmap-keybind nil)
|
||
+ (anthy-send-recv-command " SET_PREEDIT_MODE 0\n")
|
||
+ (anthy-set-break-into-roman t)
|
||
+ (anthy-send-change-toggle-command "~")
|
||
+ (anthy-clear-map)
|
||
+ (mapcar (lambda (x)
|
||
+ (anthy-change-hiragana-map (car x) (cdr x)))
|
||
+ anthy-kyuri-mode-hiragana-map)
|
||
+ )
|
||
+
|
||
+(define-key anthy-mode-map (char-to-string 10) 'newline-and-indent)
|
||
+(define-key anthy-mode-map (char-to-string 17) 'quoted-insert)
|
||
+
|
||
+(anthy-kyuri)
|
||
+
|
||
+(defun anthy-on ()
|
||
+ (interactive)
|
||
+ (anthy-mode-on))
|
||
+
|
||
+(defun anthy-off ()
|
||
+ (interactive)
|
||
+ (anthy-mode-off))
|
||
+
|
||
+(defun anthy-force-off ()
|
||
+ (interactive)
|
||
+ (anthy-handle-normal-key "(enter)")
|
||
+ (anthy-off))
|
||
+
|
||
+(global-set-key "\C-o" 'anthy-on)
|
||
+(global-set-key "\C-z" 'anthy-off)
|
||
+(global-set-key "\C-c\C-t" 'anthy-add-word-interactive)
|
||
+(define-key anthy-preedit-keymap "\C-z" 'anthy-force-off)
|
||
+(setq anthy-wide-space " ")
|
||
+(setq anthy-use-hankaku-kana nil)
|
||
+
|
||
+
|
||
diff --git a/src-util/anthy.el b/src-util/anthy-unicode.el
|
||
similarity index 82%
|
||
rename from src-util/anthy.el
|
||
rename to src-util/anthy-unicode.el
|
||
index 8980957..35e2b82 100644
|
||
--- a/src-util/anthy.el
|
||
+++ b/src-util/anthy-unicode.el
|
||
@@ -11,49 +11,49 @@
|
||
|
||
;;; Commentary:
|
||
;;
|
||
-;; $B$+$J4A;zJQ49%(%s%8%s(B Anthy$B$r(B emacs$B$+$i;H$&$?$a$N%W%m%0%i%`(B
|
||
-;; Anthy$B%i%$%V%i%j$r;H$&$?$a$N%3%^%s%I(Banthy-agent$B$r5/F0$7$F!"(B
|
||
-;; anthy-agent$B$H%Q%$%W$GDL?.$r$9$k$3$H$K$h$C$FJQ49$NF0:n$r9T$&(B
|
||
+;; かな漢字変換エンジン Anthyを emacsから使うためのプログラム
|
||
+;; Anthyライブラリを使うためのコマンドanthy-agentを起動して、
|
||
+;; anthy-agentとパイプで通信をすることによって変換の動作を行う
|
||
;;
|
||
;;
|
||
-;; Funded by IPA$BL$F'%=%U%H%&%'%"AOB$;v6H(B 2001 10/10
|
||
+;; Funded by IPA未踏ソフトウェア創造事業 2001 10/10
|
||
;;
|
||
-;; $B3+H/$O(Bemacs21.2$B>e$G9T$C$F$$$F(Bminor-mode
|
||
-;; $B$b$7$/$O(Bleim$B$H$7$F$b;HMQ$G$-$k(B
|
||
+;; 開発はemacs21.2上で行っていてminor-mode
|
||
+;; もしくはleimとしても使用できる
|
||
;; (set-input-method 'japanese-anthy)
|
||
;;
|
||
-;; emacs19(mule),20,21,xemacs$B$GF0:n$9$k(B
|
||
+;; emacs19(mule),20,21,xemacsで動作する
|
||
;;
|
||
;;
|
||
-;; 2003-08-24 XEmacs $B$N8uJdA*Br%b!<%I%P%0$KBP1~(B(suzuki)
|
||
+;; 2003-08-24 XEmacs の候補選択モードバグに対応(suzuki)
|
||
;;
|
||
;; 2001-11-16 EUC-JP -> ISO-2022-JP
|
||
;;
|
||
;; TODO
|
||
-;; $B8uJdA*Br%b!<%I$G8uJd$r$$$C$-$K<!$N%Z!<%8$K$$$+$J$$$h$&$K$9$k(B(2ch$B%9%l(B78)
|
||
-;; minibufffer$B$N07$$(B
|
||
-;; isearch$BBP1~(B
|
||
+;; 候補選択モードで候補をいっきに次のページにいかないようにする(2chスレ78)
|
||
+;; minibuffferの扱い
|
||
+;; isearch対応
|
||
;;
|
||
-;; $BMQ8l(B
|
||
-;; commit $BJ8;zNs$r3NDj$9$k$3$H(B
|
||
-;; preedit($B%W%j%(%G%#%C%H(B) $B3NDjA0$NJ8;zNs%"%s%@!<%i%$%s$d6/D4$NB0@-$b4^$`(B
|
||
-;; segment($BJ8@a(B) $BJ8K!E*$JJ8@a$G$O$J$/!$F1$8B0@-$NJ8;zNs$N$+$?$^$j(B
|
||
+;; 用語
|
||
+;; commit 文字列を確定すること
|
||
+;; preedit(プリエディット) 確定前の文字列アンダーラインや強調の属性も含む
|
||
+;; segment(文節) 文法的な文節ではなく,同じ属性の文字列のかたまり
|
||
;;
|
||
|
||
;;; Code:
|
||
;(setq debug-on-error t)
|
||
|
||
(defvar anthy-default-enable-enum-candidate-p t
|
||
- "$B$3$l$r@_Dj$9$k$H<!8uJd$r?t2s2!$7$?:]$K8uJd$N0lMw$+$iA*Br$9$k%b!<%I$K$J$j$^$9!%(B")
|
||
+ "これを設定すると次候補を数回押した際に候補の一覧から選択するモードになります.")
|
||
|
||
(defvar anthy-personality ""
|
||
- "$B%Q!<%=%J%j%F%#(B")
|
||
+ "パーソナリティ")
|
||
|
||
(defvar anthy-preedit-begin-mark "|"
|
||
- "$BJQ49;~$N@hF,$KIU$/J8;zNs(B")
|
||
+ "変換時の先頭に付く文字列")
|
||
|
||
(defvar anthy-preedit-delim-mark "|"
|
||
- "$BJQ49;~$NJ8@a$N6h@Z$j$K;H$o$l$kJ8;zNs(B")
|
||
+ "変換時の文節の区切りに使われる文字列")
|
||
|
||
(defvar anthy-accept-timeout 50)
|
||
(if (string-match "^22\." emacs-version)
|
||
@@ -61,11 +61,11 @@
|
||
|
||
(defconst anthy-working-buffer " *anthy*")
|
||
(defvar anthy-agent-process nil
|
||
- "anthy-agent$B$N%W%m%;%9(B")
|
||
+ "anthy-agentのプロセス")
|
||
(defvar anthy-use-hankaku-kana t)
|
||
;;
|
||
(defvar anthy-agent-command-list '("anthy-agent")
|
||
- "anthy-agent$B$N(BPATH$BL>(B")
|
||
+ "anthy-agentのPATH名")
|
||
|
||
;; face
|
||
(defvar anthy-highlight-face nil)
|
||
@@ -82,7 +82,7 @@
|
||
(require 'overlay))
|
||
;;
|
||
(defvar anthy-mode-map nil
|
||
- "Anthy$B$N(BASCII$B%b!<%I$N%-!<%^%C%W(B")
|
||
+ "AnthyのASCIIモードのキーマップ")
|
||
(or anthy-mode-map
|
||
(let ((map (make-keymap))
|
||
(i 32))
|
||
@@ -94,24 +94,24 @@
|
||
(setq anthy-mode-map map)))
|
||
;;
|
||
(defvar anthy-preedit-keymap nil
|
||
- "Anthy$B$N(Bpreedit$B$N%-!<%^%C%W(B")
|
||
+ "Anthyのpreeditのキーマップ")
|
||
(or anthy-preedit-keymap
|
||
(let ((map (make-keymap))
|
||
(i 0))
|
||
- ;; $BDL>o$NJ8;z$KBP$7$F(B
|
||
+ ;; 通常の文字に対して
|
||
(while (< i 128)
|
||
(define-key map (char-to-string i) 'anthy-insert)
|
||
(setq i (+ 1 i)))
|
||
- ;; $BJ8@a$N?-=L(B
|
||
+ ;; 文節の伸縮
|
||
(define-key map [(shift left)] 'anthy-insert)
|
||
(define-key map [(shift right)] 'anthy-insert)
|
||
- ;; $BJ8@a$N0\F0(B
|
||
+ ;; 文節の移動
|
||
(define-key map [left] 'anthy-insert)
|
||
(define-key map [right] 'anthy-insert)
|
||
(define-key map [backspace] 'anthy-insert)
|
||
(setq anthy-preedit-keymap map)))
|
||
|
||
-;; anthy-agent$B$KAw$k:]$K%-!<$r%(%s%3!<%I$9$k$?$a$N%F!<%V%k(B
|
||
+;; anthy-agentに送る際にキーをエンコードするためのテーブル
|
||
(defvar anthy-keyencode-alist
|
||
'((1 . "(ctrl A)") ;; \C-a
|
||
(2 . "(left)") ;; \C-b
|
||
@@ -144,19 +144,19 @@
|
||
((right) . "(right)")
|
||
((left) . "(left)")
|
||
((up) . "(up)"))
|
||
- "$B%-!<$N%$%Y%s%H$r(Banthy-agent$B$KAw$k$?$a$NBP1~I=(B")
|
||
+ "キーのイベントをanthy-agentに送るための対応表")
|
||
|
||
-;; $B%b!<%I%i%$%s$NJ8;zNs(B
|
||
+;; モードラインの文字列
|
||
(defvar anthy-mode-line-string-alist
|
||
- '(("hiragana" . " $B$"(B")
|
||
- ("katakana" . " $B%"(B")
|
||
+ '(("hiragana" . " あ")
|
||
+ ("katakana" . " ア")
|
||
("alphabet" . " A")
|
||
- ("walphabet" . " $B#A(B")
|
||
- ("hankaku_kana" . " (I1(B")
|
||
+ ("walphabet" . " A")
|
||
+ ("hankaku_kana" . " (I1")
|
||
)
|
||
- "$B%b!<%IL>$H%b!<%I%i%$%s$NJ8;zNs$NBP1~I=(B")
|
||
+ "モード名とモードラインの文字列の対応表")
|
||
|
||
-;; $B:G8e$K3d$jEv$F$?(Bcontext id
|
||
+;; 最後に割り当てたcontext id
|
||
(defvar anthy-last-context-id 1)
|
||
|
||
;; From skk-macs.el From viper-util.el. Welcome!
|
||
@@ -171,36 +171,36 @@
|
||
))
|
||
|
||
;; buffer local variables
|
||
-(anthy-deflocalvar anthy-context-id nil "$B%3%s%F%-%9%H$N(Bid")
|
||
-; $B%b!<%I$N4IM}(B
|
||
+(anthy-deflocalvar anthy-context-id nil "コンテキストのid")
|
||
+; モードの管理
|
||
(anthy-deflocalvar anthy-minor-mode nil)
|
||
(anthy-deflocalvar anthy-mode nil)
|
||
(anthy-deflocalvar anthy-leim-active-p nil)
|
||
(anthy-deflocalvar anthy-saved-mode nil)
|
||
-; $B%W%j%(%G%#%C%H(B
|
||
+; プリエディット
|
||
(anthy-deflocalvar anthy-preedit "")
|
||
(anthy-deflocalvar anthy-preedit-start 0)
|
||
(anthy-deflocalvar anthy-preedit-overlays '())
|
||
(anthy-deflocalvar anthy-mode-line-string " A")
|
||
-; $B8uJdNs5s(B
|
||
+; 候補列挙
|
||
(anthy-deflocalvar anthy-enum-candidate-p nil)
|
||
(anthy-deflocalvar anthy-enum-rcandidate-p nil)
|
||
(anthy-deflocalvar anthy-candidate-minibuffer "")
|
||
(anthy-deflocalvar anthy-enum-candidate-list '()
|
||
- "$B:#Ns5s$7$F$$$k8uJd$N>pJs(B(($B2hLLFb$N(Bindex $B8uJd$N(Bindex . $B8uJdJ8;zNs(B) ..)")
|
||
+ "今列挙している候補の情報((画面内のindex 候補のindex . 候補文字列) ..)")
|
||
(anthy-deflocalvar anthy-enable-enum-candidate-p
|
||
(cons anthy-default-enable-enum-candidate-p nil)
|
||
- "$B$3$N%P%C%U%!$G8uJd$NNs5s$r9T$&$+$I$&$+(B")
|
||
+ "このバッファで候補の列挙を行うかどうか")
|
||
(anthy-deflocalvar anthy-current-candidate-index 0)
|
||
(anthy-deflocalvar anthy-current-candidate-layout-begin-index 0)
|
||
(anthy-deflocalvar anthy-current-candidate-layout-end-index 0)
|
||
-; $BF~NO>uBV(B
|
||
+; 入力状態
|
||
(anthy-deflocalvar anthy-current-rkmap "hiragana")
|
||
; undo
|
||
(anthy-deflocalvar anthy-buffer-undo-list-saved nil)
|
||
|
||
;;
|
||
-(defvar anthy-wide-space "$B!!(B" "$B%9%Z!<%9$r2!$7$?;~$K=P$FMh$kJ8;z(B")
|
||
+(defvar anthy-wide-space " " "スペースを押した時に出て来る文字")
|
||
|
||
;;; setup minor-mode
|
||
;; minor-mode-alist
|
||
@@ -220,14 +220,14 @@
|
||
|
||
;;
|
||
(defun anthy-process-sentinel (proc stat)
|
||
- "$B%W%m%;%9$N>uBV$,JQ2=$7$?$i;2>H$r>C$7$F!$<!$K:F5/F0$G$-$k$h$&$K$9$k(B"
|
||
+ "プロセスの状態が変化したら参照を消して,次に再起動できるようにする"
|
||
(message "%s" stat)
|
||
(anthy-mode-off)
|
||
(setq anthy-agent-process nil))
|
||
|
||
;;; status
|
||
(defun anthy-update-mode-line ()
|
||
- "$B%b!<%I%i%$%s$r99?7$9$k(B"
|
||
+ "モードラインを更新する"
|
||
(let ((a (assoc anthy-current-rkmap anthy-mode-line-string-alist)))
|
||
(if a
|
||
(progn
|
||
@@ -238,7 +238,7 @@
|
||
|
||
;;; preedit control
|
||
(defun anthy-erase-preedit ()
|
||
- "$B%W%j%(%G%#%C%H$rA4It>C$9(B"
|
||
+ "プリエディットを全部消す"
|
||
(if (> (string-width anthy-preedit) 0)
|
||
(let* ((str anthy-preedit)
|
||
(len (length str))
|
||
@@ -250,13 +250,13 @@
|
||
(setq anthy-preedit-overlays nil))
|
||
|
||
(defun anthy-select-face-by-attr (attr)
|
||
- "$BJ8@a$NB0@-$K1~$8$?(Bface$B$rJV$9(B"
|
||
+ "文節の属性に応じたfaceを返す"
|
||
(if (memq 'RV attr)
|
||
'anthy-highlight-face
|
||
'anthy-underline-face))
|
||
|
||
(defun anthy-enable-preedit-keymap ()
|
||
- "$B%-!<%^%C%W$r%W%j%(%G%#%C%H$NB8:_$9$k;~$N$b$N$K@ZBX$($k(B"
|
||
+ "キーマップをプリエディットの存在する時のものに切替える"
|
||
; (setq anthy-saved-buffer-undo-list buffer-undo-list)
|
||
; (buffer-disable-undo)
|
||
(setcdr
|
||
@@ -264,7 +264,7 @@
|
||
anthy-preedit-keymap))
|
||
|
||
(defun anthy-disable-preedit-keymap ()
|
||
- "$B%-!<%^%C%W$r%W%j%(%G%#%C%H$NB8:_$7$J$$;~$N$b$N$K@ZBX$($k(B"
|
||
+ "キーマップをプリエディットの存在しない時のものに切替える"
|
||
; (buffer-enable-undo)
|
||
; (setq buffer-undo-list anthy-saved-buffer-undo-list)
|
||
(setcdr
|
||
@@ -273,17 +273,17 @@
|
||
(anthy-update-mode-line))
|
||
|
||
(defun anthy-insert-preedit-segment (str attr)
|
||
- "$B%W%j%(%G%#%C%H$r0lJ8@aJ8DI2C$9$k(B"
|
||
+ "プリエディットを一文節文追加する"
|
||
(let ((start (point))
|
||
(end) (ol))
|
||
(cond ((or (memq 'ENUM attr) (memq 'ENUMR attr))
|
||
(setq str (concat "<" str ">")))
|
||
((memq 'RV attr)
|
||
(setq str (concat "[" str "]"))))
|
||
- ; $B%W%j%(%G%#%C%H$NJ8;zNs$rDI2C$9$k(B
|
||
+ ; プリエディットの文字列を追加する
|
||
(insert-and-inherit str)
|
||
(setq end (point))
|
||
- ;; overlay$B$K$h$C$FB0@-$r@_Dj$9$k(B
|
||
+ ;; overlayによって属性を設定する
|
||
(setq ol (make-overlay start end))
|
||
(overlay-put ol 'face (anthy-select-face-by-attr attr))
|
||
(setq anthy-preedit-overlays
|
||
@@ -317,7 +317,7 @@
|
||
|
||
;;
|
||
(defun anthy-check-context-id ()
|
||
- "$B%P%C%U%!$K%3%s%F%-%9%H(Bid$B$,3d$j?6$i$l$F$$$k$+$r%A%'%C%/$9$k(B"
|
||
+ "バッファにコンテキストidが割り振られているかをチェックする"
|
||
(if (null anthy-context-id)
|
||
(progn
|
||
(setq anthy-context-id anthy-last-context-id)
|
||
@@ -325,12 +325,12 @@
|
||
(+ anthy-last-context-id 1)))))
|
||
|
||
(defun anthy-get-candidate (idx)
|
||
- "agent$B$+$i8uJd$r0l$D<hF@$9$k(B"
|
||
+ "agentから候補を一つ取得する"
|
||
(anthy-send-recv-command
|
||
(concat " GET_CANDIDATE "
|
||
(number-to-string idx) "\n")))
|
||
|
||
-;; $B8uJd%j%9%H$+$i%_%K%P%C%U%!$KI=<($9$kJ8;zNs$r9=@.$9$k(B
|
||
+;; 候補リストからミニバッファに表示する文字列を構成する
|
||
(defun anthy-make-candidate-minibuffer-string ()
|
||
(let ((cand-list anthy-enum-candidate-list)
|
||
(cur-elm)
|
||
@@ -350,7 +350,7 @@
|
||
anthy-candidate-minibuffer))
|
||
(setq cand-list (cdr cand-list)))))
|
||
|
||
-;; $BI=<($9$k8uJd$N%j%9%H$K2hLLFb$G$N%$%s%G%C%/%9$rIU$1$k(B
|
||
+;; 表示する候補のリストに画面内でのインデックスを付ける
|
||
(defun anthy-add-candidate-index (lst)
|
||
(let ((i 0)
|
||
(res nil))
|
||
@@ -364,7 +364,7 @@
|
||
res))
|
||
|
||
|
||
-;; $BJ8;z$NI}$r7W;;$7$F!"I=<($9$k8uJd$N%j%9%H$r:n$k(B
|
||
+;; 文字の幅を計算して、表示する候補のリストを作る
|
||
(defun anthy-make-candidate-index-list (base nr l2r)
|
||
(let ((width (frame-width))
|
||
(errorp nil)
|
||
@@ -401,22 +401,22 @@
|
||
lst)))
|
||
|
||
|
||
-;; $BI=<($9$k8uJd$N%j%9%H$r:n$k(B
|
||
+;; 表示する候補のリストを作る
|
||
(defun anthy-calc-candidate-layout (base nr l2r)
|
||
(let
|
||
((lst (anthy-make-candidate-index-list base nr l2r)))
|
||
- ;;$B%+%l%s%H$N8uJdHV9f$r@_Dj$9$k(B
|
||
+ ;;カレントの候補番号を設定する
|
||
(if l2r
|
||
(progn
|
||
- ;; $B:8$+$i1&$N>l9g(B
|
||
- ;; index$B$r0lHV1&$N8uJd$K@_Dj$9$k(B
|
||
+ ;; 左から右の場合
|
||
+ ;; indexを一番右の候補に設定する
|
||
(anthy-get-candidate (car (car lst)))
|
||
(setq lst (reverse lst))
|
||
(setq anthy-current-candidate-index (car (car lst))))
|
||
(progn
|
||
- ;; $B1&$+$i:8$N>l9g(B
|
||
+ ;; 右から左の場合
|
||
(setq anthy-current-candidate-index (car (car (reverse lst))))))
|
||
- ;;$B7k2L$r%;%C%H(B
|
||
+ ;;結果をセット
|
||
(setq anthy-enum-candidate-list
|
||
(if lst
|
||
(anthy-add-candidate-index lst)
|
||
@@ -424,15 +424,15 @@
|
||
|
||
;;
|
||
(defun anthy-layout-candidate (idx nr)
|
||
- "$B8uJd%j%9%H$r(Bminibuffer$B$X%l%$%"%&%H$9$k(B"
|
||
+ "候補リストをminibufferへレイアウトする"
|
||
(setq anthy-candidate-minibuffer "")
|
||
(setq anthy-enum-candidate-list '())
|
||
- ;; $B:8(B->$B1&(B or $B1&(B->$B:8$K%l%$%"%&%H$9$k(B
|
||
+ ;; 左->右 or 右->左にレイアウトする
|
||
(if anthy-enum-candidate-p
|
||
(anthy-calc-candidate-layout idx nr 't)
|
||
(anthy-calc-candidate-layout idx nr nil))
|
||
(anthy-make-candidate-minibuffer-string)
|
||
- ;; $B7k2L$rI=<($9$k(B
|
||
+ ;; 結果を表示する
|
||
(if anthy-enum-candidate-list
|
||
(progn
|
||
(message "%s" anthy-candidate-minibuffer)
|
||
@@ -444,7 +444,7 @@
|
||
nil))
|
||
|
||
(defun anthy-update-preedit (stat ps)
|
||
- "$B%W%j%(%G%#%C%H$r99?7$9$k(B"
|
||
+ "プリエディットを更新する"
|
||
(let ((cursor-pos nil)
|
||
(num-candidate 0)
|
||
(idx-candidate 0)
|
||
@@ -454,7 +454,7 @@
|
||
;; erase old preedit
|
||
(anthy-erase-preedit)
|
||
|
||
- ;; $BF~NO%-%c%s%;%k;~$K(Bundo$B%j%9%H$r7R$2$k(B
|
||
+ ;; 入力キャンセル時にundoリストを繋げる
|
||
(if (and (= (length ps) 0) anthy-buffer-undo-list-saved )
|
||
(progn
|
||
; (message "enable")
|
||
@@ -474,7 +474,7 @@
|
||
(concat anthy-preedit anthy-preedit-begin-mark))
|
||
(anthy-insert-preedit-segment anthy-preedit-begin-mark '())
|
||
|
||
- ;; $BF~NO3+;O$HF1;~$K(Bundo$B%j%9%H$rL58z2=(B
|
||
+ ;; 入力開始と同時にundoリストを無効化
|
||
(if (not anthy-buffer-undo-list-saved)
|
||
(progn
|
||
;(message "disable")
|
||
@@ -487,7 +487,7 @@
|
||
|
||
))
|
||
|
||
- ;; $B3FJ8@a$KBP$7$F(B
|
||
+ ;; 各文節に対して
|
||
(while ps
|
||
(let ((cur (car ps)))
|
||
(setq ps (cdr ps))
|
||
@@ -503,12 +503,12 @@
|
||
(attr (car cur)))
|
||
(setq str (anthy-insert-preedit-segment str attr))
|
||
(cond ((and (car anthy-enable-enum-candidate-p) (memq 'ENUM attr))
|
||
- ;; $B=gJ}8~$N8uJdNs5s(B
|
||
+ ;; 順方向の候補列挙
|
||
(setq anthy-enum-candidate-p t)
|
||
(setq idx-candidate idx)
|
||
(setq num-candidate nr))
|
||
((and (car anthy-enable-enum-candidate-p) (memq 'ENUMR attr))
|
||
- ;; $B5UJ}8~$N8uJdNs5s(B
|
||
+ ;; 逆方向の候補列挙
|
||
(setq anthy-enum-rcandidate-p t)
|
||
(setq idx-candidate idx)
|
||
(setq num-candidate nr)))
|
||
@@ -519,19 +519,19 @@
|
||
(setq anthy-preedit
|
||
(concat anthy-preedit anthy-preedit-delim-mark))
|
||
(anthy-insert-preedit-segment anthy-preedit-delim-mark '()))))))))
|
||
- ;; $B8uJd0lMw$NI=<(3+;O%A%'%C%/(B
|
||
+ ;; 候補一覧の表示開始チェック
|
||
(if (and (not enum-candidate)
|
||
(or anthy-enum-candidate-p anthy-enum-rcandidate-p))
|
||
(setq anthy-current-candidate-layout-begin-index 0))
|
||
- ;; $B8uJd$NNs5s$r9T$&(B
|
||
+ ;; 候補の列挙を行う
|
||
(if (or anthy-enum-candidate-p anthy-enum-rcandidate-p)
|
||
(anthy-layout-candidate idx-candidate num-candidate))
|
||
- ;; preedit$B$N(Bkeymap$B$r99?7$9$k(B
|
||
+ ;; preeditのkeymapを更新する
|
||
(if (member stat '(2 3 4))
|
||
(anthy-enable-preedit-keymap))
|
||
(if cursor-pos (goto-char cursor-pos))))
|
||
|
||
-; suzuki : Emacs / XEmacs $B$G6&DL$N4X?tDj5A(B
|
||
+; suzuki : Emacs / XEmacs で共通の関数定義
|
||
(defun anthy-encode-key (ch)
|
||
(let ((c (assoc ch anthy-keyencode-alist)))
|
||
(if c
|
||
@@ -558,7 +558,7 @@
|
||
(commit "")
|
||
(commitlen nil)
|
||
(preedit nil))
|
||
- ;; $B3FJ8@a$r=hM}$9$k(B
|
||
+ ;; 各文節を処理する
|
||
(while body
|
||
(let* ((cur (car body))
|
||
(pe nil))
|
||
@@ -577,22 +577,22 @@
|
||
(setq pe (list cur)))
|
||
(if pe
|
||
(setq preedit (append preedit pe)))))
|
||
- ;; $B%3%_%C%H$5$l$?J8@a$r=hM}$9$k(B
|
||
+ ;; コミットされた文節を処理する
|
||
; (anthy-restore-undo-list commit)
|
||
(if (> (string-width commit) 0)
|
||
(progn
|
||
(setq commitlen (length commit))
|
||
(anthy-erase-preedit)
|
||
(anthy-disable-preedit-keymap)
|
||
- ; $B@h$K%3%_%C%H$5$;$F$*$/(B
|
||
+ ; 先にコミットさせておく
|
||
(insert-and-inherit commit)
|
||
(anthy-do-auto-fill)
|
||
|
||
- ;; $B%3%_%C%H;~$K7R$2$k(B
|
||
+ ;; コミット時に繋げる
|
||
(if anthy-buffer-undo-list-saved
|
||
(progn
|
||
;(message "enable")
|
||
- ; $BI|5"$5$;$kA0$K!$:#(Bcommit$B$7$?FbMF$r%j%9%H$KDI2C(B
|
||
+ ; 復帰させる前に,今commitした内容をリストに追加
|
||
(setq anthy-buffer-undo-list
|
||
(cons (cons anthy-preedit-start
|
||
(+ anthy-preedit-start commitlen))
|
||
@@ -668,23 +668,23 @@
|
||
|
||
;;
|
||
(defun anthy-insert (&optional arg)
|
||
- "Anthy$B$N%-!<%O%s%I%i(B"
|
||
+ "Anthyのキーハンドラ"
|
||
(interactive "*p")
|
||
- ;; suzuki : last-command-char $B$r(B (anthy-last-command-char) $B$KJQ99(B
|
||
+ ;; suzuki : last-command-char を (anthy-last-command-char) に変更
|
||
(let* ((ch (anthy-last-command-char))
|
||
(chenc (anthy-encode-key ch)))
|
||
(anthy-handle-key ch chenc)))
|
||
|
||
(defun anthy-handle-key (ch chenc)
|
||
(cond
|
||
- ;; $B8uJdA*Br%b!<%I$+$i8uJd$rA*$V(B
|
||
+ ;; 候補選択モードから候補を選ぶ
|
||
((and (or anthy-enum-candidate-p anthy-enum-rcandidate-p)
|
||
(integerp ch)
|
||
(assq (car (rassoc (char-to-string ch)
|
||
anthy-select-candidate-keybind))
|
||
anthy-enum-candidate-list))
|
||
(anthy-insert-select-candidate ch))
|
||
- ;; $B%-!<%^%C%W$rJQ99$9$k%3%^%s%I$r=hM}$9$k(B
|
||
+ ;; キーマップを変更するコマンドを処理する
|
||
((and (anthy-find-rkmap-keybind ch)
|
||
(string-equal anthy-preedit ""))
|
||
(let ((mapname (cdr (anthy-find-rkmap-keybind ch))))
|
||
@@ -696,11 +696,11 @@
|
||
(cdr (assoc (cons anthy-current-rkmap ch)
|
||
anthy-rkmap-keybind)))
|
||
(anthy-update-mode-line))))))
|
||
- ;; $B%"%k%U%!%Y%C%H%b!<%I$N>l9g$OD>@\F~NO(B
|
||
+ ;; アルファベットモードの場合は直接入力
|
||
((and (string-equal anthy-current-rkmap "alphabet")
|
||
(string-equal anthy-preedit ""))
|
||
(self-insert-command 1))
|
||
- ;; $B%W%j%(%G%#%C%H$,$J$/$F%9%Z!<%9$,2!$5$l$?(B
|
||
+ ;; プリエディットがなくてスペースが押された
|
||
((and
|
||
(string-equal anthy-preedit "")
|
||
(= ch 32)
|
||
@@ -711,7 +711,7 @@
|
||
(anthy-do-auto-fill)))
|
||
((or anthy-enum-candidate-p anthy-enum-rcandidate-p)
|
||
(anthy-handle-enum-candidate-mode chenc))
|
||
- ;; $BIaDL$NF~NO(B
|
||
+ ;; 普通の入力
|
||
(t
|
||
(anthy-handle-normal-key chenc))))
|
||
|
||
@@ -858,13 +858,13 @@
|
||
(anthy-select-map "hankaku_kana"))
|
||
;;
|
||
;;
|
||
-;; leim $B$N(B inactivate
|
||
+;; leim の inactivate
|
||
;;
|
||
(defun anthy-leim-inactivate ()
|
||
(setq anthy-leim-active-p nil)
|
||
(anthy-update-mode))
|
||
;;
|
||
-;; leim $B$N(B activate
|
||
+;; leim の activate
|
||
;;
|
||
(defun anthy-leim-activate (&optional name)
|
||
(setq deactivate-current-input-method-function 'anthy-leim-inactivate)
|
||
@@ -874,7 +874,7 @@
|
||
(add-hook 'minibuffer-exit-hook 'anthy-leim-exit-from-minibuffer)))
|
||
|
||
;;
|
||
-;; emacs$B$N%P%0Hr$1$i$7$$$G$9(B
|
||
+;; emacsのバグ避けらしいです
|
||
;;
|
||
(defun anthy-leim-exit-from-minibuffer ()
|
||
(deactivate-input-method)
|
||
@@ -882,11 +882,11 @@
|
||
(remove-hook 'minibuffer-exit-hook 'anthy-leim-exit-from-minibuffer)))
|
||
|
||
;;
|
||
-;; Emacs / XEmacs $B%3%s%Q%A%V%k$J(B last-command-char
|
||
-;; suzuki : $B?7@_(B
|
||
+;; Emacs / XEmacs コンパチブルな last-command-char
|
||
+;; suzuki : 新設
|
||
;;
|
||
(defun anthy-last-command-char ()
|
||
- "$B:G8e$NF~NO%$%Y%s%H$rJV$9!#(BXEmacs $B$G$O(B int $B$KJQ49$9$k(B"
|
||
+ "最後の入力イベントを返す。XEmacs では int に変換する"
|
||
(if anthy-xemacs
|
||
(let ((event last-command-event))
|
||
(cond
|
||
--
|
||
2.28.0
|
||
|
||
From b831814194201341fa211c57891e01d42f91a6e2 Mon Sep 17 00:00:00 2001
|
||
From: Shinji Tamura <stamura@kvj.biglobe.ne.jp>
|
||
Date: Fri, 22 Oct 2021 11:45:35 +0900
|
||
Subject: [PATCH 2/4] src-util: Fix Makefile.am to work with renamed EL files
|
||
|
||
BUG=rhbz#1998727
|
||
---
|
||
src-util/Makefile.am | 10 +++++++---
|
||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||
|
||
diff --git a/src-util/Makefile.am b/src-util/Makefile.am
|
||
index 474a4ca..c51c076 100644
|
||
--- a/src-util/Makefile.am
|
||
+++ b/src-util/Makefile.am
|
||
@@ -4,8 +4,9 @@ SUBDIRS =
|
||
|
||
# Files
|
||
# Dictionary utilities
|
||
-ELISP_FILES = anthy.el anthy-dic.el anthy-conf.el leim-list.el \
|
||
- anthy-isearch.el anthy-azik.el anthy-kyuri.el \
|
||
+ELISP_FILES = anthy-unicode.el anthy-unicode-azik.el anthy-unicode-conf.el \
|
||
+ anthy-unicode-dic.el anthy-unicode-isearch.el anthy-unicode-kyuri.el \
|
||
+ leim-list.el \
|
||
$(NULL)
|
||
EXTRA_DIST = $(ELISP_FILES) \
|
||
typetab dic-tool-input dic-tool-result dic-tool-usage.txt anthy.i \
|
||
@@ -15,7 +16,10 @@ bin_PROGRAMS = \
|
||
anthy-agent-unicode \
|
||
anthy-morphological-analyzer-unicode \
|
||
$(NULL)
|
||
-ELCFILES = anthy.elc anthy-dic.elc anthy-azik.elc anthy-conf.elc anthy-isearch.elc anthy-kyuri.elc leim-list.elc
|
||
+ELCFILES = anthy-unicode.elc anthy-unicode-azik.elc anthy-unicode-conf.elc \
|
||
+ anthy-unicode-dic.elc anthy-unicode-isearch.elc anthy-unicode-kyuri.elc \
|
||
+ leim-list.elc \
|
||
+ $(NULL)
|
||
if ELISP
|
||
lisp_LISP = $(ELISP_FILES)
|
||
endif
|
||
--
|
||
2.28.0
|
||
|
||
From 4493804924ba282445153e0d52d6aa40dbf85305 Mon Sep 17 00:00:00 2001
|
||
From: Shinji Tamura <stamura@kvj.biglobe.ne.jp>
|
||
Date: Fri, 22 Oct 2021 11:45:37 +0900
|
||
Subject: [PATCH 3/4] src-util: Call anthy-agent-unicode and
|
||
anthy-dic-tool-unicode in EL files
|
||
|
||
BUG=rhbz#1998727
|
||
---
|
||
src-util/anthy-unicode-dic.el | 26 +++++++-------
|
||
src-util/anthy-unicode.el | 68 +++++++++++++++++------------------
|
||
src-util/leim-list.el | 8 ++---
|
||
3 files changed, 51 insertions(+), 51 deletions(-)
|
||
|
||
diff --git a/src-util/anthy-unicode-dic.el b/src-util/anthy-unicode-dic.el
|
||
index 5920451..4120f4f 100644
|
||
--- a/src-util/anthy-unicode-dic.el
|
||
+++ b/src-util/anthy-unicode-dic.el
|
||
@@ -14,7 +14,7 @@
|
||
;; Funded by IPA未踏ソフトウェア創造事業 2001 11/10
|
||
|
||
;;; Code
|
||
-(defvar anthy-dic-util-command "anthy-dic-tool")
|
||
+(defvar anthy-dic-util-command "anthy-dic-tool-unicode")
|
||
(defvar anthy-dic-buffer-name " *anthy-dic*")
|
||
|
||
(defun anthy-add-word-compose-paramlist (param)
|
||
@@ -36,13 +36,13 @@
|
||
anthy-dic-util-command "--append"))
|
||
(if proc
|
||
(progn
|
||
- (if anthy-xemacs
|
||
- (if (coding-system-p (find-coding-system 'euc-japan))
|
||
- (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
- (cond ((coding-system-p 'euc-japan)
|
||
- (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
- ((coding-system-p '*euc-japan*)
|
||
- (set-process-coding-system proc '*euc-japan* '*euc-japan*))))
|
||
+;; (if anthy-xemacs
|
||
+;; (if (coding-system-p (find-coding-system 'euc-japan))
|
||
+;; (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
+;; (cond ((coding-system-p 'euc-japan)
|
||
+;; (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
+;; ((coding-system-p '*euc-japan*)
|
||
+;; (set-process-coding-system proc '*euc-japan* '*euc-japan*))))
|
||
(process-send-string proc
|
||
(concat yomi " " (int-to-string freq) " " word "\n"))
|
||
(process-send-string proc
|
||
@@ -70,8 +70,8 @@
|
||
(defun anthy-dic-get-special-noun-category (word)
|
||
(let
|
||
((res '())
|
||
- (cat (string-to-int
|
||
- (read-from-minibuffer "1:人名 2:地名: "))))
|
||
+ (cat (floor (string-to-number
|
||
+ (read-from-minibuffer "1:人名 2:地名: ")))))
|
||
(cond ((= cat 1)
|
||
(setq res '(("品詞" "人名"))))
|
||
((= cat 2)
|
||
@@ -113,9 +113,9 @@
|
||
(and (string= word "")
|
||
(setq word (read-from-minibuffer "単語(語幹のみ): ")))
|
||
(setq yomi (read-from-minibuffer (concat "読み (" word "): ")))
|
||
- (setq cat (string-to-int
|
||
- (read-from-minibuffer
|
||
- "カテゴリー 1:一般名詞 2:その他の名詞 3:形容詞 4:副詞: ")))
|
||
+ (setq cat (floor (string-to-number
|
||
+ (read-from-minibuffer
|
||
+ "カテゴリー 1:一般名詞 2:その他の名詞 3:形容詞 4:副詞: "))))
|
||
(cond ((= cat 1)
|
||
(setq param (anthy-dic-get-noun-category word)))
|
||
((= cat 2)
|
||
diff --git a/src-util/anthy-unicode.el b/src-util/anthy-unicode.el
|
||
index 35e2b82..218d489 100644
|
||
--- a/src-util/anthy-unicode.el
|
||
+++ b/src-util/anthy-unicode.el
|
||
@@ -11,28 +11,28 @@
|
||
|
||
;;; Commentary:
|
||
;;
|
||
-;; かな漢字変換エンジン Anthyを emacsから使うためのプログラム
|
||
-;; Anthyライブラリを使うためのコマンドanthy-agentを起動して、
|
||
-;; anthy-agentとパイプで通信をすることによって変換の動作を行う
|
||
+;; かな漢字変換エンジン Anthy を emacs から使うためのプログラム
|
||
+;; Anthy ライブラリを使うためのコマンド anthy-agent-unicode を起動して、
|
||
+;; anthy-agent-unicode とパイプで通信をすることによって変換の動作を行う
|
||
;;
|
||
;;
|
||
;; Funded by IPA未踏ソフトウェア創造事業 2001 10/10
|
||
;;
|
||
-;; 開発はemacs21.2上で行っていてminor-mode
|
||
-;; もしくはleimとしても使用できる
|
||
+;; 開発は emacs21.2 上で行っていて minor-mode
|
||
+;; もしくは leim としても使用できる
|
||
;; (set-input-method 'japanese-anthy)
|
||
;;
|
||
-;; emacs19(mule),20,21,xemacsで動作する
|
||
+;; emacs19(mule),20,21,xemacs で動作する
|
||
;;
|
||
;;
|
||
-;; 2003-08-24 XEmacs の候補選択モードバグに対応(suzuki)
|
||
+;; 2003-08-24 XEmacs の候補選択モードバグに対応 (suzuki)
|
||
;;
|
||
;; 2001-11-16 EUC-JP -> ISO-2022-JP
|
||
;;
|
||
;; TODO
|
||
-;; 候補選択モードで候補をいっきに次のページにいかないようにする(2chスレ78)
|
||
-;; minibuffferの扱い
|
||
-;; isearch対応
|
||
+;; 候補選択モードで候補をいっきに次のページにいかないようにする (2chスレ78)
|
||
+;; minibufffer の扱い
|
||
+;; isearch 対応
|
||
;;
|
||
;; 用語
|
||
;; commit 文字列を確定すること
|
||
@@ -60,12 +60,12 @@
|
||
(setq anthy-accept-timeout 1))
|
||
|
||
(defconst anthy-working-buffer " *anthy*")
|
||
-(defvar anthy-agent-process nil
|
||
- "anthy-agentのプロセス")
|
||
+(defvar anthy-agent-unicode-process nil
|
||
+ "anthy-agent-unicodeのプロセス")
|
||
(defvar anthy-use-hankaku-kana t)
|
||
;;
|
||
-(defvar anthy-agent-command-list '("anthy-agent")
|
||
- "anthy-agentのPATH名")
|
||
+(defvar anthy-agent-unicode-command-list '("anthy-agent-unicode")
|
||
+ "anthy-agent-unicodeのPATH 名")
|
||
|
||
;; face
|
||
(defvar anthy-highlight-face nil)
|
||
@@ -111,7 +111,7 @@
|
||
(define-key map [backspace] 'anthy-insert)
|
||
(setq anthy-preedit-keymap map)))
|
||
|
||
-;; anthy-agentに送る際にキーをエンコードするためのテーブル
|
||
+;; anthy-agent-unicode に送る際にキーをエンコードするためのテーブル
|
||
(defvar anthy-keyencode-alist
|
||
'((1 . "(ctrl A)") ;; \C-a
|
||
(2 . "(left)") ;; \C-b
|
||
@@ -144,7 +144,7 @@
|
||
((right) . "(right)")
|
||
((left) . "(left)")
|
||
((up) . "(up)"))
|
||
- "キーのイベントをanthy-agentに送るための対応表")
|
||
+ "キーのイベントをanthy-agent-unicodeに送るための対応表")
|
||
|
||
;; モードラインの文字列
|
||
(defvar anthy-mode-line-string-alist
|
||
@@ -223,7 +223,7 @@
|
||
"プロセスの状態が変化したら参照を消して,次に再起動できるようにする"
|
||
(message "%s" stat)
|
||
(anthy-mode-off)
|
||
- (setq anthy-agent-process nil))
|
||
+ (setq anthy-agent-unicode-process nil))
|
||
|
||
;;; status
|
||
(defun anthy-update-mode-line ()
|
||
@@ -719,16 +719,16 @@
|
||
(defun anthy-do-invoke-agent (cmd)
|
||
(if (and (stringp anthy-personality)
|
||
(> (length anthy-personality) 0))
|
||
- (start-process "anthy-agent"
|
||
+ (start-process "anthy-agent-unicode"
|
||
anthy-working-buffer
|
||
cmd
|
||
(concat " --personality=" anthy-personality))
|
||
- (start-process "anthy-agent"
|
||
+ (start-process "anthy-agent-unicode"
|
||
anthy-working-buffer
|
||
cmd)))
|
||
;;
|
||
(defun anthy-invoke-agent ()
|
||
- (let ((list anthy-agent-command-list)
|
||
+ (let ((list anthy-agent-unicode-command-list)
|
||
(proc nil))
|
||
(while (and list (not proc))
|
||
(setq proc
|
||
@@ -742,31 +742,31 @@
|
||
;;
|
||
(defun anthy-check-agent ()
|
||
;; check and do invoke
|
||
- (if (not anthy-agent-process)
|
||
+ (if (not anthy-agent-unicode-process)
|
||
(let
|
||
((proc (anthy-invoke-agent)))
|
||
- (if anthy-agent-process
|
||
- (kill-process anthy-agent-process))
|
||
- (setq anthy-agent-process proc)
|
||
- (process-query-on-exist-flag proc)
|
||
- (if anthy-xemacs
|
||
- (if (coding-system-p (find-coding-system 'euc-japan))
|
||
- (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
- (cond ((coding-system-p 'euc-japan)
|
||
- (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
- ((coding-system-p '*euc-japan*)
|
||
- (set-process-coding-system proc '*euc-japan* '*euc-japan*))))
|
||
+ (if anthy-agent-unicode-process
|
||
+ (kill-process anthy-agent-unicode-process))
|
||
+ (setq anthy-agent-unicode-process proc)
|
||
+ (set-process-query-on-exit-flag proc nil)
|
||
+;; (if anthy-xemacs
|
||
+;; (if (coding-system-p (find-coding-system 'euc-japan))
|
||
+;; (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
+;; (cond ((coding-system-p 'euc-japan)
|
||
+;; (set-process-coding-system proc 'euc-japan 'euc-japan))
|
||
+;; ((coding-system-p '*euc-japan*)
|
||
+;; (set-process-coding-system proc '*euc-japan* '*euc-japan*))))
|
||
(set-process-sentinel proc 'anthy-process-sentinel))))
|
||
;;
|
||
(defun anthy-do-send-recv-command (cmd)
|
||
- (if (not anthy-agent-process)
|
||
+ (if (not anthy-agent-unicode-process)
|
||
(anthy-check-agent))
|
||
(let ((old-buffer (current-buffer)))
|
||
(unwind-protect
|
||
(progn
|
||
(set-buffer anthy-working-buffer)
|
||
(erase-buffer)
|
||
- (process-send-string anthy-agent-process cmd)
|
||
+ (process-send-string anthy-agent-unicode-process cmd)
|
||
(while (= (buffer-size) 0)
|
||
(accept-process-output nil 0 anthy-accept-timeout))
|
||
(read (buffer-string)))
|
||
diff --git a/src-util/leim-list.el b/src-util/leim-list.el
|
||
index c9b055a..2a265be 100644
|
||
--- a/src-util/leim-list.el
|
||
+++ b/src-util/leim-list.el
|
||
@@ -1,7 +1,7 @@
|
||
;; -*- no-byte-compile: t -*-
|
||
-(register-input-method "japanese-anthy" "Japanese"
|
||
- 'anthy-leim-activate "[anthy]"
|
||
- "Anthy Kana Kanji conversion system")
|
||
+(register-input-method "japanese-anthy-unicode" "Japanese"
|
||
+ 'anthy-unicode-leim-activate "[anthy-unicode]"
|
||
+ "Anthy Unicode Kana Kanji conversion system")
|
||
|
||
-(autoload 'anthy-leim-activate "anthy")
|
||
+(autoload 'anthy-unicode-leim-activate "anthy-unicode")
|
||
;;
|
||
--
|
||
2.28.0
|
||
|
||
From 96bac7f6576fad2e3c5937d7e93765736b66de70 Mon Sep 17 00:00:00 2001
|
||
From: Shinji Tamura <stamura@kvj.biglobe.ne.jp>
|
||
Date: Fri, 22 Oct 2021 11:45:39 +0900
|
||
Subject: [PATCH 4/4] src-util: Run anthy-agent-unicode with UTF-8 encoding
|
||
|
||
BUG=rhbz#1998727
|
||
---
|
||
src-util/agent.c | 6 +++---
|
||
src-util/egg.c | 6 ++++--
|
||
src-util/input.c | 45 ++++++++++++++++++++++++++++++++++++++-----
|
||
src-util/morph-main.c | 16 +++++++++++----
|
||
4 files changed, 59 insertions(+), 14 deletions(-)
|
||
|
||
diff --git a/src-util/agent.c b/src-util/agent.c
|
||
index 407e046..ed766ce 100644
|
||
--- a/src-util/agent.c
|
||
+++ b/src-util/agent.c
|
||
@@ -149,7 +149,7 @@ static int daemon_sock = -1;
|
||
static int anonymous;
|
||
static int egg;
|
||
static char *personality;
|
||
-int use_utf8;
|
||
+int use_eucjp;
|
||
|
||
static char *
|
||
encode_command_arg(char *a)
|
||
@@ -1116,8 +1116,8 @@ parse_args(int argc, char **argv)
|
||
egg = 1;
|
||
} else if (!strncmp("--personality=", str, 14)) {
|
||
personality = &str[14];
|
||
- } else if (!strcmp("--utf8", str)) {
|
||
- use_utf8 = 1;
|
||
+ } else if (!strcmp("--eucjp", str)) {
|
||
+ use_eucjp = 1;
|
||
} else if (i < argc - 1) {
|
||
char *arg = argv[i+1];
|
||
if (!strcmp("--dir", str)) {
|
||
diff --git a/src-util/egg.c b/src-util/egg.c
|
||
index b1ca871..60f4d10 100644
|
||
--- a/src-util/egg.c
|
||
+++ b/src-util/egg.c
|
||
@@ -39,7 +39,7 @@ struct context {
|
||
#define MAX_CONTEXT 16
|
||
static struct context contexts[MAX_CONTEXT];
|
||
|
||
-extern int use_utf8;
|
||
+extern int use_eucjp;
|
||
|
||
#define INITIAL_BUFLEN 512
|
||
#define INITIAL_SELLEN 128
|
||
@@ -73,7 +73,9 @@ new_context (void)
|
||
c->selection = NULL;
|
||
return -1;
|
||
}
|
||
- if (use_utf8) {
|
||
+ if (use_eucjp) {
|
||
+ anthy_context_set_encoding(c->ac, ANTHY_EUC_JP_ENCODING);
|
||
+ } else {
|
||
anthy_context_set_encoding(c->ac, ANTHY_UTF8_ENCODING);
|
||
}
|
||
|
||
diff --git a/src-util/input.c b/src-util/input.c
|
||
index 030e3d8..c6bfaa0 100644
|
||
--- a/src-util/input.c
|
||
+++ b/src-util/input.c
|
||
@@ -75,6 +75,19 @@ int anthy_input_errno;
|
||
|
||
#define is_eucchar(s) (((s)[0] & 0x80) && ((s)[1] & 0x80))
|
||
|
||
+static int utf8_char_len(char *str) {
|
||
+ int len = 0;
|
||
+ if ((*str & 0x80) == 0x00) {
|
||
+ len = 1;
|
||
+ } else if ((*str & 0xe0) == 0xc0) {
|
||
+ len = 2;
|
||
+ } else if ((*str & 0xf0) == 0xe0) {
|
||
+ len = 3;
|
||
+ } else if ((*str & 0xf8) == 0xf0) {
|
||
+ len = 4;
|
||
+ }
|
||
+ return len;
|
||
+}
|
||
|
||
struct anthy_input_config {
|
||
struct rk_option* rk_option;
|
||
@@ -233,7 +246,7 @@ enter_conv_state(struct anthy_input_context* ictx)
|
||
|
||
ictx->enum_cand_count = 0;
|
||
ictx->actx = anthy_create_context();
|
||
- anthy_context_set_encoding(ictx->actx, ANTHY_EUC_JP_ENCODING);
|
||
+ anthy_context_set_encoding(ictx->actx, ANTHY_UTF8_ENCODING);
|
||
if (!ictx->actx) {
|
||
enter_none_state(ictx);
|
||
anthy_input_errno = AIE_NOMEM;
|
||
@@ -434,8 +447,13 @@ cmd_move_cursor(struct anthy_input_context* ictx, int d)
|
||
return;
|
||
for (p = ictx->hbuf_follow;
|
||
p < ictx->hbuf_follow + ictx->n_hbuf_follow && d > 0; p++, d--) {
|
||
- if (p < ictx->hbuf_follow + ictx->n_hbuf_follow - 1 && is_eucchar(p))
|
||
+ if (p < ictx->hbuf_follow + ictx->n_hbuf_follow - 3 && utf8_char_len(p) == 4) {
|
||
+ p += 3;
|
||
+ } else if (p < ictx->hbuf_follow + ictx->n_hbuf_follow - 2 && utf8_char_len(p) == 3) {
|
||
+ p += 2;
|
||
+ } else if (p < ictx->hbuf_follow + ictx->n_hbuf_follow - 1 && utf8_char_len(p) == 2) {
|
||
p++;
|
||
+ }
|
||
}
|
||
len = p - ictx->hbuf_follow;
|
||
ensure_buffer(&ictx->hbuf, &ictx->s_hbuf, ictx->n_hbuf + len);
|
||
@@ -450,8 +468,13 @@ cmd_move_cursor(struct anthy_input_context* ictx, int d)
|
||
return;
|
||
for (p = ictx->hbuf + ictx->n_hbuf;
|
||
p > ictx->hbuf && d < 0; p--, d++) {
|
||
- if (p - 1 > ictx->hbuf && is_eucchar(p - 2))
|
||
+ if (p - 3 > ictx->hbuf && utf8_char_len(p - 4) == 4) {
|
||
+ p -= 3;
|
||
+ } else if (p - 2 > ictx->hbuf && utf8_char_len(p - 3) == 3) {
|
||
+ p -= 2;
|
||
+ } else if (p - 1 > ictx->hbuf && utf8_char_len(p - 2) == 2) {
|
||
p--;
|
||
+ }
|
||
}
|
||
len = (ictx->hbuf + ictx->n_hbuf) - p;
|
||
ensure_buffer(&ictx->hbuf_follow, &ictx->s_hbuf_follow,
|
||
@@ -490,7 +513,11 @@ cmd_backspace(struct anthy_input_context* ictx)
|
||
do_cmd_push_key(ictx,buf);
|
||
free(buf);
|
||
} else {
|
||
- if (ictx->n_hbuf >= 2 && is_eucchar(ictx->hbuf + ictx->n_hbuf - 2)) {
|
||
+ if (ictx->n_hbuf >= 4 && utf8_char_len(ictx->hbuf + ictx->n_hbuf - 4) == 4) {
|
||
+ ictx->n_hbuf -= 4;
|
||
+ } else if (ictx->n_hbuf >= 3 && utf8_char_len(ictx->hbuf + ictx->n_hbuf - 3) == 3) {
|
||
+ ictx->n_hbuf -= 3;
|
||
+ } else if (ictx->n_hbuf >= 2 && utf8_char_len(ictx->hbuf + ictx->n_hbuf - 2) == 2) {
|
||
ictx->n_hbuf -= 2;
|
||
} else if (ictx->n_hbuf >= 1) {
|
||
ictx->n_hbuf--;
|
||
@@ -514,7 +541,15 @@ cmd_delete(struct anthy_input_context* ictx)
|
||
if (ictx->n_hbuf_follow <= 0)
|
||
return;
|
||
|
||
- len = ictx->n_hbuf_follow >= 2 && is_eucchar(ictx->hbuf_follow) ? 2 : 1;
|
||
+ if (ictx->n_hbuf_follow >= 4 && utf8_char_len(ictx->hbuf_follow) == 4) {
|
||
+ len = 4;
|
||
+ } else if (ictx->n_hbuf_follow >= 3 && utf8_char_len(ictx->hbuf_follow) == 3) {
|
||
+ len = 3;
|
||
+ } else if (ictx->n_hbuf_follow >= 2 && utf8_char_len(ictx->hbuf_follow) == 2) {
|
||
+ len = 2;
|
||
+ } else {
|
||
+ len = 1;
|
||
+ }
|
||
|
||
if (ictx->n_hbuf_follow <= len)
|
||
ictx->n_hbuf_follow = 0;
|
||
diff --git a/src-util/morph-main.c b/src-util/morph-main.c
|
||
index c34aa64..de3313a 100644
|
||
--- a/src-util/morph-main.c
|
||
+++ b/src-util/morph-main.c
|
||
@@ -23,6 +23,7 @@
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <anthy/anthy.h>
|
||
+#include <anthy/xstr.h>
|
||
/* for print_context_info() */
|
||
#include <anthy/convdb.h>
|
||
|
||
@@ -34,7 +35,7 @@ static void read_file(struct test_context *tc, const char *fn);
|
||
extern void anthy_reload_record(void);
|
||
|
||
int verbose;
|
||
-int use_utf8;
|
||
+int use_eucjp;
|
||
|
||
/**/
|
||
static void
|
||
@@ -42,7 +43,9 @@ init_test_context(struct test_context *tc)
|
||
{
|
||
tc->ac = anthy_create_context();
|
||
anthy_set_reconversion_mode(tc->ac, ANTHY_RECONVERT_ALWAYS);
|
||
- if (use_utf8) {
|
||
+ if (use_eucjp) {
|
||
+ anthy_context_set_encoding(tc->ac, ANTHY_EUC_JP_ENCODING);
|
||
+ } else {
|
||
anthy_context_set_encoding(tc->ac, ANTHY_UTF8_ENCODING);
|
||
}
|
||
anthy_reload_record();
|
||
@@ -121,8 +124,8 @@ parse_args(int argc, char **argv)
|
||
int i;
|
||
for (i = 1; i < argc; i++) {
|
||
char *arg = argv[i];
|
||
- if (!strcmp(arg, "--utf8")) {
|
||
- use_utf8 = 1;
|
||
+ if (!strcmp(arg, "--eucjp")) {
|
||
+ use_eucjp = 1;
|
||
} else if (arg[i] == '-') {
|
||
print_usage();
|
||
}
|
||
@@ -140,6 +143,11 @@ main(int argc, char **argv)
|
||
|
||
/*read_file(&tc, "index.txt");*/
|
||
parse_args(argc, argv);
|
||
+ if (use_eucjp) {
|
||
+ anthy_xstr_set_print_encoding(ANTHY_EUC_JP_ENCODING);
|
||
+ } else {
|
||
+ anthy_xstr_set_print_encoding(ANTHY_UTF8_ENCODING);
|
||
+ }
|
||
|
||
nr = 0;
|
||
for (i = 1; i < argc; i++) {
|
||
--
|
||
2.28.0
|
||
|
||
From e54c7582bc7284575c12827a9685c5ab08cb2674 Mon Sep 17 00:00:00 2001
|
||
From: fujiwarat <takao.fujiwara1@gmail.com>
|
||
Date: Tue, 26 Oct 2021 16:30:00 +0900
|
||
Subject: [PATCH] src-util: Fix require in *.el
|
||
|
||
BUG=rhbz#1998727
|
||
---
|
||
src-util/anthy-unicode-azik.el | 4 ++--
|
||
src-util/anthy-unicode-conf.el | 4 ++--
|
||
src-util/anthy-unicode-dic.el | 6 +++---
|
||
src-util/anthy-unicode-isearch.el | 4 ++--
|
||
src-util/anthy-unicode-kyuri.el | 4 ++--
|
||
src-util/anthy-unicode.el | 11 +++++++----
|
||
6 files changed, 18 insertions(+), 15 deletions(-)
|
||
|
||
diff --git a/src-util/anthy-unicode-azik.el b/src-util/anthy-unicode-azik.el
|
||
index 935d4d8..019c082 100644
|
||
--- a/src-util/anthy-unicode-azik.el
|
||
+++ b/src-util/anthy-unicode-azik.el
|
||
@@ -1,10 +1,10 @@
|
||
-;; anthy-azik.el
|
||
+;; anthy-unicode-azik.el
|
||
|
||
;; Copyright (C) 2004
|
||
;; Author: Yutaka Hara<yhara@kmc.gr.jp>
|
||
|
||
;; add following 2 lines to ~/.emacs
|
||
-;; (load-library "anthy-azik")
|
||
+;; (load-library "anthy-unicode-azik")
|
||
;; (anthy-azik-mode)
|
||
;;
|
||
|
||
diff --git a/src-util/anthy-unicode-conf.el b/src-util/anthy-unicode-conf.el
|
||
index 7b7d7c2..3ebb940 100644
|
||
--- a/src-util/anthy-unicode-conf.el
|
||
+++ b/src-util/anthy-unicode-conf.el
|
||
@@ -1,4 +1,4 @@
|
||
-;; anthy-conf.el -- Anthy
|
||
+;; anthy-unicode-conf.el -- Anthy
|
||
|
||
|
||
;; Copyright (C) 2002
|
||
@@ -119,4 +119,4 @@
|
||
" BREAK_INTO_ROMAN 1\n"
|
||
" BREAK_INTO_ROMAN 0\n")))
|
||
|
||
-(provide 'anthy-conf)
|
||
+(provide 'anthy-unicode-conf)
|
||
diff --git a/src-util/anthy-unicode-dic.el b/src-util/anthy-unicode-dic.el
|
||
index 4120f4f..7999371 100644
|
||
--- a/src-util/anthy-unicode-dic.el
|
||
+++ b/src-util/anthy-unicode-dic.el
|
||
@@ -1,4 +1,4 @@
|
||
-;; anthy-dic.el -- Anthy
|
||
+;; anthy-unicode-dic.el -- Anthy
|
||
|
||
;; Copyright (C) 2001 - 2005
|
||
;; Author: Yusuke Tabata<yusuke@w5.dion.ne.jp>
|
||
@@ -125,8 +125,8 @@
|
||
((= cat 4)
|
||
(setq param (anthy-dic-get-av-category word))))
|
||
(if param
|
||
- (setq res (anthy-add-word yomi 1 word param)))
|
||
+ (setq res (anthy-add-word yomi 500 word param)))
|
||
(if res
|
||
(message (concat word "(" yomi ")を登録しました")))))
|
||
|
||
-(provide 'anthy-dic)
|
||
+(provide 'anthy-unicode-dic)
|
||
diff --git a/src-util/anthy-unicode-isearch.el b/src-util/anthy-unicode-isearch.el
|
||
index 85077cc..f7179cf 100644
|
||
--- a/src-util/anthy-unicode-isearch.el
|
||
+++ b/src-util/anthy-unicode-isearch.el
|
||
@@ -1,4 +1,4 @@
|
||
-;; anthy-isearch.el -- Anthy
|
||
+;; anthy-unicode-isearch.el -- Anthy
|
||
|
||
;; Copyright (C) 2003
|
||
;; Author: Yusuke Tabata <yusuke@cherbim.icw.co.jp>
|
||
@@ -11,7 +11,7 @@
|
||
;; most of the code is stolen from SKK.
|
||
;; for Emacs-21
|
||
|
||
-(require 'anthy)
|
||
+(require 'anthy-unicode)
|
||
|
||
(defvar anthy-isearch-mode-map nil)
|
||
|
||
diff --git a/src-util/anthy-unicode-kyuri.el b/src-util/anthy-unicode-kyuri.el
|
||
index 6fb2575..4ccdd1a 100644
|
||
--- a/src-util/anthy-unicode-kyuri.el
|
||
+++ b/src-util/anthy-unicode-kyuri.el
|
||
@@ -1,9 +1,9 @@
|
||
-;; anthy-kyuri.el
|
||
+;; anthy-unicode-kyuri.el
|
||
|
||
;; Copyright (C) 2005
|
||
;; Author: Yukihiro Matsumoto <matz@ruby-lang.org>
|
||
|
||
-(require 'anthy)
|
||
+(require 'anthy-unicode)
|
||
|
||
(setq anthy-kyuri-mode-hiragana-map
|
||
'(
|
||
diff --git a/src-util/anthy-unicode.el b/src-util/anthy-unicode.el
|
||
index 218d489..a913f87 100644
|
||
--- a/src-util/anthy-unicode.el
|
||
+++ b/src-util/anthy-unicode.el
|
||
@@ -1,6 +1,8 @@
|
||
-;;; anthy.el -- Anthy
|
||
+;;; anthy-unicode.el -- Anthy
|
||
|
||
;; Copyright (C) 2001 - 2007 KMC(Kyoto University Micro Computer Club)
|
||
+;; Copyright (C) 2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||
+;; Copyright (c) 2021 Red Hat, Inc.
|
||
|
||
;; Author: Yusuke Tabata<yusuke@kmc.gr.jp>
|
||
;; Tomoharu Ugawa
|
||
@@ -28,6 +30,7 @@
|
||
;; 2003-08-24 XEmacs の候補選択モードバグに対応 (suzuki)
|
||
;;
|
||
;; 2001-11-16 EUC-JP -> ISO-2022-JP
|
||
+;; 2021-10-26 ISO-2022-JP -> UTF-8
|
||
;;
|
||
;; TODO
|
||
;; 候補選択モードで候補をいっきに次のページにいかないようにする (2chスレ78)
|
||
@@ -901,10 +904,10 @@
|
||
;;
|
||
;;
|
||
;(global-set-key [(meta escape)] 'anthy-mode)
|
||
-(provide 'anthy)
|
||
+(provide 'anthy-unicode)
|
||
|
||
-(require 'anthy-dic)
|
||
-(require 'anthy-conf)
|
||
+(require 'anthy-unicode-dic)
|
||
+(require 'anthy-unicode-conf)
|
||
|
||
;; is it ok for i18n?
|
||
(set-language-info "Japanese" 'input-method "japanese-anthy")
|
||
--
|
||
2.28.0
|
||
|