summaryrefslogtreecommitdiff
path: root/src/std/str.h
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-03-14 22:08:43 +1100
committerGitHub <noreply@github.com>2024-03-14 22:08:43 +1100
commit70308798adbaa376da97c9c0739d437fe76b8b36 (patch)
tree09836fab6ddc9012a5f4437f2139ab0a704b3a78 /src/std/str.h
parenta627f75cc956a463e3910a8f5f615932bad3a418 (diff)
parentb240374c23365e33727d78ca74e901bcb383e077 (diff)
Merge pull request #5 from omnisci3nce/cel-41-port-over-a-basic-3d-scene-example
CEL 41 port over a basic 3d scene example
Diffstat (limited to 'src/std/str.h')
-rw-r--r--src/std/str.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/std/str.h b/src/std/str.h
index 735b88e..1ebecac 100644
--- a/src/std/str.h
+++ b/src/std/str.h
@@ -10,6 +10,8 @@
*/
#pragma once
+#include <ctype.h>
+
#include "defines.h"
#include "mem.h"
@@ -36,6 +38,11 @@ char* str8_to_cstr(arena* a, str8 s);
#define cstr(a, s) (str8_to_cstr(a, s)) // Shorthand
+/** @brief Return a str8 that references a statically allocated string.
+ `string` therefore must already be null-terminated.
+ @note The backing `string` cannot be modified. */
+str8 str8_cstr_view(char* string);
+
// --- Comparisons
/** @brief Compare two strings for exact equality */
@@ -70,4 +77,9 @@ str8 str8_concat(arena* a, str8 left, str8 right);
static inline bool str8_is_null_term(str8 a) {
return a.buf[a.len] == 0; // This doesn't seem safe. YOLO
-} \ No newline at end of file
+}
+
+// TODO: move or delete this and replace with handling using our internal type
+static void skip_space(char* p) {
+ while (isspace((unsigned char)*p)) ++p;
+}