Remove String::operator const char*().

Too many ways to shoot self in foot with this gem.
Esse commit está contido em:
Edwin Smith
2013-04-24 12:51:19 -07:00
commit de Sara Golemon
commit f29ee5314d
61 arquivos alterados com 298 adições e 270 exclusões
+3 -1
Ver Arquivo
@@ -685,7 +685,9 @@ void throw_unexpected_argument_type(int argNum, const char *fnName,
case KindOfStaticString:
case KindOfString: otype = "string"; break;
case KindOfArray: otype = "array"; break;
case KindOfObject: otype = val.getObjectData()->o_getClassName(); break;
case KindOfObject:
otype = val.getObjectData()->o_getClassName().c_str();
break;
default:
assert(false);
}
-11
Ver Arquivo
@@ -654,17 +654,6 @@ bool ClassInfo::checkAccess(ClassInfo *defClass,
return false;
}
const char *ClassInfo::getConstructor() const {
ClassInfo *defClass;
if (hasMethod("__construct", defClass)) {
return "__construct";
}
if (!(m_attribute & IsTrait) && hasMethod(m_name, defClass)) {
return m_name;
}
return nullptr;
}
void ClassInfo::getAllProperties(PropertyMap &props) const {
const PropertyMap &properties = getProperties();
props.insert(properties.begin(), properties.end());
+2 -3
Ver Arquivo
@@ -144,7 +144,7 @@ public:
struct MethodInfo {
MethodInfo() : docComment(nullptr) {}
MethodInfo(const char **&p);
explicit MethodInfo(const char **&p);
~MethodInfo();
MethodInfo *getDeclared();
Attribute attribute;
@@ -397,7 +397,6 @@ public:
bool staticCall, bool hasCallObject);
static bool IsSubClass(CStrRef className1, CStrRef className2,
bool considerInterface);
const char *getConstructor() const;
/**
* Property functions.
@@ -457,7 +456,7 @@ public:
/**
* Read one class's information from specified map pointer and move it.
*/
ClassInfoUnique(const char **&p);
explicit ClassInfoUnique(const char **&p);
virtual ~ClassInfoUnique();
// implementing ClassInfo
+8 -6
Ver Arquivo
@@ -198,7 +198,7 @@ void BaseExecutionContext::setContentType(CStrRef mimetype, CStrRef charset) {
contentType += "; ";
contentType += "charset=";
contentType += charset;
m_transport->addHeader("Content-Type", contentType);
m_transport->addHeader("Content-Type", contentType.c_str());
m_transport->setDefaultContentType(false);
}
}
@@ -638,7 +638,7 @@ void BaseExecutionContext::handleError(const std::string &msg,
if (!Eval::Debugger::InterruptException(String(msg))) return;
} catch (const Eval::DebuggerClientExitException &e) {}
const char *file = nullptr;
String file = empty_string;
int line = 0;
if (RuntimeOption::InjectedStackTrace) {
if (!bt.empty()) {
@@ -648,7 +648,7 @@ void BaseExecutionContext::handleError(const std::string &msg,
}
}
Logger::Log(Logger::LogError, prefix.c_str(), ee, file, line);
Logger::Log(Logger::LogError, prefix.c_str(), ee, file.c_str(), line);
}
}
@@ -702,7 +702,7 @@ void BaseExecutionContext::recordLastError(const Exception &e,
bool BaseExecutionContext::onFatalError(const Exception &e) {
recordLastError(e);
const char *file = nullptr;
String file = empty_string;
int line = 0;
if (RuntimeOption::InjectedStackTrace) {
const ExtendedException *ee = dynamic_cast<const ExtendedException *>(&e);
@@ -716,7 +716,8 @@ bool BaseExecutionContext::onFatalError(const Exception &e) {
}
}
if (RuntimeOption::AlwaysLogUnhandledExceptions) {
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line);
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e,
file.c_str(), line);
}
bool handled = false;
if (RuntimeOption::CallUserHandlerOnFatals) {
@@ -724,7 +725,8 @@ bool BaseExecutionContext::onFatalError(const Exception &e) {
handled = callUserErrorHandler(e, errnum, true);
}
if (!handled && !RuntimeOption::AlwaysLogUnhandledExceptions) {
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e, file, line);
Logger::Log(Logger::LogError, "HipHop Fatal error: ", e,
file.c_str(), line);
}
return handled;
}
+1 -1
Ver Arquivo
@@ -311,7 +311,7 @@ public:
int getErrorReportingLevel() const { return m_errorReportingLevel;}
void setErrorReportingLevel(int level) { m_errorReportingLevel = level;}
String getErrorPage() const { return m_errorPage;}
void setErrorPage(CStrRef page) { m_errorPage = page;}
void setErrorPage(CStrRef page) { m_errorPage = (std::string) page; }
bool getLogErrors() const { return m_logErrors;}
void setLogErrors(bool on);
String getErrorLog() const { return m_errorLog;}
+3 -2
Ver Arquivo
@@ -51,7 +51,8 @@ MemFile::~MemFile() {
bool MemFile::open(CStrRef filename, CStrRef mode) {
assert(m_len == -1);
// mem files are read-only
if (strchr(mode, '+') || strchr(mode, 'a') || strchr(mode, 'w')) {
const char* mode_str = mode.c_str();
if (strchr(mode_str, '+') || strchr(mode_str, 'a') || strchr(mode_str, 'w')) {
return false;
}
int len = INT_MIN;
@@ -72,7 +73,7 @@ bool MemFile::open(CStrRef filename, CStrRef mode) {
m_len = len;
return true;
}
m_name = filename;
m_name = (std::string) filename;
m_data = data;
m_len = len;
return true;
+5 -4
Ver Arquivo
@@ -487,19 +487,20 @@ bool SSLSocket::applyVerificationPolicy(X509 *peer) {
return false;
}
bool match = (strcmp(cnmatch, buf) == 0);
bool match = (strcmp(cnmatch.c_str(), buf) == 0);
if (!match && strlen(buf) > 3 && buf[0] == '*' && buf[1] == '.') {
/* Try wildcard */
if (strchr(buf+2, '.')) {
const char *tmp = strstr(cnmatch, buf+1);
match = tmp && strcmp(tmp, buf+2) && tmp == strchr(cnmatch, '.');
const char* cnmatch_str = cnmatch.c_str();
const char *tmp = strstr(cnmatch_str, buf+1);
match = tmp && strcmp(tmp, buf+2) && tmp == strchr(cnmatch_str, '.');
}
}
if (!match) {
/* didn't match */
raise_warning("Peer certificate CN=`%.*s' did not match expected CN=`%s'",
name_len, buf, cnmatch.data());
name_len, buf, cnmatch.c_str());
return false;
}
}
+3 -2
Ver Arquivo
@@ -41,7 +41,8 @@ UrlFile::UrlFile(const char *method /* = "GET" */,
}
bool UrlFile::open(CStrRef url, CStrRef mode) {
if (strchr(mode, '+') || strchr(mode, 'a') || strchr(mode, 'w')) {
const char* modestr = mode.c_str();
if (strchr(modestr, '+') || strchr(modestr, 'a') || strchr(modestr, 'w')) {
std::string msg = "cannot open a url stream for write/append operation: ";
msg += url.c_str();
m_error = msg;
@@ -78,7 +79,7 @@ bool UrlFile::open(CStrRef url, CStrRef mode) {
m_responseHeaders = r;
if (code == 200) {
m_name = url;
m_name = (std::string) url;
m_data = const_cast<char*>(m_response.data());
m_len = m_response.size();
return true;
+1 -1
Ver Arquivo
@@ -45,7 +45,7 @@ void ZipFile::sweep() {
bool ZipFile::open(CStrRef filename, CStrRef mode) {
assert(m_gzFile == nullptr);
if (strchr(mode, '+')) {
if (strchr(mode.c_str(), '+')) {
raise_warning("cannot open a zlib stream for reading and writing "
"at the same time!");
return false;
+1 -1
Ver Arquivo
@@ -123,7 +123,7 @@ bool ObjectData::o_instanceof(CStrRef s) const {
}
bool ObjectData::o_isClass(const char *s) const {
return strcasecmp(s, o_getClassName()) == 0;
return strcasecmp(s, o_getClassName().c_str()) == 0;
}
int64_t ObjectData::o_toInt64() const {
+1 -1
Ver Arquivo
@@ -381,7 +381,7 @@ bool AccessLog::genField(std::ostringstream &out, const char* &format,
{
String b, q;
RequestURI::splitURL(transport->getUrl(), b, q);
out << b;
out << b.c_str();
}
break;
case 'v':
+3 -4
Ver Arquivo
@@ -282,10 +282,9 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
if (!transport->isSSL() && RuntimeOption::ServerPort != 80) {
port_suffix = ":" + RuntimeOption::ServerPort;
}
server.set("SCRIPT_URI", String(prefix +
(hostHeader.empty() ?
hostName + port_suffix : hostHeader)
+ r.originalURL()));
server.set("SCRIPT_URI",
String(prefix + (hostHeader.empty() ? hostName + port_suffix :
String(hostHeader)) + r.originalURL()));
if (r.rewritten()) {
// when URL is rewritten, PHP decided to put original URL as SCRIPT_NAME
@@ -80,13 +80,13 @@ void HttpRequestHandler::sendStaticContent(Transport *transport,
char age[20];
snprintf(age, sizeof(age), "max-age=%d", RuntimeOption::ExpiresDefault);
transport->addHeader("Cache-Control", age);
transport->addHeader
("Expires", DateTime(expires, true).toString(DateTime::HttpHeader));
transport->addHeader("Expires",
DateTime(expires, true).toString(DateTime::HttpHeader).c_str());
}
if (mtime) {
transport->addHeader
("Last-Modified", DateTime(mtime, true).toString(DateTime::HttpHeader));
transport->addHeader("Last-Modified",
DateTime(mtime, true).toString(DateTime::HttpHeader).c_str());
}
transport->addHeader("Accept-Ranges", "bytes");
+1 -1
Ver Arquivo
@@ -72,7 +72,7 @@ public:
disableCompression(); // so we don't have to decompress during sendImpl()
m_rfc1867UploadedFiles = rfc1867UploadedFiles;
m_files = f_serialize(files);
m_files = (std::string) f_serialize(files);
}
/**
+2 -2
Ver Arquivo
@@ -137,7 +137,7 @@ bool RequestURI::rewriteURL(const VirtualHost *vhost, Transport *transport,
m_rewrittenURL.substr(0, 8) != "https://") {
PrependSlash(m_rewrittenURL);
}
transport->redirect(m_rewrittenURL, redirect, "rewriteURL");
transport->redirect(m_rewrittenURL.c_str(), redirect, "rewriteURL");
return false;
}
splitURL(m_rewrittenURL, m_rewrittenURL, m_queryString);
@@ -168,7 +168,7 @@ bool RequestURI::rewriteURL(const VirtualHost *vhost, Transport *transport,
m_rewrittenURL.substr(0, 8) != "https://") {
PrependSlash(m_rewrittenURL);
}
transport->redirect(m_rewrittenURL, 301, "rewriteURL");
transport->redirect(m_rewrittenURL.c_str(), 301, "rewriteURL");
return false;
}
}
@@ -220,7 +220,9 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport,
reqInitDoc = m_serverInfo->getReqInitDoc();
}
if (!reqInitDoc.empty()) reqInitDoc = canonicalize_path(reqInitDoc, "", 0);
if (!reqInitDoc.empty()) {
reqInitDoc = (std::string)canonicalize_path(reqInitDoc, "", 0);
}
if (!reqInitDoc.empty()) {
reqInitDoc = getSourceFilename(reqInitDoc, sourceRootInfo);
}
@@ -248,7 +250,7 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport,
}
}
if (!forbidden) {
rpcFile = canonicalize_path(rpcFile, "", 0);
rpcFile = (std::string) canonicalize_path(rpcFile, "", 0);
rpcFile = getSourceFilename(rpcFile, sourceRootInfo);
ret = hphp_invoke(m_context, rpcFile, false, Array(), uninit_null(),
reqInitFunc, reqInitDoc, error, errorMsg, runOnce);
+2 -2
Ver Arquivo
@@ -224,8 +224,8 @@ string SourceRootInfo::parseSandboxServerVariable(const string &format) const {
res.write(data, n);
break;
}
case 's': res << m_sandbox; break;
case 'u': res << m_user; break;
case 's': res << m_sandbox.c_str(); break;
case 'u': res << m_user.c_str(); break;
default: res << c; break;
}
control = false;
+1 -1
Ver Arquivo
@@ -648,7 +648,7 @@ void Transport::prepareHeaders(bool compressed, const void *data, int size) {
f_openssl_decrypt(encrypted, cipher, key, k_OPENSSL_RAW_DATA, iv);
assert(decrypted->same(ip.get()));
}
addHeaderImpl("X-FB-Debug", output);
addHeaderImpl("X-FB-Debug", output.c_str());
}
// shutting down servers, so need to terminate all Keep-Alive connections
+5
Ver Arquivo
@@ -91,6 +91,11 @@ StringData *StringData::GetStaticString(const StringData *str) {
return const_cast<StringData*>(pair.first->first);
}
StringData* StringData::GetStaticString(const String& str) {
assert(!str.isNull());
return GetStaticString(str.get());
}
StringData* StringData::FindStaticString(const StringData* str) {
if (UNLIKELY(!s_stringDataMap)) s_stringDataMap = new StringDataMap();
StringDataMap::const_iterator it = s_stringDataMap->find(str);
+9 -8
Ver Arquivo
@@ -154,7 +154,7 @@ class StringData {
* Different ways of constructing StringData. Default constructor at above
* is actually only for SmartAllocator to pre-allocate the objects.
*/
StringData(const char* data) {
explicit StringData(const char* data) {
initLiteral(data);
}
StringData(const char *data, AttachLiteralMode) {
@@ -208,9 +208,9 @@ class StringData {
* Create a new empty string big enough to hold the requested size,
* not counting the \0 terminator.
*/
StringData(int reserve);
explicit StringData(int reserve);
StringData(SharedVariant *shared);
explicit StringData(SharedVariant *shared);
public:
void append(StringSlice r) { append(r.ptr, r.len); }
@@ -360,10 +360,11 @@ public:
std::string toCPPString() const;
static void sweepAll();
static StringData *FindStaticString(const StringData *str);
static StringData *GetStaticString(const StringData *str);
static StringData *GetStaticString(const std::string &str);
static StringData *GetStaticString(const char *str);
static StringData *FindStaticString(const StringData* str);
static StringData *GetStaticString(const StringData* str);
static StringData *GetStaticString(const std::string& str);
static StringData *GetStaticString(const String& str);
static StringData *GetStaticString(const char* str);
static StringData *GetStaticString(char c);
static size_t GetStaticStringCount();
static uint32_t GetCnsHandle(const StringData* cnsName);
@@ -440,7 +441,7 @@ public:
class StackStringData : public StringData {
public:
StackStringData() { incRefCount(); }
StackStringData(const char* s) : StringData(s) { incRefCount(); }
explicit StackStringData(const char* s) : StringData(s) { incRefCount(); }
template <class T>
StackStringData(const char* s, T p) : StringData(s, p) { incRefCount(); }
template <class T>
+28 -28
Ver Arquivo
@@ -288,8 +288,8 @@ Variant StringUtil::ChunkSplit(CStrRef body, int chunklen /* = 76 */,
ret = body;
ret += end;
} else {
char *chunked = string_chunk_split(body.data(), len, end, end.size(),
chunklen);
char *chunked = string_chunk_split(body.data(), len, end.c_str(),
end.size(), chunklen);
return String(chunked, len, AttachString);
}
return ret;
@@ -305,35 +305,36 @@ String StringUtil::CEncode(CStrRef input, CStrRef charlist) {
}
if (input.empty() || chars.empty()) return input;
int len = input.size();
char *ret = string_addcslashes(input, len, chars.data(), chars.size());
char *ret = string_addcslashes(input.c_str(), len, chars.data(),
chars.size());
return String(ret, len, AttachString);
}
String StringUtil::CDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_stripcslashes(input, len);
char *ret = string_stripcslashes(input.c_str(), len);
return String(ret, len, AttachString);
}
String StringUtil::SqlEncode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_addslashes(input, len);
char *ret = string_addslashes(input.c_str(), len);
return String(ret, len, AttachString);
}
String StringUtil::SqlDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_stripslashes(input, len);
char *ret = string_stripslashes(input.c_str(), len);
return String(ret, len, AttachString);
}
String StringUtil::RegExEncode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_quotemeta(input, len);
char *ret = string_quotemeta(input.c_str(), len);
return String(ret, len, AttachString);
}
@@ -350,7 +351,7 @@ String StringUtil::HtmlEncode(CStrRef input, QuoteStyle quoteStyle,
}
int len = input.size();
char *ret = string_html_encode(input, len, quoteStyle != NoQuotes,
char *ret = string_html_encode(input.data(), len, quoteStyle != NoQuotes,
quoteStyle == BothQuotes, utf8, nbsp);
if (!ret) {
raise_error("HtmlEncode called on too large input (%d)", len);
@@ -435,7 +436,7 @@ String StringUtil::HtmlEncodeExtra(CStrRef input, QuoteStyle quoteStyle,
}
int len = input.size();
char *ret = string_html_encode_extra(input, len,
char *ret = string_html_encode_extra(input.data(), len,
(StringHtmlEncoding)flags, am);
if (!ret) {
raise_error("HtmlEncode called on too large input (%d)", len);
@@ -450,7 +451,7 @@ String StringUtil::HtmlDecode(CStrRef input, QuoteStyle quoteStyle,
assert(charset);
int len = input.size();
char *ret = string_html_decode(input, len, quoteStyle != NoQuotes,
char *ret = string_html_decode(input.data(), len, quoteStyle != NoQuotes,
quoteStyle == BothQuotes, charset, all);
if (!ret) {
// null iff charset was not recognized
@@ -464,28 +465,28 @@ String StringUtil::HtmlDecode(CStrRef input, QuoteStyle quoteStyle,
String StringUtil::QuotedPrintableEncode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_quoted_printable_encode(input, len);
char *ret = string_quoted_printable_encode(input.data(), len);
return String(ret, len, AttachString);
}
String StringUtil::QuotedPrintableDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_quoted_printable_decode(input, len, false);
char *ret = string_quoted_printable_decode(input.data(), len, false);
return String(ret, len, AttachString);
}
String StringUtil::HexEncode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_bin2hex(input, len);
char *ret = string_bin2hex(input.data(), len);
return String(ret, len, AttachString);
}
String StringUtil::HexDecode(CStrRef input) {
if (input.empty()) return input;
int len = input.size();
char *ret = string_hex2bin(input, len);
char *ret = string_hex2bin(input.data(), len);
return String(ret, len, AttachString);
}
@@ -493,7 +494,7 @@ String StringUtil::UUEncode(CStrRef input) {
if (input.empty()) return input;
int len;
char *encoded = string_uuencode(input, input.size(), len);
char *encoded = string_uuencode(input.data(), input.size(), len);
return String(encoded, len, AttachString);
}
@@ -558,38 +559,37 @@ String StringUtil::Translate(CStrRef input, CStrRef from, CStrRef to) {
if (input.empty()) return input;
int len = input.size();
char *ret = (char *)malloc(len + 1);
memcpy(ret, input, len);
ret[len] = '\0';
int fromSize = from.size();
int toSize = to.size();
int trlen = (fromSize < toSize) ? fromSize : toSize;
string_translate(ret, len, from, to, trlen);
return String(ret, len, AttachString);
String retstr(len, ReserveString);
char *ret = retstr.mutableSlice().ptr;
memcpy(ret, input.data(), len);
auto trlen = std::min(from.size(), to.size());
string_translate(ret, len, from.data(), to.data(), trlen);
return retstr.setSize(len);
}
String StringUtil::ROT13(CStrRef input) {
if (input.empty()) return input;
return String(string_rot13(input, input.size()), input.size(), AttachString);
return String(string_rot13(input.data(), input.size()),
input.size(), AttachString);
}
int64_t StringUtil::CRC32(CStrRef input) {
return string_crc32(input, input.size());
return string_crc32(input.data(), input.size());
}
String StringUtil::Crypt(CStrRef input, const char *salt /* = "" */) {
return String(string_crypt(input, salt), AttachString);
return String(string_crypt(input.c_str(), salt), AttachString);
}
String StringUtil::MD5(CStrRef input, bool raw /* = false */) {
int len;
char *ret = string_md5(input, input.size(), raw, len);
char *ret = string_md5(input.data(), input.size(), raw, len);
return String(ret, len, AttachString);
}
String StringUtil::SHA1(CStrRef input, bool raw /* = false */) {
int len;
char *ret = string_sha1(input, input.size(), raw, len);
char *ret = string_sha1(input.data(), input.size(), raw, len);
return String(ret, len, AttachString);
}
+1 -1
Ver Arquivo
@@ -82,7 +82,7 @@ bool Object::equal(CObjRef v2) const {
if (isResource() || v2.isResource()) {
return false;
}
if (!v2.get()->o_isClass(m_px->o_getClassName())) {
if (!v2.get()->o_isClass(m_px->o_getClassName().c_str())) {
return false;
}
if (m_px->isCollection()) {
+6 -6
Ver Arquivo
@@ -14,14 +14,14 @@
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_OBJECT_H_
#define incl_HPHP_OBJECT_H_
#ifndef incl_HPHP_INSIDE_HPHP_COMPLEX_TYPES_H_
#error Directly including 'type_object.h' is prohibited. \
Include 'complex_types.h' instead.
#endif
#ifndef incl_HPHP_OBJECT_H_
#define incl_HPHP_OBJECT_H_
#include <runtime/base/util/smart_ptr.h>
#include <runtime/base/object_data.h>
#include <runtime/base/type_string.h>
@@ -57,8 +57,8 @@ public:
/**
* Constructors
*/
Object(ObjectData *data) : ObjectBase(data) { }
Object(CObjRef src) : ObjectBase(src.m_px) { }
/* implicit */ Object(ObjectData *data) : ObjectBase(data) { }
/* implicit */ Object(CObjRef src) : ObjectBase(src.m_px) { }
// Move ctor
Object(Object&& src) : ObjectBase(std::move(src)) {
@@ -125,7 +125,7 @@ public:
T *px = dynamic_cast<T*>(cur);
if (!px) {
if (!badTypeOkay) {
throw InvalidObjectTypeException(m_px->o_getClassName());
throw InvalidObjectTypeException(m_px->o_getClassName().c_str());
}
return nullptr;
}
+27 -17
Ver Arquivo
@@ -14,14 +14,14 @@
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_STRING_H_
#define incl_HPHP_STRING_H_
#ifndef incl_HPHP_INSIDE_HPHP_COMPLEX_TYPES_H_
#error Directly including 'type_string.h' is prohibited. \
Include 'complex_types.h' instead.
#endif
#ifndef incl_HPHP_STRING_H_
#define incl_HPHP_STRING_H_
#include <util/assertions.h>
#include <runtime/base/util/smart_ptr.h>
#include <runtime/base/string_data.h>
@@ -119,21 +119,21 @@ public:
/**
* Constructors
*/
String(StringData *data) : StringBase(data) { }
String(int n);
String(int64_t n);
String(double n);
String(litstr s) {
/* implicit */ String(StringData *data) : StringBase(data) { }
/* implicit */ String(int n);
/* implicit */ String(int64_t n);
/* implicit */ String(double n);
/* implicit */ String(litstr s) {
if (s) {
m_px = buildStringData(s);
m_px->setRefCount(1);
}
}
String(CStrRef str) : StringBase(str.m_px) { }
String(const String& str) : StringBase(str.m_px) { }
// Move ctor
String(String&& str) : StringBase(std::move(str)) {}
String(Variant&& src);
/* implicit */ String(String&& str) : StringBase(std::move(str)) {}
/* implicit */ String(Variant&& src);
// Move assign
String& operator=(String&& src) {
static_assert(sizeof(String) == sizeof(StringBase),"Fix this.");
@@ -144,7 +144,7 @@ public:
// Move assign from Variant
String& operator=(Variant&& src);
String(const std::string &s) { // always make a copy
/* implicit */ String(const std::string &s) { // always make a copy
m_px = NEW(StringData)(s.data(), s.size(), CopyString);
m_px->setRefCount(1);
}
@@ -190,6 +190,13 @@ public:
m_px->setRefCount(1);
}
}
// force a copy of a String
String(const String& s, CopyStringMode mode) {
if (s.m_px) {
m_px = NEW(StringData)(s.c_str(), s.size(), mode);
m_px->setRefCount(1);
}
}
// make an empty string with cap reserve bytes, plus 1 for '\0'
String(int cap, ReserveStringMode mode) {
m_px = NEW(StringData)(cap);
@@ -203,9 +210,6 @@ public:
/**
* Informational
*/
operator const char *() const {
return m_px ? m_px->data() : "";
}
const char *data() const {
return m_px ? m_px->data() : "";
}
@@ -326,6 +330,12 @@ public:
String &operator &= (CStrRef v);
String &operator ^= (CStrRef v);
String operator ~ () const;
explicit operator std::string () const {
return std::string(c_str(), size());
}
explicit operator bool() const {
return m_px != nullptr;
}
/**
* These are convenient functions for writing extensions, since code
@@ -600,9 +610,9 @@ class StaticString : public String {
public:
friend class StringUtil;
StaticString(litstr s);
explicit StaticString(litstr s);
StaticString(litstr s, int length); // binary string
StaticString(std::string s);
explicit StaticString(std::string s);
StaticString(const StaticString &str);
~StaticString() {
// prevent ~SmartPtr from calling decRefCount after data is released
+3 -3
Ver Arquivo
@@ -2404,7 +2404,7 @@ Variant Variant::o_invoke(CStrRef s, CArrRef params, int64_t hash /* = -1 */) {
} else if (m_type == KindOfRef) {
return m_data.pref->var()->o_invoke(s, params, hash);
} else {
throw_call_non_object(s);
throw_call_non_object(s.c_str());
}
}
@@ -2417,7 +2417,7 @@ Variant Variant::o_invoke_few_args(CStrRef s, int64_t hash, int count,
return m_data.pref->var()->o_invoke_few_args(s, hash, count,
INVOKE_FEW_ARGS_PASS_ARGS);
} else {
throw_call_non_object(s);
throw_call_non_object(s.c_str());
}
}
@@ -3041,7 +3041,7 @@ void Variant::unserialize(VariableUnserializer *uns,
Object obj;
if (RuntimeOption::UnserializationWhitelistCheck &&
!uns->isWhitelistedClass(clsName)) {
String err_msg =
const char* err_msg =
"The object being unserialized with class name '%s' "
"is not in the given whitelist. "
"See http://fburl.com/SafeSerializable for more detail";
+4 -4
Ver Arquivo
@@ -111,7 +111,7 @@ Variant ZendPack::pack(CStrRef fmt, CArrRef argv) {
vector<int> formatargs;
int argc = argv.size();
const char *format = fmt;
const char *format = fmt.c_str();
int formatlen = fmt.size();
int currentarg = 0;
for (int i = 0; i < formatlen; ) {
@@ -288,7 +288,7 @@ Variant ZendPack::pack(CStrRef fmt, CArrRef argv) {
case 'A':
memset(&output[outputpos], (code == 'a') ? '\0' : ' ', arg);
val = argv[currentarg++].toString();
s = (const char *)val;
s = val.c_str();
slen = val.size();
memcpy(&output[outputpos], s, (slen < arg) ? slen : arg);
outputpos += arg;
@@ -454,9 +454,9 @@ int32_t ZendPack::unpack(const char *data, int size, int issigned, int *map) {
}
Variant ZendPack::unpack(CStrRef fmt, CStrRef data) {
const char *format = fmt;
const char *format = fmt.c_str();
int formatlen = fmt.size();
const char *input = data;
const char *input = data.c_str();
int inputlen = data.size();
int inputpos = 0;
+1 -1
Ver Arquivo
@@ -926,7 +926,7 @@ char *string_printf(const char *format, int len, CArrRef args, int *outlen) {
switch (ch) {
case 's': {
String s = tmp.toString();
appendstring(&result, &outpos, &size, s,
appendstring(&result, &outpos, &size, s.c_str(),
width, precision, padding, alignment, s.size(),
0, expprec, 0);
break;
@@ -85,13 +85,13 @@ bool CmdInstrument::onClient(DebuggerClient *client) {
if (loc == "here") {
InstPointInfoPtr ipi(new InstPointInfo());
ipi->setLocHere();
ipi->m_code = code.toString();
ipi->m_code = (std::string) code.toString();
ipi->m_desc = desc;
m_instPoints->push_back(ipi);
} else if (loc.rfind("()") == loc.size() - 2){
InstPointInfoPtr ipi(new InstPointInfo());
ipi->setLocFuncEntry(loc.substr(0, loc.size() - 2));
ipi->m_code = code.toString();
ipi->m_code = (std::string) code.toString();
ipi->m_desc = desc;
m_instPoints->push_back(ipi);
} else {
+2 -2
Ver Arquivo
@@ -529,7 +529,7 @@ bool DebuggerClient::connectRemote(const std::string &host, int port) {
}
info("Connecting to %s:%d...", host.c_str(), port);
Socket *sock = new Socket(socket(PF_INET, SOCK_STREAM, 0), PF_INET,
String(host), port);
host.c_str(), port);
// Ensure the socket is not swept---it is cached across requests in
// API mode, and in client mode we expect to destruct it ourselves
// when ~DebuggerClient runs.
@@ -556,7 +556,7 @@ bool DebuggerClient::reconnect() {
if (port) {
info("Re-connecting to %s:%d...", host.c_str(), port);
Socket *sock = new Socket(socket(PF_INET, SOCK_STREAM, 0), PF_INET,
String(host), port);
host.c_str(), port);
sock->unregister();
Object obj(sock);
if (f_socket_connect(sock, String(host), port)) {
+6 -6
Ver Arquivo
@@ -400,7 +400,7 @@ static Variant dom_canonicalization(xmlNodePtr nodep, CStrRef file,
}
}
if (mode == 1) {
buf = xmlOutputBufferCreateFilename(file, NULL, 0);
buf = xmlOutputBufferCreateFilename(file.c_str(), nullptr, 0);
} else {
buf = xmlAllocOutputBuffer(NULL);
}
@@ -1499,8 +1499,8 @@ struct PropertyAccessor {
class PropertyAccessorMap : private hphp_const_char_imap<PropertyAccessor*> {
public:
PropertyAccessorMap(PropertyAccessor* props,
PropertyAccessorMap *base = NULL) {
explicit PropertyAccessorMap(PropertyAccessor* props,
PropertyAccessorMap *base = nullptr) {
if (base) {
*this = *base;
}
@@ -5434,17 +5434,17 @@ Variant c_DOMNodeIterator::t_valid() {
///////////////////////////////////////////////////////////////////////////////
// function-style wrappers
#define DOM_GET_OBJ(name) \
#define DOM_GET_OBJ(name) \
c_DOM ##name *pobj = NULL; \
if (obj.isObject()) { \
pobj = obj.toObject().getTyped<c_DOM ##name>(true, true); \
if (pobj == NULL) { \
raise_warning("Expecting dom " #name " object"); \
return uninit_null(); \
return uninit_null(); \
} \
} else { \
raise_warning("Expecting dom objects in parameters"); \
return uninit_null(); \
return uninit_null(); \
}
Variant f_dom_document_create_element(CVarRef obj, CStrRef name,
+1 -1
Ver Arquivo
@@ -1159,7 +1159,7 @@ Array f_fb_crossall_query(CStrRef sql, int max_thread /* = 50 */,
Array ret;
// parameter checking
if (!sql || !*sql) {
if (sql.empty()) {
static const StaticString s_errstr("empty SQL");
ret.set(s_error, s_errstr);
return ret;
+9 -6
Ver Arquivo
@@ -407,7 +407,7 @@ Variant f_file_put_contents(CStrRef filename, CVarRef data,
String value = data.toString();
if (!value.empty()) {
numbytes += value.size();
int written = f->writeImpl(value, value.size());
int written = f->writeImpl(value.data(), value.size());
if (written != value.size()) {
numbytes = -1;
}
@@ -821,9 +821,9 @@ Variant f_realpath(CStrRef path) {
StaticContentCache::TheFileCache->exists(translated.data(), false)) {
return translated;
}
if (access(translated.data(), F_OK) == 0) {
if (access(translated.c_str(), F_OK) == 0) {
char resolved_path[PATH_MAX];
if (!realpath(translated, resolved_path)) {
if (!realpath(translated.c_str(), resolved_path)) {
return false;
}
return String(resolved_path, CopyString);
@@ -891,7 +891,8 @@ Variant f_pathinfo(CStrRef path, int opt /* = 15 */) {
Variant f_disk_free_space(CStrRef directory) {
struct statfs buf;
CHECK_SYSTEM(statfs(File::TranslatePath(directory), &buf));
String translated = File::TranslatePath(directory);
CHECK_SYSTEM(statfs(translated.c_str(), &buf));
return (double)buf.f_bsize * (double)buf.f_bavail;
}
@@ -901,7 +902,8 @@ Variant f_diskfreespace(CStrRef directory) {
Variant f_disk_total_space(CStrRef directory) {
struct statfs buf;
CHECK_SYSTEM(statfs(File::TranslatePath(directory), &buf));
String translated = File::TranslatePath(directory);
CHECK_SYSTEM(statfs(translated.c_str(), &buf));
return (double)buf.f_bsize * (double)buf.f_blocks;
}
@@ -909,7 +911,8 @@ Variant f_disk_total_space(CStrRef directory) {
// system wrappers
bool f_chmod(CStrRef filename, int64_t mode) {
CHECK_SYSTEM(chmod(File::TranslatePath(filename).data(), mode));
String translated = File::TranslatePath(filename);
CHECK_SYSTEM(chmod(translated.c_str(), mode));
return true;
}
+2 -2
Ver Arquivo
@@ -381,7 +381,7 @@ String f_hash_final(CObjRef context, bool raw_output /* = false */) {
int64_t f_furchash_hphp_ext(CStrRef key, int len, int nPart) {
len = std::max(std::min(len, key.size()), 0);
return furc_hash(key, len, nPart);
return furc_hash(key.data(), len, nPart);
}
bool f_furchash_hphp_ext_supported() {
@@ -390,7 +390,7 @@ bool f_furchash_hphp_ext_supported() {
int64_t f_hphp_murmurhash(CStrRef key, int len, int seed) {
len = std::max(std::min(len, key.size()), 0);
return murmur_hash_64A(key, len, seed);
return murmur_hash_64A(key.data(), len, seed);
}
///////////////////////////////////////////////////////////////////////////////
+5 -5
Ver Arquivo
@@ -1827,11 +1827,11 @@ String f_ob_iconv_handler(CStrRef contents, int status) {
char *out_buffer;
size_t out_len;
php_iconv_err_t err =
php_iconv_string(contents.data(), contents.size(),
&out_buffer, &out_len,
ICONVG(output_encoding), ICONVG(internal_encoding));
_php_iconv_show_error(err, ICONVG(output_encoding),
ICONVG(internal_encoding));
php_iconv_string(contents.data(), contents.size(), &out_buffer, &out_len,
ICONVG(output_encoding).c_str(),
ICONVG(internal_encoding).c_str());
_php_iconv_show_error(err, ICONVG(output_encoding).c_str(),
ICONVG(internal_encoding).c_str());
if (out_buffer != NULL) {
g_context->setContentType(mimetype, ICONVG(output_encoding));
return String(out_buffer, out_len, AttachString);
+1 -1
Ver Arquivo
@@ -546,7 +546,7 @@ Array c_UConverter::ti_getaliases(const char* cls , CStrRef encoding) {
Array ret = Array::Create();
for(i = 0; i < count; ++i) {
error = U_ZERO_ERROR;
const char *alias = ucnv_getAlias(encoding, i, &error);
const char *alias = ucnv_getAlias(encoding.c_str(), i, &error);
if (U_FAILURE(error)) {
THROW_UFAILURE(ucnv_getAlias, error, s_intl_error->m_error);
return uninit_null();
+3 -3
Ver Arquivo
@@ -57,10 +57,10 @@ int64_t f_ftok(CStrRef pathname, CStrRef proj) {
}
if (proj.length() != 1) {
raise_warning("Project identifier has to be one character int64: %s",
(const char *)proj);
proj.c_str());
return -1;
}
return ftok((const char *)pathname, (int)(*((const char *)proj)));
return ftok(pathname.c_str(), (int)proj[0]);
}
///////////////////////////////////////////////////////////////////////////////
@@ -193,7 +193,7 @@ bool f_msg_send(CObjRef queue, int64_t msgtype, CVarRef message,
buffer = (struct msgbuf *)calloc(len + sizeof(struct msgbuf), 1);
ScopedMem deleter(buffer);
MSGBUF_MTYPE(buffer) = msgtype;
memcpy(MSGBUF_MTEXT(buffer), (const char *)data, len + 1);
memcpy(MSGBUF_MTEXT(buffer), data.c_str(), len + 1);
int result = msgsnd(q->id, buffer, len, blocking ? 0 : IPC_NOWAIT);
if (result < 0) {
+3 -3
Ver Arquivo
@@ -42,7 +42,7 @@ StaticString
static RecursiveIteratorIterator *
get_recursiveiteratoriterator(CObjRef obj) {
if (!obj->instanceof(SystemLib::s_RecursiveIteratorIteratorClass)) {
throw InvalidObjectTypeException(obj->o_getClassName());
throw InvalidObjectTypeException(obj->o_getClassName().c_str());
}
CObjRef rsrc = obj->o_get("rsrc", true, "RecursiveIteratorIterator");
return rsrc.getTyped<RecursiveIteratorIterator>();
@@ -51,7 +51,7 @@ get_recursiveiteratoriterator(CObjRef obj) {
static RecursiveDirectoryIterator *
get_recursivedirectoryiterator(CObjRef obj) {
if (!obj->instanceof(SystemLib::s_RecursiveDirectoryIteratorClass)) {
throw InvalidObjectTypeException(obj->o_getClassName());
throw InvalidObjectTypeException(obj->o_getClassName().c_str());
}
// SplFileInfo as context -- rsrc is a private property
CObjRef rsrc = obj->o_get("rsrc", true, "SplFileInfo");
@@ -61,7 +61,7 @@ get_recursivedirectoryiterator(CObjRef obj) {
static DirectoryIterator *
get_directoryiterator(CObjRef obj) {
if (!obj->instanceof(SystemLib::s_DirectoryIteratorClass)) {
throw InvalidObjectTypeException(obj->o_getClassName());
throw InvalidObjectTypeException(obj->o_getClassName().c_str());
}
// SplFileInfo as context -- rsrc is a private property
CObjRef rsrc = obj->o_get("rsrc", true, "SplFileInfo");
+1 -1
Ver Arquivo
@@ -510,7 +510,7 @@ static void get_attributes(Array &ret, LDAP *ldap,
ldap_value_free_len(ldap_value);
String sAttribute(attribute, CopyString);
ret.set(to_lower ? Util::toLower(attribute) : sAttribute, tmp);
ret.set(to_lower ? String(Util::toLower(attribute)) : sAttribute, tmp);
ret.set(num_attrib, sAttribute);
num_attrib++;
+1 -1
Ver Arquivo
@@ -183,7 +183,7 @@ Array f_mailparse_msg_get_part_data(CObjRef mimemail) {
}
Variant f_mailparse_msg_get_part(CObjRef mimemail, CStrRef mimesection) {
Object part = mimemail.getTyped<MimePart>()->findByName(mimesection);
Object part = mimemail.getTyped<MimePart>()->findByName(mimesection.c_str());
if (part.isNull()) {
raise_warning("cannot find section %s in message", mimesection.data());
return false;
+10 -10
Ver Arquivo
@@ -31,7 +31,7 @@ IMPLEMENT_DEFAULT_EXTENSION(mcrypt);
class MCrypt : public SweepableResourceData {
public:
MCrypt(MCRYPT td) : m_td(td), m_init(false) {
explicit MCrypt(MCRYPT td) : m_td(td), m_init(false) {
}
~MCrypt() {
@@ -241,7 +241,7 @@ bool f_mcrypt_module_close(CObjRef td) {
}
Array f_mcrypt_list_algorithms(CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
int count = 0;
char **modules = mcrypt_list_algorithms((char*)dir.data(), &count);
@@ -257,7 +257,7 @@ Array f_mcrypt_list_algorithms(CStrRef lib_dir /* = null_string */) {
}
Array f_mcrypt_list_modes(CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(modes_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(modes_dir)) : lib_dir;
int count = 0;
char **modules = mcrypt_list_modes((char*)dir.data(), &count);
@@ -274,21 +274,21 @@ Array f_mcrypt_list_modes(CStrRef lib_dir /* = null_string */) {
int64_t f_mcrypt_module_get_algo_block_size(CStrRef algorithm,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
return mcrypt_module_get_algo_block_size((char*)algorithm.data(),
(char*)dir.data());
}
int64_t f_mcrypt_module_get_algo_key_size(CStrRef algorithm,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
return mcrypt_module_get_algo_key_size((char*)algorithm.data(),
(char*)dir.data());
}
Array f_mcrypt_module_get_supported_key_sizes(CStrRef algorithm,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
int count = 0;
int *key_sizes = mcrypt_module_get_algo_supported_key_sizes
@@ -304,28 +304,28 @@ Array f_mcrypt_module_get_supported_key_sizes(CStrRef algorithm,
bool f_mcrypt_module_is_block_algorithm_mode(CStrRef mode,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(modes_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(modes_dir)) : lib_dir;
return mcrypt_module_is_block_algorithm_mode((char*)mode.data(),
(char*)dir.data()) == 1;
}
bool f_mcrypt_module_is_block_algorithm(CStrRef algorithm,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
return mcrypt_module_is_block_algorithm((char*)algorithm.data(),
(char*)dir.data()) == 1;
}
bool f_mcrypt_module_is_block_mode(CStrRef mode,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(modes_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(modes_dir)) : lib_dir;
return mcrypt_module_is_block_mode((char*)mode.data(),
(char*)dir.data()) == 1;
}
bool f_mcrypt_module_self_test(CStrRef algorithm,
CStrRef lib_dir /* = null_string */) {
String dir = lib_dir.empty() ? MCG(algorithms_dir) : lib_dir;
String dir = lib_dir.empty() ? String(MCG(algorithms_dir)) : lib_dir;
return mcrypt_module_self_test((char*)algorithm.data(),
(char*)dir.data()) == 0;
}
+2 -2
Ver Arquivo
@@ -169,7 +169,7 @@ namespace {
class MemcachedResultWrapper {
public:
memcached_result_st value;
MemcachedResultWrapper(memcached_st *memcached) {
explicit MemcachedResultWrapper(memcached_st *memcached) {
memcached_result_create(memcached, &value);
}
~MemcachedResultWrapper() {
@@ -630,7 +630,7 @@ Variant c_Memcached::t_getserverbykey(CStrRef server_key) {
memcached_return_t error;
const memcached_server_st *server = memcached_server_by_key(
&m_impl->memcached, server_key, server_key.length(), &error);
&m_impl->memcached, server_key.c_str(), server_key.size(), &error);
if (!server) {
handleError(error);
return false;
+2 -2
Ver Arquivo
@@ -282,10 +282,10 @@ String f_uniqid(CStrRef prefix /* = null_string */,
char uniqid[256];
if (more_entropy) {
snprintf(uniqid, sizeof(uniqid), "%s%08x%05x%.8F",
(const char *)prefix, sec, usec, math_combined_lcg() * 10);
prefix.c_str(), sec, usec, math_combined_lcg() * 10);
} else {
snprintf(uniqid, sizeof(uniqid), "%s%08x%05x",
(const char *)prefix, sec, usec);
prefix.c_str(), sec, usec);
}
return String(uniqid, CopyString);
}
+2 -1
Ver Arquivo
@@ -561,7 +561,8 @@ static Variant php_mysql_do_connect(String server, String username,
}
if (mySQL == NULL) {
mySQL = new MySQL(host, port, username, password, database);
mySQL = new MySQL(host.c_str(), port, username.c_str(), password.c_str(),
database.c_str());
ret = mySQL;
if (async) {
#ifdef FACEBOOK
+4 -4
Ver Arquivo
@@ -1379,7 +1379,7 @@ bool f_openssl_pkcs7_encrypt(CStrRef infilename, CStrRef outfilename,
raise_warning("error opening the file, %s", infilename.data());
goto clean_exit;
}
outfile = BIO_new_file(outfilename, "w");
outfile = BIO_new_file(outfilename.data(), "w");
if (outfile == NULL) {
raise_warning("error opening the file, %s", outfilename.data());
goto clean_exit;
@@ -2352,7 +2352,7 @@ static String php_openssl_validate_iv(String piv, int iv_required_len) {
Variant f_openssl_encrypt(CStrRef data, CStrRef method, CStrRef password,
int options /* = 0 */,
CStrRef iv /* = null_string */) {
const EVP_CIPHER *cipher_type = EVP_get_cipherbyname(method);
const EVP_CIPHER *cipher_type = EVP_get_cipherbyname(method.c_str());
if (!cipher_type) {
raise_warning("Unknown cipher algorithm");
return false;
@@ -2426,7 +2426,7 @@ Variant f_openssl_encrypt(CStrRef data, CStrRef method, CStrRef password,
Variant f_openssl_decrypt(CStrRef data, CStrRef method, CStrRef password,
int options /* = 0 */,
CStrRef iv /* = null_string */) {
const EVP_CIPHER *cipher_type = EVP_get_cipherbyname(method);
const EVP_CIPHER *cipher_type = EVP_get_cipherbyname(method.c_str());
if (!cipher_type) {
raise_warning("Unknown cipher algorithm");
return false;
@@ -2489,7 +2489,7 @@ Variant f_openssl_decrypt(CStrRef data, CStrRef method, CStrRef password,
Variant f_openssl_digest(CStrRef data, CStrRef method,
bool raw_output /* = false */) {
const EVP_MD *mdtype = EVP_get_digestbyname(method);
const EVP_MD *mdtype = EVP_get_digestbyname(method.c_str());
if (!mdtype) {
raise_warning("Unknown signature algorithm");
+1 -1
Ver Arquivo
@@ -107,7 +107,7 @@ Array f_hphp_get_iostatus() {
return ServerStats::GetThreadIOStatuses();
}
void f_hphp_set_iostatus_address(CStrRef name) {
return ServerStats::SetThreadIOStatusAddress(name);
return ServerStats::SetThreadIOStatusAddress(name.c_str());
}
+2 -1
Ver Arquivo
@@ -2548,7 +2548,8 @@ rewrite:
String name(plc->pos, plc->len, AttachLiteral);
/* check if bound parameter is already available */
if (!strcmp(name, "?") || !stmt->bound_param_map.exists(name)) {
if (!strcmp(name.c_str(), "?") ||
!stmt->bound_param_map.exists(name.c_str())) {
idxbuf.printf(tmpl, bind_no++);
} else {
idxbuf.clear();
+8 -8
Ver Arquivo
@@ -138,7 +138,7 @@ void f_pcntl_exec(CStrRef path, CArrRef args /* = null_array */,
// build environment pair list
std::vector<String> senvs; // holding those char *
char **envp = build_envp(envs, senvs);
if (execve(path, argv, envp) == -1) {
if (execve(path.c_str(), argv, envp) == -1) {
raise_warning("Error has occured: (errno %d) %s",
errno, Util::safe_strerror(errno).c_str());
}
@@ -418,7 +418,7 @@ private:
String f_shell_exec(CStrRef cmd) {
ShellExecContext ctx;
FILE *fp = ctx.exec(cmd);
FILE *fp = ctx.exec(cmd.c_str());
if (!fp) return "";
StringBuffer sbuf;
sbuf.read(fp);
@@ -428,7 +428,7 @@ String f_shell_exec(CStrRef cmd) {
String f_exec(CStrRef command, VRefParam output /* = null */,
VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
FILE *fp = ctx.exec(command.c_str());
if (!fp) return "";
StringBuffer sbuf;
sbuf.read(fp);
@@ -457,7 +457,7 @@ String f_exec(CStrRef command, VRefParam output /* = null */,
void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
FILE *fp = ctx.exec(command.c_str());
if (!fp) return;
char buffer[1024];
@@ -475,7 +475,7 @@ void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
String f_system(CStrRef command, VRefParam return_var /* = null */) {
ShellExecContext ctx;
FILE *fp = ctx.exec(command);
FILE *fp = ctx.exec(command.c_str());
if (!fp) return "";
StringBuffer sbuf;
if (fp) {
@@ -612,7 +612,7 @@ public:
bool openFile(CStrRef zfile, CStrRef zmode) {
mode = DESC_FILE;
/* try a wrapper */
FILE *file = fopen(zfile, zmode);
FILE *file = fopen(zfile.c_str(), zmode.c_str());
if (!file) {
raise_warning("Unable to open specified file: %s (mode %s)",
zfile.data(), zmode.data());
@@ -894,7 +894,7 @@ bool f_proc_nice(int increment) {
String f_escapeshellarg(CStrRef arg) {
if (!arg.empty()) {
char *ret = string_escape_shell_arg(arg);
char *ret = string_escape_shell_arg(arg.c_str());
return String(ret, AttachString);
}
return arg;
@@ -902,7 +902,7 @@ String f_escapeshellarg(CStrRef arg) {
String f_escapeshellcmd(CStrRef command) {
if (!command.empty()) {
char *ret = string_escape_shell_cmd(command);
char *ret = string_escape_shell_cmd(command.c_str());
return String(ret, AttachString);
}
return command;
+11 -11
Ver Arquivo
@@ -68,7 +68,7 @@ private:
class SoapServerScope : public SoapScope {
public:
SoapServerScope(c_SoapServer *server) {
explicit SoapServerScope(c_SoapServer *server) {
USE_SOAP_GLOBAL;
SOAP_GLOBAL(error_code) = "Server";
SOAP_GLOBAL(error_object) = Object(server);
@@ -77,7 +77,7 @@ public:
class SoapClientScope : public SoapScope {
public:
SoapClientScope(c_SoapClient *client) {
explicit SoapClientScope(c_SoapClient *client) {
USE_SOAP_GLOBAL;
SOAP_GLOBAL(error_code) = "Client";
SOAP_GLOBAL(error_object) = Object(client);
@@ -86,7 +86,7 @@ public:
class SoapServiceScope {
public:
SoapServiceScope(c_SoapServer *server) {
explicit SoapServiceScope(c_SoapServer *server) {
save();
USE_SOAP_GLOBAL;
SOAP_GLOBAL(soap_version) = server->m_version;
@@ -97,7 +97,7 @@ public:
SOAP_GLOBAL(features) = server->m_features;
}
SoapServiceScope(c_SoapClient *client) {
explicit SoapServiceScope(c_SoapClient *client) {
save();
USE_SOAP_GLOBAL;
SOAP_GLOBAL(soap_version) = client->m_soap_version;
@@ -1009,7 +1009,7 @@ static sdlFunctionPtr deserialize_function_call
key += (char*)hdr_func->ns->href;
key += ':';
}
key += h->function_name;
key += (std::string)h->function_name;
sdlSoapBindingFunctionHeaderMap::iterator iter =
fnb->input.headers.find(key);
if (iter != fnb->input.headers.end()) {
@@ -1132,7 +1132,7 @@ static int serialize_response_call2(xmlNodePtr body, sdlFunction *function,
param_index = key.toInt64();
}
parameter = get_param(function, param_name, param_index, true);
parameter = get_param(function, param_name.c_str(), param_index, true);
if (style == SOAP_RPC) {
param = serialize_parameter(parameter, data, i, param_name.data(),
use, method);
@@ -2131,9 +2131,9 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
int soap_version = 0;
sdlFunctionPtr function;
try {
function = deserialize_function_call
(m_sdl, doc_request, m_actor, function_name, params, soap_version,
m_soap_headers);
function = deserialize_function_call(m_sdl, doc_request, m_actor.c_str(),
function_name, params, soap_version,
m_soap_headers);
} catch (Exception &e) {
xmlFreeDoc(doc_request);
send_soap_server_fault(function, e, NULL);
@@ -2560,11 +2560,11 @@ Variant c_SoapClient::t___soapcall(CStrRef name, CArrRef args,
action += '#';
action += name.data();
} else {
action += soap_action;
action += (std::string) soap_action;
}
Variant response;
try {
ret = do_request(this, request, location, action.c_str(),
ret = do_request(this, request, location.c_str(), action.c_str(),
m_soap_version, 0, response);
} catch (Exception &e) {
xmlFreeDoc(request);
+5 -5
Ver Arquivo
@@ -773,7 +773,7 @@ Variant f_socket_sendto(CObjRef socket, CStrRef buf, int len, int flags,
s_un.sun_family = AF_UNIX;
snprintf(s_un.sun_path, 108, "%s", addr.data());
retval = sendto(sock->fd(), buf, len, flags,
retval = sendto(sock->fd(), buf.data(), len, flags,
(struct sockaddr *)&s_un, SUN_LEN(&s_un));
}
break;
@@ -783,11 +783,11 @@ Variant f_socket_sendto(CObjRef socket, CStrRef buf, int len, int flags,
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons((unsigned short) port);
if (!php_set_inet_addr(&sin, addr, sock)) {
if (!php_set_inet_addr(&sin, addr.c_str(), sock)) {
return false;
}
retval = sendto(sock->fd(), buf, len, flags,
retval = sendto(sock->fd(), buf.data(), len, flags,
(struct sockaddr *)&sin, sizeof(sin));
}
break;
@@ -798,11 +798,11 @@ Variant f_socket_sendto(CObjRef socket, CStrRef buf, int len, int flags,
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons((unsigned short) port);
if (!php_set_inet6_addr(&sin6, addr, sock)) {
if (!php_set_inet6_addr(&sin6, addr.c_str(), sock)) {
return false;
}
retval = sendto(sock->fd(), buf, len, flags,
retval = sendto(sock->fd(), buf.data(), len, flags,
(struct sockaddr *)&sin6, sizeof(sin6));
}
break;
+2 -2
Ver Arquivo
@@ -34,7 +34,7 @@ IMPLEMENT_OBJECT_ALLOCATION(SplFileObject)
static SplFileInfo *get_splfileinfo(CObjRef obj) {
if (!obj->o_instanceof("SplFileInfo")) {
throw InvalidObjectTypeException(obj->o_getClassName());
throw InvalidObjectTypeException(obj->o_getClassName().c_str());
}
CObjRef rsrc = obj->o_get("rsrc", true, "SplFileInfo");
return rsrc.getTyped<SplFileInfo>();
@@ -42,7 +42,7 @@ static SplFileInfo *get_splfileinfo(CObjRef obj) {
static SplFileObject *get_splfileobject(CObjRef obj) {
if (!obj->o_instanceof("SplFileObject")) {
throw InvalidObjectTypeException(obj->o_getClassName());
throw InvalidObjectTypeException(obj->o_getClassName().c_str());
}
// "SplFileInfo" as context -- rsrc is a private property
CObjRef rsrc = obj->o_get("rsrc", true, "SplFileInfo");
+36 -26
Ver Arquivo
@@ -372,7 +372,7 @@ Variant f_vsprintf(CStrRef format, CArrRef args) {
Variant f_sscanf(int _argc, CStrRef str, CStrRef format, CArrRef _argv /* = null_array */) {
Variant ret;
int result;
result = string_sscanf(str, format, _argv.size(), ret);
result = string_sscanf(str.c_str(), format.c_str(), _argv.size(), ret);
if (SCAN_ERROR_WRONG_PARAM_COUNT == result) return uninit_null();
if (_argv.empty()) return ret;
@@ -391,11 +391,13 @@ String f_chr(int64_t ascii) {
char buf[2]; buf[0] = ascii; buf[1] = 0;
return String(buf, 1, CopyString);
}
int64_t f_ord(CStrRef str) {
return (int64_t)(unsigned char)(*((const char *)str));
return (int64_t)(unsigned char)str[0];
}
Variant f_money_format(CStrRef format, double number) {
String s = StringUtil::MoneyFormat(format, number);
String s = StringUtil::MoneyFormat(format.c_str(), number);
if (s.isNull()) return false;
return s;
}
@@ -406,7 +408,7 @@ String f_number_format(double number, int decimals /* = 0 */,
char ch_dec_point = '.';
if (!dec_point.isNull()) {
if (dec_point.size() >= 1) {
ch_dec_point = ((const char *)dec_point)[0];
ch_dec_point = dec_point[0];
} else {
ch_dec_point = 0;
}
@@ -414,7 +416,7 @@ String f_number_format(double number, int decimals /* = 0 */,
char ch_thousands_sep = ',';
if (!thousands_sep.isNull()) {
if (thousands_sep.size() >= 1) {
ch_thousands_sep = ((const char *)thousands_sep)[0];
ch_thousands_sep = thousands_sep[0];
} else {
ch_thousands_sep = 0;
}
@@ -439,9 +441,11 @@ int64_t f_strnatcmp(CStrRef str1, CStrRef str2) {
return string_natural_cmp(str1.data(), str1.size(), str2.data(), str2.size(),
false);
}
int64_t f_strcasecmp(CStrRef str1, CStrRef str2) {
return bstrcasecmp(str1.data(), str1.size(), str2.data(), str2.size());
}
Variant f_strncasecmp(CStrRef str1, CStrRef str2, int len) {
if (len < 0) {
raise_warning("Length must be greater than or equal to 0");
@@ -450,12 +454,14 @@ Variant f_strncasecmp(CStrRef str1, CStrRef str2, int len) {
return string_strncasecmp(str1.data(), str1.size(), str2.data(), str2.size(),
len);
}
int64_t f_strnatcasecmp(CStrRef str1, CStrRef str2) {
return string_natural_cmp(str1.data(), str1.size(), str2.data(), str2.size(),
true);
}
int64_t f_strcoll(CStrRef str1, CStrRef str2) {
return strcoll(str1, str2);
return strcoll(str1.c_str(), str2.c_str());
}
Variant f_substr_compare(CStrRef main_str, CStrRef str, int offset,
@@ -478,9 +484,9 @@ Variant f_substr_compare(CStrRef main_str, CStrRef str, int offset,
const char *s1 = main_str.data();
if (case_insensitivity) {
return bstrcasecmp(s1 + offset, cmp_len, str, cmp_len);
return bstrcasecmp(s1 + offset, cmp_len, str.data(), cmp_len);
}
return string_ncmp(s1 + offset, str, cmp_len);
return string_ncmp(s1 + offset, str.data(), cmp_len);
}
Variant f_strrchr(CStrRef haystack, CVarRef needle) {
@@ -517,7 +523,7 @@ Variant f_strpbrk(CStrRef haystack, CStrRef char_list) {
throw_invalid_argument("char_list: (empty)");
return false;
}
const char *p = strpbrk(haystack, char_list);
const char *p = strpbrk(haystack.c_str(), char_list.c_str());
if (p) {
return String(p, CopyString);
}
@@ -624,8 +630,8 @@ Variant f_substr_count(CStrRef haystack, CStrRef needle, int offset /* = 0 */,
Variant f_strspn(CStrRef str1, CStrRef str2, int start /* = 0 */,
int length /* = 0x7FFFFFFF */) {
const char *s1 = str1;
const char *s2 = str2;
const char *s1 = str1.data();
const char *s2 = str2.data();
int s1_len = str1.size();
int s2_len = str2.size();
@@ -643,8 +649,8 @@ Variant f_strspn(CStrRef str1, CStrRef str2, int start /* = 0 */,
Variant f_strcspn(CStrRef str1, CStrRef str2, int start /* = 0 */,
int length /* = 0x7FFFFFFF */) {
const char *s1 = str1;
const char *s2 = str2;
const char *s1 = str1.data();
const char *s2 = str2.data();
int s1_len = str1.size();
int s2_len = str2.size();
@@ -683,7 +689,7 @@ Variant f_strlen(CVarRef vstr) {
Variant f_count_chars(CStrRef str, int64_t mode /* = 0 */) {
int chars[256];
memset((void*)chars, 0, sizeof(chars));
const unsigned char *buf = (const unsigned char *)(const char *)str;
const unsigned char *buf = (const unsigned char *)str.data();
for (int len = str.size(); len > 0; len--) {
chars[*buf++]++;
}
@@ -763,15 +769,15 @@ Variant f_str_word_count(CStrRef str, int64_t format /* = 0 */,
}
char ch[256];
const char *char_list = charlist;
const char *char_list = charlist.data();
if (*char_list) {
string_charmask(charlist, charlist.size(), ch);
string_charmask(char_list, charlist.size(), ch);
} else {
char_list = NULL;
}
int word_count = 0;
const char *s0 = str;
const char *s0 = str.data();
const char *p = s0;
const char *e = p + str_len;
@@ -818,23 +824,26 @@ Variant f_str_word_count(CStrRef str, int64_t format /* = 0 */,
int64_t f_levenshtein(CStrRef str1, CStrRef str2, int cost_ins /* = 1 */,
int cost_rep /* = 1 */, int cost_del /* = 1 */) {
return string_levenshtein(str1, str1.size(), str2, str2.size(),
return string_levenshtein(str1.data(), str1.size(), str2.data(), str2.size(),
cost_ins, cost_rep, cost_del);
}
int64_t f_similar_text(CStrRef first, CStrRef second,
VRefParam percent /* = uninit_null() */) {
float p;
int ret = string_similar_text(first, first.size(), second, second.size(),
&p);
int ret = string_similar_text(first.data(), first.size(),
second.data(), second.size(), &p);
percent = p;
return ret;
}
Variant f_soundex(CStrRef str) {
if (str.empty()) return false;
return String(string_soundex(str), AttachString);
return String(string_soundex(str.c_str()), AttachString);
}
Variant f_metaphone(CStrRef str, int phones /* = 0 */) {
char *ret = string_metaphone(str, str.size(), 0, 1);
char *ret = string_metaphone(str.data(), str.size(), 0, 1);
if (ret) {
return String(ret, AttachString);
}
@@ -848,6 +857,7 @@ String f_html_entity_decode(CStrRef str, int quote_style /* = k_ENT_COMPAT */,
return StringUtil::HtmlDecode(str, (StringUtil::QuoteStyle)quote_style,
scharset, true);
}
String f_htmlentities(CStrRef str, int quote_style /* = k_ENT_COMPAT */,
CStrRef charset /* = "ISO-8859-1" */,
bool double_encode /* = true */) {
@@ -901,7 +911,7 @@ int64_t f_crc32(CStrRef str) {
return (uint32_t)StringUtil::CRC32(str);
}
String f_crypt(CStrRef str, CStrRef salt /* = "" */) {
return StringUtil::Crypt(str, salt);
return StringUtil::Crypt(str, salt.c_str());
}
String f_md5(CStrRef str, bool raw_output /* = false */) {
return StringUtil::MD5(str, raw_output);
@@ -992,7 +1002,7 @@ Variant f_setlocale(int _argc, int category, CVarRef locale, CArrRef _argv /* =
slocale = argv[i].toString();
}
const char *loc = slocale;
const char *loc = slocale.c_str();
if (slocale.size() >= 255) {
throw_invalid_argument("locale name is too long: %s", loc);
return false;
@@ -1082,8 +1092,8 @@ String f_nl_langinfo(int item) {
}
String f_convert_cyr_string(CStrRef str, CStrRef from, CStrRef to) {
char ch_from = ((const char *)from)[0];
char ch_to = ((const char *)to)[0];
char ch_from = from[0];
char ch_to = to[0];
char *ret = string_convert_cyrillic_string(str.data(), str.size(),
ch_from, ch_to);
return String(ret, str.size(), AttachString);
+4 -4
Ver Arquivo
@@ -439,7 +439,7 @@ bool c_XMLReader::t_setschema(CStrRef source) {
}
if (m_ptr) {
int ret = xmlTextReaderSchemaValidate(m_ptr, source);
int ret = xmlTextReaderSchemaValidate(m_ptr, source.c_str());
if (ret == 0) {
return true;
}
@@ -510,8 +510,8 @@ struct PropertyAccessor {
class PropertyAccessorMap : private hphp_const_char_imap<PropertyAccessor*> {
public:
PropertyAccessorMap(PropertyAccessor* props,
PropertyAccessorMap *base = NULL) {
explicit PropertyAccessorMap(PropertyAccessor* props,
PropertyAccessorMap *base = nullptr) {
if (base) {
*this = *base;
}
@@ -554,7 +554,7 @@ static PropertyAccessorMap xmlreader_properties_map
Variant c_XMLReader::t___get(Variant name) {
const xmlChar *retchar = NULL;
int retint = 0;
int retint = 0;
PropertyAccessor *propertyMap = xmlreader_properties_map.get(name);
if (m_ptr) {
+4 -3
Ver Arquivo
@@ -120,8 +120,8 @@ PDOSqliteConnection::~PDOSqliteConnection() {
}
bool PDOSqliteConnection::create(CArrRef options) {
String filename = data_source.substr(0,1) == ":" ? data_source :
File::TranslatePath(data_source);
String filename = data_source.substr(0,1) == ":" ? String(data_source) :
File::TranslatePath(data_source);
if (filename.empty()) {
throw_pdo_exception(0, Array(),
"safe_mode/open_basedir prohibits opening %s",
@@ -467,7 +467,8 @@ bool PDOSqliteStatement::paramHook(PDOBoundParam *param,
if (param->is_param) {
if (param->paramno == -1) {
param->paramno = sqlite3_bind_parameter_index(m_stmt, param->name) - 1;
param->paramno = sqlite3_bind_parameter_index(m_stmt,
param->name.c_str()) - 1;
}
switch (PDO_PARAM_TYPE(param->param_type)) {
+1 -1
Ver Arquivo
@@ -552,7 +552,7 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, CVarRef data, int style,
if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) {
if (!p->m_stype.empty()) {
set_ns_and_type_ex(node, p->m_ns, p->m_stype);
set_ns_and_type_ex(node, p->m_ns.c_str(), p->m_stype.c_str());
}
}
+3 -3
Ver Arquivo
@@ -369,7 +369,7 @@ void binary_serialize(int8_t thrift_typeID, PHPOutputTransport& transport,
case T_UTF16:
case T_STRING: {
String sv = value.toString();
transport.writeString(sv, sv.size());
transport.writeString(sv.data(), sv.size());
} return;
case T_MAP: {
Array ht = value.toArray();
@@ -460,10 +460,10 @@ void f_thrift_protocol_write_binary(CObjRef transportobj, CStrRef method_name,
if (strict_write) {
int32_t version = VERSION_1 | msgtype;
transport.writeI32(version);
transport.writeString(method_name, method_name.size());
transport.writeString(method_name.data(), method_name.size());
transport.writeI32(seqid);
} else {
transport.writeString(method_name, method_name.size());
transport.writeString(method_name.data(), method_name.size());
transport.writeI8(msgtype);
transport.writeI32(seqid);
}
+8 -8
Ver Arquivo
@@ -164,7 +164,7 @@ static void thrift_error(CStrRef what, TError why) {
class CompactWriter {
public:
CompactWriter(CObjRef _transportobj) :
explicit CompactWriter(CObjRef _transportobj) :
transport(_transportobj),
version(VERSION),
state(STATE_CLEAR),
@@ -336,9 +336,9 @@ class CompactWriter {
case T_UTF16:
case T_STRING: {
String s = value.toString();
uint32_t len = s.size();
writeVarint(len);
transport.write(s, len);
auto slice = s.slice();
writeVarint(slice.len);
transport.write(slice.ptr, slice.len);
break;
}
@@ -458,9 +458,9 @@ class CompactWriter {
}
void writeString(CStrRef s) {
uint32_t len = s.size();
writeVarint(len);
transport.write(s, len);
auto slice = s.slice();
writeVarint(slice.len);
transport.write(slice.ptr, slice.len);
}
uint64_t i64ToZigzag(int64_t n) {
@@ -470,7 +470,7 @@ class CompactWriter {
class CompactReader {
public:
CompactReader(CObjRef _transportobj) :
explicit CompactReader(CObjRef _transportobj) :
transport(_transportobj),
version(VERSION),
state(STATE_CLEAR),
+24 -24
Ver Arquivo
@@ -53,7 +53,7 @@ bool TestCppBase::RunTests(const std::string &which) {
class Timer {
public:
Timer(const char *name = nullptr) {
explicit Timer(const char *name = nullptr) {
if (name) m_name = name;
gettimeofday(&m_start, 0);
}
@@ -126,13 +126,13 @@ bool TestCppBase::TestSmartAllocator() {
bool TestCppBase::TestString() {
// constructors
{
VS((const char *)String(15), "15");
VS((const char *)String(-15), "-15");
VS((const char *)String(int64_t(12345678912345678LL)), "12345678912345678");
VS((const char *)String(int64_t(-12345678912345678LL)), "-12345678912345678");
VS((const char *)String(5.603), "5.603");
VS((const char *)String("test"), "test");
VS((const char *)String(String("test")), "test");
VS(String(15).c_str(), "15");
VS(String(-15).c_str(), "-15");
VS(String(int64_t(12345678912345678LL)).c_str(), "12345678912345678");
VS(String(int64_t(-12345678912345678LL)).c_str(), "-12345678912345678");
VS(String(5.603).c_str(), "5.603");
VS(String("test").c_str(), "test");
VS(String(String("test")).c_str(), "test");
}
// informational
@@ -163,27 +163,27 @@ bool TestCppBase::TestString() {
// operators
{
String s;
s = "test1"; VS((const char *)s, "test1");
s = String("test2"); VS((const char *)s, "test2");
s = Variant("test3"); VS((const char *)s, "test3");
s = String("a") + "b"; VS((const char *)s, "ab");
s = String("c") + String("d"); VS((const char *)s, "cd");
s += "efg"; VS((const char *)s, "cdefg");
s += String("hij"); VS((const char *)s, "cdefghij");
s = "test1"; VS(s.c_str(), "test1");
s = String("test2"); VS(s.c_str(), "test2");
s = Variant("test3"); VS(s.c_str(), "test3");
s = String("a") + "b"; VS(s.c_str(), "ab");
s = String("c") + String("d"); VS(s.c_str(), "cd");
s += "efg"; VS(s.c_str(), "cdefg");
s += String("hij"); VS(s.c_str(), "cdefghij");
s = String("\x50\x51") | "\x51\x51"; VS((const char *)s, "\x51\x51");
s = String("\x50\x51") & "\x51\x51"; VS((const char *)s, "\x50\x51");
s = String("\x50\x51") ^ "\x51\x51"; VS((const char *)s, "\x01");
s = "\x50\x51"; s |= "\x51\x51"; VS((const char *)s, "\x51\x51");
s = "\x50\x51"; s &= "\x51\x51"; VS((const char *)s, "\x50\x51");
s = "\x50\x51"; s ^= "\x51\x51"; VS((const char *)s, "\x01");
s = "\x50\x51"; s = ~s; VS((const char *)s, "\xAF\xAE");
s = String("\x50\x51") | "\x51\x51"; VS(s.c_str(), "\x51\x51");
s = String("\x50\x51") & "\x51\x51"; VS(s.c_str(), "\x50\x51");
s = String("\x50\x51") ^ "\x51\x51"; VS(s.c_str(), "\x01");
s = "\x50\x51"; s |= "\x51\x51"; VS(s.c_str(), "\x51\x51");
s = "\x50\x51"; s &= "\x51\x51"; VS(s.c_str(), "\x50\x51");
s = "\x50\x51"; s ^= "\x51\x51"; VS(s.c_str(), "\x01");
s = "\x50\x51"; s = ~s; VS(s.c_str(), "\xAF\xAE");
}
// manipulations
{
String s = StringUtil::ToLower("Test");
VS((const char *)s, "test");
VS(s.c_str(), "test");
}
// conversions
@@ -199,7 +199,7 @@ bool TestCppBase::TestString() {
// offset
{
VS((const char *)String("test").rvalAt(2), "s");
VS(String("test").rvalAt(2).c_str(), "s");
String s = "test";
s.lvalAt(2) = "";
VS(s, String("te\0t", 4, AttachLiteral));
+1 -1
Ver Arquivo
@@ -93,7 +93,7 @@ bool TestDebugger::getResponse(const string& path, string& result,
printf(" Request failed\n");
return false;
}
result = res.toString();
result = (std::string) res.toString();
printf(" Request succeeded, returning '%s'\n", result.c_str());
return true;
}
+1 -1
Ver Arquivo
@@ -36,7 +36,7 @@ public:
const void *data = transport->getPostData(len);
String res = "POST: ";
res += String((char*)data, len, CopyString);
transport->sendString(res);
transport->sendString(res.c_str());
} else {
transport->sendString("OK");
}
+1 -1
Ver Arquivo
@@ -174,7 +174,7 @@ bool TestExtIcu::test_icu_transliterate() {
VERIFY(output_de == "Ich mochte uberzeugend oder ahnliche sein");
// Verify that keeping accents works.
VERIFY(f_icu_transliterate(input_de, false) == (const char*)input_de);
VERIFY(f_icu_transliterate(input_de, false) == input_de.c_str());
// Check an non-Latin language.
String input_zh = String("\xe5\x9b\x9b"
+1 -1
Ver Arquivo
@@ -98,7 +98,7 @@ bool TestServer::VerifyServerResponse(const char *input, const char **outputs,
Variant res = f_curl_exec(c);
if (!same(res, false)) {
actual = res.toString();
actual = (std::string) res.toString();
break;
}
sleep(1); // wait until HTTP server is up and running