MCPcopy Create free account
hub / github.com/antonmedv/gitmal / WriteQuotedName

Method WriteQuotedName

pkg/gitdiff/format.go:40–57  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

38}
39
40func (fm *formatter) WriteQuotedName(s string) {
41 qpos := 0
42 for i := 0; i < len(s); i++ {
43 ch := s[i]
44 if q, quoted := quoteByte(ch); quoted {
45 if qpos == 0 {
46 fm.WriteByte('"')
47 }
48 fm.WriteString(s[qpos:i])
49 fm.Write(q)
50 qpos = i + 1
51 }
52 }
53 fm.WriteString(s[qpos:])
54 if qpos > 0 {
55 fm.WriteByte('"')
56 }
57}
58
59var quoteEscapeTable = map[byte]byte{
60 '\a': 'a',

Callers 2

FormatFileMethod · 0.95

Calls 4

WriteByteMethod · 0.95
WriteStringMethod · 0.95
WriteMethod · 0.95
quoteByteFunction · 0.85

Tested by 1