mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Escape "\" char in GDB console output
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
@ -30,12 +31,16 @@ class GDBBytesIO(BytesIO): # pylint: disable=too-few-public-methods
|
|||||||
|
|
||||||
STDOUT = sys.stdout
|
STDOUT = sys.stdout
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def escape(text):
|
||||||
|
return re.sub(r"\\+", "\\\\", text)
|
||||||
|
|
||||||
def write(self, text):
|
def write(self, text):
|
||||||
if "\n" in text:
|
if "\n" in text:
|
||||||
for line in text.strip().split("\n"):
|
for line in text.strip().split("\n"):
|
||||||
self.STDOUT.write('~"%s\\n"\n' % line)
|
self.STDOUT.write('~"%s\\n"\n' % self.escape(line))
|
||||||
else:
|
else:
|
||||||
self.STDOUT.write('~"%s"' % text)
|
self.STDOUT.write('~"%s"' % self.escape(text))
|
||||||
self.STDOUT.flush()
|
self.STDOUT.flush()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user