summaryrefslogtreecommitdiff
path: root/std/string.zc
diff options
context:
space:
mode:
authorczjstmax <jstmaxlol@disroot.org>2026-01-31 15:10:20 +0100
committerGitHub <noreply@github.com>2026-01-31 15:10:20 +0100
commitd2e2617dec584884b92eb452f377b20c0bf8f321 (patch)
treed7cdc28d1a83f16a0fc7e945963aa070bfa9d3e4 /std/string.zc
parent0427d254207a69e394499d1abaea768f484f1cb5 (diff)
parent051400c70a4d5384923113cfbcbc69e8e58d27a0 (diff)
Merge pull request #1 from z-libs/main
Merge newer updates
Diffstat (limited to 'std/string.zc')
-rw-r--r--std/string.zc22
1 files changed, 22 insertions, 0 deletions
diff --git a/std/string.zc b/std/string.zc
index fe5b0ad..0bc9539 100644
--- a/std/string.zc
+++ b/std/string.zc
@@ -55,6 +55,28 @@ impl String {
}
}
+ fn append_c(self, s: char*) {
+ if (self.vec.len > 0) {
+ self.vec.len = self.vec.len - 1;
+ }
+ let len = strlen(s);
+ for (let i = 0; i < len; i = i + 1) {
+ self.vec.push(s[i]);
+ }
+ self.vec.push(0);
+ }
+
+ fn append_c_ptr(ptr: String*, s: char*) {
+ if (ptr.vec.len > 0) {
+ ptr.vec.len = ptr.vec.len - 1;
+ }
+ let len = strlen(s);
+ for (let i = 0; i < len; i = i + 1) {
+ ptr.vec.push(s[i]);
+ }
+ ptr.vec.push(0);
+ }
+
fn add(self, other: String*) -> String {
let new_s = String::from(self.c_str());
new_s.append(other);