aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/lexer.c9
-rw-r--r--asm/lexer.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/asm/lexer.c b/asm/lexer.c
index 6358e95..7d1ad8c 100644
--- a/asm/lexer.c
+++ b/asm/lexer.c
@@ -130,6 +130,15 @@ const char *lerr_as_cstr(lerr_t lerr)
return "";
}
+token_t token_copy(token_t t)
+{
+ token_t new = t;
+ new.str = malloc(t.str_size + 1);
+ memcpy(new.str, t.str, t.str_size);
+ new.str[t.str_size] = '\0';
+ return new;
+}
+
size_t space_left(buffer_t *buffer)
{
if (buffer->available == buffer->used)
diff --git a/asm/lexer.h b/asm/lexer.h
index 3434b72..734ffa1 100644
--- a/asm/lexer.h
+++ b/asm/lexer.h
@@ -71,6 +71,8 @@ typedef struct
size_t str_size;
} token_t;
+token_t token_copy(token_t);
+
typedef enum
{
LERR_OK = 0,