[uim-commit] r211 - trunk/uim
yamaken@freedesktop.org
yamaken@freedesktop.org
Sun Jan 9 21:59:50 PST 2005
Author: yamaken
Date: 2005-01-09 21:59:47 -0800 (Sun, 09 Jan 2005)
New Revision: 211
Modified:
trunk/uim/uim-scm.c
trunk/uim/uim-scm.h
trunk/uim/uim-util.c
Log:
* This commit removes Siod dependency from uim-util.c
* uim/uim-util.c
- Remove #include "siod.h"
- (str_seq_equal, str_seq_partial): Rewrite siod dependent codes
with uim-scm API
- (string_equal) Move to uim-scm.c
- (uim_init_util_subrs): Move initialization of string=? to uim-scm.c
* uim/uim-scm.h
- Add API intention to the header comment
- (uim_scm_length): New function
* uim/uim-scm.c
- (uim_scm_nullp, uim_scm_eq): Fix return type int with uim_bool
- (uim_scm_string_equal):
* Ditto
* Replace the implementation with string_equal
- (string_equal): Moved from uim-util.c
- (uim_scm_length): New function
- (uim_scm_init): Moved initialization of string=? from uim-util.c
Modified: trunk/uim/uim-scm.c
===================================================================
--- trunk/uim/uim-scm.c 2005-01-10 05:11:35 UTC (rev 210)
+++ trunk/uim/uim-scm.c 2005-01-10 05:59:47 UTC (rev 211)
@@ -56,6 +56,8 @@
#include "slib.c"
#endif
+static uim_lisp string_equal(uim_lisp x, uim_lisp y);
+
#if 1
/* will be deprecated. use uim_scm_t() and uim_scm_f() for new design */
uim_lisp true_sym;
@@ -246,7 +248,7 @@
return (uim_lisp)NIL;
}
-int
+uim_bool
uim_scm_nullp(uim_lisp obj)
{
return NULLP((LISP)obj);
@@ -270,21 +272,32 @@
return STRINGP((LISP)obj);
}
-int
+uim_bool
uim_scm_eq(uim_lisp a, uim_lisp b)
{
return EQ(a, b);
}
-int
+static uim_lisp
+string_equal(uim_lisp x, uim_lisp y)
+{
+ long xl, yl;
+ char *xs, *ys;
+ xs = get_c_string_dim((LISP)x, &xl);
+ ys = get_c_string_dim((LISP)y, &yl);
+ if (xl != yl) {
+ return uim_scm_f();
+ }
+ if (!strncmp(xs, ys, xl)) {
+ return uim_scm_t();
+ }
+ return uim_scm_f();
+}
+
+uim_bool
uim_scm_string_equal(uim_lisp a, uim_lisp b)
{
- uim_lisp form, p;
- protected_arg0 = form = uim_scm_list3(uim_scm_make_symbol("string=?"),
- a,
- b);
- p = uim_scm_eval(form);
- return TRUEP(p);
+ return NFALSEP(string_equal(a, b));
}
uim_lisp
@@ -356,6 +369,16 @@
}
uim_lisp
+uim_scm_length(uim_lisp list)
+{
+ /*
+ although nlength() of siod returns length of anything, this
+ function should be called only for list
+ */
+ return (uim_lisp)uim_scm_make_int(nlength((LISP)list));
+}
+
+uim_lisp
uim_scm_reverse(uim_lisp cell)
{
return (uim_lisp)reverse((LISP)cell);
@@ -481,6 +504,8 @@
protected_arg0 = uim_scm_f();
uim_scm_gc_protect(&protected_arg0);
+
+ uim_scm_init_subr_2("string=?", string_equal);
}
void
Modified: trunk/uim/uim-scm.h
===================================================================
--- trunk/uim/uim-scm.h 2005-01-10 05:11:35 UTC (rev 210)
+++ trunk/uim/uim-scm.h 2005-01-10 05:59:47 UTC (rev 211)
@@ -38,7 +38,12 @@
API easily causes fatal crash involving GC if you does not pay
attention enough. Be careful.
- 2004-12-21 YamaKen
+ This API is not intended to provide all R5RS features. Only 'core'
+ ones to write Scheme-C adapters should be added. Consider how
+ frequently it will be used, and whether it should be written by C,
+ when you add an API function.
+
+ 2005-01-10 YamaKen
*/
@@ -192,6 +197,8 @@
uim_lisp
uim_scm_cddr(uim_lisp cell);
uim_lisp
+uim_scm_length(uim_lisp list);
+uim_lisp
uim_scm_reverse(uim_lisp cell);
#ifdef __cplusplus
Modified: trunk/uim/uim-util.c
===================================================================
--- trunk/uim/uim-util.c 2005-01-10 05:11:35 UTC (rev 210)
+++ trunk/uim/uim-util.c 2005-01-10 05:59:47 UTC (rev 211)
@@ -39,7 +39,6 @@
#include <langinfo.h>
#include "context.h"
#include "gettext.h"
-#include "siod.h"
#include "uim-scm.h"
#include "uim-compat-scm.h"
#include "uim-util.h"
@@ -78,24 +77,7 @@
return uim_scm_make_str(PKGDATADIR);
}
-
static uim_lisp
-string_equal(uim_lisp x, uim_lisp y)
-{
- long xl, yl;
- char *xs, *ys;
- xs = get_c_string_dim((LISP)x, &xl);
- ys = get_c_string_dim((LISP)y, &yl);
- if (xl != yl) {
- return uim_scm_f();
- }
- if (!strncmp(xs, ys, xl)) {
- return uim_scm_t();
- }
- return uim_scm_f();
-}
-
-static uim_lisp
charcode2string(uim_lisp x)
{
char buf[2];
@@ -149,14 +131,14 @@
static uim_lisp
str_seq_equal(uim_lisp seq, uim_lisp rule)
{
- int sl = nlength((LISP)seq);
- int rl = nlength((LISP)rule);
+ int sl = uim_scm_c_int(uim_scm_length(seq));
+ int rl = uim_scm_c_int(uim_scm_length(rule));
int i;
if (sl != rl) {
return uim_scm_f();
}
for (i = 0; i < sl; i++) {
- if FALSEP(string_equal(uim_scm_car(seq), uim_scm_car(rule))) {
+ if (!uim_scm_string_equal(uim_scm_car(seq), uim_scm_car(rule))) {
return uim_scm_f();
}
seq = uim_scm_cdr(seq);
@@ -174,8 +156,8 @@
static uim_lisp
str_seq_partial(uim_lisp seq, uim_lisp rule)
{
- int sl = nlength((LISP)seq);
- int rl = nlength((LISP)rule);
+ int sl = uim_scm_c_int(uim_scm_length(seq));
+ int rl = uim_scm_c_int(uim_scm_length(rule));
int i;
if (sl >= rl) {
@@ -183,7 +165,7 @@
}
/* Obviously. sl < rl */
for (i = 0; i < sl; i++) {
- if FALSEP(string_equal(uim_scm_car(seq), uim_scm_car(rule))) {
+ if (!uim_scm_string_equal(uim_scm_car(seq), uim_scm_car(rule))) {
return uim_scm_f();
}
seq = uim_scm_cdr(seq);
@@ -457,7 +439,6 @@
uim_scm_init_subr_0("sys-pkglibdir", sys_pkglibdir);
uim_scm_init_subr_0("sys-datadir", sys_datadir);
uim_scm_init_subr_0("sys-pkgdatadir", sys_pkgdatadir);
- uim_scm_init_subr_2("string=?", string_equal);
uim_scm_init_subr_2("nthcdr", nthcdr);
uim_scm_init_subr_1("charcode->string", charcode2string);
uim_scm_init_subr_1("string->charcode", string2charcode);
More information about the Uim-commit
mailing list