| 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package mainscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/ |
| 6 | |
| 7 | import "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 8 | |
| 9 | type stringsFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/stringsFlag# []string |
| 10 | |
| 11 | func (v *stringsFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/stringsFlag#) Setscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/stringsFlag#Set().(s string) error { |
| 12 | var err error |
| 13 | *v, err = splitQuotedFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/splitQuotedFields().(s) |
| 14 | if *v == nil { |
| 15 | *v = []string{} |
| 16 | } |
| 17 | return err |
| 18 | } |
| 19 | |
| 20 | func isSpaceBytescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/isSpaceByte().(c byte) bool { |
| 21 | return c == ' ' || c == '\t' || c == '\n' || c == '\r' |
| 22 | } |
| 23 | |
| 24 | func splitQuotedFieldsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/splitQuotedFields().(s string) ([]string, error) { |
| 25 | // Split fields allowing '' or "" around elements. |
| 26 | // Quotes further inside the string do not count. |
| 27 | var f []string |
| 28 | for len(s) > 0 { |
| 29 | for len(s) > 0 && isSpaceBytescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/isSpaceByte().(s[0]) { |
| 30 | s = s[1:] |
| 31 | } |
| 32 | if len(s) == 0 { |
| 33 | break |
| 34 | } |
| 35 | // Accepted quoted string. No unescaping inside. |
| 36 | if s[0] == '"' || s[0] == '\'' { |
| 37 | quote := s[0] |
| 38 | s = s[1:] |
| 39 | i := 0 |
| 40 | for i < len(s) && s[i] != quote { |
| 41 | i++ |
| 42 | } |
| 43 | if i >= len(s) { |
| 44 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unterminated %c string", quote) |
| 45 | } |
| 46 | f = append(f, s[:i]) |
| 47 | s = s[i+1:] |
| 48 | continue |
| 49 | } |
| 50 | i := 0 |
| 51 | for i < len(s) && !isSpaceBytescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/isSpaceByte().(s[i]) { |
| 52 | i++ |
| 53 | } |
| 54 | f = append(f, s[:i]) |
| 55 | s = s[i:] |
| 56 | } |
| 57 | return f, nil |
| 58 | } |
| 59 | |
| 60 | func (v *stringsFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/stringsFlag#) Stringscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/cmd/gomobile`/stringsFlag#String().() string { |
| 61 | return "<stringsFlag>" |
| 62 | } |