From: Robert Griesemer Date: Mon, 19 Nov 2012 17:09:04 +0000 (-0800) Subject: cmd/gc: complain about invalid whitespace chars X-Git-Tag: go1.1rc2~1840 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8f3b703323df5831d13a2492019ebe932559ae4f;p=gostls13.git cmd/gc: complain about invalid whitespace chars Fixes #4405. R=rsc, bradfitz CC=golang-dev https://golang.org/cl/6855060 --- diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c index 1031320a01..ad8bdebf03 100644 --- a/src/cmd/gc/lex.c +++ b/src/cmd/gc/lex.c @@ -99,7 +99,7 @@ yy_isdigit(int c) static int yy_isspace(int c) { - return c >= 0 && c <= 0xFF && isspace(c); + return c == ' ' || c == '\t' || c == '\n' || c == '\r'; } static int @@ -790,12 +790,8 @@ static int isfrog(int c) { // complain about possibly invisible control characters - if(c < 0) - return 1; if(c < ' ') { - if(c == '\n' || c== '\r' || c == '\t') // good white space - return 0; - return 1; + return !yy_isspace(c); // exclude good white space } if(0x7f <= c && c <= 0xa0) // DEL, unicode block including unbreakable space. return 1; diff --git a/test/fixedbugs/issue4405.go b/test/fixedbugs/issue4405.go new file mode 100644 index 0000000000..c0d8085598 --- /dev/null +++ b/test/fixedbugs/issue4405.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2012 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 p + +const ( + _ = iota + _ // ERROR "illegal character" + _ // ERROR "illegal character" + _ // ERROR "illegal character" + _ // ERROR "illegal character" +)