From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8600: struct charset.code_space[15] contains garbage Date: Sun, 01 May 2011 09:59:25 -0700 Organization: UCLA Computer Science Department Message-ID: <4DBD916D.6000804@cs.ucla.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304269621 2942 80.91.229.12 (1 May 2011 17:07:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 1 May 2011 17:07:01 +0000 (UTC) To: 8600@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 01 19:06:57 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QGa6j-00048D-Aa for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 May 2011 19:06:57 +0200 Original-Received: from localhost ([::1]:59626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGa6i-0006AO-OA for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 May 2011 13:06:56 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGa6f-0006AE-SP for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 13:06:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGa6e-0007t0-OQ for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 13:06:53 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGa6e-0007sw-J4 for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 13:06:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QGa05-0006VL-O4; Sun, 01 May 2011 13:00:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 01 May 2011 17:00:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8600 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.130426917824942 (code B ref -1); Sun, 01 May 2011 17:00:05 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 May 2011 16:59:38 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QGZze-0006UE-71 for submit@debbugs.gnu.org; Sun, 01 May 2011 12:59:38 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QGZzc-0006U3-Hi for submit@debbugs.gnu.org; Sun, 01 May 2011 12:59:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGZzW-00075M-Sz for submit@debbugs.gnu.org; Sun, 01 May 2011 12:59:31 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:36956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGZzW-00075I-R9 for submit@debbugs.gnu.org; Sun, 01 May 2011 12:59:30 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:59618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGZzV-0005c8-RP for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 12:59:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGZzV-00074Z-2a for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 12:59:29 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:49594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGZzU-00074T-Pf for bug-gnu-emacs@gnu.org; Sun, 01 May 2011 12:59:29 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id A460D39E8109 for ; Sun, 1 May 2011 09:59:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ao+2QhNtM6Vj for ; Sun, 1 May 2011 09:59:26 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id B1F7839E80F8 for ; Sun, 1 May 2011 09:59:26 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 01 May 2011 13:00:05 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46126 Archived-At: While testing the 32+64 port I noticed that a too-wide value is stuffed into charset.code_space[15], which means that slot has a garbage value (at least, it's garbage on typical machines with 32-bit int). As far as I can see, the garbage value is never used, so it's a bit cleaner to never compute or store it. I plan to install the following patch to do that. This patch is relevant to ordinary 32- and 64-bit hosts, too, so I'm separating it out. * charset.h (struct charset.code_space): Now has 15 elements, not 16. * charset.c (Fdefine_charset_internal): Don't initialize charset.code_space[15]. The value was garbage, on hosts with 32-bit int. === modified file 'src/charset.c' --- src/charset.c 2011-04-26 06:17:52 +0000 +++ src/charset.c 2011-05-01 06:28:23 +0000 @@ -869,7 +869,7 @@ ASET (attrs, charset_name, args[charset_arg_name]); val = args[charset_arg_code_space]; - for (i = 0, dimension = 0, nchars = 1; i < 4; i++) + for (i = 0, dimension = 0, nchars = 1; ; i++) { int min_byte, max_byte; @@ -880,10 +880,12 @@ charset.code_space[i * 4] = min_byte; charset.code_space[i * 4 + 1] = max_byte; charset.code_space[i * 4 + 2] = max_byte - min_byte + 1; + if (max_byte > 0) + dimension = i + 1; + if (i == 3) + break; nchars *= charset.code_space[i * 4 + 2]; charset.code_space[i * 4 + 3] = nchars; - if (max_byte > 0) - dimension = i + 1; } val = args[charset_arg_dimension]; === modified file 'src/charset.h' --- src/charset.h 2011-04-11 06:48:18 +0000 +++ src/charset.h 2011-05-01 16:22:33 +0000 @@ -155,10 +155,11 @@ byte code of the (N+1)th dimension, [4N+1] is a maximum byte code of the (N+1)th dimension, [4N+2] is ([4N+1] - [4N] + 1), [4N+3] - is a number of characters containd in the first to (N+1)th - dismesions. We get `char-index' of a `code-point' from this + is the number of characters contained in the first through (N+1)th + dimensions, except that there is no [15]. + We get `char-index' of a `code-point' from this information. */ - int code_space[16]; + int code_space[15]; /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit of code_space_mask[B] is set. This array is used to quickly