MCPcopy Index your code
hub / github.com/Shopify/go-lua / scanFormat

Function scanFormat

string.go:43–69  ·  view source on GitHub ↗
(l *State, fs string)

Source from the content-addressed store, hash-verified

41}
42
43func scanFormat(l *State, fs string) string {
44 i := 0
45 skipDigit := func() {
46 if unicode.IsDigit(rune(fs[i])) {
47 i++
48 }
49 }
50 flags := "-+ #0"
51 for i < len(fs) && strings.ContainsRune(flags, rune(fs[i])) {
52 i++
53 }
54 if i >= len(flags) {
55 Errorf(l, "invalid format (repeated flags)")
56 }
57 skipDigit()
58 skipDigit()
59 if fs[i] == '.' {
60 i++
61 skipDigit()
62 skipDigit()
63 }
64 if unicode.IsDigit(rune(fs[i])) {
65 Errorf(l, "invalid format (width or precision too long)")
66 }
67 i++
68 return "%" + fs[:i]
69}
70
71func formatHelper(l *State, fs string, argCount int) string {
72 var b bytes.Buffer

Callers 1

formatHelperFunction · 0.85

Calls 1

ErrorfFunction · 0.85

Tested by

no test coverage detected