Mercurial > hg > xemacs-beta
changeset 608:4d7fdf497470
[xemacs-hg @ 2001-06-04 16:59:51 by wmperry]
2001-06-04 William M. Perry <wmperry@gnu.org>
* gpmevent.c (KG_CTRL): Just define these unconditionally. The
linux headers are so lame that they do not expose these to
userland programs and you cannot gracefully include the kernel
headers.
2001-06-03 William M. Perry <wmperry@gnu.org>
* scrollbar-gtk.c (gtk_create_scrollbar_instance): Make calling of
gtk_size_request unconditional.
2001-06-02 William M. Perry <wmperry@gnu.org>
* emacs-marshals.c: Regenerated.
2001-06-01 William M. Perry <wmperry@gnu.org>
* glyphs-shared.c (read_bitmap_data): Common definition of
read_bitmap_data_from_file added. This does not attempt to use
the Xmu based code at all - lets us be consistent across
platforms.
* glyphs-gtk.c: Removed definition of read_bitmap_data_from_file -
this is now in glyphs-shared.c
* glyphs-msw.c: Ditto.
* glyphs-x.c: Ditto.
2001-06-03 William M. Perry <wmperry@gnu.org>
* dialog-gtk.el (popup-builtin-open-dialog): Yikes - don't forget
to return the filename!
* font.el (font-window-system-mappings): Add gtk entry - just an
alias to the X code)
2001-06-02 William M. Perry <wmperry@gnu.org>
* gtk-marshal.el: Fix for removing of the string_hash utility
functions in hash.c
author | wmperry |
---|---|
date | Mon, 04 Jun 2001 17:00:02 +0000 |
parents | 9979b8030c99 |
children | 13e3d7ae7155 |
files | lisp/ChangeLog lisp/dialog-gtk.el lisp/font.el lisp/gtk-marshal.el src/ChangeLog src/emacs-marshals.c src/glyphs-gtk.c src/glyphs-msw.c src/glyphs-shared.c src/glyphs-x.c src/gpmevent.c src/scrollbar-gtk.c src/xmu.c |
diffstat | 13 files changed, 350 insertions(+), 739 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sun Jun 03 14:25:45 2001 +0000 +++ b/lisp/ChangeLog Mon Jun 04 17:00:02 2001 +0000 @@ -1,3 +1,16 @@ +2001-06-03 William M. Perry <wmperry@gnu.org> + + * dialog-gtk.el (popup-builtin-open-dialog): Yikes - don't forget + to return the filename! + + * font.el (font-window-system-mappings): Add gtk entry - just an + alias to the X code) + +2001-06-02 William M. Perry <wmperry@gnu.org> + + * gtk-marshal.el: Fix for removing of the string_hash utility + functions in hash.c + 2001-05-13 Karl M. Hegbloom <karlheg@hegbloom.net> * packages.el (locate-data-file): Use suffixes list to allow
--- a/lisp/dialog-gtk.el Sun Jun 03 14:25:45 2001 +0000 +++ b/lisp/dialog-gtk.el Mon Jun 04 17:00:02 2001 +0000 @@ -82,7 +82,8 @@ (gtk-widget-show-all widget) (gtk-main) (if (not clicked-ok) - (signal 'quit nil)))) + (signal 'quit nil) + filename))) (defalias 'popup-builtin-save-as-dialog 'popup-builtin-open-dialog)
--- a/lisp/font.el Sun Jun 03 14:25:45 2001 +0000 +++ b/lisp/font.el Mon Jun 04 17:00:02 2001 +0000 @@ -105,6 +105,7 @@ (defconst font-window-system-mappings '((x . (x-font-create-name x-font-create-object)) + (gtk . (x-font-create-name x-font-create-object)) (ns . (ns-font-create-name ns-font-create-object)) (mswindows . (mswindows-font-create-name mswindows-font-create-object)) (pm . (x-font-create-name x-font-create-object)) ; Change? FIXME
--- a/lisp/gtk-marshal.el Sun Jun 03 14:25:45 2001 +0000 +++ b/lisp/gtk-marshal.el Mon Jun 04 17:00:02 2001 +0000 @@ -257,13 +257,43 @@ (insert "\n #include \"hash.h\" -static c_hashtable marshaller_hashtable; +static int +our_string_eq (const void *st1, const void *st2) +{ + if (!st1) + return st2 ? 0 : 1; + else if (!st2) + return 0; + else + return !strcmp ( (const char *) st1, (const char *) st2); +} + +unsigned long +our_string_hash (const void *xv) +{ + unsigned int h = 0; + unsigned const char *x = (unsigned const char *) xv; + + if (!x) return 0; + + while (*x) + { + unsigned int g; + h = (h << 4) + *x++; + if ((g = h & 0xf0000000) != 0) + h = (h ^ (g >> 24)) ^ g; + } + + return h; +} + +static struct hash_table *marshaller_hashtable; static void initialize_marshaller_storage (void) { if (!marshaller_hashtable) { - marshaller_hashtable = make_strings_hashtable (100); + marshaller_hashtable = make_general_hash_table (100, our_string_hash, our_string_eq); ") (mapc (lambda (x)
--- a/src/ChangeLog Sun Jun 03 14:25:45 2001 +0000 +++ b/src/ChangeLog Mon Jun 04 17:00:02 2001 +0000 @@ -1,3 +1,33 @@ +2001-06-04 William M. Perry <wmperry@gnu.org> + + * gpmevent.c (KG_CTRL): Just define these unconditionally. The + linux headers are so lame that they do not expose these to + userland programs and you cannot gracefully include the kernel + headers. + +2001-06-03 William M. Perry <wmperry@gnu.org> + + * scrollbar-gtk.c (gtk_create_scrollbar_instance): Make calling of + gtk_size_request unconditional. + +2001-06-02 William M. Perry <wmperry@gnu.org> + + * emacs-marshals.c: Regenerated. + +2001-06-01 William M. Perry <wmperry@gnu.org> + + * glyphs-shared.c (read_bitmap_data): Common definition of + read_bitmap_data_from_file added. This does not attempt to use + the Xmu based code at all - lets us be consistent across + platforms. + + * glyphs-gtk.c: Removed definition of read_bitmap_data_from_file - + this is now in glyphs-shared.c + + * glyphs-msw.c: Ditto. + + * glyphs-x.c: Ditto. + 2001-06-01 Ben Wing <ben@xemacs.org> * Makefile.in.in (ldflags): @@ -178,6 +208,7 @@ path, instead of char*. * systime.h: Include <sys/utime.h> on WIN32_NATIVE. +>>>>>>> 1.354 2001-05-30 William M. Perry <wmperry@gnu.org> * emacs-marshals.c: Regenerated from lisp.
--- a/src/emacs-marshals.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/emacs-marshals.c Mon Jun 04 17:00:02 2001 +0000 @@ -1456,13 +1456,43 @@ #include "hash.h" -static c_hashtable marshaller_hashtable; +static int +our_string_eq (const void *st1, const void *st2) +{ + if (!st1) + return st2 ? 0 : 1; + else if (!st2) + return 0; + else + return !strcmp ( (const char *) st1, (const char *) st2); +} + +unsigned long +our_string_hash (const void *xv) +{ + unsigned int h = 0; + unsigned const char *x = (unsigned const char *) xv; + + if (!x) return 0; + + while (*x) + { + unsigned int g; + h = (h << 4) + *x++; + if ((g = h & 0xf0000000) != 0) + h = (h ^ (g >> 24)) ^ g; + } + + return h; +} + +static struct hash_table *marshaller_hashtable; static void initialize_marshaller_storage (void) { if (!marshaller_hashtable) { - marshaller_hashtable = make_strings_hashtable (100); + marshaller_hashtable = make_general_hash_table (100, our_string_hash, our_string_eq); puthash ("emacs_gtk_marshal_BOOL__OBJECT_INT", (void *) emacs_gtk_marshal_BOOL__OBJECT_INT, marshaller_hashtable); puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT_OBJECT, marshaller_hashtable); puthash ("emacs_gtk_marshal_BOOL__OBJECT_OBJECT", (void *) emacs_gtk_marshal_BOOL__OBJECT_OBJECT, marshaller_hashtable);
--- a/src/glyphs-gtk.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/glyphs-gtk.c Mon Jun 04 17:00:02 2001 +0000 @@ -2728,224 +2728,6 @@ #undef BUILD_GLYPH_INST } - -/* Ripped off from glyphs-msw.c */ -/* - * The data returned by the following routine is always in left-most byte - * first and left-most bit first. If it doesn't return BitmapSuccess then - * its arguments won't have been touched. This routine should look as much - * like the Xlib routine XReadBitmapfile as possible. - */ -#define MAX_SIZE 1024 - -/* shared data for the image read/parse logic */ -static short hexTable[256]; /* conversion value */ -static int initialized = FALSE; /* easier to fill in at run time */ - -/* - * Table index for the hex values. Initialized once, first time. - * Used for translation value or delimiter significance lookup. - */ -static void initHexTable() -{ - /* - * We build the table at run time for several reasons: - * - * 1. portable to non-ASCII machines. - * 2. still reentrant since we set the init flag after setting table. - * 3. easier to extend. - * 4. less prone to bugs. - */ - hexTable['0'] = 0; hexTable['1'] = 1; - hexTable['2'] = 2; hexTable['3'] = 3; - hexTable['4'] = 4; hexTable['5'] = 5; - hexTable['6'] = 6; hexTable['7'] = 7; - hexTable['8'] = 8; hexTable['9'] = 9; - hexTable['A'] = 10; hexTable['B'] = 11; - hexTable['C'] = 12; hexTable['D'] = 13; - hexTable['E'] = 14; hexTable['F'] = 15; - hexTable['a'] = 10; hexTable['b'] = 11; - hexTable['c'] = 12; hexTable['d'] = 13; - hexTable['e'] = 14; hexTable['f'] = 15; - - /* delimiters of significance are flagged w/ negative value */ - hexTable[' '] = -1; hexTable[','] = -1; - hexTable['}'] = -1; hexTable['\n'] = -1; - hexTable['\t'] = -1; - - initialized = TRUE; -} - -/* - * read next hex value in the input stream, return -1 if EOF - */ -static int NextInt ( FILE *fstream ) -{ - int ch; - int value = 0; - int gotone = 0; - int done = 0; - - /* loop, accumulate hex value until find delimiter */ - /* skip any initial delimiters found in read stream */ - - while (!done) { - ch = getc(fstream); - if (ch == EOF) { - value = -1; - done++; - } else { - /* trim high bits, check type and accumulate */ - ch &= 0xff; - if (isascii(ch) && isxdigit(ch)) { - value = (value << 4) + hexTable[ch]; - gotone++; - } else if ((hexTable[ch]) < 0 && gotone) - done++; - } - } - return value; -} - -int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot) - FILE *fstream; /* handle on file */ - unsigned int *width, *height; /* RETURNED */ - unsigned char **datap; /* RETURNED */ - int *x_hot, *y_hot; /* RETURNED */ -{ - unsigned char *data = NULL; /* working variable */ - char line[MAX_SIZE]; /* input line from file */ - int size; /* number of bytes of data */ - char name_and_type[MAX_SIZE]; /* an input line */ - char *type; /* for parsing */ - int value; /* from an input line */ - int version10p; /* boolean, old format */ - int padding; /* to handle alignment */ - int bytes_per_line; /* per scanline of data */ - unsigned int ww = 0; /* width */ - unsigned int hh = 0; /* height */ - int hx = -1; /* x hotspot */ - int hy = -1; /* y hotspot */ - -#define Xmalloc(size) malloc(size) - - /* first time initialization */ - if (initialized == FALSE) initHexTable(); - - /* error cleanup and return macro */ -#define RETURN(code) { if (data) free (data); return code; } - - while (fgets(line, MAX_SIZE, fstream)) { - if (strlen(line) == MAX_SIZE-1) { - RETURN (BitmapFileInvalid); - } - if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (!strcmp("width", type)) - ww = (unsigned int) value; - if (!strcmp("height", type)) - hh = (unsigned int) value; - if (!strcmp("hot", type)) { - if (type-- == name_and_type || type-- == name_and_type) - continue; - if (!strcmp("x_hot", type)) - hx = value; - if (!strcmp("y_hot", type)) - hy = value; - } - continue; - } - - if (sscanf(line, "static short %s = {", name_and_type) == 1) - version10p = 1; - else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) - version10p = 0; - else if (sscanf(line, "static char %s = {", name_and_type) == 1) - version10p = 0; - else - continue; - - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (strcmp("bits[]", type)) - continue; - - if (!ww || !hh) - RETURN (BitmapFileInvalid); - - if ((ww % 16) && ((ww % 16) < 9) && version10p) - padding = 1; - else - padding = 0; - - bytes_per_line = (ww+7)/8 + padding; - - size = bytes_per_line * hh; - data = (unsigned char *) Xmalloc ((unsigned int) size); - if (!data) - RETURN (BitmapNoMemory); - - if (version10p) { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; (bytes += 2)) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *(ptr++) = value; - if (!padding || ((bytes+2) % bytes_per_line)) - *(ptr++) = value >> 8; - } - } else { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *ptr=value; - } - } - break; - } /* end while */ - - if (data == NULL) { - RETURN (BitmapFileInvalid); - } - - *datap = data; - data = NULL; - *width = ww; - *height = hh; - if (x_hot) *x_hot = hx; - if (y_hot) *y_hot = hy; - - RETURN (BitmapSuccess); -} - - -int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, - unsigned int *height, unsigned char **datap, - int *x_hot, int *y_hot) -{ - FILE *fstream; - int rval; - - if ((fstream = fopen (filename, "r")) == NULL) { - return BitmapOpenFailed; - } - rval = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot); - fclose (fstream); - return rval; -} - /* X specific crap */ #include <gdk/gdkx.h> /* #### Should remove all this X specific stuff when GTK/GDK matures a
--- a/src/glyphs-msw.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/glyphs-msw.c Mon Jun 04 17:00:02 2001 +0000 @@ -1363,279 +1363,6 @@ /********************************************************************** * XBM * **********************************************************************/ -#ifndef HAVE_X_WINDOWS -/* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */ - -/* - -Copyright (c) 1988 X Consortium - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the X Consortium shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from the X Consortium. - -*/ - -/* - * This file contains miscellaneous utility routines and is not part of the - * Xlib standard. - * - * Public entry points: - * - * XmuReadBitmapData read data from FILE descriptor - * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files - * and return data - * - * Note that this file and ../X/XRdBitF.c look very similar.... Keep them - * that way (but don't use common source code so that people can have one - * without the other). - */ - - -/* - * Based on an optimized version provided by Jim Becker, August 5, 1988. - */ -#ifndef BitmapSuccess -#define BitmapSuccess 0 -#define BitmapOpenFailed 1 -#define BitmapFileInvalid 2 -#define BitmapNoMemory 3 -#endif -#define MAX_SIZE 255 - -/* shared data for the image read/parse logic */ -static short hexTable[256]; /* conversion value */ -static int initialized = FALSE; /* easier to fill in at run time */ - -/* - * Table index for the hex values. Initialized once, first time. - * Used for translation value or delimiter significance lookup. - */ -static void -initHexTable (void) -{ - /* - * We build the table at run time for several reasons: - * - * 1. portable to non-ASCII machines. - * 2. still reentrant since we set the init flag after setting table. - * 3. easier to extend. - * 4. less prone to bugs. - */ - hexTable['0'] = 0; hexTable['1'] = 1; - hexTable['2'] = 2; hexTable['3'] = 3; - hexTable['4'] = 4; hexTable['5'] = 5; - hexTable['6'] = 6; hexTable['7'] = 7; - hexTable['8'] = 8; hexTable['9'] = 9; - hexTable['A'] = 10; hexTable['B'] = 11; - hexTable['C'] = 12; hexTable['D'] = 13; - hexTable['E'] = 14; hexTable['F'] = 15; - hexTable['a'] = 10; hexTable['b'] = 11; - hexTable['c'] = 12; hexTable['d'] = 13; - hexTable['e'] = 14; hexTable['f'] = 15; - - /* delimiters of significance are flagged w/ negative value */ - hexTable[' '] = -1; hexTable[','] = -1; - hexTable['}'] = -1; hexTable['\n'] = -1; - hexTable['\t'] = -1; - - initialized = TRUE; -} - -/* - * read next hex value in the input stream, return -1 if EOF - */ -static int -NextInt (FILE *fstream) -{ - int ch; - int value = 0; - int gotone = 0; - int done = 0; - - /* loop, accumulate hex value until find delimiter */ - /* skip any initial delimiters found in read stream */ - - while (!done) { - ch = getc(fstream); - if (ch == EOF) { - value = -1; - done++; - } else { - /* trim high bits, check type and accumulate */ - ch &= 0xff; - if (isascii(ch) && isxdigit(ch)) { - value = (value << 4) + hexTable[ch]; - gotone++; - } else if ((hexTable[ch]) < 0 && gotone) - done++; - } - } - return value; -} - - -/* - * The data returned by the following routine is always in left-most byte - * first and left-most bit first. If it doesn't return BitmapSuccess then - * its arguments won't have been touched. This routine should look as much - * like the Xlib routine XReadBitmapfile as possible. - */ -int read_bitmap_data (FILE* fstream, unsigned int *width, - unsigned int *height, UChar_Binary **datap, - int *x_hot, int *y_hot) -{ - UChar_Binary *data = NULL; /* working variable */ - char line[MAX_SIZE]; /* input line from file */ - int size; /* number of bytes of data */ - char name_and_type[MAX_SIZE]; /* an input line */ - char *type; /* for parsing */ - int value; /* from an input line */ - int version10p; /* boolean, old format */ - int padding; /* to handle alignment */ - int bytes_per_line; /* per scanline of data */ - unsigned int ww = 0; /* width */ - unsigned int hh = 0; /* height */ - int hx = -1; /* x hotspot */ - int hy = -1; /* y hotspot */ - -#define Xmalloc(size) malloc(size) - - /* first time initialization */ - if (initialized == FALSE) initHexTable(); - - /* error cleanup and return macro */ -#define RETURN(code) { if (data) free (data); return code; } - - while (fgets(line, MAX_SIZE, fstream)) { - if (strlen(line) == MAX_SIZE-1) { - RETURN (BitmapFileInvalid); - } - if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (!strcmp("width", type)) - ww = (unsigned int) value; - if (!strcmp("height", type)) - hh = (unsigned int) value; - if (!strcmp("hot", type)) { - if (type-- == name_and_type || type-- == name_and_type) - continue; - if (!strcmp("x_hot", type)) - hx = value; - if (!strcmp("y_hot", type)) - hy = value; - } - continue; - } - - if (sscanf(line, "static short %s = {", name_and_type) == 1) - version10p = 1; - else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) - version10p = 0; - else if (sscanf(line, "static char %s = {", name_and_type) == 1) - version10p = 0; - else - continue; - - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (strcmp("bits[]", type)) - continue; - - if (!ww || !hh) - RETURN (BitmapFileInvalid); - - if ((ww % 16) && ((ww % 16) < 9) && version10p) - padding = 1; - else - padding = 0; - - bytes_per_line = (ww+7)/8 + padding; - - size = bytes_per_line * hh; - data = (UChar_Binary *) Xmalloc ((unsigned int) size); - if (!data) - RETURN (BitmapNoMemory); - - if (version10p) { - UChar_Binary *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; (bytes += 2)) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *(ptr++) = value; - if (!padding || ((bytes+2) % bytes_per_line)) - *(ptr++) = value >> 8; - } - } else { - UChar_Binary *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *ptr=value; - } - } - break; - } /* end while */ - - if (data == NULL) { - RETURN (BitmapFileInvalid); - } - - *datap = data; - data = NULL; - *width = ww; - *height = hh; - if (x_hot) *x_hot = hx; - if (y_hot) *y_hot = hy; - - RETURN (BitmapSuccess); -} - - -int read_bitmap_data_from_file (const char *filename, unsigned int *width, - unsigned int *height, UChar_Binary **datap, - int *x_hot, int *y_hot) -{ - FILE *fstream; - int status; - - if ((fstream = fopen (filename, "r")) == NULL) { - return BitmapOpenFailed; - } - status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot); - fclose (fstream); - return status; -} -#endif /* HAVE_X_WINDOWS */ - /* this table flips four bits around. */ static int flip_table[] = {
--- a/src/glyphs-shared.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/glyphs-shared.c Mon Jun 04 17:00:02 2001 +0000 @@ -1,4 +1,4 @@ -/* mswindows-specific glyph objects. +/* Routines shared between window-system backends for glyph objects. Copyright (C) 1993, 1994 Free Software Foundation, Inc. Copyright (C) 1995 Board of Trustees, University of Illinois. Copyright (C) 1995 Tinker Systems @@ -95,6 +95,240 @@ } } +/* Originally from xmu.c, but is now shared across X11, GTK, and MSW. */ +/* + * Based on an optimized version provided by Jim Becker, August 5, 1988. + */ + + +#ifndef BitmapSuccess +#define BitmapSuccess 0 +#define BitmapOpenFailed 1 +#define BitmapFileInvalid 2 +#define BitmapNoMemory 3 +#endif + +#define MAX_SIZE 255 + +/* shared data for the image read/parse logic */ +static short hexTable[256]; /* conversion value */ +static int hex_initialized; /* easier to fill in at run time */ + + +/* + * Table index for the hex values. Initialized once, first time. + * Used for translation value or delimiter significance lookup. + */ +static void initHexTable (void) +{ + /* + * We build the table at run time for several reasons: + * + * 1. portable to non-ASCII machines. + * 2. still reentrant since we set the init flag after setting table. + * 3. easier to extend. + * 4. less prone to bugs. + */ + hexTable['0'] = 0; hexTable['1'] = 1; + hexTable['2'] = 2; hexTable['3'] = 3; + hexTable['4'] = 4; hexTable['5'] = 5; + hexTable['6'] = 6; hexTable['7'] = 7; + hexTable['8'] = 8; hexTable['9'] = 9; + hexTable['A'] = 10; hexTable['B'] = 11; + hexTable['C'] = 12; hexTable['D'] = 13; + hexTable['E'] = 14; hexTable['F'] = 15; + hexTable['a'] = 10; hexTable['b'] = 11; + hexTable['c'] = 12; hexTable['d'] = 13; + hexTable['e'] = 14; hexTable['f'] = 15; + + /* delimiters of significance are flagged w/ negative value */ + hexTable[' '] = -1; hexTable[','] = -1; + hexTable['}'] = -1; hexTable['\n'] = -1; + hexTable['\t'] = -1; + + hex_initialized = 1; +} + +/* + * read next hex value in the input stream, return -1 if EOF + */ +static int NextInt (FILE *fstream) +{ + int ch; + int value = 0; + int gotone = 0; + int done = 0; + + /* loop, accumulate hex value until find delimiter */ + /* skip any initial delimiters found in read stream */ + + while (!done) { + ch = getc(fstream); + if (ch == EOF) { + value = -1; + done++; + } else { + /* trim high bits, check type and accumulate */ + ch &= 0xff; + if (isascii(ch) && isxdigit(ch)) { + value = (value << 4) + hexTable[ch]; + gotone++; + } else if ((hexTable[ch]) < 0 && gotone) + done++; + } + } + return value; +} + + +/* + * The data returned by the following routine is always in left-most byte + * first and left-most bit first. If it doesn't return BitmapSuccess then + * its arguments won't have been touched. This routine should look as much + * like the Xlib routine XReadBitmapfile as possible. + */ +int read_bitmap_data (FILE* fstream, unsigned int *width, + unsigned int *height, UChar_Binary **datap, + int *x_hot, int *y_hot) +{ + UChar_Binary *data = NULL; /* working variable */ + char line[MAX_SIZE]; /* input line from file */ + int size; /* number of bytes of data */ + char name_and_type[MAX_SIZE]; /* an input line */ + char *type; /* for parsing */ + int value; /* from an input line */ + int version10p; /* boolean, old format */ + int padding; /* to handle alignment */ + int bytes_per_line; /* per scanline of data */ + unsigned int ww = 0; /* width */ + unsigned int hh = 0; /* height */ + int hx = -1; /* x hotspot */ + int hy = -1; /* y hotspot */ + +#ifndef Xmalloc +#define Xmalloc(size) malloc(size) +#endif + + /* first time initialization */ + if (!hex_initialized) initHexTable(); + + /* error cleanup and return macro */ +#define RETURN(code) { if (data) free (data); return code; } + + while (fgets(line, MAX_SIZE, fstream)) { + if (strlen(line) == MAX_SIZE-1) { + RETURN (BitmapFileInvalid); + } + if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { + if (!(type = strrchr(name_and_type, '_'))) + type = name_and_type; + else + type++; + + if (!strcmp("width", type)) + ww = (unsigned int) value; + if (!strcmp("height", type)) + hh = (unsigned int) value; + if (!strcmp("hot", type)) { + if (type-- == name_and_type || type-- == name_and_type) + continue; + if (!strcmp("x_hot", type)) + hx = value; + if (!strcmp("y_hot", type)) + hy = value; + } + continue; + } + + if (sscanf(line, "static short %s = {", name_and_type) == 1) + version10p = 1; + else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) + version10p = 0; + else if (sscanf(line, "static char %s = {", name_and_type) == 1) + version10p = 0; + else + continue; + + if (!(type = strrchr(name_and_type, '_'))) + type = name_and_type; + else + type++; + + if (strcmp("bits[]", type)) + continue; + + if (!ww || !hh) + RETURN (BitmapFileInvalid); + + if ((ww % 16) && ((ww % 16) < 9) && version10p) + padding = 1; + else + padding = 0; + + bytes_per_line = (ww+7)/8 + padding; + + size = bytes_per_line * hh; + data = (UChar_Binary *) Xmalloc ((unsigned int) size); + if (!data) + RETURN (BitmapNoMemory); + + if (version10p) { + UChar_Binary *ptr; + int bytes; + + for (bytes=0, ptr=data; bytes<size; (bytes += 2)) { + if ((value = NextInt(fstream)) < 0) + RETURN (BitmapFileInvalid); + *(ptr++) = value; + if (!padding || ((bytes+2) % bytes_per_line)) + *(ptr++) = value >> 8; + } + } else { + UChar_Binary *ptr; + int bytes; + + for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { + if ((value = NextInt(fstream)) < 0) + RETURN (BitmapFileInvalid); + *ptr=value; + } + } + break; + } /* end while */ + + if (data == NULL) { + RETURN (BitmapFileInvalid); + } + + *datap = data; + data = NULL; + *width = ww; + *height = hh; + if (x_hot) *x_hot = hx; + if (y_hot) *y_hot = hy; + + RETURN (BitmapSuccess); +} + + +int read_bitmap_data_from_file (const char *filename, + /* Remaining args are RETURNED */ + unsigned int *width, + unsigned int *height, + UChar_Binary **datap, + int *x_hot, int *y_hot) +{ + FILE *fstream; + int status; + + if ((fstream = fopen (filename, "r")) == NULL) { + return BitmapOpenFailed; + } + status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot); + fclose (fstream); + return status; +} + void syms_of_glyphs_shared (void) {
--- a/src/glyphs-x.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/glyphs-x.c Mon Jun 04 17:00:02 2001 +0000 @@ -988,14 +988,6 @@ } } -int read_bitmap_data_from_file (const char *filename, unsigned int *width, - unsigned int *height, unsigned char **datap, - int *x_hot, int *y_hot) -{ - return XmuReadBitmapDataFromFile (filename, width, height, - datap, x_hot, y_hot); -} - /* Given inline data for a mono pixmap, create and return the corresponding X object. */
--- a/src/gpmevent.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/gpmevent.c Mon Jun 04 17:00:02 2001 +0000 @@ -39,13 +39,9 @@ #include "gpmevent.h" #include <gpm.h> -#if (!defined(__linux__)) /* possible under xterm */ #define KG_SHIFT 0 #define KG_CTRL 2 #define KG_ALT 3 -#else -#include <linux/keyboard.h> -#endif extern int gpm_tried; extern void *gpm_stack;
--- a/src/scrollbar-gtk.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/scrollbar-gtk.c Mon Jun 04 17:00:02 2001 +0000 @@ -115,7 +115,6 @@ gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), SCROLLBAR_GTK_WIDGET (instance), 0, 0); -#if GTK_CHECK_VERSION(1,2,9) /* ** With gtk version > 1.2.8 the scrollbars in gtk-xemacs and xemacs ** from CVS are invisible. In fact they are not invisible but very @@ -128,7 +127,6 @@ ** gtk_widget_show() call is done on the scrolbar. */ gtk_widget_size_request(GTK_WIDGET(sb), &(GTK_WIDGET(sb)->requisition)); -#endif gtk_widget_hide (SCROLLBAR_GTK_WIDGET (instance)); }
--- a/src/xmu.c Sun Jun 03 14:25:45 2001 +0000 +++ b/src/xmu.c Mon Jun 04 17:00:02 2001 +0000 @@ -156,235 +156,11 @@ return -1; } - -/* - * Based on an optimized version provided by Jim Becker, August 5, 1988. - */ - - -#define MAX_SIZE 255 - -/* shared data for the image read/parse logic */ -static short hexTable[256]; /* conversion value */ -static int hex_initialized; /* easier to fill in at run time */ - - -/* - * Table index for the hex values. Initialized once, first time. - * Used for translation value or delimiter significance lookup. - */ -static void initHexTable (void) -{ - /* - * We build the table at run time for several reasons: - * - * 1. portable to non-ASCII machines. - * 2. still reentrant since we set the init flag after setting table. - * 3. easier to extend. - * 4. less prone to bugs. - */ - hexTable['0'] = 0; hexTable['1'] = 1; - hexTable['2'] = 2; hexTable['3'] = 3; - hexTable['4'] = 4; hexTable['5'] = 5; - hexTable['6'] = 6; hexTable['7'] = 7; - hexTable['8'] = 8; hexTable['9'] = 9; - hexTable['A'] = 10; hexTable['B'] = 11; - hexTable['C'] = 12; hexTable['D'] = 13; - hexTable['E'] = 14; hexTable['F'] = 15; - hexTable['a'] = 10; hexTable['b'] = 11; - hexTable['c'] = 12; hexTable['d'] = 13; - hexTable['e'] = 14; hexTable['f'] = 15; - - /* delimiters of significance are flagged w/ negative value */ - hexTable[' '] = -1; hexTable[','] = -1; - hexTable['}'] = -1; hexTable['\n'] = -1; - hexTable['\t'] = -1; - - hex_initialized = 1; -} - -/* - * read next hex value in the input stream, return -1 if EOF - */ -static int NextInt (FILE *fstream) -{ - int ch; - int value = 0; - int gotone = 0; - int done = 0; - - /* loop, accumulate hex value until find delimiter */ - /* skip any initial delimiters found in read stream */ - - while (!done) { - ch = getc(fstream); - if (ch == EOF) { - value = -1; - done++; - } else { - /* trim high bits, check type and accumulate */ - ch &= 0xff; - if (isascii(ch) && isxdigit(ch)) { - value = (value << 4) + hexTable[ch]; - gotone++; - } else if ((hexTable[ch]) < 0 && gotone) - done++; - } - } - return value; -} - - -/* - * The data returned by the following routine is always in left-most byte - * first and left-most bit first. If it doesn't return BitmapSuccess then - * its arguments won't have been touched. This routine should look as much - * like the Xlib routine XReadBitmapfile as possible. +/* Definition of XmuReadBitmapDataFromFile replaced with the code in + * glyphs-shared.c + * + * wmperry Jun 1, 2001 */ -int XmuReadBitmapData ( - FILE *fstream, /* handle on file */ - unsigned int *width, /* RETURNED */ - unsigned int *height, /* RETURNED */ - unsigned char **datap, /* RETURNED */ - int *x_hot, int *y_hot) /* RETURNED */ -{ - unsigned char *data = NULL; /* working variable */ - char line[MAX_SIZE]; /* input line from file */ - int size; /* number of bytes of data */ - char name_and_type[MAX_SIZE]; /* an input line */ - char *type; /* for parsing */ - int value; /* from an input line */ - int version10p; /* boolean, old format */ - int padding; /* to handle alignment */ - int bytes_per_line; /* per scanline of data */ - unsigned int ww = 0; /* width */ - unsigned int hh = 0; /* height */ - int hx = -1; /* x hotspot */ - int hy = -1; /* y hotspot */ - -#ifndef Xmalloc -#define Xmalloc(size) malloc(size) -#endif - - /* first time initialization */ - if (!hex_initialized) initHexTable(); - - /* error cleanup and return macro */ -#define RETURN(code) { if (data) free (data); return code; } - - while (fgets(line, MAX_SIZE, fstream)) { - if (strlen(line) == MAX_SIZE-1) { - RETURN (BitmapFileInvalid); - } - if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (!strcmp("width", type)) - ww = (unsigned int) value; - if (!strcmp("height", type)) - hh = (unsigned int) value; - if (!strcmp("hot", type)) { - if (type-- == name_and_type || type-- == name_and_type) - continue; - if (!strcmp("x_hot", type)) - hx = value; - if (!strcmp("y_hot", type)) - hy = value; - } - continue; - } - - if (sscanf(line, "static short %s = {", name_and_type) == 1) - version10p = 1; - else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) - version10p = 0; - else if (sscanf(line, "static char %s = {", name_and_type) == 1) - version10p = 0; - else - continue; - - if (!(type = strrchr(name_and_type, '_'))) - type = name_and_type; - else - type++; - - if (strcmp("bits[]", type)) - continue; - - if (!ww || !hh) - RETURN (BitmapFileInvalid); - - if ((ww % 16) && ((ww % 16) < 9) && version10p) - padding = 1; - else - padding = 0; - - bytes_per_line = (ww+7)/8 + padding; - - size = bytes_per_line * hh; - data = (unsigned char *) Xmalloc ((unsigned int) size); - if (!data) - RETURN (BitmapNoMemory); - - if (version10p) { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; (bytes += 2)) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *(ptr++) = value; - if (!padding || ((bytes+2) % bytes_per_line)) - *(ptr++) = value >> 8; - } - } else { - unsigned char *ptr; - int bytes; - - for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { - if ((value = NextInt(fstream)) < 0) - RETURN (BitmapFileInvalid); - *ptr=value; - } - } - break; - } /* end while */ - - if (data == NULL) { - RETURN (BitmapFileInvalid); - } - - *datap = data; - data = NULL; - *width = ww; - *height = hh; - if (x_hot) *x_hot = hx; - if (y_hot) *y_hot = hy; - - RETURN (BitmapSuccess); -} - - -int XmuReadBitmapDataFromFile (const char *filename, - /* Remaining args are RETURNED */ - unsigned int *width, - unsigned int *height, - unsigned char **datap, - int *x_hot, int *y_hot) -{ - FILE *fstream; - int status; - - if ((fstream = fopen (filename, "r")) == NULL) { - return BitmapOpenFailed; - } - status = XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot); - fclose (fstream); - return status; -} /* * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual