diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-01 12:45:37 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-01 12:45:37 -0500 |
commit | e53329668e403a6b73bc8c9b56ad6b55eecba4e9 (patch) | |
tree | ca87e777053112f5de53155374f2272d6aad0ca1 /syntax.c | |
parent | 11b50663dc489b7ec8cb1c8774d9bda2c7acac3b (diff) |
fix C hex literal highlighting
also open to untitled empty buffer
Diffstat (limited to 'syntax.c')
-rw-r--r-- | syntax.c | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -45,7 +45,7 @@ static void syntax_highlight_c(SyntaxStateC *state, char32_t *line, u32 line_len bool in_multi_line_comment = state->multi_line_comment; bool in_char = false; bool in_number = false; - + int backslashes = 0; for (u32 i = 0; i < line_len; ++i) { SyntaxCharType type = SYNTAX_NORMAL; @@ -92,14 +92,6 @@ static void syntax_highlight_c(SyntaxStateC *state, char32_t *line, u32 line_len else if (!in_multi_line_comment && !in_single_line_comment && !in_string) in_char = in_char_now = true; break; - case '<': // preprocessor string, e.g. <stdio.h> - if (in_preprocessor && !in_char) - in_string = in_string_now = true; - break; - case '>': - if (in_preprocessor && in_string) - in_string = false; - break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': // don't you wish C had case ranges... // a number! if (!in_single_line_comment && !in_multi_line_comment && !in_string && !in_number && !in_char) { @@ -209,8 +201,9 @@ static void syntax_highlight_c(SyntaxStateC *state, char32_t *line, u32 line_len } break; } if (line[i] != '\\') backslashes = 0; - if (in_number && !(is32_digit(line[i]) || line[i] == '.' || line[i] == 'e' || - (i && line[i-1] == 'e' && (line[i] == '+' || line[i] == '-')))) { + if (in_number && !(is32_digit(line[i]) || line[i] == '.' + || (line[i] < CHAR_MAX && strchr("xXoObBlLuU", (char)line[i])) + || (i && line[i-1] == 'e' && (line[i] == '+' || line[i] == '-')))) { in_number = false; } |