From 0e9230178f6e823e2d330424bd4aa410587c2e19 Mon Sep 17 00:00:00 2001 From: Ben Campbell Date: Mon, 10 Aug 2015 12:50:16 +1200 Subject: [PATCH 1/2] tweak queryparser 'go generate' lines (portablity) sed is used to massage the .go files output from nex and yacc. However, the -i (in-place) option works slightly differently between gnu (eg Linux) and bsd (eg OSX) sed. This change should make it work on both flavours. --- .gitignore | 2 ++ query_string_parser.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 97f0415d..3e5c72b5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ .project .settings .DS_Store +query_string.nn.go.tmp +query_string.y.go.tmp /analysis/token_filters/cld2/cld2-read-only /analysis/token_filters/cld2/libcld2_full.a /utils/bleve_create/bleve_create diff --git a/query_string_parser.go b/query_string_parser.go index 3b035523..a758c037 100644 --- a/query_string_parser.go +++ b/query_string_parser.go @@ -8,12 +8,16 @@ // and limitations under the License. //go:generate nex query_string.nex -//go:generate sed -i "" -e s/Lexer/lexer/g query_string.nn.go -//go:generate sed -i "" -e s/Newlexer/newLexer/g query_string.nn.go -//go:generate sed -i "" -e s/debuglexer/debugLexer/g query_string.nn.go +//go:generate sed -i.tmp -e s/Lexer/lexer/g query_string.nn.go +//go:generate sed -i.tmp -e s/Newlexer/newLexer/g query_string.nn.go +//go:generate sed -i.tmp -e s/debuglexer/debugLexer/g query_string.nn.go //go:generate go fmt query_string.nn.go //go:generate go tool yacc -o query_string.y.go query_string.y -//go:generate sed -i "" -e 1d query_string.y.go +//go:generate sed -i.tmp -e 1d query_string.y.go + +// note: OSX sed and gnu sed handle the -i (in-place) option differently. +// using -i.tmp works on both, at the expense of leaving a couple of +// unsightly .tmp files littering the directory... package bleve From 592c1cb2d8b99e44daeb924eb74a2de2f452961c Mon Sep 17 00:00:00 2001 From: Ben Campbell Date: Tue, 20 Oct 2015 06:53:36 +1300 Subject: [PATCH 2/2] Remove leftover .tmp files in go gen phase --- query_string_parser.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/query_string_parser.go b/query_string_parser.go index a758c037..d70ac61a 100644 --- a/query_string_parser.go +++ b/query_string_parser.go @@ -11,13 +11,15 @@ //go:generate sed -i.tmp -e s/Lexer/lexer/g query_string.nn.go //go:generate sed -i.tmp -e s/Newlexer/newLexer/g query_string.nn.go //go:generate sed -i.tmp -e s/debuglexer/debugLexer/g query_string.nn.go +//go:generate rm query_string.nn.go.tmp //go:generate go fmt query_string.nn.go //go:generate go tool yacc -o query_string.y.go query_string.y //go:generate sed -i.tmp -e 1d query_string.y.go +//go:generate rm query_string.y.go.tmp // note: OSX sed and gnu sed handle the -i (in-place) option differently. -// using -i.tmp works on both, at the expense of leaving a couple of -// unsightly .tmp files littering the directory... +// using -i.tmp works on both, at the expense of having to remove +// the unsightly .tmp files package bleve