fix: Quote Stick, Pot, Slider and Switch names (#1754)

* Quote stick names

Resolves #1749

* Fix pot, slider and switch names as well.
This commit is contained in:
Raphael Coeffic
2022-03-31 10:39:39 +10:00
committed by GitHub
parent 777b0a48ae
commit b9077c7e5a
2 changed files with 34 additions and 10 deletions
@@ -323,8 +323,11 @@ bool w_stick_name(void* user, uint8_t* data, uint32_t bitoffs,
data -= offsetof(RadioData, switchConfig);
RadioData* rd = reinterpret_cast<RadioData*>(data);
return wf(opaque, rd->anaNames[idx],
strnlen(rd->anaNames[idx], LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, rd->anaNames[idx],
strnlen(rd->anaNames[idx], LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
bool stick_name_valid(void* user, uint8_t* data, uint32_t bitoffs)
@@ -353,7 +356,10 @@ bool sw_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
const char* str = rd->switchNames[idx];
return wf(opaque, str, strnlen(str, LEN_SWITCH_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_SWITCH_NAME)))
return false;
return wf(opaque, "\"", 1);
}
extern const struct YamlIdStr enum_SwitchConfig[];
@@ -394,7 +400,10 @@ bool pot_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
idx += NUM_STICKS;
const char* str = rd->anaNames[idx];
return wf(opaque, str, strnlen(str, LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlIdStr enum_PotConfig[] = {
@@ -444,7 +453,10 @@ bool sl_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
idx += NUM_STICKS + STORAGE_NUM_POTS;
const char* str = rd->anaNames[idx];
return wf(opaque, str, strnlen(str, LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlIdStr enum_SliderConfig[] = {
@@ -557,8 +557,11 @@ static bool w_stick_name(void* user, uint8_t* data, uint32_t bitoffs,
data -= offsetof(RadioData, switchConfig);
RadioData* rd = reinterpret_cast<RadioData*>(data);
return wf(opaque, rd->anaNames[idx],
strnlen(rd->anaNames[idx], LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, rd->anaNames[idx],
strnlen(rd->anaNames[idx], LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static bool stick_name_valid(void* user, uint8_t* data, uint32_t bitoffs)
@@ -602,7 +605,10 @@ static bool sw_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
const char* str = rd->switchNames[idx];
return wf(opaque, str, strnlen(str, LEN_SWITCH_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_SWITCH_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlNode struct_switchConfig[] = {
@@ -658,7 +664,10 @@ static bool pot_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
idx += NUM_STICKS;
const char* str = rd->anaNames[idx];
return wf(opaque, str, strnlen(str, LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlIdStr enum_PotConfig[] = {
@@ -741,7 +750,10 @@ static bool sl_name_write(void* user, uint8_t* data, uint32_t bitoffs,
RadioData* rd = reinterpret_cast<RadioData*>(data);
idx += NUM_STICKS + STORAGE_NUM_POTS;
const char* str = rd->anaNames[idx];
return wf(opaque, str, strnlen(str, LEN_ANA_NAME));
if (!wf(opaque, "\"", 1)) return false;
if (!wf(opaque, str, strnlen(str, LEN_ANA_NAME)))
return false;
return wf(opaque, "\"", 1);
}
static const struct YamlIdStr enum_SliderConfig[] = {