File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,9 @@ void herb_lex_to_buffer(const char* source, hb_buffer_T* output) {
6161 for (size_t i = 0 ; i < hb_array_size (tokens ); i ++ ) {
6262 token_T * token = hb_array_get (tokens , i );
6363
64- char * type = token_to_string (token );
65- hb_buffer_append (output , type );
66- free (type );
64+ hb_string_T type = token_to_string (token );
65+ hb_buffer_append_string (output , type );
66+ free (type . data );
6767
6868 hb_buffer_append (output , "\n" );
6969 }
Original file line number Diff line number Diff line change 44#include "lexer_struct.h"
55#include "position.h"
66#include "token_struct.h"
7+ #include "util/hb_string.h"
78
89token_T * token_init (const char * value , token_type_T type , lexer_T * lexer );
9- char * token_to_string (const token_T * token );
10+ hb_string_T token_to_string (const token_T * token );
1011const char * token_type_to_string (token_type_T type );
1112
1213token_T * token_copy (token_T * token );
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ const char* token_type_to_string(const token_type_T type) {
8383 return "Unknown token_type_T" ;
8484}
8585
86- char * token_to_string (const token_T * token ) {
86+ hb_string_T token_to_string (const token_T * token ) {
8787 const char * type_string = token_type_to_string (token -> type );
8888 const char * template = "#<Herb::Token type=\"%s\" value=\"%.*s\" range=[%u, %u] start=(%u:%u) end=(%u:%u)>" ;
8989
@@ -112,7 +112,7 @@ char* token_to_string(const token_T* token) {
112112
113113 free (escaped .data );
114114
115- return string ;
115+ return hb_string ( string ) ;
116116}
117117
118118token_T * token_copy (token_T * token ) {
You can’t perform that action at this time.
0 commit comments