summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-03-08 18:27:54 +0100
committerJose <jose@zeroc.com>2016-03-08 18:27:54 +0100
commit0e7e446475ebb6cf3a9382d54f0a28c04fa6e776 (patch)
tree3370c718e1acab6fc5b7a9a3ffb2db01c56e46bf /cpp/src
parentrenaming man pages for icegriddb/icestormdb (diff)
downloadice-0e7e446475ebb6cf3a9382d54f0a28c04fa6e776.tar.bz2
ice-0e7e446475ebb6cf3a9382d54f0a28c04fa6e776.tar.xz
ice-0e7e446475ebb6cf3a9382d54f0a28c04fa6e776.zip
String literals Windows fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Slice/PythonUtil.cpp14
-rw-r--r--cpp/src/Slice/RubyUtil.cpp14
-rw-r--r--cpp/src/slice2cpp/Gen.cpp88
-rw-r--r--cpp/src/slice2cpp/Makefile2
-rw-r--r--cpp/src/slice2cpp/Makefile.mak2
-rw-r--r--cpp/src/slice2cs/Gen.cpp38
-rw-r--r--cpp/src/slice2java/Gen.cpp22
-rw-r--r--cpp/src/slice2js/Gen.cpp26
-rw-r--r--cpp/src/slice2php/Main.cpp20
9 files changed, 152 insertions, 74 deletions
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index 92f657e8221..38619b6db3e 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -1902,7 +1902,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -1916,16 +1916,16 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
// Convert codepoint to UTF8 bytes and write the escaped bytes
//
_out << s.substr(0, s.size() - 1);
-
+
size_t sz = value[j] == 'U' ? 8 : 4;
string codepoint = value.substr(j + 1, sz);
assert(codepoint.size() == sz);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
+
vector<unsigned int> u32buffer;
- u32buffer.push_back(v);
-
+ u32buffer.push_back(static_cast<unsigned int>(v));
+
vector<unsigned char> u8buffer;
IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
switch(result)
@@ -1942,7 +1942,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
ostringstream s;
for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
{
@@ -1953,7 +1953,7 @@ Slice::Python::CodeVisitor::writeConstantValue(const TypePtr& type, const Syntax
s << static_cast<unsigned int>(*q);
}
_out << s.str();
-
+
i = j + 1 + sz;
}
else
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index fbed4764bbe..796bdd5cd57 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -1493,7 +1493,7 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -1507,15 +1507,15 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr
// Convert codepoint to UTF8 bytes and write the escaped bytes
//
_out << s.substr(0, s.size() - 1);
-
+
size_t sz = value[j] == 'U' ? 8 : 4;
string codepoint = value.substr(j + 1, sz);
assert(codepoint.size() == sz);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
+
vector<unsigned int> u32buffer;
- u32buffer.push_back(v);
-
+ u32buffer.push_back(static_cast<unsigned int>(v));
+
vector<unsigned char> u8buffer;
IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
switch(result)
@@ -1532,7 +1532,7 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
ostringstream s;
for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
{
@@ -1543,7 +1543,7 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr
s << static_cast<unsigned int>(*q);
}
_out << s.str();
-
+
i = j + 1 + sz;
}
else
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index bcb5d5d2475..d93c457bf9e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -13,6 +13,8 @@
#include <Slice/CPlusPlusUtil.h>
#include <IceUtil/Functional.h>
#include <IceUtil/Iterator.h>
+#include <IceUtil/InputUtil.h>
+#include <IceUtil/Unicode.h>
#include <Slice/Checksum.h>
#include <Slice/FileTracker.h>
@@ -76,11 +78,11 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
}
out << "\""; // Opening "
- for(string::const_iterator c = value.begin(); c != value.end(); ++c)
+ for(size_t i = 0; i < value.size();)
{
- if(charSet.find(*c) == charSet.end())
+ if(charSet.find(value[i]) == charSet.end())
{
- unsigned char uc = *c; // char may be signed, so make it positive
+ unsigned char uc = value[i]; // char may be signed, so make it positive
ostringstream s;
s << "\\"; // Print as octal if not in basic source character set
s.width(3);
@@ -91,8 +93,83 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
}
else
{
- switch(*c)
+ switch(value[i])
{
+ case '\\':
+ {
+ string s = "\\";
+ size_t j = i + 1;
+ for(; j < value.size(); ++j)
+ {
+ if(value[j] != '\\')
+ {
+ break;
+ }
+ s += "\\";
+ }
+
+ //
+ // An even number of slash \ will escape the backslash and
+ // the codepoint will be interpreted as its charaters
+ //
+ // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1']
+ // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A')
+ //
+ if(s.size() % 2 != 0 && (value[j] == 'U' || value[j] == 'u'))
+ {
+ //
+ // Convert codepoint to UTF8 bytes and write the escaped bytes
+ //
+ out << s.substr(0, s.size() - 1);
+
+ size_t sz = value[j] == 'U' ? 8 : 4;
+ string codepoint = value.substr(j + 1, sz);
+ assert(codepoint.size() == sz);
+
+ IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
+
+
+ vector<unsigned int> u32buffer;
+ u32buffer.push_back(static_cast<unsigned int>(v));
+
+ vector<unsigned char> u8buffer;
+
+ IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
+ switch(result)
+ {
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
+ case sourceIllegal:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
+ default:
+ {
+ assert(0);
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
+ }
+ }
+
+ ostringstream s;
+ for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
+ {
+ s << "\\";
+ s.fill('0');
+ s.width(3);
+ s << oct;
+ s << static_cast<unsigned int>(*q);
+ }
+ out << s.str();
+
+ i = j + 1 + sz;
+ }
+ else
+ {
+ out << s;
+ i = j;
+ }
+ continue;
+ }
case '"':
{
out << "\\";
@@ -100,8 +177,9 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
}
}
- out << *c; // Print normally if in basic source character set
+ out << value[i]; // Print normally if in basic source character set
}
+ ++i;
}
out << "\""; // Closing "
diff --git a/cpp/src/slice2cpp/Makefile b/cpp/src/slice2cpp/Makefile
index 790ad0aecc3..3af754207f8 100644
--- a/cpp/src/slice2cpp/Makefile
+++ b/cpp/src/slice2cpp/Makefile
@@ -20,7 +20,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir)
include $(top_srcdir)/config/Make.rules
-CPPFLAGS := -I. $(CPPFLAGS)
+CPPFLAGS := -I. -I.. $(CPPFLAGS)
$(NAME): $(OBJS)
rm -f $@
diff --git a/cpp/src/slice2cpp/Makefile.mak b/cpp/src/slice2cpp/Makefile.mak
index 6c0e8c7ccac..6e0efe9a147 100644
--- a/cpp/src/slice2cpp/Makefile.mak
+++ b/cpp/src/slice2cpp/Makefile.mak
@@ -18,7 +18,7 @@ OBJS = .\Gen.obj \
!include $(top_srcdir)/config/Make.rules.mak
-CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+CPPFLAGS = -I. -I.. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
!if "$(GENERATE_PDB)" == "yes"
PDBFLAGS = /pdb:$(NAME:.exe=.pdb)
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index e537f90f3ea..2c2ccf0eb2d 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -68,7 +68,7 @@ writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output&
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
for(vector<unsigned short>::const_iterator c = u16buffer.begin(); c != u16buffer.end(); ++c)
{
out << u16CodePoint(*c);
@@ -1557,7 +1557,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
}
string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
string memberType = typeToString((*d)->type(), (*d)->optional());
-
+
if(ClassDeclPtr::dynamicCast((*d)->type()))
{
_out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
@@ -1566,14 +1566,14 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
{
_out << nl << "_instance." << memberName << " = v;";
}
-
+
if(classMembers.size() > 1)
{
_out << nl << "break;";
}
memberCount++;
}
-
+
for(DataMemberList::const_iterator d = optionalMembers.begin(); d != optionalMembers.end(); ++d)
{
TypePtr paramType = (*d)->type();
@@ -1618,7 +1618,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
memberCount++;
}
}
-
+
if(classMembers.size() > 1)
{
_out << eb;
@@ -2033,7 +2033,7 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
_out << "\""; // Opening "
vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
-
+
for(size_t i = 0; i < value.size();)
{
if(charSet.find(value[i]) == charSet.end())
@@ -2074,7 +2074,7 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -2091,16 +2091,16 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
assert(codepoint.size() == 8);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
-
+
+
//
// Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal
- // and is represented using a Unicode surrogate pair.
+ // and is represented using a Unicode surrogate pair.
//
if(v > 0xFFFF)
{
- unsigned int high = ((v - 0x10000) / 0x400) + 0xD800;
- unsigned int low = ((v - 0x10000) % 0x400) + 0xDC00;
+ unsigned int high = ((static_cast<unsigned int>(v) - 0x10000) / 0x400) + 0xD800;
+ unsigned int low = ((static_cast<unsigned int>(v) - 0x10000) % 0x400) + 0xDC00;
_out << u16CodePoint(high);
_out << u16CodePoint(low);
}
@@ -2108,7 +2108,7 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
{
_out << "\\U" << codepoint;
}
-
+
i = j + 1 + 8;
}
else
@@ -2128,7 +2128,7 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
}
i++;
}
-
+
//
// Write any pedding characters in the utf8 buffer
//
@@ -2137,7 +2137,7 @@ Slice::CsVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePt
writeU8Buffer(u8buffer, _out);
u8buffer.clear();
}
-
+
_out << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
@@ -4098,7 +4098,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
_out << eb;
-
+
if(classMembers.size() != 0)
{
_out << sp;
@@ -4177,7 +4177,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
memberCount++;
}
-
+
for(DataMemberList::const_iterator q = optionalMembers.begin(); q != optionalMembers.end(); ++q)
{
@@ -4223,7 +4223,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
memberCount++;
}
}
-
+
if(classMembers.size() > 1)
{
_out << eb;
@@ -4248,7 +4248,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << nl << "protected override void readImpl__(IceInternal.BasicStream is__)";
_out << sb;
_out << nl << "is__.startReadSlice();";
-
+
int patchIter = 0;
const bool needCustomPatcher = classMembers.size() > 1;
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index eba540f57a6..e0e4df2aba7 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -55,7 +55,7 @@ writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output&
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
for(vector<unsigned short>::const_iterator c = u16buffer.begin(); c != u16buffer.end(); ++c)
{
out << u16CodePoint(*c);
@@ -1902,9 +1902,9 @@ Slice::JavaVisitor::writeConstantValue(Output& out, const TypePtr& type, const S
"_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
out << "\"";
-
+
vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
-
+
for(size_t i = 0; i < value.size();)
{
if(charSet.find(value[i]) == charSet.end())
@@ -1967,7 +1967,7 @@ Slice::JavaVisitor::writeConstantValue(Output& out, const TypePtr& type, const S
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -1985,8 +1985,8 @@ Slice::JavaVisitor::writeConstantValue(Output& out, const TypePtr& type, const S
assert(codepoint.size() == sz);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
-
+
+
//
// Java doesn't like this special characters encoded as universal characters
//
@@ -2008,20 +2008,20 @@ Slice::JavaVisitor::writeConstantValue(Output& out, const TypePtr& type, const S
}
//
// Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal
- // and is represented using a Unicode surrogate pair.
+ // and is represented using a Unicode surrogate pair.
//
else if(v > 0xFFFF)
{
- unsigned int high = ((v - 0x10000) / 0x400) + 0xD800;
- unsigned int low = ((v - 0x10000) % 0x400) + 0xDC00;
+ unsigned int high = ((static_cast<unsigned int>(v) - 0x10000) / 0x400) + 0xD800;
+ unsigned int low = ((static_cast<unsigned int>(v) - 0x10000) % 0x400) + 0xDC00;
out << u16CodePoint(high);
out << u16CodePoint(low);
}
else
{
- out << u16CodePoint(v);
+ out << u16CodePoint(static_cast<unsigned int>(v));
}
-
+
i = j + 1 + sz;
}
else
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp
index 871dd7d47b3..573d0180c67 100644
--- a/cpp/src/slice2js/Gen.cpp
+++ b/cpp/src/slice2js/Gen.cpp
@@ -66,7 +66,7 @@ writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output&
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
for(vector<unsigned short>::const_iterator c = u16buffer.begin(); c != u16buffer.end(); ++c)
{
out << u16CodePoint(*c);
@@ -519,11 +519,11 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
_out << "\""; // Opening "
vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
-
+
for(size_t i = 0; i < value.size();)
{
if(charSet.find(value[i]) == charSet.end())
- {
+ {
if(static_cast<unsigned char>(value[i]) < 128) // Single byte character
{
//
@@ -560,7 +560,7 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -577,24 +577,24 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
assert(codepoint.size() == 8);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
-
+
+
//
// Unicode character in the range U+10000 to U+10FFFF is not permitted in a character literal
- // and is represented using a Unicode surrogate pair.
+ // and is represented using a Unicode surrogate pair.
//
if(v > 0xFFFF)
{
- unsigned int high = ((v - 0x10000) / 0x400) + 0xD800;
- unsigned int low = ((v - 0x10000) % 0x400) + 0xDC00;
+ unsigned int high = ((static_cast<unsigned int>(v) - 0x10000) / 0x400) + 0xD800;
+ unsigned int low = ((static_cast<unsigned int>(v) - 0x10000) % 0x400) + 0xDC00;
_out << u16CodePoint(high);
_out << u16CodePoint(low);
}
else
{
- _out << u16CodePoint(v);
+ _out << u16CodePoint(static_cast<unsigned int>(v));
}
-
+
i = j + 1 + 8;
}
else
@@ -614,7 +614,7 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
}
i++;
}
-
+
//
// Write any pedding characters in the utf8 buffer
//
@@ -623,7 +623,7 @@ Slice::JsVisitor::writeConstantValue(const string& scope, const TypePtr& type, c
writeU8Buffer(u8buffer, _out);
u8buffer.clear();
}
-
+
_out << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index 6de877cec54..9fcac53342c 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -1288,7 +1288,7 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va
}
case '\\':
{
-
+
string s = "\\";
size_t j = i + 1;
for(; j < value.size(); ++j)
@@ -1299,7 +1299,7 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va
}
s += "\\";
}
-
+
//
// An even number of slash \ will escape the backslash and
// the codepoint will be interpreted as its charaters
@@ -1313,19 +1313,19 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va
// Convert codepoint to UTF8 bytes and write the escaped bytes
//
_out << s.substr(0, s.size() - 1);
-
+
size_t sz = value[j] == 'U' ? 8 : 4;
string codepoint = value.substr(j + 1, sz);
assert(codepoint.size() == sz);
IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
-
-
+
+
vector<unsigned int> u32buffer;
- u32buffer.push_back(v);
-
+ u32buffer.push_back(static_cast<unsigned int>(v));
+
vector<unsigned char> u8buffer;
-
+
IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
switch(result)
{
@@ -1341,7 +1341,7 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va
throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
}
}
-
+
ostringstream s;
for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
{
@@ -1352,7 +1352,7 @@ CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTreeBasePtr& va
s << static_cast<unsigned int>(*q);
}
_out << s.str();
-
+
i = j + 1 + sz;
}
else