From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Michael Mauger Newsgroups: gmane.emacs.devel Subject: Windows XBM patch Date: Thu, 6 Nov 2003 09:05:23 -0800 (PST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20031106170523.43662.qmail@web60305.mail.yahoo.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1068138633 24244 80.91.224.253 (6 Nov 2003 17:10:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 Nov 2003 17:10:33 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Nov 06 18:10:31 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AHneR-0001Fu-00 for ; Thu, 06 Nov 2003 18:10:31 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AHneR-000680-00 for ; Thu, 06 Nov 2003 18:10:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AHndx-00009o-V6 for emacs-devel@quimby.gnus.org; Thu, 06 Nov 2003 12:10:01 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AHnbj-0006hh-Tg for emacs-devel@gnu.org; Thu, 06 Nov 2003 12:07:43 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AHnaS-0004XO-9G for emacs-devel@gnu.org; Thu, 06 Nov 2003 12:06:55 -0500 Original-Received: from [216.109.118.116] (helo=web60305.mail.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.24) id 1AHnaI-0002wG-0B for emacs-devel@gnu.org; Thu, 06 Nov 2003 12:06:14 -0500 Original-Received: from [12.91.2.184] by web60305.mail.yahoo.com via HTTP; Thu, 06 Nov 2003 09:05:23 PST Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17710 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17710 I've been encountering intermittent Access Violations using a current CVS snapshot of Emacs on Windows. The most common failure situation was when customizing a face. I eventually tracked down the problem to the use of signed char's being passed to the isXXXXX() family of functions. In `xbm_scan' data is passed via a `char**'. The first byte of the one of the bitmaps was 0xc0 (192) which was treated via signed arithmetic as -64. This value was passed to isspace() which, in MSVCRTL, is used as an index to an array of character flags. Depending on what was mapped 64 bytes prior to the array, I would get an Access Violation. The following patch modifies the handling of XBM data in w32fncs.c so that it uses unsigned arithmetic throughout. -- Michael ***********************************************************************/ static Lisp_Object x_find_image_file P_ ((Lisp_Object)); -static char *slurp_file P_ ((char *, int *)); +static unsigned char *slurp_file P_ ((char *, int *)); /* Find image file FILE. Look in data-directory, then @@ -8278,13 +8278,13 @@ with xmalloc holding FILE's contents. Value is null if an error occurred. *SIZE is set to the size of the file. */ -static char * +static unsigned char * slurp_file (file, size) char *file; int *size; { FILE *fp = NULL; - char *buf = NULL; + unsigned char *buf = NULL; struct stat st; if (stat (file, &st) == 0 @@ -8315,12 +8315,14 @@ XBM images ***********************************************************************/ -static int xbm_scan P_ ((char **, char *, char *, int *)); +static int xbm_scan P_ ((unsigned char **, unsigned char *, + char *, int *)); static int xbm_load P_ ((struct frame *f, struct image *img)); static int xbm_load_image P_ ((struct frame *f, struct image *img, - char *, char *)); + unsigned char *, unsigned char *)); static int xbm_image_p P_ ((Lisp_Object object)); -static int xbm_read_bitmap_data P_ ((char *, char *, int *, int *, +static int xbm_read_bitmap_data P_ ((unsigned char *, unsigned char *, + int *, int *, unsigned char **)); static int xbm_file_p P_ ((Lisp_Object)); @@ -8510,11 +8512,11 @@ static int xbm_scan (s, end, sval, ival) - char **s, *end; + unsigned char **s, *end; char *sval; int *ival; { - int c; + unsigned int c; loop: @@ -8644,11 +8646,11 @@ static int xbm_read_bitmap_data (contents, end, width, height, data) - char *contents, *end; + unsigned char *contents, *end; int *width, *height; unsigned char **data; { - char *s = contents; + unsigned char *s = contents; char buffer[BUFSIZ]; int padding_p = 0; int v10 = 0; @@ -8826,7 +8828,7 @@ xbm_load_image (f, img, contents, end) struct frame *f; struct image *img; - char *contents, *end; + unsigned char *contents, *end; { int rc; unsigned char *data; @@ -8914,7 +8916,7 @@ if (STRINGP (file_name)) { Lisp_Object file; - char *contents; + unsigned char *contents; int size; struct gcpro gcpro1; __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree