uppsrc: Visual C++ compiler bug [W]StringBuffer workaround

git-svn-id: svn://ultimatepp.org/upp/trunk@15123 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-09-23 09:37:31 +00:00
parent 313a4b1d90
commit 9293ed2be0
41 changed files with 99 additions and 99 deletions

View file

@ -79,7 +79,7 @@ static WString sReadLn(const wchar *p)
else
wbuf.Cat(*p++);
}
return wbuf;
return WString(wbuf);
}
int LastC(const wchar *b, const wchar *e)

View file

@ -2053,7 +2053,7 @@ WString ToUnicode(const char *src, int l, byte charset)
return FromUtf8(src, l);
WStringBuffer result(l);
ToUnicode(result, src, l, charset);
return result;
return WString(result);
}
WString ToUnicode(const String& src, byte charset)
@ -2068,7 +2068,7 @@ String FromUnicodeBuffer(const wchar *src, int len, byte charset, int defchar)
return ToUtf8(src, len);
StringBuffer result(len);
FromUnicode(result, src, len, charset, defchar);
return result;
return String(result);
}
String FromUnicodeBuffer(const wchar *src)
@ -2094,7 +2094,7 @@ String ToCharset(byte charset, const String& src, byte scharset, int def)
return ToUtf8(ToUnicode(src, scharset));
StringBuffer result(slen);
ConvertCharset(result, charset, src, scharset, slen);
return result;
return String(result);
}
WString InitCaps(const wchar *s)
@ -2125,7 +2125,7 @@ WString InitCaps(const WString& s)
r[i] = ToLower(c);
spc = !IsLeNum(c);
}
return r;
return WString(r);
}
WString ToUpper(const WString& w)
@ -2133,7 +2133,7 @@ WString ToUpper(const WString& w)
int l = w.GetLength();
WStringBuffer r(l);
ToUpper(r, w, l);
return r;
return WString(r);
}
WString ToLower(const WString& w)
@ -2141,7 +2141,7 @@ WString ToLower(const WString& w)
int l = w.GetLength();
WStringBuffer r(l);
ToLower(r, w, l);
return r;
return WString(r);
}
WString ToAscii(const WString& w)
@ -2149,7 +2149,7 @@ WString ToAscii(const WString& w)
int l = w.GetLength();
WStringBuffer r(l);
ToAscii(r, w, l);
return r;
return WString(r);
}
String InitCaps(const char *s, byte charset)
@ -2165,7 +2165,7 @@ String ToUpper(const char *s, byte charset)
int l = (int)strlen(s);
StringBuffer r(l);
ToUpper(r, s, l, charset);
return r;
return String(r);
}
String ToLower(const char *s, byte charset)
@ -2176,7 +2176,7 @@ String ToLower(const char *s, byte charset)
int l = (int)strlen(s);
StringBuffer r(l);
ToLower(r, s, l, charset);
return r;
return String(r);
}
String ToAscii(const char *s, byte charset)
@ -2187,7 +2187,7 @@ String ToAscii(const char *s, byte charset)
int l = (int)strlen(s);
StringBuffer r(l);
ToAscii(r, s, l, charset);
return r;
return String(r);
}
String ToUpper(const String& s, byte charset)
@ -2198,7 +2198,7 @@ String ToUpper(const String& s, byte charset)
int l = s.GetLength();
StringBuffer r(l);
ToUpper(r, s, l, charset);
return r;
return String(r);
}
String ToLower(const String& s, byte charset)
@ -2209,7 +2209,7 @@ String ToLower(const String& s, byte charset)
int l = s.GetLength();
StringBuffer r(l);
ToLower(r, s, l, charset);
return r;
return String(r);
}
String ToAscii(const String& s, byte charset)
@ -2220,7 +2220,7 @@ String ToAscii(const String& s, byte charset)
int l = s.GetLength();
StringBuffer r(l);
ToAscii(r, s, l, charset);
return r;
return String(r);
}
String ToUpperAscii(const String& s, byte charset)
@ -2231,7 +2231,7 @@ String ToUpperAscii(const String& s, byte charset)
int l = s.GetLength();
StringBuffer r(l);
ToAscii(r, s, l, charset);
return r;
return String(r);
}
String ToLowerAscii(const String& s, byte charset)
@ -2242,7 +2242,7 @@ String ToLowerAscii(const String& s, byte charset)
int l = s.GetLength();
StringBuffer r(l);
ToAscii(r, s, l, charset);
return r;
return String(r);
}
bool IsDoubleWidth(int c)

