diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 288750ca21dd..836bb3446e8d 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,15 +6,15 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2023-11-16 15:03+0000\n" -"Last-Translator: Dan Halbert \n" +"PO-Revision-Date: 2023-11-28 06:04+0000\n" +"Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 5.2\n" +"X-Generator: Weblate 5.3-dev\n" #: main.c msgid "" @@ -1615,7 +1615,7 @@ msgstr "Ok" #: ports/raspberrypi/common-hal/audiobusio/PDMIn.c #, c-format msgid "Only 8 or 16 bit mono with %dx oversampling supported." -msgstr "" +msgstr "Somente mono de 8 ou 16 bits com %dx de sobreamostragem são suportados." #: ports/espressif/common-hal/wifi/__init__.c #: ports/raspberrypi/common-hal/wifi/__init__.c diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 3faa6a94896c..f7294d9038c7 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -137,30 +137,12 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable); STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { #if MICROPY_PY_BUILTINS_STR_UNICODE mp_uint_t c = mp_obj_get_int(o_in); - uint8_t str[4]; - int len = 0; - if (c < 0x80) { - *str = c; - len = 1; - } else if (c < 0x800) { - str[0] = (c >> 6) | 0xC0; - str[1] = (c & 0x3F) | 0x80; - len = 2; - } else if (c < 0x10000) { - str[0] = (c >> 12) | 0xE0; - str[1] = ((c >> 6) & 0x3F) | 0x80; - str[2] = (c & 0x3F) | 0x80; - len = 3; - } else if (c < 0x110000) { - str[0] = (c >> 18) | 0xF0; - str[1] = ((c >> 12) & 0x3F) | 0x80; - str[2] = ((c >> 6) & 0x3F) | 0x80; - str[3] = (c & 0x3F) | 0x80; - len = 4; - } else { + if (c >= 0x110000) { mp_raise_ValueError(MP_ERROR_TEXT("chr() arg not in range(0x110000)")); } - return mp_obj_new_str_via_qstr((char *)str, len); + VSTR_FIXED(buf, 4); + vstr_add_char(&buf, c); + return mp_obj_new_str_via_qstr(buf.buf, buf.len); #else mp_int_t ord = mp_obj_get_int(o_in); if (0 <= ord && ord <= 0xff) { diff --git a/supervisor/shared/translate/translate.c b/supervisor/shared/translate/translate.c index e0b5fb897ac9..e23047c9a24e 100644 --- a/supervisor/shared/translate/translate.c +++ b/supervisor/shared/translate/translate.c @@ -57,37 +57,23 @@ STATIC void get_word(int n, const mchar_t **pos, const mchar_t **end) { *end = *pos + len; } -STATIC int put_utf8(char *buf, int u) { +STATIC void put_utf8(vstr_t *vstr, int u) { if (u >= translation_offstart) { u += translation_offset; } - if (u <= 0x7f) { - *buf = u; - return 1; - } else if (word_start <= u && u <= word_end) { + if (word_start <= u && u <= word_end) { uint n = (u - word_start); const mchar_t *pos, *end; get_word(n, &pos, &end); - int ret = 0; // note that at present, entries in the words table are // guaranteed not to represent words themselves, so this adds // at most 1 level of recursive call for (; pos < end; pos++) { - int len = put_utf8(buf, *pos); - buf += len; - ret += len; + put_utf8(vstr, *pos); } - return ret; - } else if (u <= 0x07ff) { - *buf++ = 0b11000000 | (u >> 6); - *buf = 0b10000000 | (u & 0b00111111); - return 2; - } else { // u <= 0xffff - *buf++ = 0b11100000 | (u >> 12); - *buf++ = 0b10000000 | ((u >> 6) & 0b00111111); - *buf = 0b10000000 | (u & 0b00111111); - return 3; + return; } + vstr_add_char(vstr, u); } uint16_t decompress_length(mp_rom_error_text_t compressed) { @@ -123,15 +109,15 @@ static int get_nbits(bitstream_state_t *st, int n) { return r; } -char *decompress(mp_rom_error_text_t compressed, char *decompressed) { +static void decompress_vstr(mp_rom_error_text_t compressed, vstr_t *decompressed) { bitstream_state_t b = { .ptr = &(compressed->data) + (compress_max_length_bits >> 3), .bit = 1 << (7 - ((compress_max_length_bits) & 0x7)), }; - uint16_t length = decompress_length(compressed); + size_t alloc = decompressed->alloc - 1; // Stop one early because the last byte is always NULL. - for (uint16_t i = 0; i < length - 1;) { + for (; decompressed->len < alloc;) { uint32_t bits = 0; uint8_t bit_length = 0; uint32_t max_code = lengths[0]; @@ -148,16 +134,19 @@ char *decompress(mp_rom_error_text_t compressed, char *decompressed) { int v = values[searched_length + bits - max_code]; if (v == 1) { qstr q = get_nbits(&b, translation_qstr_bits) + 1; // honestly no idea why "+1"... - for (const char *qc = qstr_str(q); *qc;) { - decompressed[i++] = *qc++; - } + vstr_add_str(decompressed, qstr_str(q)); } else { - i += put_utf8(decompressed + i, v); + put_utf8(decompressed, v); } } +} - decompressed[length - 1] = '\0'; - return decompressed; + +char *decompress(mp_rom_error_text_t compressed, char *decompressed) { + vstr_t vstr; + vstr_init_fixed_buf(&vstr, decompress_length(compressed), decompressed); + decompress_vstr(compressed, &vstr); + return vstr_null_terminated_str(&vstr); } #if CIRCUITPY_TRANSLATE_OBJECT == 1