Remove unneeded check in *escapeInterpreter.parseOne()

This commit is contained in:
Roi Martin 2017-02-12 15:26:07 +01:00
parent e27f247a3e
commit 139487f578

View File

@ -76,14 +76,16 @@ func (ei *escapeInterpreter) reset() {
// of an escape sequence, and as such should not be printed verbatim. Otherwise,
// it's not an escape sequence.
func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
// Sanity checks to make sure we're not parsing something totally bogus.
// Sanity checks
if len(ei.csiParam) > 20 {
return false, errCSITooLong
}
if len(ei.csiParam) > 0 && len(ei.csiParam[len(ei.csiParam)-1]) > 255 {
return false, errCSITooLong
}
ei.curch = ch
switch ei.state {
case stateNone:
if ch == 0x1b {
@ -117,16 +119,11 @@ func (ei *escapeInterpreter) parseOne(ch rune) (isEscape bool, err error) {
ei.csiParam = append(ei.csiParam, "")
return true, nil
case ch == 'm':
if len(ei.csiParam) < 1 {
return false, errCSIParseError
}
var err error
switch ei.mode {
case OutputMode(OutputNormal):
case OutputNormal:
err = ei.outputNormal()
case OutputMode(Output256):
case Output256:
err = ei.output256()
}
if err != nil {