[uim-commit] r2234 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Tue Nov 22 16:50:41 PST 2005
Author: kzk
Date: 2005-11-22 16:50:37 -0800 (Tue, 22 Nov 2005)
New Revision: 2234
Modified:
branches/r5rs/sigscheme/operations.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/storage.c
Log:
* abolish Scm_NewStringWithLen
* sigscheme/storage.c
- (Scm_NewStringWithLen): removed
* sigscheme/sigscheme.h
- (Scm_NewStringWithLen): removed
* sigscheme/operations.c
- (ScmOp_make_string): not to use Scm_NewStringWithLen.
more solid code.
- (Scm_NewStringWithLen): not to use Scm_NewStringWithLen.
but this makes a bit slower.
Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c 2005-11-23 00:07:04 UTC (rev 2233)
+++ branches/r5rs/sigscheme/operations.c 2005-11-23 00:50:37 UTC (rev 2234)
@@ -1138,30 +1138,41 @@
ScmObj ScmOp_make_string(ScmObj length, ScmObj args)
{
int len = 0;
- ScmObj str = SCM_FALSE;
+ int i;
+ int fillstr_size = 0;
ScmObj filler = SCM_FALSE;
+ const char *fillstr = NULL;
+ char *new_str = NULL;
+ char *p = NULL;
DECLARE_FUNCTION("make-string", ProcedureVariadic1);
ASSERT_INTP(length);
len = SCM_INT_VALUE(length);
if (len == 0)
return Scm_NewStringCopying("");
+ if (len < 0)
+ ERR_OBJ("length out of range", length);
- /* specify filler */
+ /* extract fillstr */
if (NO_MORE_ARG(args)) {
- filler = Scm_NewChar(strdup(" "));
+ fillstr = " ";
} else {
filler = POP_ARG(args);
+ ASSERT_NO_MORE_ARG(args);
ASSERT_CHARP(filler);
+ fillstr = SCM_CHAR_VALUE(filler);
}
- /* make string */
- str = Scm_NewStringWithLen(NULL, len);
+ /* fill string */
+ fillstr_size = strlen(fillstr);
+ new_str = (char*)malloc(sizeof(char) * fillstr_size * len + 1);
+ for (i = 0, p = new_str; i < len; i++) {
+ strcpy(p, fillstr);
+ p += fillstr_size;
+ }
+ new_str[fillstr_size * len] = '\0';
- /* and fill! */
- ScmOp_string_filld(str, filler);
-
- return str;
+ return Scm_NewString(new_str);
}
ScmObj ScmOp_string(ScmObj args)
@@ -1339,7 +1350,7 @@
p += strlen(SCM_STRING_STR(obj));
}
- return Scm_NewStringWithLen(new_str, total_len);
+ return Scm_NewString(new_str);
}
ScmObj ScmOp_string2list(ScmObj string)
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-11-23 00:07:04 UTC (rev 2233)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-11-23 00:50:37 UTC (rev 2234)
@@ -382,7 +382,6 @@
ScmObj Scm_NewChar(char *ch);
ScmObj Scm_NewString(char *str);
ScmObj Scm_NewStringCopying(const char *str);
-ScmObj Scm_NewStringWithLen(char *str, int len);
ScmObj Scm_NewFunc(enum ScmFuncTypeCode type, ScmFuncType func);
ScmObj Scm_NewClosure(ScmObj exp, ScmObj env);
ScmObj Scm_NewVector(ScmObj *vec, int len);
Modified: branches/r5rs/sigscheme/storage.c
===================================================================
--- branches/r5rs/sigscheme/storage.c 2005-11-23 00:07:04 UTC (rev 2233)
+++ branches/r5rs/sigscheme/storage.c 2005-11-23 00:50:37 UTC (rev 2234)
@@ -226,17 +226,6 @@
return obj;
}
-ScmObj Scm_NewStringWithLen(char *str, int len)
-{
- ScmObj obj = SigScm_NewObjFromHeap();
-
- SCM_ENTYPE_STRING(obj);
- SCM_STRING_SET_STR(obj, str);
- SCM_STRING_SET_LEN(obj, len);
-
- return obj;
-}
-
ScmObj Scm_NewFunc(enum ScmFuncTypeCode type, ScmFuncType func)
{
ScmObj obj = SigScm_NewObjFromHeap();
More information about the uim-commit
mailing list