(s *bufio.Scanner)
| 975 | } |
| 976 | |
| 977 | func parseProcMapsFromScanner(s *bufio.Scanner) ([]*Mapping, error) { |
| 978 | var mapping []*Mapping |
| 979 | |
| 980 | var attrs []string |
| 981 | const delimiter = "=" |
| 982 | r := strings.NewReplacer() |
| 983 | for s.Scan() { |
| 984 | line := r.Replace(removeLoggingInfo(s.Text())) |
| 985 | m, err := parseMappingEntry(line) |
| 986 | if err != nil { |
| 987 | if err == errUnrecognized { |
| 988 | // Recognize assignments of the form: attr=value, and replace |
| 989 | // $attr with value on subsequent mappings. |
| 990 | if attr := strings.SplitN(line, delimiter, 2); len(attr) == 2 { |
| 991 | attrs = append(attrs, "$"+strings.TrimSpace(attr[0]), strings.TrimSpace(attr[1])) |
| 992 | r = strings.NewReplacer(attrs...) |
| 993 | } |
| 994 | // Ignore any unrecognized entries |
| 995 | continue |
| 996 | } |
| 997 | return nil, err |
| 998 | } |
| 999 | if m == nil { |
| 1000 | continue |
| 1001 | } |
| 1002 | mapping = append(mapping, m) |
| 1003 | } |
| 1004 | if err := s.Err(); err != nil { |
| 1005 | return nil, err |
| 1006 | } |
| 1007 | return mapping, nil |
| 1008 | } |
| 1009 | |
| 1010 | // removeLoggingInfo detects and removes log prefix entries generated |
| 1011 | // by the glog package. If no logging prefix is detected, the string |
no test coverage detected
searching dependent graphs…