AP_Scripting: bindings: logging: add flag to copy format strings

This commit is contained in:
Iampete1 2022-10-26 17:01:59 +01:00 committed by Andrew Tridgell
parent 1df00d879a
commit 1547c65ff3
2 changed files with 4 additions and 4 deletions

View File

@ -1187,9 +1187,9 @@ AP_Logger::log_write_fmt *AP_Logger::msg_fmt_for_name(const char *name, const ch
memcpy((char*)ls_strings.format, f->fmt, MIN(sizeof(ls_strings.format), strlen(f->fmt)));
memcpy((char*)ls_strings.labels, f->labels, MIN(sizeof(ls_strings.labels), strlen(f->labels)));
if (f->units != nullptr) {
memcpy((char*)ls_strings.units, f->units, MIN(sizeof(ls.units), strlen(f->units)));
memcpy((char*)ls_strings.units, f->units, MIN(sizeof(ls_strings.units), strlen(f->units)));
} else {
memset((char*)ls_strings.units, '?', MIN(sizeof(ls.format), strlen(f->fmt)));
memset((char*)ls_strings.units, '?', MIN(sizeof(ls_strings.format), strlen(f->fmt)));
}
if (f->mults != nullptr) {
memcpy((char*)ls_strings.multipliers, f->mults, MIN(sizeof(ls_strings.multipliers), strlen(f->mults)));

View File

@ -130,7 +130,7 @@ int AP_Logger_Write(lua_State *L) {
struct AP_Logger::log_write_fmt *f;
if (!have_units) {
// ask for a mesage type
f = AP_logger->msg_fmt_for_name(name, label_cat, nullptr, nullptr, fmt_cat, true);
f = AP_logger->msg_fmt_for_name(name, label_cat, nullptr, nullptr, fmt_cat, true, true);
} else {
// read in units and multiplers strings
@ -153,7 +153,7 @@ int AP_Logger_Write(lua_State *L) {
strcat(multipliers_cat,multipliers);
// ask for a mesage type
f = AP_logger->msg_fmt_for_name(name, label_cat, units_cat, multipliers_cat, fmt_cat, true);
f = AP_logger->msg_fmt_for_name(name, label_cat, units_cat, multipliers_cat, fmt_cat, true, true);
}
if (f == nullptr) {