From 4bd50abe2cd18dffd5e2aed5f6aba15ce24b9af7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Fri, 4 Sep 2009 17:56:00 +0000 Subject: [PATCH] * fix the not yet before used StrBufRemove_token() * 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 | 24 +++++++++++++++++++++--- libcitadel/lib/libcitadel.h | 1 + libcitadel/lib/stringbuf.c | 28 +++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/libcitadel/debian/changelog b/libcitadel/debian/changelog index 46e9605d2..0d1d2b7ae 100644 --- a/libcitadel/debian/changelog +++ b/libcitadel/debian/changelog @@ -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 Tue, 17 Mar 2009 00:00:00 +0002 + -- Wilfried Goesgens Tue, 1 Sep 2009 8:00:00 +0002 + +libcitadel (7.61-82) unstable; urgency=low + + * tiny bugfix + + -- Wilfried Goesgens Mon, 17 Aug 2009 23:00:00 +0002 + +libcitadel (7.61-81) unstable; urgency=low + + * new release + + -- Wilfried Goesgens Tue, 6 Aug 2009 10:00:00 +0002 + +libcitadel (7.60-80) unstable; urgency=low + + * new release + + -- Wilfried Goesgens Tue, 28 Jul 2009 00:00:00 +0002 libcitadel (7.50-73) unstable; urgency=low diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index ab17da016..c77f57b6e 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -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); diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 0a88acbad..f9ef42e23 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -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; -- 2.30.2