From 96fb23737dd142077c1494874542256762ef00f2 Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Mon, 23 Jul 2018 01:29:50 -0300 Subject: [PATCH 1/2] Move subStr Function to Support.ino --- sonoff/xdrv_10_rules.ino | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 2129fdbbe..3296a9560 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -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; } -// 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 \*********************************************************************************************/ From 754955cd4886a9796dcf67fddc03b5301291b106 Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Mon, 23 Jul 2018 01:32:54 -0300 Subject: [PATCH 2/2] Move subStr Function to Support.ino --- sonoff/support.ino | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sonoff/support.ino b/sonoff/support.ino index 4930f8e4b..a5d6e9e4e 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -130,6 +130,24 @@ size_t strchrspn(const char *str1, int character) 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) { // simple ascii to double, because atof or strtod are too large