From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105020 invoked by alias); 2 Mar 2016 04:46:21 -0000 Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org Received: (qmail 104868 invoked by uid 89); 2 Mar 2016 04:46:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=appending, H*r:sk:cgen@so, 1.13, Hx-languages-length:2185 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 02 Mar 2016 04:46:07 +0000 Received: by mail-pa0-f46.google.com with SMTP id fl4so125379912pad.0 for ; Tue, 01 Mar 2016 20:46:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=vKmecA9cLGrk6BKoHMm5qJ1BdToTmDk3CuEsvhpfPQM=; b=Qs/P6lplRZ0X96NVLt7w2SL3S1pU5oNbmbZnwYWJeztWJ7kuHWpmPvCObAsrschj5t NP0pvKOC8Q0l2NlaKHTGLO7yjI/oXHeAz4WTqcehqjMFmFGbodPDIa95Qzflitjk4dpO /hmif/kzbcBD2gnxC96I67fdl8+C6nBXkf3ktcQtUNt6jynRR9Fj582PtC3VYh8Hbj7i zAO+qRXampv/oGo0iH2P96dkhS8OX51yfqLsCmi4hA1nJH+ePkf/c8MSemQxlCrXo/6s KUwBUf16A0nbk9i+fmnxYB08l0+48h3epGVUTGNBSaZDyQHgZb8dK3hI9uc4BPtF+j09 uksw== X-Gm-Message-State: AD7BkJILzbqVKXMdcZC+ckoX89uFhsAK5Ra+GzbleAGzkc/tq9cVGi/rnvcPkt+QoOiNgw== X-Received: by 10.67.23.161 with SMTP id ib1mr34446395pad.156.1456893966008; Tue, 01 Mar 2016 20:46:06 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id h85sm34930822pfj.52.2016.03.01.20.46.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2016 20:46:05 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 132C8EA0157; Wed, 2 Mar 2016 15:16:01 +1030 (ACDT) Date: Wed, 02 Mar 2016 04:46:00 -0000 From: Alan Modra To: cgen@sourceware.org Subject: Make large enum constants unsigned, revisited Message-ID: <20160302044600.GW10657@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2016-q1/txt/msg00002.txt.bz2 The patch at https://sourceware.org/ml/cgen/2014-q2/msg00008.html was never committed, presumably because the submitter gave up trying. I thought the patch was good, but have rewritten it to instead output hex numbers rather than appending "u", an idiom used elsewhere in cgen. Search for "that's not k&r". I've also fixed the upcase to apply just to identifiers, so cgen emits 0x80000000 rather than 0X80000000, and tidied the sanitize code a little. The tidy doesn't change emitted code. OK to commit? * enum.scm (gen-enum-decl): Emit large numbers as hex. Tidy start-sanitize. Upcase just the identifiers. Index: enum.scm =================================================================== RCS file: /cvs/src/src/cgen/enum.scm,v retrieving revision 1.13 diff -u -p -r1.13 enum.scm --- enum.scm 13 Feb 2010 03:39:15 -0000 1.13 +++ enum.scm 2 Mar 2016 04:19:20 -0000 @@ -272,35 +272,31 @@ (append! result (string-list - (if san? - (string-append "\n" - (if include-sanitize-marker? - ; split string to avoid removal - (string-append "/* start-" - "sanitize-" - san-code " */\n") - "") - " ") + (if (and san? include-sanitize-marker?) + ; split string to avoid removal + (string-append "\n/* start-" + "sanitize-" + san-code " */") + "") + (if (or san? (=? (remainder n 4) 0)) + "\n " "") - (string-upcase - (string-append - (if (and (not san?) (=? (remainder n 4) 0)) - "\n " - "") - (if (= n 0) - " " - ", ") - (gen-c-symbol prefix) - (gen-c-symbol (car e)) - (if (or sequential? - (null? (cdr e)) - (eq? '- (cadr e))) - "" - (string-append " = " - (if (number? (cadr e)) - (number->string (cadr e)) - (cadr e)))) - )) + (if (= n 0) + " " + ", ") + (string-upcase (gen-c-symbol prefix)) + (string-upcase (gen-c-symbol (car e))) + (if (or sequential? + (null? (cdr e)) + (eq? '- (cadr e))) + "" + (string-append " = " + (if (number? (cadr e)) + (if (>= (cadr e) #x80000000) + (string-append "0x" + (number->string (cadr e) 16)) + (number->string (cadr e))) + (string-upcase (cadr e))))) (if (and san? include-sanitize-marker?) ; split string to avoid removal (string-append "\n/* end-" -- Alan Modra Australia Development Lab, IBM