comparison src/main/kotlin/name/blackcap/passman/Shplitter.kt @ 21:ea65ab890f66

More work to support interactive feature.
author David Barts <n5jrn@me.com>
date Tue, 02 Jul 2024 11:27:39 -0700
parents 4391afcf6bd0
children
comparison
equal deleted inserted replaced
20:4391afcf6bd0 21:ea65ab890f66
106 '\\' -> { pushState(::backslash); false } 106 '\\' -> { pushState(::backslash); false }
107 '"' -> { popState(); false } 107 '"' -> { popState(); false }
108 else -> { current.append(ch); false } 108 else -> { current.append(ch); false }
109 } 109 }
110 110
111 // XXX - multiline commands achieved with backslash-newline
112 // sequences not supported, so this only works with single-
113 // line commands.
111 private fun backslash(ch: Char): Boolean { 114 private fun backslash(ch: Char): Boolean {
112 val last = lastState() 115 // continue existing string no matter what
113 if (ch == '\n' && last !in QUOTING) { 116 current.append(ch)
114 // if not quoting, \\n makes a normal whitespace out of command terminator 117 popState()
115 popState() 118 return false
116 return true
117 } else if (last == ::space) {
118 // start a new unquoted string no matter what
119 current.append(ch)
120 state = ::nonspace
121 return false
122 } else {
123 // continue existing string no matter what
124 current.append(ch)
125 popState()
126 return false
127 }
128 } 119 }
129 } 120 }