From patchwork Sun Sep 26 06:05:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Wildenhues X-Patchwork-Id: 65772 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 14823B70F1 for ; Sun, 26 Sep 2010 16:05:41 +1000 (EST) Received: (qmail 11460 invoked by alias); 26 Sep 2010 06:05:39 -0000 Received: (qmail 11452 invoked by uid 22791); 26 Sep 2010 06:05:38 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_20, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mail.gmx.net) (213.165.64.22) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sun, 26 Sep 2010 06:05:33 +0000 Received: (qmail invoked by alias); 26 Sep 2010 06:05:31 -0000 Received: from xdsl-89-0-135-164.netcologne.de (EHLO localhost.localdomain) [89.0.135.164] by mail.gmx.net (mp012) with SMTP; 26 Sep 2010 08:05:31 +0200 Received: from ralf by localhost.localdomain with local (Exim 4.69) (envelope-from ) id 1OzkMc-0005OF-Qe for gcc-patches@gcc.gnu.org; Sun, 26 Sep 2010 08:05:30 +0200 Date: Sun, 26 Sep 2010 08:05:30 +0200 From: Ralf Wildenhues To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR bootstrap/35855: awk character classes. Message-ID: <20100926060530.GK17516@gmx.de> Mail-Followup-To: Ralf Wildenhues , gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2010-08-04) 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 Bootstrapped x86_64-unknown-linux-gnu, regtest is running. OK for trunk? OK for 4.5, 4.4, and 4.3 after a while, as the PR documents this to be a 4.3 regression? Not using [:alpha:] or other character classes for two reasons: - they would require the locale to be set/overridden correctly, - not all awk implementations support them; at least, that is what I can infer from the gawk.info documentation of -W compat. Thanks, Ralf Fix PR bootstrap/35855: awk character classes. gcc/ChangeLog: 2010-09-26 Ralf Wildenhues PR bootstrap/35855 * opt-functions.awk (BEGIN): New section. (alpha, ALPHA, numeric, alnum): New variables. (static_var, opt_sanitized_name): Use alnum instead of character classes, for non-C locale. * optc-gen.awk: Likewise. * opth-gen.awk: Likewise. diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index ed65d93..52ebf5e 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -19,6 +19,14 @@ # Some common subroutines for use by opt[ch]-gen.awk. +# Define some helpful character classes, for portability. +BEGIN { + alpha = "abcdefghijklmnopqrstuvwxyz" + ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + numeric = "0123456789" + alnum = alpha "" ALPHA "" numeric +} + # Return nonzero if FLAGS contains a flag matching REGEX. function flag_set_p(regex, flags) { @@ -127,7 +135,7 @@ function static_var(name, flags) { if (global_state_p(flags) || !needs_state_p(flags)) return "" - gsub ("[^A-Za-z0-9]", "_", name) + gsub ("[^" alnum "]", "_", name) return "VAR_" name } @@ -206,7 +214,7 @@ function opt_sanitized_name(name) { if (name == "gdwarf+") name = "gdwarfplus" - gsub ("[^A-Za-z0-9]", "_", name) + gsub ("[^" alnum "]", "_", name) return name } diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 4a146dd..beb14b8 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -127,7 +127,7 @@ print "" print "const char * const lang_names[] =\n{" for (i = 0; i < n_langs; i++) { macros[i] = "CL_" langs[i] - gsub( "[^A-Za-z0-9_]", "X", macros[i] ) + gsub( "[^" alnum "_]", "X", macros[i] ) s = substr(" ", length (macros[i])) print " " quote langs[i] quote "," } diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index 423328d..cd02e14 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -172,13 +172,13 @@ n_target_int = 0; n_target_other = 0; for (i = 0; i < n_target_save; i++) { - if (target_save_decl[i] ~ "^((un)?signed +)?int +[_a-zA-Z0-9]+$") + if (target_save_decl[i] ~ "^((un)?signed +)?int +[_" alnum "]+$") var_target_int[n_target_int++] = target_save_decl[i]; - else if (target_save_decl[i] ~ "^((un)?signed +)?short +[_a-zA-Z0-9]+$") + else if (target_save_decl[i] ~ "^((un)?signed +)?short +[_" alnum "]+$") var_target_short[n_target_short++] = target_save_decl[i]; - else if (target_save_decl[i] ~ "^((un)?signed +)?char +[_a-zA-Z0-9]+$") + else if (target_save_decl[i] ~ "^((un)?signed +)?char +[_ " alnum "]+$") var_target_char[n_target_char++] = target_save_decl[i]; else @@ -316,7 +316,7 @@ print "" for (i = 0; i < n_langs; i++) { macros[i] = "CL_" langs[i] - gsub( "[^A-Za-z0-9_]", "X", macros[i] ) + gsub( "[^" alnum "_]", "X", macros[i] ) s = substr(" ", length (macros[i])) print "#define " macros[i] s " (1 << " i ")" }