mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Merge pull request #3307 from ascillato/patch-2
Move subStr() Function to Support.ino
This commit is contained in:
commit
bf0d0dcd94
@ -130,6 +130,24 @@ size_t strchrspn(const char *str1, int character)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to return a substring defined by a delimiter at an index
|
||||||
|
char* subStr(char* dest, char* str, const char *delim, int index)
|
||||||
|
{
|
||||||
|
char *act;
|
||||||
|
char *sub;
|
||||||
|
char *ptr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Since strtok consumes the first arg, make a copy
|
||||||
|
strncpy(dest, str, strlen(str));
|
||||||
|
for (i = 1, act = dest; i <= index; i++, act = NULL) {
|
||||||
|
sub = strtok_r(act, delim, &ptr);
|
||||||
|
if (sub == NULL) break;
|
||||||
|
}
|
||||||
|
sub = Trim(sub);
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
double CharToDouble(char *str)
|
double CharToDouble(char *str)
|
||||||
{
|
{
|
||||||
// simple ascii to double, because atof or strtod are too large
|
// simple ascii to double, because atof or strtod are too large
|
||||||
|
@ -603,24 +603,6 @@ double map_double(double x, double in_min, double in_max, double out_min, double
|
|||||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to return a substring defined by a delimiter at an index
|
|
||||||
char* subStr(char* dest, char* str, const char *delim, int index)
|
|
||||||
{
|
|
||||||
char *act;
|
|
||||||
char *sub;
|
|
||||||
char *ptr;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Since strtok consumes the first arg, make a copy
|
|
||||||
strncpy(dest, str, strlen(str));
|
|
||||||
for (i = 1, act = dest; i <= index; i++, act = NULL) {
|
|
||||||
sub = strtok_r(act, delim, &ptr);
|
|
||||||
if (sub == NULL) break;
|
|
||||||
}
|
|
||||||
sub = Trim(sub);
|
|
||||||
return sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Interface
|
* Interface
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user