From c332e84eacb63a785ec1598a6e75ababc8734627 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 13 Oct 2015 21:50:06 -0400 Subject: [PATCH 1/3] Switched order of parameters in Cyc_string_append --- include/cyclone/runtime.h | 2 +- runtime.c | 2 +- scheme/cyclone/cgen.sld | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 10291097..78b2d12c 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -126,7 +126,7 @@ object Cyc_string2symbol(object str); object Cyc_list2string(object cont, object lst); common_type Cyc_string2number(object str); void dispatch_string_91append(int argc, object clo, object cont, object str1, ...); -object Cyc_string_append(int argc, object cont, object str1, ...); +object Cyc_string_append(object cont, int argc, object str1, ...); integer_type Cyc_string_length(object str); object Cyc_substring(object cont, object str, object start, object end); object Cyc_string_ref(object str, object k); diff --git a/runtime.c b/runtime.c index 5b87b259..d4658cf9 100644 --- a/runtime.c +++ b/runtime.c @@ -966,7 +966,7 @@ void dispatch_string_91append(int _argc, object clo, object cont, object str1, . Cyc_string_append_va_list(_argc - 1); } -object Cyc_string_append(int _argc, object cont, object str1, ...) { +object Cyc_string_append(object cont, int _argc, object str1, ...) { string_type result; va_list ap; va_start(ap, str1); diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index c8a79ee4..b1d7be0d 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -610,13 +610,6 @@ Cyc-read-line cons length vector-length cell)))) -TODO: how to fix this up to generate argc after cont? -or alternatively, maybe we say screw it and just reverse the order of -args in the runtime function... but that's not ideal since we do it differently -everywhere else. will it cause problems to have a special case????? -object c_732612 = Cyc_string_append((closure)&c_732599, 2,&c_732613, r_73276); -return_closcall1((closure)&c_732599, c_732612);; - ;; Pass continuation as the function's first parameter? (define (prim:cont? exp) (and (prim? exp) From 338d46ac9ec8f3bd0a1635c3454b756c2b39297a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 13 Oct 2015 22:32:17 -0400 Subject: [PATCH 2/3] Added notes --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index 25235323..6136b57c 100644 --- a/TODO +++ b/TODO @@ -11,6 +11,7 @@ at this point, cyclone crashes when compiling the test suite. I think there may Roadmap: + - Make it easier to work with multiple copies of cyclone. for example, maybe an env variable could be used to point a local copy of cyclone to the current directory for resources, instead of /usr/local/ - Add macro support, ideally including some level of hygiene - Code cleanup - need to take care of accumulated cruft before release. also, can we profile to make things any faster? - Target r7rs support (coordinate with feature list) From 738fe0439ec5027bad549851e2a0a2b6bc12e905 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 13 Oct 2015 22:51:25 -0400 Subject: [PATCH 3/3] Bug fixes --- include/cyclone/types.h | 8 +++++--- runtime.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 1e92c558..9d9ce1df 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -193,11 +193,13 @@ typedef struct {gc_header_type hdr; tag_type tag; int len; char *str;} string_ty #define make_string(cs, s) string_type cs; \ { int len = strlen(s); cs.tag = string_tag; cs.len = len; \ cs.str = alloca(sizeof(char) * (len + 1)); \ - strcpy(cs.str, s);} + memcpy(cs.str, s, len + 1);} #define make_string_with_len(cs, s, length) string_type cs; \ -{ cs.tag = string_tag; cs.len = length; \ +{ int len = length; \ + cs.tag = string_tag; cs.len = len; \ cs.str = alloca(sizeof(char) * (len + 1)); \ - strcpy(cs.str, s);} + memcpy(cs.str, s, len); \ + cs.str[len + 1] = '\0';} #define make_string_noalloc(cs, s, length) string_type cs; \ { cs.tag = string_tag; cs.len = length; \ cs.str = s; } diff --git a/runtime.c b/runtime.c index d4658cf9..5047ce03 100644 --- a/runtime.c +++ b/runtime.c @@ -856,7 +856,8 @@ object Cyc_number2string(object cont, object n) { } else { Cyc_rt_raise2("number->string - Unexpected object", n); } - make_string_noalloc(str, buffer, strlen(buffer)); + //make_string_noalloc(str, buffer, strlen(buffer)); + make_string(str, buffer); return_closcall1(cont, &str); } @@ -891,7 +892,8 @@ object Cyc_list2string(object cont, object lst){ } buf[i] = '\0'; - { make_string_noalloc(str, buf, i); + //{ make_string_noalloc(str, buf, i); + { make_string(str, buf); return_closcall1(cont, &str);} } @@ -960,14 +962,12 @@ integer_type Cyc_string_cmp(object str1, object str2) { } void dispatch_string_91append(int _argc, object clo, object cont, object str1, ...) { - string_type result; va_list ap; va_start(ap, str1); Cyc_string_append_va_list(_argc - 1); } object Cyc_string_append(object cont, int _argc, object str1, ...) { - string_type result; va_list ap; va_start(ap, str1); Cyc_string_append_va_list(_argc); @@ -1042,6 +1042,12 @@ object Cyc_substring(object cont, object str, object start, object end) { { make_string_with_len(sub, raw + s, e - s); +//string_type sub; +//{ int len = e - s; +// sub.tag = string_tag; sub.len = len; +// sub.str = alloca(sizeof(char) * (len + 1)); +// memcpy(sub.str, raw + s, len); +// sub.str[len + 1] = '\0';} return_closcall1(cont, &sub); } }