diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 20:10:42 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-13 20:10:42 -0400 |
| commit | 0c8b2f8e99fdb60ed6ac2648ee49d97b1d675557 (patch) | |
| tree | 37914a883eb261459866712887c6409aa5994f83 /builtins/c_string.c | |
| parent | df9096e6e509513f41473368296fa038120fff83 (diff) | |
Rename c_string.{c,h} -> c_strings.{c,h}
Diffstat (limited to 'builtins/c_string.c')
| -rw-r--r-- | builtins/c_string.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/builtins/c_string.c b/builtins/c_string.c deleted file mode 100644 index 392565ab..00000000 --- a/builtins/c_string.c +++ /dev/null @@ -1,55 +0,0 @@ -// Type info and methods for CString datatype (char*) -#include <ctype.h> -#include <err.h> -#include <gc.h> -#include <stdbool.h> -#include <stdint.h> -#include <stdlib.h> - -#include "text.h" -#include "siphash.h" -#include "util.h" - -public Text_t CString$as_text(const char **c_string, bool colorize, const TypeInfo *info) -{ - (void)info; - if (!c_string) return Text("CString"); - Text_t text = Text$from_str(*c_string); - return Text$concat(colorize ? Text("\x1b[34mCString\x1b[m(") : Text("CString("), Text$quoted(text, colorize), Text(")")); -} - -public Text_t CString$as_text_simple(const char *str) -{ - return Text$format("%s", str); -} - -PUREFUNC public int32_t CString$compare(const char **x, const char **y) -{ - if (x == y) - return 0; - - if (!*x != !*y) - return (!*y) - (!*x); - - return strcmp(*x, *y); -} - -PUREFUNC public bool CString$equal(const char **x, const char **y) -{ - return CString$compare(x, y) == 0; -} - -PUREFUNC public uint64_t CString$hash(const char **c_str) -{ - if (!*c_str) return 0; - return siphash24((void*)*c_str, strlen(*c_str)); -} - -public const TypeInfo CString$info = { - .size=sizeof(char*), - .align=__alignof__(char*), - .tag=CStringInfo, - .CustomInfo={.as_text=(void*)CString$as_text, .compare=(void*)CString$compare, .equal=(void*)CString$equal, .hash=(void*)CString$hash}, -}; - -// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
