Change AttachLiteral to CopyString everywhere

This is a big codemod but has no effect; the actual change
was from D894412.
Esse commit está contido em:
Edwin Smith
2013-07-22 16:58:40 -07:00
commit de Sara Golemon
commit b9812e548a
38 arquivos alterados com 96 adições e 98 exclusões
+2 -2
Ver Arquivo
@@ -387,13 +387,13 @@ std::string Option::MangleFilename(const std::string &name, bool id) {
bool Option::IsFileExcluded(const std::string &file,
const std::set<std::string> &patterns) {
String sfile(file.c_str(), file.size(), AttachLiteral);
String sfile(file.c_str(), file.size(), CopyString);
for (set<string>::const_iterator iter = patterns.begin();
iter != patterns.end(); ++iter) {
const std::string &pattern = *iter;
Variant matches;
Variant ret = preg_match(String(pattern.c_str(), pattern.size(),
AttachLiteral), sfile, matches);
CopyString), sfile, matches);
if (ret.toInt64() > 0) {
return true;
}
+2 -2
Ver Arquivo
@@ -326,7 +326,7 @@ static int64_t get_int64_value(StoreValue* sval) {
v = sval->var->toLocal();
} else {
assert(sval->inFile());
String s(sval->sAddr, sval->getSerializedSize(), AttachLiteral);
String s(sval->sAddr, sval->getSerializedSize(), CopyString);
v = apc_unserialize(s);
}
return v.toInt64();
@@ -605,7 +605,7 @@ void ConcurrentTableSharedStore::dump(std::ostream & out, bool keyOnly,
assert(sval->inFile());
// we need unserialize and serialize again because the format was
// APCSerialize
String s(sval->sAddr, sval->getSerializedSize(), AttachLiteral);
String s(sval->sAddr, sval->getSerializedSize(), CopyString);
value = apc_unserialize(s);
}
try {
+1 -1
Ver Arquivo
@@ -502,7 +502,7 @@ void execute_command_line_begin(int argc, char **argv, int xhprof) {
}
String file = empty_string;
if (argc > 0) {
file = NEW(StringData)(argv[0], AttachLiteral);
file = NEW(StringData)(argv[0], CopyString);
}
server.set(s_REQUEST_START_TIME, now);
server.set(s_REQUEST_TIME, now);
+2 -2
Ver Arquivo
@@ -522,9 +522,9 @@ static bool matchHdfPattern(const std::string &value, Hdf hdfPattern) {
string pattern = hdfPattern.getString();
if (!pattern.empty()) {
Variant ret = preg_match(String(pattern.c_str(), pattern.size(),
AttachLiteral),
CopyString),
String(value.c_str(), value.size(),
AttachLiteral));
CopyString));
if (ret.toInt64() <= 0) {
return false;
}
+2 -2
Ver Arquivo
@@ -153,7 +153,7 @@ Variant SharedVariant::toLocal() {
{
if (getSerializedArray()) {
return apc_unserialize(String(m_data.str->data(), m_data.str->size(),
AttachLiteral));
CopyString));
}
return NEW(SharedMap)(this);
}
@@ -169,7 +169,7 @@ Variant SharedVariant::toLocal() {
return m_data.obj->getObject();
}
return apc_unserialize(String(m_data.str->data(), m_data.str->size(),
AttachLiteral));
CopyString));
}
}
}
+2 -2
Ver Arquivo
@@ -138,7 +138,7 @@ StringData* StringData::GetStaticString(const String& str) {
}
StringData *StringData::GetStaticString(const char *str, size_t len) {
StackStringData sd(str, len, AttachLiteral);
StackStringData sd(str, len, CopyString);
return GetStaticString(&sd);
}
@@ -600,7 +600,7 @@ static StringData** precompute_chars() {
StringData** raw = new StringData*[256];
for (int i = 0; i < 256; i++) {
char s[2] = { (char)i, 0 };
StackStringData str(s, 1, AttachLiteral);
StackStringData str(s, 1, CopyString);
raw[i] = StringData::GetStaticString(&str);
}
return raw;
+2 -4
Ver Arquivo
@@ -51,15 +51,13 @@ struct Slice {
typedef Slice<const char> StringSlice;
typedef Slice<char> MutableSlice;
// Aggressively copy small strings and free the passed-in buffer immediately;
// otherwise keep the buffer for long strings, and free it when the string
// is mutated or released.
// Copy the passed-in string and free the buffer immediately.
enum AttachStringMode { AttachString };
// const char* points to client-owned memory, StringData will copy it
// at construct-time using smart_malloc. This is only ok when the StringData
// itself was smart-allocated.
enum CopyStringMode { CopyString, AttachLiteral };
enum CopyStringMode { CopyString };
// reserve space for buffer that will be filled in by client.
enum ReserveStringMode { ReserveString };
+1 -1
Ver Arquivo
@@ -305,7 +305,7 @@ Variant StringUtil::ChunkSplit(CStrRef body, int chunklen /* = 76 */,
String StringUtil::CEncode(CStrRef input, CStrRef charlist) {
String chars = charlist;
if (chars.isNull()) {
chars = String("\\\x00\x01..\x1f\x7f..\xff", 10, AttachLiteral);
chars = String("\\\x00\x01..\x1f\x7f..\xff", 10, CopyString);
}
if (input.empty() || chars.empty()) return input;
int len = input.size();
+2 -2
Ver Arquivo
@@ -70,7 +70,7 @@ void ThriftBuffer::write(CStrRef data) {
void ThriftBuffer::flush() {
*m_p = '\0';
String data(m_buf, m_p - m_buf, AttachLiteral);
String data(m_buf, m_p - m_buf, CopyString);
m_p = m_buf;
flushImpl(data);
}
@@ -211,7 +211,7 @@ void ThriftBuffer::read(std::string &data) {
}
void ThriftBuffer::write(const std::string &data) {
write(String(data.data(), data.size(), AttachLiteral));
write(String(data.data(), data.size(), CopyString));
}
void ThriftBuffer::read(std::vector<std::string> &data) {
+2 -2
Ver Arquivo
@@ -157,7 +157,7 @@ Array TimeZone::GetNames() {
Array ret;
for (int i = 0; i < item_count; ++i) {
ret.append(String(table[i].id, AttachLiteral));
ret.append(String(table[i].id, CopyString));
}
return ret;
}
@@ -183,7 +183,7 @@ Array TimeZone::GetAbbreviations() {
element.set(s_dst, (bool)entry->type);
element.set(s_offset, entry->gmtoffset);
if (entry->full_tz_name) {
element.set(s_timezone_id, String(entry->full_tz_name, AttachLiteral));
element.set(s_timezone_id, String(entry->full_tz_name, CopyString));
} else {
element.set(s_timezone_id, uninit_null());
}
+4 -4
Ver Arquivo
@@ -137,7 +137,7 @@ String::String(double n) {
}
StringData* buildStringData(litstr s) {
return NEW(StringData)(s, AttachLiteral);
return NEW(StringData)(s, CopyString);
}
///////////////////////////////////////////////////////////////////////////////
@@ -272,7 +272,7 @@ char String::charAt(int pos) const {
String &String::operator=(litstr s) {
if (m_px) decRefStr(m_px);
if (s) {
m_px = NEW(StringData)(s, AttachLiteral);
m_px = NEW(StringData)(s, CopyString);
m_px->setRefCount(1);
} else {
m_px = nullptr;
@@ -308,7 +308,7 @@ String &String::operator=(CVarRef var) {
String &String::operator+=(litstr s) {
if (s && *s) {
if (empty()) {
m_px = NEW(StringData)(s, AttachLiteral);
m_px = NEW(StringData)(s, CopyString);
m_px->setRefCount(1);
} else if (m_px->getCount() == 1) {
m_px->append(s, strlen(s));
@@ -610,7 +610,7 @@ StaticString::StaticString(litstr s) {
}
StaticString::StaticString(litstr s, int length) {
StackStringData sd(s, length, AttachLiteral);
StackStringData sd(s, length, CopyString);
m_px = StringData::GetStaticString(&sd);
}
+2 -2
Ver Arquivo
@@ -1841,12 +1841,12 @@ void Variant::unserialize(VariableUnserializer *uns,
throw Exception("Mangled private object property");
}
}
String k(kdata + subLen, ksize - subLen, AttachLiteral);
String k(kdata + subLen, ksize - subLen, CopyString);
if (kdata[1] == '*') {
unserializeProp(uns, obj.get(), k, clsName, key, i + 1);
} else {
unserializeProp(uns, obj.get(), k,
String(kdata + 1, subLen - 2, AttachLiteral),
String(kdata + 1, subLen - 2, CopyString),
key, i + 1);
}
} else {
+2 -2
Ver Arquivo
@@ -972,8 +972,8 @@ bool BreakPointInfo::Match(const char *haystack, int haystack_len,
Variant matches;
Variant r = preg_match(String(needle.c_str(), needle.size(),
AttachLiteral),
String(haystack, haystack_len, AttachLiteral),
CopyString),
String(haystack, haystack_len, CopyString),
matches);
return HPHP::same(r, 1);
}
+4 -4
Ver Arquivo
@@ -1438,7 +1438,7 @@ void DebuggerClient::print(CStrRef msg) {
name(msg); \
} \
void DebuggerClient::name(const std::string &msg) { \
name(String(msg.data(), msg.length(), AttachLiteral)); \
name(String(msg.data(), msg.length(), CopyString)); \
} \
IMPLEMENT_COLOR_OUTPUT(help, stdout, HelpColor);
@@ -1451,7 +1451,7 @@ IMPLEMENT_COLOR_OUTPUT(error, stderr, ErrorColor);
string DebuggerClient::wrap(const std::string &s) {
TRACE(2, "DebuggerClient::wrap\n");
String ret = StringUtil::WordWrap(String(s.c_str(), s.size(), AttachLiteral),
String ret = StringUtil::WordWrap(String(s.c_str(), s.size(), CopyString),
LineWidth - 4, "\n", true);
return string(ret.data(), ret.size());
}
@@ -1496,8 +1496,8 @@ void DebuggerClient::helpCmds(const std::vector<const char *> &cmds) {
StringBuffer sb;
for (unsigned int i = 0; i < cmds.size() - 1; i += 2) {
String cmd(cmds[i], AttachLiteral);
String desc(cmds[i+1], AttachLiteral);
String cmd(cmds[i], CopyString);
String desc(cmds[i+1], CopyString);
// two special formats
if (cmd.empty() && desc.empty()) {
@@ -27,7 +27,7 @@ String DebuggerThriftBuffer::readImpl() {
assert(m_size <= BUFFER_SIZE);
int nread = m_socket->readImpl(m_buffer, m_size);
m_buffer[nread] = '\0';
return String(m_buffer, nread, AttachLiteral);
return String(m_buffer, nread, CopyString);
}
void DebuggerThriftBuffer::flushImpl(CStrRef data) {
+14 -14
Ver Arquivo
@@ -479,7 +479,7 @@ void const_load_impl(struct cache_info *info,
const char **p = objects;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
const_load_set(key, unserialize_from_string(value));
}
}
@@ -491,7 +491,7 @@ void const_load_impl(struct cache_info *info,
const char **p = thrifts;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant success;
Variant v = f_fb_unserialize(value, ref(success));
if (same(success, false)) {
@@ -507,7 +507,7 @@ void const_load_impl(struct cache_info *info,
const char **p = others;
for (int i = 0; i < count; i++, p += 4) {
String key(*p, (int)(int64_t)*(p+1), CopyString);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
throw Exception("bad apc archive, unserialize_from_string failed");
@@ -574,7 +574,7 @@ void apc_load_impl(struct cache_info *info,
item.key = *p;
item.len = (int)(int64_t)*(p+1);
// Strings would be copied into APC anyway.
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
s.constructPrime(value, item, false);
}
s.prime(vars);
@@ -589,7 +589,7 @@ void apc_load_impl(struct cache_info *info,
SharedStore::KeyValuePair &item = vars[i];
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
s.constructPrime(value, item, true);
}
s.prime(vars);
@@ -604,7 +604,7 @@ void apc_load_impl(struct cache_info *info,
SharedStore::KeyValuePair &item = vars[i];
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant success;
Variant v = f_fb_unserialize(value, ref(success));
if (same(success, false)) {
@@ -625,7 +625,7 @@ void apc_load_impl(struct cache_info *info,
item.key = *p;
item.len = (int)(int64_t)*(p+1);
String value(*(p+2), (int)(int64_t)*(p+3), AttachLiteral);
String value(*(p+2), (int)(int64_t)*(p+3), CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
// we can't possibly get here if it was a boolean "false" that's
@@ -726,7 +726,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, object_lens[i + i + 2], CopyString);
p += object_lens[i + i + 2] + 1;
String value(p, object_lens[i + i + 3], AttachLiteral);
String value(p, object_lens[i + i + 3], CopyString);
const_load_set(key, unserialize_from_string(value));
p += object_lens[i + i + 3] + 1;
}
@@ -744,7 +744,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, thrift_lens[i + i + 2], CopyString);
p += thrift_lens[i + i + 2] + 1;
String value(p, thrift_lens[i + i + 3], AttachLiteral);
String value(p, thrift_lens[i + i + 3], CopyString);
Variant success;
Variant v = f_fb_unserialize(value, ref(success));
if (same(success, false)) {
@@ -767,7 +767,7 @@ void const_load_impl_compressed
for (int i = 0; i < count; i++) {
String key(p, other_lens[i + i + 2], CopyString);
p += other_lens[i + i + 2] + 1;
String value(p, other_lens[i + i + 3], AttachLiteral);
String value(p, other_lens[i + i + 3], CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
throw Exception("bad apc archive, unserialize_from_string failed");
@@ -856,7 +856,7 @@ void apc_load_impl_compressed
item.len = string_lens[i + i + 2];
p += string_lens[i + i + 2] + 1; // skip \0
// Strings would be copied into APC anyway.
String value(p, string_lens[i + i + 3], AttachLiteral);
String value(p, string_lens[i + i + 3], CopyString);
// todo: t2539893: check if value is already a static string
s.constructPrime(value, item, false);
p += string_lens[i + i + 3] + 1; // skip \0
@@ -879,7 +879,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = object_lens[i + i + 2];
p += object_lens[i + i + 2] + 1; // skip \0
String value(p, object_lens[i + i + 3], AttachLiteral);
String value(p, object_lens[i + i + 3], CopyString);
s.constructPrime(value, item, true);
p += object_lens[i + i + 3] + 1; // skip \0
}
@@ -901,7 +901,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = thrift_lens[i + i + 2];
p += thrift_lens[i + i + 2] + 1; // skip \0
String value(p, thrift_lens[i + i + 3], AttachLiteral);
String value(p, thrift_lens[i + i + 3], CopyString);
Variant success;
Variant v = f_fb_unserialize(value, ref(success));
if (same(success, false)) {
@@ -928,7 +928,7 @@ void apc_load_impl_compressed
item.key = p;
item.len = other_lens[i + i + 2];
p += other_lens[i + i + 2] + 1; // skip \0
String value(p, other_lens[i + i + 3], AttachLiteral);
String value(p, other_lens[i + i + 3], CopyString);
Variant v = unserialize_from_string(value);
if (same(v, false)) {
// we can't possibly get here if it was a boolean "false" that's
+2 -2
Ver Arquivo
@@ -649,7 +649,7 @@ public:
g_context->write(data, length);
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
return t->fp->write(String(data, length, CopyString), length);
case PHP_CURL_RETURN:
if (length > 0) {
t->buf.append(data, (int)length);
@@ -684,7 +684,7 @@ public:
}
break;
case PHP_CURL_FILE:
return t->fp->write(String(data, length, AttachLiteral), length);
return t->fp->write(String(data, length, CopyString), length);
case PHP_CURL_USER:
{
Variant ret = ch->do_callback(
+4 -4
Ver Arquivo
@@ -47,11 +47,11 @@ String f_intl_get_error_message() {
if (!s_intl_error->m_error.custom_error_message.empty()) {
return s_intl_error->m_error.custom_error_message;
}
return String(u_errorName(s_intl_error->m_error.code), AttachLiteral);
return String(u_errorName(s_intl_error->m_error.code), CopyString);
}
String f_intl_error_name(int64_t error_code) {
return String(u_errorName((UErrorCode)error_code), AttachLiteral);
return String(u_errorName((UErrorCode)error_code), CopyString);
}
bool f_intl_is_failure(int64_t error_code) {
@@ -222,7 +222,7 @@ int64_t c_Collator::t_geterrorcode() {
}
String c_Collator::t_geterrormessage() {
return String(u_errorName(m_errcode.code), AttachLiteral);
return String(u_errorName(m_errcode.code), CopyString);
}
String c_Collator::t_getlocale(int64_t type /* = 0 */) {
@@ -234,7 +234,7 @@ String c_Collator::t_getlocale(int64_t type /* = 0 */) {
String ret(
(char*)ucol_getLocaleByType(m_ucoll, (ULocDataLocaleType)type,
&(m_errcode.code)),
AttachLiteral);
CopyString);
if (U_FAILURE(m_errcode.code)) {
m_errcode.custom_error_message = "Error getting locale by type";
s_intl_error->m_error.code = m_errcode.code;
+4 -4
Ver Arquivo
@@ -2418,7 +2418,7 @@ int pdo_parse_params(PDOStatement *stmt, CStrRef in, String &out) {
if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > params.size()) {
int ok = 1;
for (plc = placeholders; plc; plc = plc->next) {
if (!params.exists(String(plc->pos, plc->len, AttachLiteral))) {
if (!params.exists(String(plc->pos, plc->len, CopyString))) {
ok = 0;
break;
}
@@ -2446,7 +2446,7 @@ safe:
if (query_type == PDO_PLACEHOLDER_POSITIONAL) {
vparam = params[plc->bindno];
} else {
vparam = params[String(plc->pos, plc->len, AttachLiteral)];
vparam = params[String(plc->pos, plc->len, CopyString)];
}
if (vparam.isNull()) {
/* parameter was not defined */
@@ -2549,7 +2549,7 @@ rewrite:
for (plc = placeholders; plc; plc = plc->next) {
int skip_map = 0;
String name(plc->pos, plc->len, AttachLiteral);
String name(plc->pos, plc->len, CopyString);
/* check if bound parameter is already available */
if (!strcmp(name.c_str(), "?") ||
@@ -2581,7 +2581,7 @@ rewrite:
newbuffer_len = in.size();
for (plc = placeholders; plc; plc = plc->next) {
String name(plc->pos, plc->len, AttachLiteral);
String name(plc->pos, plc->len, CopyString);
stmt->bound_param_map.set(plc->bindno, name);
plc->quoted = "?";
}
+1 -1
Ver Arquivo
@@ -469,7 +469,7 @@ void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
if (len == -1 && errno == EINTR) continue;
if (len <= 0) break; // break on error or EOF
buffer[len] = '\0';
echo(String(buffer, len, AttachLiteral));
echo(String(buffer, len, CopyString));
}
int ret = ctx.exit();
if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
+1 -1
Ver Arquivo
@@ -276,7 +276,7 @@ String SessionModule::create_sid() {
to_read : (int)sizeof(buf)));
if (n <= 0) break;
if (!f_hash_update(context.toResource(),
String((const char *)rbuf, n, AttachLiteral))) {
String((const char *)rbuf, n, CopyString))) {
Logger::Error("hash_update() failed");
::close(fd);
return String();
+1 -1
Ver Arquivo
@@ -1001,7 +1001,7 @@ void c_SimpleXMLElement::t_offsetunset(CVarRef index) {
if (m_attributes.toArray().exists(name) && m_node) {
for (xmlAttrPtr attr = m_node->properties; attr; attr = attr->next) {
if (String((char*)attr->name, xmlStrlen(attr->name), AttachLiteral) ==
if (String((char*)attr->name, xmlStrlen(attr->name), CopyString) ==
name) {
xmlUnlinkNode((xmlNodePtr)attr);
break;
+8 -8
Ver Arquivo
@@ -476,9 +476,9 @@ static bool do_request(c_SoapClient *client, xmlDoc *request,
client->m_last_request = String((char*)buf, buf_size, CopyString);
}
response = client->o_invoke_few_args(s___dorequest, 5,
String(buf, buf_size, AttachLiteral),
String(location, AttachLiteral),
String(action, AttachLiteral),
String(buf, buf_size, CopyString),
String(location, CopyString),
String(action, CopyString),
version, one_way);
if (!response.isString()) {
if (client->m_soap_fault.isNull()) {
@@ -1777,7 +1777,7 @@ static void send_soap_server_fault(sdlFunctionPtr function, Variant fault,
xmlChar *buf; int size;
xmlDocDumpMemory(doc_return, &buf, &size);
if (buf) {
echo(String((const char *)buf, size, AttachLiteral));
echo(String((const char *)buf, size, CopyString));
xmlFree(buf);
}
xmlFreeDoc(doc_return);
@@ -2090,16 +2090,16 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
if (!data || !*data || !size) {
return;
}
req = String(data, size, AttachLiteral);
req = String(data, size, CopyString);
GlobalVariables *g = get_global_variables();
if (g->get(s__SERVER).toArray().exists(s_HTTP_CONTENT_ENCODING)) {
String encoding = g->get(s__SERVER)[s_HTTP_CONTENT_ENCODING].toString();
Variant ret;
if (encoding == "gzip" || encoding == "x-gzip") {
ret = f_gzinflate(String(data, size, AttachLiteral));
ret = f_gzinflate(String(data, size, CopyString));
} else if (encoding == "deflate") {
ret = f_gzuncompress(String(data, size, AttachLiteral));
ret = f_gzuncompress(String(data, size, CopyString));
} else {
raise_warning("Request is encoded with unknown compression '%s'",
encoding.data());
@@ -2255,7 +2255,7 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
}
output_xml_header(soap_version);
if (buf) {
echo(String((char*)buf, size, AttachLiteral));
echo(String((char*)buf, size, CopyString));
xmlFree(buf);
}
}
+1 -1
Ver Arquivo
@@ -105,7 +105,7 @@ Variant f_stream_copy_to_stream(CResRef source, CResRef dest,
if (rbytes == 0) break;
if (rbytes < 0) return false;
buf[rbytes] = '\0';
if (destFile->write(String(buf, rbytes, AttachLiteral)) != rbytes) {
if (destFile->write(String(buf, rbytes, CopyString)) != rbytes) {
return false;
}
cbytes += rbytes;
+1 -1
Ver Arquivo
@@ -145,7 +145,7 @@ static void url_encode_array(StringBuffer &ret, CVarRef varr,
new_prefix += key_suffix;
new_prefix += "%5B";
url_encode_array(ret, data, seen_arrs, String(),
new_prefix.detach(), String("%5D", AttachLiteral),
new_prefix.detach(), String("%5D", CopyString),
arg_sep);
} else {
if (!ret.empty()) {
+1 -1
Ver Arquivo
@@ -875,7 +875,7 @@ int64_t f_xml_get_error_code(CResRef parser) {
String f_xml_error_string(int code) {
char * str = (char *)XML_ErrorString((XML_Error)/*(int)*/code);
return String(str, AttachLiteral);
return String(str, CopyString);
}
///////////////////////////////////////////////////////////////////////////////
+2 -2
Ver Arquivo
@@ -31,9 +31,9 @@ FilesMatch::FilesMatch(Hdf vh) {
bool FilesMatch::match(const std::string &filename) const {
if (!m_pattern.empty()) {
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(filename.c_str(), filename.size(),
AttachLiteral));
CopyString));
return ret.toInt64() > 0;
}
return false;
+1 -1
Ver Arquivo
@@ -230,7 +230,7 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
// For literal we disregard RuntimeOption::AlwaysPopulateRawPostData
if (uint32_t(size) <= StringData::MaxSize) {
g->getRef(s_HTTP_RAW_POST_DATA) =
String((char*)data, size, AttachLiteral);
String((char*)data, size, CopyString);
}
}
}
+2 -2
Ver Arquivo
@@ -421,10 +421,10 @@ bool HttpRequestHandler::handleProxyRequest(Transport *transport, bool force) {
bool HttpRequestHandler::MatchAnyPattern
(const std::string &path, const std::vector<std::string> &patterns) {
String spath(path.c_str(), path.size(), AttachLiteral);
String spath(path.c_str(), path.size(), CopyString);
for (unsigned int i = 0; i < patterns.size(); i++) {
Variant ret = preg_match(String(patterns[i].c_str(), patterns[i].size(),
AttachLiteral),
CopyString),
spath);
if (ret.toInt64() > 0) return true;
}
+1 -1
Ver Arquivo
@@ -226,7 +226,7 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport,
int size;
const void *data = transport->getPostData(size);
if (data && size) {
params.append(String((char*)data, size, AttachLiteral));
params.append(String((char*)data, size, CopyString));
}
}
}
+4 -4
Ver Arquivo
@@ -70,12 +70,12 @@ SatelliteServerInfo::SatelliteServerInfo(Hdf hdf) {
}
bool SatelliteServerInfo::checkMainURL(const std::string& path) {
String url(path.c_str(), path.size(), AttachLiteral);
String url(path.c_str(), path.size(), CopyString);
for (std::set<string>::const_iterator iter =
SatelliteServerInfo::InternalURLs.begin();
iter != SatelliteServerInfo::InternalURLs.end(); ++iter) {
Variant ret = preg_match
(String(iter->c_str(), iter->size(), AttachLiteral), url);
(String(iter->c_str(), iter->size(), CopyString), url);
if (ret.toInt64() > 0) {
return false;
}
@@ -109,10 +109,10 @@ public:
private:
bool checkURL(const std::string &path) const {
String url(path.c_str(), path.size(), AttachLiteral);
String url(path.c_str(), path.size(), CopyString);
for (const auto &allowed : m_allowedURLs) {
Variant ret = preg_match
(String(allowed.c_str(), allowed.size(), AttachLiteral), url);
(String(allowed.c_str(), allowed.size(), CopyString), url);
if (ret.toInt64() > 0) {
return true;
}
+2 -2
Ver Arquivo
@@ -160,8 +160,8 @@ void ServerStats::Filter(list<TimeSlot*> &slots, const std::string &keys,
const string &rule = riter->first;
if (rule[0] == ':') {
Variant ret = preg_match(String(rule.c_str(), rule.size(),
AttachLiteral),
String(key.c_str(), key.size(), AttachLiteral));
CopyString),
String(key.c_str(), key.size(), CopyString));
if (!same(ret, false) && more(ret, 0)) {
wantedKeys[key] |= riter->second;
}
+1 -1
Ver Arquivo
@@ -39,7 +39,7 @@ SourceRootInfo::SourceRootInfo(const char *host)
Variant matches;
Variant r = preg_match(String(RuntimeOption::SandboxPattern.c_str(),
RuntimeOption::SandboxPattern.size(),
AttachLiteral), host, matches);
CopyString), host, matches);
if (!same(r, 1)) {
m_sandboxCond = SandboxCondition::Off;
return;
+2 -2
Ver Arquivo
@@ -690,7 +690,7 @@ void Transport::prepareHeaders(bool compressed, bool chunked,
String Transport::prepareResponse(const void *data, int size, bool &compressed,
bool last) {
String response((const char *)data, size, AttachLiteral);
String response((const char *)data, size, CopyString);
// we don't use chunk encoding to send anything pre-compressed
assert(!compressed || !m_chunkedEncoding);
@@ -783,7 +783,7 @@ void Transport::sendRawLocked(void *data, int size, int code /* = 200 */,
// HTTP header handling
if (!m_headerSent) {
String orig_response((const char *)data, size, AttachLiteral);
String orig_response((const char *)data, size, CopyString);
prepareHeaders(compressed, chunked, response, orig_response);
m_headerSent = true;
}
+9 -9
Ver Arquivo
@@ -261,9 +261,9 @@ void VirtualHost::init(Hdf vh) {
bool VirtualHost::match(const string &host) const {
if (!m_pattern.empty()) {
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(host.c_str(), host.size(),
AttachLiteral));
CopyString));
return ret.toInt64() > 0;
} else if (!m_prefix.empty()) {
return strncasecmp(host.c_str(), m_prefix.c_str(), m_prefix.size()) == 0;
@@ -302,7 +302,7 @@ bool VirtualHost::rewriteURL(CStrRef host, String &url, bool &qsa,
subject = host;
}
Variant ret = preg_match(String(it->pattern.c_str(), it->pattern.size(),
AttachLiteral), subject);
CopyString), subject);
if (!same(ret, it->negate ? 0 : 1)) {
passed = false;
break;
@@ -379,9 +379,9 @@ std::string VirtualHost::serverName(const std::string &host) const {
if (!m_pattern.empty()) {
Variant matches;
Variant ret = preg_match(String(m_pattern.c_str(), m_pattern.size(),
AttachLiteral),
CopyString),
String(host.c_str(), host.size(),
AttachLiteral),
CopyString),
matches);
if (ret.toInt64() > 0) {
String prefix = matches[1].toString();
@@ -414,9 +414,9 @@ std::string VirtualHost::filterUrl(const std::string &url) const {
if (!filter.urlPattern.empty()) {
Variant ret = preg_match(String(filter.urlPattern.c_str(),
filter.urlPattern.size(),
AttachLiteral),
CopyString),
String(url.c_str(), url.size(),
AttachLiteral));
CopyString));
match = (ret.toInt64() > 0);
}
@@ -429,9 +429,9 @@ std::string VirtualHost::filterUrl(const std::string &url) const {
int count = preg_replace(ret, filter.namePattern.c_str(),
String(filter.replaceWith.c_str(),
filter.replaceWith.size(),
AttachLiteral),
CopyString),
String(url.c_str(), url.size(),
AttachLiteral));
CopyString));
if (!same(ret, false) && count > 0) {
return ret.toString().data();
}
+1 -1
Ver Arquivo
@@ -4832,7 +4832,7 @@ void CodeGenerator::cgLdClsPropAddrCached(IRInstruction* inst) {
string sds(Util::toLower(clsNameString->data()) + ":" +
string(propNameString->data(), propNameString->size()));
StackStringData sd(sds.c_str(), sds.size(), AttachLiteral);
StackStringData sd(sds.c_str(), sds.size(), CopyString);
CacheHandle ch = SPropCache::alloc(&sd);
auto dstReg = m_regs[dst].reg();
+1 -1
Ver Arquivo
@@ -379,7 +379,7 @@ void RepoQuery::getStaticString(int iCol, StringData*& s) {
const char* text;
size_t size;
getText(iCol, text, size);
StackStringData sd(text, size, AttachLiteral);
StackStringData sd(text, size, CopyString);
s = StringData::GetStaticString(&sd);
}
}
+1 -1
Ver Arquivo
@@ -192,7 +192,7 @@ bool TestCppBase::TestString() {
VS(String("test").rvalAt(2).c_str(), "s");
String s = "test";
s.set(2, String(""));
VS(s, String("te\0t", 4, AttachLiteral));
VS(s, String("te\0t", 4, CopyString));
s.set(2, String("zz"));
VS(s, "tezt");
s.set(5, String("q"));