Skip to content

Commit b0bb458

Browse files
committed
unicode: String API is const byte*.
We still have that char vs byte dichotomy, but majority of string operations now use byte.
1 parent 2ec38a1 commit b0bb458

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

py/lexer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ bool str_strn_equal(const char *str, const char *strn, int len) {
8383
void mp_token_show(const mp_token_t *tok) {
8484
printf("(%d:%d) kind:%d str:%p len:%d", tok->src_line, tok->src_column, tok->kind, tok->str, tok->len);
8585
if (tok->str != NULL && tok->len > 0) {
86-
const char *i = tok->str;
87-
const char *j = i + tok->len;
86+
const byte *i = (const byte *)tok->str;
87+
const byte *j = (const byte *)i + tok->len;
8888
printf(" ");
8989
while (i < j) {
9090
unichar c = utf8_get_char(i);

py/misc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ int m_get_peak_bytes_allocated(void);
8888

8989
typedef int unichar; // TODO
9090

91-
unichar utf8_get_char(const char *s);
92-
char *utf8_next_char(const char *s);
91+
unichar utf8_get_char(const byte *s);
92+
const byte *utf8_next_char(const byte *s);
9393

9494
bool unichar_isspace(unichar c);
9595
bool unichar_isalpha(unichar c);

py/unicode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ STATIC const uint8_t attr[] = {
6565
AT_LO, AT_LO, AT_LO, AT_PR, AT_PR, AT_PR, AT_PR, 0
6666
};
6767

68-
unichar utf8_get_char(const char *s) {
68+
unichar utf8_get_char(const byte *s) {
6969
return *s;
7070
}
7171

72-
char *utf8_next_char(const char *s) {
73-
return (char*)(s + 1);
72+
const byte *utf8_next_char(const byte *s) {
73+
return s + 1;
7474
}
7575

7676
bool unichar_isspace(unichar c) {

0 commit comments

Comments
 (0)