unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Windows XBM patch
@ 2003-11-06 17:05 Michael Mauger
  0 siblings, 0 replies; only message in thread
From: Michael Mauger @ 2003-11-06 17:05 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-06 17:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-06 17:05 Windows XBM patch Michael Mauger

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).