Vladimir Serbinenko | 8251e90 | 2014-11-23 16:19:48 +0100 | [diff] [blame] | 1 | package kconfig |
| 2 | |
| 3 | import ( |
| 4 | "bufio" |
| 5 | "bytes" |
| 6 | "strings" |
| 7 | ) |
| 8 | |
| 9 | func ParseKConfig(raw []byte) map[string]string { |
| 10 | buffer := bytes.NewBuffer(raw) |
| 11 | |
| 12 | scanner := bufio.NewScanner(buffer) |
| 13 | ret := map[string]string{} |
| 14 | for scanner.Scan() { |
| 15 | line := scanner.Text() |
| 16 | if line[0] == '#' { |
| 17 | continue |
| 18 | } |
| 19 | idx := strings.Index(line, "=") |
| 20 | if idx < 0 { |
| 21 | continue |
| 22 | } |
| 23 | ret[line[0:idx]] = line[idx+1:] |
| 24 | } |
| 25 | return ret |
| 26 | } |
| 27 | |
| 28 | func UnQuote(in string) string { |
| 29 | return in[1 : len(in)-1] |
| 30 | } |