From 6b6794f5e4efcf84d406a7b2259708bd4aa3c9af Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Thu, 14 Apr 2016 11:02:02 -0700 Subject: ICE-7014 - Slice comments that begin or end with a double quote can cause bogus Python code to be generated --- cpp/src/Slice/PythonUtil.cpp | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 2e714214052..4848dfcbcff 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -2291,14 +2291,10 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const string& for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void @@ -2314,11 +2310,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } if(!members.empty()) @@ -2360,7 +2352,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const DataMemb } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void @@ -2376,11 +2368,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat for(StringVec::const_iterator q = lines.begin(); q != lines.end(); ++q) { - if(q != lines.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } if(!enums.empty()) @@ -2422,7 +2410,7 @@ Slice::Python::CodeVisitor::writeDocstring(const string& comment, const Enumerat } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } bool @@ -2665,11 +2653,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode { for(StringVec::const_iterator q = comment.description.begin(); q != comment.description.end(); ++q) { - if(q != comment.description.begin()) - { - _out << nl; - } - _out << *q; + _out << nl << *q; } } @@ -2798,7 +2782,7 @@ Slice::Python::CodeVisitor::writeDocstring(const OperationPtr& op, DocstringMode _out << nl << r->first << " -- " << r->second; } } - _out << "\"\"\""; + _out << nl << "\"\"\""; } void -- cgit v1.2.3