aboutsummaryrefslogtreecommitdiff
path: root/py/lexer.c
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2015-05-18 14:41:25 -0700
committerDamien George <damien.p.george@gmail.com>2015-05-20 09:29:22 +0100
commit3ad94d6072555955a796c8c72a526c4fdff86711 (patch)
treec845f32926a12105b6929b422c3b66c55f098481 /py/lexer.c
parent97ce883217c646a2d2bc9bf6bfce6e2eaa731dae (diff)
extmod: Add ubinascii.unhexlify
This also pulls out hex_digit from py/lexer.c and makes unichar_hex_digit
Diffstat (limited to 'py/lexer.c')
-rw-r--r--py/lexer.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 536208e41..12cb5ae5b 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -261,16 +261,6 @@ STATIC const char *tok_kw[] = {
"__debug__",
};
-STATIC mp_uint_t hex_digit(unichar c) {
- // c is assumed to be hex digit
- mp_uint_t n = c - '0';
- if (n > 9) {
- n &= ~('a' - 'A');
- n -= ('A' - ('9' + 1));
- }
- return n;
-}
-
// This is called with CUR_CHAR() before first hex digit, and should return with
// it pointing to last hex digit
// num_digits must be greater than zero
@@ -282,7 +272,7 @@ STATIC bool get_hex(mp_lexer_t *lex, mp_uint_t num_digits, mp_uint_t *result) {
if (!unichar_isxdigit(c)) {
return false;
}
- num = (num << 4) + hex_digit(c);
+ num = (num << 4) + unichar_xdigit_value(c);
}
*result = num;
return true;