From d33f09bcc0814d900510c23ad5285b3a7c3b2e5c Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Tue, 23 Apr 2013 16:02:50 -0700 Subject: [PATCH] cmd/dist: fix line numbers in goc2c generated files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We have to reset the global lineno variable before processing each file otherwise line numbers will be offset by the number of lines in the previous file. The following examples are from the beginning of the ztime_linux_amd64.c file which is generated from time.goc in the runtime package. Before: #line 2483 "/home/apm/src/go/src/pkg/runtime/time.goc" static Timers timers; static void addtimer ( Timer* ) ; void time·Sleep(int64 ns) { #line 2492 "/home/apm/src/go/src/pkg/runtime/time.goc" After: #line 16 "/home/apm/src/go/src/pkg/runtime/time.goc" static Timers timers; static void addtimer ( Timer* ) ; void time·Sleep(int64 ns) { #line 25 "/home/apm/src/go/src/pkg/runtime/time.goc" R=golang-dev, minux.ma, iant, r, adg CC=golang-dev https://golang.org/cl/8653045 --- src/cmd/dist/goc2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/dist/goc2c.c b/src/cmd/dist/goc2c.c index a103bce8d9..f584603971 100644 --- a/src/cmd/dist/goc2c.c +++ b/src/cmd/dist/goc2c.c @@ -66,7 +66,7 @@ static int gcc; /* File and line number */ static const char *file; -static unsigned int lineno = 1; +static unsigned int lineno; /* List of names and types. */ struct params { @@ -754,6 +754,7 @@ goc2c(char *goc, char *c) input = bstr(&in); output = &out; + lineno = 1; process_file(); writefile(&out, c, 0); -- 2.48.1