tur/str-build
stdlib/str-build.tur
minimal cstr-building primitives (str-concat, int->str).
Since: interp-string-natives-and-range-show-plan (Phase 1)
defn
str-concat
(str-concat [a : cstr b : cstr] :)
concatenate two NUL-terminated strings into a new heap buffer.
Parameters
| a | first :cstr (NUL-terminated) | |
| b | second :cstr (NUL-terminated) |
Returns
A newly heap-allocated :cstr containing the bytes of a followed by b, NUL-terminated. The caller is responsible for freeing the returned pointer.
Example
(str-concat "Hello, " "world") ; => "Hello, world"
Since: Phase B1
defn
int->str
(int->str [v : int] :)
format an int64 as a decimal :cstr.
Parameters
| v | the integer to render |
Returns
A freshly heap-allocated NUL-terminated :cstr containing the decimal digits of v (with a leading '-' for negatives). Caller owns the buffer.
Example
(int->str 42) ; => "42" (int->str -7) ; => "-7"
Since: interp-string-natives-and-range-show-plan (Phase 1)