From eb5753f3ffd2aa530cba21da6fe91a1061b8aafd Mon Sep 17 00:00:00 2001 From: dseliskar Date: Fri, 1 Jan 2016 22:11:49 +0100 Subject: [PATCH 1/2] Problem with TemplateFileStream --- Sming/SmingCore/DataSourceStream.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sming/SmingCore/DataSourceStream.cpp b/Sming/SmingCore/DataSourceStream.cpp index a1f5a76822..812507376b 100644 --- a/Sming/SmingCore/DataSourceStream.cpp +++ b/Sming/SmingCore/DataSourceStream.cpp @@ -223,10 +223,12 @@ uint16_t TemplateFileStream::readMemoryBlock(char* data, int bufSize) memcpy(varname, cur + 1, p - cur - 1); // name without { and } varName = varname; state = eTES_Found; - varWaitSize = cur - tpl; - debugf("found var: %s, at %d (%d) - %d, send size %d", varName.c_str(), cur - tpl + 1, cur - tpl + getPos(), p - tpl, cur - tpl); + int sz = cur - tpl; + varWaitSize = sz; + debugf("found var: %s, at %d (%d) - %d, send size %d", varName.c_str(), sz + 1, sz + getPos(), p - tpl, sz); skipBlockSize = block; - return cur - tpl; // return only plain text from template without our variable + if (sz == 0) state = eTES_StartVar; + return sz; // return only plain text from template without our variable } } cur = (char*)memchr(p, '{', len - (p - tpl)); // continue searching.. From 805e23c7ccb3592c679be965b89c54b78e1a531d Mon Sep 17 00:00:00 2001 From: dseliskar Date: Fri, 1 Jan 2016 22:13:01 +0100 Subject: [PATCH 2/2] typo fix for eSST_TemplateFile --- Sming/SmingCore/DataSourceStream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sming/SmingCore/DataSourceStream.h b/Sming/SmingCore/DataSourceStream.h index 274c169553..296bf0569a 100644 --- a/Sming/SmingCore/DataSourceStream.h +++ b/Sming/SmingCore/DataSourceStream.h @@ -22,7 +22,7 @@ enum StreamType { eSST_Memory, eSST_File, - eSST_TepmplateFile, + eSST_TemplateFile, eSST_JsonObject, eSST_User, eSST_Unknown @@ -104,7 +104,7 @@ class TemplateFileStream : public FileStream TemplateFileStream(String templateFileName); virtual ~TemplateFileStream(); - virtual StreamType getStreamType() { return eSST_TepmplateFile; } + virtual StreamType getStreamType() { return eSST_TemplateFile; } virtual uint16_t readMemoryBlock(char* data, int bufSize); virtual bool seek(int len);