added comments

This commit is contained in:
fluxgen 2002-04-08 22:29:45 +00:00
parent c3fef77fa4
commit 1b64d4cfac

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: StringUtil.cc,v 1.8 2002/03/20 11:32:03 fluxgen Exp $ // $Id: StringUtil.cc,v 1.9 2002/04/08 22:29:45 fluxgen Exp $
#include "StringUtil.hh" #include "StringUtil.hh"
@ -35,7 +35,9 @@ namespace StringUtil
{ {
//------- strdup ------------------------ //------- strdup ------------------------
//TODO: comment this // Takes a pointer to string *s as an argument,
// creates a new string n, copies s to n and
// returns a pointer to n.
//---------------------------------------- //----------------------------------------
char *strdup(const char *s) { char *strdup(const char *s) {
int l = strlen(s) + 1; int l = strlen(s) + 1;
@ -48,14 +50,13 @@ char *strdup(const char *s) {
// Tries to find a string in another and // Tries to find a string in another and
// ignoring the case of the characters // ignoring the case of the characters
// Returns 0 on success else pointer to str. // Returns 0 on success else pointer to str.
// TODO: comment this
//--------------------------------- //---------------------------------
const char *strcasestr(const char *str, const char *ptn) { const char *strcasestr(const char *str, const char *ptn) {
const char *s2, *p2; const char *s2, *p2;
for( ; *str; str++) { for( ; *str; str++) {
for(s2=str, p2=ptn; ; s2++,p2++) { for(s2=str, p2=ptn; ; s2++,p2++) {
if (!*p2) return str; if (!*p2) return str; // check if we reached the end of ptn, if so, return str
if (toupper(*s2) != toupper(*p2)) break; if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case)
} }
} }
return 0; return 0;