author | zecke <zecke> | 2003-02-22 16:33:34 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-22 16:33:34 (UTC) |
commit | 2424bcd292444b3a03c9b92dbc7f5b392c355755 (patch) (side-by-side diff) | |
tree | 7f909f39bce8ba8501d07dc6ff238ae7918fc8de | |
parent | 66b00525256255290dfcd9d48ebe1539f15b8dce (diff) | |
download | opie-2424bcd292444b3a03c9b92dbc7f5b392c355755.zip opie-2424bcd292444b3a03c9b92dbc7f5b392c355755.tar.gz opie-2424bcd292444b3a03c9b92dbc7f5b392c355755.tar.bz2 |
fixx off by one in reading
-rw-r--r-- | libopie/pim/odatebookaccessbackend_xml.cpp | 29 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 30 | ||||
-rw-r--r-- | libopie/pim/test/oevent_test.cpp | 21 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 29 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 30 |
5 files changed, 114 insertions, 25 deletions
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index bc51996..24b69fe 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp @@ -24,4 +24,31 @@ namespace { + // FROM TT again +char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) +{ + char needleChar; + char haystackChar; + if (!needle || !haystack || !hLen || !nLen) + return 0; + + const char* hsearch = haystack; + + if ((needleChar = *needle++) != 0) { + nLen--; //(to make up for needle++) + do { + do { + if ((haystackChar = *hsearch++) == 0) + return (0); + if (hsearch >= haystack + hLen) + return (0); + } while (haystackChar != needleChar); + } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); + hsearch--; + } + return ((char *)hsearch); +} +} + +namespace { time_t start, end, created, rp_end; ORecur* rec; @@ -343,5 +370,5 @@ bool ODateBookAccessBackend_XML::loadFile() { int strLen = ::strlen(collectionString); int *find; - while ( dt + 1 != 0 && (( point = ::strstr( dt+i, collectionString ) ) != 0 ) ) { + while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { i = point -dt; i+= strLen; diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 22b2469..cda300b 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp @@ -18,4 +18,32 @@ #include "otodoaccessxml.h" +namespace { + // FROM TT again +char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) +{ + char needleChar; + char haystackChar; + if (!needle || !haystack || !hLen || !nLen) + return 0; + + const char* hsearch = haystack; + + if ((needleChar = *needle++) != 0) { + nLen--; //(to make up for needle++) + do { + do { + if ((haystackChar = *hsearch++) == 0) + return (0); + if (hsearch >= haystack + hLen) + return (0); + } while (haystackChar != needleChar); + } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); + hsearch--; + } + return ((char *)hsearch); +} +} + + OTodoAccessXML::OTodoAccessXML( const QString& appName, const QString& fileName ) @@ -86,5 +114,5 @@ bool OTodoAccessXML::load() { const char* collectionString = "<Task "; int strLen = strlen(collectionString); - while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { + while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { i = point -dt; i+= strLen; diff --git a/libopie/pim/test/oevent_test.cpp b/libopie/pim/test/oevent_test.cpp index 247b83b..d83ee0b 100644 --- a/libopie/pim/test/oevent_test.cpp +++ b/libopie/pim/test/oevent_test.cpp @@ -5,22 +5,4 @@ int main(int argc, char* argv ) { - OEvent ev; -// ev.setUid( 20 ); - - ev.setDescription( "Foo Descsfewrf" ); - - OEvent ev2 = ev; - ev2.setDescription("Foo3"); - qWarning("%s", ev2.description().latin1() ); - qWarning("%s", ev.description().latin1() ); - - QDateTime time = QDateTime::currentDateTime(); - ev2.setStartDateTime( time ); - ev2.setTimeZone( "Europe/London" ); - - qWarning("%s", ev2.startDateTime().toString().latin1() ); - qWarning("%s", ev2.startDateTimeInZone().toString().latin1() ); - qWarning("%d %d", ev.isAllDay(), ev2.isAllDay() ); - ODateBookAccess acc; if(!acc.load() ) qWarning("could not load"); @@ -47,7 +29,4 @@ int main(int argc, char* argv ) { qWarning("Date: %s", ef.date().toString().latin1() ); } - ev.setUid( 1 ); - acc.add( ev ); - acc.save(); return 0; diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index bc51996..24b69fe 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp @@ -24,4 +24,31 @@ namespace { + // FROM TT again +char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) +{ + char needleChar; + char haystackChar; + if (!needle || !haystack || !hLen || !nLen) + return 0; + + const char* hsearch = haystack; + + if ((needleChar = *needle++) != 0) { + nLen--; //(to make up for needle++) + do { + do { + if ((haystackChar = *hsearch++) == 0) + return (0); + if (hsearch >= haystack + hLen) + return (0); + } while (haystackChar != needleChar); + } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); + hsearch--; + } + return ((char *)hsearch); +} +} + +namespace { time_t start, end, created, rp_end; ORecur* rec; @@ -343,5 +370,5 @@ bool ODateBookAccessBackend_XML::loadFile() { int strLen = ::strlen(collectionString); int *find; - while ( dt + 1 != 0 && (( point = ::strstr( dt+i, collectionString ) ) != 0 ) ) { + while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { i = point -dt; i+= strLen; diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 22b2469..cda300b 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -18,4 +18,32 @@ #include "otodoaccessxml.h" +namespace { + // FROM TT again +char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) +{ + char needleChar; + char haystackChar; + if (!needle || !haystack || !hLen || !nLen) + return 0; + + const char* hsearch = haystack; + + if ((needleChar = *needle++) != 0) { + nLen--; //(to make up for needle++) + do { + do { + if ((haystackChar = *hsearch++) == 0) + return (0); + if (hsearch >= haystack + hLen) + return (0); + } while (haystackChar != needleChar); + } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); + hsearch--; + } + return ((char *)hsearch); +} +} + + OTodoAccessXML::OTodoAccessXML( const QString& appName, const QString& fileName ) @@ -86,5 +114,5 @@ bool OTodoAccessXML::load() { const char* collectionString = "<Task "; int strLen = strlen(collectionString); - while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { + while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { i = point -dt; i+= strLen; |