aboutsummaryrefslogtreecommitdiff
path: root/sys/libn/string.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2020-04-30 11:54:19 -0700
committerNicholas Noll <nbnoll@eml.cc>2020-04-30 11:54:19 -0700
commit9e83bf8c3656b736ba3a14d9b7b8af61b48415f4 (patch)
tree4417ac3eafdd744d7a944a6da6bf630844ef5f90 /sys/libn/string.c
parent86134ccf82dcafe338e68c14e483ec98cfc94925 (diff)
chore: move from new to make prefix of constructors
Diffstat (limited to 'sys/libn/string.c')
-rw-r--r--sys/libn/string.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/libn/string.c b/sys/libn/string.c
index d5bb7ef..4280e27 100644
--- a/sys/libn/string.c
+++ b/sys/libn/string.c
@@ -156,7 +156,7 @@ utf8·findrune(byte* s, long c)
// len defines the length of the C substring that we will copy into our buffer.
// The backing buffer will have capacity cap.
string
-str·newcap(const byte* s, vlong len, vlong cap)
+str·makecap(const byte* s, vlong len, vlong cap)
{
struct str·Hdr* h;
@@ -185,34 +185,34 @@ cleanup:
// New returns a new dynamic string object, initialized from the given C string.
// The backing buffer capacity is equivalent to the string length.
string
-str·newlen(const byte* s, vlong len)
+str·makelen(const byte* s, vlong len)
{
vlong sl = (!s) ? 0 : strlen(s);
if (sl < len) panicf("attempted to take a bigger substring than string length");
vlong cap = (len == 0) ? 1 : len;
- return str·newcap(s, len, cap);
+ return str·makecap(s, len, cap);
}
// New returns a new dynamic string object, initialized from the given C string.
// The backing buffer capacity is equivalent to the string length.
string
-str·new(const byte* s)
+str·make(const byte* s)
{
vlong len = (!s) ? 0 : strlen(s);
- return str·newlen(s, len);
+ return str·makelen(s, len);
}
// Newf returns a new dynamic string object
string
-str·newf(const byte* fmt, ...)
+str·makef(const byte* fmt, ...)
{
va_list args;
va_start(args, fmt);
vlong n = vsnprintf(nil, 0, fmt, args);
va_end(args);
- string s = str·newcap(nil, 0, n);
+ string s = str·makecap(nil, 0, n);
va_start(args, fmt);
vsnprintf(s, n + 1, fmt, args);
@@ -473,7 +473,7 @@ str·split(string s, const byte* tok)
for (vlong i = 0; i < sL - tokL; i++) {
if ((tokL == 1 && s[i] == tokL) || !memcmp(s + i, tok, tokL)) {
- bufpush(fields, str·newlen(s + start, i - start));
+ bufpush(fields, str·makelen(s + start, i - start));
if (fields[buflen(fields) - 1] == nil) goto cleanup;
start = i + tokL;
@@ -481,7 +481,7 @@ str·split(string s, const byte* tok)
}
}
- bufpush(fields, str·newlen(s + start, sL - start));
+ bufpush(fields, str·makelen(s + start, sL - start));
return fields;
@@ -496,7 +496,7 @@ cleanup:
string
str·join(vlong len, byte** fields, const byte* sep)
{
- string s = str·newcap(nil, 0, 10);
+ string s = str·makecap(nil, 0, 10);
int j = 0;
for (j = 0; j < len; j++) {