From 215b97b7e270641166f3b764e87ebf7bdfb851e0 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 19 Sep 2007 09:15:55 +0000 Subject: [PATCH] NPAL16955: syntax storage in a python supervisiongraph. Fix for already sreened single quote and other meta-symbols. --- src/GraphBase/DataFlowBase_ComputingNode.cxx | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 51b902f..b97d441 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -35,11 +35,32 @@ using namespace std; static string protectQuotes (const string theText) { string aRes (theText); - for (unsigned int pos = 0; pos < aRes.size(); pos+=2) { + unsigned int pos; + + // screen back slash + for (pos = 0; pos < aRes.size(); pos++) { + pos = aRes.find("\\", pos); + if (pos < 0 || pos > aRes.size()) break; + + aRes.insert(pos, "\\"); + pos++; + + // screen symbol after back slash (except single quote, which will be processed below) + if (pos + 1 < aRes.size() && aRes[pos + 1] != '\'') { + aRes.insert(pos + 1, "\\"); + pos++; + } + } + + // screen single quote + for (pos = 0; pos < aRes.size(); pos++) { pos = aRes.find("'", pos); if (pos < 0 || pos > aRes.size()) break; - aRes.replace(pos, 1, "\\\'"); + + aRes.insert(pos, "\\"); + pos++; } + return aRes; } -- 2.39.2