feat(core): rename string and stream functions for clarity

- Rename `cstring_push` to `cstring_append_ch` and `cstring_push_cstr` to `cstring_append_cstr` for consistent naming with new `cstring_append` function
- Update all callers in lexer and tests to use new function names
- Rename stream `destroy` method to `drop` for consistency with resource management conventions
- Fix potential overflow in string capacity calculation by adjusting growth logic
This commit is contained in:
zzy
2025-12-09 18:04:53 +08:00
parent 36bff64a91
commit 186602a301
5 changed files with 28 additions and 16 deletions

View File

@@ -293,7 +293,7 @@ cbool lex_parse_string(core_probe_stream_t *input, core_pos_t *pos,
if (val == -1) {
LOG_ERROR("Invalid escape character it is \\%c [%d]", ch, ch);
} else {
cstring_push(&str, val);
cstring_append_ch(&str, val);
continue;
}
} else if (ch == '"') {
@@ -304,7 +304,7 @@ cbool lex_parse_string(core_probe_stream_t *input, core_pos_t *pos,
core_probe_stream_consume(stream);
core_pos_next(pos);
cstring_push(&str, ch);
cstring_append_ch(&str, ch);
}
*output = str;
@@ -419,7 +419,7 @@ cbool lex_parse_identifier(core_probe_stream_t *input, core_pos_t *pos,
} else if (ch == '_' || (ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z')) {
while (1) {
cstring_push(output, ch);
cstring_append_ch(output, ch);
core_probe_stream_consume(stream);
core_pos_next(pos);
ch = core_probe_stream_peek(stream);