View file

@ -64,7 +64,7 @@ String FormatIntBase(int i, int base, int width, char lpad, int sign, bool upper
if(dwd < width)
memset(o, lpad, pad);
memcpy8(o + pad, p, dwd);
return out;
return String(out);
}
String FormatInt(int i)
@ -382,7 +382,7 @@ String FormatDoubleExp(double d, int digits, int flags, int fill_exp)
}
out.Cat(flags & FD_CAP_E ? 'E' : 'e');
out.Cat(FormatIntDec(exp, fill_exp, '0', flags & FD_SIGN_EXP));
return out;
return String(out);
}
String FormatDate(Date date, const char *format, int language)
@ -577,7 +577,7 @@ String IntFormatter(const Formatting& f)
StringBuffer q;
q.SetLength(1000);
q.SetLength(sprintf(q, '%' + f.format + f.id, (int)f.arg));
return q;
return String(q);
}
String Int64Formatter(const Formatting& f)
@ -585,7 +585,7 @@ String Int64Formatter(const Formatting& f)
StringBuffer q;
q.SetLength(1000);
q.SetLength(sprintf(q, '%' + f.format + f.id, (int64)f.arg));
return q;
return String(q);
}
String IntLowerAlphaFormatter(const Formatting& f)
@ -1148,7 +1148,7 @@ String DeFormat(const char *text)
x.Cat('%');
x.Cat(*text++);
}
return x;
return String(x);
}
}

View file

@ -41,7 +41,7 @@ String Huge::Get() const
Panic("String is too big!");
StringBuffer sb((int)size);
Get(~sb, 0, size);
return sb;
return String(sb);
}
}

View file

@ -124,7 +124,7 @@ String UrlEncode(const char *p, const char *e)
else
out << '%' << hex_digits[(*p >> 4) & 15] << hex_digits[*p & 15];
}
return out;
return String(out);
}
String UrlEncode(const char *s, int len)
@ -156,7 +156,7 @@ String UrlDecode(const char *b, const char *e)
}
else
out.Cat(*p);
return out;
return String(out);
}
String UrlDecode(const char *s, int len)
@ -179,7 +179,7 @@ String QPEncode(const char* s)
r.Cat(s[0]);
len++;
}
else
else
if(s[0] == '\r')
;
else
@ -209,7 +209,7 @@ String QPEncode(const char* s)
}
s++;
}
return r;
return String(r);
}
String QPDecode(const char *s, bool underscore_to_space)
@ -232,7 +232,7 @@ String QPDecode(const char *s, bool underscore_to_space)
else
r.Cat(c);
}
return r;
return String(r);
}
String Base64Encode(const char *_b, const char *_e)
@ -272,7 +272,7 @@ String Base64Encode(const char *_b, const char *_e)
p[2] = encoder[(b[1] << 2) & 0x3C];
p[3] = '=';
}
return s;
return String(s);
}
String Base64Encode(const char *b, int len)
@ -330,7 +330,7 @@ String Base64Decode(const char *b, const char *e)
out.Cat((c[2] << 6) | (c[3] >> 0));
}
}
return out;
return String(out);
}
String Base64Decode(const char *s, int len)

View file

@ -834,7 +834,7 @@ String TcpSocket::Get(int count)
if(!done && IsEof())
return String::GetVoid();
out.SetLength(done);
return out;
return String(out);
}
bool TcpSocket::GetAll(void *buffer, int len)

View file

@ -173,7 +173,7 @@ T Join_(const Vector<T>& im, const T& delim, bool ignoreempty) {
r.Cat(im[i]);
next = true;
}
return r;
return T(r);
}
String Join(const Vector<String>& im, const String& delim, bool ignoreempty) {

View file

@ -176,7 +176,7 @@ String Stream::Get(int size)
StringBuffer b(size);
int n = Get(~b, size);
b.SetCount(n);
return b;
return String(b);
}
String Stream::GetAll(int size)
@ -1218,7 +1218,7 @@ String LoadStream(Stream& in) {
StringBuffer s((int)size);
in.Get(s, (int)size);
if(!in.IsError())
return s;
return String(s);
}
}
return String::GetVoid();

