diff options
Diffstat (limited to 'pkg/csource/csource.go')
| -rw-r--r-- | pkg/csource/csource.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index aa5f615e1..91e66e1cd 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -430,21 +430,23 @@ func (ctx *context) hoistIncludes(result []byte) []byte { includes[string(match)] = true } result = includeRe.ReplaceAll(result, nil) - // Linux headers are broken, so we have to move all linux includes to the bottom. - var sorted, sortedLinux []string + // Certain linux and bsd headers are broken and go to the bottom. + var sorted, sortedBottom []string for include := range includes { if strings.Contains(include, "<linux/") { - sortedLinux = append(sortedLinux, include) + sortedBottom = append(sortedBottom, include) + } else if strings.Contains(include, "<netinet/if_ether.h>") { + sortedBottom = append(sortedBottom, include) } else { sorted = append(sorted, include) } } sort.Strings(sorted) - sort.Strings(sortedLinux) + sort.Strings(sortedBottom) newResult := append([]byte{}, result[:includesStart]...) newResult = append(newResult, strings.Join(sorted, "")...) newResult = append(newResult, '\n') - newResult = append(newResult, strings.Join(sortedLinux, "")...) + newResult = append(newResult, strings.Join(sortedBottom, "")...) newResult = append(newResult, result[includesStart:]...) return newResult } |
