]> code.citadel.org Git - citadel.git/commitdiff
* add lowercase converter function
authorWilfried Göesgens <willi@citadel.org>
Thu, 13 Nov 2008 19:22:50 +0000 (19:22 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 13 Nov 2008 19:22:50 +0000 (19:22 +0000)
* fix off by one in increase buffer function

libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c

index 7223456a8899b80462ed0ea267ece22e4715dd84..51c59774eef2aa8e35028d87d9642063e504179a 100644 (file)
@@ -257,6 +257,7 @@ void StrBufCutLeft(StrBuf *Buf, int nChars);
 void StrBufCutRight(StrBuf *Buf, int nChars);
 void StrBufTrim(StrBuf *Buf);
 void StrBufUpCase(StrBuf *Buf);
+void StrBufLowerCase(StrBuf *Buf);
 void StrBufEUid_unescapize(StrBuf *target, const StrBuf *source);
 void StrBufEUid_escapize(StrBuf *target, const StrBuf *source);
 
index c52313c22b4ec8bdae6367d985443aa805225e70..49dbd4e06d97df62aea9b8ad45ad7cf6f3d96eea 100644 (file)
@@ -78,7 +78,7 @@ static int IncreaseBuf(StrBuf *Buf, int KeepOriginal, int DestSize)
                return -1;
                
        if (DestSize > 0)
-               while (NewSize < DestSize)
+               while (NewSize <= DestSize)
                        NewSize *= 2;
 
        NewBuf= (char*) malloc(NewSize);
@@ -1178,6 +1178,19 @@ void StrBufUpCase(StrBuf *Buf)
 }
 
 
+void StrBufLowerCase(StrBuf *Buf) 
+{
+       char *pch, *pche;
+
+       pch = Buf->buf;
+       pche = pch + Buf->BufUsed;
+       while (pch < pche) {
+               *pch = tolower(*pch);
+               pch ++;
+       }
+}
+
+
 /**
  * \brief unhide special chars hidden to the HTML escaper
  * \param target buffer to put the unescaped string in