summaryrefslogtreecommitdiff
path: root/lib/libXfont2/src
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2024-11-05 08:14:57 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2024-11-05 08:14:57 +0000
commit11b563ea9d7cd1e78e1e3bdd63d22a1587e0aaba (patch)
tree46b9e3b5d8acae8337f9cc9d361cfadc8b79f9ff /lib/libXfont2/src
parent3ced31dfa7da11653ae880c2776cbf2e2256a009 (diff)
Update to libXfont2 2.0.7
Diffstat (limited to 'lib/libXfont2/src')
-rw-r--r--lib/libXfont2/src/bitmap/bitscale.c24
-rw-r--r--lib/libXfont2/src/fc/fserve.c49
-rw-r--r--lib/libXfont2/src/fc/fsio.c4
-rw-r--r--lib/libXfont2/src/fc/fsio.h4
-rw-r--r--lib/libXfont2/src/fc/fslibos.h10
-rw-r--r--lib/libXfont2/src/fontfile/bufio.c8
-rw-r--r--lib/libXfont2/src/fontfile/bunzip2.c2
-rw-r--r--lib/libXfont2/src/fontfile/dirfile.c8
-rw-r--r--lib/libXfont2/src/fontfile/fontfile.c4
-rw-r--r--lib/libXfont2/src/stubs/atom.c38
-rw-r--r--lib/libXfont2/src/util/fontxlfd.c20
-rw-r--r--lib/libXfont2/src/util/replace.h8
12 files changed, 48 insertions, 131 deletions
diff --git a/lib/libXfont2/src/bitmap/bitscale.c b/lib/libXfont2/src/bitmap/bitscale.c
index e29ba9694..3f3c10e29 100644
--- a/lib/libXfont2/src/bitmap/bitscale.c
+++ b/lib/libXfont2/src/bitmap/bitscale.c
@@ -41,10 +41,6 @@ from The Open Group.
#include <X11/fonts/fontutil.h>
#include <math.h>
-#ifndef MAX
-#define MAX(a,b) (((a)>(b)) ? a : b)
-#endif
-
static void bitmapUnloadScalable (FontPtr pFont);
static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
CharInfoPtr pci, double *inv_xform,
@@ -281,24 +277,24 @@ ComputeScaleFactors(FontScalablePtr from, FontScalablePtr to,
/* favor enlargement over reduction because of aliasing resulting
from reduction */
#define SCORE(m,s) \
-if (m >= 1.0) { \
- if (m == 1.0) \
- score += (16 * s); \
- else if (m == 2.0) \
- score += (4 * s); \
+if ((m) >= 1.0) { \
+ if ((m) == 1.0) \
+ score += (16 * (s)); \
+ else if ((m) == 2.0) \
+ score += (4 * (s)); \
else \
- score += (int)(((double)(3 * s)) / m); \
+ score += (int)(((double)(3 * (s))) / (m)); \
} else { \
- score += (int)(((double)(2 * s)) * m); \
+ score += (int)(((double)(2 * (s))) * (m)); \
}
/* don't need to favor enlargement when looking for bitmap that can
be used unscalable */
#define SCORE2(m,s) \
-if (m >= 1.0) \
- score += (int)(((double)(8 * s)) / m); \
+if ((m) >= 1.0) \
+ score += (int)(((double)(8 * (s))) / (m)); \
else \
- score += (int)(((double)(8 * s)) * m);
+ score += (int)(((double)(8 * (s))) * (m));
static FontEntryPtr
FindBestToScale(FontPathElementPtr fpe, FontEntryPtr entry,
diff --git a/lib/libXfont2/src/fc/fserve.c b/lib/libXfont2/src/fc/fserve.c
index c6762349c..abf7d070f 100644
--- a/lib/libXfont2/src/fc/fserve.c
+++ b/lib/libXfont2/src/fc/fserve.c
@@ -77,10 +77,6 @@ in this Software without prior written authorization from The Open Group.
#include <time.h>
#define Time_t time_t
-#ifdef NCD
-#include <ncd/nvram.h>
-#endif
-
#include <stddef.h>
#ifndef MIN
@@ -335,10 +331,6 @@ fs_init_fpe(FontPathElementPtr fpe)
if (err == Successful)
{
-#ifdef NCD
- if (configData.ExtendedFontDiags)
- printf("Connected to font server \"%s\"\n", name);
-#endif
#ifdef DEBUG
fprintf (stderr, "connected to FS \"%s\"\n", name);
#endif
@@ -348,10 +340,6 @@ fs_init_fpe(FontPathElementPtr fpe)
#ifdef DEBUG
fprintf(stderr, "failed to connect to FS \"%s\" %d\n", name, err);
#endif
-#ifdef NCD
- if (configData.ExtendedFontDiags)
- printf("Failed to connect to font server \"%s\"\n", name);
-#endif
;
}
return err;
@@ -388,10 +376,6 @@ fs_free_fpe(FontPathElementPtr fpe)
_fs_free_conn (conn);
fpe->private = (pointer) 0;
-#ifdef NCD
- if (configData.ExtendedFontDiags)
- printf("Disconnected from font server \"%s\"\n", fpe->name);
-#endif
#ifdef DEBUG
fprintf (stderr, "disconnect from FS \"%s\"\n", fpe->name);
#endif
@@ -1484,6 +1468,8 @@ fs_wakeup(FontPathElementPtr fpe)
{
FSFpePtr conn = (FSFpePtr) fpe->private;
+ if ((conn->blockState & FS_RECONNECTING))
+ _fs_check_reconnect (conn);
if (conn->blockState & (FS_PENDING_REPLY|FS_BROKEN_CONNECTION|FS_BROKEN_WRITE))
_fs_do_blocked (conn);
if (conn->blockState & FS_COMPLETE_REPLY)
@@ -1760,15 +1746,6 @@ fs_send_open_font(pointer client, FontPathElementPtr fpe, Mask flags,
_fs_write(conn, (char *) &extreq, SIZEOF(fsQueryXExtents16Req));
}
-#ifdef NCD
- if (configData.ExtendedFontDiags)
- {
- memcpy(buf, name, MIN(256, namelen));
- buf[MIN(256, namelen)] = '\0';
- printf("Requesting font \"%s\" from font server \"%s\"\n",
- buf, font->fpe->name);
- }
-#endif
_fs_prepare_for_reply (conn);
err = blockrec->errcode;
@@ -2448,17 +2425,6 @@ fs_send_list_fonts(pointer client, FontPathElementPtr fpe, const char *pattern,
blockrec->sequenceNumber = conn->current_seq;
-#ifdef NCD
- if (configData.ExtendedFontDiags) {
- char buf[256];
-
- memcpy(buf, pattern, MIN(256, patlen));
- buf[MIN(256, patlen)] = '\0';
- printf("Listing fonts on pattern \"%s\" from font server \"%s\"\n",
- buf, fpe->name);
- }
-#endif
-
_fs_prepare_for_reply (conn);
return Suspended;
}
@@ -2676,17 +2642,6 @@ fs_start_list_with_info(pointer client, FontPathElementPtr fpe,
blockrec->sequenceNumber = conn->current_seq;
-#ifdef NCD
- if (configData.ExtendedFontDiags) {
- char buf[256];
-
- memcpy(buf, pattern, MIN(256, len));
- buf[MIN(256, len)] = '\0';
- printf("Listing fonts with info on pattern \"%s\" from font server \"%s\"\n",
- buf, fpe->name);
- }
-#endif
-
_fs_prepare_for_reply (conn);
return Successful;
}
diff --git a/lib/libXfont2/src/fc/fsio.c b/lib/libXfont2/src/fc/fsio.c
index a5fe5b03d..3be246328 100644
--- a/lib/libXfont2/src/fc/fsio.c
+++ b/lib/libXfont2/src/fc/fsio.c
@@ -50,11 +50,7 @@
#include <signal.h>
#include <sys/types.h>
#if !defined(WIN32)
-#ifndef Lynx
#include <sys/socket.h>
-#else
-#include <socket.h>
-#endif
#endif
#include <errno.h>
#ifdef WIN32
diff --git a/lib/libXfont2/src/fc/fsio.h b/lib/libXfont2/src/fc/fsio.h
index 9d0255a77..481d3cd68 100644
--- a/lib/libXfont2/src/fc/fsio.h
+++ b/lib/libXfont2/src/fc/fsio.h
@@ -170,11 +170,7 @@ extern XtransConnInfo _fs_connect(char *servername, int *ret);
#define ECHECK(err) (WSAGetLastError() == err)
#define ESET(val) WSASetLastError(val)
#else
-#ifdef ISC
-#define ECHECK(err) ((errno == err) || ETEST())
-#else
#define ECHECK(err) (errno == err)
-#endif
#define ESET(val) errno = val
#endif
diff --git a/lib/libXfont2/src/fc/fslibos.h b/lib/libXfont2/src/fc/fslibos.h
index 1ef362dfc..d42c5dcbe 100644
--- a/lib/libXfont2/src/fc/fslibos.h
+++ b/lib/libXfont2/src/fc/fslibos.h
@@ -65,14 +65,10 @@ from The Open Group.
# else
# include <sys/param.h>
# ifndef OPEN_MAX
-# ifdef __OSF1__
-# define OPEN_MAX 256
+# ifdef NOFILE
+# define OPEN_MAX NOFILE
# else
-# ifdef NOFILE
-# define OPEN_MAX NOFILE
-# else
-# define OPEN_MAX NOFILES_MAX
-# endif
+# define OPEN_MAX NOFILES_MAX
# endif
# endif
# endif
diff --git a/lib/libXfont2/src/fontfile/bufio.c b/lib/libXfont2/src/fontfile/bufio.c
index de06e1ab8..7465f72cb 100644
--- a/lib/libXfont2/src/fontfile/bufio.c
+++ b/lib/libXfont2/src/fontfile/bufio.c
@@ -83,9 +83,9 @@ BufFileRawFill (BufFilePtr f)
static int
BufFileRawSkip (BufFilePtr f, int count)
{
- int curoff;
- int fileoff;
- int todo;
+ off_t curoff;
+ off_t fileoff;
+ off_t todo;
curoff = f->bufp - f->buffer;
fileoff = curoff + f->left;
@@ -94,7 +94,7 @@ BufFileRawSkip (BufFilePtr f, int count)
f->left -= count;
} else {
todo = count - (fileoff - curoff);
- if (lseek (FileDes(f), todo, 1) == -1) {
+ if (lseek (FileDes(f), todo, SEEK_CUR) == -1) {
if (errno != ESPIPE)
return BUFFILEEOF;
while (todo) {
diff --git a/lib/libXfont2/src/fontfile/bunzip2.c b/lib/libXfont2/src/fontfile/bunzip2.c
index 34065f8ce..d17785033 100644
--- a/lib/libXfont2/src/fontfile/bunzip2.c
+++ b/lib/libXfont2/src/fontfile/bunzip2.c
@@ -3,7 +3,7 @@
intended for inclusion in X11 public releases. */
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/lib/libXfont2/src/fontfile/dirfile.c b/lib/libXfont2/src/fontfile/dirfile.c
index 04125b5d1..5155aa5d4 100644
--- a/lib/libXfont2/src/fontfile/dirfile.c
+++ b/lib/libXfont2/src/fontfile/dirfile.c
@@ -47,6 +47,10 @@ in this Software without prior written authorization from The Open Group.
#include <limits.h>
#include "src/util/replace.h"
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
static Bool AddFileNameAliases ( FontDirectoryPtr dir );
static int ReadFontAlias ( char *directory, Bool isFile,
FontDirectoryPtr *pdir );
@@ -96,7 +100,7 @@ FontFileReadDirectory (const char *directory, FontDirectoryPtr *pdir)
strlcat(dir_file, "/", sizeof(dir_file));
strlcat(dir_file, FontDirFile, sizeof(dir_file));
#ifndef WIN32
- file_fd = open(dir_file, O_RDONLY | O_NOFOLLOW);
+ file_fd = open(dir_file, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (file_fd >= 0) {
file = fdopen(file_fd, "rt");
}
@@ -293,7 +297,7 @@ ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
}
#ifndef WIN32
- file_fd = open(alias_file, O_RDONLY | O_NOFOLLOW);
+ file_fd = open(alias_file, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (file_fd >= 0) {
file = fdopen(file_fd, "rt");
}
diff --git a/lib/libXfont2/src/fontfile/fontfile.c b/lib/libXfont2/src/fontfile/fontfile.c
index 4fb75ad2e..e16b58e47 100644
--- a/lib/libXfont2/src/fontfile/fontfile.c
+++ b/lib/libXfont2/src/fontfile/fontfile.c
@@ -73,7 +73,6 @@ static int FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
int
FontFileNameCheck (const char *name)
{
-#ifndef NCD
#if defined(WIN32)
/* WIN32 uses D:/... as a path name for fonts, so accept this as a valid
* path if it starts with a letter and a colon.
@@ -82,9 +81,6 @@ FontFileNameCheck (const char *name)
return TRUE;
#endif
return *name == '/';
-#else
- return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
-#endif
}
int
diff --git a/lib/libXfont2/src/stubs/atom.c b/lib/libXfont2/src/stubs/atom.c
index afc186c41..4163ee70f 100644
--- a/lib/libXfont2/src/stubs/atom.c
+++ b/lib/libXfont2/src/stubs/atom.c
@@ -46,37 +46,35 @@ typedef struct _AtomList {
static AtomListPtr *hashTable;
-static int hashSize, hashUsed;
-static int hashMask;
-static int rehash;
+static unsigned hashSize, hashUsed;
+static unsigned hashMask;
+static unsigned rehash;
static AtomListPtr *reverseMap;
static int reverseMapSize;
static Atom lastAtom;
-static int
-Hash(const char *string, int len)
+static unsigned
+Hash(const char *string, unsigned len)
{
- int h;
+ unsigned h = 0;
- h = 0;
while (len--)
h = (h << 3) ^ *string++;
- if (h < 0)
- return -h;
+
return h;
}
static int
ResizeHashTable(void)
{
- int newHashSize;
- int newHashMask;
+ unsigned newHashSize;
+ unsigned newHashMask;
AtomListPtr *newHashTable;
- int i;
- int h;
- int newRehash;
- int r;
+ unsigned i;
+ unsigned h;
+ unsigned newRehash;
+ unsigned r;
if (hashSize == 0)
newHashSize = 1024;
@@ -148,9 +146,9 @@ Atom
__libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit)
{
AtomListPtr a;
- int hash;
- int h = 0;
- int r;
+ unsigned hash;
+ unsigned h = 0;
+ unsigned r;
hash = Hash(string, len);
if (hashTable) {
@@ -190,8 +188,10 @@ __libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit)
a->hash = hash;
if (hashUsed >= hashSize / 2) {
if ((ResizeHashTable() == FALSE) &&
- ((hashTable == NULL) || (hashUsed == hashSize)))
+ ((hashTable == NULL) || (hashUsed == hashSize))) {
+ free(a);
return None;
+ }
h = hash & hashMask;
if (hashTable[h]) {
r = (hash % rehash) | 1;
diff --git a/lib/libXfont2/src/util/fontxlfd.c b/lib/libXfont2/src/util/fontxlfd.c
index 0a4be1d1d..b232c361e 100644
--- a/lib/libXfont2/src/util/fontxlfd.c
+++ b/lib/libXfont2/src/util/fontxlfd.c
@@ -42,12 +42,7 @@ from The Open Group.
#include <X11/Xos.h>
#include <math.h>
#include <stdlib.h>
-#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV)
-#define NO_LOCALE
-#endif
-#ifndef NO_LOCALE
#include <locale.h>
-#endif
#include <ctype.h>
#include <stdio.h> /* for sprintf() */
#include "src/util/replace.h"
@@ -70,9 +65,7 @@ GetInt(char *ptr, int *val)
#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
-#ifndef NO_LOCALE
static struct lconv *locale = 0;
-#endif
static const char *radix = ".", *plus = "+", *minus = "-";
static char *
@@ -80,7 +73,6 @@ readreal(char *ptr, double *result)
{
char buffer[80], *p1, *p2;
-#ifndef NO_LOCALE
/* Figure out what symbols apply in this locale */
if (!locale)
@@ -93,7 +85,6 @@ readreal(char *ptr, double *result)
if (locale->negative_sign && *locale->negative_sign)
minus = locale->negative_sign;
}
-#endif
/* Copy the first 80 chars of ptr into our local buffer, changing
symbols as needed. */
for (p1 = ptr, p2 = buffer;
@@ -125,7 +116,6 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
int ndigits, exponent;
const size_t buflen = XLFD_DOUBLE_TO_TEXT_BUF_SIZE;
-#ifndef NO_LOCALE
if (!locale)
{
locale = localeconv();
@@ -136,7 +126,6 @@ xlfd_double_to_text(double value, char *buffer, int space_required)
if (locale->negative_sign && *locale->negative_sign)
minus = locale->negative_sign;
}
-#endif
if (space_required)
*buffer++ = ' ';
@@ -194,12 +183,7 @@ xlfd_round_double(double x)
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(__amd64__) || defined(__amd64) || \
- defined(sgi)
+#ifdef HAVE_FLOAT_H
#include <float.h>
/* if we have IEEE 754 fp, we can round to binary digits... */
@@ -260,7 +244,7 @@ xlfd_round_double(double x)
}
else
#endif
-#endif /* i386 || __i386__ */
+#endif /* HAVE_FLOAT_H */
{
/*
* If not IEEE 754: Let printf() do it for you.
diff --git a/lib/libXfont2/src/util/replace.h b/lib/libXfont2/src/util/replace.h
index 53a81a212..39fe4930b 100644
--- a/lib/libXfont2/src/util/replace.h
+++ b/lib/libXfont2/src/util/replace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,9 +32,6 @@
#include <X11/Xfuncproto.h>
#include <stdlib.h>
-#if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY)
-#include <bsd/stdlib.h> /* for reallocarray */
-#endif
#ifndef HAVE_REALLOCARRAY
extern _X_HIDDEN void *
@@ -46,9 +43,6 @@ reallocarray(void *optr, size_t nmemb, size_t size);
#endif
#include <string.h>
-#if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY)
-#include <bsd/string.h> /* for strlcpy, strlcat */
-#endif
#ifndef HAVE_STRLCPY
extern _X_HIDDEN size_t