Skip to content

Commit 1d9a0c0

Browse files
committed
Merge branch 'main' of github.com:AdamCummick/circuitpython into add_p1am_200
2 parents 3b3b12e + 1cfb894 commit 1d9a0c0

File tree

3 files changed

+25
-54
lines changed

3 files changed

+25
-54
lines changed

locale/pt_BR.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
77
"Report-Msgid-Bugs-To: \n"
88
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
9-
"PO-Revision-Date: 2023-11-16 15:03+0000\n"
10-
"Last-Translator: Dan Halbert <[email protected]>\n"
9+
"PO-Revision-Date: 2023-11-28 06:04+0000\n"
10+
"Last-Translator: Wellington Terumi Uemura <[email protected]>\n"
1111
"Language-Team: \n"
1212
"Language: pt_BR\n"
1313
"MIME-Version: 1.0\n"
1414
"Content-Type: text/plain; charset=UTF-8\n"
1515
"Content-Transfer-Encoding: 8bit\n"
1616
"Plural-Forms: nplurals=2; plural=n > 1;\n"
17-
"X-Generator: Weblate 5.2\n"
17+
"X-Generator: Weblate 5.3-dev\n"
1818

1919
#: main.c
2020
msgid ""
@@ -1615,7 +1615,7 @@ msgstr "Ok"
16151615
#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c
16161616
#, c-format
16171617
msgid "Only 8 or 16 bit mono with %dx oversampling supported."
1618-
msgstr ""
1618+
msgstr "Somente mono de 8 ou 16 bits com %dx de sobreamostragem são suportados."
16191619

16201620
#: ports/espressif/common-hal/wifi/__init__.c
16211621
#: ports/raspberrypi/common-hal/wifi/__init__.c

py/modbuiltins.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,12 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
137137
STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
138138
#if MICROPY_PY_BUILTINS_STR_UNICODE
139139
mp_uint_t c = mp_obj_get_int(o_in);
140-
uint8_t str[4];
141-
int len = 0;
142-
if (c < 0x80) {
143-
*str = c;
144-
len = 1;
145-
} else if (c < 0x800) {
146-
str[0] = (c >> 6) | 0xC0;
147-
str[1] = (c & 0x3F) | 0x80;
148-
len = 2;
149-
} else if (c < 0x10000) {
150-
str[0] = (c >> 12) | 0xE0;
151-
str[1] = ((c >> 6) & 0x3F) | 0x80;
152-
str[2] = (c & 0x3F) | 0x80;
153-
len = 3;
154-
} else if (c < 0x110000) {
155-
str[0] = (c >> 18) | 0xF0;
156-
str[1] = ((c >> 12) & 0x3F) | 0x80;
157-
str[2] = ((c >> 6) & 0x3F) | 0x80;
158-
str[3] = (c & 0x3F) | 0x80;
159-
len = 4;
160-
} else {
140+
if (c >= 0x110000) {
161141
mp_raise_ValueError(MP_ERROR_TEXT("chr() arg not in range(0x110000)"));
162142
}
163-
return mp_obj_new_str_via_qstr((char *)str, len);
143+
VSTR_FIXED(buf, 4);
144+
vstr_add_char(&buf, c);
145+
return mp_obj_new_str_via_qstr(buf.buf, buf.len);
164146
#else
165147
mp_int_t ord = mp_obj_get_int(o_in);
166148
if (0 <= ord && ord <= 0xff) {

supervisor/shared/translate/translate.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,23 @@ STATIC void get_word(int n, const mchar_t **pos, const mchar_t **end) {
5757
*end = *pos + len;
5858
}
5959

60-
STATIC int put_utf8(char *buf, int u) {
60+
STATIC void put_utf8(vstr_t *vstr, int u) {
6161
if (u >= translation_offstart) {
6262
u += translation_offset;
6363
}
64-
if (u <= 0x7f) {
65-
*buf = u;
66-
return 1;
67-
} else if (word_start <= u && u <= word_end) {
64+
if (word_start <= u && u <= word_end) {
6865
uint n = (u - word_start);
6966
const mchar_t *pos, *end;
7067
get_word(n, &pos, &end);
71-
int ret = 0;
7268
// note that at present, entries in the words table are
7369
// guaranteed not to represent words themselves, so this adds
7470
// at most 1 level of recursive call
7571
for (; pos < end; pos++) {
76-
int len = put_utf8(buf, *pos);
77-
buf += len;
78-
ret += len;
72+
put_utf8(vstr, *pos);
7973
}
80-
return ret;
81-
} else if (u <= 0x07ff) {
82-
*buf++ = 0b11000000 | (u >> 6);
83-
*buf = 0b10000000 | (u & 0b00111111);
84-
return 2;
85-
} else { // u <= 0xffff
86-
*buf++ = 0b11100000 | (u >> 12);
87-
*buf++ = 0b10000000 | ((u >> 6) & 0b00111111);
88-
*buf = 0b10000000 | (u & 0b00111111);
89-
return 3;
74+
return;
9075
}
76+
vstr_add_char(vstr, u);
9177
}
9278

9379
uint16_t decompress_length(mp_rom_error_text_t compressed) {
@@ -123,15 +109,15 @@ static int get_nbits(bitstream_state_t *st, int n) {
123109
return r;
124110
}
125111

126-
char *decompress(mp_rom_error_text_t compressed, char *decompressed) {
112+
static void decompress_vstr(mp_rom_error_text_t compressed, vstr_t *decompressed) {
127113
bitstream_state_t b = {
128114
.ptr = &(compressed->data) + (compress_max_length_bits >> 3),
129115
.bit = 1 << (7 - ((compress_max_length_bits) & 0x7)),
130116
};
131-
uint16_t length = decompress_length(compressed);
132117

118+
size_t alloc = decompressed->alloc - 1;
133119
// Stop one early because the last byte is always NULL.
134-
for (uint16_t i = 0; i < length - 1;) {
120+
for (; decompressed->len < alloc;) {
135121
uint32_t bits = 0;
136122
uint8_t bit_length = 0;
137123
uint32_t max_code = lengths[0];
@@ -148,16 +134,19 @@ char *decompress(mp_rom_error_text_t compressed, char *decompressed) {
148134
int v = values[searched_length + bits - max_code];
149135
if (v == 1) {
150136
qstr q = get_nbits(&b, translation_qstr_bits) + 1; // honestly no idea why "+1"...
151-
for (const char *qc = qstr_str(q); *qc;) {
152-
decompressed[i++] = *qc++;
153-
}
137+
vstr_add_str(decompressed, qstr_str(q));
154138
} else {
155-
i += put_utf8(decompressed + i, v);
139+
put_utf8(decompressed, v);
156140
}
157141
}
142+
}
158143

159-
decompressed[length - 1] = '\0';
160-
return decompressed;
144+
145+
char *decompress(mp_rom_error_text_t compressed, char *decompressed) {
146+
vstr_t vstr;
147+
vstr_init_fixed_buf(&vstr, decompress_length(compressed), decompressed);
148+
decompress_vstr(compressed, &vstr);
149+
return vstr_null_terminated_str(&vstr);
161150
}
162151

163152
#if CIRCUITPY_TRANSLATE_OBJECT == 1

0 commit comments

Comments
 (0)