* fix the not yet before used StrBufRemove_token()
authorWilfried Göesgens <willi@citadel.org>
Fri, 4 Sep 2009 17:56:00 +0000 (17:56 +0000)
committerWilfried Göesgens <willi@citadel.org>
Fri, 4 Sep 2009 17:56:00 +0000 (17:56 +0000)
* have a clear EndOfBuffer indicator in StrBufExtract_NextToken so we can do while(haveanothertoken)
* add StrBufHaveNextToken() to have a way to find out the end in case of using the integer versions

libcitadel/debian/changelog
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 46e9605d2897130f3af138bbaa949eaf4d317d10..0d1d2b7aeefff5cf167c74d73b6637b438e13507 100644 (file)
@@ -1,8 +1,26 @@
-libcitadel (7.60-73) unstable; urgency=low
+libcitadel (7.63-83) unstable; urgency=low
 
-  * soon to come release
+  * new release
 
- -- Wilfried Goesgens <w.goesgens@outgesourced.org>  Tue, 17 Mar 2009 00:00:00 +0002
+ -- Wilfried Goesgens <w.goesgens@outgesourced.org>  Tue, 1 Sep 2009 8:00:00 +0002
+
+libcitadel (7.61-82) unstable; urgency=low
+
+  * tiny bugfix
+
+ -- Wilfried Goesgens <w.goesgens@outgesourced.org>  Mon, 17 Aug 2009 23:00:00 +0002
+
+libcitadel (7.61-81) unstable; urgency=low
+
+  * new release
+
+ -- Wilfried Goesgens <w.goesgens@outgesourced.org>  Tue, 6 Aug 2009 10:00:00 +0002
+
+libcitadel (7.60-80) unstable; urgency=low
+
+  * new release
+
+ -- Wilfried Goesgens <w.goesgens@outgesourced.org>  Tue, 28 Jul 2009 00:00:00 +0002
 
 libcitadel (7.50-73) unstable; urgency=low
 
index ab17da016b1561670a4bbc02a9f0221050269ba4..c77f57b6e2dc4b852dfa423ce435774665427519 100644 (file)
@@ -274,6 +274,7 @@ int StrBufExtract_int(const StrBuf* Source, int parmnum, char separator);
 int StrBufNum_tokens(const StrBuf *source, char tok);
 int StrBufRemove_token(StrBuf *Source, int parmnum, char separator);
 
+int StrBufHaveNextToken(const StrBuf *Source, const char **pStart);
 int StrBufExtract_NextToken(StrBuf *dest, const StrBuf *Source, const char **pStart, char separator);
 int StrBufSkip_NTokenS(const StrBuf *Source, const char **pStart, char separator, int nTokens);
 unsigned long StrBufExtractNext_unsigned_long(const StrBuf* Source, const char **pStart, char separator);
index 0a88acbad55f50631ab809ebc31e0a4872489eec..f9ef42e23d5d25d0c040073d05ff28847f11137d 100644 (file)
@@ -1137,8 +1137,8 @@ int StrBufRemove_token(StrBuf *Source, int parmnum, char separator)
 
        /* Hack and slash */
        if (*s) {
-               memmove(d, s, Source->BufUsed - (s - Source->buf) + 1);
-               Source->BufUsed -= (ReducedBy + 1);
+               memmove(d, s, Source->BufUsed - (s - Source->buf));
+               Source->BufUsed += ReducedBy;
        }
        else if (d == Source->buf) {
                *d = 0;
@@ -1146,7 +1146,7 @@ int StrBufRemove_token(StrBuf *Source, int parmnum, char separator)
        }
        else {
                *--d = 0;
-               Source->BufUsed -= (ReducedBy + 1);
+               Source->BufUsed += ReducedBy;
        }
        /*
        while (*s) {
@@ -1301,6 +1301,26 @@ unsigned long StrBufExtract_unsigned_long(const StrBuf* Source, int parmnum, cha
 }
 
 
+
+/**
+ * \briefa string tokenizer; Bounds checker
+ *  function to make shure whether StrBufExtract_NextToken and friends have reached the end of the string.
+ * \param Source our tokenbuffer
+ * \param pStart the token iterator pointer to inspect
+ * \returns whether the revolving pointer is inside of the search range
+ */
+int StrBufHaveNextToken(const StrBuf *Source, const char **pStart)
+{
+
+       if (*pStart == NULL)
+               return 1;
+       else if (*pStart >= Source->buf + Source->BufUsed)
+               return 0;
+       else if (*pStart <= Source->buf)
+               return 0;
+       return 1;
+}
+
 /**
  * \brief a string tokenizer
  * \param dest Destination StringBuffer
@@ -1328,6 +1348,8 @@ int StrBufExtract_NextToken(StrBuf *dest, const StrBuf *Source, const char **pSt
        }
        if (*pStart == NULL)
                *pStart = Source->buf;
+       else if (*pStart >= Source->buf + Source->BufUsed)
+               return -1;
 
        EndBuffer = Source->buf + Source->BufUsed;