@@ -82,58 +82,54 @@ hb_string_T token_type_to_string(const token_type_T type) {
8282 case TOKEN_ERROR : return hb_string ("TOKEN_ERROR" );
8383 case TOKEN_EOF : return hb_string ("TOKEN_EOF" );
8484 }
85-
86- return hb_string ("Unknown token_type_T" );
8785}
8886
89- const char * token_type_to_friendly_string (const token_type_T type ) {
87+ hb_string_T token_type_to_friendly_string (const token_type_T type ) {
9088 switch (type ) {
91- case TOKEN_WHITESPACE : return "whitespace" ;
92- case TOKEN_NBSP : return "non-breaking space" ;
93- case TOKEN_NEWLINE : return "a newline" ;
94- case TOKEN_IDENTIFIER : return "an identifier" ;
95- case TOKEN_HTML_DOCTYPE : return "`<!DOCTYPE`" ;
96- case TOKEN_XML_DECLARATION : return "`<?xml`" ;
97- case TOKEN_XML_DECLARATION_END : return "`?>`" ;
98- case TOKEN_CDATA_START : return "`<![CDATA[`" ;
99- case TOKEN_CDATA_END : return "`]]>`" ;
100- case TOKEN_HTML_TAG_START : return "`<`" ;
101- case TOKEN_HTML_TAG_END : return "`>`" ;
102- case TOKEN_HTML_TAG_START_CLOSE : return "`</`" ;
103- case TOKEN_HTML_TAG_SELF_CLOSE : return "`/>`" ;
104- case TOKEN_HTML_COMMENT_START : return "`<!--`" ;
105- case TOKEN_HTML_COMMENT_END : return "`-->`" ;
106- case TOKEN_HTML_COMMENT_INVALID_END : return "`--!>`" ;
107- case TOKEN_EQUALS : return "`=`" ;
108- case TOKEN_QUOTE : return "a quote" ;
109- case TOKEN_BACKTICK : return "a backtick" ;
110- case TOKEN_BACKSLASH : return "`\\`" ;
111- case TOKEN_DASH : return "`-`" ;
112- case TOKEN_UNDERSCORE : return "`_`" ;
113- case TOKEN_EXCLAMATION : return "`!`" ;
114- case TOKEN_SLASH : return "`/`" ;
115- case TOKEN_SEMICOLON : return "`;`" ;
116- case TOKEN_COLON : return "`:`" ;
117- case TOKEN_AT : return "`@`" ;
118- case TOKEN_LT : return "`<`" ;
119- case TOKEN_PERCENT : return "`%`" ;
120- case TOKEN_AMPERSAND : return "`&`" ;
121- case TOKEN_ERB_START : return "`<%`" ;
122- case TOKEN_ERB_CONTENT : return "ERB content" ;
123- case TOKEN_ERB_END : return "`%>`" ;
124- case TOKEN_CHARACTER : return "a character" ;
125- case TOKEN_ERROR : return "an error token" ;
126- case TOKEN_EOF : return "end of file" ;
89+ case TOKEN_WHITESPACE : return hb_string ( "whitespace" ) ;
90+ case TOKEN_NBSP : return hb_string ( "non-breaking space" ) ;
91+ case TOKEN_NEWLINE : return hb_string ( "a newline" ) ;
92+ case TOKEN_IDENTIFIER : return hb_string ( "an identifier" ) ;
93+ case TOKEN_HTML_DOCTYPE : return hb_string ( "`<!DOCTYPE`" ) ;
94+ case TOKEN_XML_DECLARATION : return hb_string ( "`<?xml`" ) ;
95+ case TOKEN_XML_DECLARATION_END : return hb_string ( "`?>`" ) ;
96+ case TOKEN_CDATA_START : return hb_string ( "`<![CDATA[`" ) ;
97+ case TOKEN_CDATA_END : return hb_string ( "`]]>`" ) ;
98+ case TOKEN_HTML_TAG_START : return hb_string ( "`<`" ) ;
99+ case TOKEN_HTML_TAG_END : return hb_string ( "`>`" ) ;
100+ case TOKEN_HTML_TAG_START_CLOSE : return hb_string ( "`</`" ) ;
101+ case TOKEN_HTML_TAG_SELF_CLOSE : return hb_string ( "`/>`" ) ;
102+ case TOKEN_HTML_COMMENT_START : return hb_string ( "`<!--`" ) ;
103+ case TOKEN_HTML_COMMENT_END : return hb_string ( "`-->`" ) ;
104+ case TOKEN_HTML_COMMENT_INVALID_END : return hb_string ( "`--!>`" ) ;
105+ case TOKEN_EQUALS : return hb_string ( "`=`" ) ;
106+ case TOKEN_QUOTE : return hb_string ( "a quote" ) ;
107+ case TOKEN_BACKTICK : return hb_string ( "a backtick" ) ;
108+ case TOKEN_BACKSLASH : return hb_string ( "`\\`" ) ;
109+ case TOKEN_DASH : return hb_string ( "`-`" ) ;
110+ case TOKEN_UNDERSCORE : return hb_string ( "`_`" ) ;
111+ case TOKEN_EXCLAMATION : return hb_string ( "`!`" ) ;
112+ case TOKEN_SLASH : return hb_string ( "`/`" ) ;
113+ case TOKEN_SEMICOLON : return hb_string ( "`;`" ) ;
114+ case TOKEN_COLON : return hb_string ( "`:`" ) ;
115+ case TOKEN_AT : return hb_string ( "`@`" ) ;
116+ case TOKEN_LT : return hb_string ( "`<`" ) ;
117+ case TOKEN_PERCENT : return hb_string ( "`%`" ) ;
118+ case TOKEN_AMPERSAND : return hb_string ( "`&`" ) ;
119+ case TOKEN_ERB_START : return hb_string ( "`<%`" ) ;
120+ case TOKEN_ERB_CONTENT : return hb_string ( "ERB content" ) ;
121+ case TOKEN_ERB_END : return hb_string ( "`%>`" ) ;
122+ case TOKEN_CHARACTER : return hb_string ( "a character" ) ;
123+ case TOKEN_ERROR : return hb_string ( "an error token" ) ;
124+ case TOKEN_EOF : return hb_string ( "end of file" ) ;
127125 }
128-
129- return "Unknown token type" ;
130126}
131127
132128char * token_types_to_friendly_string_valist (token_type_T first_token , va_list args ) {
133129 if ((int ) first_token == TOKEN_SENTINEL ) { return herb_strdup ("" ); }
134130
135131 size_t count = 0 ;
136- const char * names [32 ];
132+ hb_string_T names [32 ];
137133 token_type_T current = first_token ;
138134
139135 while ((int ) current != TOKEN_SENTINEL && count < 32 ) {
@@ -145,7 +141,7 @@ char* token_types_to_friendly_string_valist(token_type_T first_token, va_list ar
145141 hb_buffer_init (& buffer , 128 );
146142
147143 for (size_t i = 0 ; i < count ; i ++ ) {
148- hb_buffer_append (& buffer , names [i ]);
144+ hb_buffer_append_string (& buffer , names [i ]);
149145
150146 if (i < count - 1 ) {
151147 if (count > 2 ) { hb_buffer_append (& buffer , ", " ); }
0 commit comments