trim all params
This commit is contained in:
parent
4e986a823c
commit
9bd00041fa
2 changed files with 4 additions and 11 deletions
|
@ -124,8 +124,7 @@ func ParseFile(r io.Reader) (*File, error) {
|
||||||
case stateComment, stateNil:
|
case stateComment, stateNil:
|
||||||
// pass
|
// pass
|
||||||
case stateValue:
|
case stateValue:
|
||||||
s, ok := unquote(b.String())
|
s, ok := unquote(strings.TrimSpace(b.String()))
|
||||||
|
|
||||||
if !ok || isSpace(r) {
|
if !ok || isSpace(r) {
|
||||||
if _, err := b.WriteRune(r); err != nil {
|
if _, err := b.WriteRune(r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -159,13 +158,7 @@ func ParseFile(r io.Reader) (*File, error) {
|
||||||
case stateComment, stateNil:
|
case stateComment, stateNil:
|
||||||
// pass; nothing to flush
|
// pass; nothing to flush
|
||||||
case stateValue:
|
case stateValue:
|
||||||
var s string
|
s, ok := unquote(strings.TrimSpace(b.String()))
|
||||||
var ok bool
|
|
||||||
if cmd.Name == "model" {
|
|
||||||
s, ok = unquote(strings.TrimSpace(b.String()))
|
|
||||||
} else {
|
|
||||||
s, ok = unquote(b.String())
|
|
||||||
}
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, io.ErrUnexpectedEOF
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ func TestParseFileFrom(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"PARAMETER what the \nFROM lemons make lemonade ",
|
"PARAMETER what the \nFROM lemons make lemonade ",
|
||||||
[]Command{{Name: "what", Args: "the "}, {Name: "model", Args: "lemons make lemonade"}},
|
[]Command{{Name: "what", Args: "the"}, {Name: "model", Args: "lemons make lemonade"}},
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ func TestParseFileParameters(t *testing.T) {
|
||||||
"mirostat_eta 1.0": {"mirostat_eta", "1.0"},
|
"mirostat_eta 1.0": {"mirostat_eta", "1.0"},
|
||||||
"penalize_newline true": {"penalize_newline", "true"},
|
"penalize_newline true": {"penalize_newline", "true"},
|
||||||
"stop ### User:": {"stop", "### User:"},
|
"stop ### User:": {"stop", "### User:"},
|
||||||
"stop ### User: ": {"stop", "### User: "},
|
"stop ### User: ": {"stop", "### User:"},
|
||||||
"stop \"### User:\"": {"stop", "### User:"},
|
"stop \"### User:\"": {"stop", "### User:"},
|
||||||
"stop \"### User: \"": {"stop", "### User: "},
|
"stop \"### User: \"": {"stop", "### User: "},
|
||||||
"stop \"\"\"### User:\"\"\"": {"stop", "### User:"},
|
"stop \"\"\"### User:\"\"\"": {"stop", "### User:"},
|
||||||
|
|
Loading…
Reference in a new issue