More whitespace fixups

This commit is contained in:
Chris Angelico 2014-06-10 05:05:57 +10:00
parent 086a2a0f57
commit e2c9782a65
2 changed files with 18 additions and 18 deletions

View File

@ -504,12 +504,12 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
case 'r': c = 0x0d; break; case 'r': c = 0x0d; break;
case 'u': case 'u':
case 'U': case 'U':
if (is_bytes) { if (is_bytes) {
// b'\u1234' == b'\\u1234' // b'\u1234' == b'\\u1234'
vstr_add_char(&lex->vstr, '\\'); vstr_add_char(&lex->vstr, '\\');
break; break;
} }
// Otherwise fall through. // Otherwise fall through.
case 'x': case 'x':
{ {
uint num = 0; uint num = 0;
@ -527,7 +527,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
// roughly half a meg of storage. This form of Unicode escape may be added // roughly half a meg of storage. This form of Unicode escape may be added
// later on, but it's definitely not a priority right now. -- CJA 20140607 // later on, but it's definitely not a priority right now. -- CJA 20140607
assert(!"Unicode name escapes not supported"); assert(!"Unicode name escapes not supported");
break; break;
default: default:
if (c >= '0' && c <= '7') { if (c >= '0' && c <= '7') {
// Octal sequence, 1-3 chars // Octal sequence, 1-3 chars
@ -546,13 +546,13 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
} }
} }
if (c != MP_LEXER_CHAR_EOF) { if (c != MP_LEXER_CHAR_EOF) {
if (c < 0x110000 && !is_bytes) { if (c < 0x110000 && !is_bytes) {
vstr_add_char(&lex->vstr, c); vstr_add_char(&lex->vstr, c);
} else if (c < 0x100 && is_bytes) { } else if (c < 0x100 && is_bytes) {
vstr_add_byte(&lex->vstr, c); vstr_add_byte(&lex->vstr, c);
} else { } else {
assert(!"TODO: Throw an error, invalid escape code probably"); assert(!"TODO: Throw an error, invalid escape code probably");
} }
} }
} else { } else {
vstr_add_char(&lex->vstr, CUR_CHAR(lex)); vstr_add_char(&lex->vstr, CUR_CHAR(lex));

View File

@ -205,20 +205,20 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
byte *buf = (byte*)vstr_add_len(vstr, 1); byte *buf = (byte*)vstr_add_len(vstr, 1);
if (buf == NULL) { if (buf == NULL) {
return; return;
} }
*buf = (byte)c; *buf = (byte)c;
} else if (c < 0x800) { } else if (c < 0x800) {
byte *buf = (byte*)vstr_add_len(vstr, 2); byte *buf = (byte*)vstr_add_len(vstr, 2);
if (buf == NULL) { if (buf == NULL) {
return; return;
} }
buf[0] = (c >> 6) | 0xC0; buf[0] = (c >> 6) | 0xC0;
buf[1] = (c & 0x3F) | 0x80; buf[1] = (c & 0x3F) | 0x80;
} else if (c < 0x10000) { } else if (c < 0x10000) {
byte *buf = (byte*)vstr_add_len(vstr, 3); byte *buf = (byte*)vstr_add_len(vstr, 3);
if (buf == NULL) { if (buf == NULL) {
return; return;
} }
buf[0] = (c >> 12) | 0xE0; buf[0] = (c >> 12) | 0xE0;
buf[1] = ((c >> 6) & 0x3F) | 0x80; buf[1] = ((c >> 6) & 0x3F) | 0x80;
buf[2] = (c & 0x3F) | 0x80; buf[2] = (c & 0x3F) | 0x80;
@ -227,7 +227,7 @@ void vstr_add_char(vstr_t *vstr, unichar c) {
byte *buf = (byte*)vstr_add_len(vstr, 4); byte *buf = (byte*)vstr_add_len(vstr, 4);
if (buf == NULL) { if (buf == NULL) {
return; return;
} }
buf[0] = (c >> 18) | 0xF0; buf[0] = (c >> 18) | 0xF0;
buf[1] = ((c >> 12) & 0x3F) | 0x80; buf[1] = ((c >> 12) & 0x3F) | 0x80;
buf[2] = ((c >> 6) & 0x3F) | 0x80; buf[2] = ((c >> 6) & 0x3F) | 0x80;