diff options
Diffstat (limited to 'src/StringUtil.cc')
-rw-r--r-- | src/StringUtil.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/StringUtil.cc b/src/StringUtil.cc index 54ef357..d6e71b6 100644 --- a/src/StringUtil.cc +++ b/src/StringUtil.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: StringUtil.cc,v 1.8 2002/03/20 11:32:03 fluxgen Exp $ | 22 | // $Id: StringUtil.cc,v 1.9 2002/04/08 22:29:45 fluxgen Exp $ |
23 | 23 | ||
24 | #include "StringUtil.hh" | 24 | #include "StringUtil.hh" |
25 | 25 | ||
@@ -35,7 +35,9 @@ namespace StringUtil | |||
35 | { | 35 | { |
36 | 36 | ||
37 | //------- strdup ------------------------ | 37 | //------- strdup ------------------------ |
38 | //TODO: comment this | 38 | // Takes a pointer to string *s as an argument, |
39 | // creates a new string n, copies s to n and | ||
40 | // returns a pointer to n. | ||
39 | //---------------------------------------- | 41 | //---------------------------------------- |
40 | char *strdup(const char *s) { | 42 | char *strdup(const char *s) { |
41 | int l = strlen(s) + 1; | 43 | int l = strlen(s) + 1; |
@@ -48,14 +50,13 @@ char *strdup(const char *s) { | |||
48 | // Tries to find a string in another and | 50 | // Tries to find a string in another and |
49 | // ignoring the case of the characters | 51 | // ignoring the case of the characters |
50 | // Returns 0 on success else pointer to str. | 52 | // Returns 0 on success else pointer to str. |
51 | // TODO: comment this | ||
52 | //--------------------------------- | 53 | //--------------------------------- |
53 | const char *strcasestr(const char *str, const char *ptn) { | 54 | const char *strcasestr(const char *str, const char *ptn) { |
54 | const char *s2, *p2; | 55 | const char *s2, *p2; |
55 | for( ; *str; str++) { | 56 | for( ; *str; str++) { |
56 | for(s2=str, p2=ptn; ; s2++,p2++) { | 57 | for(s2=str, p2=ptn; ; s2++,p2++) { |
57 | if (!*p2) return str; | 58 | if (!*p2) return str; // check if we reached the end of ptn, if so, return str |
58 | if (toupper(*s2) != toupper(*p2)) break; | 59 | if (toupper(*s2) != toupper(*p2)) break; // check if the chars match(ignoring case) |
59 | } | 60 | } |
60 | } | 61 | } |
61 | return 0; | 62 | return 0; |