diff options
Diffstat (limited to 'include/str.h')
-rw-r--r-- | include/str.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/include/str.h b/include/str.h index b208515..277a6f3 100644 --- a/include/str.h +++ b/include/str.h @@ -7,20 +7,18 @@ #include <stddef.h> #include <stdbool.h> +#include "array.h" // string library taken from cuddlesOS: // https://github.com/cuddlesOS/cuddles/blob/master/stage3/string.c -// arr -#define len(X) (sizeof X / sizeof *X) -#define array(T) struct { size_t len; T *data; } - typedef array(char) str; -#define S(X) ((str) { len(X)-1, X }) #define NILS ((str) { 0, NULL }) +#define S(X) ((str) { len(X)-1, X }) +#define PSTR(X) (int) (X).len, (X).data -typedef struct { size_t cap; str buf; } strbuf; -#define NILSBUF ((strbuf) { 0, NILS }) +typedef arraybuf(char) strbuf; +#define NILSBUF ((strbuf) { 0, 0, NULL }) // compares two strings by length and ASCII values. return value: // < 0 if s1 < s2 |