From: Greg Stein Date: Thu, 19 Oct 2000 10:43:03 +0000 (+0000) Subject: somebody was a Very Bad Boy when they inserted casts into this function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7053c7a55f0cdcdef8f6fb393295a88adfb53aaa;p=apache somebody was a Very Bad Boy when they inserted casts into this function. casting away the const was absolutely wrong... the warnings were saying the return value type needed to be fixed. did that and torched the casts. who still thinks casts are a good idea? :-) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86668 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/httpd.h b/include/httpd.h index a1c6ffc37e..7e0f64f0f9 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -1396,9 +1396,10 @@ AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2); * @param bigstring The input string * @param prefix The prefix to strip away * @return A pointer relative to bigstring after prefix - * deffunc char *ap_stripprefix(const char *bigstring, const char *prefix); + * deffunc const char *ap_stripprefix(const char *bigstring, const char *prefix); */ -AP_DECLARE(char *) ap_stripprefix(const char *bigstring, const char *prefix); +AP_DECLARE(const char *) ap_stripprefix(const char *bigstring, + const char *prefix); /** * Decode a base64 encoded string into memory allocated out of a pool diff --git a/server/util.c b/server/util.c index 6b23e71525..a3aab61b2d 100644 --- a/server/util.c +++ b/server/util.c @@ -342,21 +342,24 @@ AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2) * can use standard pointer comparisons in the calling function * (eg: test if ap_stripprefix(a,b) == a) */ -AP_DECLARE(char *) ap_stripprefix(const char *bigstring, const char *prefix) +AP_DECLARE(const char *) ap_stripprefix(const char *bigstring, + const char *prefix) { - char *p1; - if (*prefix == '\0') { - return( (char *)bigstring); - } - p1 = (char *)bigstring; - while(*p1 && *prefix) { + const char *p1; + + if (*prefix == '\0') + return bigstring; + + p1 = bigstring; + while (*p1 && *prefix) { if (*p1++ != *prefix++) - return( (char *)bigstring); + return bigstring; } if (*prefix == '\0') - return(p1); - else /* hit the end of bigstring! */ - return( (char *)bigstring); + return p1; + + /* hit the end of bigstring! */ + return bigstring; } /*