diff --git a/Units/parser-go.r/github-issue-2430.d/expected.tags b/Units/parser-go.r/github-issue-2430.d/expected.tags index e69de29bb2..b96e91c99e 100644 --- a/Units/parser-go.r/github-issue-2430.d/expected.tags +++ b/Units/parser-go.r/github-issue-2430.d/expected.tags @@ -0,0 +1 @@ +main input.go /^func main() {$/;" f package:main diff --git a/Units/parser-go.r/github-issue-2430.d/input.go b/Units/parser-go.r/github-issue-2430.d/input.go index e969ee9e47..b46747e627 100644 --- a/Units/parser-go.r/github-issue-2430.d/input.go +++ b/Units/parser-go.r/github-issue-2430.d/input.go @@ -4,3 +4,6 @@ package main type Interval struct { Start, Stop string } + +func main() { +} diff --git a/Units/parser-go.r/github-issue-2430.d/validator b/Units/parser-go.r/github-issue-2430.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/github-issue-2430.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-crash-issue-2220.d/validator b/Units/parser-go.r/go-crash-issue-2220.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-crash-issue-2220.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-dont-solve-type-for-underscore-var.d/validator b/Units/parser-go.r/go-dont-solve-type-for-underscore-var.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-dont-solve-type-for-underscore-var.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-end-field-for-types.d/validator b/Units/parser-go.r/go-end-field-for-types.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-end-field-for-types.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-funcs.d/validator b/Units/parser-go.r/go-funcs.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-funcs.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-goroutines.d/validator b/Units/parser-go.r/go-goroutines.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-goroutines.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-helloworld.d/validator b/Units/parser-go.r/go-helloworld.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-helloworld.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-ignore-underscore-var.d/validator b/Units/parser-go.r/go-ignore-underscore-var.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-ignore-underscore-var.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-op-less-than.d/validator b/Units/parser-go.r/go-op-less-than.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-op-less-than.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-timeouts.d/validator b/Units/parser-go.r/go-timeouts.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-timeouts.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-torture.d/validator b/Units/parser-go.r/go-torture.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-torture.d/validator @@ -0,0 +1 @@ +go diff --git a/Units/parser-go.r/go-variadic-dots.d/validator b/Units/parser-go.r/go-variadic-dots.d/validator new file mode 100644 index 0000000000..4023f20957 --- /dev/null +++ b/Units/parser-go.r/go-variadic-dots.d/validator @@ -0,0 +1 @@ +go diff --git a/circle.yml b/circle.yml index 3ee2a00439..0be573d078 100644 --- a/circle.yml +++ b/circle.yml @@ -22,9 +22,9 @@ jobs: name: Install tools for building ctags and validating test input files command: | dnf -y install awk gcc automake autoconf pkgconfig make libseccomp-devel libxml2-devel jansson-devel libyaml-devel pcre2-devel findutils diffutils sudo - dnf -y install jq puppet python3-sphinx + dnf -y install python3-sphinx # These are for input-validation. - dnf -y install g++ jq puppet nodejs gcc-gfortran gcc-gnat typescript swi-prolog + dnf -y install g++ jq puppet nodejs gcc-gfortran gcc-gnat typescript swi-prolog rubypick golang-bin # nodejs requires libsqlite.so.0 with sqlite-session feature # It was turned off in 3.46.1-1. dnf -y update sqlite-libs diff --git a/docs/news/HEAD.rst b/docs/news/HEAD.rst index 9f47dc3228..3ee7bdd5f3 100644 --- a/docs/news/HEAD.rst +++ b/docs/news/HEAD.rst @@ -76,6 +76,10 @@ QemuHX: * Implement a selector arbitrating Haxe and QemuHX parsers, both handling ``.hx`` file extension. +Go: + + * Add ``receiver`` field to ``func`` kind tags. + New parsers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following parsers have been added: diff --git a/main/vstring.h b/main/vstring.h index c1a3db97f5..f6673cb606 100644 --- a/main/vstring.h +++ b/main/vstring.h @@ -65,8 +65,8 @@ extern void vStringCat (vString *const string, const vString *const s); extern void vStringCatS (vString *const string, const char *const s); extern void vStringNCat (vString *const string, const vString *const s, const size_t length); -/* vStringNCatS calls strnlen(S,LENGTH) thought it takes LENGTH because - * the handle the case that the length of S is smaller than LENGTH. +/* vStringNCatS calls strnlen(S,LENGTH) though it takes LENGTH because + * it handles the case that the length of S is smaller than LENGTH. * * In the case a caller knows the length equals to or is greater than LENGTH, * calling strlen is just overhead. vStringNCatSUnsafe doesn't call strlen. */ diff --git a/misc/validators/g++-common.sh b/misc/validators/g++-common.sh index 716aa4777d..e5c8a58b3b 100644 --- a/misc/validators/g++-common.sh +++ b/misc/validators/g++-common.sh @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # g++-common.sh - common code used in validator-cxx* # # Copyright (c) 2022, Masatake YAMATO @@ -25,11 +26,15 @@ shift 3 case "$action" in is_runnable) - type g++ > /dev/null 2>&1 - exit $? - ;; + command -v g++ > /dev/null 2>&1 + exit $? + ;; validate) - g++ -fsyntax-only -std=${STD} "$@" "$input" > /dev/null - exit $? + g++ -fsyntax-only -std=${STD} "$@" "$input" > /dev/null + exit $? + ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 ;; esac diff --git a/misc/validators/gfortran-common.sh b/misc/validators/gfortran-common.sh index bb7ecab983..f078e854e7 100644 --- a/misc/validators/gfortran-common.sh +++ b/misc/validators/gfortran-common.sh @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # gfortran-common.sh - common code used in validator-fortran* # # Copyright (c) 2024, Masatake YAMATO @@ -24,11 +25,15 @@ shift 2 case "$action" in is_runnable) - type gfortran > /dev/null 2>&1 - exit $? + command -v gfortran > /dev/null 2>&1 + exit $? ;; validate) - gfortran -fsyntax-only "$@" "$input" > /dev/null - exit $? + gfortran -fsyntax-only "$@" "$input" > /dev/null + exit $? + ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 ;; esac diff --git a/misc/validators/tsc-common.sh b/misc/validators/tsc-common.sh index 58966e76b0..7c24a73ffc 100644 --- a/misc/validators/tsc-common.sh +++ b/misc/validators/tsc-common.sh @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # tsc-common.sh - common code used in validator-tsc* # # Copyright (c) 2026, Masatake YAMATO @@ -25,11 +26,15 @@ shift 3 case "$action" in is_runnable) - type tsc > /dev/null 2>&1 - exit $? + command -v tsc > /dev/null 2>&1 + exit $? ;; validate) - tsc --noEmit "$input" --target $TARGET > /dev/null - exit $? + tsc --noEmit "$input" --target $TARGET > /dev/null + exit $? + ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 ;; esac diff --git a/misc/validators/validator-c b/misc/validators/validator-c index 8be2cee9a9..102b56decf 100755 --- a/misc/validators/validator-c +++ b/misc/validators/validator-c @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-c --- validating C input files # # Copyright (c) 2022, Masatake YAMATO @@ -22,11 +23,15 @@ input=$2 case "$action" in is_runnable) - type gcc > /dev/null 2>&1 + command -v gcc > /dev/null 2>&1 exit $? ;; validate) gcc -fsyntax-only "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-cxx03 b/misc/validators/validator-cxx03 index 4881fd1728..89f4964b2f 100755 --- a/misc/validators/validator-cxx03 +++ b/misc/validators/validator-cxx03 @@ -1 +1,2 @@ -source $3/g++-common.sh $1 $2 c++03 +#!/bin/sh +. "$3"/g++-common.sh "$1" "$2" c++03 diff --git a/misc/validators/validator-cxx11 b/misc/validators/validator-cxx11 index f62f8cf61a..0d9c35be2d 100755 --- a/misc/validators/validator-cxx11 +++ b/misc/validators/validator-cxx11 @@ -1 +1,2 @@ -source $3/g++-common.sh $1 $2 c++11 +#!/bin/sh +. "$3"/g++-common.sh "$1" "$2" c++11 diff --git a/misc/validators/validator-cxx17 b/misc/validators/validator-cxx17 index 8710ea63bc..467da64a1c 100755 --- a/misc/validators/validator-cxx17 +++ b/misc/validators/validator-cxx17 @@ -1 +1,2 @@ -source $3/g++-common.sh $1 $2 c++17 +#!/bin/sh +. "$3"/g++-common.sh "$1" "$2" c++17 diff --git a/misc/validators/validator-cxx20+module b/misc/validators/validator-cxx20+module index 4745e4168a..e0bbbe453e 100755 --- a/misc/validators/validator-cxx20+module +++ b/misc/validators/validator-cxx20+module @@ -1 +1,2 @@ -source $3/g++-common.sh $1 $2 c++20 -fmodules-ts -c +#!/bin/sh +. "$3"/g++-common.sh "$1" "$2" c++20 -fmodules-ts -c diff --git a/misc/validators/validator-fortran+dollar-ok b/misc/validators/validator-fortran+dollar-ok index 399df135dd..4beb0db04f 100755 --- a/misc/validators/validator-fortran+dollar-ok +++ b/misc/validators/validator-fortran+dollar-ok @@ -1 +1,2 @@ -source $3/gfortran-common.sh $1 $2 -fdollar-ok +#!/bin/sh +. "$3"/gfortran-common.sh "$1" "$2" -fdollar-ok diff --git a/misc/validators/validator-gnat b/misc/validators/validator-gnat index 352178b119..c665483c83 100755 --- a/misc/validators/validator-gnat +++ b/misc/validators/validator-gnat @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-gnat --- validating Ada input files # # Copyright (c) 2025, Masatake YAMATO @@ -22,11 +23,15 @@ input=$2 case "$action" in is_runnable) - type gnat > /dev/null 2>&1 + command -v gnat > /dev/null 2>&1 exit $? ;; validate) - gnat compile -gnats "$input" >& /dev/null + gnat compile -gnats "$input" > /dev/null 2>&1 exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-go b/misc/validators/validator-go new file mode 100755 index 0000000000..cbcd052988 --- /dev/null +++ b/misc/validators/validator-go @@ -0,0 +1,37 @@ +#!/bin/sh +# +# validator-go - validating go input files with go command +# +# Copyright (c) 2026, Masatake YAMATO +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. +# +action=$1 +input=$2 +case "$action" in + is_runnable) + command -v go > /dev/null 2>&1 + exit $? + ;; + validate) + go build -o /dev/null "$input" + exit $? + ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; +esac diff --git a/misc/validators/validator-jq b/misc/validators/validator-jq index 3f21cdd6f4..5579d271eb 100755 --- a/misc/validators/validator-jq +++ b/misc/validators/validator-jq @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-jq - validating json input files # # Copyright (c) 2018, Red Hat, Inc. @@ -32,11 +33,15 @@ action=$1 input=$2 case "$action" in is_runnable) - type jq > /dev/null 2>&1 + command -v jq > /dev/null 2>&1 exit $? ;; validate) jq . "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-node b/misc/validators/validator-node index 8a5b0a0025..24d472a99f 100755 --- a/misc/validators/validator-node +++ b/misc/validators/validator-node @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-node - validating JavaScript input files with node # # Copyright (c) 2022, Masatake YAMATO @@ -22,11 +23,15 @@ action=$1 input=$2 case "$action" in is_runnable) - type node > /dev/null 2>&1 + command -v node > /dev/null 2>&1 exit $? ;; validate) node --check "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-puppet b/misc/validators/validator-puppet index 36447391a0..40aaa552b2 100755 --- a/misc/validators/validator-puppet +++ b/misc/validators/validator-puppet @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-puppet - validating puppetManifest input files # # Copyright (c) 2018, Hakan Baba @@ -50,11 +51,15 @@ action=$1 input=$2 case "$action" in is_runnable) - type puppet > /dev/null 2>&1 + command -v puppet > /dev/null 2>&1 exit $? ;; validate) puppet apply --noop "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-python b/misc/validators/validator-python index 7298319d7d..a7e8545acd 100755 --- a/misc/validators/validator-python +++ b/misc/validators/validator-python @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-python --- validating Python input files # # Copyright (c) 2025, Masatake YAMATO @@ -23,16 +24,20 @@ input=$2 case "$action" in is_runnable) - type ${PYTHON} > /dev/null 2>&1 + command -v "${PYTHON}" > /dev/null 2>&1 exit $? ;; validate) - ${PYTHON} -m py_compile "$input" + "${PYTHON}" -m py_compile "$input" s=$? d=$(dirname "$input") b=$(basename "$input" .py) - rm $d/__pycache__/$b*pyc - rmdir $d/__pycache__ + rm "$d"/__pycache__/"$b"*pyc + rmdir "$d"/__pycache__ exit $s ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-ruby b/misc/validators/validator-ruby index 20ee5dbd18..fa92e40c14 100755 --- a/misc/validators/validator-ruby +++ b/misc/validators/validator-ruby @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-ruby - validating Ruby input files with ruby # # Copyright (c) 2022 Masatake YAMATO @@ -22,11 +23,15 @@ action=$1 input=$2 case "$action" in is_runnable) - type ruby > /dev/null 2>&1 + command -v ruby > /dev/null 2>&1 exit $? ;; validate) ruby -c "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-svlint b/misc/validators/validator-svlint index 7c94589ed6..99b3bcfdaf 100755 --- a/misc/validators/validator-svlint +++ b/misc/validators/validator-svlint @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-svlint - validating Verilog/SystemVerilog input files with svlint # https://github.com/dalance/svlint # @@ -25,11 +26,15 @@ cmd=svlint flags="--ignore-include" case "$action" in is_runnable) - type $cmd > /dev/null 2>&1 + command -v $cmd > /dev/null 2>&1 exit $? ;; validate) $cmd $flags "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-swipl b/misc/validators/validator-swipl index 998aeb927c..d5bab9e676 100755 --- a/misc/validators/validator-swipl +++ b/misc/validators/validator-swipl @@ -1,4 +1,5 @@ -# -*- sh -*- +#!/bin/sh +# # validator-swipl - validating Prolog input files with swipl # # Copyright (c) 2025 Masatake YAMATO @@ -24,11 +25,15 @@ cmd=swipl flags="--on-error=status -g halt." case "$action" in is_runnable) - type $cmd > /dev/null 2>&1 + command -v $cmd > /dev/null 2>&1 exit $? ;; validate) $cmd $flags "$input" > /dev/null exit $? ;; + *) + echo "$0: unknown action: $action" >&2 + exit 1 + ;; esac diff --git a/misc/validators/validator-tsc b/misc/validators/validator-tsc index c4a590944e..a4e6292442 100755 --- a/misc/validators/validator-tsc +++ b/misc/validators/validator-tsc @@ -1 +1,2 @@ -source $3/tsc-common.sh $1 $2 es5 +#!/bin/sh +. "$3"/tsc-common.sh "$1" "$2" es5 diff --git a/misc/validators/validator-tsc-es2015 b/misc/validators/validator-tsc-es2015 index b2bebabae8..3453664c24 100755 --- a/misc/validators/validator-tsc-es2015 +++ b/misc/validators/validator-tsc-es2015 @@ -1 +1,2 @@ -source $3/tsc-common.sh $1 $2 es2015 +#!/bin/sh +. "$3"/tsc-common.sh "$1" "$2" es2015 diff --git a/parsers/go.c b/parsers/go.c index 21e82e1417..25c78bd9f6 100644 --- a/parsers/go.c +++ b/parsers/go.c @@ -3,7 +3,7 @@ * GNU General Public License version 2 or (at your option) any later version. * * Reference: -* https://golang.org/ref/spec +* https://go.dev/ref/spec */ @@ -288,11 +288,24 @@ static void parseIdentifier (vString *const string, const int firstChar) ungetcToInputFile (c); /* always unget, LF might add a semicolon */ } -static bool collectorIsEmpty(collector *collector) +static bool collectorIsEmpty(const collector *collector) { return !vStringLength(collector->str); } +static bool collectorCanAppend (const collector *collector, + size_t n_to_append) +{ + size_t current_len = vStringLength (collector->str); + if (current_len >= MAX_COLLECTOR_LENGTH) + return false; + if (n_to_append == 0) + return true; + if (n_to_append > MAX_COLLECTOR_LENGTH) + return false; + return n_to_append <= MAX_COLLECTOR_LENGTH - current_len; +} + static void collectorPut (collector *collector, char c) { if ((vStringLength(collector->str) > 2) @@ -300,26 +313,40 @@ static void collectorPut (collector *collector, char c) "...") == 0 && c == ' ') return; - else if (vStringLength(collector->str) > 0) + + if (vStringLength(collector->str) > 0) { if (vStringLast(collector->str) == '(' && c == ' ') return; - else if (vStringLast(collector->str) == ' ' && c == ')') + if (vStringLast(collector->str) == ' ' && c == ')') vStringChop(collector->str); } + if (!collectorCanAppend (collector, 1)) + return; + collector->last_len = vStringLength (collector->str); vStringPut (collector->str, c); } -static void collectorCatS (collector *collector, char *cstr) +static void collectorCatS (collector *collector, const char *cstr) { + size_t cstr_len = strlen (cstr); + if (cstr_len == 0) + return; + + if (!collectorCanAppend (collector, cstr_len)) + return; + collector->last_len = vStringLength (collector->str); - vStringCatS (collector->str, cstr); + vStringNCatSUnsafe (collector->str, cstr, cstr_len); } -static void collectorCat (collector *collector, vString *str) +static void collectorCat (collector *collector, const vString *str) { + if (!collectorCanAppend (collector, vStringLength (str))) + return; + collector->last_len = vStringLength (collector->str); vStringCat (collector->str, str); } @@ -332,6 +359,9 @@ static void collectorAppendToken (collector *collector, const tokenInfo *const t { // only struct member annotations can appear in function prototypes // so only `` type strings are possible + if (!collectorCanAppend (collector, + vStringLength (token->string) + 2)) + return; collector->last_len = vStringLength (collector->str); vStringPut(collector->str, '`'); vStringCat(collector->str, token->string); @@ -359,6 +389,15 @@ static void collectorTruncate (collector *collector, bool dropLast) vStringStripTrailing (collector->str); } +static void collectorReset (collector *collector) +{ + if (collector->str) + vStringClear (collector->str); + collector->last_len = 0; +} + +#define COLLECTOR(VSTR) { .str = VSTR, .last_len = 0, } + static void readTokenFull (tokenInfo *const token, collector *collector) { int c; @@ -387,7 +426,7 @@ static void readTokenFull (tokenInfo *const token, collector *collector) c = ';'; // semicolon injection } whitespace = c == '\t' || c == ' ' || c == '\r' || c == '\n'; - if (collector && whitespace && firstWhitespace && vStringLength (collector->str) < MAX_COLLECTOR_LENGTH) + if (collector && whitespace && firstWhitespace) { firstWhitespace = false; collectorPut (collector, ' '); @@ -550,7 +589,7 @@ static void readTokenFull (tokenInfo *const token, collector *collector) token->c = c; - if (collector && vStringLength (collector->str) < MAX_COLLECTOR_LENGTH) + if (collector) collectorAppendToken (collector, token); lastTokenType = token->type; @@ -811,7 +850,7 @@ static void parseFunctionOrMethod (tokenInfo *const token, const int scope) // Start recording signature vString *buffer = vStringNew (); - collector collector = { .str = buffer, .last_len = 0, }; + collector collector = COLLECTOR (buffer); // Skip over parameters. readTokenFull (token, &collector); @@ -843,8 +882,7 @@ static void parseFunctionOrMethod (tokenInfo *const token, const int scope) deleteToken (functionToken); - vStringClear (collector.str); - collector.last_len = 0; + collectorReset (&collector); readTokenFull (token, &collector); @@ -905,7 +943,7 @@ static void parseInterfaceMethods (tokenInfo *const token, const int scope) // InterfaceTypeName = TypeName . vString *inheritsBuf = vStringNew (); - collector inherits = { .str = inheritsBuf, .last_len = 0, }; + collector inherits = COLLECTOR (inheritsBuf); readToken (token); if (!isType (token, TOKEN_OPEN_CURLY)) @@ -947,9 +985,9 @@ static void parseInterfaceMethods (tokenInfo *const token, const int scope) // => Signature // Signature = Parameters [ Result ] . vString *pbuf = vStringNew (); - collector pcol = { .str = pbuf, .last_len = 0, }; + collector pcol = COLLECTOR (pbuf); vString *rbuf = NULL; - collector rcol = { .str = NULL, .last_len = 0, }; + collector rcol = COLLECTOR (NULL); // Parameters collectorPut (&pcol, '('); @@ -1100,7 +1138,7 @@ static void parseStructMembers (tokenInfo *const token, const int scope) else { vString *typeForMember = vStringNew (); - collector collector = { .str = typeForMember, .last_len = 0, }; + collector collector = COLLECTOR (typeForMember); collectorAppendToken (&collector, token); skipType (token, &collector); @@ -1217,7 +1255,7 @@ static void parseConstTypeVar (tokenInfo *const token, goKind kind, const int sc { /* Filling "typeref:" field of typeToken. */ vString *buffer = vStringNew (); - collector collector = { .str = buffer, .last_len = 0, }; + collector collector = COLLECTOR(buffer); collectorAppendToken (&collector, token); skipType (token, &collector); @@ -1240,7 +1278,7 @@ static void parseConstTypeVar (tokenInfo *const token, goKind kind, const int sc else if (corks) { vString *buffer = vStringNew (); - collector collector = { .str = buffer, .last_len = 0, }; + collector collector = COLLECTOR (buffer); collectorAppendToken (&collector, token); skipType (token, &collector);