aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/RdBitF.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-10-12 08:32:04 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-10-12 08:32:04 +0200
commit051d521f6e20761ba6831cecd91883da960fa931 (patch)
treeb28abba7818115d2fed80eb360a79a0f9183948e /nx-X11/lib/X11/RdBitF.c
parent6dce607bad8711dd06a5a7b69ad1930386b4123b (diff)
parentb8de7bf654929c823080b211aeac56cd213f5a32 (diff)
downloadnx-libs-051d521f6e20761ba6831cecd91883da960fa931.tar.gz
nx-libs-051d521f6e20761ba6831cecd91883da960fa931.tar.bz2
nx-libs-051d521f6e20761ba6831cecd91883da960fa931.zip
Merge branch 'uli42-pr/upgrade_libX11' into 3.6.x
Attributes GH PR #214: https://github.com/ArcticaProject/nx-libs/pull/214 Fixes ArcticaProject/nx-libs#157.
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;
}