@@ -602,14 +602,14 @@ func s:GdbOutCallback(channel, text)
602602 return
603603 endif
604604 if a: text = ~ ' ^\^error,msg='
605- let text = s: DecodeMessage (a: text [11 :])
605+ let text = s: DecodeMessage (a: text [11 :], v: false )
606606 if exists (' s:evalexpr' ) && text = ~ ' A syntax error in expression, near\|No symbol .* in current context'
607607 " Silently drop evaluation errors.
608608 unlet s: evalexpr
609609 return
610610 endif
611611 elseif a: text [0 ] == ' ~'
612- let text = s: DecodeMessage (a: text [1 :])
612+ let text = s: DecodeMessage (a: text [1 :], v: false )
613613 else
614614 call s: CommOutput (a: channel , a: text )
615615 return
@@ -625,21 +625,20 @@ func s:GdbOutCallback(channel, text)
625625 call win_gotoid (curwinid)
626626endfunc
627627
628- " Decode a message from gdb. quotedText starts with a ", return the text up
628+ " Decode a message from gdb. " quotedText" starts with a ", return the text up
629629" to the next ", unescaping characters:
630- " - remove line breaks
631- " - change \\t to \t
630+ " - remove line breaks (unless "literal" is v:true)
631+ " - change \\t to \t (unless "literal" is v:true)
632632" - change \0xhh to \xhh (disabled for now)
633633" - change \ooo to octal
634634" - change \\ to \
635- func s: DecodeMessage (quotedText)
635+ func s: DecodeMessage (quotedText, literal )
636636 if a: quotedText [0 ] != ' "'
637637 echoerr ' DecodeMessage(): missing quote in ' . a: quotedText
638638 return
639639 endif
640- return a: quotedText
641- \ - >substitute (' ^"\|".*\|\\n' , ' ' , ' g' )
642- \ - >substitute (' \\t' , " \t " , ' g' )
640+ let msg = a: quotedText
641+ \ - >substitute (' ^"\|".*' , ' ' , ' g' )
643642 " multi-byte characters arrive in octal form
644643 " NULL-values must be kept encoded as those break the string otherwise
645644 \ - >substitute (' \\000' , s: NullRepl , ' g' )
@@ -651,6 +650,13 @@ func s:DecodeMessage(quotedText)
651650 " \ ->substitute('\\0x00', s:NullRepl, 'g')
652651 \ - >substitute (' \\\\' , ' \' , ' g' )
653652 \ - >substitute (s: NullRepl , ' \\000' , ' g' )
653+ if ! a: literal
654+ return msg
655+ \ - >substitute (' \\t' , " \t " , ' g' )
656+ \ - >substitute (' \\n' , ' ' , ' g' )
657+ else
658+ return msg
659+ endif
654660endfunc
655661const s: NullRepl = ' XXXNULLXXX'
656662
@@ -659,7 +665,7 @@ func s:GetFullname(msg)
659665 if a: msg !~ ' fullname'
660666 return ' '
661667 endif
662- let name = s: DecodeMessage (substitute (a: msg , ' .*fullname=' , ' ' , ' ' ))
668+ let name = s: DecodeMessage (substitute (a: msg , ' .*fullname=' , ' ' , ' ' ), v: true )
663669 if has (' win32' ) && name = ~ ' :\\\\'
664670 " sometimes the name arrives double-escaped
665671 let name = substitute (name, ' \\\\' , ' \\' , ' g' )
@@ -672,7 +678,7 @@ func s:GetAsmAddr(msg)
672678 if a: msg !~ ' addr='
673679 return ' '
674680 endif
675- let addr = s: DecodeMessage (substitute (a: msg , ' .*addr=' , ' ' , ' ' ))
681+ let addr = s: DecodeMessage (substitute (a: msg , ' .*addr=' , ' ' , ' ' ), v: false )
676682 return addr
677683endfunc
678684
0 commit comments