There is still a lot of code that uses legacy String class, and an
increasing amount of code that has to append modern SBufs to Strings.
SBuf handles NUL bytes better than String. With respect to handling NUL
bytes, the new append() method is as (un)safe as the existing explicit
size-based one (that callers tend to use prior to these changes anyway).
#include "base/TextException.h"
#include "debug/Stream.h"
#include "base/TextException.h"
#include "debug/Stream.h"
+#include "sbuf/forward.h"
void append(char const *buf);
void append(char const);
void append(String const &);
void append(char const *buf);
void append(char const);
void append(String const &);
+ void append(const SBuf &); ///< adds the entire given buffer
void absorb(String &old);
const char * pos(char const *aString) const;
const char * pos(char const ch) const;
void absorb(String &old);
const char * pos(char const *aString) const;
const char * pos(char const ch) const;
#include "squid.h"
#include "mem/forward.h"
#include "squid.h"
#include "mem/forward.h"
#include "SquidString.h"
#include <climits>
#include "SquidString.h"
#include <climits>
append(old.rawBuf(), old.len_);
}
append(old.rawBuf(), old.len_);
}
+void
+String::append(const SBuf &buf)
+{
+ append(buf.rawContent(), buf.length());
+}
+
void
String::absorb(String &old)
{
void
String::absorb(String &old)
{
SBuf authority = request->url.authority(request->url.getScheme() != AnyP::PROTO_FTP);
SBuf authority = request->url.authority(request->url.getScheme() != AnyP::PROTO_FTP);
- title_url.append(authority.rawContent(), authority.length());
- title_url.append(request->url.path().rawContent(), request->url.path().length());
+ title_url.append(authority);
+ title_url.append(request->url.path());
- base_href.append(authority.rawContent(), authority.length());
- base_href.append(request->url.path().rawContent(), request->url.path().length());
+ base_href.append(authority);
+ base_href.append(request->url.path());
{
assert(id >= 0);
String addr = channelPathPfx;
{
assert(id >= 0);
String addr = channelPathPfx;
- addr.append(service_name.c_str());
+ addr.append(service_name);
addr.append(processLabel);
addr.append('-');
addr.append(xitoa(id));
addr.append(processLabel);
addr.append('-');
addr.append(xitoa(id));
static String coordinatorAddr;
if (!coordinatorAddr.size()) {
coordinatorAddr= channelPathPfx;
static String coordinatorAddr;
if (!coordinatorAddr.size()) {
coordinatorAddr= channelPathPfx;
- coordinatorAddr.append(service_name.c_str());
+ coordinatorAddr.append(service_name);
coordinatorAddr.append(coordinatorAddrLabel);
coordinatorAddr.append(".ipc");
}
coordinatorAddr.append(coordinatorAddrLabel);
coordinatorAddr.append(".ipc");
}
name.append('/');
} else {
name.append('/');
name.append('/');
} else {
name.append('/');
- name.append(service_name.c_str());
+ name.append(service_name);