mirror of https://github.com/arendst/Tasmota.git
Merge pull request #3717 from ascillato/patch-1
Code Simplification for Substr
This commit is contained in:
commit
b1f0203130
|
@ -143,7 +143,7 @@ char* subStr(char* dest, char* str, const char *delim, int index)
|
|||
int i;
|
||||
|
||||
// Since strtok consumes the first arg, make a copy
|
||||
strncpy(dest, str, strlen(str));
|
||||
strncpy(dest, str, strlen(str)+1);
|
||||
for (i = 1, act = dest; i <= index; i++, act = NULL) {
|
||||
sub = strtok_r(act, delim, &ptr);
|
||||
if (sub == NULL) break;
|
||||
|
|
|
@ -1156,7 +1156,7 @@ boolean KnxCommand()
|
|||
else if (CMND_KNX_PA == command_code) {
|
||||
if (XdrvMailbox.data_len) {
|
||||
if (strstr(XdrvMailbox.data, ".")) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
char sub_string[XdrvMailbox.data_len];
|
||||
|
||||
int pa_area = atoi(subStr(sub_string, XdrvMailbox.data, ".", 1));
|
||||
int pa_line = atoi(subStr(sub_string, XdrvMailbox.data, ".", 2));
|
||||
|
@ -1183,7 +1183,7 @@ boolean KnxCommand()
|
|||
else if ((CMND_KNX_GA == command_code) && (index > 0) && (index <= MAX_KNX_GA)) {
|
||||
if (XdrvMailbox.data_len) {
|
||||
if (strstr(XdrvMailbox.data, ",")) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
char sub_string[XdrvMailbox.data_len];
|
||||
|
||||
int ga_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
|
||||
int ga_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
|
||||
|
@ -1232,7 +1232,7 @@ boolean KnxCommand()
|
|||
else if ((CMND_KNX_CB == command_code) && (index > 0) && (index <= MAX_KNX_CB)) {
|
||||
if (XdrvMailbox.data_len) {
|
||||
if (strstr(XdrvMailbox.data, ",")) { // Process parameter entry
|
||||
char sub_string[XdrvMailbox.data_len +1];
|
||||
char sub_string[XdrvMailbox.data_len];
|
||||
|
||||
int cb_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
|
||||
int cb_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
|
||||
|
|
Loading…
Reference in New Issue