]> granicus.if.org Git - apache/commitdiff
Removed "tolower(++s)" idiom from ap_strcasestr(), to avoid side-effects
authorBrian Pane <brianp@apache.org>
Sun, 23 Jun 2002 09:01:22 +0000 (09:01 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 23 Jun 2002 09:01:22 +0000 (09:01 +0000)
on any platform with a macro-based tolower() that references its argument
multiple times.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95867 13f79535-47bb-0310-9956-ffa450edef68

include/httpd.h
server/util.c

index c6f2d029e610ca0e60adb120a62ed4fe057b27ec..f563951cca33a67a8f81c85aa8df598e9bc8c663 100644 (file)
@@ -1453,6 +1453,7 @@ AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *exp);
  * @param s1 The string to search
  * @param s2 The substring to search for
  * @return A pointer to the beginning of the substring
+ * @remark See apr_strmatch() for a faster alternative
  */
 AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2);
 
index 65c695a5cb44874ab17a62cc957bdfdd53e35a6c..c86e37cdbf0b4512886edd187cc11b9f30f9efa1 100644 (file)
@@ -327,7 +327,7 @@ AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2)
        /* found first character of s2, see if the rest matches */
         p1 = (char *)s1;
         p2 = (char *)s2;
-        while (apr_tolower(*++p1) == apr_tolower(*++p2)) {
+        for (++p1, ++p2; apr_tolower(*p1) == apr_tolower(*p2); ++p1, ++p2) {
             if (*p1 == '\0') {
                 /* both strings ended together */
                 return((char *)s1);