Skip to content

Commit

Permalink
#2517 ..
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Mar 1, 2025
1 parent 53c32db commit 4ea04ea
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/misc/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,16 @@ static inline char *ts_string_escape(char *s)
int num_replacements = 0;

while (*cursor) {
switch (*cursor) {
case '"':
case '\\':
case '\b':
case '\f':
case '\n':
case '\r':
case '\t':
if ((*cursor == '"') ||
(*cursor == '\\') ||
(*cursor == '\b') ||
(*cursor == '\f') ||
(*cursor == '\n') ||
(*cursor == '\r') ||
(*cursor == '\t')) {
++num_replacements;
break;
default:
if (*cursor >= 0x00 && *cursor <= 0x1f) {
num_replacements += 5;
}
break;
} else if (*cursor >= 0x00 && *cursor <= 0x1f) {
num_replacements += 5;
}

++cursor;
Expand Down

0 comments on commit 4ea04ea

Please sign in to comment.