View file

@ -53,7 +53,7 @@ String ToUtf8(const wchar *s, int len)
StringBuffer r;
r.Reserve(len);
FromUtf16_([&](const wchar *, dword code) { ToUtf8_([&](char c) { r.Cat(c); }, code); }, s, len);
return r;
return String(r);
}
int Utf16Len(const dword *s, int len)
@ -76,7 +76,7 @@ WString ToUtf16(const dword *s, int len)
r.Reserve(len);
for(const dword *lim = s + len; s < lim; s++)
ToUtf16_([&](wchar c) { r.Cat(c); }, *s);
return r;
return WString(r);
}
int Utf16Len(const char *s, int len)
@ -95,7 +95,7 @@ WString ToUtf16(const char *s, int len)
{
WStringBuffer r;
FromUtf8_([&](const byte *, dword code) { ToUtf16_([&](wchar c) { r.Cat(c); }, code); }, s, len);
return r;
return WString(r);
}
int Utf32Len(const char *s, int len)
@ -146,7 +146,7 @@ String Utf8ToAscii(const String& src)
while(s < lim)
*t++ = (byte)*s < 128 ? *s++ : ToAscii(FetchUtf8(s, lim));
r.SetLength(int(t - ~r));
return r;
return String(r);
}
String Utf8ToUpperAscii(const String& src)
@ -160,7 +160,7 @@ String Utf8ToUpperAscii(const String& src)
*t++ = (byte)*s <= 'Z' ? *s++ : ToUpperAscii(FetchUtf8(s, lim));
}
r.SetLength(int(t - ~r));
return r;
return String(r);
}
String Utf8ToLowerAscii(const String& src)
@ -173,7 +173,7 @@ String Utf8ToLowerAscii(const String& src)
while(s < lim)
*t++ = ToLowerAscii(FetchUtf8(s, lim));
r.SetLength(int(t - ~r));
return r;
return String(r);
}
};

View file

@ -392,13 +392,13 @@ String HexString(const byte *s, int count, int sep, int sepchr)
for(;;) {
for(int q = 0; q < sep; q++) {
if(i >= count)
return b;
return String(b);
*t++ = itoc[(s[i] & 0xf0) >> 4];
*t++ = itoc[s[i] & 0x0f];
i++;
}
if(i >= count)
return b;
return String(b);
*t++ = sepchr;
}
}
@ -467,7 +467,7 @@ String NormalizeSpaces(const char *s)
else
r.Cat(*s++);
}
return r;
return String(r);
}
String NormalizeSpaces(const char *s, const char *end)
@ -485,7 +485,7 @@ String NormalizeSpaces(const char *s, const char *end)
else
r.Cat(*s++);
}
return r;
return String(r);
}
String CsvString(const String& text)
@ -569,7 +569,7 @@ String CompressLog(const char *s)
else
result.Cat(b, s);
}
return result;
return String(result);
}
int ChNoInvalid(int c)
@ -599,7 +599,7 @@ String ToSystemCharset(const String& src, int cp)
if(q <= 0)
return src;
b.SetCount(q);
return b;
return String(b);
}
String ToSystemCharset(const String& src)

View file

@ -107,7 +107,7 @@ String Bits::ToString() const
StringBuffer ss;
for(int i = GetLast(); i >= 0; i--)
ss << FormatIntHex(bp[i]);
return ss;
return String(ss);
}
void Bits::Serialize(Stream& s)

View file

