--------------------- PatchSet 6550 Date: 2008/01/19 11:35:23 Author: amosjeffries Branch: ayjwork Tag: (none) Log: Add offset-base rpos operator to search the string buffer. Returns either the positive offset of the character found or a negative value for failure/negative-result. Members: src/SquidString.h:1.8.8.12->1.8.8.13 src/String.cci:1.6.6.5->1.6.6.6 Index: squid3/src/SquidString.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SquidString.h,v retrieving revision 1.8.8.12 retrieving revision 1.8.8.13 diff -u -r1.8.8.12 -r1.8.8.13 --- squid3/src/SquidString.h 19 Jan 2008 11:15:43 -0000 1.8.8.12 +++ squid3/src/SquidString.h 19 Jan 2008 11:35:23 -0000 1.8.8.13 @@ -1,5 +1,5 @@ /* - * $Id: SquidString.h,v 1.8.8.12 2008/01/19 11:15:43 amosjeffries Exp $ + * $Id: SquidString.h,v 1.8.8.13 2008/01/19 11:35:23 amosjeffries Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -110,7 +110,20 @@ void absorb(String &old); _SQUID_INLINE_ const char * pos(char const *) const; _SQUID_INLINE_ const char * pos(char const ch) const; + + /** + * Find the last position of a character in a String. + * + \param ch Character to lookup + \retval N Positive offset of the character in the string. + \retval -N Negative value if Character not found. + */ + _SQUID_INLINE_ const int rpos(char const ch) const; + + /** \deprecated Should be using the offset-lookup instead: unsigned int rpos(char) + */ _SQUID_INLINE_ const char * rpos(char const ch) const; + _SQUID_INLINE_ int cmp (char const *) const; _SQUID_INLINE_ int cmp (char const *, size_t count) const; _SQUID_INLINE_ int cmp (String const &) const; Index: squid3/src/String.cci =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/String.cci,v retrieving revision 1.6.6.5 retrieving revision 1.6.6.6 diff -u -r1.6.6.5 -r1.6.6.6 --- squid3/src/String.cci 19 Jan 2008 11:15:43 -0000 1.6.6.5 +++ squid3/src/String.cci 19 Jan 2008 11:35:23 -0000 1.6.6.6 @@ -1,5 +1,5 @@ /* - * $Id: String.cci,v 1.6.6.5 2008/01/19 11:15:43 amosjeffries Exp $ + * $Id: String.cci,v 1.6.6.6 2008/01/19 11:35:23 amosjeffries Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -71,6 +71,15 @@ return strchr(buf(), ch); } +const int +String::rpos(char const ch) const +{ + unsigned int r = _len; + if(_len == 0) return -1; + while(r > 0 && _buf[r] != ch) --r; + return r; +} + const char * String::rpos(char const ch) const { @@ -151,7 +160,7 @@ buf_[loc-buf_] = ch; } -#if 0 // DEAD +#if DEAD_CODE void String::cut(size_t newLength) {