klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 1e1e8c18bca2b7a7d8dec0583b66c8d876974c5b
parent 47035f4886166583d84ffaae29f95edb1ac0334c
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 23 Mar 2011 01:47:11 -0300

Added string-fill! to the ground environment.

Diffstat:
Msrc/kground.c | 2+-
Msrc/kgstrings.c | 13++++++++++++-
Msrc/kgstrings.h | 2+-
3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/kground.c b/src/kground.c @@ -623,7 +623,7 @@ void kinit_ground_env(klisp_State *K) /* TODO */ /* 13.2.9? string-fill! */ - /* TODO */ + add_applicative(K, ground_env, "string-fill!", string_fillS, 0); /* ** 13.3 Symbol Features (this are from section symbol in r5rs) diff --git a/src/kgstrings.c b/src/kgstrings.c @@ -6,6 +6,7 @@ #include <assert.h> #include <stdio.h> +#include <string.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> @@ -124,7 +125,17 @@ void string_setS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) /* TODO */ /* 13.2.9? string-fill! */ -/* TODO */ +void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv) +{ + UNUSED(xparams); + UNUSED(denv); + bind_2tp(K, "string-fill!", ptree, "string", ttisstring, str, + "char", ttischar, tv_ch); + + memset(kstring_buf(str), chvalue(tv_ch), kstring_size(str)); + kapply_cc(K, KINERT); +} + /* 13.3.1? symbol->string */ /* TEMP: for now all strings are mutable, this returns a new object diff --git a/src/kgstrings.h b/src/kgstrings.h @@ -59,7 +59,7 @@ void string_setS (klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* TODO */ /* 13.2.9? string-fill! */ -/* TODO */ +void string_fillS(klisp_State *K, TValue *xparams, TValue ptree, TValue denv); /* 13.3.1? symbol->string */ /* TEMP: for now all strings are mutable, this returns a new object