@ -61,7 +61,7 @@ String AsString(const wchar_t *buffer, int count) { // Convert with code page...
StringBuffer temp(count);
for(char *p = temp, *e = p + count; p < e;)
*p++ = (char)*buffer++;
return temp;
return String(temp);
}
String AsString(const wchar_t *buffer, const wchar_t *end) {
@ -90,7 +90,7 @@ String GetWinRegString(const char *value, const char *path, HKEY base_key, dword
len--;
raw_len.SetLength(len);
RegCloseKey(key);
return raw_len;
return String(raw_len);
}
int GetWinRegInt(const char *value, const char *path, HKEY base_key, dword wow) {

View file

@ -24,7 +24,7 @@ String DeXml(const char *s, byte charset, bool escapelf)
StringBuffer result;
for(; *s; s++)
sDeXmlChar(result, *s, charset, escapelf);
return result;
return String(result);
}
String DeXml(const char *s, const char *end, byte charset, bool escapelf)
@ -34,7 +34,7 @@ String DeXml(const char *s, const char *end, byte charset, bool escapelf)
StringBuffer result;
for(; s < end; s++)
sDeXmlChar(result, *s, charset, escapelf);
return result;
return String(result);
}
String DeXml(const String& s, byte charset, bool escapelf)
@ -51,21 +51,21 @@ String XmlHeader(const char *encoding, const char *version, const char *standalo
if(standalone)
r << " standalone=\"" << standalone << "\"";
r << " ?>\r\n";
return r;
return String(r);
}
String XmlPI(const char *text)
{
StringBuffer r;
r << "<?" << text << "?>\r\n";
return r;
return String(r);
}
String XmlDecl(const char *text)
{
StringBuffer r;
r << "<!" << text << ">\r\n";
return r;
return String(r);
}
String XmlDocType(const char *text)
@ -82,7 +82,7 @@ String XmlComment(const char *text)
{
StringBuffer out;
out << "<!-- " << text << " -->\r\n";
return out;
return String(out);
}
String XmlTag::operator()()
@ -120,7 +120,7 @@ String XmlTag::operator()(const char *text)
else
if(first) {
r << text << end;
return r;
return String(r);
}
first = false;
wasslash = false;
@ -142,7 +142,7 @@ String XmlTag::operator()(const char *text)
if(!first)
r << "\r\n";
r << end;
return r;
return String(r);
}
String XmlTag::Text(const char *text, byte charset)
@ -707,7 +707,7 @@ String XmlParser::ReadTextE()
out.Cat(t);
else if(IsEnd()) {
PassEnd();
return out;
return String(out);
}
else
Skip();

View file

@ -196,7 +196,7 @@ String CParser::ReadIdt() {
result.Cat(*term++);
}
DoSpaces();
return result;
return String(result);
}
bool CParser::IsInt() const {
@ -381,7 +381,7 @@ String CParser::ReadOneString(int delim, bool chkend) {
if(*term == delim) {
term++;
DoSpaces();
return result;
return String(result);
}
else
if(*term == '\\') {
@ -452,16 +452,16 @@ String CParser::ReadOneString(int delim, bool chkend) {
if((byte)*term < ' ' && *term != '\t') {
if(chkend) {
ThrowError("Unterminated string");
return result;
return String(result);
}
if(*term == '\0')
return result;
return String(result);
}
result.Cat(*term++);
}
}
DoSpaces();
return result;
return String(result);
}
String CParser::ReadOneString(bool chkend)
@ -700,7 +700,7 @@ String AsCString(const char *s, const char *lim, int linemax, const char *linepf
s++;
}
t.Cat('\"');
return t;
return String(t);
}
String AsCString(const char *s, int linemax, const char *linepfx, dword flags)

View file

@ -490,7 +490,7 @@ String FastCompress(const void *s, int sz)
int clen = LZ4_compress_default((const char *)s, ~b + sizeof(int), sz, (int)maxsize);
b.SetCount(clen + sizeof(int));
b.Shrink();
return b;
return String(b);
}
String FastCompress(const String& s)
@ -503,7 +503,7 @@ String FastDecompress(const String& data)
int sz = *(int *)~data;
StringBuffer b(sz);
LZ4_decompress_safe(~data + sizeof(int), b, data.GetCount() - sizeof(int), sz);
return b;
return String(b);
}
// following function is used in both plugin/lz4 and plugin/zstd

View file

@ -483,7 +483,7 @@ String Parser::ReadOper(bool& castoper) {
spc = true;
p++;
}
return r;
return String(r);
}
String Parser::Name(String& name, bool& castoper, bool& oper)

View file

@ -100,7 +100,7 @@ String Cpp::Expand(const char *s)
prefix_macro = bid;
else
prefix_macro = String(' ', 1) + bid; // do not want to emit grounding in body
return r;
return String(r);
}
else
if(*s == '\"' || *s == '\'')
@ -147,7 +147,7 @@ String Cpp::Expand(const char *s)
else
r.Cat(*s++);
}
return r;
return String(r);
}
void Cpp::DoFlatInclude(const String& header_path)

