Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
orangecat
ollama
Commits
95397416
Unverified
Commit
95397416
authored
Jul 25, 2023
by
Michael Yang
Committed by
GitHub
Jul 25, 2023
Browse files
Merge pull request #212 from jmorganca/fix-multiline-parsing
fix multiline string
parents
8a86aae0
24c2c770
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
parser/parser.go
parser/parser.go
+7
-4
No files found.
parser/parser.go
View file @
95397416
...
...
@@ -4,8 +4,8 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"log"
)
type
Command
struct
{
...
...
@@ -28,7 +28,7 @@ func Parse(reader io.Reader) ([]Command, error) {
line
:=
scanner
.
Bytes
()
fields
:=
bytes
.
SplitN
(
line
,
[]
byte
(
" "
),
2
)
if
len
(
fields
)
==
0
{
if
len
(
fields
)
==
0
||
len
(
fields
[
0
])
==
0
{
continue
}
...
...
@@ -47,7 +47,7 @@ func Parse(reader io.Reader) ([]Command, error) {
command
.
Args
=
string
(
fields
[
1
])
default
:
// log a warning for unknown commands
fmt
.
Printf
(
"WARNING: Unknown command: %s
\n
"
,
fields
[
0
])
log
.
Printf
(
"WARNING: Unknown command: %s"
,
fields
[
0
])
continue
}
...
...
@@ -78,7 +78,10 @@ func scanModelfile(data []byte, atEOF bool) (advance int, token []byte, err erro
}
n
:=
start
+
len
(
multilineString
)
+
end
+
len
(
multilineString
)
return
n
,
data
[
:
n
],
nil
newData
:=
data
[
:
start
]
newData
=
append
(
newData
,
data
[
start
+
len
(
multilineString
)
:
n
-
len
(
multilineString
)]
...
)
return
n
,
newData
,
nil
}
return
bufio
.
ScanLines
(
data
,
atEOF
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment