Consolidate function RemoveSpace

This commit is contained in:
Theo Arends 2020-10-10 17:00:37 +02:00
parent 89c690c05d
commit 5ec972376c
3 changed files with 14 additions and 13 deletions

View File

@ -359,8 +359,8 @@ char* Unescape(char* buffer, uint32_t* size)
return buffer;
}
char* RemoveSpace(char* p)
{
char* RemoveSpace(char* p) {
// Remove white-space character (' ','\t','\n','\v','\f','\r')
char* write = p;
char* read = p;
char ch = '.';
@ -371,12 +371,11 @@ char* RemoveSpace(char* p)
*write++ = ch;
}
}
// *write = '\0'; // Removed 20190223 as it buffer overflows on no isspace found - no need either
return p;
}
char* RemoveControlCharacter(char* p)
{
char* RemoveControlCharacter(char* p) {
// Remove control character (0x00 .. 0x1F and 0x7F)
char* write = p;
char* read = p;
char ch = '.';
@ -391,8 +390,8 @@ char* RemoveControlCharacter(char* p)
return p;
}
char* ReplaceCommaWithDot(char* p)
{
char* ReplaceCommaWithDot(char* p) {
// Replace character ',' with '.'
char* write = (char*)p;
char* read = (char*)p;
char ch = '.';
@ -458,6 +457,7 @@ char* Trim(char* p)
return p;
}
/*
char* RemoveAllSpaces(char* p)
{
// remove any white space from the base64
@ -474,6 +474,7 @@ char* RemoveAllSpaces(char* p)
}
return p;
}
*/
char* NoAlNumToUnderscore(char* dest, const char* source)
{

View File

@ -1174,7 +1174,7 @@ void CmndTlsKey(void) {
memcpy_P(spi_buffer, tls_spi_start, tls_spi_len);
// remove any white space from the base64
RemoveAllSpaces(XdrvMailbox.data);
RemoveSpace(XdrvMailbox.data);
// allocate buffer for decoded base64
uint32_t bin_len = decode_base64_length((unsigned char*)XdrvMailbox.data);

View File

@ -1340,7 +1340,7 @@ bool parseDeviceInnerData(class Z_Device & device, JsonParserObject root) {
//
void CmndZbData(void) {
if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
RemoveAllSpaces(XdrvMailbox.data);
RemoveSpace(XdrvMailbox.data);
if (XdrvMailbox.data[0] == '{') {
// JSON input, enter saved data into memory -- essentially for debugging
JsonParser parser(XdrvMailbox.data);
@ -1448,7 +1448,7 @@ void CmndZbConfig(void) {
int8_t zb_txradio_dbm = Settings.zb_txradio_dbm;
// if (zigbee.init_phase) { ResponseCmndChar_P(PSTR(D_ZIGBEE_NOT_STARTED)); return; }
RemoveAllSpaces(XdrvMailbox.data);
RemoveSpace(XdrvMailbox.data);
if (strlen(XdrvMailbox.data) > 0) {
JsonParser parser(XdrvMailbox.data);
JsonParserObject root = parser.getRootObject();