View file

@ -130,7 +130,7 @@ String WinMetaFile::Get() const
int size = ::GetEnhMetaFileBits(hemf, 0, 0);
StringBuffer b(size);
::GetEnhMetaFileBits(hemf, size, (BYTE *)~b);
return b;
return String(b);
}
void WinMetaFile::Serialize(Stream& s) {

View file

@ -408,7 +408,7 @@ String sDib(const Value& image)
byte *p = (byte *)~b;
memcpy(p, &header, sizeof(header));
memcpy(p + sizeof(header), ~img, 4 * img.GetLength());
return b;
return String(b);
}
String sImage(const Value& image)

View file

@ -194,7 +194,7 @@ struct Win32ImageMaker : ImageMaker {
RawCat(key, part);
RawCat(key, state);
RawCat(key, sz);
return key;
return String(key);
}
virtual Image Make() const {
Rect rr(sz);

View file

@ -678,7 +678,7 @@ WString TextCtrl::GetW(int64 pos, int size) const
if(size == 0) break;
pos = 0;
}
return r;
return WString(r);
}
String TextCtrl::Get(int64 pos, int size, byte charset) const
@ -707,7 +707,7 @@ String TextCtrl::Get(int64 pos, int size, byte charset) const
if(size == 0) break;
pos = 0;
}
return r;
return String(r);
}
return FromUnicode(GetW(pos, size), charset);
}

View file

@ -17,7 +17,7 @@ WString TextUnicode(const char *s, int n, byte cs, Font font)
*t++ = *s++;
n--;
}
return b;
return WString(b);
}
#endif
return ToUnicode(s, n, cs);

View file

@ -79,7 +79,7 @@ String PackRLE(const RGBA *s, int len)
}
}
}
return r;
return String(r);
}
int Premultiply(RGBA *t, const RGBA *s, int len)

View file

@ -13,7 +13,7 @@ struct scImageMaker : ValueMaker {
s.Cat(typeid(*m).name());
RawCat(s, paintonly);
s.Cat(m->Key());
return s;
return String(s);
}
virtual int Make(Value& object) const {
Image img = m->Make();
@ -140,7 +140,7 @@ struct sCachedRescale : public ImageMaker
RawCat(h, sz.cy);
RawCat(h, img.GetSerialId());
RawCat(h, filter);
return h;
return String(h);
}
virtual Image Make() const {
@ -195,7 +195,7 @@ struct sColorize : public ImageMaker
StringBuffer h;
RawCat(h, color);
RawCat(h, img.GetSerialId());
return h;
return String(h);
}
virtual Image Make() const {

View file

@ -28,7 +28,7 @@ struct sMakeTextGlyph : public ImageMaker
RawCat(h, angle);
RawCat(h, color);
RawCat(h, yy);
return h;
return String(h);
}
virtual Image Make() const {

View file

@ -106,7 +106,7 @@ EscValue::operator WString() const
s.Cat(c);
}
}
return s;
return WString(s);
}
void EscValue::InitString(const WString& s)

View file

@ -280,7 +280,7 @@ String EscValue::ToString(int maxlen, int indent_step, bool hex, int indent) con
r << lambda->arg[i];
}
r << ")\n" << lambda->code;
return r;
return String(r);
case ESC_MAP:
r << ind << "{ ";
int c = min(map->map.GetCount(), 100);

View file

@ -1707,7 +1707,7 @@ WString OracleClob::Read()
out.SetCount(nchars);
Seek(0);
Stream::Get(out, 2 * nchars);
return out;
return WString(out);
}
void OracleClob::Write(const WString& w)

View file

@ -277,7 +277,7 @@ String PdfDraw::PdfString(const char *s)
b.Cat(*s++);
}
b.Cat(')');
return b;
return String(b);
}
void PdfDraw::PutFontHeight(int fi, double ht)

View file

