MCPcopy Create free account
hub / github.com/SeeFlowerX/stackplz / parse

Function parse

user/util/android.go:83–119  ·  view source on GitHub ↗
(s *bufio.Scanner, p map[string]string)

Source from the content-addressed store, hash-verified

81}
82
83func parse(s *bufio.Scanner, p map[string]string) error {
84 r, _ := regexp.Compile("^(?:# *)?(CONFIG_\\w*)(?:=| )(y|n|m|is not set|\\d+|0x.+|\".*\")$")
85
86 for s.Scan() {
87
88 t := s.Text()
89
90 // Skip line if empty.
91 if t == "" {
92 continue
93 }
94
95 // 0 is the match of the entire expression,
96 // 1 is the key, 2 is the value.
97 m := r.FindStringSubmatch(t)
98 if m == nil {
99 continue
100 }
101
102 if len(m) != 3 {
103 return fmt.Errorf("match is not 3 chars long: %v", m)
104 }
105 // Remove all leading and trailing double quotes from the value.
106 if len(m[2]) > 1 {
107 m[2] = strings.Trim(m[2], "\"")
108 }
109
110 // Insert entry into map.
111 p[m[1]] = m[2]
112 }
113
114 if err := s.Err(); err != nil {
115 return err
116 }
117
118 return nil
119}

Callers 1

getAndroidConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected