diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-05-06 15:29:18 -0700 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-05-06 15:29:18 -0700 |
| commit | 03afd0afa2ee5e2e3995fb6385e1d33a783dd602 (patch) | |
| tree | d5589f31b5d5ae19da9ec75b3d5e0f9e8fb6f9a4 /csource/csource.go | |
| parent | 6b3319f489c9b5c7c5c3f4e04cc3a8897f634725 (diff) | |
csource: strip __STDC_VERSION__ macro from generated source
Diffstat (limited to 'csource/csource.go')
| -rw-r--r-- | csource/csource.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/csource/csource.go b/csource/csource.go index 4311bfc98..1bf3fc7a1 100644 --- a/csource/csource.go +++ b/csource/csource.go @@ -303,7 +303,6 @@ func preprocessCommonHeader(opts Options, handled map[string]int) (string, error } remove := append(defines, []string{ "__STDC__", - "__STDC_VERSION__", "__STDC_HOSTED__", "__STDC_UTF_16__", "__STDC_UTF_32__", @@ -312,6 +311,18 @@ func preprocessCommonHeader(opts Options, handled map[string]int) (string, error for _, def := range remove { out = strings.Replace(out, "#define "+def+" 1\n", "", -1) } + // strip: #define __STDC_VERSION__ 201112L + for _, def := range []string{"__STDC_VERSION__"} { + pos := strings.Index(out, "#define "+def) + if pos == -1 { + continue + } + end := strings.IndexByte(out[pos:], '\n') + if end == -1 { + continue + } + out = strings.Replace(out, out[pos:end+1], "", -1) + } return out, nil } |
