summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
commit4349bf0fa125e2a1c32b0b49c974ff5fa588cdbe (patch)
tree2e4b857f2103cfbcdfcfd53b47334166e139a273 /src/util
parent3795e9702b3b3a6fe0594d09cdd110adeb5e42f9 (diff)
Diffstat (limited to 'src/util')
-rw-r--r--src/util/atom.c38
-rw-r--r--src/util/fontaccel.c10
-rw-r--r--src/util/fontnames.c12
-rw-r--r--src/util/fontutil.c88
-rw-r--r--src/util/fontxlfd.c144
-rw-r--r--src/util/format.c18
-rw-r--r--src/util/miscutil.c41
-rw-r--r--src/util/patcache.c34
-rw-r--r--src/util/private.c57
-rw-r--r--src/util/utilbitmap.c28
10 files changed, 283 insertions, 187 deletions
diff --git a/src/util/atom.c b/src/util/atom.c
index 140d774..3863c94 100644
--- a/src/util/atom.c
+++ b/src/util/atom.c
@@ -25,6 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/atom.c,v 1.10 2002/09/24 20:52:48 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -52,8 +53,7 @@ static int reverseMapSize;
static Atom lastAtom;
static int
-Hash(string, len)
- char *string;
+Hash(char *string, int len)
{
int h;
@@ -66,7 +66,7 @@ Hash(string, len)
}
static int
-ResizeHashTable ()
+ResizeHashTable (void)
{
int newHashSize;
int newHashMask;
@@ -82,7 +82,9 @@ ResizeHashTable ()
newHashSize = hashSize * 2;
newHashTable = (AtomListPtr *) xalloc (newHashSize * sizeof (AtomListPtr));
if (!newHashTable) {
- fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate newHashTable (%d)\n", newHashSize * sizeof (AtomListPtr));
+ fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
+ " newHashTable (%ld)\n",
+ newHashSize * (unsigned long)sizeof (AtomListPtr));
return FALSE;
}
bzero ((char *) newHashTable, newHashSize * sizeof (AtomListPtr));
@@ -114,7 +116,7 @@ ResizeHashTable ()
}
static int
-ResizeReverseMap ()
+ResizeReverseMap (void)
{
int ret = TRUE;
if (reverseMapSize == 0)
@@ -123,15 +125,16 @@ ResizeReverseMap ()
reverseMapSize *= 2;
reverseMap = (AtomListPtr *) xrealloc (reverseMap, reverseMapSize * sizeof (AtomListPtr));
if (!reverseMap) {
- fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate reverseMap (%d)\n", reverseMapSize * sizeof(AtomListPtr));
+ fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
+ " reverseMap (%ld)\n",
+ reverseMapSize * (unsigned long)sizeof(AtomListPtr));
ret = FALSE;
}
return ret;
}
static int
-NameEqual (a, b, l)
- char *a, *b;
+NameEqual (const char *a, const char *b, int l)
{
while (l--)
if (*a++ != *b++)
@@ -140,14 +143,11 @@ NameEqual (a, b, l)
}
Atom
-MakeAtom(string, len, makeit)
- char *string;
- unsigned len;
- int makeit;
+MakeAtom(char *string, unsigned len, int makeit)
{
AtomListPtr a;
int hash;
- int h;
+ int h = 0;
int r;
hash = Hash (string, len);
@@ -181,7 +181,8 @@ MakeAtom(string, len, makeit)
return None;
a = (AtomListPtr) xalloc (sizeof (AtomListRec) + len + 1);
if (a == NULL) {
- fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec (%d)\n", sizeof (AtomListRec) + len + 1);
+ fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
+ " (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
return None;
}
a->name = (char *) (a + 1);
@@ -214,17 +215,16 @@ MakeAtom(string, len, makeit)
return a->atom;
}
-int ValidAtom(atom)
- Atom atom;
+int
+ValidAtom(Atom atom)
{
return (atom != None) && (atom <= lastAtom);
}
char *
-NameForAtom(atom)
- Atom atom;
+NameForAtom(Atom atom)
{
if (atom != None && atom <= lastAtom)
return reverseMap[atom]->name;
- return 0;
+ return NULL;
}
diff --git a/src/util/fontaccel.c b/src/util/fontaccel.c
index b0e8b57..f922145 100644
--- a/src/util/fontaccel.c
+++ b/src/util/fontaccel.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontaccel.c,v 1.7 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -34,9 +35,10 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
+#include "fontutil.h"
-void FontComputeInfoAccelerators(pFontInfo)
- FontInfoPtr pFontInfo;
+void
+FontComputeInfoAccelerators(FontInfoPtr pFontInfo)
{
pFontInfo->noOverlap = FALSE;
if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing)
@@ -80,8 +82,8 @@ void FontComputeInfoAccelerators(pFontInfo)
pFontInfo->inkInside = FALSE;
}
-int FontCouldBeTerminal(pFontInfo)
- FontInfoPtr pFontInfo;
+int
+FontCouldBeTerminal(FontInfoPtr pFontInfo)
{
if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
(pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) &&
diff --git a/src/util/fontnames.c b/src/util/fontnames.c
index 939d531..cbd355a 100644
--- a/src/util/fontnames.c
+++ b/src/util/fontnames.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontnames.c,v 1.5 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -38,8 +39,7 @@ from The Open Group.
#include "fontstruct.h"
void
-FreeFontNames(pFN)
- FontNamesPtr pFN;
+FreeFontNames(FontNamesPtr pFN)
{
int i;
@@ -54,8 +54,7 @@ FreeFontNames(pFN)
}
FontNamesPtr
-MakeFontNamesRecord(size)
- unsigned size;
+MakeFontNamesRecord(unsigned int size)
{
FontNamesPtr pFN;
@@ -84,10 +83,7 @@ MakeFontNamesRecord(size)
}
int
-AddFontNamesName(names, name, length)
- FontNamesPtr names;
- char *name;
- int length;
+AddFontNamesName(FontNamesPtr names, char *name, int length)
{
int index = names->nnames;
char *nelt;
diff --git a/src/util/fontutil.c b/src/util/fontutil.c
index c67be62..3bd5e51 100644
--- a/src/util/fontutil.c
+++ b/src/util/fontutil.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontutil.c,v 3.7 2001/12/14 19:56:56 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,6 +36,7 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
#include "FSproto.h"
+#include "fontutil.h"
/* Define global here... doesn't hurt the servers, and avoids
unresolved references in font clients. */
@@ -43,13 +45,12 @@ static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
void
-GetGlyphs(font, count, chars, fontEncoding, glyphcount, glyphs)
- FontPtr font;
- unsigned long count;
- unsigned char *chars;
- FontEncoding fontEncoding;
- unsigned long *glyphcount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+GetGlyphs(FontPtr font,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding fontEncoding,
+ unsigned long *glyphcount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
(*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs);
}
@@ -58,11 +59,10 @@ GetGlyphs(font, count, chars, fontEncoding, glyphcount, glyphs)
#define MAX(a,b) ((a)>(b)?(a):(b))
void
-QueryGlyphExtents(pFont, charinfo, count, info)
- FontPtr pFont;
- CharInfoPtr *charinfo;
- unsigned long count;
- ExtentInfoRec *info;
+QueryGlyphExtents(FontPtr pFont,
+ CharInfoPtr *charinfo,
+ unsigned long count,
+ ExtentInfoRec *info)
{
register unsigned long i;
xCharInfo *pCI;
@@ -131,11 +131,10 @@ QueryGlyphExtents(pFont, charinfo, count, info)
}
Bool
-QueryTextExtents(pFont, count, chars, info)
- FontPtr pFont;
- unsigned long count;
- unsigned char *chars;
- ExtentInfoRec *info;
+QueryTextExtents(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ ExtentInfoRec *info)
{
xCharInfo **charinfo;
unsigned long n;
@@ -158,11 +157,11 @@ QueryTextExtents(pFont, count, chars, info)
/* Do default character substitution as get_metrics doesn't */
#define IsNonExistentChar(ci) (!(ci) || \
- (ci)->ascent == 0 && \
+ ((ci)->ascent == 0 && \
(ci)->descent == 0 && \
(ci)->leftSideBearing == 0 && \
(ci)->rightSideBearing == 0 && \
- (ci)->characterWidth == 0)
+ (ci)->characterWidth == 0))
firstReal = n;
defc[0] = pFont->info.defaultCh >> 8;
@@ -191,8 +190,7 @@ QueryTextExtents(pFont, count, chars, info)
}
Bool
-ParseGlyphCachingMode(str)
- char *str;
+ParseGlyphCachingMode(char *str)
{
if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF;
else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS;
@@ -202,7 +200,7 @@ ParseGlyphCachingMode(str)
}
void
-InitGlyphCaching()
+InitGlyphCaching(void)
{
/* Set glyphCachingMode to the mode the server hopes to
support. DDX drivers that do not support the requested level
@@ -217,8 +215,7 @@ InitGlyphCaching()
* caching they can support.
*/
void
-SetGlyphCachingMode(newmode)
- int newmode;
+SetGlyphCachingMode(int newmode)
{
if ( (glyphCachingMode > newmode) && (newmode >= 0) )
glyphCachingMode = newmode;
@@ -230,16 +227,15 @@ SetGlyphCachingMode(newmode)
/* add_range(): Add range to a list of ranges, with coalescence */
int
-add_range(newrange, nranges, range, charset_subset)
-fsRange *newrange;
-int *nranges;
-fsRange **range;
-Bool charset_subset;
+add_range(fsRange *newrange,
+ int *nranges,
+ fsRange **range,
+ Bool charset_subset)
{
int first, last, middle;
unsigned long keymin, keymax;
- unsigned long ptrmin, ptrmax;
- fsRange *ptr, *ptr1, *ptr2, *endptr;
+ unsigned long ptrmin = 0, ptrmax = 0;
+ fsRange *ptr = NULL, *ptr1, *ptr2, *endptr;
/* There are two different ways to treat ranges:
@@ -257,7 +253,7 @@ Bool charset_subset;
/* If newrange covers multiple rows; break up the rows */
if (!charset_subset && newrange->min_char_high != newrange->max_char_high)
{
- int i, err;
+ int i, err = 0;
fsRange temprange;
for (i = newrange->min_char_high;
i <= newrange->max_char_high;
@@ -414,3 +410,31 @@ Bool charset_subset;
return Successful;
}
+
+/* It is difficult to find a good place for this. */
+#ifdef NEED_STRCASECMP
+int
+f_strcasecmp(const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (*s1 == 0)
+ if (*s2 == 0)
+ return 0;
+ else
+ return 1;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2) {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return c1 - c2;
+}
+#endif
+
diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c
index f1245f6..3a2c93d 100644
--- a/src/util/fontxlfd.c
+++ b/src/util/fontxlfd.c
@@ -27,6 +27,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/fontxlfd.c,v 3.15 2002/05/31 18:45:50 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -35,12 +36,11 @@ from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
#include "fontxlfd.h"
+#include "fontutil.h"
#include <X11/Xos.h>
#include <math.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#endif
-#if defined(X_NOT_STDC_ENV) || (defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV))
+#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV)
#define NO_LOCALE
#endif
#ifndef NO_LOCALE
@@ -50,9 +50,7 @@ from The Open Group.
#include <stdio.h> /* for sprintf() */
static char *
-GetInt(ptr, val)
- char *ptr;
- int *val;
+GetInt(char *ptr, int *val)
{
if (*ptr == '*') {
*val = -1;
@@ -75,9 +73,7 @@ static struct lconv *locale = 0;
static char *radix = ".", *plus = "+", *minus = "-";
static char *
-readreal(ptr, result)
-char *ptr;
-double *result;
+readreal(char *ptr, double *result)
{
char buffer[80], *p1, *p2;
@@ -112,26 +108,13 @@ double *result;
*p2 = 0;
/* Now we have something that strtod() can interpret... do it. */
-#ifndef X_NOT_STDC_ENV
*result = strtod(buffer, &p1);
/* Return NULL if failure, pointer past number if success */
return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer));
-#else
- for (p1 = buffer; isspace(*p1); p1++)
- ;
- if (sscanf(p1, "%lf", result) != 1)
- return (char *)0;
- while (!isspace(*p1))
- p1++;
- return ptr + (p1 - buffer);
-#endif
}
static char *
-xlfd_double_to_text(value, buffer, space_required)
-double value;
-char *buffer;
-int space_required;
+xlfd_double_to_text(double value, char *buffer, int space_required)
{
char formatbuf[40];
register char *p1;
@@ -204,24 +187,95 @@ int space_required;
}
double
-xlfd_round_double(x)
-double x;
+xlfd_round_double(double x)
{
- /* Utility for XLFD users to round numbers to XLFD_NDIGITS
- significant digits. How do you round to n significant digits on
- a binary machine? Let printf() do it for you. */
- char formatbuf[40], buffer[40];
-
- sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
- sprintf(buffer, formatbuf, x);
- return atof(buffer);
+ /* Utility for XLFD users to round numbers to XLFD_NDIGITS
+ significant digits. How do you round to n significant digits on
+ a binary machine? */
+
+#if defined(i386) || defined(__i386__) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__hppa__) || \
+ defined(__x86_64__) || defined(__x86_64)
+#if !defined(__UNIXOS2__)
+#include <float.h>
+
+/* if we have IEEE 754 fp, we can round to binary digits... */
+
+#if (FLT_RADIX == 2) && (DBL_DIG == 15) && (DBL_MANT_DIG == 53)
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10 2.30258509299404568402
+#endif
+
+/* convert # of decimal digits to # of binary digits */
+#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5))
+
+ union conv_d {
+ double d;
+ unsigned char b[8];
+ } d;
+ int i,j,k,d_exp;
+
+ if (x == 0)
+ return x;
+
+ /* do minor sanity check for IEEE 754 fp and correct byte order */
+ d.d = 1.0;
+ if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) {
+
+ /*
+ * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits
+ */
+
+ d.d = x;
+ d_exp = (d.b[7] << 4) | (d.b[6] >> 4);
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ for (; i<7; i++) {
+ k = d.b[i] + j;
+ d.b[i] = k;
+ if (k & 0x100) j = 1;
+ else break;
+ }
+ if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) {
+ /* mantissa overflow: increment exponent */
+ d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1);
+ d.b[7] = d_exp >> 4;
+ d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4);
+ }
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ d.b[i] &= ~(j-1);
+ for (;--i>=0;) d.b[i] = 0;
+
+ return d.d;
+ }
+ else
+#endif
+#endif /* !__UNIXOS2__ */
+#endif /* i386 || __i386__ */
+ {
+ /*
+ * If not IEEE 754: Let printf() do it for you.
+ */
+
+ char formatbuf[40], buffer[40];
+
+ sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
+ sprintf(buffer, formatbuf, x);
+ return atof(buffer);
+ }
}
static char *
-GetMatrix(ptr, vals, which)
-char *ptr;
-FontScalablePtr vals;
-int which;
+GetMatrix(char *ptr, FontScalablePtr vals, int which)
{
double *matrix;
@@ -298,10 +352,8 @@ int which;
}
-static void append_ranges(fname, nranges, ranges)
-char *fname;
-int nranges;
-fsRange *ranges;
+static void
+append_ranges(char *fname, int nranges, fsRange *ranges)
{
if (nranges)
{
@@ -325,10 +377,7 @@ fsRange *ranges;
}
Bool
-FontParseXLFDName(fname, vals, subst)
- char *fname;
- FontScalablePtr vals;
- int subst;
+FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
{
register char *ptr;
register char *ptr1,
@@ -532,15 +581,12 @@ FontParseXLFDName(fname, vals, subst)
return TRUE;
}
-fsRange *FontParseRanges(name, nranges)
-char *name;
-int *nranges;
+fsRange *FontParseRanges(char *name, int *nranges)
{
int n;
unsigned long l;
char *p1, *p2;
fsRange *result = (fsRange *)0;
- extern int add_range();
name = strchr(name, '-');
for (n = 1; name && n < 14; n++)
diff --git a/src/util/format.c b/src/util/format.c
index 615f0ee..c406009 100644
--- a/src/util/format.c
+++ b/src/util/format.c
@@ -50,19 +50,21 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/format.c,v 1.5 2001/12/14 19:56:57 dawes Exp $ */
#include "FSproto.h"
#include "font.h"
+#include "fontstruct.h"
+#include "fontutil.h"
int
-CheckFSFormat(format, fmask, bit_order, byte_order, scan, glyph, image)
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- int *bit_order,
- *byte_order,
- *scan,
- *glyph,
- *image;
+CheckFSFormat(fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ int *bit_order,
+ int *byte_order,
+ int *scan,
+ int *glyph,
+ int *image)
{
/* convert format to what the low levels want */
if (fmask & BitmapFormatMaskBit) {
diff --git a/src/util/miscutil.c b/src/util/miscutil.c
index 5db04a1..484e387 100644
--- a/src/util/miscutil.c
+++ b/src/util/miscutil.c
@@ -27,13 +27,11 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/miscutil.c,v 1.8 2001/12/14 19:56:57 dawes Exp $ */
#include <X11/Xosdefs.h>
-#ifndef X_NOT_STDC_ENV
#include <stdlib.h>
-#else
-char *malloc(), *realloc();
-#endif
+#include "fontmisc.h"
#define XK_LATIN1
#include <X11/keysymdef.h>
@@ -43,32 +41,36 @@ char *malloc(), *realloc();
long serverGeneration = 1;
-unsigned long *
-Xalloc (m)
+void *
+Xalloc (unsigned long m)
{
- return (unsigned long *) malloc (m);
+ return malloc (m);
}
-unsigned long *
-Xrealloc (n,m)
- unsigned long *n;
+void *
+Xrealloc (void *n, unsigned long m)
{
if (!n)
- return (unsigned long *) malloc (m);
+ return malloc (m);
else
- return (unsigned long *) realloc ((char *) n, m);
+ return realloc (n, m);
}
-void Xfree (n)
- unsigned long *n;
+void
+Xfree (void *n)
{
if (n)
- free ((char *) n);
+ free (n);
}
-void CopyISOLatin1Lowered (dst, src, len)
- char *dst, *src;
- int len;
+void *
+Xcalloc (unsigned long n)
+{
+ return calloc (n, 1);
+}
+
+void
+CopyISOLatin1Lowered (char *dst, char *src, int len)
{
register unsigned char *dest, *source;
@@ -88,6 +90,7 @@ void CopyISOLatin1Lowered (dst, src, len)
*dest = '\0';
}
-void register_fpe_functions ()
+void
+register_fpe_functions ()
{
}
diff --git a/src/util/patcache.c b/src/util/patcache.c
index 824255c..7b31016 100644
--- a/src/util/patcache.c
+++ b/src/util/patcache.c
@@ -25,6 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/patcache.c,v 3.5 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -62,8 +63,7 @@ typedef struct _FontPatternCache {
/* Empty cache (for rehash) */
void
-EmptyFontPatternCache (cache)
- FontPatternCachePtr cache;
+EmptyFontPatternCache (FontPatternCachePtr cache)
{
int i;
@@ -84,7 +84,7 @@ EmptyFontPatternCache (cache)
/* Create and initialize cache */
FontPatternCachePtr
-MakeFontPatternCache ()
+MakeFontPatternCache (void)
{
FontPatternCachePtr cache;
int i;
@@ -102,8 +102,7 @@ MakeFontPatternCache ()
/* toss cache */
void
-FreeFontPatternCache (cache)
- FontPatternCachePtr cache;
+FreeFontPatternCache (FontPatternCachePtr cache)
{
int i;
@@ -114,9 +113,7 @@ FreeFontPatternCache (cache)
/* compute id for string */
static int
-Hash (string, len)
- char *string;
- int len;
+Hash (const char *string, int len)
{
int hash;
@@ -130,11 +127,10 @@ Hash (string, len)
/* add entry */
void
-CacheFontPattern (cache, pattern, patlen, pFont)
- FontPatternCachePtr cache;
- char *pattern;
- int patlen;
- FontPtr pFont;
+CacheFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen,
+ FontPtr pFont)
{
FontPatternCacheEntryPtr e;
char *newpat;
@@ -177,10 +173,9 @@ CacheFontPattern (cache, pattern, patlen, pFont)
/* find matching entry */
FontPtr
-FindCachedFontPattern (cache, pattern, patlen)
- FontPatternCachePtr cache;
- char *pattern;
- int patlen;
+FindCachedFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen)
{
int hash;
int i;
@@ -200,9 +195,8 @@ FindCachedFontPattern (cache, pattern, patlen)
}
void
-RemoveCachedFontPattern (cache, pFont)
- FontPatternCachePtr cache;
- FontPtr pFont;
+RemoveCachedFontPattern (FontPatternCachePtr cache,
+ FontPtr pFont)
{
FontPatternCacheEntryPtr e;
int i;
diff --git a/src/util/private.c b/src/util/private.c
index 9cb58c6..ef7d48b 100644
--- a/src/util/private.c
+++ b/src/util/private.c
@@ -25,6 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/private.c,v 1.8 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -33,33 +34,64 @@ in this Software without prior written authorization from The Open Group.
#include "fontmisc.h"
#include "fontstruct.h"
-int _FontPrivateAllocateIndex;
+static int _FontPrivateAllocateIndex = 0;
int
-AllocateFontPrivateIndex ()
+AllocateFontPrivateIndex (void)
{
return _FontPrivateAllocateIndex++;
}
+FontPtr
+CreateFontRec (void)
+{
+ FontPtr pFont;
+ int size;
+
+ size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
+
+ pFont = (FontPtr)xalloc(size);
+ bzero((char*)pFont, size);
+
+ if(pFont) {
+ pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
+ if(_FontPrivateAllocateIndex)
+ pFont->devPrivates = (pointer)(&pFont[1]);
+ }
+
+ return pFont;
+}
+
+void DestroyFontRec (FontPtr pFont)
+{
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
+ xfree(pFont->devPrivates);
+ xfree(pFont);
+}
+
void
-ResetFontPrivateIndex ()
+ResetFontPrivateIndex (void)
{
_FontPrivateAllocateIndex = 0;
}
Bool
-_FontSetNewPrivate (pFont, n, ptr)
- FontPtr pFont;
- int n;
- pointer ptr;
+_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr)
{
pointer *new;
- if (n > pFont->maxPrivate)
- {
- new = (pointer *) xrealloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
+ if (n > pFont->maxPrivate) {
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
+ new = (pointer *) xrealloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ } else {
+ new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ if (pFont->devPrivates)
+ memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer));
+ }
pFont->devPrivates = new;
/* zero out new, uninitialized privates */
while(++pFont->maxPrivate < n)
@@ -68,3 +100,4 @@ _FontSetNewPrivate (pFont, n, ptr)
pFont->devPrivates[n] = ptr;
return TRUE;
}
+
diff --git a/src/util/utilbitmap.c b/src/util/utilbitmap.c
index 9842db1..c407f29 100644
--- a/src/util/utilbitmap.c
+++ b/src/util/utilbitmap.c
@@ -25,11 +25,14 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
+/* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.5 2001/12/14 19:56:57 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
*/
+#include "fontmisc.h"
+
/* Utility functions for reformating font bitmaps */
static unsigned char _reverse_byte[0x100] = {
@@ -71,11 +74,9 @@ static unsigned char _reverse_byte[0x100] = {
* Invert bit order within each BYTE of an array.
*/
void
-BitOrderInvert(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+BitOrderInvert(unsigned char *buf, int nbytes)
{
- register unsigned char *rev = _reverse_byte;
+ unsigned char *rev = _reverse_byte;
for (; --nbytes >= 0; buf++)
*buf = rev[*buf];
@@ -85,11 +86,9 @@ BitOrderInvert(buf, nbytes)
* Invert byte order within each 16-bits of an array.
*/
void
-TwoByteSwap(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+TwoByteSwap(unsigned char *buf, int nbytes)
{
- register unsigned char c;
+ unsigned char c;
for (; nbytes > 0; nbytes -= 2, buf += 2)
{
@@ -103,11 +102,9 @@ TwoByteSwap(buf, nbytes)
* Invert byte order within each 32-bits of an array.
*/
void
-FourByteSwap(buf, nbytes)
- register unsigned char *buf;
- register int nbytes;
+FourByteSwap(unsigned char *buf, int nbytes)
{
- register unsigned char c;
+ unsigned char c;
for (; nbytes > 0; nbytes -= 4, buf += 4)
{
@@ -125,10 +122,9 @@ FourByteSwap(buf, nbytes)
*/
int
-RepadBitmap (pSrc, pDst, srcPad, dstPad, width, height)
- char *pSrc, *pDst;
- unsigned srcPad, dstPad;
- int width, height;
+RepadBitmap (char *pSrc, char *pDst,
+ unsigned int srcPad, unsigned int dstPad,
+ int width, int height)
{
int srcWidthBytes,dstWidthBytes;
int row,col;