aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/RdBitF.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2016-07-29 00:44:38 +0200
committerUlrich Sibiller <uli42@gmx.de>2016-10-10 22:52:29 +0200
commit687d44b6eaa3c64a12af9bbd557b401419b208eb (patch)
tree55c30ba6b0ae6a2618395fae92922ea4402d52f6 /nx-X11/lib/X11/RdBitF.c
parentea24f0b0eb7b82ad879810c8e84292d6bf810bea (diff)
downloadnx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.tar.gz
nx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.tar.bz2
nx-libs-687d44b6eaa3c64a12af9bbd557b401419b208eb.zip
update src files *[ch] to libX11 1.3.4
Diffstat (limited to 'nx-X11/lib/X11/RdBitF.c')
-rw-r--r--nx-X11/lib/X11/RdBitF.c73
1 files changed, 25 insertions, 48 deletions
diff --git a/nx-X11/lib/X11/RdBitF.c b/nx-X11/lib/X11/RdBitF.c
index ffb703ba3..b3c21bc53 100644
--- a/nx-X11/lib/X11/RdBitF.c
+++ b/nx-X11/lib/X11/RdBitF.c
@@ -27,17 +27,17 @@ from The Open Group.
*/
/*
- * Code to read bitmaps from disk files. Interprets
+ * Code to read bitmaps from disk files. Interprets
* data from X10 and X11 bitmap files and creates
* Pixmap representations of files. Returns Pixmap
* ID and specifics about image.
*
* Modified for speedup by Jim Becker, changed image
- * data parsing logic (removed some fscanf()s).
+ * data parsing logic (removed some fscanf()s).
* Aug 5, 1988
*
* Note that this file and ../Xmu/RdBitF.c look very similar.... Keep them
- * that way (but don't use common source code so that people can have one
+ * that way (but don't use common source code so that people can have one
* without the other).
*/
@@ -54,43 +54,23 @@ from The Open Group.
#define MAX_SIZE 255
/* shared data for the image read/parse logic */
-static short hexTable[256]; /* conversion value */
-static Bool 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;
-}
+static const short hexTable[256] = {
+ ['0'] = 0, ['1'] = 1,
+ ['2'] = 2, ['3'] = 3,
+ ['4'] = 4, ['5'] = 5,
+ ['6'] = 6, ['7'] = 7,
+ ['8'] = 8, ['9'] = 9,
+ ['A'] = 10, ['B'] = 11,
+ ['C'] = 12, ['D'] = 13,
+ ['E'] = 14, ['F'] = 15,
+ ['a'] = 10, ['b'] = 11,
+ ['c'] = 12, ['d'] = 13,
+ ['e'] = 14, ['f'] = 15,
+
+ [' '] = -1, [','] = -1,
+ ['}'] = -1, ['\n'] = -1,
+ ['\t'] = -1
+};
/*
* read next hex value in the input stream, return -1 if EOF
@@ -103,7 +83,7 @@ NextInt (
int value = 0;
int gotone = 0;
int done = 0;
-
+
/* loop, accumulate hex value until find delimiter */
/* skip any initial delimiters found in read stream */
@@ -149,9 +129,6 @@ XReadBitmapFileData (
int hx = -1; /* x hotspot */
int hy = -1; /* y hotspot */
- /* first time initialization */
- if (initialized == False) initHexTable();
-
#ifdef __UNIXOS2__
filename = __XOS2RedirRoot(filename);
#endif
@@ -185,7 +162,7 @@ XReadBitmapFileData (
}
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)
@@ -202,7 +179,7 @@ XReadBitmapFileData (
if (strcmp("bits[]", type))
continue;
-
+
if (!ww || !hh)
RETURN (BitmapFileInvalid);
@@ -215,7 +192,7 @@ XReadBitmapFileData (
size = bytes_per_line * hh;
bits = (unsigned char *) Xmalloc ((unsigned int) size);
- if (!bits)
+ if (!bits)
RETURN (BitmapNoMemory);
if (version10p) {
@@ -234,7 +211,7 @@ XReadBitmapFileData (
int bytes;
for (bytes=0, ptr=bits; bytes<size; bytes++, ptr++) {
- if ((value = NextInt(fstream)) < 0)
+ if ((value = NextInt(fstream)) < 0)
RETURN (BitmapFileInvalid);
*ptr=value;
}