1
#! /bin/sh /usr/share/dpatch/dpatch-run
4
--- ../old/squid3-3.1.6/src/SquidString.h 2010-08-02 00:01:39.000000000 +1000
5
+++ squid3-3.1.6/src/SquidString.h 2010-09-13 17:00:17.000000000 +1000
7
void allocBuffer(size_type sz);
8
void setBuffer(char *buf, size_type sz);
10
+ _SQUID_INLINE_ bool nilCmp(bool, bool, int &) const;
12
/* never reference these directly! */
13
size_type size_; /* buffer size; 64K limit */
15
--- ../old/squid3-3.1.6/src/String.cci 2010-08-02 00:01:37.000000000 +1000
16
+++ squid3-3.1.6/src/String.cci 2010-09-13 17:05:43.000000000 +1000
22
-String::cmp (char const *aString) const
23
+/// compare NULL and empty strings because str*cmp() may fail on NULL strings
24
+/// and because we need to return consistent results for strncmp(count == 0).
26
+String::nilCmp(const bool thisIsNilOrEmpty, const bool otherIsNilOrEmpty, int &result) const
28
- /* strcmp fails on NULLS */
29
+ if (!thisIsNilOrEmpty && !otherIsNilOrEmpty)
30
+ return false; // result does not matter
32
- if (size() == 0 && (aString == NULL || aString[0] == '\0'))
34
+ if (thisIsNilOrEmpty && otherIsNilOrEmpty)
36
+ else if (thisIsNilOrEmpty)
38
+ else // otherIsNilOrEmpty
47
- if (aString == NULL || aString[0] == '\0')
50
+String::cmp (char const *aString) const
53
+ if (nilCmp(!size(), (!aString || !*aString), result))
56
return strcmp(termedBuf(), aString);
60
String::cmp (char const *aString, String::size_type count) const
62
- /* always the same at length 0 */
67
+ if (nilCmp((!size() || !count), (!aString || !*aString || !count), result))
70
- if (size() == 0 && (aString == NULL || aString[0] == '\0'))
76
- if (aString == NULL || aString[0] == '\0')
79
return strncmp(termedBuf(), aString, count);
83
String::cmp (String const &aString) const
85
- /* strcmp fails on NULLS */
87
- if (size() == 0 && aString.size() == 0)
93
+ if (nilCmp(!size(), !aString.size(), result))
96
- if (aString.size() == 0)
99
return strcmp(termedBuf(), aString.termedBuf());
101
@@ -145,12 +142,22 @@
103
String::caseCmp(char const *aString) const
106
+ if (nilCmp(!size(), (!aString || !*aString), result))
110
return strcasecmp(termedBuf(), aString);
114
String::caseCmp(char const *aString, String::size_type count) const
117
+ if (nilCmp((!size() || !count), (!aString || !*aString || !count), result))
121
return strncasecmp(termedBuf(), aString, count);