func (s *IncludesFinderWithRegExp) Run(context map[string]interface{}) error { source := context[s.ContextField].(string) matches := INCLUDE_REGEXP.FindAllStringSubmatch(source, -1) includes := []string{} for _, match := range matches { includes = append(includes, strings.TrimSpace(match[1])) } if len(includes) == 0 { include := findIncludesForOldCompilers(source) if include != "" { includes = append(includes, include) } } context[constants.CTX_INCLUDES_JUST_FOUND] = includes if !utils.MapHas(context, constants.CTX_INCLUDES) { context[constants.CTX_INCLUDES] = includes return nil } context[constants.CTX_INCLUDES] = utils.AddStringsToStringsSet(context[constants.CTX_INCLUDES].([]string), includes) return nil }
func (s *GCCMinusMOutputParser) Run(context map[string]interface{}) error { output := context[constants.CTX_GCC_MINUS_M_OUTPUT].(string) rows := strings.Split(output, "\n") includes := make([]string, 0) if len(rows) > 2 { for _, row := range rows[2:] { if !strings.HasPrefix(row, constants.SPACE) { row = strings.TrimSpace(row) if row != constants.EMPTY_STRING { row = strings.TrimSuffix(row, ":") row = strings.Replace(row, "\\ ", " ", -1) includes = append(includes, row) } } } } if !utils.MapHas(context, constants.CTX_INCLUDES) { context[constants.CTX_INCLUDES] = includes return nil } context[constants.CTX_INCLUDES] = utils.AddStringsToStringsSet(context[constants.CTX_INCLUDES].([]string), includes) return nil }