mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 13:37:57 +03:00
Added prn for Strings, make 'str' not print with @ and quotes.
This commit is contained in:
parent
5c6bdb87d8
commit
e80af19a39
@ -8,6 +8,7 @@
|
||||
(register duplicate (Fn [&String] String))
|
||||
(register cstr (Fn [&String] (Ptr Char)))
|
||||
(register str (Fn [&String] String))
|
||||
(register prn (Fn [&String] String))
|
||||
(register char-at (Fn [&String Int] Char))
|
||||
(register chars (Fn [&String] (Array Char)))
|
||||
(register from-chars (Fn [(Array Char)] String))
|
||||
|
@ -299,6 +299,13 @@ char* String_cstr(string *s) {
|
||||
string String_str(string *s) {
|
||||
int n = strlen(*s) + 4;
|
||||
string buffer = CARP_MALLOC(n);
|
||||
snprintf(buffer, n, "%s", *s);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
string String_prn(string *s) {
|
||||
int n = strlen(*s) + 1;
|
||||
string buffer = CARP_MALLOC(n);
|
||||
snprintf(buffer, n, "@\"%s\"", *s);
|
||||
return buffer;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@
|
||||
"or* macro works as expected II"
|
||||
)
|
||||
(assert-equal test
|
||||
"1@\" thing \"2@\" things\""
|
||||
"1 thing 2 things"
|
||||
&(str* 1 " thing " 2 " things")
|
||||
"str* macro works as expected"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user