diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lexer.c | 5 | ||||
-rw-r--r-- | src/shared.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/lexer.c b/src/lexer.c index 5863ef6..a3d5b61 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -85,8 +85,11 @@ char *vstr_strdup(vstr_t *vstr) return str; } -char *vstr_to_cstr(vstr_t *vstr) +const char *vstr_to_cstr(vstr_t *vstr) { + if (!vstr->size) + return NULL; + vstr->data[vstr->size] = '\0'; return vstr->data; } diff --git a/src/shared.h b/src/shared.h index bf4adeb..1554ce9 100644 --- a/src/shared.h +++ b/src/shared.h @@ -131,7 +131,7 @@ void vstr_clear(vstr_t *vstr); int vstr_putc(vstr_t *vstr, char ch); int vstr_cmp(vstr_t *vstr, const char *str); char *vstr_strdup(vstr_t *vstr); -char *vstr_to_cstr(vstr_t *vstr); +const char *vstr_to_cstr(vstr_t *vstr); #define LEXER_BUFFER 1024 |