From c08c1cd05c3c8e0cf6b24a0425f058c6555b82cc Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 6 Mar 2019 20:32:44 -0500 Subject: pkg/csource: sort sys/types.h to the top on FreeBSD sys/types.h is a special header that is required by many other system headers on FreeBSD. --- pkg/csource/csource.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'pkg/csource/csource.go') diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 26834dd3f..d58c361ee 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -445,19 +445,24 @@ func (ctx *context) hoistIncludes(result []byte) []byte { } result = includeRe.ReplaceAll(result, nil) // Certain linux and bsd headers are broken and go to the bottom. - var sorted, sortedBottom []string + var sorted, sortedBottom, sortedTop []string for include := range includes { if strings.Contains(include, "") { sortedBottom = append(sortedBottom, include) + } else if ctx.target.OS == freebsd && strings.Contains(include, "") { + sortedTop = append(sortedTop, include) } else { sorted = append(sorted, include) } } + sort.Strings(sortedTop) sort.Strings(sorted) sort.Strings(sortedBottom) newResult := append([]byte{}, result[:includesStart]...) + newResult = append(newResult, strings.Join(sortedTop, "")...) + newResult = append(newResult, '\n') newResult = append(newResult, strings.Join(sorted, "")...) newResult = append(newResult, '\n') newResult = append(newResult, strings.Join(sortedBottom, "")...) -- cgit mrf-deployment