[uim-commit] r2176 - trunk/uim
ekato at freedesktop.org
ekato at freedesktop.org
Sat Nov 19 22:25:00 PST 2005
Author: ekato
Date: 2005-11-19 22:24:57 -0800 (Sat, 19 Nov 2005)
New Revision: 2176
Modified:
trunk/uim/skk.c
Log:
* uim/skk.c : Include <arpa/inet.h> for inet_aton().
(has_numeric_in_head) : New function.
(skk_get_entry) : Handle non-numeric entries even if numeric
conversion option is enabled.
(skk_get_nth_candidate) : Ditto.
(skk_get_nr_candidates) : Ditto
(skk_get_completion) : Ditto.
(skk_get_nth_completion) : Ditto.
(skk_get_nr_completions) : Ditto.
(skk_clear_completions) : Ditto.
(skk_get_dcomp_word) : Ditto.
(skk_commit_candidate) : Ditto.
(skk_purge_candidate) : Ditto.
Modified: trunk/uim/skk.c
===================================================================
--- trunk/uim/skk.c 2005-11-20 05:06:12 UTC (rev 2175)
+++ trunk/uim/skk.c 2005-11-20 06:24:57 UTC (rev 2176)
@@ -52,6 +52,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
+#include <arpa/inet.h>
#include "uim-scm.h"
#include "plugin.h"
@@ -73,7 +74,7 @@
/* candidate array for each okurigana
*
- * |C0|C1| .. |Cnr_real_cands| .. |Cnr_cands|
+ * |C0|C1| .. |Cnr_real_cands| .. |Cnr_cands|
* <-------should be saved --><-- cache of master dict -->
*/
struct skk_cand_array {
@@ -1083,6 +1084,9 @@
if (ca && ca->nr_cands > 0 && !is_purged_only(ca))
return uim_scm_t();
+ if NFALSEP(numeric_conv_)
+ return skk_get_entry(head_, okuri_head_, okuri_, uim_scm_f());
+
return uim_scm_f();
}
@@ -1520,6 +1524,23 @@
return p;
}
+static int
+has_numeric_in_head(uim_lisp head_)
+{
+ const char *str;
+ int i = 0;
+
+ str = uim_scm_refer_c_str(head_);
+
+ while (str[i] != '\0') {
+ if (isdigit((unsigned char)str[i]))
+ return 1;
+ i++;
+ }
+
+ return 0;
+}
+
static uim_lisp
get_nth(int nth, uim_lisp lst_)
{
@@ -1664,6 +1685,11 @@
}
}
+ /* check non-numeric conversion */
+ if (!cands && n >= k && !uim_scm_nullp(numlst_))
+ return skk_get_nth_candidate(uim_scm_make_int(n - k), head_, okuri_head_,
+ okuri_, uim_scm_f());
+
if (cands)
str_ = uim_scm_make_str(cands);
@@ -1713,6 +1739,13 @@
}
}
}
+
+ /* add non-numeric conversion */
+ if (!uim_scm_nullp(numlst_))
+ return uim_scm_make_int(nr_cands +
+ uim_scm_c_int(skk_get_nr_candidates(head_, okuri_head_,
+ okuri_, uim_scm_f())));
+
return uim_scm_make_int(nr_cands);
}
@@ -1806,6 +1839,10 @@
ca->refcount++;
return uim_scm_t();
}
+
+ if (NFALSEP(numeric_conv_) && has_numeric_in_head(head_))
+ return skk_get_completion(head_, uim_scm_f());
+
return uim_scm_f();
}
@@ -1825,14 +1862,26 @@
else
ca = find_comp_array_lisp(head_, uim_scm_f());
+ if (!ca) {
+ if (!uim_scm_nullp(numlst_))
+ return skk_get_nth_completion(nth_, head_, uim_scm_f());
+ else
+ return uim_scm_null_list();
+ }
+
n = uim_scm_c_int(nth_);
- if (ca && ca->nr_comps > n) {
+ if (ca->nr_comps > n) {
str = ca->comps[n];
if (!uim_scm_nullp(numlst_))
return restore_numeric(str, numlst_);
else
return uim_scm_make_str(str);
}
+
+ if (!uim_scm_nullp(numlst_) && n >= ca->nr_comps)
+ return skk_get_nth_completion(uim_scm_make_int(n - ca->nr_comps),
+ head_, uim_scm_f());
+
return uim_scm_null_list();
}
@@ -1846,6 +1895,10 @@
if (ca)
n = ca->nr_comps;
+ if (NFALSEP(numeric_conv_) && has_numeric_in_head(head_))
+ return uim_scm_make_int(n +
+ uim_scm_c_int(skk_get_nr_completions(head_, uim_scm_f())));
+
return uim_scm_make_int(n);
}
@@ -1865,15 +1918,15 @@
if (!rs)
for (ca = skk_comp; ca; ca = ca->next) {
if (!strcmp(ca->head, hs)) {
- ca->refcount--;
- break;
+ ca->refcount--;
+ break;
}
}
else {
for (ca = skk_comp; ca; ca = ca->next) {
if (!strcmp(ca->head, rs)) {
- ca->refcount--;
- break;
+ ca->refcount--;
+ break;
}
}
free(rs);
@@ -1898,6 +1951,10 @@
free(ca);
}
}
+
+ if (NFALSEP(numeric_conv_) && has_numeric_in_head(head_))
+ skk_clear_completions(head_, uim_scm_f());
+
return uim_scm_t();
}
@@ -1973,6 +2030,7 @@
}
}
free(rs);
+ return skk_get_dcomp_word(head_, uim_scm_f());
}
}
return uim_scm_make_str("");
@@ -2272,8 +2330,13 @@
else
ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 0, uim_scm_f());
- if (!ca)
+ if (!ca) {
+ if (!uim_scm_nullp(numlst_))
+ return skk_commit_candidate(head_, okuri_head_, okuri_, nth_,
+ uim_scm_f());
return uim_scm_f();
+ }
+
get_ignoring_indices(ca, ignoring_indices);
/* handle #4 method of numeric conversion */
@@ -2307,8 +2370,12 @@
k++;
}
}
- if (!str)
+ if (!str) {
+ if (nth >= k)
+ return skk_commit_candidate(head_, okuri_head_, okuri_,
+ uim_scm_make_int(nth - k), uim_scm_f());
return uim_scm_f();
+ }
} else {
for (i = 0; i < ca->nr_cands; i++) {
if (match_to_discarding_index(ignoring_indices, i))
@@ -2339,9 +2406,9 @@
}
if (!found) {
if (!uim_scm_nullp(numlst_))
- ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 1, numeric_conv_);
+ ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 1, numeric_conv_);
else
- ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 1, uim_scm_f());
+ ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 1, uim_scm_f());
reorder_candidate(ca, str);
} else {
/* also reorder base candidate array */
@@ -2407,8 +2474,14 @@
ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 0, numeric_conv_);
else
ca = find_cand_array_lisp(head_, okuri_head_, okuri_, 0, uim_scm_f());
- if (!ca)
+
+ if (!ca) {
+ if (!uim_scm_nullp(numlst_))
+ return skk_purge_candidate(head_, okuri_head_, okuri_, nth_,
+ uim_scm_f());
return uim_scm_f(); /* shouldn't happen */
+ }
+
get_ignoring_indices(ca, ignoring_indices);
/* handle #4 method of numeric conversion */
@@ -2444,8 +2517,12 @@
k++;
}
}
- if (!str)
+ if (!str) {
+ if (nth >= k)
+ skk_purge_candidate(head_, okuri_head_, okuri_,
+ uim_scm_make_int(nth - k), uim_scm_f());
return uim_scm_f();
+ }
} else {
for (i = 0; i < ca->nr_cands; i++) {
if (match_to_discarding_index(ignoring_indices, i))
More information about the uim-commit
mailing list