From: josepjones Date: Thu, 3 Oct 2019 13:57:32 +0000 (+0000) Subject: Cleanup: rename String::limitInit() to assign() (#488) X-Git-Tag: SQUID_5_0_1~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2fe0439c3925da553b305510b14593f212dd9eda;p=thirdparty%2Fsquid.git Cleanup: rename String::limitInit() to assign() (#488) --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 774e0cf8fb..d161cbfa29 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1493,7 +1493,7 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end, const htt } /* set field value */ - value.limitInit(value_start, field_end - value_start); + value.assign(value_start, field_end - value_start); if (id != Http::HdrType::BAD_HDR) ++ headerStatsTable[id].seenCount; diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index b4f1ab111b..7f82551928 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -229,7 +229,7 @@ httpHeaderParseQuotedString(const char *start, const int len, String *val) } /* Make sure it's defined even if empty "" */ if (!val->termedBuf()) - val->limitInit("", 0); + val->assign("", 0); return 1; } diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 38ea4638a2..0cc0c190f8 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -335,7 +335,7 @@ HttpReply::hdrCacheInit() const char *str = header.getStr(Http::HdrType::CONTENT_TYPE); if (str) - content_type.limitInit(str, strcspn(str, ";\t ")); + content_type.assign(str, strcspn(str, ";\t ")); else content_type = String(); diff --git a/src/SquidString.h b/src/SquidString.h index d7af11fbfb..cda4d986db 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -90,7 +90,7 @@ public: */ char const * termedBuf() const { return buf_; } - void limitInit(const char *str, int len); // TODO: rename to assign() + void assign(const char *str, int len); void clean(); void reset(char const *str); void append(char const *buf, int len); diff --git a/src/String.cc b/src/String.cc index 62a839e7ea..9fccddc45a 100644 --- a/src/String.cc +++ b/src/String.cc @@ -91,7 +91,7 @@ String::operator !=(String const &that) const // public interface, makes sure that we clean the old buffer first void -String::limitInit(const char *str, int len) +String::assign(const char *str, int len) { clean(); // TODO: optimize to avoid cleaning the buffer we can use allocAndFill(str, len); @@ -228,7 +228,7 @@ String::substr(String::size_type from, String::size_type to) const Must(to > from); String rv; - rv.limitInit(rawBuf()+from,to-from); + rv.assign(rawBuf()+from, to-from); return rv; } diff --git a/src/adaptation/ServiceConfig.cc b/src/adaptation/ServiceConfig.cc index 59fcd87faa..e7b9078b1a 100644 --- a/src/adaptation/ServiceConfig.cc +++ b/src/adaptation/ServiceConfig.cc @@ -244,7 +244,7 @@ Adaptation::ServiceConfig::grokUri(const char *value) len = e - s; } - host.limitInit(s, len); + host.assign(s, len); #if USE_OPENSSL if (secure.sslDomain.isEmpty()) secure.sslDomain.assign(host.rawBuf(), host.size()); @@ -285,7 +285,7 @@ Adaptation::ServiceConfig::grokUri(const char *value) "long resource name (>1024), probably wrong"); } - resource.limitInit(s, len + 1); + resource.assign(s, len + 1); return true; } diff --git a/src/adaptation/ServiceGroups.cc b/src/adaptation/ServiceGroups.cc index c419ac887b..8c738acb03 100644 --- a/src/adaptation/ServiceGroups.cc +++ b/src/adaptation/ServiceGroups.cc @@ -252,7 +252,7 @@ Adaptation::DynamicServiceChain::Split(const ServiceFilter &filter, const char *pos = NULL; while (strListGetItem(&ids, ',', &item, &ilen, &pos)) { String id; - id.limitInit(item, ilen); + id.assign(item, ilen); ServicePointer service = FindService(id); if (doingCurrent) { if (!service || // cannot tell or matches current location diff --git a/src/auth/digest/Config.cc b/src/auth/digest/Config.cc index 67498d0bf9..8621d8eb9f 100644 --- a/src/auth/digest/Config.cc +++ b/src/auth/digest/Config.cc @@ -777,16 +777,16 @@ Auth::Digest::Config::decode(char const *proxy_auth, const char *aRequestRealm) // domain is Special. Not a quoted-string, must not be de-quoted. But is wrapped in '"' // BUG 3077: uri= can also be sent to us in a mangled (invalid!) form like domain if (vlen > 1 && *p == '"' && *(p + vlen -1) == '"') { - value.limitInit(p+1, vlen-2); + value.assign(p+1, vlen-2); } } else if (keyName == SBuf("qop",3)) { // qop is more special. // On request this must not be quoted-string de-quoted. But is several values wrapped in '"' // On response this is a single un-quoted token. if (vlen > 1 && *p == '"' && *(p + vlen -1) == '"') { - value.limitInit(p+1, vlen-2); + value.assign(p+1, vlen-2); } else { - value.limitInit(p, vlen); + value.assign(p, vlen); } } else if (*p == '"') { if (!httpHeaderParseQuotedString(p, vlen, &value)) { @@ -794,7 +794,7 @@ Auth::Digest::Config::decode(char const *proxy_auth, const char *aRequestRealm) continue; } } else { - value.limitInit(p, vlen); + value.assign(p, vlen); } } else { debugs(29, 9, "Failed to parse attribute '" << item << "' in '" << temp << "'"); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 4ef581279b..fba5e6847b 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1289,7 +1289,7 @@ parseBytesOptionValue(size_t * bptr, const char *units, char const * value) } String number; - number.limitInit(number_begin, number_end - number_begin); + number.assign(number_begin, number_end - number_begin); int d = xatoi(number.termedBuf()); int m; diff --git a/src/esi/Segment.cc b/src/esi/Segment.cc index 1dab735fec..d20304c11f 100644 --- a/src/esi/Segment.cc +++ b/src/esi/Segment.cc @@ -191,7 +191,7 @@ void ESISegment::dumpOne() const { String temp; - temp.limitInit(buf, len); + temp.assign(buf, len); debugs(86, 9, "ESISegment::dumpOne: \"" << temp << "\""); } diff --git a/src/esi/VarState.cc b/src/esi/VarState.cc index b5daf6cde3..d59a77c760 100644 --- a/src/esi/VarState.cc +++ b/src/esi/VarState.cc @@ -282,7 +282,7 @@ void ESIVarState::addVariable(char const *name, size_t len, Variable *aVariable) { String temp; - temp.limitInit (name, len); + temp.assign(name, len); removeVariable (temp); variables.add(name, len, aVariable); variablesForCleanup.push_back(aVariable); diff --git a/src/ipc/TypedMsgHdr.cc b/src/ipc/TypedMsgHdr.cc index 99c94b42bd..b9a5844cd2 100644 --- a/src/ipc/TypedMsgHdr.cc +++ b/src/ipc/TypedMsgHdr.cc @@ -143,7 +143,7 @@ Ipc::TypedMsgHdr::getString(String &s) const // TODO: use SBuf.reserve() instead of a temporary buffer char buf[maxSize]; getRaw(&buf, length); - s.limitInit(buf, length); + s.assign(buf, length); } void diff --git a/src/sbuf/StringConvert.h b/src/sbuf/StringConvert.h index 7223d8dabb..df55575f3e 100644 --- a/src/sbuf/StringConvert.h +++ b/src/sbuf/StringConvert.h @@ -26,7 +26,7 @@ inline String SBufToString(const SBuf &s) { String rv; - rv.limitInit(s.rawContent(), s.length()); + rv.assign(s.rawContent(), s.length()); return rv; }