summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-14 06:18:34 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-14 06:22:11 +0300
commitb0bb458810142dac24fc12279c7bc541464a354d (patch)
tree516da6473644b9d1bc186b0b530945069b2d231e
parent2ec38a17d4e357f8f12ee6a2643e2dd2ff7a426e (diff)
downloadmicropython-b0bb458810142dac24fc12279c7bc541464a354d.tar.gz
micropython-b0bb458810142dac24fc12279c7bc541464a354d.zip
unicode: String API is const byte*.
We still have that char vs byte dichotomy, but majority of string operations now use byte.
-rw-r--r--py/lexer.c4
-rw-r--r--py/misc.h4
-rw-r--r--py/unicode.c6
3 files changed, 7 insertions, 7 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 26993922eb..a65df54ba6 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -83,8 +83,8 @@ bool str_strn_equal(const char *str, const char *strn, int len) {
void mp_token_show(const mp_token_t *tok) {
printf("(%d:%d) kind:%d str:%p len:%d", tok->src_line, tok->src_column, tok->kind, tok->str, tok->len);
if (tok->str != NULL && tok->len > 0) {
- const char *i = tok->str;
- const char *j = i + tok->len;
+ const byte *i = (const byte *)tok->str;
+ const byte *j = (const byte *)i + tok->len;
printf(" ");
while (i < j) {
unichar c = utf8_get_char(i);
diff --git a/py/misc.h b/py/misc.h
index fd54147efd..97e16c23ec 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -88,8 +88,8 @@ int m_get_peak_bytes_allocated(void);
typedef int unichar; // TODO
-unichar utf8_get_char(const char *s);
-char *utf8_next_char(const char *s);
+unichar utf8_get_char(const byte *s);
+const byte *utf8_next_char(const byte *s);
bool unichar_isspace(unichar c);
bool unichar_isalpha(unichar c);
diff --git a/py/unicode.c b/py/unicode.c
index 131ddc8108..c8faa57009 100644
--- a/py/unicode.c
+++ b/py/unicode.c
@@ -65,12 +65,12 @@ STATIC const uint8_t attr[] = {
AT_LO, AT_LO, AT_LO, AT_PR, AT_PR, AT_PR, AT_PR, 0
};
-unichar utf8_get_char(const char *s) {
+unichar utf8_get_char(const byte *s) {
return *s;
}
-char *utf8_next_char(const char *s) {
- return (char*)(s + 1);
+const byte *utf8_next_char(const byte *s) {
+ return s + 1;
}
bool unichar_isspace(unichar c) {