Do not implicitly concatenate localized strings (#15383)

This commit is contained in:
Marcio Teixeira 2019-09-27 03:38:43 -06:00 committed by Scott Lahteine
parent 62e4e05a19
commit a18d16fb8b
7 changed files with 62 additions and 37 deletions

View file

@ -61,6 +61,13 @@
// Nanoseconds per cycle
#define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU)
// Macros to make sprintf_P read from PROGMEM (AVR extension)
#ifdef __AVR__
#define S_FMT "%S"
#else
#define S_FMT "%s"
#endif
// Macros to make a string from a macro
#define STRINGIFY_(M) #M
#define STRINGIFY(M) STRINGIFY_(M)

View file

@ -715,7 +715,7 @@ G29_TYPE GcodeSuite::G29() {
if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(MSG_PROBING_MESH " %i/%i"), int(pt_index), int(GRID_MAX_POINTS));
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), PSTR(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
#endif
measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(xProbe, yProbe, raise_after, verbose_level);

View file

@ -46,13 +46,13 @@
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe_offset[Z_AXIS]);
}
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
else {
else {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
hotend_offset[Z_AXIS][active_extruder] -= offs;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_Z_OFFSET ": ", hotend_offset[Z_AXIS][active_extruder]);
}
#endif
SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", hotend_offset[Z_AXIS][active_extruder]);
#endif
}
}
#endif

View file

@ -34,6 +34,9 @@
#include "game/game.h"
#endif
#define STATIC_PAIR(MSG, VALUE, CNTR) do{ strcpy_P(buffer, PSTR(": ")); strcpy(buffer + 2, VALUE); STATIC_ITEM(MSG, CNTR, false, buffer); }while(0)
#define STATIC_PAIR_P(MSG, PVALUE, CNTR) do{ strcpy_P(buffer, PSTR(": ")); strcpy_P(buffer + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, CNTR, false, buffer); }while(0)
#if ENABLED(PRINTCOUNTER)
#include "../../module/printcounter.h"
@ -48,27 +51,27 @@
#endif
);
char buffer[21];
char buffer[21]; // for STATIC_PAIR_P
printStatistics stats = print_job_timer.getStats();
START_SCREEN(); // 12345678901234567890
STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, i16tostr3left(stats.totalPrints)); // Print Count: 999
STATIC_ITEM(MSG_INFO_COMPLETED_PRINTS": ", false, false, i16tostr3left(stats.finishedPrints)); // Completed : 666
STATIC_PAIR(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), false); // Print Count: 999
STATIC_PAIR(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), false); // Completed : 666
duration_t elapsed = stats.printTime;
elapsed.toString(buffer);
STATIC_ITEM(MSG_INFO_PRINT_TIME ":", false, false); // Total print Time:
STATIC_PAIR_P(MSG_INFO_PRINT_TIME, "", false); // Total print Time:
STATIC_ITEM("> ", false, false, buffer); // > 99y 364d 23h 59m 59s
STATIC_PAIR_P(MSG_INFO_PRINT_LONGEST, "", false); // Longest job time:
elapsed = stats.longestPrint;
elapsed.toString(buffer);
STATIC_ITEM(MSG_INFO_PRINT_LONGEST ":", false, false); // Longest job time:
STATIC_ITEM("> ", false, false, buffer); // > 99y 364d 23h 59m 59s
STATIC_PAIR_P(MSG_INFO_PRINT_FILAMENT, "", false); // Extruded total:
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
STATIC_ITEM(MSG_INFO_PRINT_FILAMENT ":", false, false); // Extruded total:
STATIC_ITEM("> ", false, false, buffer); // > 125m
#if SERVICE_INTERVAL_1 > 0
@ -77,12 +80,14 @@
STATIC_ITEM(SERVICE_NAME_1 MSG_SERVICE_IN, false, false); // Service X in:
STATIC_ITEM("> ", false, false, buffer); // > 7d 12h 11m 10s
#endif
#if SERVICE_INTERVAL_2 > 0
elapsed = stats.nextService2;
elapsed.toString(buffer);
STATIC_ITEM(SERVICE_NAME_2 MSG_SERVICE_IN, false, false);
STATIC_ITEM("> ", false, false, buffer);
#endif
#if SERVICE_INTERVAL_3 > 0
elapsed = stats.nextService3;
elapsed.toString(buffer);
@ -104,13 +109,16 @@ void menu_info_thermistors() {
true
#endif
);
char buffer[21]; // for STATIC_PAIR_P
START_SCREEN();
#if EXTRUDERS
#define THERMISTOR_ID TEMP_SENSOR_0
#include "../thermistornames.h"
STATIC_ITEM("T0: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_0_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_0_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), false);
#endif
#if TEMP_SENSOR_1 != 0
@ -118,8 +126,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_1
#include "../thermistornames.h"
STATIC_ITEM("T1: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_1_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_1_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), false);
#endif
#if TEMP_SENSOR_2 != 0
@ -127,8 +135,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_2
#include "../thermistornames.h"
STATIC_ITEM("T2: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_2_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_2_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), false);
#endif
#if TEMP_SENSOR_3 != 0
@ -136,8 +144,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_3
#include "../thermistornames.h"
STATIC_ITEM("T3: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_3_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_3_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), false);
#endif
#if TEMP_SENSOR_4 != 0
@ -145,8 +153,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_4
#include "../thermistornames.h"
STATIC_ITEM("T4: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_4_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_4_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), false);
#endif
#if TEMP_SENSOR_5 != 0
@ -154,8 +162,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_5
#include "../thermistornames.h"
STATIC_ITEM("T5: " THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_5_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_5_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), false);
#endif
#if HAS_HEATED_BED
@ -163,8 +171,8 @@ void menu_info_thermistors() {
#define THERMISTOR_ID TEMP_SENSOR_BED
#include "../thermistornames.h"
STATIC_ITEM("TBed:" THERMISTOR_NAME, false, true);
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(BED_MINTEMP), false);
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(BED_MAXTEMP), false);
STATIC_PAIR_P(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), false);
STATIC_PAIR_P(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), false);
#endif
END_SCREEN();
}
@ -178,14 +186,17 @@ void menu_info_board() {
true
#endif
);
char buffer[21]; // for STATIC_PAIR_P
START_SCREEN();
STATIC_ITEM(BOARD_INFO_NAME, true, true); // MyPrinterController
#ifdef BOARD_WEBSITE_URL
STATIC_ITEM(BOARD_WEBSITE_URL, false, false); // www.my3dprinter.com
#endif
STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
STATIC_ITEM(MSG_INFO_PROTOCOL ": " PROTOCOL_VERSION, true); // Protocol: 1.0
STATIC_ITEM(MSG_INFO_PSU ": " PSU_NAME, true);
STATIC_PAIR_P(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), true); // Baud: 250000
STATIC_PAIR_P(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, true); // Protocol: 1.0
STATIC_PAIR_P(MSG_INFO_PSU, PSU_NAME, true);
END_SCREEN();
}

