Skip to content

Commit 50f5d27

Browse files
authored
Merge pull request adafruit#1325 from tannewt/fix_overruns
Fix output overflow and make help translatable
2 parents 97bc951 + d012fd1 commit 50f5d27

File tree

15 files changed

+567
-462
lines changed

15 files changed

+567
-462
lines changed

lib/utils/stdout_helpers.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@
1212
// Send "cooked" string of given length, where every occurrence of
1313
// LF character is replaced with CR LF.
1414
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
15-
while (len--) {
16-
if (*str == '\n') {
15+
bool last_cr = false;
16+
while (len > 0) {
17+
size_t i = 0;
18+
if (str[0] == '\n' && !last_cr) {
1719
mp_hal_stdout_tx_strn("\r", 1);
20+
i = 1;
1821
}
19-
mp_hal_stdout_tx_strn(str++, 1);
22+
// Lump all characters on the next line together.
23+
while((last_cr || str[i] != '\n') && i < len) {
24+
last_cr = str[i] == '\r';
25+
i++;
26+
}
27+
mp_hal_stdout_tx_strn(str, i);
28+
str = &str[i];
29+
len -= i;
2030
}
2131
}
2232

locale/circuitpython.pot

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2018-11-07 14:10-0500\n"
11+
"POT-Creation-Date: 2018-11-09 16:20-0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -151,70 +151,70 @@ msgstr ""
151151
msgid "script compilation not supported"
152152
msgstr ""
153153

154-
#: main.c:153
154+
#: main.c:154
155155
msgid " output:\n"
156156
msgstr ""
157157

158-
#: main.c:167 main.c:240
158+
#: main.c:168 main.c:241
159159
msgid ""
160160
"Auto-reload is on. Simply save files over USB to run them or enter REPL to "
161161
"disable.\n"
162162
msgstr ""
163163

164-
#: main.c:169
164+
#: main.c:170
165165
msgid "Running in safe mode! Auto-reload is off.\n"
166166
msgstr ""
167167

168-
#: main.c:171 main.c:242
168+
#: main.c:172 main.c:243
169169
msgid "Auto-reload is off.\n"
170170
msgstr ""
171171

172-
#: main.c:185
172+
#: main.c:186
173173
msgid "Running in safe mode! Not running saved code.\n"
174174
msgstr ""
175175

176-
#: main.c:201
176+
#: main.c:202
177177
msgid "WARNING: Your code filename has two extensions\n"
178178
msgstr ""
179179

180-
#: main.c:249
180+
#: main.c:250
181181
msgid "You requested starting safe mode by "
182182
msgstr ""
183183

184-
#: main.c:252
184+
#: main.c:253
185185
msgid "To exit, please reset the board without "
186186
msgstr ""
187187

188-
#: main.c:259
188+
#: main.c:260
189189
msgid ""
190190
"You are running in safe mode which means something really bad happened.\n"
191191
msgstr ""
192192

193-
#: main.c:261
193+
#: main.c:262
194194
msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
195195
msgstr ""
196196

197-
#: main.c:262
197+
#: main.c:263
198198
msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n"
199199
msgstr ""
200200

201-
#: main.c:265
201+
#: main.c:266
202202
msgid ""
203203
"The microcontroller's power dipped. Please make sure your power supply "
204204
"provides\n"
205205
msgstr ""
206206

207-
#: main.c:266
207+
#: main.c:267
208208
msgid ""
209209
"enough power for the whole circuit and press reset (after ejecting "
210210
"CIRCUITPY).\n"
211211
msgstr ""
212212

213-
#: main.c:270
213+
#: main.c:271
214214
msgid "Press any key to enter the REPL. Use CTRL-D to reload."
215215
msgstr ""
216216

217-
#: main.c:426
217+
#: main.c:429
218218
msgid "soft reboot\n"
219219
msgstr ""
220220

@@ -359,7 +359,7 @@ msgid "Not enough pins available"
359359
msgstr ""
360360

361361
#: ports/atmel-samd/common-hal/busio/I2C.c:78
362-
#: ports/atmel-samd/common-hal/busio/SPI.c:132
362+
#: ports/atmel-samd/common-hal/busio/SPI.c:171
363363
#: ports/atmel-samd/common-hal/busio/UART.c:119
364364
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
365365
#: ports/nrf/common-hal/busio/I2C.c:82
@@ -403,7 +403,7 @@ msgid "No TX pin"
403403
msgstr ""
404404

405405
#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170
406-
#: ports/nrf/common-hal/digitalio/DigitalInOut.c:142
406+
#: ports/nrf/common-hal/digitalio/DigitalInOut.c:147
407407
msgid "Cannot get pull while in output mode"
408408
msgstr ""
409409

@@ -463,30 +463,10 @@ msgstr ""
463463
msgid "calibration value out of range +/-127"
464464
msgstr ""
465465

466-
#: ports/atmel-samd/common-hal/storage/__init__.c:48
467-
msgid "Cannot remount '/' when USB is active."
468-
msgstr ""
469-
470466
#: ports/atmel-samd/common-hal/touchio/TouchIn.c:75
471467
msgid "No free GCLKs"
472468
msgstr ""
473469

474-
#: ports/atmel-samd/common-hal/usb_hid/Device.c:78
475-
#: ports/nrf/common-hal/usb_hid/Device.c:45
476-
#, c-format
477-
msgid "Buffer incorrect size. Should be %d bytes."
478-
msgstr ""
479-
480-
#: ports/atmel-samd/common-hal/usb_hid/Device.c:82
481-
#: ports/nrf/common-hal/usb_hid/Device.c:53
482-
msgid "USB Busy"
483-
msgstr ""
484-
485-
#: ports/atmel-samd/common-hal/usb_hid/Device.c:82
486-
#: ports/nrf/common-hal/usb_hid/Device.c:59
487-
msgid "USB Error"
488-
msgstr ""
489-
490470
#: ports/esp8266/common-hal/analogio/AnalogIn.c:43
491471
msgid "Pin %q does not have ADC capabilities"
492472
msgstr ""
@@ -823,7 +803,7 @@ msgstr ""
823803
msgid "All I2C peripherals are in use"
824804
msgstr ""
825805

826-
#: ports/nrf/common-hal/busio/SPI.c:115
806+
#: ports/nrf/common-hal/busio/SPI.c:133
827807
msgid "All SPI peripherals are in use"
828808
msgstr ""
829809

@@ -958,6 +938,20 @@ msgstr ""
958938
msgid "bad compile mode"
959939
msgstr ""
960940

941+
#: py/builtinhelp.c:137
942+
msgid "Plus any modules on the filesystem\n"
943+
msgstr ""
944+
945+
#: py/builtinhelp.c:183
946+
#, c-format
947+
msgid ""
948+
"Welcome to Adafruit CircuitPython %s!\n"
949+
"\n"
950+
"Please visit learn.adafruit.com/category/circuitpython for project guides.\n"
951+
"\n"
952+
"To list built-in modules please do `help(\"modules\")`.\n"
953+
msgstr ""
954+
961955
#: py/builtinimport.c:336
962956
msgid "cannot perform relative import"
963957
msgstr ""
@@ -2440,27 +2434,27 @@ msgstr ""
24402434
msgid "Clock stretch too long"
24412435
msgstr ""
24422436

2443-
#: shared-module/bitbangio/SPI.c:45
2437+
#: shared-module/bitbangio/SPI.c:44
24442438
msgid "Clock pin init failed."
24452439
msgstr ""
24462440

2447-
#: shared-module/bitbangio/SPI.c:51
2441+
#: shared-module/bitbangio/SPI.c:50
24482442
msgid "MOSI pin init failed."
24492443
msgstr ""
24502444

2451-
#: shared-module/bitbangio/SPI.c:62
2445+
#: shared-module/bitbangio/SPI.c:61
24522446
msgid "MISO pin init failed."
24532447
msgstr ""
24542448

2455-
#: shared-module/bitbangio/SPI.c:122
2449+
#: shared-module/bitbangio/SPI.c:121
24562450
msgid "Cannot write without MOSI pin."
24572451
msgstr ""
24582452

2459-
#: shared-module/bitbangio/SPI.c:177
2453+
#: shared-module/bitbangio/SPI.c:176
24602454
msgid "Cannot read without MISO pin."
24612455
msgstr ""
24622456

2463-
#: shared-module/bitbangio/SPI.c:241
2457+
#: shared-module/bitbangio/SPI.c:240
24642458
msgid "Cannot transfer without MOSI and MISO pins."
24652459
msgstr ""
24662460

@@ -2494,10 +2488,27 @@ msgstr ""
24942488
msgid "Only true color (24 bpp or higher) BMP supported %x"
24952489
msgstr ""
24962490

2491+
#: shared-module/storage/__init__.c:155
2492+
msgid "Cannot remount '/' when USB is active."
2493+
msgstr ""
2494+
24972495
#: shared-module/struct/__init__.c:39
24982496
msgid "'S' and 'O' are not supported format types"
24992497
msgstr ""
25002498

25012499
#: shared-module/struct/__init__.c:83
25022500
msgid "too many arguments provided with the given format"
25032501
msgstr ""
2502+
2503+
#: shared-module/usb_hid/Device.c:45
2504+
#, c-format
2505+
msgid "Buffer incorrect size. Should be %d bytes."
2506+
msgstr ""
2507+
2508+
#: shared-module/usb_hid/Device.c:53
2509+
msgid "USB Busy"
2510+
msgstr ""
2511+
2512+
#: shared-module/usb_hid/Device.c:59
2513+
msgid "USB Error"
2514+
msgstr ""

0 commit comments

Comments
 (0)