@ -363,7 +363,7 @@ String DefaultHtmlObjectSaver::GetHtml(const RichObject& object, const String& l
PNGEncoder png;
png.SaveFile(AppendFileName(outdir, lname), object.ToImage(psz));
}
return html;
return String(html);
}
String EncodeHtml(const RichText& text, Index<String>& css,

View file

@ -562,7 +562,7 @@ String DeQtf(const char *s) {
r.Cat(*s);
}
}
return r;
return String(r);
}
String DeQtfLf(const char *s) {
@ -580,7 +580,7 @@ String DeQtfLf(const char *s) {
r.Cat("-|");
s++;
}
return r;
return String(r);
}
RichText AsRichText(const RichObject& obj)

View file

@ -141,7 +141,7 @@ String RichObjectImageMaker::Key() const
RawCat(b, object.GetSerialId());
RawCat(b, sz);
RawCat(b, context);
return b;
return String(b);
}
Image RichObjectImageMaker::Make() const

View file

@ -10,7 +10,7 @@ String MakeSqlValue(int code, T& value)
StringBuffer b(sizeof(T) + 1);
b[0] = code;
memcpy(~b + 1, &value, sizeof(T));
return b;
return String(b);
}
template <class T>
@ -327,7 +327,7 @@ String SqlCompile(byte dialect, const String& s)
b.Reserve(s.GetLength() + 100);
const char *q = s;
SqlCompile(q, &b, dialect, NULL);
return b;
return String(b);
}
#ifndef NOAPPSQL
@ -370,7 +370,7 @@ String SqlFormat0(const char *s, int l, int code)
b[0] = code;
memcpy(~b + 1, &l, sizeof(int));
memcpy(~b + 1 + sizeof(int), s, l);
return b;
return String(b);
}
String SqlFormat(const char *s, int l)

View file

@ -48,7 +48,7 @@ String SqlSet::operator()(int at, byte cond) const {
return text;
StringBuffer out;
out << SqlCode(cond, "(")() << text << SqlCode(cond, ")")();
return out;
return String(out);
}
SqlSet& SqlSet::Cat(const SqlVal& val) {

View file

@ -77,7 +77,7 @@ String SqlS::operator()(int at, byte cond) const
return text;
StringBuffer out;
out << SqlCode(cond, "(")() << text << SqlCode(cond, ")")();
return out;
return String(out);
}
void SqlS::Init(const SqlS& a, const char *o, int olen, const SqlS& b, int pr, int prb)

View file

@ -158,7 +158,7 @@ String NaturalDeQtf(const char *s) {
}
s++;
}
return r;
return String(r);
}
static int sSplitT(int c) {

View file

@ -97,7 +97,7 @@ String WriteTopic(const char *title, const RichText& text)
StringBuffer r;
r << "topic " << AsCString(title) << ";\r\n";
r << AsQTF(text, CHARSET_UTF8, QTF_BODY|QTF_ALL_STYLES|QTF_CRLF);
return r;
return String(r);
}
String WriteTopicI(const char *title, const RichText& text)
@ -121,7 +121,7 @@ String WriteTopicI(const char *title, const RichText& text)
r << "\r\n";
}
r << "\r\n\r\n";
return r;
return String(r);
}
void SaveGroupInc(const String& grouppath)

View file

@ -532,7 +532,7 @@ String BrcToC(CParser& binscript, String basedir)
"int " << ident << "_length = " << b_length << ";\n\n";
}
}
return fo;
return String(fo);
}
void CopyFile(const String& d, const String& s, bool brc)

View file

@ -14,7 +14,7 @@ String ReadValue(CParser& p)
while(IsUppValueChar(p.PeekChar()))
v.Cat(p.GetChar());
p.Spaces();
return v;
return String(v);
}
static bool sMatchOr(CParser& p, const Vector<String>& flag);

View file

@ -325,7 +325,7 @@ static WString sSwapCase(const WString& s)
r.SetCount(s.GetCount());
for(int i = 0; i < s.GetCount(); i++)
r[i] = IsUpper(s[i]) ? ToLower(s[i]) : ToUpper(s[i]);
return r;
return WString(r);
}
void Ide::SwapCase()

View file

@ -216,7 +216,7 @@ String WriteIcon(const Vector<Image>& icons, int flags)
Poke32le(entry + OFFSETOF(BMP_ICONDIRENTRY, dwImageOffset), out_offset);
}
}
return out;
return String(out);
}
}