diff options
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index a3c5ba96964..0c6b3aa6c6d 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1132,26 +1132,24 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" - "_{}[]#()<>%:;,?*+=/^&|~!=,\\\"' \t"; + "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' "; static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end()); H << "\""; // Opening " - ios_base::fmtflags originalFlags = H.flags(); // Save stream state - streamsize originalWidth = H.width(); - ostream::char_type originalFill = H.fill(); - const string val = p->value(); for(string::const_iterator c = val.begin(); c != val.end(); ++c) { if(charSet.find(*c) == charSet.end()) { unsigned char uc = *c; // char may be signed, so make it positive - H << "\\"; // Print as octal if not in basic source character set - H.flags(ios_base::oct); - H.width(3); - H.fill('0'); - H << static_cast<unsigned>(uc); + ostringstream s; + s << "\\"; // Print as octal if not in basic source character set + s.width(3); + s.fill('0'); + s << oct; + s << static_cast<unsigned>(uc); + H << s.str(); } else { @@ -1159,10 +1157,6 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) } } - H.fill(originalFill); // Restore stream state - H.width(originalWidth); - H.flags(originalFlags); - H << "\""; // Closing " } else if(bp && bp->kind() == Builtin::KindLong) @@ -3065,7 +3059,7 @@ Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& pref else if(DictionaryPtr d = DictionaryPtr::dynamicCast(p)) { string scoped = fixKwd(d->scoped()); - stringstream tmp; + ostringstream tmp; tmp << "_i" << level; string iterName = tmp.str(); C << sb; @@ -3079,7 +3073,7 @@ Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& pref else if(SequencePtr s = SequencePtr::dynamicCast(p)) { string scoped = fixKwd(s->scoped()); - stringstream tmp; + ostringstream tmp; tmp << "_i" << level; string iterName = tmp.str(); C << sb; @@ -3118,7 +3112,7 @@ Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefi else if(DictionaryPtr d = DictionaryPtr::dynamicCast(p)) { string scoped = fixKwd(d->scoped()); - stringstream tmp; + ostringstream tmp; tmp << "_i" << level; string iterName = tmp.str(); C << sb; @@ -3132,7 +3126,7 @@ Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefi else if(SequencePtr s = SequencePtr::dynamicCast(p)) { string scoped = fixKwd(s->scoped()); - stringstream tmp; + ostringstream tmp; tmp << "_i" << level; string iterName = tmp.str(); C << sb; |