From patchwork Thu Sep 20 00:54:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 185274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1CBA32C0094 for ; Thu, 20 Sep 2012 10:55:11 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1348707312; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=XsnRdy7Sy+MGxCbZqrfG1tjgkJY=; b=cXVzv6oL8LMg/4Q mNwhEIEOIFmC2/5s7F0aY4FcvNHpMooxRNICDIpe5aN2qYHC9eMJOb/gxG0CaGg6 G0fQTXY7zRKW2inDpri8L155OZV/PKFa6QWl7DtMOB92I7pb4SkwkFeYPMLlo1eK 1fIC9YDt4DZhDRt6T3S5tTZ1f9CE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Y8JofwE3pimbd9WN5LWUkV96ABZf0KTwQy47NPf3JSoZdUZ197abDgAP/KplHs id8NUq9j1GZm6hGLsvNVScxrasxIfQKXDGM8M85JaIZ87gs9xD19wIC6xr6KfBcl b6p6wb5EyQXY1/eVKuzFeqlh7+sxmeBwpSpfFSDBnwEGY=; Received: (qmail 20932 invoked by alias); 20 Sep 2012 00:55:07 -0000 Received: (qmail 20920 invoked by uid 22791); 20 Sep 2012 00:55:06 -0000 X-SWARE-Spam-Status: No, hits=-4.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_NX, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Sep 2012 00:54:52 +0000 Received: by pbcwy7 with SMTP id wy7so4073948pbc.20 for ; Wed, 19 Sep 2012 17:54:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=0sHL2VMlVzG9AyAITs7pD0rp7RaluY+x+HE7YRobbYA=; b=N7fmNUrWDpZK47zAFYTe5FK5ISaCJvcPEbTHIu/pelaTJbvrmcYo4eg8iu1g+zDxyL moOYvm6VGtyfNMttAuxP0y1o4aV+MIG5Okwxm9l8GygHB89rTMm5YqA99s7pM5naRfNv rHz0gHSkjuC4StA25ijALLfPapncyrM28fPgoMVPo+4PB2PufFnr9l8s+Pq98dFct9Ce M/np3OUO5dAFEG+QW1zThWPoxXiQ7HfTOYENkTLm5NIHf/qTke1mupWaMQ6DbQ5CVyo3 XlYHa4yiWbZqEERrbwoeA+svwsPL3eldUULujZDGT38nO17ye39adMtOS4VRB3RImn1g ExPw== Received: by 10.68.203.228 with SMTP id kt4mr2013348pbc.87.1348102491741; Wed, 19 Sep 2012 17:54:51 -0700 (PDT) Received: by 10.68.203.228 with SMTP id kt4mr2013339pbc.87.1348102491626; Wed, 19 Sep 2012 17:54:51 -0700 (PDT) Received: from coign.google.com ([199.189.96.41]) by mx.google.com with ESMTPS id gj9sm2624904pbc.16.2012.09.19.17.54.45 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 19 Sep 2012 17:54:51 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Error for byte-order-mark in middle of file Date: Wed, 19 Sep 2012 17:54:39 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlOQh6ecL+fBSvifRinH9OTeIqRPU1EiXf1h7vTV4erZFfe12W+cdZAVY5B9yGJ8Z19U2yLD2bCm3ZQ+kw2Zxh8qZpDnKWz/tB++IRqOs+Opl80Qx4LZwvHCKoVfq1EDCS4O7Ho4nXyc7WPJ7yJub3OfN4WhnVc74B0xkGjVp3LyEKWLrbh34YmkgmCS6XE5SV12YUA X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I should have looked at some more of the testsuite before my last patch. This patch to the Go frontend issues an error for a Unicode byte-order-mark in the middle of a Go file, while continuing to ignore it at the beginning of the file. Bootstrapped and ran Go testsuite on x86_64-unknown-linxu-gnu. Committed to mainline. Will commit to 4.7 branch when it reopens. Ian diff -r 917ece6aa599 go/lex.cc --- a/go/lex.cc Wed Sep 19 08:50:19 2012 -0700 +++ b/go/lex.cc Wed Sep 19 17:47:42 2012 -0700 @@ -726,7 +726,7 @@ &issued_error); // Ignore byte order mark at start of file. - if (ci == 0xfeff && this->lineno_ == 1 && this->lineoff_ == 0) + if (ci == 0xfeff) { p = pnext; break; @@ -840,6 +840,14 @@ *issued_error = true; return p + 1; } + + // Warn about byte order mark, except at start of file. + if (*value == 0xfeff && (this->lineno_ != 1 || this->lineoff_ != 0)) + { + error_at(this->location(), "Unicode (UTF-8) BOM in middle of file"); + *issued_error = true; + } + return p + adv; }