* update revive lint to latest commit * make fmt * change importtags/v1.13.0-rc1
@@ -11,12 +11,12 @@ package main | |||
import ( | |||
// for lint | |||
_ "github.com/BurntSushi/toml" | |||
_ "github.com/mgechev/dots" | |||
_ "github.com/mgechev/revive/formatter" | |||
_ "github.com/mgechev/revive/lint" | |||
_ "github.com/mgechev/revive/rule" | |||
_ "github.com/mitchellh/go-homedir" | |||
_ "github.com/pelletier/go-toml" | |||
// for embed | |||
_ "github.com/shurcooL/vfsgen" |
@@ -15,12 +15,12 @@ import ( | |||
"path/filepath" | |||
"strings" | |||
"github.com/BurntSushi/toml" | |||
"github.com/mgechev/dots" | |||
"github.com/mgechev/revive/formatter" | |||
"github.com/mgechev/revive/lint" | |||
"github.com/mgechev/revive/rule" | |||
"github.com/mitchellh/go-homedir" | |||
"github.com/pelletier/go-toml" | |||
) | |||
func fail(err string) { | |||
@@ -133,7 +133,7 @@ func parseConfig(path string) *lint.Config { | |||
if err != nil { | |||
fail("cannot read the config file") | |||
} | |||
_, err = toml.Decode(string(file), config) | |||
err = toml.Unmarshal(file, config) | |||
if err != nil { | |||
fail("cannot parse the config file: " + err.Error()) | |||
} |
@@ -16,7 +16,6 @@ require ( | |||
gitea.com/macaron/macaron v1.5.0 | |||
gitea.com/macaron/session v0.0.0-20200902202411-e3a87877db6e | |||
gitea.com/macaron/toolbox v0.0.0-20190822013122-05ff0fc766b7 | |||
github.com/BurntSushi/toml v0.3.1 | |||
github.com/PuerkitoBio/goquery v1.5.1 | |||
github.com/alecthomas/chroma v0.8.0 | |||
github.com/blevesearch/bleve v1.0.10 | |||
@@ -63,10 +62,12 @@ require ( | |||
github.com/lib/pq v1.8.1-0.20200908161135-083382b7e6fc | |||
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96 | |||
github.com/markbates/goth v1.61.2 | |||
github.com/mattn/go-colorable v0.1.7 // indirect | |||
github.com/mattn/go-isatty v0.0.12 | |||
github.com/mattn/go-runewidth v0.0.9 // indirect | |||
github.com/mattn/go-sqlite3 v1.14.0 | |||
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 | |||
github.com/mgechev/revive v1.0.2 | |||
github.com/mgechev/revive v1.0.3-0.20200921231451-246eac737dc7 | |||
github.com/mholt/archiver/v3 v3.3.0 | |||
github.com/microcosm-cc/bluemonday v1.0.3-0.20191119130333-0a75d7616912 | |||
github.com/minio/minio-go/v7 v7.0.4 | |||
@@ -76,6 +77,7 @@ require ( | |||
github.com/niklasfasching/go-org v1.3.2 | |||
github.com/oliamb/cutter v0.2.2 | |||
github.com/olivere/elastic/v7 v7.0.9 | |||
github.com/pelletier/go-toml v1.8.1 | |||
github.com/pkg/errors v0.9.1 | |||
github.com/pquerna/otp v1.2.0 | |||
github.com/prometheus/client_golang v1.1.0 | |||
@@ -102,10 +104,10 @@ require ( | |||
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a | |||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 | |||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d | |||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae | |||
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff | |||
golang.org/x/text v0.3.3 | |||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect | |||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d | |||
golang.org/x/tools v0.0.0-20200921210052-fa0125251cc4 | |||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect | |||
gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect | |||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df |
@@ -265,7 +265,6 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9 | |||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= | |||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= | |||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= | |||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= | |||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= | |||
github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= | |||
github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= | |||
@@ -647,6 +646,8 @@ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaa | |||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= | |||
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= | |||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | |||
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= | |||
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | |||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= | |||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= | |||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | |||
@@ -659,6 +660,8 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX | |||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | |||
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= | |||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= | |||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= | |||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= | |||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= | |||
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= | |||
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= | |||
@@ -667,8 +670,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j | |||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= | |||
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 h1:QASJXOGm2RZ5Ardbc86qNFvby9AqkLDibfChMtAg5QM= | |||
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= | |||
github.com/mgechev/revive v1.0.2 h1:v0NxxQ7fSFz/u1NQydPo6EGdq7va0J1BtsZmae6kzUg= | |||
github.com/mgechev/revive v1.0.2/go.mod h1:rb0dQy1LVAxW9SWy5R3LPUjevzUbUS316U5MFySA2lo= | |||
github.com/mgechev/revive v1.0.3-0.20200921231451-246eac737dc7 h1:ydVkpU/M4/c45yT3e5lzMeguKJm9GxGgsawx4/XlwK0= | |||
github.com/mgechev/revive v1.0.3-0.20200921231451-246eac737dc7/go.mod h1:no/hfevHbndpXR5CaJahkYCfM/FFpmM/dSOwFGU7Z1o= | |||
github.com/mholt/archiver/v3 v3.3.0 h1:vWjhY8SQp5yzM9P6OJ/eZEkmi3UAbRrxCq48MxjAzig= | |||
github.com/mholt/archiver/v3 v3.3.0/go.mod h1:YnQtqsp+94Rwd0D/rk5cnLrxusUBUXg+08Ebtr1Mqao= | |||
github.com/microcosm-cc/bluemonday v1.0.3-0.20191119130333-0a75d7616912 h1:hJde9rA24hlTcAYSwJoXpDUyGtfKQ/jsofw+WaDqGrI= | |||
@@ -739,6 +742,8 @@ github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfS | |||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= | |||
github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= | |||
github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= | |||
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= | |||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= | |||
github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= | |||
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= | |||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= | |||
@@ -981,7 +986,6 @@ golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU | |||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= | |||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= | |||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= | |||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= | |||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | |||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= | |||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | |||
@@ -1017,6 +1021,7 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ | |||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | |||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= | |||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= | |||
golang.org/x/oauth2 v0.0.0-20180620175406-ef147856a6dd/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | |||
@@ -1075,6 +1080,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w | |||
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= | |||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff h1:1CPUrky56AcgSpxz/KfgzQWzfG09u5YOL8MvPYBlrL8= | |||
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | |||
@@ -1114,17 +1121,18 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn | |||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | |||
golang.org/x/tools v0.0.0-20200225230052-807dcd883420/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= | |||
golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= | |||
golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= | |||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d h1:W07d4xkoAUSNOkOzdzXCdFGxT7o2rW4q8M34tB2i//k= | |||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= | |||
golang.org/x/tools v0.0.0-20200921210052-fa0125251cc4 h1:v8Jgq9X6Es9K9otVr9jxENEJigepKMZgA9OmrIZDtFA= | |||
golang.org/x/tools v0.0.0-20200921210052-fa0125251cc4/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= | |||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | |||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= | |||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= | |||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= | |||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= | |||
@@ -1219,7 +1227,6 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh | |||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | |||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | |||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= | |||
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= | |||
mvdan.cc/xurls/v2 v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA= | |||
mvdan.cc/xurls/v2 v2.1.0/go.mod h1:5GrSd9rOnKOpZaji1OZLYL/yeAAtGDlo/cFe+8K5n8E= | |||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= |
@@ -10,6 +10,7 @@ import ( | |||
"os" | |||
"strconv" | |||
"strings" | |||
"sync" | |||
"syscall" | |||
"unsafe" | |||
@@ -27,6 +28,7 @@ const ( | |||
backgroundRed = 0x40 | |||
backgroundIntensity = 0x80 | |||
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity) | |||
commonLvbUnderscore = 0x8000 | |||
cENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 | |||
) | |||
@@ -93,6 +95,7 @@ type Writer struct { | |||
oldattr word | |||
oldpos coord | |||
rest bytes.Buffer | |||
mutex sync.Mutex | |||
} | |||
// NewColorable returns new instance of Writer which handles escape sequence from File. | |||
@@ -432,6 +435,8 @@ func atoiWithDefault(s string, def int) (int, error) { | |||
// Write writes data on console | |||
func (w *Writer) Write(data []byte) (n int, err error) { | |||
w.mutex.Lock() | |||
defer w.mutex.Unlock() | |||
var csbi consoleScreenBufferInfo | |||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi))) | |||
@@ -683,14 +688,19 @@ loop: | |||
switch { | |||
case n == 0 || n == 100: | |||
attr = w.oldattr | |||
case 1 <= n && n <= 5: | |||
case n == 4: | |||
attr |= commonLvbUnderscore | |||
case (1 <= n && n <= 3) || n == 5: | |||
attr |= foregroundIntensity | |||
case n == 7: | |||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) | |||
case n == 22 || n == 25: | |||
attr |= foregroundIntensity | |||
case n == 27: | |||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4) | |||
case n == 7 || n == 27: | |||
attr = | |||
(attr &^ (foregroundMask | backgroundMask)) | | |||
((attr & foregroundMask) << 4) | | |||
((attr & backgroundMask) >> 4) | |||
case n == 22: | |||
attr &^= foregroundIntensity | |||
case n == 24: | |||
attr &^= commonLvbUnderscore | |||
case 30 <= n && n <= 37: | |||
attr &= backgroundMask | |||
if (n-30)&1 != 0 { |
@@ -1,8 +1,16 @@ | |||
language: go | |||
sudo: false | |||
go: | |||
- 1.13.x | |||
- tip | |||
before_install: | |||
- go get github.com/mattn/goveralls | |||
- go get golang.org/x/tools/cmd/cover | |||
- go get -t -v ./... | |||
script: | |||
- $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL | |||
- go generate | |||
- git diff --cached --exit-code | |||
- ./go.test.sh | |||
after_success: | |||
- bash <(curl -s https://codecov.io/bash) |
@@ -2,7 +2,7 @@ go-runewidth | |||
============ | |||
[![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) | |||
[![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) | |||
[![Codecov](https://codecov.io/gh/mattn/go-runewidth/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-runewidth) | |||
[![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) | |||
[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) | |||
@@ -0,0 +1,12 @@ | |||
#!/usr/bin/env bash | |||
set -e | |||
echo "" > coverage.txt | |||
for d in $(go list ./... | grep -v vendor); do | |||
go test -race -coverprofile=profile.out -covermode=atomic "$d" | |||
if [ -f profile.out ]; then | |||
cat profile.out >> coverage.txt | |||
rm profile.out | |||
fi | |||
done |
@@ -50,7 +50,6 @@ func inTables(r rune, ts ...table) bool { | |||
} | |||
func inTable(r rune, t table) bool { | |||
// func (t table) IncludesRune(r rune) bool { | |||
if r < t[0].first { | |||
return false | |||
} |
@@ -62,7 +62,10 @@ func isEastAsian(locale string) bool { | |||
// IsEastAsian return true if the current locale is CJK | |||
func IsEastAsian() bool { | |||
locale := os.Getenv("LC_CTYPE") | |||
locale := os.Getenv("LC_ALL") | |||
if locale == "" { | |||
locale = os.Getenv("LC_CTYPE") | |||
} | |||
if locale == "" { | |||
locale = os.Getenv("LANG") | |||
} |
@@ -1,20 +1,23 @@ | |||
// Code generated by script/generate.go. DO NOT EDIT. | |||
package runewidth | |||
var combining = table{ | |||
{0x0300, 0x036F}, {0x0483, 0x0489}, {0x07EB, 0x07F3}, | |||
{0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0D00, 0x0D01}, | |||
{0x135D, 0x135F}, {0x1A7F, 0x1A7F}, {0x1AB0, 0x1ABE}, | |||
{0x135D, 0x135F}, {0x1A7F, 0x1A7F}, {0x1AB0, 0x1AC0}, | |||
{0x1B6B, 0x1B73}, {0x1DC0, 0x1DF9}, {0x1DFB, 0x1DFF}, | |||
{0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2DE0, 0x2DFF}, | |||
{0x3099, 0x309A}, {0xA66F, 0xA672}, {0xA674, 0xA67D}, | |||
{0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, {0xA8E0, 0xA8F1}, | |||
{0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, {0x10376, 0x1037A}, | |||
{0x10F46, 0x10F50}, {0x11300, 0x11301}, {0x1133B, 0x1133C}, | |||
{0x11366, 0x1136C}, {0x11370, 0x11374}, {0x16AF0, 0x16AF4}, | |||
{0x1D165, 0x1D169}, {0x1D16D, 0x1D172}, {0x1D17B, 0x1D182}, | |||
{0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, {0x1D242, 0x1D244}, | |||
{0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, | |||
{0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E8D0, 0x1E8D6}, | |||
{0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, {0x11300, 0x11301}, | |||
{0x1133B, 0x1133C}, {0x11366, 0x1136C}, {0x11370, 0x11374}, | |||
{0x16AF0, 0x16AF4}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172}, | |||
{0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, | |||
{0x1D242, 0x1D244}, {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, | |||
{0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, | |||
{0x1E8D0, 0x1E8D6}, | |||
} | |||
var doublewidth = table{ | |||
@@ -32,29 +35,30 @@ var doublewidth = table{ | |||
{0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99}, | |||
{0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, | |||
{0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF}, | |||
{0x3105, 0x312F}, {0x3131, 0x318E}, {0x3190, 0x31BA}, | |||
{0x31C0, 0x31E3}, {0x31F0, 0x321E}, {0x3220, 0x3247}, | |||
{0x3250, 0x4DBF}, {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, | |||
{0xA960, 0xA97C}, {0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, | |||
{0xFE10, 0xFE19}, {0xFE30, 0xFE52}, {0xFE54, 0xFE66}, | |||
{0xFE68, 0xFE6B}, {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6}, | |||
{0x16FE0, 0x16FE3}, {0x17000, 0x187F7}, {0x18800, 0x18AF2}, | |||
{0x1B000, 0x1B11E}, {0x1B150, 0x1B152}, {0x1B164, 0x1B167}, | |||
{0x1B170, 0x1B2FB}, {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, | |||
{0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, {0x1F200, 0x1F202}, | |||
{0x1F210, 0x1F23B}, {0x1F240, 0x1F248}, {0x1F250, 0x1F251}, | |||
{0x1F260, 0x1F265}, {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, | |||
{0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, | |||
{0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4}, | |||
{0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, | |||
{0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, | |||
{0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, | |||
{0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, | |||
{0x1F6D0, 0x1F6D2}, {0x1F6D5, 0x1F6D5}, {0x1F6EB, 0x1F6EC}, | |||
{0x1F6F4, 0x1F6FA}, {0x1F7E0, 0x1F7EB}, {0x1F90D, 0x1F971}, | |||
{0x1F973, 0x1F976}, {0x1F97A, 0x1F9A2}, {0x1F9A5, 0x1F9AA}, | |||
{0x1F9AE, 0x1F9CA}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA73}, | |||
{0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA82}, {0x1FA90, 0x1FA95}, | |||
{0x3105, 0x312F}, {0x3131, 0x318E}, {0x3190, 0x31E3}, | |||
{0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x4DBF}, | |||
{0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C}, | |||
{0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, | |||
{0xFE30, 0xFE52}, {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, | |||
{0xFF01, 0xFF60}, {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE4}, | |||
{0x16FF0, 0x16FF1}, {0x17000, 0x187F7}, {0x18800, 0x18CD5}, | |||
{0x18D00, 0x18D08}, {0x1B000, 0x1B11E}, {0x1B150, 0x1B152}, | |||
{0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F004, 0x1F004}, | |||
{0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, | |||
{0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248}, | |||
{0x1F250, 0x1F251}, {0x1F260, 0x1F265}, {0x1F300, 0x1F320}, | |||
{0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, | |||
{0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, | |||
{0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, | |||
{0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, | |||
{0x1F550, 0x1F567}, {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, | |||
{0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, | |||
{0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2}, {0x1F6D5, 0x1F6D7}, | |||
{0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB}, | |||
{0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F978}, | |||
{0x1F97A, 0x1F9CB}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA74}, | |||
{0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA86}, {0x1FA90, 0x1FAA8}, | |||
{0x1FAB0, 0x1FAB6}, {0x1FAC0, 0x1FAC2}, {0x1FAD0, 0x1FAD6}, | |||
{0x20000, 0x2FFFD}, {0x30000, 0x3FFFD}, | |||
} | |||
@@ -151,7 +155,7 @@ var neutral = table{ | |||
{0x0600, 0x061C}, {0x061E, 0x070D}, {0x070F, 0x074A}, | |||
{0x074D, 0x07B1}, {0x07C0, 0x07FA}, {0x07FD, 0x082D}, | |||
{0x0830, 0x083E}, {0x0840, 0x085B}, {0x085E, 0x085E}, | |||
{0x0860, 0x086A}, {0x08A0, 0x08B4}, {0x08B6, 0x08BD}, | |||
{0x0860, 0x086A}, {0x08A0, 0x08B4}, {0x08B6, 0x08C7}, | |||
{0x08D3, 0x0983}, {0x0985, 0x098C}, {0x098F, 0x0990}, | |||
{0x0993, 0x09A8}, {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, | |||
{0x09B6, 0x09B9}, {0x09BC, 0x09C4}, {0x09C7, 0x09C8}, | |||
@@ -170,7 +174,7 @@ var neutral = table{ | |||
{0x0B05, 0x0B0C}, {0x0B0F, 0x0B10}, {0x0B13, 0x0B28}, | |||
{0x0B2A, 0x0B30}, {0x0B32, 0x0B33}, {0x0B35, 0x0B39}, | |||
{0x0B3C, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4D}, | |||
{0x0B56, 0x0B57}, {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63}, | |||
{0x0B55, 0x0B57}, {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63}, | |||
{0x0B66, 0x0B77}, {0x0B82, 0x0B83}, {0x0B85, 0x0B8A}, | |||
{0x0B8E, 0x0B90}, {0x0B92, 0x0B95}, {0x0B99, 0x0B9A}, | |||
{0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F}, {0x0BA3, 0x0BA4}, | |||
@@ -184,166 +188,169 @@ var neutral = table{ | |||
{0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9}, | |||
{0x0CBC, 0x0CC4}, {0x0CC6, 0x0CC8}, {0x0CCA, 0x0CCD}, | |||
{0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE3}, | |||
{0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, {0x0D00, 0x0D03}, | |||
{0x0D05, 0x0D0C}, {0x0D0E, 0x0D10}, {0x0D12, 0x0D44}, | |||
{0x0D46, 0x0D48}, {0x0D4A, 0x0D4F}, {0x0D54, 0x0D63}, | |||
{0x0D66, 0x0D7F}, {0x0D82, 0x0D83}, {0x0D85, 0x0D96}, | |||
{0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD}, | |||
{0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD4}, | |||
{0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF}, {0x0DE6, 0x0DEF}, | |||
{0x0DF2, 0x0DF4}, {0x0E01, 0x0E3A}, {0x0E3F, 0x0E5B}, | |||
{0x0E81, 0x0E82}, {0x0E84, 0x0E84}, {0x0E86, 0x0E8A}, | |||
{0x0E8C, 0x0EA3}, {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EBD}, | |||
{0x0EC0, 0x0EC4}, {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECD}, | |||
{0x0ED0, 0x0ED9}, {0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, | |||
{0x0F49, 0x0F6C}, {0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, | |||
{0x0FBE, 0x0FCC}, {0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, | |||
{0x10C7, 0x10C7}, {0x10CD, 0x10CD}, {0x10D0, 0x10FF}, | |||
{0x1160, 0x1248}, {0x124A, 0x124D}, {0x1250, 0x1256}, | |||
{0x1258, 0x1258}, {0x125A, 0x125D}, {0x1260, 0x1288}, | |||
{0x128A, 0x128D}, {0x1290, 0x12B0}, {0x12B2, 0x12B5}, | |||
{0x12B8, 0x12BE}, {0x12C0, 0x12C0}, {0x12C2, 0x12C5}, | |||
{0x12C8, 0x12D6}, {0x12D8, 0x1310}, {0x1312, 0x1315}, | |||
{0x1318, 0x135A}, {0x135D, 0x137C}, {0x1380, 0x1399}, | |||
{0x13A0, 0x13F5}, {0x13F8, 0x13FD}, {0x1400, 0x169C}, | |||
{0x16A0, 0x16F8}, {0x1700, 0x170C}, {0x170E, 0x1714}, | |||
{0x1720, 0x1736}, {0x1740, 0x1753}, {0x1760, 0x176C}, | |||
{0x176E, 0x1770}, {0x1772, 0x1773}, {0x1780, 0x17DD}, | |||
{0x17E0, 0x17E9}, {0x17F0, 0x17F9}, {0x1800, 0x180E}, | |||
{0x1810, 0x1819}, {0x1820, 0x1878}, {0x1880, 0x18AA}, | |||
{0x18B0, 0x18F5}, {0x1900, 0x191E}, {0x1920, 0x192B}, | |||
{0x1930, 0x193B}, {0x1940, 0x1940}, {0x1944, 0x196D}, | |||
{0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9}, | |||
{0x19D0, 0x19DA}, {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E}, | |||
{0x1A60, 0x1A7C}, {0x1A7F, 0x1A89}, {0x1A90, 0x1A99}, | |||
{0x1AA0, 0x1AAD}, {0x1AB0, 0x1ABE}, {0x1B00, 0x1B4B}, | |||
{0x1B50, 0x1B7C}, {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37}, | |||
{0x1C3B, 0x1C49}, {0x1C4D, 0x1C88}, {0x1C90, 0x1CBA}, | |||
{0x1CBD, 0x1CC7}, {0x1CD0, 0x1CFA}, {0x1D00, 0x1DF9}, | |||
{0x1DFB, 0x1F15}, {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, | |||
{0x1F48, 0x1F4D}, {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, | |||
{0x1F5B, 0x1F5B}, {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, | |||
{0x1F80, 0x1FB4}, {0x1FB6, 0x1FC4}, {0x1FC6, 0x1FD3}, | |||
{0x1FD6, 0x1FDB}, {0x1FDD, 0x1FEF}, {0x1FF2, 0x1FF4}, | |||
{0x1FF6, 0x1FFE}, {0x2000, 0x200F}, {0x2011, 0x2012}, | |||
{0x2017, 0x2017}, {0x201A, 0x201B}, {0x201E, 0x201F}, | |||
{0x2023, 0x2023}, {0x2028, 0x202F}, {0x2031, 0x2031}, | |||
{0x2034, 0x2034}, {0x2036, 0x203A}, {0x203C, 0x203D}, | |||
{0x203F, 0x2064}, {0x2066, 0x2071}, {0x2075, 0x207E}, | |||
{0x2080, 0x2080}, {0x2085, 0x208E}, {0x2090, 0x209C}, | |||
{0x20A0, 0x20A8}, {0x20AA, 0x20AB}, {0x20AD, 0x20BF}, | |||
{0x20D0, 0x20F0}, {0x2100, 0x2102}, {0x2104, 0x2104}, | |||
{0x2106, 0x2108}, {0x210A, 0x2112}, {0x2114, 0x2115}, | |||
{0x2117, 0x2120}, {0x2123, 0x2125}, {0x2127, 0x212A}, | |||
{0x212C, 0x2152}, {0x2155, 0x215A}, {0x215F, 0x215F}, | |||
{0x216C, 0x216F}, {0x217A, 0x2188}, {0x218A, 0x218B}, | |||
{0x219A, 0x21B7}, {0x21BA, 0x21D1}, {0x21D3, 0x21D3}, | |||
{0x21D5, 0x21E6}, {0x21E8, 0x21FF}, {0x2201, 0x2201}, | |||
{0x2204, 0x2206}, {0x2209, 0x220A}, {0x220C, 0x220E}, | |||
{0x2210, 0x2210}, {0x2212, 0x2214}, {0x2216, 0x2219}, | |||
{0x221B, 0x221C}, {0x2221, 0x2222}, {0x2224, 0x2224}, | |||
{0x2226, 0x2226}, {0x222D, 0x222D}, {0x222F, 0x2233}, | |||
{0x2238, 0x223B}, {0x223E, 0x2247}, {0x2249, 0x224B}, | |||
{0x224D, 0x2251}, {0x2253, 0x225F}, {0x2262, 0x2263}, | |||
{0x2268, 0x2269}, {0x226C, 0x226D}, {0x2270, 0x2281}, | |||
{0x2284, 0x2285}, {0x2288, 0x2294}, {0x2296, 0x2298}, | |||
{0x229A, 0x22A4}, {0x22A6, 0x22BE}, {0x22C0, 0x2311}, | |||
{0x2313, 0x2319}, {0x231C, 0x2328}, {0x232B, 0x23E8}, | |||
{0x23ED, 0x23EF}, {0x23F1, 0x23F2}, {0x23F4, 0x2426}, | |||
{0x2440, 0x244A}, {0x24EA, 0x24EA}, {0x254C, 0x254F}, | |||
{0x2574, 0x257F}, {0x2590, 0x2591}, {0x2596, 0x259F}, | |||
{0x25A2, 0x25A2}, {0x25AA, 0x25B1}, {0x25B4, 0x25B5}, | |||
{0x25B8, 0x25BB}, {0x25BE, 0x25BF}, {0x25C2, 0x25C5}, | |||
{0x25C9, 0x25CA}, {0x25CC, 0x25CD}, {0x25D2, 0x25E1}, | |||
{0x25E6, 0x25EE}, {0x25F0, 0x25FC}, {0x25FF, 0x2604}, | |||
{0x2607, 0x2608}, {0x260A, 0x260D}, {0x2610, 0x2613}, | |||
{0x2616, 0x261B}, {0x261D, 0x261D}, {0x261F, 0x263F}, | |||
{0x2641, 0x2641}, {0x2643, 0x2647}, {0x2654, 0x265F}, | |||
{0x2662, 0x2662}, {0x2666, 0x2666}, {0x266B, 0x266B}, | |||
{0x266E, 0x266E}, {0x2670, 0x267E}, {0x2680, 0x2692}, | |||
{0x2694, 0x269D}, {0x26A0, 0x26A0}, {0x26A2, 0x26A9}, | |||
{0x26AC, 0x26BC}, {0x26C0, 0x26C3}, {0x26E2, 0x26E2}, | |||
{0x26E4, 0x26E7}, {0x2700, 0x2704}, {0x2706, 0x2709}, | |||
{0x270C, 0x2727}, {0x2729, 0x273C}, {0x273E, 0x274B}, | |||
{0x274D, 0x274D}, {0x274F, 0x2752}, {0x2756, 0x2756}, | |||
{0x2758, 0x2775}, {0x2780, 0x2794}, {0x2798, 0x27AF}, | |||
{0x27B1, 0x27BE}, {0x27C0, 0x27E5}, {0x27EE, 0x2984}, | |||
{0x2987, 0x2B1A}, {0x2B1D, 0x2B4F}, {0x2B51, 0x2B54}, | |||
{0x2B5A, 0x2B73}, {0x2B76, 0x2B95}, {0x2B98, 0x2C2E}, | |||
{0x2C30, 0x2C5E}, {0x2C60, 0x2CF3}, {0x2CF9, 0x2D25}, | |||
{0x2D27, 0x2D27}, {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, | |||
{0x2D6F, 0x2D70}, {0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6}, | |||
{0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE}, | |||
{0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6}, | |||
{0x2DD8, 0x2DDE}, {0x2DE0, 0x2E4F}, {0x303F, 0x303F}, | |||
{0x4DC0, 0x4DFF}, {0xA4D0, 0xA62B}, {0xA640, 0xA6F7}, | |||
{0xA700, 0xA7BF}, {0xA7C2, 0xA7C6}, {0xA7F7, 0xA82B}, | |||
{0xA830, 0xA839}, {0xA840, 0xA877}, {0xA880, 0xA8C5}, | |||
{0xA8CE, 0xA8D9}, {0xA8E0, 0xA953}, {0xA95F, 0xA95F}, | |||
{0xA980, 0xA9CD}, {0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, | |||
{0xAA00, 0xAA36}, {0xAA40, 0xAA4D}, {0xAA50, 0xAA59}, | |||
{0xAA5C, 0xAAC2}, {0xAADB, 0xAAF6}, {0xAB01, 0xAB06}, | |||
{0xAB09, 0xAB0E}, {0xAB11, 0xAB16}, {0xAB20, 0xAB26}, | |||
{0xAB28, 0xAB2E}, {0xAB30, 0xAB67}, {0xAB70, 0xABED}, | |||
{0xABF0, 0xABF9}, {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, | |||
{0xD800, 0xDFFF}, {0xFB00, 0xFB06}, {0xFB13, 0xFB17}, | |||
{0xFB1D, 0xFB36}, {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, | |||
{0xFB40, 0xFB41}, {0xFB43, 0xFB44}, {0xFB46, 0xFBC1}, | |||
{0xFBD3, 0xFD3F}, {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, | |||
{0xFDF0, 0xFDFD}, {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, | |||
{0xFE76, 0xFEFC}, {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, | |||
{0x10000, 0x1000B}, {0x1000D, 0x10026}, {0x10028, 0x1003A}, | |||
{0x1003C, 0x1003D}, {0x1003F, 0x1004D}, {0x10050, 0x1005D}, | |||
{0x10080, 0x100FA}, {0x10100, 0x10102}, {0x10107, 0x10133}, | |||
{0x10137, 0x1018E}, {0x10190, 0x1019B}, {0x101A0, 0x101A0}, | |||
{0x101D0, 0x101FD}, {0x10280, 0x1029C}, {0x102A0, 0x102D0}, | |||
{0x102E0, 0x102FB}, {0x10300, 0x10323}, {0x1032D, 0x1034A}, | |||
{0x10350, 0x1037A}, {0x10380, 0x1039D}, {0x1039F, 0x103C3}, | |||
{0x103C8, 0x103D5}, {0x10400, 0x1049D}, {0x104A0, 0x104A9}, | |||
{0x104B0, 0x104D3}, {0x104D8, 0x104FB}, {0x10500, 0x10527}, | |||
{0x10530, 0x10563}, {0x1056F, 0x1056F}, {0x10600, 0x10736}, | |||
{0x10740, 0x10755}, {0x10760, 0x10767}, {0x10800, 0x10805}, | |||
{0x10808, 0x10808}, {0x1080A, 0x10835}, {0x10837, 0x10838}, | |||
{0x1083C, 0x1083C}, {0x1083F, 0x10855}, {0x10857, 0x1089E}, | |||
{0x108A7, 0x108AF}, {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, | |||
{0x108FB, 0x1091B}, {0x1091F, 0x10939}, {0x1093F, 0x1093F}, | |||
{0x10980, 0x109B7}, {0x109BC, 0x109CF}, {0x109D2, 0x10A03}, | |||
{0x10A05, 0x10A06}, {0x10A0C, 0x10A13}, {0x10A15, 0x10A17}, | |||
{0x10A19, 0x10A35}, {0x10A38, 0x10A3A}, {0x10A3F, 0x10A48}, | |||
{0x10A50, 0x10A58}, {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6}, | |||
{0x10AEB, 0x10AF6}, {0x10B00, 0x10B35}, {0x10B39, 0x10B55}, | |||
{0x10B58, 0x10B72}, {0x10B78, 0x10B91}, {0x10B99, 0x10B9C}, | |||
{0x10BA9, 0x10BAF}, {0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, | |||
{0x10CC0, 0x10CF2}, {0x10CFA, 0x10D27}, {0x10D30, 0x10D39}, | |||
{0x10E60, 0x10E7E}, {0x10F00, 0x10F27}, {0x10F30, 0x10F59}, | |||
{0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, {0x0D00, 0x0D0C}, | |||
{0x0D0E, 0x0D10}, {0x0D12, 0x0D44}, {0x0D46, 0x0D48}, | |||
{0x0D4A, 0x0D4F}, {0x0D54, 0x0D63}, {0x0D66, 0x0D7F}, | |||
{0x0D81, 0x0D83}, {0x0D85, 0x0D96}, {0x0D9A, 0x0DB1}, | |||
{0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD}, {0x0DC0, 0x0DC6}, | |||
{0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD4}, {0x0DD6, 0x0DD6}, | |||
{0x0DD8, 0x0DDF}, {0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF4}, | |||
{0x0E01, 0x0E3A}, {0x0E3F, 0x0E5B}, {0x0E81, 0x0E82}, | |||
{0x0E84, 0x0E84}, {0x0E86, 0x0E8A}, {0x0E8C, 0x0EA3}, | |||
{0x0EA5, 0x0EA5}, {0x0EA7, 0x0EBD}, {0x0EC0, 0x0EC4}, | |||
{0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, | |||
{0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, {0x0F49, 0x0F6C}, | |||
{0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FBE, 0x0FCC}, | |||
{0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, {0x10C7, 0x10C7}, | |||
{0x10CD, 0x10CD}, {0x10D0, 0x10FF}, {0x1160, 0x1248}, | |||
{0x124A, 0x124D}, {0x1250, 0x1256}, {0x1258, 0x1258}, | |||
{0x125A, 0x125D}, {0x1260, 0x1288}, {0x128A, 0x128D}, | |||
{0x1290, 0x12B0}, {0x12B2, 0x12B5}, {0x12B8, 0x12BE}, | |||
{0x12C0, 0x12C0}, {0x12C2, 0x12C5}, {0x12C8, 0x12D6}, | |||
{0x12D8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135A}, | |||
{0x135D, 0x137C}, {0x1380, 0x1399}, {0x13A0, 0x13F5}, | |||
{0x13F8, 0x13FD}, {0x1400, 0x169C}, {0x16A0, 0x16F8}, | |||
{0x1700, 0x170C}, {0x170E, 0x1714}, {0x1720, 0x1736}, | |||
{0x1740, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770}, | |||
{0x1772, 0x1773}, {0x1780, 0x17DD}, {0x17E0, 0x17E9}, | |||
{0x17F0, 0x17F9}, {0x1800, 0x180E}, {0x1810, 0x1819}, | |||
{0x1820, 0x1878}, {0x1880, 0x18AA}, {0x18B0, 0x18F5}, | |||
{0x1900, 0x191E}, {0x1920, 0x192B}, {0x1930, 0x193B}, | |||
{0x1940, 0x1940}, {0x1944, 0x196D}, {0x1970, 0x1974}, | |||
{0x1980, 0x19AB}, {0x19B0, 0x19C9}, {0x19D0, 0x19DA}, | |||
{0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E}, {0x1A60, 0x1A7C}, | |||
{0x1A7F, 0x1A89}, {0x1A90, 0x1A99}, {0x1AA0, 0x1AAD}, | |||
{0x1AB0, 0x1AC0}, {0x1B00, 0x1B4B}, {0x1B50, 0x1B7C}, | |||
{0x1B80, 0x1BF3}, {0x1BFC, 0x1C37}, {0x1C3B, 0x1C49}, | |||
{0x1C4D, 0x1C88}, {0x1C90, 0x1CBA}, {0x1CBD, 0x1CC7}, | |||
{0x1CD0, 0x1CFA}, {0x1D00, 0x1DF9}, {0x1DFB, 0x1F15}, | |||
{0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D}, | |||
{0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B}, | |||
{0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4}, | |||
{0x1FB6, 0x1FC4}, {0x1FC6, 0x1FD3}, {0x1FD6, 0x1FDB}, | |||
{0x1FDD, 0x1FEF}, {0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFE}, | |||
{0x2000, 0x200F}, {0x2011, 0x2012}, {0x2017, 0x2017}, | |||
{0x201A, 0x201B}, {0x201E, 0x201F}, {0x2023, 0x2023}, | |||
{0x2028, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034}, | |||
{0x2036, 0x203A}, {0x203C, 0x203D}, {0x203F, 0x2064}, | |||
{0x2066, 0x2071}, {0x2075, 0x207E}, {0x2080, 0x2080}, | |||
{0x2085, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8}, | |||
{0x20AA, 0x20AB}, {0x20AD, 0x20BF}, {0x20D0, 0x20F0}, | |||
{0x2100, 0x2102}, {0x2104, 0x2104}, {0x2106, 0x2108}, | |||
{0x210A, 0x2112}, {0x2114, 0x2115}, {0x2117, 0x2120}, | |||
{0x2123, 0x2125}, {0x2127, 0x212A}, {0x212C, 0x2152}, | |||
{0x2155, 0x215A}, {0x215F, 0x215F}, {0x216C, 0x216F}, | |||
{0x217A, 0x2188}, {0x218A, 0x218B}, {0x219A, 0x21B7}, | |||
{0x21BA, 0x21D1}, {0x21D3, 0x21D3}, {0x21D5, 0x21E6}, | |||
{0x21E8, 0x21FF}, {0x2201, 0x2201}, {0x2204, 0x2206}, | |||
{0x2209, 0x220A}, {0x220C, 0x220E}, {0x2210, 0x2210}, | |||
{0x2212, 0x2214}, {0x2216, 0x2219}, {0x221B, 0x221C}, | |||
{0x2221, 0x2222}, {0x2224, 0x2224}, {0x2226, 0x2226}, | |||
{0x222D, 0x222D}, {0x222F, 0x2233}, {0x2238, 0x223B}, | |||
{0x223E, 0x2247}, {0x2249, 0x224B}, {0x224D, 0x2251}, | |||
{0x2253, 0x225F}, {0x2262, 0x2263}, {0x2268, 0x2269}, | |||
{0x226C, 0x226D}, {0x2270, 0x2281}, {0x2284, 0x2285}, | |||
{0x2288, 0x2294}, {0x2296, 0x2298}, {0x229A, 0x22A4}, | |||
{0x22A6, 0x22BE}, {0x22C0, 0x2311}, {0x2313, 0x2319}, | |||
{0x231C, 0x2328}, {0x232B, 0x23E8}, {0x23ED, 0x23EF}, | |||
{0x23F1, 0x23F2}, {0x23F4, 0x2426}, {0x2440, 0x244A}, | |||
{0x24EA, 0x24EA}, {0x254C, 0x254F}, {0x2574, 0x257F}, | |||
{0x2590, 0x2591}, {0x2596, 0x259F}, {0x25A2, 0x25A2}, | |||
{0x25AA, 0x25B1}, {0x25B4, 0x25B5}, {0x25B8, 0x25BB}, | |||
{0x25BE, 0x25BF}, {0x25C2, 0x25C5}, {0x25C9, 0x25CA}, | |||
{0x25CC, 0x25CD}, {0x25D2, 0x25E1}, {0x25E6, 0x25EE}, | |||
{0x25F0, 0x25FC}, {0x25FF, 0x2604}, {0x2607, 0x2608}, | |||
{0x260A, 0x260D}, {0x2610, 0x2613}, {0x2616, 0x261B}, | |||
{0x261D, 0x261D}, {0x261F, 0x263F}, {0x2641, 0x2641}, | |||
{0x2643, 0x2647}, {0x2654, 0x265F}, {0x2662, 0x2662}, | |||
{0x2666, 0x2666}, {0x266B, 0x266B}, {0x266E, 0x266E}, | |||
{0x2670, 0x267E}, {0x2680, 0x2692}, {0x2694, 0x269D}, | |||
{0x26A0, 0x26A0}, {0x26A2, 0x26A9}, {0x26AC, 0x26BC}, | |||
{0x26C0, 0x26C3}, {0x26E2, 0x26E2}, {0x26E4, 0x26E7}, | |||
{0x2700, 0x2704}, {0x2706, 0x2709}, {0x270C, 0x2727}, | |||
{0x2729, 0x273C}, {0x273E, 0x274B}, {0x274D, 0x274D}, | |||
{0x274F, 0x2752}, {0x2756, 0x2756}, {0x2758, 0x2775}, | |||
{0x2780, 0x2794}, {0x2798, 0x27AF}, {0x27B1, 0x27BE}, | |||
{0x27C0, 0x27E5}, {0x27EE, 0x2984}, {0x2987, 0x2B1A}, | |||
{0x2B1D, 0x2B4F}, {0x2B51, 0x2B54}, {0x2B5A, 0x2B73}, | |||
{0x2B76, 0x2B95}, {0x2B97, 0x2C2E}, {0x2C30, 0x2C5E}, | |||
{0x2C60, 0x2CF3}, {0x2CF9, 0x2D25}, {0x2D27, 0x2D27}, | |||
{0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D70}, | |||
{0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, | |||
{0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, | |||
{0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, | |||
{0x2DE0, 0x2E52}, {0x303F, 0x303F}, {0x4DC0, 0x4DFF}, | |||
{0xA4D0, 0xA62B}, {0xA640, 0xA6F7}, {0xA700, 0xA7BF}, | |||
{0xA7C2, 0xA7CA}, {0xA7F5, 0xA82C}, {0xA830, 0xA839}, | |||
{0xA840, 0xA877}, {0xA880, 0xA8C5}, {0xA8CE, 0xA8D9}, | |||
{0xA8E0, 0xA953}, {0xA95F, 0xA95F}, {0xA980, 0xA9CD}, | |||
{0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, {0xAA00, 0xAA36}, | |||
{0xAA40, 0xAA4D}, {0xAA50, 0xAA59}, {0xAA5C, 0xAAC2}, | |||
{0xAADB, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E}, | |||
{0xAB11, 0xAB16}, {0xAB20, 0xAB26}, {0xAB28, 0xAB2E}, | |||
{0xAB30, 0xAB6B}, {0xAB70, 0xABED}, {0xABF0, 0xABF9}, | |||
{0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDFFF}, | |||
{0xFB00, 0xFB06}, {0xFB13, 0xFB17}, {0xFB1D, 0xFB36}, | |||
{0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41}, | |||
{0xFB43, 0xFB44}, {0xFB46, 0xFBC1}, {0xFBD3, 0xFD3F}, | |||
{0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, {0xFDF0, 0xFDFD}, | |||
{0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC}, | |||
{0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, {0x10000, 0x1000B}, | |||
{0x1000D, 0x10026}, {0x10028, 0x1003A}, {0x1003C, 0x1003D}, | |||
{0x1003F, 0x1004D}, {0x10050, 0x1005D}, {0x10080, 0x100FA}, | |||
{0x10100, 0x10102}, {0x10107, 0x10133}, {0x10137, 0x1018E}, | |||
{0x10190, 0x1019C}, {0x101A0, 0x101A0}, {0x101D0, 0x101FD}, | |||
{0x10280, 0x1029C}, {0x102A0, 0x102D0}, {0x102E0, 0x102FB}, | |||
{0x10300, 0x10323}, {0x1032D, 0x1034A}, {0x10350, 0x1037A}, | |||
{0x10380, 0x1039D}, {0x1039F, 0x103C3}, {0x103C8, 0x103D5}, | |||
{0x10400, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3}, | |||
{0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563}, | |||
{0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755}, | |||
{0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808}, | |||
{0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C}, | |||
{0x1083F, 0x10855}, {0x10857, 0x1089E}, {0x108A7, 0x108AF}, | |||
{0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x1091B}, | |||
{0x1091F, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x109B7}, | |||
{0x109BC, 0x109CF}, {0x109D2, 0x10A03}, {0x10A05, 0x10A06}, | |||
{0x10A0C, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A35}, | |||
{0x10A38, 0x10A3A}, {0x10A3F, 0x10A48}, {0x10A50, 0x10A58}, | |||
{0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6}, {0x10AEB, 0x10AF6}, | |||
{0x10B00, 0x10B35}, {0x10B39, 0x10B55}, {0x10B58, 0x10B72}, | |||
{0x10B78, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF}, | |||
{0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2}, | |||
{0x10CFA, 0x10D27}, {0x10D30, 0x10D39}, {0x10E60, 0x10E7E}, | |||
{0x10E80, 0x10EA9}, {0x10EAB, 0x10EAD}, {0x10EB0, 0x10EB1}, | |||
{0x10F00, 0x10F27}, {0x10F30, 0x10F59}, {0x10FB0, 0x10FCB}, | |||
{0x10FE0, 0x10FF6}, {0x11000, 0x1104D}, {0x11052, 0x1106F}, | |||
{0x1107F, 0x110C1}, {0x110CD, 0x110CD}, {0x110D0, 0x110E8}, | |||
{0x110F0, 0x110F9}, {0x11100, 0x11134}, {0x11136, 0x11146}, | |||
{0x11150, 0x11176}, {0x11180, 0x111CD}, {0x111D0, 0x111DF}, | |||
{0x111E1, 0x111F4}, {0x11200, 0x11211}, {0x11213, 0x1123E}, | |||
{0x11280, 0x11286}, {0x11288, 0x11288}, {0x1128A, 0x1128D}, | |||
{0x1128F, 0x1129D}, {0x1129F, 0x112A9}, {0x112B0, 0x112EA}, | |||
{0x112F0, 0x112F9}, {0x11300, 0x11303}, {0x11305, 0x1130C}, | |||
{0x1130F, 0x11310}, {0x11313, 0x11328}, {0x1132A, 0x11330}, | |||
{0x11332, 0x11333}, {0x11335, 0x11339}, {0x1133B, 0x11344}, | |||
{0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11350, 0x11350}, | |||
{0x11357, 0x11357}, {0x1135D, 0x11363}, {0x11366, 0x1136C}, | |||
{0x11370, 0x11374}, {0x11400, 0x11459}, {0x1145B, 0x1145B}, | |||
{0x1145D, 0x1145F}, {0x11480, 0x114C7}, {0x114D0, 0x114D9}, | |||
{0x11580, 0x115B5}, {0x115B8, 0x115DD}, {0x11600, 0x11644}, | |||
{0x11650, 0x11659}, {0x11660, 0x1166C}, {0x11680, 0x116B8}, | |||
{0x116C0, 0x116C9}, {0x11700, 0x1171A}, {0x1171D, 0x1172B}, | |||
{0x11730, 0x1173F}, {0x11800, 0x1183B}, {0x118A0, 0x118F2}, | |||
{0x118FF, 0x118FF}, {0x119A0, 0x119A7}, {0x119AA, 0x119D7}, | |||
{0x119DA, 0x119E4}, {0x11A00, 0x11A47}, {0x11A50, 0x11AA2}, | |||
{0x11AC0, 0x11AF8}, {0x11C00, 0x11C08}, {0x11C0A, 0x11C36}, | |||
{0x11C38, 0x11C45}, {0x11C50, 0x11C6C}, {0x11C70, 0x11C8F}, | |||
{0x11C92, 0x11CA7}, {0x11CA9, 0x11CB6}, {0x11D00, 0x11D06}, | |||
{0x11D08, 0x11D09}, {0x11D0B, 0x11D36}, {0x11D3A, 0x11D3A}, | |||
{0x11D3C, 0x11D3D}, {0x11D3F, 0x11D47}, {0x11D50, 0x11D59}, | |||
{0x11D60, 0x11D65}, {0x11D67, 0x11D68}, {0x11D6A, 0x11D8E}, | |||
{0x11D90, 0x11D91}, {0x11D93, 0x11D98}, {0x11DA0, 0x11DA9}, | |||
{0x11EE0, 0x11EF8}, {0x11FC0, 0x11FF1}, {0x11FFF, 0x12399}, | |||
{0x110F0, 0x110F9}, {0x11100, 0x11134}, {0x11136, 0x11147}, | |||
{0x11150, 0x11176}, {0x11180, 0x111DF}, {0x111E1, 0x111F4}, | |||
{0x11200, 0x11211}, {0x11213, 0x1123E}, {0x11280, 0x11286}, | |||
{0x11288, 0x11288}, {0x1128A, 0x1128D}, {0x1128F, 0x1129D}, | |||
{0x1129F, 0x112A9}, {0x112B0, 0x112EA}, {0x112F0, 0x112F9}, | |||
{0x11300, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310}, | |||
{0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333}, | |||
{0x11335, 0x11339}, {0x1133B, 0x11344}, {0x11347, 0x11348}, | |||
{0x1134B, 0x1134D}, {0x11350, 0x11350}, {0x11357, 0x11357}, | |||
{0x1135D, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374}, | |||
{0x11400, 0x1145B}, {0x1145D, 0x11461}, {0x11480, 0x114C7}, | |||
{0x114D0, 0x114D9}, {0x11580, 0x115B5}, {0x115B8, 0x115DD}, | |||
{0x11600, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C}, | |||
{0x11680, 0x116B8}, {0x116C0, 0x116C9}, {0x11700, 0x1171A}, | |||
{0x1171D, 0x1172B}, {0x11730, 0x1173F}, {0x11800, 0x1183B}, | |||
{0x118A0, 0x118F2}, {0x118FF, 0x11906}, {0x11909, 0x11909}, | |||
{0x1190C, 0x11913}, {0x11915, 0x11916}, {0x11918, 0x11935}, | |||
{0x11937, 0x11938}, {0x1193B, 0x11946}, {0x11950, 0x11959}, | |||
{0x119A0, 0x119A7}, {0x119AA, 0x119D7}, {0x119DA, 0x119E4}, | |||
{0x11A00, 0x11A47}, {0x11A50, 0x11AA2}, {0x11AC0, 0x11AF8}, | |||
{0x11C00, 0x11C08}, {0x11C0A, 0x11C36}, {0x11C38, 0x11C45}, | |||
{0x11C50, 0x11C6C}, {0x11C70, 0x11C8F}, {0x11C92, 0x11CA7}, | |||
{0x11CA9, 0x11CB6}, {0x11D00, 0x11D06}, {0x11D08, 0x11D09}, | |||
{0x11D0B, 0x11D36}, {0x11D3A, 0x11D3A}, {0x11D3C, 0x11D3D}, | |||
{0x11D3F, 0x11D47}, {0x11D50, 0x11D59}, {0x11D60, 0x11D65}, | |||
{0x11D67, 0x11D68}, {0x11D6A, 0x11D8E}, {0x11D90, 0x11D91}, | |||
{0x11D93, 0x11D98}, {0x11DA0, 0x11DA9}, {0x11EE0, 0x11EF8}, | |||
{0x11FB0, 0x11FB0}, {0x11FC0, 0x11FF1}, {0x11FFF, 0x12399}, | |||
{0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543}, | |||
{0x13000, 0x1342E}, {0x13430, 0x13438}, {0x14400, 0x14646}, | |||
{0x16800, 0x16A38}, {0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, | |||
@@ -382,20 +389,22 @@ var neutral = table{ | |||
{0x1EEA5, 0x1EEA9}, {0x1EEAB, 0x1EEBB}, {0x1EEF0, 0x1EEF1}, | |||
{0x1F000, 0x1F003}, {0x1F005, 0x1F02B}, {0x1F030, 0x1F093}, | |||
{0x1F0A0, 0x1F0AE}, {0x1F0B1, 0x1F0BF}, {0x1F0C1, 0x1F0CE}, | |||
{0x1F0D1, 0x1F0F5}, {0x1F10B, 0x1F10C}, {0x1F12E, 0x1F12F}, | |||
{0x1F16A, 0x1F16C}, {0x1F1E6, 0x1F1FF}, {0x1F321, 0x1F32C}, | |||
{0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, {0x1F394, 0x1F39F}, | |||
{0x1F3CB, 0x1F3CE}, {0x1F3D4, 0x1F3DF}, {0x1F3F1, 0x1F3F3}, | |||
{0x1F3F5, 0x1F3F7}, {0x1F43F, 0x1F43F}, {0x1F441, 0x1F441}, | |||
{0x1F4FD, 0x1F4FE}, {0x1F53E, 0x1F54A}, {0x1F54F, 0x1F54F}, | |||
{0x1F568, 0x1F579}, {0x1F57B, 0x1F594}, {0x1F597, 0x1F5A3}, | |||
{0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F}, {0x1F6C6, 0x1F6CB}, | |||
{0x1F6CD, 0x1F6CF}, {0x1F6D3, 0x1F6D4}, {0x1F6E0, 0x1F6EA}, | |||
{0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, {0x1F780, 0x1F7D8}, | |||
{0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, {0x1F850, 0x1F859}, | |||
{0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, {0x1F900, 0x1F90B}, | |||
{0x1FA00, 0x1FA53}, {0x1FA60, 0x1FA6D}, {0xE0001, 0xE0001}, | |||
{0xE0020, 0xE007F}, | |||
{0x1F0D1, 0x1F0F5}, {0x1F10B, 0x1F10F}, {0x1F12E, 0x1F12F}, | |||
{0x1F16A, 0x1F16F}, {0x1F1AD, 0x1F1AD}, {0x1F1E6, 0x1F1FF}, | |||
{0x1F321, 0x1F32C}, {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, | |||
{0x1F394, 0x1F39F}, {0x1F3CB, 0x1F3CE}, {0x1F3D4, 0x1F3DF}, | |||
{0x1F3F1, 0x1F3F3}, {0x1F3F5, 0x1F3F7}, {0x1F43F, 0x1F43F}, | |||
{0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FE}, {0x1F53E, 0x1F54A}, | |||
{0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594}, | |||
{0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F}, | |||
{0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6D3, 0x1F6D4}, | |||
{0x1F6E0, 0x1F6EA}, {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, | |||
{0x1F780, 0x1F7D8}, {0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, | |||
{0x1F850, 0x1F859}, {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, | |||
{0x1F8B0, 0x1F8B1}, {0x1F900, 0x1F90B}, {0x1F93B, 0x1F93B}, | |||
{0x1F946, 0x1F946}, {0x1FA00, 0x1FA53}, {0x1FA60, 0x1FA6D}, | |||
{0x1FB00, 0x1FB92}, {0x1FB94, 0x1FBCA}, {0x1FBF0, 0x1FBF9}, | |||
{0xE0001, 0xE0001}, {0xE0020, 0xE007F}, | |||
} | |||
var emoji = table{ | |||
@@ -423,5 +432,6 @@ var emoji = table{ | |||
{0x1F546, 0x1F64F}, {0x1F680, 0x1F6FF}, {0x1F774, 0x1F77F}, | |||
{0x1F7D5, 0x1F7FF}, {0x1F80C, 0x1F80F}, {0x1F848, 0x1F84F}, | |||
{0x1F85A, 0x1F85F}, {0x1F888, 0x1F88F}, {0x1F8AE, 0x1F8FF}, | |||
{0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1FFFD}, | |||
{0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1FAFF}, | |||
{0x1FC00, 0x1FFFD}, | |||
} |
@@ -10,11 +10,6 @@ import ( | |||
"github.com/olekukonko/tablewriter" | |||
) | |||
var ( | |||
errorEmoji = color.RedString("✘") | |||
warningEmoji = color.YellowString("⚠") | |||
) | |||
var newLines = map[rune]bool{ | |||
0x000A: true, | |||
0x000B: true, | |||
@@ -25,6 +20,14 @@ var newLines = map[rune]bool{ | |||
0x2029: true, | |||
} | |||
func getErrorEmoji() string { | |||
return color.RedString("✘") | |||
} | |||
func getWarningEmoji() string { | |||
return color.YellowString("⚠") | |||
} | |||
// Friendly is an implementation of the Formatter interface | |||
// which formats the errors to JSON. | |||
type Friendly struct { | |||
@@ -68,9 +71,9 @@ func (f *Friendly) printFriendlyFailure(failure lint.Failure, severity lint.Seve | |||
} | |||
func (f *Friendly) printHeaderRow(failure lint.Failure, severity lint.Severity) { | |||
emoji := warningEmoji | |||
emoji := getWarningEmoji() | |||
if severity == lint.SeverityError { | |||
emoji = errorEmoji | |||
emoji = getErrorEmoji() | |||
} | |||
fmt.Print(f.table([][]string{{emoji, "https://revive.run/r#" + failure.RuleName, color.GreenString(failure.Failure)}})) | |||
} | |||
@@ -85,9 +88,9 @@ type statEntry struct { | |||
} | |||
func (f *Friendly) printSummary(errors, warnings int) { | |||
emoji := warningEmoji | |||
emoji := getWarningEmoji() | |||
if errors > 0 { | |||
emoji = errorEmoji | |||
emoji = getErrorEmoji() | |||
} | |||
problemsLabel := "problems" | |||
if errors+warnings == 1 { |
@@ -52,7 +52,7 @@ type cognitiveComplexityLinter struct { | |||
func (w cognitiveComplexityLinter) lint() { | |||
f := w.file | |||
for _, decl := range f.AST.Decls { | |||
if fn, ok := decl.(*ast.FuncDecl); ok { | |||
if fn, ok := decl.(*ast.FuncDecl); ok && fn.Body != nil { | |||
v := cognitiveComplexityVisitor{} | |||
c := v.subTreeComplexity(fn.Body) | |||
if c > w.maxComplexity { | |||
@@ -109,7 +109,7 @@ func (v *cognitiveComplexityVisitor) Visit(n ast.Node) ast.Visitor { | |||
return nil // skip visiting binexp sub-tree (already visited by binExpComplexity) | |||
case *ast.BranchStmt: | |||
if n.Label != nil { | |||
v.complexity += 1 | |||
v.complexity++ | |||
} | |||
} | |||
// TODO handle (at least) direct recursion |
@@ -0,0 +1,137 @@ | |||
package rule | |||
import ( | |||
"fmt" | |||
"go/ast" | |||
"github.com/mgechev/revive/lint" | |||
) | |||
// DeferRule lints unused params in functions. | |||
type DeferRule struct{} | |||
// Apply applies the rule to given file. | |||
func (r *DeferRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { | |||
allow := r.allowFromArgs(arguments) | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
failures = append(failures, failure) | |||
} | |||
w := lintDeferRule{onFailure: onFailure, allow: allow} | |||
ast.Walk(w, file.AST) | |||
return failures | |||
} | |||
// Name returns the rule name. | |||
func (r *DeferRule) Name() string { | |||
return "defer" | |||
} | |||
func (r *DeferRule) allowFromArgs(args lint.Arguments) map[string]bool { | |||
if len(args) < 1 { | |||
allow := map[string]bool{ | |||
"loop": true, | |||
"call-chain": true, | |||
"method-call": true, | |||
"return": true, | |||
"recover": true, | |||
} | |||
return allow | |||
} | |||
aa, ok := args[0].([]interface{}) | |||
if !ok { | |||
panic(fmt.Sprintf("Invalid argument '%v' for 'defer' rule. Expecting []string, got %T", args[0], args[0])) | |||
} | |||
allow := make(map[string]bool, len(aa)) | |||
for _, subcase := range aa { | |||
sc, ok := subcase.(string) | |||
if !ok { | |||
panic(fmt.Sprintf("Invalid argument '%v' for 'defer' rule. Expecting string, got %T", subcase, subcase)) | |||
} | |||
allow[sc] = true | |||
} | |||
return allow | |||
} | |||
type lintDeferRule struct { | |||
onFailure func(lint.Failure) | |||
inALoop bool | |||
inADefer bool | |||
inAFuncLit bool | |||
allow map[string]bool | |||
} | |||
func (w lintDeferRule) Visit(node ast.Node) ast.Visitor { | |||
switch n := node.(type) { | |||
case *ast.ForStmt: | |||
w.visitSubtree(n.Body, w.inADefer, true, w.inAFuncLit) | |||
return nil | |||
case *ast.RangeStmt: | |||
w.visitSubtree(n.Body, w.inADefer, true, w.inAFuncLit) | |||
return nil | |||
case *ast.FuncLit: | |||
w.visitSubtree(n.Body, w.inADefer, false, true) | |||
return nil | |||
case *ast.ReturnStmt: | |||
if len(n.Results) != 0 && w.inADefer && w.inAFuncLit { | |||
w.newFailure("return in a defer function has no effect", n, 1.0, "logic", "return") | |||
} | |||
case *ast.CallExpr: | |||
if isIdent(n.Fun, "recover") && !w.inADefer { | |||
// confidence is not 1 because recover can be in a function that is deferred elsewhere | |||
w.newFailure("recover must be called inside a deferred function", n, 0.8, "logic", "recover") | |||
} | |||
case *ast.DeferStmt: | |||
w.visitSubtree(n.Call.Fun, true, false, false) | |||
if w.inALoop { | |||
w.newFailure("prefer not to defer inside loops", n, 1.0, "bad practice", "loop") | |||
} | |||
switch fn := n.Call.Fun.(type) { | |||
case *ast.CallExpr: | |||
w.newFailure("prefer not to defer chains of function calls", fn, 1.0, "bad practice", "call-chain") | |||
case *ast.SelectorExpr: | |||
if id, ok := fn.X.(*ast.Ident); ok { | |||
isMethodCall := id != nil && id.Obj != nil && id.Obj.Kind == ast.Typ | |||
if isMethodCall { | |||
w.newFailure("be careful when deferring calls to methods without pointer receiver", fn, 0.8, "bad practice", "method-call") | |||
} | |||
} | |||
} | |||
return nil | |||
} | |||
return w | |||
} | |||
func (w lintDeferRule) visitSubtree(n ast.Node, inADefer, inALoop, inAFuncLit bool) { | |||
nw := &lintDeferRule{ | |||
onFailure: w.onFailure, | |||
inADefer: inADefer, | |||
inALoop: inALoop, | |||
inAFuncLit: inAFuncLit, | |||
allow: w.allow} | |||
ast.Walk(nw, n) | |||
} | |||
func (w lintDeferRule) newFailure(msg string, node ast.Node, confidence float64, cat string, subcase string) { | |||
if !w.allow[subcase] { | |||
return | |||
} | |||
w.onFailure(lint.Failure{ | |||
Confidence: confidence, | |||
Node: node, | |||
Category: cat, | |||
Failure: msg, | |||
}) | |||
} |
@@ -0,0 +1,78 @@ | |||
package rule | |||
import ( | |||
"go/ast" | |||
"github.com/mgechev/revive/lint" | |||
) | |||
// EarlyReturnRule lints given else constructs. | |||
type EarlyReturnRule struct{} | |||
// Apply applies the rule to given file. | |||
func (r *EarlyReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
failures = append(failures, failure) | |||
} | |||
w := lintEarlyReturnRule{onFailure: onFailure} | |||
ast.Walk(w, file.AST) | |||
return failures | |||
} | |||
// Name returns the rule name. | |||
func (r *EarlyReturnRule) Name() string { | |||
return "early-return" | |||
} | |||
type lintEarlyReturnRule struct { | |||
onFailure func(lint.Failure) | |||
} | |||
func (w lintEarlyReturnRule) Visit(node ast.Node) ast.Visitor { | |||
switch n := node.(type) { | |||
case *ast.IfStmt: | |||
if n.Else == nil { | |||
// no else branch | |||
return w | |||
} | |||
elseBlock, ok := n.Else.(*ast.BlockStmt) | |||
if !ok { | |||
// is if-else-if | |||
return w | |||
} | |||
lenElseBlock := len(elseBlock.List) | |||
if lenElseBlock < 1 { | |||
// empty else block, continue (there is another rule that warns on empty blocks) | |||
return w | |||
} | |||
lenThenBlock := len(n.Body.List) | |||
if lenThenBlock < 1 { | |||
// then block is empty thus the stmt can be simplified | |||
w.onFailure(lint.Failure{ | |||
Confidence: 1, | |||
Node: n, | |||
Failure: "if c { } else {... return} can be simplified to if !c { ... return }", | |||
}) | |||
return w | |||
} | |||
_, lastThenStmtIsReturn := n.Body.List[lenThenBlock-1].(*ast.ReturnStmt) | |||
_, lastElseStmtIsReturn := elseBlock.List[lenElseBlock-1].(*ast.ReturnStmt) | |||
if lastElseStmtIsReturn && !lastThenStmtIsReturn { | |||
w.onFailure(lint.Failure{ | |||
Confidence: 1, | |||
Node: n, | |||
Failure: "if c {...} else {... return } can be simplified to if !c { ... return } ...", | |||
}) | |||
} | |||
} | |||
return w | |||
} |
@@ -17,7 +17,7 @@ func (r *EmptyBlockRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure | |||
failures = append(failures, failure) | |||
} | |||
w := lintEmptyBlock{make([]*ast.BlockStmt, 0), onFailure} | |||
w := lintEmptyBlock{make(map[*ast.BlockStmt]bool, 0), onFailure} | |||
ast.Walk(w, file.AST) | |||
return failures | |||
} | |||
@@ -28,49 +28,38 @@ func (r *EmptyBlockRule) Name() string { | |||
} | |||
type lintEmptyBlock struct { | |||
ignore []*ast.BlockStmt | |||
ignore map[*ast.BlockStmt]bool | |||
onFailure func(lint.Failure) | |||
} | |||
func (w lintEmptyBlock) Visit(node ast.Node) ast.Visitor { | |||
fd, ok := node.(*ast.FuncDecl) | |||
if ok { | |||
w.ignore = append(w.ignore, fd.Body) | |||
switch n := node.(type) { | |||
case *ast.FuncDecl: | |||
w.ignore[n.Body] = true | |||
return w | |||
} | |||
fl, ok := node.(*ast.FuncLit) | |||
if ok { | |||
w.ignore = append(w.ignore, fl.Body) | |||
return w | |||
} | |||
block, ok := node.(*ast.BlockStmt) | |||
if !ok { | |||
return w | |||
} | |||
if mustIgnore(block, w.ignore) { | |||
case *ast.FuncLit: | |||
w.ignore[n.Body] = true | |||
return w | |||
} | |||
if len(block.List) == 0 { | |||
w.onFailure(lint.Failure{ | |||
Confidence: 1, | |||
Node: block, | |||
Category: "logic", | |||
Failure: "this block is empty, you can remove it", | |||
}) | |||
case *ast.RangeStmt: | |||
if len(n.Body.List) == 0 { | |||
w.onFailure(lint.Failure{ | |||
Confidence: 0.9, | |||
Node: n, | |||
Category: "logic", | |||
Failure: "this block is empty, you can remove it", | |||
}) | |||
return nil // skip visiting the range subtree (it will produce a duplicated failure) | |||
} | |||
case *ast.BlockStmt: | |||
if !w.ignore[n] && len(n.List) == 0 { | |||
w.onFailure(lint.Failure{ | |||
Confidence: 1, | |||
Node: n, | |||
Category: "logic", | |||
Failure: "this block is empty, you can remove it", | |||
}) | |||
} | |||
} | |||
return w | |||
} | |||
func mustIgnore(block *ast.BlockStmt, blackList []*ast.BlockStmt) bool { | |||
for _, b := range blackList { | |||
if b == block { | |||
return true | |||
} | |||
} | |||
return false | |||
} |
@@ -0,0 +1,82 @@ | |||
package rule | |||
import ( | |||
"go/ast" | |||
"github.com/mgechev/revive/lint" | |||
) | |||
// IdenticalBranchesRule warns on constant logical expressions. | |||
type IdenticalBranchesRule struct{} | |||
// Apply applies the rule to given file. | |||
func (r *IdenticalBranchesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
failures = append(failures, failure) | |||
} | |||
astFile := file.AST | |||
w := &lintIdenticalBranches{astFile, onFailure} | |||
ast.Walk(w, astFile) | |||
return failures | |||
} | |||
// Name returns the rule name. | |||
func (r *IdenticalBranchesRule) Name() string { | |||
return "identical-branches" | |||
} | |||
type lintIdenticalBranches struct { | |||
file *ast.File | |||
onFailure func(lint.Failure) | |||
} | |||
func (w *lintIdenticalBranches) Visit(node ast.Node) ast.Visitor { | |||
n, ok := node.(*ast.IfStmt) | |||
if !ok { | |||
return w | |||
} | |||
if n.Else == nil { | |||
return w | |||
} | |||
branches := []*ast.BlockStmt{n.Body} | |||
elseBranch, ok := n.Else.(*ast.BlockStmt) | |||
if !ok { // if-else-if construction | |||
return w | |||
} | |||
branches = append(branches, elseBranch) | |||
if w.identicalBranches(branches) { | |||
w.newFailure(n, "both branches of the if are identical") | |||
} | |||
return w | |||
} | |||
func (w *lintIdenticalBranches) identicalBranches(branches []*ast.BlockStmt) bool { | |||
if len(branches) < 2 { | |||
return false | |||
} | |||
ref := gofmt(branches[0]) | |||
for i := 1; i < len(branches); i++ { | |||
if gofmt(branches[i]) != ref { | |||
return false | |||
} | |||
} | |||
return true | |||
} | |||
func (w lintIdenticalBranches) newFailure(node ast.Node, msg string) { | |||
w.onFailure(lint.Failure{ | |||
Confidence: 1, | |||
Node: node, | |||
Category: "logic", | |||
Failure: msg, | |||
}) | |||
} |
@@ -0,0 +1,183 @@ | |||
package rule | |||
import ( | |||
"go/ast" | |||
"github.com/mgechev/revive/lint" | |||
) | |||
// UnconditionalRecursionRule lints given else constructs. | |||
type UnconditionalRecursionRule struct{} | |||
// Apply applies the rule to given file. | |||
func (r *UnconditionalRecursionRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
failures = append(failures, failure) | |||
} | |||
w := lintUnconditionalRecursionRule{onFailure: onFailure} | |||
ast.Walk(w, file.AST) | |||
return failures | |||
} | |||
// Name returns the rule name. | |||
func (r *UnconditionalRecursionRule) Name() string { | |||
return "unconditional-recursion" | |||
} | |||
type funcDesc struct { | |||
reciverID *ast.Ident | |||
id *ast.Ident | |||
} | |||
func (fd *funcDesc) equal(other *funcDesc) bool { | |||
receiversAreEqual := (fd.reciverID == nil && other.reciverID == nil) || fd.reciverID != nil && other.reciverID != nil && fd.reciverID.Name == other.reciverID.Name | |||
idsAreEqual := (fd.id == nil && other.id == nil) || fd.id.Name == other.id.Name | |||
return receiversAreEqual && idsAreEqual | |||
} | |||
type funcStatus struct { | |||
funcDesc *funcDesc | |||
seenConditionalExit bool | |||
} | |||
type lintUnconditionalRecursionRule struct { | |||
onFailure func(lint.Failure) | |||
currentFunc *funcStatus | |||
} | |||
// Visit will traverse the file AST. | |||
// The rule is based in the following algorithm: inside each function body we search for calls to the function itself. | |||
// We do not search inside conditional control structures (if, for, switch, ...) because any recursive call inside them is conditioned | |||
// We do search inside conditional control structures are statements that will take the control out of the function (return, exit, panic) | |||
// If we find conditional control exits, it means the function is NOT unconditionally-recursive | |||
// If we find a recursive call before finding any conditional exit, a failure is generated | |||
// In resume: if we found a recursive call control-dependant from the entry point of the function then we raise a failure. | |||
func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor { | |||
switch n := node.(type) { | |||
case *ast.FuncDecl: | |||
var rec *ast.Ident | |||
switch { | |||
case n.Recv == nil || n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1: | |||
rec = nil | |||
default: | |||
rec = n.Recv.List[0].Names[0] | |||
} | |||
w.currentFunc = &funcStatus{&funcDesc{rec, n.Name}, false} | |||
case *ast.CallExpr: | |||
var funcID *ast.Ident | |||
var selector *ast.Ident | |||
switch c := n.Fun.(type) { | |||
case *ast.Ident: | |||
selector = nil | |||
funcID = c | |||
case *ast.SelectorExpr: | |||
var ok bool | |||
selector, ok = c.X.(*ast.Ident) | |||
if !ok { // a.b....Foo() | |||
return nil | |||
} | |||
funcID = c.Sel | |||
default: | |||
return w | |||
} | |||
if w.currentFunc != nil && // not in a func body | |||
!w.currentFunc.seenConditionalExit && // there is a conditional exit in the function | |||
w.currentFunc.funcDesc.equal(&funcDesc{selector, funcID}) { | |||
w.onFailure(lint.Failure{ | |||
Category: "logic", | |||
Confidence: 1, | |||
Node: n, | |||
Failure: "unconditional recursive call", | |||
}) | |||
} | |||
case *ast.IfStmt: | |||
w.updateFuncStatus(n.Body) | |||
w.updateFuncStatus(n.Else) | |||
return nil | |||
case *ast.SelectStmt: | |||
w.updateFuncStatus(n.Body) | |||
return nil | |||
case *ast.RangeStmt: | |||
w.updateFuncStatus(n.Body) | |||
return nil | |||
case *ast.TypeSwitchStmt: | |||
w.updateFuncStatus(n.Body) | |||
return nil | |||
case *ast.SwitchStmt: | |||
w.updateFuncStatus(n.Body) | |||
return nil | |||
case *ast.GoStmt: | |||
for _, a := range n.Call.Args { | |||
ast.Walk(w, a) // check if arguments have a recursive call | |||
} | |||
return nil // recursive async call is not an issue | |||
case *ast.ForStmt: | |||
if n.Cond != nil { | |||
return nil | |||
} | |||
// unconditional loop | |||
return w | |||
} | |||
return w | |||
} | |||
func (w *lintUnconditionalRecursionRule) updateFuncStatus(node ast.Node) { | |||
if node == nil || w.currentFunc == nil || w.currentFunc.seenConditionalExit { | |||
return | |||
} | |||
w.currentFunc.seenConditionalExit = w.hasControlExit(node) | |||
} | |||
var exitFunctions = map[string]map[string]bool{ | |||
"os": map[string]bool{"Exit": true}, | |||
"syscall": map[string]bool{"Exit": true}, | |||
"log": map[string]bool{ | |||
"Fatal": true, | |||
"Fatalf": true, | |||
"Fatalln": true, | |||
"Panic": true, | |||
"Panicf": true, | |||
"Panicln": true, | |||
}, | |||
} | |||
func (w *lintUnconditionalRecursionRule) hasControlExit(node ast.Node) bool { | |||
// isExit returns true if the given node makes control exit the function | |||
isExit := func(node ast.Node) bool { | |||
switch n := node.(type) { | |||
case *ast.ReturnStmt: | |||
return true | |||
case *ast.CallExpr: | |||
if isIdent(n.Fun, "panic") { | |||
return true | |||
} | |||
se, ok := n.Fun.(*ast.SelectorExpr) | |||
if !ok { | |||
return false | |||
} | |||
id, ok := se.X.(*ast.Ident) | |||
if !ok { | |||
return false | |||
} | |||
fn := se.Sel.Name | |||
pkg := id.Name | |||
if exitFunctions[pkg] != nil && exitFunctions[pkg][fn] { // it's a call to an exit function | |||
return true | |||
} | |||
} | |||
return false | |||
} | |||
return len(pick(node, isExit, nil)) != 0 | |||
} |
@@ -0,0 +1,115 @@ | |||
package rule | |||
import ( | |||
"fmt" | |||
"go/ast" | |||
"go/token" | |||
"github.com/mgechev/revive/lint" | |||
) | |||
// UnexportedNamingRule lints wrongly named unexported symbols. | |||
type UnexportedNamingRule struct{} | |||
// Apply applies the rule to given file. | |||
func (r *UnexportedNamingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
failures = append(failures, failure) | |||
} | |||
ba := &unexportablenamingLinter{onFailure} | |||
ast.Walk(ba, file.AST) | |||
return failures | |||
} | |||
// Name returns the rule name. | |||
func (r *UnexportedNamingRule) Name() string { | |||
return "unexported-naming" | |||
} | |||
type unexportablenamingLinter struct { | |||
onFailure func(lint.Failure) | |||
} | |||
func (unl unexportablenamingLinter) Visit(node ast.Node) ast.Visitor { | |||
switch n := node.(type) { | |||
case *ast.FuncDecl: | |||
unl.lintFunction(n.Type, n.Body) | |||
return nil | |||
case *ast.FuncLit: | |||
unl.lintFunction(n.Type, n.Body) | |||
return nil | |||
case *ast.AssignStmt: | |||
if n.Tok != token.DEFINE { | |||
return nil | |||
} | |||
ids := []*ast.Ident{} | |||
for _, e := range n.Lhs { | |||
id, ok := e.(*ast.Ident) | |||
if !ok { | |||
continue | |||
} | |||
ids = append(ids, id) | |||
} | |||
unl.lintIDs(ids) | |||
case *ast.DeclStmt: | |||
gd, ok := n.Decl.(*ast.GenDecl) | |||
if !ok { | |||
return nil | |||
} | |||
if len(gd.Specs) < 1 { | |||
return nil | |||
} | |||
vs, ok := gd.Specs[0].(*ast.ValueSpec) | |||
if !ok { | |||
return nil | |||
} | |||
unl.lintIDs(vs.Names) | |||
} | |||
return unl | |||
} | |||
func (unl unexportablenamingLinter) lintFunction(ft *ast.FuncType, body *ast.BlockStmt) { | |||
unl.lintFields(ft.Params) | |||
unl.lintFields(ft.Results) | |||
if body != nil { | |||
ast.Walk(unl, body) | |||
} | |||
} | |||
func (unl unexportablenamingLinter) lintFields(fields *ast.FieldList) { | |||
if fields == nil { | |||
return | |||
} | |||
ids := []*ast.Ident{} | |||
for _, field := range fields.List { | |||
ids = append(ids, field.Names...) | |||
} | |||
unl.lintIDs(ids) | |||
} | |||
func (unl unexportablenamingLinter) lintIDs(ids []*ast.Ident) { | |||
for _, id := range ids { | |||
if id.IsExported() { | |||
unl.onFailure(lint.Failure{ | |||
Node: id, | |||
Confidence: 1, | |||
Category: "naming", | |||
Failure: fmt.Sprintf("the symbol %s is local, its name should start with a lowercase letter", id.String()), | |||
}) | |||
} | |||
} | |||
} |
@@ -11,7 +11,7 @@ import ( | |||
type UnusedReceiverRule struct{} | |||
// Apply applies the rule to given file. | |||
func (_ *UnusedReceiverRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
func (*UnusedReceiverRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { | |||
var failures []lint.Failure | |||
onFailure := func(failure lint.Failure) { | |||
@@ -26,7 +26,7 @@ func (_ *UnusedReceiverRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fai | |||
} | |||
// Name returns the rule name. | |||
func (_ *UnusedReceiverRule) Name() string { | |||
func (*UnusedReceiverRule) Name() string { | |||
return "unused-receiver" | |||
} | |||
@@ -182,8 +182,8 @@ func isExprABooleanLit(n ast.Node) (lexeme string, ok bool) { | |||
return oper.Name, (oper.Name == trueName || oper.Name == falseName) | |||
} | |||
// gofmt returns a string representation of the expression. | |||
func gofmt(x ast.Expr) string { | |||
// gofmt returns a string representation of an AST subtree. | |||
func gofmt(x interface{}) string { | |||
buf := bytes.Buffer{} | |||
fs := token.NewFileSet() | |||
printer.Fprint(&buf, fs, x) |
@@ -13,9 +13,9 @@ stages: | |||
vmImage: ubuntu-latest | |||
steps: | |||
- task: GoTool@0 | |||
displayName: "Install Go 1.14" | |||
displayName: "Install Go 1.15" | |||
inputs: | |||
version: "1.14" | |||
version: "1.15" | |||
- script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/" | |||
- script: mkdir -p ${HOME}/go/src/github.com/pelletier/go-toml | |||
- script: cp -R . ${HOME}/go/src/github.com/pelletier/go-toml | |||
@@ -36,9 +36,9 @@ stages: | |||
vmImage: ubuntu-latest | |||
steps: | |||
- task: GoTool@0 | |||
displayName: "Install Go 1.14" | |||
displayName: "Install Go 1.15" | |||
inputs: | |||
version: "1.14" | |||
version: "1.15" | |||
- task: Go@0 | |||
displayName: "go fmt ./..." | |||
inputs: | |||
@@ -51,9 +51,9 @@ stages: | |||
vmImage: ubuntu-latest | |||
steps: | |||
- task: GoTool@0 | |||
displayName: "Install Go 1.14" | |||
displayName: "Install Go 1.15" | |||
inputs: | |||
version: "1.14" | |||
version: "1.15" | |||
- task: Go@0 | |||
displayName: "Generate coverage" | |||
inputs: | |||
@@ -71,9 +71,9 @@ stages: | |||
vmImage: ubuntu-latest | |||
steps: | |||
- task: GoTool@0 | |||
displayName: "Install Go 1.14" | |||
displayName: "Install Go 1.15" | |||
inputs: | |||
version: "1.14" | |||
version: "1.15" | |||
- script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/" | |||
- task: Bash@3 | |||
inputs: | |||
@@ -86,9 +86,9 @@ stages: | |||
vmImage: ubuntu-latest | |||
steps: | |||
- task: GoTool@0 | |||
displayName: "Install Go 1.14" | |||
displayName: "Install Go 1.15" | |||
inputs: | |||
version: "1.14" | |||
version: "1.15" | |||
- script: echo "##vso[task.setvariable variable=PATH]${PATH}:/home/vsts/go/bin/" | |||
- script: mkdir -p ${HOME}/go/src/github.com/pelletier/go-toml | |||
- script: cp -R . ${HOME}/go/src/github.com/pelletier/go-toml | |||
@@ -102,6 +102,15 @@ stages: | |||
displayName: "unit tests" | |||
strategy: | |||
matrix: | |||
linux 1.15: | |||
goVersion: '1.15' | |||
imageName: 'ubuntu-latest' | |||
mac 1.15: | |||
goVersion: '1.15' | |||
imageName: 'macOS-latest' | |||
windows 1.15: | |||
goVersion: '1.15' | |||
imageName: 'windows-latest' | |||
linux 1.14: | |||
goVersion: '1.14' | |||
imageName: 'ubuntu-latest' | |||
@@ -111,15 +120,6 @@ stages: | |||
windows 1.14: | |||
goVersion: '1.14' | |||
imageName: 'windows-latest' | |||
linux 1.13: | |||
goVersion: '1.13' | |||
imageName: 'ubuntu-latest' | |||
mac 1.13: | |||
goVersion: '1.13' | |||
imageName: 'macOS-latest' | |||
windows 1.13: | |||
goVersion: '1.13' | |||
imageName: 'windows-latest' | |||
pool: | |||
vmImage: $(imageName) | |||
steps: | |||
@@ -155,7 +155,7 @@ stages: | |||
- task: GoTool@0 | |||
displayName: "Install Go" | |||
inputs: | |||
version: 1.14 | |||
version: 1.15 | |||
- task: Bash@3 | |||
inputs: | |||
targetType: inline |
@@ -1,164 +0,0 @@ | |||
{ | |||
"array": { | |||
"key1": [ | |||
1, | |||
2, | |||
3 | |||
], | |||
"key2": [ | |||
"red", | |||
"yellow", | |||
"green" | |||
], | |||
"key3": [ | |||
[ | |||
1, | |||
2 | |||
], | |||
[ | |||
3, | |||
4, | |||
5 | |||
] | |||
], | |||
"key4": [ | |||
[ | |||
1, | |||
2 | |||
], | |||
[ | |||
"a", | |||
"b", | |||
"c" | |||
] | |||
], | |||
"key5": [ | |||
1, | |||
2, | |||
3 | |||
], | |||
"key6": [ | |||
1, | |||
2 | |||
] | |||
}, | |||
"boolean": { | |||
"False": false, | |||
"True": true | |||
}, | |||
"datetime": { | |||
"key1": "1979-05-27T07:32:00Z", | |||
"key2": "1979-05-27T00:32:00-07:00", | |||
"key3": "1979-05-27T00:32:00.999999-07:00" | |||
}, | |||
"float": { | |||
"both": { | |||
"key": 6.626e-34 | |||
}, | |||
"exponent": { | |||
"key1": 5e+22, | |||
"key2": 1000000, | |||
"key3": -0.02 | |||
}, | |||
"fractional": { | |||
"key1": 1, | |||
"key2": 3.1415, | |||
"key3": -0.01 | |||
}, | |||
"underscores": { | |||
"key1": 9224617.445991227, | |||
"key2": 1e+100 | |||
} | |||
}, | |||
"fruit": [{ | |||
"name": "apple", | |||
"physical": { | |||
"color": "red", | |||
"shape": "round" | |||
}, | |||
"variety": [{ | |||
"name": "red delicious" | |||
}, | |||
{ | |||
"name": "granny smith" | |||
} | |||
] | |||
}, | |||
{ | |||
"name": "banana", | |||
"variety": [{ | |||
"name": "plantain" | |||
}] | |||
} | |||
], | |||
"integer": { | |||
"key1": 99, | |||
"key2": 42, | |||
"key3": 0, | |||
"key4": -17, | |||
"underscores": { | |||
"key1": 1000, | |||
"key2": 5349221, | |||
"key3": 12345 | |||
} | |||
}, | |||
"products": [{ | |||
"name": "Hammer", | |||
"sku": 738594937 | |||
}, | |||
{}, | |||
{ | |||
"color": "gray", | |||
"name": "Nail", | |||
"sku": 284758393 | |||
} | |||
], | |||
"string": { | |||
"basic": { | |||
"basic": "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF." | |||
}, | |||
"literal": { | |||
"multiline": { | |||
"lines": "The first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n", | |||
"regex2": "I [dw]on't need \\d{2} apples" | |||
}, | |||
"quoted": "Tom \"Dubs\" Preston-Werner", | |||
"regex": "\u003c\\i\\c*\\s*\u003e", | |||
"winpath": "C:\\Users\\nodejs\\templates", | |||
"winpath2": "\\\\ServerX\\admin$\\system32\\" | |||
}, | |||
"multiline": { | |||
"continued": { | |||
"key1": "The quick brown fox jumps over the lazy dog.", | |||
"key2": "The quick brown fox jumps over the lazy dog.", | |||
"key3": "The quick brown fox jumps over the lazy dog." | |||
}, | |||
"key1": "One\nTwo", | |||
"key2": "One\nTwo", | |||
"key3": "One\nTwo" | |||
} | |||
}, | |||
"table": { | |||
"inline": { | |||
"name": { | |||
"first": "Tom", | |||
"last": "Preston-Werner" | |||
}, | |||
"point": { | |||
"x": 1, | |||
"y": 2 | |||
} | |||
}, | |||
"key": "value", | |||
"subtable": { | |||
"key": "another value" | |||
} | |||
}, | |||
"x": { | |||
"y": { | |||
"z": { | |||
"w": {} | |||
} | |||
} | |||
} | |||
} |
@@ -20,11 +20,15 @@ git clone ${reference_git} ${ref_tempdir} >/dev/null 2>/dev/null | |||
pushd ${ref_tempdir} >/dev/null | |||
git checkout ${reference_ref} >/dev/null 2>/dev/null | |||
go test -bench=. -benchmem | tee ${ref_benchmark} | |||
cd benchmark | |||
go test -bench=. -benchmem | tee -a ${ref_benchmark} | |||
popd >/dev/null | |||
echo "" | |||
echo "=== local" | |||
go test -bench=. -benchmem | tee ${local_benchmark} | |||
cd benchmark | |||
go test -bench=. -benchmem | tee -a ${local_benchmark} | |||
echo "" | |||
echo "=== diff" |
@@ -1,244 +0,0 @@ | |||
################################################################################ | |||
## Comment | |||
# Speak your mind with the hash symbol. They go from the symbol to the end of | |||
# the line. | |||
################################################################################ | |||
## Table | |||
# Tables (also known as hash tables or dictionaries) are collections of | |||
# key/value pairs. They appear in square brackets on a line by themselves. | |||
[table] | |||
key = "value" # Yeah, you can do this. | |||
# Nested tables are denoted by table names with dots in them. Name your tables | |||
# whatever crap you please, just don't use #, ., [ or ]. | |||
[table.subtable] | |||
key = "another value" | |||
# You don't need to specify all the super-tables if you don't want to. TOML | |||
# knows how to do it for you. | |||
# [x] you | |||
# [x.y] don't | |||
# [x.y.z] need these | |||
[x.y.z.w] # for this to work | |||
################################################################################ | |||
## Inline Table | |||
# Inline tables provide a more compact syntax for expressing tables. They are | |||
# especially useful for grouped data that can otherwise quickly become verbose. | |||
# Inline tables are enclosed in curly braces `{` and `}`. No newlines are | |||
# allowed between the curly braces unless they are valid within a value. | |||
[table.inline] | |||
name = { first = "Tom", last = "Preston-Werner" } | |||
point = { x = 1, y = 2 } | |||
################################################################################ | |||
## String | |||
# There are four ways to express strings: basic, multi-line basic, literal, and | |||
# multi-line literal. All strings must contain only valid UTF-8 characters. | |||
[string.basic] | |||
basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." | |||
[string.multiline] | |||
# The following strings are byte-for-byte equivalent: | |||
key1 = "One\nTwo" | |||
key2 = """One\nTwo""" | |||
key3 = """ | |||
One | |||
Two""" | |||
[string.multiline.continued] | |||
# The following strings are byte-for-byte equivalent: | |||
key1 = "The quick brown fox jumps over the lazy dog." | |||
key2 = """ | |||
The quick brown \ | |||
fox jumps over \ | |||
the lazy dog.""" | |||
key3 = """\ | |||
The quick brown \ | |||
fox jumps over \ | |||
the lazy dog.\ | |||
""" | |||
[string.literal] | |||
# What you see is what you get. | |||
winpath = 'C:\Users\nodejs\templates' | |||
winpath2 = '\\ServerX\admin$\system32\' | |||
quoted = 'Tom "Dubs" Preston-Werner' | |||
regex = '<\i\c*\s*>' | |||
[string.literal.multiline] | |||
regex2 = '''I [dw]on't need \d{2} apples''' | |||
lines = ''' | |||
The first newline is | |||
trimmed in raw strings. | |||
All other whitespace | |||
is preserved. | |||
''' | |||
################################################################################ | |||
## Integer | |||
# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. | |||
# Negative numbers are prefixed with a minus sign. | |||
[integer] | |||
key1 = +99 | |||
key2 = 42 | |||
key3 = 0 | |||
key4 = -17 | |||
[integer.underscores] | |||
# For large numbers, you may use underscores to enhance readability. Each | |||
# underscore must be surrounded by at least one digit. | |||
key1 = 1_000 | |||
key2 = 5_349_221 | |||
key3 = 1_2_3_4_5 # valid but inadvisable | |||
################################################################################ | |||
## Float | |||
# A float consists of an integer part (which may be prefixed with a plus or | |||
# minus sign) followed by a fractional part and/or an exponent part. | |||
[float.fractional] | |||
key1 = +1.0 | |||
key2 = 3.1415 | |||
key3 = -0.01 | |||
[float.exponent] | |||
key1 = 5e+22 | |||
key2 = 1e6 | |||
key3 = -2E-2 | |||
[float.both] | |||
key = 6.626e-34 | |||
[float.underscores] | |||
key1 = 9_224_617.445_991_228_313 | |||
key2 = 1e1_00 | |||
################################################################################ | |||
## Boolean | |||
# Booleans are just the tokens you're used to. Always lowercase. | |||
[boolean] | |||
True = true | |||
False = false | |||
################################################################################ | |||
## Datetime | |||
# Datetimes are RFC 3339 dates. | |||
[datetime] | |||
key1 = 1979-05-27T07:32:00Z | |||
key2 = 1979-05-27T00:32:00-07:00 | |||
key3 = 1979-05-27T00:32:00.999999-07:00 | |||
################################################################################ | |||
## Array | |||
# Arrays are square brackets with other primitives inside. Whitespace is | |||
# ignored. Elements are separated by commas. Data types may not be mixed. | |||
[array] | |||
key1 = [ 1, 2, 3 ] | |||
key2 = [ "red", "yellow", "green" ] | |||
key3 = [ [ 1, 2 ], [3, 4, 5] ] | |||
#key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok | |||
# Arrays can also be multiline. So in addition to ignoring whitespace, arrays | |||
# also ignore newlines between the brackets. Terminating commas are ok before | |||
# the closing bracket. | |||
key5 = [ | |||
1, 2, 3 | |||
] | |||
key6 = [ | |||
1, | |||
2, # this is ok | |||
] | |||
################################################################################ | |||
## Array of Tables | |||
# These can be expressed by using a table name in double brackets. Each table | |||
# with the same double bracketed name will be an element in the array. The | |||
# tables are inserted in the order encountered. | |||
[[products]] | |||
name = "Hammer" | |||
sku = 738594937 | |||
[[products]] | |||
[[products]] | |||
name = "Nail" | |||
sku = 284758393 | |||
color = "gray" | |||
# You can create nested arrays of tables as well. | |||
[[fruit]] | |||
name = "apple" | |||
[fruit.physical] | |||
color = "red" | |||
shape = "round" | |||
[[fruit.variety]] | |||
name = "red delicious" | |||
[[fruit.variety]] | |||
name = "granny smith" | |||
[[fruit]] | |||
name = "banana" | |||
[[fruit.variety]] | |||
name = "plantain" |
@@ -1,121 +0,0 @@ | |||
--- | |||
array: | |||
key1: | |||
- 1 | |||
- 2 | |||
- 3 | |||
key2: | |||
- red | |||
- yellow | |||
- green | |||
key3: | |||
- - 1 | |||
- 2 | |||
- - 3 | |||
- 4 | |||
- 5 | |||
key4: | |||
- - 1 | |||
- 2 | |||
- - a | |||
- b | |||
- c | |||
key5: | |||
- 1 | |||
- 2 | |||
- 3 | |||
key6: | |||
- 1 | |||
- 2 | |||
boolean: | |||
'False': false | |||
'True': true | |||
datetime: | |||
key1: '1979-05-27T07:32:00Z' | |||
key2: '1979-05-27T00:32:00-07:00' | |||
key3: '1979-05-27T00:32:00.999999-07:00' | |||
float: | |||
both: | |||
key: 6.626e-34 | |||
exponent: | |||
key1: 5.0e+22 | |||
key2: 1000000 | |||
key3: -0.02 | |||
fractional: | |||
key1: 1 | |||
key2: 3.1415 | |||
key3: -0.01 | |||
underscores: | |||
key1: 9224617.445991227 | |||
key2: 1.0e+100 | |||
fruit: | |||
- name: apple | |||
physical: | |||
color: red | |||
shape: round | |||
variety: | |||
- name: red delicious | |||
- name: granny smith | |||
- name: banana | |||
variety: | |||
- name: plantain | |||
integer: | |||
key1: 99 | |||
key2: 42 | |||
key3: 0 | |||
key4: -17 | |||
underscores: | |||
key1: 1000 | |||
key2: 5349221 | |||
key3: 12345 | |||
products: | |||
- name: Hammer | |||
sku: 738594937 | |||
- {} | |||
- color: gray | |||
name: Nail | |||
sku: 284758393 | |||
string: | |||
basic: | |||
basic: "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF." | |||
literal: | |||
multiline: | |||
lines: | | |||
The first newline is | |||
trimmed in raw strings. | |||
All other whitespace | |||
is preserved. | |||
regex2: I [dw]on't need \d{2} apples | |||
quoted: Tom "Dubs" Preston-Werner | |||
regex: "<\\i\\c*\\s*>" | |||
winpath: C:\Users\nodejs\templates | |||
winpath2: "\\\\ServerX\\admin$\\system32\\" | |||
multiline: | |||
continued: | |||
key1: The quick brown fox jumps over the lazy dog. | |||
key2: The quick brown fox jumps over the lazy dog. | |||
key3: The quick brown fox jumps over the lazy dog. | |||
key1: |- | |||
One | |||
Two | |||
key2: |- | |||
One | |||
Two | |||
key3: |- | |||
One | |||
Two | |||
table: | |||
inline: | |||
name: | |||
first: Tom | |||
last: Preston-Werner | |||
point: | |||
x: 1 | |||
y: 2 | |||
key: value | |||
subtable: | |||
key: another value | |||
x: | |||
y: | |||
z: | |||
w: {} |
@@ -2,8 +2,4 @@ module github.com/pelletier/go-toml | |||
go 1.12 | |||
require ( | |||
github.com/BurntSushi/toml v0.3.1 | |||
github.com/davecgh/go-spew v1.1.1 | |||
gopkg.in/yaml.v2 v2.3.0 | |||
) | |||
require github.com/davecgh/go-spew v1.1.1 |
@@ -306,7 +306,7 @@ func (l *tomlLexer) lexComma() tomlLexStateFn { | |||
// Parse the key and emits its value without escape sequences. | |||
// bare keys, basic string keys and literal string keys are supported. | |||
func (l *tomlLexer) lexKey() tomlLexStateFn { | |||
growingString := "" | |||
var sb strings.Builder | |||
for r := l.peek(); isKeyChar(r) || r == '\n' || r == '\r'; r = l.peek() { | |||
if r == '"' { | |||
@@ -315,7 +315,9 @@ func (l *tomlLexer) lexKey() tomlLexStateFn { | |||
if err != nil { | |||
return l.errorf(err.Error()) | |||
} | |||
growingString += "\"" + str + "\"" | |||
sb.WriteString("\"") | |||
sb.WriteString(str) | |||
sb.WriteString("\"") | |||
l.next() | |||
continue | |||
} else if r == '\'' { | |||
@@ -324,41 +326,45 @@ func (l *tomlLexer) lexKey() tomlLexStateFn { | |||
if err != nil { | |||
return l.errorf(err.Error()) | |||
} | |||
growingString += "'" + str + "'" | |||
sb.WriteString("'") | |||
sb.WriteString(str) | |||
sb.WriteString("'") | |||
l.next() | |||
continue | |||
} else if r == '\n' { | |||
return l.errorf("keys cannot contain new lines") | |||
} else if isSpace(r) { | |||
str := " " | |||
var str strings.Builder | |||
str.WriteString(" ") | |||
// skip trailing whitespace | |||
l.next() | |||
for r = l.peek(); isSpace(r); r = l.peek() { | |||
str += string(r) | |||
str.WriteRune(r) | |||
l.next() | |||
} | |||
// break loop if not a dot | |||
if r != '.' { | |||
break | |||
} | |||
str += "." | |||
str.WriteString(".") | |||
// skip trailing whitespace after dot | |||
l.next() | |||
for r = l.peek(); isSpace(r); r = l.peek() { | |||
str += string(r) | |||
str.WriteRune(r) | |||
l.next() | |||
} | |||
growingString += str | |||
sb.WriteString(str.String()) | |||
continue | |||
} else if r == '.' { | |||
// skip | |||
} else if !isValidBareChar(r) { | |||
return l.errorf("keys cannot contain %c character", r) | |||
} | |||
growingString += string(r) | |||
sb.WriteRune(r) | |||
l.next() | |||
} | |||
l.emitWithValue(tokenKey, growingString) | |||
l.emitWithValue(tokenKey, sb.String()) | |||
return l.lexVoid | |||
} | |||
@@ -383,7 +389,7 @@ func (l *tomlLexer) lexLeftBracket() tomlLexStateFn { | |||
} | |||
func (l *tomlLexer) lexLiteralStringAsString(terminator string, discardLeadingNewLine bool) (string, error) { | |||
growingString := "" | |||
var sb strings.Builder | |||
if discardLeadingNewLine { | |||
if l.follow("\r\n") { | |||
@@ -397,14 +403,14 @@ func (l *tomlLexer) lexLiteralStringAsString(terminator string, discardLeadingNe | |||
// find end of string | |||
for { | |||
if l.follow(terminator) { | |||
return growingString, nil | |||
return sb.String(), nil | |||
} | |||
next := l.peek() | |||
if next == eof { | |||
break | |||
} | |||
growingString += string(l.next()) | |||
sb.WriteRune(l.next()) | |||
} | |||
return "", errors.New("unclosed string") | |||
@@ -438,7 +444,7 @@ func (l *tomlLexer) lexLiteralString() tomlLexStateFn { | |||
// Terminator is the substring indicating the end of the token. | |||
// The resulting string does not include the terminator. | |||
func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, acceptNewLines bool) (string, error) { | |||
growingString := "" | |||
var sb strings.Builder | |||
if discardLeadingNewLine { | |||
if l.follow("\r\n") { | |||
@@ -451,7 +457,7 @@ func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, | |||
for { | |||
if l.follow(terminator) { | |||
return growingString, nil | |||
return sb.String(), nil | |||
} | |||
if l.follow("\\") { | |||
@@ -469,61 +475,61 @@ func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, | |||
l.next() | |||
} | |||
case '"': | |||
growingString += "\"" | |||
sb.WriteString("\"") | |||
l.next() | |||
case 'n': | |||
growingString += "\n" | |||
sb.WriteString("\n") | |||
l.next() | |||
case 'b': | |||
growingString += "\b" | |||
sb.WriteString("\b") | |||
l.next() | |||
case 'f': | |||
growingString += "\f" | |||
sb.WriteString("\f") | |||
l.next() | |||
case '/': | |||
growingString += "/" | |||
sb.WriteString("/") | |||
l.next() | |||
case 't': | |||
growingString += "\t" | |||
sb.WriteString("\t") | |||
l.next() | |||
case 'r': | |||
growingString += "\r" | |||
sb.WriteString("\r") | |||
l.next() | |||
case '\\': | |||
growingString += "\\" | |||
sb.WriteString("\\") | |||
l.next() | |||
case 'u': | |||
l.next() | |||
code := "" | |||
var code strings.Builder | |||
for i := 0; i < 4; i++ { | |||
c := l.peek() | |||
if !isHexDigit(c) { | |||
return "", errors.New("unfinished unicode escape") | |||
} | |||
l.next() | |||
code = code + string(c) | |||
code.WriteRune(c) | |||
} | |||
intcode, err := strconv.ParseInt(code, 16, 32) | |||
intcode, err := strconv.ParseInt(code.String(), 16, 32) | |||
if err != nil { | |||
return "", errors.New("invalid unicode escape: \\u" + code) | |||
return "", errors.New("invalid unicode escape: \\u" + code.String()) | |||
} | |||
growingString += string(rune(intcode)) | |||
sb.WriteRune(rune(intcode)) | |||
case 'U': | |||
l.next() | |||
code := "" | |||
var code strings.Builder | |||
for i := 0; i < 8; i++ { | |||
c := l.peek() | |||
if !isHexDigit(c) { | |||
return "", errors.New("unfinished unicode escape") | |||
} | |||
l.next() | |||
code = code + string(c) | |||
code.WriteRune(c) | |||
} | |||
intcode, err := strconv.ParseInt(code, 16, 64) | |||
intcode, err := strconv.ParseInt(code.String(), 16, 64) | |||
if err != nil { | |||
return "", errors.New("invalid unicode escape: \\U" + code) | |||
return "", errors.New("invalid unicode escape: \\U" + code.String()) | |||
} | |||
growingString += string(rune(intcode)) | |||
sb.WriteRune(rune(intcode)) | |||
default: | |||
return "", errors.New("invalid escape sequence: \\" + string(l.peek())) | |||
} | |||
@@ -534,7 +540,7 @@ func (l *tomlLexer) lexStringAsString(terminator string, discardLeadingNewLine, | |||
return "", fmt.Errorf("unescaped control character %U", r) | |||
} | |||
l.next() | |||
growingString += string(r) | |||
sb.WriteRune(r) | |||
} | |||
if l.peek() == eof { | |||
@@ -769,19 +775,19 @@ func init() { | |||
// /!\ also matches the empty string | |||
// | |||
// Example matches: | |||
//1979-05-27T07:32:00Z | |||
//1979-05-27T00:32:00-07:00 | |||
//1979-05-27T00:32:00.999999-07:00 | |||
//1979-05-27 07:32:00Z | |||
//1979-05-27 00:32:00-07:00 | |||
//1979-05-27 00:32:00.999999-07:00 | |||
//1979-05-27T07:32:00 | |||
//1979-05-27T00:32:00.999999 | |||
//1979-05-27 07:32:00 | |||
//1979-05-27 00:32:00.999999 | |||
//1979-05-27 | |||
//07:32:00 | |||
//00:32:00.999999 | |||
// 1979-05-27T07:32:00Z | |||
// 1979-05-27T00:32:00-07:00 | |||
// 1979-05-27T00:32:00.999999-07:00 | |||
// 1979-05-27 07:32:00Z | |||
// 1979-05-27 00:32:00-07:00 | |||
// 1979-05-27 00:32:00.999999-07:00 | |||
// 1979-05-27T07:32:00 | |||
// 1979-05-27T00:32:00.999999 | |||
// 1979-05-27 07:32:00 | |||
// 1979-05-27 00:32:00.999999 | |||
// 1979-05-27 | |||
// 07:32:00 | |||
// 00:32:00.999999 | |||
dateRegexp = regexp.MustCompile(`^(?:\d{1,4}-\d{2}-\d{2})?(?:[T ]?\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})?)?`) | |||
} | |||
@@ -76,6 +76,7 @@ var textUnmarshalerType = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem() | |||
var localDateType = reflect.TypeOf(LocalDate{}) | |||
var localTimeType = reflect.TypeOf(LocalTime{}) | |||
var localDateTimeType = reflect.TypeOf(LocalDateTime{}) | |||
var mapStringInterfaceType = reflect.TypeOf(map[string]interface{}{}) | |||
// Check if the given marshal type maps to a Tree primitive | |||
func isPrimitive(mtype reflect.Type) bool { | |||
@@ -436,6 +437,7 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er | |||
if tree, ok := val.(*Tree); ok && mtypef.Anonymous && !opts.nameFromTag && !e.promoteAnon { | |||
e.appendTree(tval, tree) | |||
} else { | |||
val = e.wrapTomlValue(val, tval) | |||
tval.SetPathWithOptions([]string{opts.name}, SetOptions{ | |||
Comment: opts.comment, | |||
Commented: opts.commented, | |||
@@ -474,6 +476,7 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er | |||
if err != nil { | |||
return nil, err | |||
} | |||
val = e.wrapTomlValue(val, tval) | |||
if e.quoteMapKeys { | |||
keyStr, err := tomlValueStringRepresentation(key.String(), "", "", e.order, e.arraysOneElementPerLine) | |||
if err != nil { | |||
@@ -516,13 +519,13 @@ func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (int | |||
// Convert given marshal value to toml value | |||
func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { | |||
e.line++ | |||
if mtype.Kind() == reflect.Ptr { | |||
switch { | |||
case isCustomMarshaler(mtype): | |||
return callCustomMarshaler(mval) | |||
case isTextMarshaler(mtype): | |||
return callTextMarshaler(mval) | |||
b, err := callTextMarshaler(mval) | |||
return string(b), err | |||
default: | |||
return e.valueToToml(mtype.Elem(), mval.Elem()) | |||
} | |||
@@ -534,7 +537,8 @@ func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface | |||
case isCustomMarshaler(mtype): | |||
return callCustomMarshaler(mval) | |||
case isTextMarshaler(mtype): | |||
return callTextMarshaler(mval) | |||
b, err := callTextMarshaler(mval) | |||
return string(b), err | |||
case isTree(mtype): | |||
return e.valueToTree(mtype, mval) | |||
case isOtherSequence(mtype), isCustomMarshalerSequence(mtype), isTextMarshalerSequence(mtype): | |||
@@ -577,6 +581,25 @@ func (e *Encoder) appendTree(t, o *Tree) error { | |||
return nil | |||
} | |||
// Create a toml value with the current line number as the position line | |||
func (e *Encoder) wrapTomlValue(val interface{}, parent *Tree) interface{} { | |||
_, isTree := val.(*Tree) | |||
_, isTreeS := val.([]*Tree) | |||
if isTree || isTreeS { | |||
return val | |||
} | |||
ret := &tomlValue{ | |||
value: val, | |||
position: Position{ | |||
e.line, | |||
parent.position.Col, | |||
}, | |||
} | |||
e.line++ | |||
return ret | |||
} | |||
// Unmarshal attempts to unmarshal the Tree into a Go struct pointed by v. | |||
// Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for | |||
// sub-structs, and only definite types can be unmarshaled. | |||
@@ -681,6 +704,8 @@ func (d *Decoder) unmarshal(v interface{}) error { | |||
switch elem.Kind() { | |||
case reflect.Struct, reflect.Map: | |||
case reflect.Interface: | |||
elem = mapStringInterfaceType | |||
default: | |||
return errors.New("only a pointer to struct or map can be unmarshaled from TOML") | |||
} | |||
@@ -717,6 +742,10 @@ func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree, mval1 *reflect.V | |||
if mvalPtr := reflect.New(mtype); isCustomUnmarshaler(mvalPtr.Type()) { | |||
d.visitor.visitAll() | |||
if tval == nil { | |||
return mvalPtr.Elem(), nil | |||
} | |||
if err := callCustomUnmarshaler(mvalPtr, tval.ToMap()); err != nil { | |||
return reflect.ValueOf(nil), fmt.Errorf("unmarshal toml: %v", err) | |||
} |
@@ -122,6 +122,89 @@ func (t *Tree) GetPath(keys []string) interface{} { | |||
} | |||
} | |||
// GetArray returns the value at key in the Tree. | |||
// It returns []string, []int64, etc type if key has homogeneous lists | |||
// Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings. | |||
// Returns nil if the path does not exist in the tree. | |||
// If keys is of length zero, the current tree is returned. | |||
func (t *Tree) GetArray(key string) interface{} { | |||
if key == "" { | |||
return t | |||
} | |||
return t.GetArrayPath(strings.Split(key, ".")) | |||
} | |||
// GetArrayPath returns the element in the tree indicated by 'keys'. | |||
// If keys is of length zero, the current tree is returned. | |||
func (t *Tree) GetArrayPath(keys []string) interface{} { | |||
if len(keys) == 0 { | |||
return t | |||
} | |||
subtree := t | |||
for _, intermediateKey := range keys[:len(keys)-1] { | |||
value, exists := subtree.values[intermediateKey] | |||
if !exists { | |||
return nil | |||
} | |||
switch node := value.(type) { | |||
case *Tree: | |||
subtree = node | |||
case []*Tree: | |||
// go to most recent element | |||
if len(node) == 0 { | |||
return nil | |||
} | |||
subtree = node[len(node)-1] | |||
default: | |||
return nil // cannot navigate through other node types | |||
} | |||
} | |||
// branch based on final node type | |||
switch node := subtree.values[keys[len(keys)-1]].(type) { | |||
case *tomlValue: | |||
switch n := node.value.(type) { | |||
case []interface{}: | |||
return getArray(n) | |||
default: | |||
return node.value | |||
} | |||
default: | |||
return node | |||
} | |||
} | |||
// if homogeneous array, then return slice type object over []interface{} | |||
func getArray(n []interface{}) interface{} { | |||
var s []string | |||
var i64 []int64 | |||
var f64 []float64 | |||
var bl []bool | |||
for _, value := range n { | |||
switch v := value.(type) { | |||
case string: | |||
s = append(s, v) | |||
case int64: | |||
i64 = append(i64, v) | |||
case float64: | |||
f64 = append(f64, v) | |||
case bool: | |||
bl = append(bl, v) | |||
default: | |||
return n | |||
} | |||
} | |||
if len(s) == len(n) { | |||
return s | |||
} else if len(i64) == len(n) { | |||
return i64 | |||
} else if len(f64) == len(n) { | |||
return f64 | |||
} else if len(bl) == len(n) { | |||
return bl | |||
} | |||
return n | |||
} | |||
// GetPosition returns the position of the given key. | |||
func (t *Tree) GetPosition(key string) Position { | |||
if key == "" { | |||
@@ -130,6 +213,50 @@ func (t *Tree) GetPosition(key string) Position { | |||
return t.GetPositionPath(strings.Split(key, ".")) | |||
} | |||
// SetPositionPath sets the position of element in the tree indicated by 'keys'. | |||
// If keys is of length zero, the current tree position is set. | |||
func (t *Tree) SetPositionPath(keys []string, pos Position) { | |||
if len(keys) == 0 { | |||
t.position = pos | |||
return | |||
} | |||
subtree := t | |||
for _, intermediateKey := range keys[:len(keys)-1] { | |||
value, exists := subtree.values[intermediateKey] | |||
if !exists { | |||
return | |||
} | |||
switch node := value.(type) { | |||
case *Tree: | |||
subtree = node | |||
case []*Tree: | |||
// go to most recent element | |||
if len(node) == 0 { | |||
return | |||
} | |||
subtree = node[len(node)-1] | |||
default: | |||
return | |||
} | |||
} | |||
// branch based on final node type | |||
switch node := subtree.values[keys[len(keys)-1]].(type) { | |||
case *tomlValue: | |||
node.position = pos | |||
return | |||
case *Tree: | |||
node.position = pos | |||
return | |||
case []*Tree: | |||
// go to most recent element | |||
if len(node) == 0 { | |||
return | |||
} | |||
node[len(node)-1].position = pos | |||
return | |||
} | |||
} | |||
// GetPositionPath returns the element in the tree indicated by 'keys'. | |||
// If keys is of length zero, the current tree is returned. | |||
func (t *Tree) GetPositionPath(keys []string) Position { | |||
@@ -212,7 +339,8 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac | |||
// go to most recent element | |||
if len(node) == 0 { | |||
// create element if it does not exist | |||
subtree.values[intermediateKey] = append(node, newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col})) | |||
node = append(node, newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col})) | |||
subtree.values[intermediateKey] = node | |||
} | |||
subtree = node[len(node)-1] | |||
} | |||
@@ -232,6 +360,8 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac | |||
toInsert = value | |||
case *tomlValue: | |||
v.comment = opts.Comment | |||
v.commented = opts.Commented | |||
v.multiline = opts.Multiline | |||
toInsert = v | |||
default: | |||
toInsert = &tomlValue{value: value, |
@@ -57,6 +57,19 @@ func simpleValueCoercion(object interface{}) (interface{}, error) { | |||
return float64(original), nil | |||
case fmt.Stringer: | |||
return original.String(), nil | |||
case []interface{}: | |||
value := reflect.ValueOf(original) | |||
length := value.Len() | |||
arrayValue := reflect.MakeSlice(value.Type(), 0, length) | |||
for i := 0; i < length; i++ { | |||
val := value.Index(i).Interface() | |||
simpleValue, err := simpleValueCoercion(val) | |||
if err != nil { | |||
return nil, err | |||
} | |||
arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue)) | |||
} | |||
return arrayValue.Interface(), nil | |||
default: | |||
return nil, fmt.Errorf("cannot convert type %T to Tree", object) | |||
} |
@@ -163,7 +163,7 @@ func tomlValueStringRepresentation(v interface{}, commented string, indent strin | |||
return "\"" + encodeTomlString(value) + "\"", nil | |||
case []byte: | |||
b, _ := v.([]byte) | |||
return tomlValueStringRepresentation(string(b), commented, indent, ord, arraysOneElementPerLine) | |||
return string(b), nil | |||
case bool: | |||
if value { | |||
return "true", nil |
@@ -6,6 +6,11 @@ | |||
// various CPU architectures. | |||
package cpu | |||
import ( | |||
"os" | |||
"strings" | |||
) | |||
// Initialized reports whether the CPU features were initialized. | |||
// | |||
// For some GOOS/GOARCH combinations initialization of the CPU features depends | |||
@@ -169,3 +174,94 @@ var S390X struct { | |||
HasVXE bool // vector-enhancements facility 1 | |||
_ CacheLinePad | |||
} | |||
func init() { | |||
archInit() | |||
initOptions() | |||
processOptions() | |||
} | |||
// options contains the cpu debug options that can be used in GODEBUG. | |||
// Options are arch dependent and are added by the arch specific initOptions functions. | |||
// Features that are mandatory for the specific GOARCH should have the Required field set | |||
// (e.g. SSE2 on amd64). | |||
var options []option | |||
// Option names should be lower case. e.g. avx instead of AVX. | |||
type option struct { | |||
Name string | |||
Feature *bool | |||
Specified bool // whether feature value was specified in GODEBUG | |||
Enable bool // whether feature should be enabled | |||
Required bool // whether feature is mandatory and can not be disabled | |||
} | |||
func processOptions() { | |||
env := os.Getenv("GODEBUG") | |||
field: | |||
for env != "" { | |||
field := "" | |||
i := strings.IndexByte(env, ',') | |||
if i < 0 { | |||
field, env = env, "" | |||
} else { | |||
field, env = env[:i], env[i+1:] | |||
} | |||
if len(field) < 4 || field[:4] != "cpu." { | |||
continue | |||
} | |||
i = strings.IndexByte(field, '=') | |||
if i < 0 { | |||
print("GODEBUG sys/cpu: no value specified for \"", field, "\"\n") | |||
continue | |||
} | |||
key, value := field[4:i], field[i+1:] // e.g. "SSE2", "on" | |||
var enable bool | |||
switch value { | |||
case "on": | |||
enable = true | |||
case "off": | |||
enable = false | |||
default: | |||
print("GODEBUG sys/cpu: value \"", value, "\" not supported for cpu option \"", key, "\"\n") | |||
continue field | |||
} | |||
if key == "all" { | |||
for i := range options { | |||
options[i].Specified = true | |||
options[i].Enable = enable || options[i].Required | |||
} | |||
continue field | |||
} | |||
for i := range options { | |||
if options[i].Name == key { | |||
options[i].Specified = true | |||
options[i].Enable = enable | |||
continue field | |||
} | |||
} | |||
print("GODEBUG sys/cpu: unknown cpu feature \"", key, "\"\n") | |||
} | |||
for _, o := range options { | |||
if !o.Specified { | |||
continue | |||
} | |||
if o.Enable && !*o.Feature { | |||
print("GODEBUG sys/cpu: can not enable \"", o.Name, "\", missing CPU support\n") | |||
continue | |||
} | |||
if !o.Enable && o.Required { | |||
print("GODEBUG sys/cpu: can not disable \"", o.Name, "\", required CPU feature\n") | |||
continue | |||
} | |||
*o.Feature = o.Enable | |||
} | |||
} |
@@ -6,8 +6,6 @@ | |||
package cpu | |||
const cacheLineSize = 128 | |||
const ( | |||
// getsystemcfg constants | |||
_SC_IMPL = 2 | |||
@@ -15,7 +13,7 @@ const ( | |||
_IMPL_POWER9 = 0x20000 | |||
) | |||
func init() { | |||
func archInit() { | |||
impl := getsystemcfg(_SC_IMPL) | |||
if impl&_IMPL_POWER8 != 0 { | |||
PPC64.IsPOWER8 = true |
@@ -38,3 +38,36 @@ const ( | |||
hwcap2_SHA2 = 1 << 3 | |||
hwcap2_CRC32 = 1 << 4 | |||
) | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "pmull", Feature: &ARM.HasPMULL}, | |||
{Name: "sha1", Feature: &ARM.HasSHA1}, | |||
{Name: "sha2", Feature: &ARM.HasSHA2}, | |||
{Name: "swp", Feature: &ARM.HasSWP}, | |||
{Name: "thumb", Feature: &ARM.HasTHUMB}, | |||
{Name: "thumbee", Feature: &ARM.HasTHUMBEE}, | |||
{Name: "tls", Feature: &ARM.HasTLS}, | |||
{Name: "vfp", Feature: &ARM.HasVFP}, | |||
{Name: "vfpd32", Feature: &ARM.HasVFPD32}, | |||
{Name: "vfpv3", Feature: &ARM.HasVFPv3}, | |||
{Name: "vfpv3d16", Feature: &ARM.HasVFPv3D16}, | |||
{Name: "vfpv4", Feature: &ARM.HasVFPv4}, | |||
{Name: "half", Feature: &ARM.HasHALF}, | |||
{Name: "26bit", Feature: &ARM.Has26BIT}, | |||
{Name: "fastmul", Feature: &ARM.HasFASTMUL}, | |||
{Name: "fpa", Feature: &ARM.HasFPA}, | |||
{Name: "edsp", Feature: &ARM.HasEDSP}, | |||
{Name: "java", Feature: &ARM.HasJAVA}, | |||
{Name: "iwmmxt", Feature: &ARM.HasIWMMXT}, | |||
{Name: "crunch", Feature: &ARM.HasCRUNCH}, | |||
{Name: "neon", Feature: &ARM.HasNEON}, | |||
{Name: "idivt", Feature: &ARM.HasIDIVT}, | |||
{Name: "idiva", Feature: &ARM.HasIDIVA}, | |||
{Name: "lpae", Feature: &ARM.HasLPAE}, | |||
{Name: "evtstrm", Feature: &ARM.HasEVTSTRM}, | |||
{Name: "aes", Feature: &ARM.HasAES}, | |||
{Name: "crc32", Feature: &ARM.HasCRC32}, | |||
} | |||
} |
@@ -8,7 +8,36 @@ import "runtime" | |||
const cacheLineSize = 64 | |||
func init() { | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "fp", Feature: &ARM64.HasFP}, | |||
{Name: "asimd", Feature: &ARM64.HasASIMD}, | |||
{Name: "evstrm", Feature: &ARM64.HasEVTSTRM}, | |||
{Name: "aes", Feature: &ARM64.HasAES}, | |||
{Name: "fphp", Feature: &ARM64.HasFPHP}, | |||
{Name: "jscvt", Feature: &ARM64.HasJSCVT}, | |||
{Name: "lrcpc", Feature: &ARM64.HasLRCPC}, | |||
{Name: "pmull", Feature: &ARM64.HasPMULL}, | |||
{Name: "sha1", Feature: &ARM64.HasSHA1}, | |||
{Name: "sha2", Feature: &ARM64.HasSHA2}, | |||
{Name: "sha3", Feature: &ARM64.HasSHA3}, | |||
{Name: "sha512", Feature: &ARM64.HasSHA512}, | |||
{Name: "sm3", Feature: &ARM64.HasSM3}, | |||
{Name: "sm4", Feature: &ARM64.HasSM4}, | |||
{Name: "sve", Feature: &ARM64.HasSVE}, | |||
{Name: "crc32", Feature: &ARM64.HasCRC32}, | |||
{Name: "atomics", Feature: &ARM64.HasATOMICS}, | |||
{Name: "asimdhp", Feature: &ARM64.HasASIMDHP}, | |||
{Name: "cpuid", Feature: &ARM64.HasCPUID}, | |||
{Name: "asimrdm", Feature: &ARM64.HasASIMDRDM}, | |||
{Name: "fcma", Feature: &ARM64.HasFCMA}, | |||
{Name: "dcpop", Feature: &ARM64.HasDCPOP}, | |||
{Name: "asimddp", Feature: &ARM64.HasASIMDDP}, | |||
{Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, | |||
} | |||
} | |||
func archInit() { | |||
switch runtime.GOOS { | |||
case "android", "darwin", "netbsd": | |||
// Android and iOS don't seem to allow reading these registers. |
@@ -6,7 +6,7 @@ | |||
package cpu | |||
func init() { | |||
func archInit() { | |||
if err := readHWCAP(); err != nil { | |||
return | |||
} |
@@ -2,6 +2,7 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build linux | |||
// +build mips64 mips64le | |||
package cpu |
@@ -7,8 +7,6 @@ | |||
package cpu | |||
const cacheLineSize = 128 | |||
// HWCAP/HWCAP2 bits. These are exposed by the kernel. | |||
const ( | |||
// ISA Level |
@@ -4,8 +4,6 @@ | |||
package cpu | |||
const cacheLineSize = 256 | |||
const ( | |||
// bit mask values from /usr/include/bits/hwcap.h | |||
hwcap_ZARCH = 2 |
@@ -7,3 +7,9 @@ | |||
package cpu | |||
const cacheLineSize = 32 | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "msa", Feature: &MIPS64X.HasMSA}, | |||
} | |||
} |
@@ -7,3 +7,5 @@ | |||
package cpu | |||
const cacheLineSize = 32 | |||
func initOptions() {} |
@@ -0,0 +1,9 @@ | |||
// Copyright 2020 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !linux,arm | |||
package cpu | |||
func archInit() {} |
@@ -0,0 +1,16 @@ | |||
// Copyright 2020 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build ppc64 ppc64le | |||
package cpu | |||
const cacheLineSize = 128 | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "darn", Feature: &PPC64.HasDARN}, | |||
{Name: "scv", Feature: &PPC64.HasSCV}, | |||
} | |||
} |
@@ -7,3 +7,5 @@ | |||
package cpu | |||
const cacheLineSize = 32 | |||
func initOptions() {} |
@@ -0,0 +1,30 @@ | |||
// Copyright 2020 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
package cpu | |||
const cacheLineSize = 256 | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "zarch", Feature: &S390X.HasZARCH}, | |||
{Name: "stfle", Feature: &S390X.HasSTFLE}, | |||
{Name: "ldisp", Feature: &S390X.HasLDISP}, | |||
{Name: "eimm", Feature: &S390X.HasEIMM}, | |||
{Name: "dfp", Feature: &S390X.HasDFP}, | |||
{Name: "etf3eh", Feature: &S390X.HasETF3EH}, | |||
{Name: "msa", Feature: &S390X.HasMSA}, | |||
{Name: "aes", Feature: &S390X.HasAES}, | |||
{Name: "aescbc", Feature: &S390X.HasAESCBC}, | |||
{Name: "aesctr", Feature: &S390X.HasAESCTR}, | |||
{Name: "aesgcm", Feature: &S390X.HasAESGCM}, | |||
{Name: "ghash", Feature: &S390X.HasGHASH}, | |||
{Name: "sha1", Feature: &S390X.HasSHA1}, | |||
{Name: "sha256", Feature: &S390X.HasSHA256}, | |||
{Name: "sha3", Feature: &S390X.HasSHA3}, | |||
{Name: "sha512", Feature: &S390X.HasSHA512}, | |||
{Name: "vx", Feature: &S390X.HasVX}, | |||
{Name: "vxe", Feature: &S390X.HasVXE}, | |||
} | |||
} |
@@ -11,3 +11,7 @@ package cpu | |||
// rules are good enough. | |||
const cacheLineSize = 0 | |||
func initOptions() {} | |||
func archInit() {} |
@@ -6,9 +6,37 @@ | |||
package cpu | |||
import "runtime" | |||
const cacheLineSize = 64 | |||
func init() { | |||
func initOptions() { | |||
options = []option{ | |||
{Name: "adx", Feature: &X86.HasADX}, | |||
{Name: "aes", Feature: &X86.HasAES}, | |||
{Name: "avx", Feature: &X86.HasAVX}, | |||
{Name: "avx2", Feature: &X86.HasAVX2}, | |||
{Name: "bmi1", Feature: &X86.HasBMI1}, | |||
{Name: "bmi2", Feature: &X86.HasBMI2}, | |||
{Name: "erms", Feature: &X86.HasERMS}, | |||
{Name: "fma", Feature: &X86.HasFMA}, | |||
{Name: "osxsave", Feature: &X86.HasOSXSAVE}, | |||
{Name: "pclmulqdq", Feature: &X86.HasPCLMULQDQ}, | |||
{Name: "popcnt", Feature: &X86.HasPOPCNT}, | |||
{Name: "rdrand", Feature: &X86.HasRDRAND}, | |||
{Name: "rdseed", Feature: &X86.HasRDSEED}, | |||
{Name: "sse3", Feature: &X86.HasSSE3}, | |||
{Name: "sse41", Feature: &X86.HasSSE41}, | |||
{Name: "sse42", Feature: &X86.HasSSE42}, | |||
{Name: "ssse3", Feature: &X86.HasSSSE3}, | |||
// These capabilities should always be enabled on amd64: | |||
{Name: "sse2", Feature: &X86.HasSSE2, Required: runtime.GOARCH == "amd64"}, | |||
} | |||
} | |||
func archInit() { | |||
Initialized = true | |||
maxID, _, _, _ := cpuid(0, 0) | |||
@@ -52,6 +80,7 @@ func init() { | |||
X86.HasERMS = isSet(9, ebx7) | |||
X86.HasRDSEED = isSet(18, ebx7) | |||
X86.HasADX = isSet(19, ebx7) | |||
} | |||
func isSet(bitpos uint, value uint32) bool { |
@@ -0,0 +1,29 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build !gccgo | |||
#include "textflag.h" | |||
// | |||
// System call support for mips64, OpenBSD | |||
// | |||
// Just jump to package syscall's implementation for all these functions. | |||
// The runtime may know about them. | |||
TEXT ·Syscall(SB),NOSPLIT,$0-56 | |||
JMP syscall·Syscall(SB) | |||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 | |||
JMP syscall·Syscall6(SB) | |||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 | |||
JMP syscall·Syscall9(SB) | |||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 | |||
JMP syscall·RawSyscall(SB) | |||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 | |||
JMP syscall·RawSyscall6(SB) |
@@ -16,3 +16,9 @@ func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { | |||
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) | |||
return err | |||
} | |||
// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command. | |||
func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error { | |||
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore)))) | |||
return err | |||
} |
@@ -20,6 +20,15 @@ func IoctlSetInt(fd int, req uint, value int) error { | |||
return ioctl(fd, req, uintptr(value)) | |||
} | |||
// IoctlSetPointerInt performs an ioctl operation which sets an | |||
// integer value on fd, using the specified request number. The ioctl | |||
// argument is called with a pointer to the integer value, rather than | |||
// passing the integer value directly. | |||
func IoctlSetPointerInt(fd int, req uint, value int) error { | |||
v := int32(value) | |||
return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) | |||
} | |||
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. | |||
// | |||
// To change fd's window size, the req argument should be TIOCSWINSZ. |
@@ -73,26 +73,22 @@ aix_ppc64) | |||
darwin_386) | |||
mkerrors="$mkerrors -m32" | |||
mksyscall="go run mksyscall.go -l32" | |||
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | |||
mkasm="go run mkasm_darwin.go" | |||
;; | |||
darwin_amd64) | |||
mkerrors="$mkerrors -m64" | |||
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h" | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | |||
mkasm="go run mkasm_darwin.go" | |||
;; | |||
darwin_arm) | |||
mkerrors="$mkerrors" | |||
mksyscall="go run mksyscall.go -l32" | |||
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h" | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | |||
mkasm="go run mkasm_darwin.go" | |||
;; | |||
darwin_arm64) | |||
mkerrors="$mkerrors -m64" | |||
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h" | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs" | |||
mkasm="go run mkasm_darwin.go" | |||
;; | |||
@@ -184,6 +180,15 @@ openbsd_arm64) | |||
# API consistent across platforms. | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" | |||
;; | |||
openbsd_mips64) | |||
mkerrors="$mkerrors -m64" | |||
mksyscall="go run mksyscall.go -openbsd" | |||
mksysctl="go run mksysctl_openbsd.go" | |||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'" | |||
# Let the type of C char be signed for making the bare syscall | |||
# API consistent across platforms. | |||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" | |||
;; | |||
solaris_amd64) | |||
mksyscall="go run mksyscall_solaris.go" | |||
mkerrors="$mkerrors -m64" | |||
@@ -217,8 +222,6 @@ esac | |||
# aix/ppc64 script generates files instead of writing to stdin. | |||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ; | |||
elif [ "$GOOS" == "darwin" ]; then | |||
# pre-1.12, direct syscalls | |||
echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos syscall_darwin_${GOARCH}.1_11.go $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go"; | |||
# 1.12 and later, syscalls via libSystem | |||
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; | |||
# 1.13 and later, syscalls via libSystem (including syscallPtr) |
@@ -58,6 +58,7 @@ includes_Darwin=' | |||
#define _DARWIN_USE_64_BIT_INODE | |||
#include <stdint.h> | |||
#include <sys/attr.h> | |||
#include <sys/clonefile.h> | |||
#include <sys/types.h> | |||
#include <sys/event.h> | |||
#include <sys/ptrace.h> | |||
@@ -107,6 +108,7 @@ includes_FreeBSD=' | |||
#include <sys/types.h> | |||
#include <sys/disk.h> | |||
#include <sys/event.h> | |||
#include <sys/sched.h> | |||
#include <sys/select.h> | |||
#include <sys/socket.h> | |||
#include <sys/sockio.h> | |||
@@ -192,9 +194,12 @@ struct ltchars { | |||
#include <sys/xattr.h> | |||
#include <linux/bpf.h> | |||
#include <linux/can.h> | |||
#include <linux/can/error.h> | |||
#include <linux/can/raw.h> | |||
#include <linux/capability.h> | |||
#include <linux/cryptouser.h> | |||
#include <linux/devlink.h> | |||
#include <linux/dm-ioctl.h> | |||
#include <linux/errqueue.h> | |||
#include <linux/falloc.h> | |||
#include <linux/fanotify.h> | |||
@@ -297,6 +302,7 @@ includes_NetBSD=' | |||
#include <sys/extattr.h> | |||
#include <sys/mman.h> | |||
#include <sys/mount.h> | |||
#include <sys/sched.h> | |||
#include <sys/select.h> | |||
#include <sys/socket.h> | |||
#include <sys/sockio.h> | |||
@@ -325,6 +331,7 @@ includes_OpenBSD=' | |||
#include <sys/mman.h> | |||
#include <sys/mount.h> | |||
#include <sys/select.h> | |||
#include <sys/sched.h> | |||
#include <sys/socket.h> | |||
#include <sys/sockio.h> | |||
#include <sys/stat.h> | |||
@@ -507,11 +514,14 @@ ccflags="$@" | |||
$2 ~ /^(CLOCK|TIMER)_/ || | |||
$2 ~ /^CAN_/ || | |||
$2 ~ /^CAP_/ || | |||
$2 ~ /^CP_/ || | |||
$2 ~ /^CPUSTATES$/ || | |||
$2 ~ /^ALG_/ || | |||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ || | |||
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ || | |||
$2 ~ /^FS_VERITY_/ || | |||
$2 ~ /^FSCRYPT_/ || | |||
$2 ~ /^DM_/ || | |||
$2 ~ /^GRND_/ || | |||
$2 ~ /^RND/ || | |||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ || |
@@ -527,6 +527,23 @@ func SysctlClockinfo(name string) (*Clockinfo, error) { | |||
return &ci, nil | |||
} | |||
func SysctlTimeval(name string) (*Timeval, error) { | |||
mib, err := sysctlmib(name) | |||
if err != nil { | |||
return nil, err | |||
} | |||
var tv Timeval | |||
n := uintptr(unsafe.Sizeof(tv)) | |||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&tv)), &n, nil, 0); err != nil { | |||
return nil, err | |||
} | |||
if n != unsafe.Sizeof(tv) { | |||
return nil, EIO | |||
} | |||
return &tv, nil | |||
} | |||
//sys utimes(path string, timeval *[2]Timeval) (err error) | |||
func Utimes(path string, tv []Timeval) error { |
@@ -10,6 +10,8 @@ import ( | |||
"unsafe" | |||
) | |||
const _SYS_GETDIRENTRIES64 = 344 | |||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { | |||
// To implement this using libSystem we'd need syscall_syscallPtr for | |||
// fdopendir. However, syscallPtr was only added in Go 1.13, so we fall | |||
@@ -20,7 +22,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { | |||
} else { | |||
p = unsafe.Pointer(&_zero) | |||
} | |||
r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) | |||
r0, _, e1 := Syscall6(_SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) | |||
n = int(r0) | |||
if e1 != 0 { | |||
return n, errnoErr(e1) |
@@ -49,6 +49,11 @@ type SockaddrDatalink struct { | |||
raw RawSockaddrDatalink | |||
} | |||
// Some external packages rely on SYS___SYSCTL being defined to implement their | |||
// own sysctl wrappers. Provide it here, even though direct syscalls are no | |||
// longer supported on darwin. | |||
const SYS___SYSCTL = 202 | |||
// Translate "kern.hostname" to []_C_int{0,1,2,3}. | |||
func nametomib(name string) (mib []_C_int, err error) { | |||
const siz = unsafe.Sizeof(mib[0]) | |||
@@ -396,6 +401,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
//sys Chroot(path string) (err error) | |||
//sys ClockGettime(clockid int32, time *Timespec) (err error) | |||
//sys Close(fd int) (err error) | |||
//sys Clonefile(src string, dst string, flags int) (err error) | |||
//sys Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) | |||
//sys Dup(fd int) (nfd int, err error) | |||
//sys Dup2(from int, to int) (err error) | |||
//sys Exchangedata(path1 string, path2 string, options int) (err error) | |||
@@ -407,6 +414,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e | |||
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) | |||
//sys Fchown(fd int, uid int, gid int) (err error) | |||
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) | |||
//sys Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) | |||
//sys Flock(fd int, how int) (err error) | |||
//sys Fpathconf(fd int, name int) (val int, err error) | |||
//sys Fsync(fd int) (err error) |
@@ -1,9 +0,0 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build darwin,386,!go1.12 | |||
package unix | |||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 |
@@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) | |||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions | |||
// of darwin/386 the syscall is called sysctl instead of __sysctl. | |||
const SYS___SYSCTL = SYS_SYSCTL | |||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 | |||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 | |||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 |
@@ -1,9 +0,0 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build darwin,amd64,!go1.12 | |||
package unix | |||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 |
@@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) | |||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions | |||
// of darwin/amd64 the syscall is called sysctl instead of __sysctl. | |||
const SYS___SYSCTL = SYS_SYSCTL | |||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 | |||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 | |||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 |
@@ -1,11 +0,0 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build darwin,arm,!go1.12 | |||
package unix | |||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { | |||
return 0, ENOSYS | |||
} |
@@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic | |||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions | |||
// of darwin/arm the syscall is called sysctl instead of __sysctl. | |||
const SYS___SYSCTL = SYS_SYSCTL | |||
//sys Fstat(fd int, stat *Stat_t) (err error) | |||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) | |||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) |
@@ -1,11 +0,0 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build darwin,arm64,!go1.12 | |||
package unix | |||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { | |||
return 0, ENOSYS | |||
} |
@@ -46,10 +46,6 @@ func (cmsg *Cmsghdr) SetLen(length int) { | |||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic | |||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions | |||
// of darwin/arm64 the syscall is called sysctl instead of __sysctl. | |||
const SYS___SYSCTL = SYS_SYSCTL | |||
//sys Fstat(fd int, stat *Stat_t) (err error) | |||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) | |||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) |
@@ -24,7 +24,7 @@ func bytes2iovec(bs [][]byte) []Iovec { | |||
return iovecs | |||
} | |||
//sys readv(fd int, iovs []Iovec) (n int, err error) | |||
//sys readv(fd int, iovs []Iovec) (n int, err error) | |||
func Readv(fd int, iovs [][]byte) (n int, err error) { | |||
iovecs := bytes2iovec(iovs) | |||
@@ -32,7 +32,7 @@ func Readv(fd int, iovs [][]byte) (n int, err error) { | |||
return n, err | |||
} | |||
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error) | |||
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error) | |||
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { | |||
iovecs := bytes2iovec(iovs) | |||
@@ -40,7 +40,7 @@ func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { | |||
return n, err | |||
} | |||
//sys writev(fd int, iovs []Iovec) (n int, err error) | |||
//sys writev(fd int, iovs []Iovec) (n int, err error) | |||
func Writev(fd int, iovs [][]byte) (n int, err error) { | |||
iovecs := bytes2iovec(iovs) | |||
@@ -48,10 +48,43 @@ func Writev(fd int, iovs [][]byte) (n int, err error) { | |||
return n, err | |||
} | |||
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error) | |||
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error) | |||
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { | |||
iovecs := bytes2iovec(iovs) | |||
n, err = pwritev(fd, iovecs, off) | |||
return n, err | |||
} | |||
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) | |||
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { | |||
var rsa RawSockaddrAny | |||
var len _Socklen = SizeofSockaddrAny | |||
nfd, err = accept4(fd, &rsa, &len, flags) | |||
if err != nil { | |||
return | |||
} | |||
if len > SizeofSockaddrAny { | |||
panic("RawSockaddrAny too small") | |||
} | |||
sa, err = anyToSockaddr(fd, &rsa) | |||
if err != nil { | |||
Close(nfd) | |||
nfd = 0 | |||
} | |||
return | |||
} | |||
//sysnb pipe2(p *[2]_C_int, flags int) (err error) | |||
func Pipe2(p []int, flags int) error { | |||
if len(p) != 2 { | |||
return EINVAL | |||
} | |||
var pp [2]_C_int | |||
err := pipe2(&pp, flags) | |||
p[0] = int(pp[0]) | |||
p[1] = int(pp[1]) | |||
return err | |||
} |
@@ -82,15 +82,6 @@ func IoctlRetInt(fd int, req uint) (int, error) { | |||
return int(ret), nil | |||
} | |||
// IoctlSetPointerInt performs an ioctl operation which sets an | |||
// integer value on fd, using the specified request number. The ioctl | |||
// argument is called with a pointer to the integer value, rather than | |||
// passing the integer value directly. | |||
func IoctlSetPointerInt(fd int, req uint, value int) error { | |||
v := int32(value) | |||
return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) | |||
} | |||
func IoctlSetRTCTime(fd int, value *RTCTime) error { | |||
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value))) | |||
runtime.KeepAlive(value) | |||
@@ -145,6 +136,12 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) | |||
return openat(dirfd, path, flags|O_LARGEFILE, mode) | |||
} | |||
//sys openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error) | |||
func Openat2(dirfd int, path string, how *OpenHow) (fd int, err error) { | |||
return openat2(dirfd, path, how, SizeofOpenHow) | |||
} | |||
//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) | |||
func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { | |||
@@ -885,6 +882,35 @@ func (sa *SockaddrL2TPIP6) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
return unsafe.Pointer(&sa.raw), SizeofSockaddrL2TPIP6, nil | |||
} | |||
// SockaddrIUCV implements the Sockaddr interface for AF_IUCV sockets. | |||
type SockaddrIUCV struct { | |||
UserID string | |||
Name string | |||
raw RawSockaddrIUCV | |||
} | |||
func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) { | |||
sa.raw.Family = AF_IUCV | |||
// These are EBCDIC encoded by the kernel, but we still need to pad them | |||
// with blanks. Initializing with blanks allows the caller to feed in either | |||
// a padded or an unpadded string. | |||
for i := 0; i < 8; i++ { | |||
sa.raw.Nodeid[i] = ' ' | |||
sa.raw.User_id[i] = ' ' | |||
sa.raw.Name[i] = ' ' | |||
} | |||
if len(sa.UserID) > 8 || len(sa.Name) > 8 { | |||
return nil, 0, EINVAL | |||
} | |||
for i, b := range []byte(sa.UserID[:]) { | |||
sa.raw.User_id[i] = int8(b) | |||
} | |||
for i, b := range []byte(sa.Name[:]) { | |||
sa.raw.Name[i] = int8(b) | |||
} | |||
return unsafe.Pointer(&sa.raw), SizeofSockaddrIUCV, nil | |||
} | |||
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
switch rsa.Addr.Family { | |||
case AF_NETLINK: | |||
@@ -1065,6 +1091,38 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |||
} | |||
return sa, nil | |||
case AF_IUCV: | |||
pp := (*RawSockaddrIUCV)(unsafe.Pointer(rsa)) | |||
var user [8]byte | |||
var name [8]byte | |||
for i := 0; i < 8; i++ { | |||
user[i] = byte(pp.User_id[i]) | |||
name[i] = byte(pp.Name[i]) | |||
} | |||
sa := &SockaddrIUCV{ | |||
UserID: string(user[:]), | |||
Name: string(name[:]), | |||
} | |||
return sa, nil | |||
case AF_CAN: | |||
pp := (*RawSockaddrCAN)(unsafe.Pointer(rsa)) | |||
sa := &SockaddrCAN{ | |||
Ifindex: int(pp.Ifindex), | |||
} | |||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID)) | |||
for i := 0; i < 4; i++ { | |||
rx[i] = pp.Addr[i] | |||
} | |||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID)) | |||
for i := 0; i < 4; i++ { | |||
tx[i] = pp.Addr[i+4] | |||
} | |||
return sa, nil | |||
} | |||
return nil, EAFNOSUPPORT | |||
} | |||
@@ -1965,10 +2023,15 @@ func isGroupMember(gid int) bool { | |||
} | |||
//sys faccessat(dirfd int, path string, mode uint32) (err error) | |||
//sys Faccessat2(dirfd int, path string, mode uint32, flags int) (err error) | |||
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { | |||
if flags & ^(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 { | |||
return EINVAL | |||
if flags == 0 { | |||
return faccessat(dirfd, path, mode) | |||
} | |||
if err := Faccessat2(dirfd, path, mode, flags); err != ENOSYS && err != EPERM { | |||
return err | |||
} | |||
// The Linux kernel faccessat system call does not take any flags. | |||
@@ -1977,8 +2040,8 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { | |||
// Because people naturally expect syscall.Faccessat to act | |||
// like C faccessat, we do the same. | |||
if flags == 0 { | |||
return faccessat(dirfd, path, mode) | |||
if flags & ^(AT_SYMLINK_NOFOLLOW|AT_EACCESS) != 0 { | |||
return EINVAL | |||
} | |||
var st Stat_t | |||
@@ -2122,6 +2185,18 @@ func Klogset(typ int, arg int) (err error) { | |||
return nil | |||
} | |||
// RemoteIovec is Iovec with the pointer replaced with an integer. | |||
// It is used for ProcessVMReadv and ProcessVMWritev, where the pointer | |||
// refers to a location in a different process' address space, which | |||
// would confuse the Go garbage collector. | |||
type RemoteIovec struct { | |||
Base uintptr | |||
Len int | |||
} | |||
//sys ProcessVMReadv(pid int, localIov []Iovec, remoteIov []RemoteIovec, flags uint) (n int, err error) = SYS_PROCESS_VM_READV | |||
//sys ProcessVMWritev(pid int, localIov []Iovec, remoteIov []RemoteIovec, flags uint) (n int, err error) = SYS_PROCESS_VM_WRITEV | |||
/* | |||
* Unimplemented | |||
*/ |
@@ -7,7 +7,6 @@ | |||
package unix | |||
import ( | |||
"syscall" | |||
"unsafe" | |||
) | |||
@@ -49,10 +48,6 @@ func Pipe2(p []int, flags int) (err error) { | |||
return | |||
} | |||
// Underlying system call writes to newoffset via pointer. | |||
// Implemented in assembly to avoid allocation. | |||
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) | |||
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { | |||
newoffset, errno := seek(fd, offset, whence) | |||
if errno != 0 { |
@@ -0,0 +1,13 @@ | |||
// Copyright 2009 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
// +build arm,!gccgo,linux | |||
package unix | |||
import "syscall" | |||
// Underlying system call writes to newoffset via pointer. | |||
// Implemented in assembly to avoid allocation. | |||
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) |
@@ -0,0 +1,35 @@ | |||
// Copyright 2019 The Go Authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
package unix | |||
func setTimespec(sec, nsec int64) Timespec { | |||
return Timespec{Sec: sec, Nsec: nsec} | |||
} | |||
func setTimeval(sec, usec int64) Timeval { | |||
return Timeval{Sec: sec, Usec: usec} | |||
} | |||
func SetKevent(k *Kevent_t, fd, mode, flags int) { | |||
k.Ident = uint64(fd) | |||
k.Filter = int16(mode) | |||
k.Flags = uint16(flags) | |||
} | |||
func (iov *Iovec) SetLen(length int) { | |||
iov.Len = uint64(length) | |||
} | |||
func (msghdr *Msghdr) SetControllen(length int) { | |||
msghdr.Controllen = uint32(length) | |||
} | |||
func (cmsg *Cmsghdr) SetLen(length int) { | |||
cmsg.Len = uint32(length) | |||
} | |||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions | |||
// of OpenBSD the syscall is called sysctl instead of __sysctl. | |||
const SYS___SYSCTL = SYS_SYSCTL |
@@ -232,6 +232,8 @@ const ( | |||
CLOCK_THREAD_CPUTIME_ID = 0x10 | |||
CLOCK_UPTIME_RAW = 0x8 | |||
CLOCK_UPTIME_RAW_APPROX = 0x9 | |||
CLONE_NOFOLLOW = 0x1 | |||
CLONE_NOOWNERCOPY = 0x2 | |||
CR0 = 0x0 | |||
CR1 = 0x1000 | |||
CR2 = 0x2000 |
@@ -232,6 +232,8 @@ const ( | |||
CLOCK_THREAD_CPUTIME_ID = 0x10 | |||
CLOCK_UPTIME_RAW = 0x8 | |||
CLOCK_UPTIME_RAW_APPROX = 0x9 | |||
CLONE_NOFOLLOW = 0x1 | |||
CLONE_NOOWNERCOPY = 0x2 | |||
CR0 = 0x0 | |||
CR1 = 0x1000 | |||
CR2 = 0x2000 |
@@ -232,6 +232,8 @@ const ( | |||
CLOCK_THREAD_CPUTIME_ID = 0x10 | |||
CLOCK_UPTIME_RAW = 0x8 | |||
CLOCK_UPTIME_RAW_APPROX = 0x9 | |||
CLONE_NOFOLLOW = 0x1 | |||
CLONE_NOOWNERCOPY = 0x2 | |||
CR0 = 0x0 | |||
CR1 = 0x1000 | |||
CR2 = 0x2000 |
@@ -232,6 +232,8 @@ const ( | |||
CLOCK_THREAD_CPUTIME_ID = 0x10 | |||
CLOCK_UPTIME_RAW = 0x8 | |||
CLOCK_UPTIME_RAW_APPROX = 0x9 | |||
CLONE_NOFOLLOW = 0x1 | |||
CLONE_NOOWNERCOPY = 0x2 | |||
CR0 = 0x0 | |||
CR1 = 0x1000 | |||
CR2 = 0x2000 |
@@ -339,6 +339,12 @@ const ( | |||
CLOCK_UPTIME_FAST = 0x8 | |||
CLOCK_UPTIME_PRECISE = 0x7 | |||
CLOCK_VIRTUAL = 0x1 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x30000 | |||
CS5 = 0x0 |
@@ -339,6 +339,12 @@ const ( | |||
CLOCK_UPTIME_FAST = 0x8 | |||
CLOCK_UPTIME_PRECISE = 0x7 | |||
CLOCK_VIRTUAL = 0x1 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x30000 | |||
CS5 = 0x0 |
@@ -339,6 +339,12 @@ const ( | |||
CLOCK_UPTIME_FAST = 0x8 | |||
CLOCK_UPTIME_PRECISE = 0x7 | |||
CLOCK_VIRTUAL = 0x1 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x30000 | |||
CS5 = 0x0 |
@@ -339,6 +339,12 @@ const ( | |||
CLOCK_UPTIME_FAST = 0x8 | |||
CLOCK_UPTIME_PRECISE = 0x7 | |||
CLOCK_VIRTUAL = 0x1 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x30000 | |||
CS5 = 0x0 |
@@ -244,8 +244,66 @@ const ( | |||
CAN_EFF_FLAG = 0x80000000 | |||
CAN_EFF_ID_BITS = 0x1d | |||
CAN_EFF_MASK = 0x1fffffff | |||
CAN_ERR_ACK = 0x20 | |||
CAN_ERR_BUSERROR = 0x80 | |||
CAN_ERR_BUSOFF = 0x40 | |||
CAN_ERR_CRTL = 0x4 | |||
CAN_ERR_CRTL_ACTIVE = 0x40 | |||
CAN_ERR_CRTL_RX_OVERFLOW = 0x1 | |||
CAN_ERR_CRTL_RX_PASSIVE = 0x10 | |||
CAN_ERR_CRTL_RX_WARNING = 0x4 | |||
CAN_ERR_CRTL_TX_OVERFLOW = 0x2 | |||
CAN_ERR_CRTL_TX_PASSIVE = 0x20 | |||
CAN_ERR_CRTL_TX_WARNING = 0x8 | |||
CAN_ERR_CRTL_UNSPEC = 0x0 | |||
CAN_ERR_DLC = 0x8 | |||
CAN_ERR_FLAG = 0x20000000 | |||
CAN_ERR_LOSTARB = 0x2 | |||
CAN_ERR_LOSTARB_UNSPEC = 0x0 | |||
CAN_ERR_MASK = 0x1fffffff | |||
CAN_ERR_PROT = 0x8 | |||
CAN_ERR_PROT_ACTIVE = 0x40 | |||
CAN_ERR_PROT_BIT = 0x1 | |||
CAN_ERR_PROT_BIT0 = 0x8 | |||
CAN_ERR_PROT_BIT1 = 0x10 | |||
CAN_ERR_PROT_FORM = 0x2 | |||
CAN_ERR_PROT_LOC_ACK = 0x19 | |||
CAN_ERR_PROT_LOC_ACK_DEL = 0x1b | |||
CAN_ERR_PROT_LOC_CRC_DEL = 0x18 | |||
CAN_ERR_PROT_LOC_CRC_SEQ = 0x8 | |||
CAN_ERR_PROT_LOC_DATA = 0xa | |||
CAN_ERR_PROT_LOC_DLC = 0xb | |||
CAN_ERR_PROT_LOC_EOF = 0x1a | |||
CAN_ERR_PROT_LOC_ID04_00 = 0xe | |||
CAN_ERR_PROT_LOC_ID12_05 = 0xf | |||
CAN_ERR_PROT_LOC_ID17_13 = 0x7 | |||
CAN_ERR_PROT_LOC_ID20_18 = 0x6 | |||
CAN_ERR_PROT_LOC_ID28_21 = 0x2 | |||
CAN_ERR_PROT_LOC_IDE = 0x5 | |||
CAN_ERR_PROT_LOC_INTERM = 0x12 | |||
CAN_ERR_PROT_LOC_RES0 = 0x9 | |||
CAN_ERR_PROT_LOC_RES1 = 0xd | |||
CAN_ERR_PROT_LOC_RTR = 0xc | |||
CAN_ERR_PROT_LOC_SOF = 0x3 | |||
CAN_ERR_PROT_LOC_SRTR = 0x4 | |||
CAN_ERR_PROT_LOC_UNSPEC = 0x0 | |||
CAN_ERR_PROT_OVERLOAD = 0x20 | |||
CAN_ERR_PROT_STUFF = 0x4 | |||
CAN_ERR_PROT_TX = 0x80 | |||
CAN_ERR_PROT_UNSPEC = 0x0 | |||
CAN_ERR_RESTARTED = 0x100 | |||
CAN_ERR_TRX = 0x10 | |||
CAN_ERR_TRX_CANH_NO_WIRE = 0x4 | |||
CAN_ERR_TRX_CANH_SHORT_TO_BAT = 0x5 | |||
CAN_ERR_TRX_CANH_SHORT_TO_GND = 0x7 | |||
CAN_ERR_TRX_CANH_SHORT_TO_VCC = 0x6 | |||
CAN_ERR_TRX_CANL_NO_WIRE = 0x40 | |||
CAN_ERR_TRX_CANL_SHORT_TO_BAT = 0x50 | |||
CAN_ERR_TRX_CANL_SHORT_TO_CANH = 0x80 | |||
CAN_ERR_TRX_CANL_SHORT_TO_GND = 0x70 | |||
CAN_ERR_TRX_CANL_SHORT_TO_VCC = 0x60 | |||
CAN_ERR_TRX_UNSPEC = 0x0 | |||
CAN_ERR_TX_TIMEOUT = 0x1 | |||
CAN_INV_FILTER = 0x20000000 | |||
CAN_ISOTP = 0x6 | |||
CAN_J1939 = 0x7 | |||
@@ -265,6 +323,7 @@ const ( | |||
CAP_AUDIT_READ = 0x25 | |||
CAP_AUDIT_WRITE = 0x1d | |||
CAP_BLOCK_SUSPEND = 0x24 | |||
CAP_BPF = 0x27 | |||
CAP_CHOWN = 0x0 | |||
CAP_DAC_OVERRIDE = 0x1 | |||
CAP_DAC_READ_SEARCH = 0x2 | |||
@@ -273,7 +332,7 @@ const ( | |||
CAP_IPC_LOCK = 0xe | |||
CAP_IPC_OWNER = 0xf | |||
CAP_KILL = 0x5 | |||
CAP_LAST_CAP = 0x25 | |||
CAP_LAST_CAP = 0x27 | |||
CAP_LEASE = 0x1c | |||
CAP_LINUX_IMMUTABLE = 0x9 | |||
CAP_MAC_ADMIN = 0x21 | |||
@@ -283,6 +342,7 @@ const ( | |||
CAP_NET_BIND_SERVICE = 0xa | |||
CAP_NET_BROADCAST = 0xb | |||
CAP_NET_RAW = 0xd | |||
CAP_PERFMON = 0x26 | |||
CAP_SETFCAP = 0x1f | |||
CAP_SETGID = 0x6 | |||
CAP_SETPCAP = 0x8 | |||
@@ -372,8 +432,54 @@ const ( | |||
DEVLINK_GENL_NAME = "devlink" | |||
DEVLINK_GENL_VERSION = 0x1 | |||
DEVLINK_SB_THRESHOLD_TO_ALPHA_MAX = 0x14 | |||
DEVMEM_MAGIC = 0x454d444d | |||
DEVPTS_SUPER_MAGIC = 0x1cd1 | |||
DMA_BUF_MAGIC = 0x444d4142 | |||
DM_ACTIVE_PRESENT_FLAG = 0x20 | |||
DM_BUFFER_FULL_FLAG = 0x100 | |||
DM_CONTROL_NODE = "control" | |||
DM_DATA_OUT_FLAG = 0x10000 | |||
DM_DEFERRED_REMOVE = 0x20000 | |||
DM_DEV_ARM_POLL = 0xc138fd10 | |||
DM_DEV_CREATE = 0xc138fd03 | |||
DM_DEV_REMOVE = 0xc138fd04 | |||
DM_DEV_RENAME = 0xc138fd05 | |||
DM_DEV_SET_GEOMETRY = 0xc138fd0f | |||
DM_DEV_STATUS = 0xc138fd07 | |||
DM_DEV_SUSPEND = 0xc138fd06 | |||
DM_DEV_WAIT = 0xc138fd08 | |||
DM_DIR = "mapper" | |||
DM_GET_TARGET_VERSION = 0xc138fd11 | |||
DM_INACTIVE_PRESENT_FLAG = 0x40 | |||
DM_INTERNAL_SUSPEND_FLAG = 0x40000 | |||
DM_IOCTL = 0xfd | |||
DM_LIST_DEVICES = 0xc138fd02 | |||
DM_LIST_VERSIONS = 0xc138fd0d | |||
DM_MAX_TYPE_NAME = 0x10 | |||
DM_NAME_LEN = 0x80 | |||
DM_NOFLUSH_FLAG = 0x800 | |||
DM_PERSISTENT_DEV_FLAG = 0x8 | |||
DM_QUERY_INACTIVE_TABLE_FLAG = 0x1000 | |||
DM_READONLY_FLAG = 0x1 | |||
DM_REMOVE_ALL = 0xc138fd01 | |||
DM_SECURE_DATA_FLAG = 0x8000 | |||
DM_SKIP_BDGET_FLAG = 0x200 | |||
DM_SKIP_LOCKFS_FLAG = 0x400 | |||
DM_STATUS_TABLE_FLAG = 0x10 | |||
DM_SUSPEND_FLAG = 0x2 | |||
DM_TABLE_CLEAR = 0xc138fd0a | |||
DM_TABLE_DEPS = 0xc138fd0b | |||
DM_TABLE_LOAD = 0xc138fd09 | |||
DM_TABLE_STATUS = 0xc138fd0c | |||
DM_TARGET_MSG = 0xc138fd0e | |||
DM_UEVENT_GENERATED_FLAG = 0x2000 | |||
DM_UUID_FLAG = 0x4000 | |||
DM_UUID_LEN = 0x81 | |||
DM_VERSION = 0xc138fd00 | |||
DM_VERSION_EXTRA = "-ioctl (2020-02-27)" | |||
DM_VERSION_MAJOR = 0x4 | |||
DM_VERSION_MINOR = 0x2a | |||
DM_VERSION_PATCHLEVEL = 0x0 | |||
DT_BLK = 0x6 | |||
DT_CHR = 0x2 | |||
DT_DIR = 0x4 | |||
@@ -475,6 +581,7 @@ const ( | |||
ETH_P_MOBITEX = 0x15 | |||
ETH_P_MPLS_MC = 0x8848 | |||
ETH_P_MPLS_UC = 0x8847 | |||
ETH_P_MRP = 0x88e3 | |||
ETH_P_MVRP = 0x88f5 | |||
ETH_P_NCSI = 0x88f8 | |||
ETH_P_NSH = 0x894f | |||
@@ -602,8 +709,9 @@ const ( | |||
FSCRYPT_POLICY_FLAGS_PAD_4 = 0x0 | |||
FSCRYPT_POLICY_FLAGS_PAD_8 = 0x1 | |||
FSCRYPT_POLICY_FLAGS_PAD_MASK = 0x3 | |||
FSCRYPT_POLICY_FLAGS_VALID = 0xf | |||
FSCRYPT_POLICY_FLAGS_VALID = 0x1f | |||
FSCRYPT_POLICY_FLAG_DIRECT_KEY = 0x4 | |||
FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 = 0x10 | |||
FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 = 0x8 | |||
FSCRYPT_POLICY_V1 = 0x0 | |||
FSCRYPT_POLICY_V2 = 0x2 | |||
@@ -632,7 +740,7 @@ const ( | |||
FS_POLICY_FLAGS_PAD_4 = 0x0 | |||
FS_POLICY_FLAGS_PAD_8 = 0x1 | |||
FS_POLICY_FLAGS_PAD_MASK = 0x3 | |||
FS_POLICY_FLAGS_VALID = 0xf | |||
FS_POLICY_FLAGS_VALID = 0x1f | |||
FS_VERITY_FL = 0x100000 | |||
FS_VERITY_HASH_ALG_SHA256 = 0x1 | |||
FS_VERITY_HASH_ALG_SHA512 = 0x2 | |||
@@ -834,6 +942,7 @@ const ( | |||
IPPROTO_EGP = 0x8 | |||
IPPROTO_ENCAP = 0x62 | |||
IPPROTO_ESP = 0x32 | |||
IPPROTO_ETHERNET = 0x8f | |||
IPPROTO_FRAGMENT = 0x2c | |||
IPPROTO_GRE = 0x2f | |||
IPPROTO_HOPOPTS = 0x0 | |||
@@ -847,6 +956,7 @@ const ( | |||
IPPROTO_L2TP = 0x73 | |||
IPPROTO_MH = 0x87 | |||
IPPROTO_MPLS = 0x89 | |||
IPPROTO_MPTCP = 0x106 | |||
IPPROTO_MTP = 0x5c | |||
IPPROTO_NONE = 0x3b | |||
IPPROTO_PIM = 0x67 | |||
@@ -1016,6 +1126,7 @@ const ( | |||
KEYCTL_CAPS0_PERSISTENT_KEYRINGS = 0x2 | |||
KEYCTL_CAPS0_PUBLIC_KEY = 0x8 | |||
KEYCTL_CAPS0_RESTRICT_KEYRING = 0x40 | |||
KEYCTL_CAPS1_NOTIFICATIONS = 0x4 | |||
KEYCTL_CAPS1_NS_KEYRING_NAME = 0x1 | |||
KEYCTL_CAPS1_NS_KEY_TAG = 0x2 | |||
KEYCTL_CHOWN = 0x4 | |||
@@ -1053,6 +1164,7 @@ const ( | |||
KEYCTL_SUPPORTS_VERIFY = 0x8 | |||
KEYCTL_UNLINK = 0x9 | |||
KEYCTL_UPDATE = 0x2 | |||
KEYCTL_WATCH_KEY = 0x20 | |||
KEY_REQKEY_DEFL_DEFAULT = 0x0 | |||
KEY_REQKEY_DEFL_GROUP_KEYRING = 0x6 | |||
KEY_REQKEY_DEFL_NO_CHANGE = -0x1 | |||
@@ -1096,6 +1208,8 @@ const ( | |||
LOOP_SET_FD = 0x4c00 | |||
LOOP_SET_STATUS = 0x4c02 | |||
LOOP_SET_STATUS64 = 0x4c04 | |||
LOOP_SET_STATUS_CLEARABLE_FLAGS = 0x4 | |||
LOOP_SET_STATUS_SETTABLE_FLAGS = 0xc | |||
LO_KEY_SIZE = 0x20 | |||
LO_NAME_SIZE = 0x40 | |||
MADV_COLD = 0x14 | |||
@@ -1929,6 +2043,7 @@ const ( | |||
SOL_ATM = 0x108 | |||
SOL_CAIF = 0x116 | |||
SOL_CAN_BASE = 0x64 | |||
SOL_CAN_RAW = 0x65 | |||
SOL_DCCP = 0x10d | |||
SOL_DECNET = 0x105 | |||
SOL_ICMPV6 = 0x3a | |||
@@ -1992,8 +2107,10 @@ const ( | |||
STATX_ATTR_APPEND = 0x20 | |||
STATX_ATTR_AUTOMOUNT = 0x1000 | |||
STATX_ATTR_COMPRESSED = 0x4 | |||
STATX_ATTR_DAX = 0x2000 | |||
STATX_ATTR_ENCRYPTED = 0x800 | |||
STATX_ATTR_IMMUTABLE = 0x10 | |||
STATX_ATTR_MOUNT_ROOT = 0x2000 | |||
STATX_ATTR_NODUMP = 0x40 | |||
STATX_ATTR_VERITY = 0x100000 | |||
STATX_BASIC_STATS = 0x7ff | |||
@@ -2002,6 +2119,7 @@ const ( | |||
STATX_CTIME = 0x80 | |||
STATX_GID = 0x10 | |||
STATX_INO = 0x100 | |||
STATX_MNT_ID = 0x1000 | |||
STATX_MODE = 0x2 | |||
STATX_MTIME = 0x40 | |||
STATX_NLINK = 0x4 |
@@ -192,6 +192,7 @@ const ( | |||
PPPIOCSRASYNCMAP = 0x40047454 | |||
PPPIOCSXASYNCMAP = 0x4020744f | |||
PPPIOCXFERUNIT = 0x744e | |||
PROT_BTI = 0x10 | |||
PR_SET_PTRACER_ANY = 0xffffffffffffffff | |||
PTRACE_SYSEMU = 0x1f | |||
PTRACE_SYSEMU_SINGLESTEP = 0x20 |
@@ -158,6 +158,12 @@ const ( | |||
CLONE_SIGHAND = 0x800 | |||
CLONE_VFORK = 0x4000 | |||
CLONE_VM = 0x100 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -158,6 +158,12 @@ const ( | |||
CLONE_SIGHAND = 0x800 | |||
CLONE_VFORK = 0x4000 | |||
CLONE_VM = 0x100 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -150,6 +150,12 @@ const ( | |||
BRKINT = 0x2 | |||
CFLUSH = 0xf | |||
CLOCAL = 0x8000 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -158,6 +158,12 @@ const ( | |||
CLONE_SIGHAND = 0x800 | |||
CLONE_VFORK = 0x4000 | |||
CLONE_VM = 0x100 | |||
CPUSTATES = 0x5 | |||
CP_IDLE = 0x4 | |||
CP_INTR = 0x3 | |||
CP_NICE = 0x1 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -146,6 +146,13 @@ const ( | |||
BRKINT = 0x2 | |||
CFLUSH = 0xf | |||
CLOCAL = 0x8000 | |||
CPUSTATES = 0x6 | |||
CP_IDLE = 0x5 | |||
CP_INTR = 0x4 | |||
CP_NICE = 0x1 | |||
CP_SPIN = 0x3 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -153,6 +153,13 @@ const ( | |||
CLOCK_REALTIME = 0x0 | |||
CLOCK_THREAD_CPUTIME_ID = 0x4 | |||
CLOCK_UPTIME = 0x5 | |||
CPUSTATES = 0x6 | |||
CP_IDLE = 0x5 | |||
CP_INTR = 0x4 | |||
CP_NICE = 0x1 | |||
CP_SPIN = 0x3 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -146,6 +146,13 @@ const ( | |||
BRKINT = 0x2 | |||
CFLUSH = 0xf | |||
CLOCAL = 0x8000 | |||
CPUSTATES = 0x6 | |||
CP_IDLE = 0x5 | |||
CP_INTR = 0x4 | |||
CP_NICE = 0x1 | |||
CP_SPIN = 0x3 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -156,6 +156,13 @@ const ( | |||
CLOCK_REALTIME = 0x0 | |||
CLOCK_THREAD_CPUTIME_ID = 0x4 | |||
CLOCK_UPTIME = 0x5 | |||
CPUSTATES = 0x6 | |||
CP_IDLE = 0x5 | |||
CP_INTR = 0x4 | |||
CP_NICE = 0x1 | |||
CP_SPIN = 0x3 | |||
CP_SYS = 0x2 | |||
CP_USER = 0x0 | |||
CREAD = 0x800 | |||
CRTSCTS = 0x10000 | |||
CS5 = 0x0 |
@@ -958,6 +958,56 @@ func libc_close_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefile(src string, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags)) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefile_trampoline() | |||
//go:linkname libc_clonefile libc_clonefile | |||
//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefileat_trampoline() | |||
//go:linkname libc_clonefileat libc_clonefileat | |||
//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Dup(fd int) (nfd int, err error) { | |||
r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0) | |||
nfd = int(r0) | |||
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_fclonefileat_trampoline() | |||
//go:linkname libc_fclonefileat libc_fclonefileat | |||
//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Flock(fd int, how int) (err error) { | |||
_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0) | |||
if e1 != 0 { |
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clock_gettime(SB) | |||
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_close(SB) | |||
TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefile(SB) | |||
TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefileat(SB) | |||
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_dup(SB) | |||
TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchown(SB) | |||
TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchownat(SB) | |||
TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fclonefileat(SB) | |||
TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_flock(SB) | |||
TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getrusage(SB) | |||
TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getsid(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getuid(SB) | |||
TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -266,8 +274,6 @@ TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_munmap(SB) | |||
TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_ptrace(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fstat64(SB) | |||
TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0 |
@@ -958,6 +958,56 @@ func libc_close_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefile(src string, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags)) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefile_trampoline() | |||
//go:linkname libc_clonefile libc_clonefile | |||
//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefileat_trampoline() | |||
//go:linkname libc_clonefileat libc_clonefileat | |||
//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Dup(fd int) (nfd int, err error) { | |||
r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0) | |||
nfd = int(r0) | |||
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_fclonefileat_trampoline() | |||
//go:linkname libc_fclonefileat libc_fclonefileat | |||
//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Flock(fd int, how int) (err error) { | |||
_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0) | |||
if e1 != 0 { |
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clock_gettime(SB) | |||
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_close(SB) | |||
TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefile(SB) | |||
TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefileat(SB) | |||
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_dup(SB) | |||
TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchown(SB) | |||
TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchownat(SB) | |||
TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fclonefileat(SB) | |||
TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_flock(SB) | |||
TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getrusage(SB) | |||
TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getsid(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getuid(SB) | |||
TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -266,8 +274,6 @@ TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_munmap(SB) | |||
TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_ptrace(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fstat64(SB) | |||
TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0 |
@@ -958,6 +958,56 @@ func libc_close_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefile(src string, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags)) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefile_trampoline() | |||
//go:linkname libc_clonefile libc_clonefile | |||
//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefileat_trampoline() | |||
//go:linkname libc_clonefileat libc_clonefileat | |||
//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Dup(fd int) (nfd int, err error) { | |||
r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0) | |||
nfd = int(r0) | |||
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_fclonefileat_trampoline() | |||
//go:linkname libc_fclonefileat libc_fclonefileat | |||
//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Flock(fd int, how int) (err error) { | |||
_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0) | |||
if e1 != 0 { |
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clock_gettime(SB) | |||
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_close(SB) | |||
TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefile(SB) | |||
TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefileat(SB) | |||
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_dup(SB) | |||
TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchown(SB) | |||
TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchownat(SB) | |||
TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fclonefileat(SB) | |||
TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_flock(SB) | |||
TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getrusage(SB) | |||
TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getsid(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getuid(SB) | |||
TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -264,8 +272,6 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_mmap(SB) | |||
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_munmap(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fstat(SB) | |||
TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0 |
@@ -958,6 +958,56 @@ func libc_close_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefile(src string, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall(funcPC(libc_clonefile_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags)) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefile_trampoline() | |||
//go:linkname libc_clonefile libc_clonefile | |||
//go:cgo_import_dynamic libc_clonefile clonefile "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(src) | |||
if err != nil { | |||
return | |||
} | |||
var _p1 *byte | |||
_p1, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_clonefileat_trampoline), uintptr(srcDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_clonefileat_trampoline() | |||
//go:linkname libc_clonefileat libc_clonefileat | |||
//go:cgo_import_dynamic libc_clonefileat clonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Dup(fd int) (nfd int, err error) { | |||
r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0) | |||
nfd = int(r0) | |||
@@ -1146,6 +1196,26 @@ func libc_fchownat_trampoline() | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error) { | |||
var _p0 *byte | |||
_p0, err = BytePtrFromString(dst) | |||
if err != nil { | |||
return | |||
} | |||
_, _, e1 := syscall_syscall6(funcPC(libc_fclonefileat_trampoline), uintptr(srcDirfd), uintptr(dstDirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0, 0) | |||
if e1 != 0 { | |||
err = errnoErr(e1) | |||
} | |||
return | |||
} | |||
func libc_fclonefileat_trampoline() | |||
//go:linkname libc_fclonefileat libc_fclonefileat | |||
//go:cgo_import_dynamic libc_fclonefileat fclonefileat "/usr/lib/libSystem.B.dylib" | |||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT | |||
func Flock(fd int, how int) (err error) { | |||
_, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0) | |||
if e1 != 0 { |
@@ -110,6 +110,10 @@ TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clock_gettime(SB) | |||
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_close(SB) | |||
TEXT ·libc_clonefile_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefile(SB) | |||
TEXT ·libc_clonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_clonefileat(SB) | |||
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_dup(SB) | |||
TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -132,6 +136,8 @@ TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchown(SB) | |||
TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fchownat(SB) | |||
TEXT ·libc_fclonefileat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fclonefileat(SB) | |||
TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_flock(SB) | |||
TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -164,6 +170,8 @@ TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getrusage(SB) | |||
TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getsid(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_getuid(SB) | |||
TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0 | |||
@@ -264,8 +272,6 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_mmap(SB) | |||
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_munmap(SB) | |||
TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_gettimeofday(SB) | |||
TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0 | |||
JMP libc_fstat(SB) | |||
TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0 |