diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-07 15:14:11 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-07 15:16:03 -0600 |
commit | 29e710836007c8946d636a68b7dfaea6ee44028b (patch) | |
tree | a1d0866bd844d384d7bade3b24bb237495f2d398 /gopher/gophermap/extended.go | |
parent | da5d3607c7e51043f425dac87ac723395e092551 (diff) |
fix loop exit conditions on extended gophermap parsing
Diffstat (limited to 'gopher/gophermap/extended.go')
-rw-r--r-- | gopher/gophermap/extended.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gopher/gophermap/extended.go b/gopher/gophermap/extended.go index 8b04104..e1db9dc 100644 --- a/gopher/gophermap/extended.go +++ b/gopher/gophermap/extended.go @@ -33,6 +33,8 @@ func ParseExtended(input io.Reader, location *url.URL) (*ExtendedMapDocument, er outer: for num := 1; ; num += 1 { + var item gopher.MapItem + var spl []string line, err := rdr.ReadString('\n') isEOF := errors.Is(err, io.EOF) if err != nil && !isEOF { @@ -48,41 +50,41 @@ outer: Type: CommentType, Display: strings.TrimPrefix(line[1:], " "), }) - continue outer + goto next case '!': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: TitleType, Display: line[1:], }) - continue outer + goto next case '-': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: HiddenType, Selector: line[1:], }) - continue outer + goto next case ':': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: ExtensionType, Display: line[1:], }) - continue outer + goto next case '=': doc.Lines = append(doc.Lines, gopher.MapItem{ Type: InclusionType, Selector: line[1:], }) - continue outer + goto next } } switch line { case "~": doc.Lines = append(doc.Lines, gopher.MapItem{Type: UserListType}) - continue outer + goto next case "%": doc.Lines = append(doc.Lines, gopher.MapItem{Type: VHostListType}) - continue outer + goto next case ".": doc.Lines = append(doc.Lines, gopher.MapItem{Type: EndDocType}) break outer @@ -99,12 +101,12 @@ outer: Hostname: location.Hostname(), Port: location.Port(), }) - continue + goto next } - item := gopher.MapItem{Type: types.Status(line[0])} + item = gopher.MapItem{Type: types.Status(line[0])} - spl := strings.Split(line[1:], "\t") + spl = strings.Split(line[1:], "\t") if len(spl) != 4 { return doc, InvalidLine(num) } @@ -117,6 +119,7 @@ outer: } doc.Lines = append(doc.Lines, item) + next: if isEOF { break } |