diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff7d04b..7310df0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,12 @@ on: jobs: test: name: Test - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Go uses: actions/setup-go@v2 with: - go-version: '1.18.x' + go-version: '1.22.x' - name: actions/checkout uses: actions/checkout@v2 - name: actions/cache @@ -29,12 +29,12 @@ jobs: test-tcc: name: TCC Tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Install Go uses: actions/setup-go@v2 with: - go-version: '1.18.x' + go-version: '1.22.x' - name: actions/checkout uses: actions/checkout@v2 - name: actions/cache @@ -56,8 +56,12 @@ jobs: # test-gcc: # name: GCC Tests -# runs-on: ubuntu-20.04 +# runs-on: ubuntu-22.04 # steps: +# - name: Install Go +# uses: actions/setup-go@v2 +# with: +# go-version: '1.22.x' # - name: actions/checkout # uses: actions/checkout@v2 # - name: actions/cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cdc0e24..7c1e3d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2 with: - go-version: '1.18.x' + go-version: '1.22.x' - name: Checkout uses: actions/checkout@v2 with: diff --git a/README.md b/README.md index 721a66c..5f237c4 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Although it was successfully tested on multiple projects, it might _change the b **Transpiled projects:** -- [Potrace](./examples/potrace) (image vectorization library) +- [Potrace](https://github.com/gotranspile/gotrace) (image vectorization library) - [G722](https://github.com/gotranspile/g722) (audio codec) - [PortableGL](https://github.com/TotallyGamerJet/pgl) (OpenGL 3.x implementation) - [Physac](https://github.com/koteyur/physac-go) (2D physics engine) diff --git a/cmd/cxgo/main.go b/cmd/cxgo/main.go index 9cc2a83..c28a0b9 100644 --- a/cmd/cxgo/main.go +++ b/cmd/cxgo/main.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "go/format" - "io/ioutil" "log" "os" "os/exec" @@ -162,7 +161,7 @@ func mergeBool(val *bool, def bool) bool { func run(cmd *cobra.Command, args []string) error { defer cxgo.CallFinals() conf, _ := cmd.Flags().GetString("config") - data, err := ioutil.ReadFile(conf) + data, err := os.ReadFile(conf) if err != nil { return err } @@ -251,7 +250,7 @@ func run(cmd *cobra.Command, args []string) error { if fdata, err := format.Source(data); err == nil { data = fdata } - return ioutil.WriteFile(filepath.Join(c.Out, f.Name), data, 0644) + return os.WriteFile(filepath.Join(c.Out, f.Name), data, 0644) } idents := make(map[string]cxgo.IdentConfig) for _, v := range c.Idents { @@ -368,7 +367,7 @@ require ( %s %s ) `, c.Package, libs.RuntimePackage, libs.RuntimePackageVers) - if err := ioutil.WriteFile(filepath.Join(c.Out, "go.mod"), buf.Bytes(), 0644); err != nil { + if err := os.WriteFile(filepath.Join(c.Out, "go.mod"), buf.Bytes(), 0644); err != nil { return err } } diff --git a/compile_test.go b/compile_test.go index 29663bb..883f5bd 100644 --- a/compile_test.go +++ b/compile_test.go @@ -3,7 +3,6 @@ package cxgo import ( "bytes" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -62,7 +61,7 @@ func goTranspileAndExec(t testing.TB, cxgo, dir string, cfile string) progOut { }) require.NoError(t, err) goProjectMod(t, dir) - gosrc, err := ioutil.ReadFile(gofile) + gosrc, err := os.ReadFile(gofile) require.NoError(t, err) t.Logf("// === Go source ===\n%s", string(gosrc)) return goCompileAndExec(t, dir) @@ -112,11 +111,11 @@ require ( ) replace github.com/gotranspile/cxgo v0.0.0-local => %s`, cxgo) - err = ioutil.WriteFile(filepath.Join(out, "go.mod"), []byte(gomod), 0644) + err = os.WriteFile(filepath.Join(out, "go.mod"), []byte(gomod), 0644) require.NoError(t, err) // allows running go mod tidy without having other source files and still keep require above - err = ioutil.WriteFile(filepath.Join(out, "dummy.go"), []byte(` + err = os.WriteFile(filepath.Join(out, "dummy.go"), []byte(` package main import _ "github.com/gotranspile/cxgo/runtime/libc" diff --git a/examples/potrace/README.md b/examples/potrace/README.md index 54a073f..3a57301 100644 --- a/examples/potrace/README.md +++ b/examples/potrace/README.md @@ -533,7 +533,6 @@ package gotrace import ( "io" - "io/ioutil" "net/http" "os" "testing" @@ -553,7 +552,7 @@ func TestPotrace(t *testing.T) { t.Fatal(resp.Status) } - tfile, err := ioutil.TempFile("", "potrace_") + tfile, err := os.CreateTemp("", "potrace_") if err != nil { t.Fatal(err) } @@ -742,7 +741,6 @@ package gotrace import ( "io" - "io/ioutil" "net/http" "os" "testing" @@ -762,7 +760,7 @@ func TestPotrace(t *testing.T) { t.Fatal(resp.Status) } - tfile, err := ioutil.TempFile("", "potrace_") + tfile, err := os.CreateTemp("", "potrace_") if err != nil { t.Fatal(err) } diff --git a/flow_test.go b/flow_test.go index 52e25cd..5e691bf 100644 --- a/flow_test.go +++ b/flow_test.go @@ -2,7 +2,6 @@ package cxgo import ( "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -1215,9 +1214,9 @@ goto L_1 func writeDotFile(name string, data []byte) { name = strings.ReplaceAll(name, " ", "_") fname := name + ".dot" - _ = ioutil.WriteFile(fname, data, 0644) + _ = os.WriteFile(fname, data, 0644) sdata, _ := exec.Command("dot", "-Tsvg", fname).Output() - _ = ioutil.WriteFile(name+".svg", sdata, 0644) + _ = os.WriteFile(name+".svg", sdata, 0644) _ = os.Remove(fname) } diff --git a/gcc_test.go b/gcc_test.go index 7828cc5..f6c7bb1 100644 --- a/gcc_test.go +++ b/gcc_test.go @@ -2,7 +2,6 @@ package cxgo import ( "bytes" - "io/ioutil" "os" "path/filepath" "runtime/debug" @@ -56,6 +55,8 @@ func TestGCCExecute(t *testing.T) { ignoreTests := map[string]string{ "limits-caselabels": "OOM", + "limits-declparen": "stack exceeded", + "limits-exprparen": "stack exceeded", } blacklist := map[string]struct{}{} @@ -104,7 +105,7 @@ func TestGCCExecute(t *testing.T) { oname := filepath.Base(path) + ".go" env := libs.NewEnv(types.Config32()) _, lib := isLib[tname] - if data, err := ioutil.ReadFile(path); err == nil && !bytes.Contains(data, []byte("main")) { + if data, err := os.ReadFile(path); err == nil && !bytes.Contains(data, []byte("main")) { t.Log("testing as a library (no main found)") lib = true } diff --git a/go.mod b/go.mod index 23fca4f..584d681 100644 --- a/go.mod +++ b/go.mod @@ -3,24 +3,23 @@ module github.com/gotranspile/cxgo go 1.19 require ( - github.com/bmatcuk/doublestar v1.3.0 + github.com/bmatcuk/doublestar v1.3.4 github.com/chewxy/math32 v1.10.1 - github.com/emicklei/dot v0.16.0 - github.com/spf13/cobra v0.0.5 - github.com/stretchr/testify v1.4.0 - gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 - modernc.org/cc/v3 v3.36.1 - modernc.org/token v1.0.0 + github.com/emicklei/dot v1.6.2 + github.com/spf13/cobra v1.8.1 + github.com/stretchr/testify v1.9.0 + gopkg.in/yaml.v3 v3.0.1 + modernc.org/cc/v3 v3.41.0 + modernc.org/token v1.1.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect - github.com/spf13/pflag v1.0.3 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - lukechampine.com/uint128 v1.2.0 // indirect - modernc.org/mathutil v1.4.1 // indirect - modernc.org/strutil v1.1.1 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/spf13/pflag v1.0.5 // indirect + lukechampine.com/uint128 v1.3.0 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/strutil v1.2.0 // indirect ) diff --git a/go.sum b/go.sum index 8502f0e..ba2153b 100644 --- a/go.sum +++ b/go.sum @@ -1,69 +1,38 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/bmatcuk/doublestar v1.3.0 h1:1jLE2y0VpSrOn/QR9G4f2RmrCtkM3AuATcWradjHUvM= -github.com/bmatcuk/doublestar v1.3.0/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/chewxy/math32 v1.10.1 h1:LFpeY0SLJXeaiej/eIp2L40VYfscTvKh/FSEZ68uMkU= github.com/chewxy/math32 v1.10.1/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/emicklei/dot v0.16.0 h1:7PseyizTgeQ/aSF1eo4LcEfWlQSlzamFZpzY/nMB9EY= -github.com/emicklei/dot v0.16.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A= +github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM= -gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.36.1 h1:CICrjwr/1M4+6OQ4HJZ/AHxjcwe67r5vPUF518MkO8A= -modernc.org/cc/v3 v3.36.1/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8= -modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs= -modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= -modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= -modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +lukechampine.com/uint128 v1.3.0 h1:cDdUVfRwDUDovz610ABgFD17nXD4/uDgVHl2sC3+sbo= +lukechampine.com/uint128 v1.3.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +modernc.org/cc/v3 v3.41.0 h1:QoR1Sn3YWlmA1T4vLaKZfawdVtSiGx8H+cEojbC7v1Q= +modernc.org/cc/v3 v3.41.0/go.mod h1:Ni4zjJYJ04CDOhG7dn640WGfwBzfE0ecX8TyMB0Fv0Y= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= +modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/tcc_test.go b/tcc_test.go index 91d9728..0d4dd6c 100644 --- a/tcc_test.go +++ b/tcc_test.go @@ -1,7 +1,6 @@ package cxgo import ( - "io/ioutil" "os" "path/filepath" "runtime/debug" @@ -72,7 +71,7 @@ func TestTCCExecute(t *testing.T) { "55_lshift_type": {}, "60_errors_and_warnings": {}, "73_arm64": {}, - "75_array_in_struct_init": {}, // CC type checker failure + "75_array_in_struct_init": {}, // FIXME: cxgo handles struct field init incorrectly? "77_push_pop_macro": {}, // FIXME: cannot detect if a macro was redefined "78_vla_label": {}, "79_vla_continue": {}, @@ -81,7 +80,7 @@ func TestTCCExecute(t *testing.T) { "89_nocode_wanted": {}, "90_struct-init": {}, "92_enum_bitfield": {}, - "93_integer_promotion": {}, // TODO: some issues with char promotion + "93_integer_promotion": {}, // FIXME: one issue with char promotion "94_generic": {}, "95_bitfields": {}, "95_bitfields_ms": {}, @@ -163,7 +162,7 @@ func TestTCCExecute(t *testing.T) { if s, ok := overrideExpect[tname]; ok { exp = []byte(s) } else { - exp, err = ioutil.ReadFile(epath) + exp, err = os.ReadFile(epath) require.NoError(t, err) } if string(exp) != string(got) && skip { diff --git a/translate.go b/translate.go index d6316be..20e8cd3 100644 --- a/translate.go +++ b/translate.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "io/ioutil" "os" "path/filepath" "regexp" @@ -178,10 +177,10 @@ func Translate(root, fname, out string, env *libs.Env, conf Config) error { fmtdata, err := format.Source(fdata) if err != nil { // write anyway for examination - _ = ioutil.WriteFile(gopath, fdata, 0644) + _ = os.WriteFile(gopath, fdata, 0644) return fmt.Errorf("error formatting %s: %v", filepath.Base(gofile), err) } - err = ioutil.WriteFile(gopath, fmtdata, 0644) + err = os.WriteFile(gopath, fmtdata, 0644) if err != nil { return err } diff --git a/translate_test.go b/translate_test.go index c8c1752..6232a81 100644 --- a/translate_test.go +++ b/translate_test.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "math" "math/rand" "os" @@ -87,7 +86,7 @@ type runConfig struct { } func goRun(t testing.TB, wd string, files []string, c runConfig, args ...string) []byte { - f, err := ioutil.TempFile("", "cxgo_bin_") + f, err := os.CreateTemp("", "cxgo_bin_") require.NoError(t, err) _ = f.Close() bin := f.Name() @@ -322,7 +321,7 @@ func TestImplicitCompat(t *testing.T) { } func testTranspileOut(t testing.TB, csrc string) { - dir, err := ioutil.TempDir("", "cxgo_cout") + dir, err := os.MkdirTemp("", "cxgo_cout") require.NoError(t, err) defer os.RemoveAll(dir) @@ -331,7 +330,7 @@ func testTranspileOut(t testing.TB, csrc string) { require.NoError(t, err) cfile := filepath.Join(cdir, "main.c") - err = ioutil.WriteFile(cfile, []byte(csrc), 0644) + err = os.WriteFile(cfile, []byte(csrc), 0644) require.NoError(t, err) // this is required for test to wait other goroutines in case it fails earlier on the main one diff --git a/vfs.go b/vfs.go index 46bcb44..88a20b9 100644 --- a/vfs.go +++ b/vfs.go @@ -2,7 +2,6 @@ package cxgo import ( "io" - "io/ioutil" "os" "strings" "time" @@ -48,7 +47,7 @@ func (fs includeFS) Open(path string, sys bool) (io.ReadCloser, error) { if err != nil { return nil, err } - return ioutil.NopCloser(strings.NewReader(data)), nil + return io.NopCloser(strings.NewReader(data)), nil } type includeFI struct {