View file

@ -82,10 +82,14 @@ inline void sdcard_start_selected_file() {
#if ENABLED(SD_MENU_CONFIRM_START)
void menu_sd_confirm() {
char * const longest = card.longest_filename();
char buffer[strlen(longest) + 2];
buffer[0] = ' ';
strcpy(buffer + 1, longest);
do_select_screen(
PSTR(MSG_BUTTON_PRINT), PSTR(MSG_BUTTON_CANCEL),
sdcard_start_selected_file, ui.goto_previous_screen,
PSTR(MSG_START_PRINT " "), card.longest_filename(), PSTR("?")
PSTR(MSG_START_PRINT), buffer, PSTR("?")
);
}

View file

@ -373,7 +373,7 @@ void Endstops::event_handler() {
SERIAL_EOL();
#if HAS_SPI_LCD
ui.status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
ui.status_printf_P(0, PSTR(S_FMT " %c %c %c %c"), PSTR(MSG_LCD_ENDSTOPS), chrX, chrY, chrZ, chrP);
#endif
#if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT)

View file

@ -2933,11 +2933,14 @@ void Temperature::isr() {
#if HOTENDS && HAS_DISPLAY
void Temperature::set_heating_message(const uint8_t e) {
const bool heating = isHeatingHotend(e);
#if HOTENDS > 1
ui.status_printf_P(0, heating ? PSTR("E%c " MSG_HEATING) : PSTR("E%c " MSG_COOLING), '1' + e);
#else
ui.set_status_P(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
#endif
ui.status_printf_P(0,
#if HOTENDS > 1
PSTR("E%c " S_FMT), '1' + e
#else
PSTR("E " S_FMT)
#endif
, heating ? PSTR(MSG_HEATING) : PSTR(MSG_COOLING)
);
}
#endif