summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jennings <mej@kainx.org>2000-10-30 23:05:25 +0000
committerMichael Jennings <mej@kainx.org>2000-10-30 23:05:25 +0000
commit8138d895fa950e1a10e921985390f9ece8e46a6e (patch)
tree2c348a5f6eb8e0204c2735f72712a18feb230092
parent536efe1a48cabc3c9ed2bcd671e2eced1177cad5 (diff)
downloadeterm-8138d895fa950e1a10e921985390f9ece8e46a6e.tar.gz
Mon Oct 30 07:45:16 PST 2000 Michael Jennings <mej@eterm.org>
Several small changes, like freeing pixmaps which won't be needed later, reducing the default Imlib2 cache size to 0 bytes (we don't really use it well), and an image path bugfix spotted by Teodor Zlatanov <tzz@iglou.com>. The big change, of course, is the disappearance of libmej and the new dependency on libast, which is now distributed separately. SVN revision: 3793
-rw-r--r--ChangeLog11
-rw-r--r--Makefile.am2
-rw-r--r--README15
-rw-r--r--acconfig.h4
-rw-r--r--configure.in57
-rw-r--r--libmej/.cvsignore7
-rw-r--r--libmej/Makefile.am10
-rw-r--r--libmej/debug.c36
-rw-r--r--libmej/libmej.h400
-rw-r--r--libmej/mem.c446
-rw-r--r--libmej/msgs.c81
-rw-r--r--libmej/snprintf.c521
-rw-r--r--libmej/strings.c549
-rw-r--r--src/Makefile.am6
-rw-r--r--src/buttons.c2
-rw-r--r--src/draw.c12
-rw-r--r--src/encoding.c6
-rw-r--r--src/events.h2
-rw-r--r--src/feature.h2
-rw-r--r--src/menus.c14
-rw-r--r--src/options.c4
-rw-r--r--src/pixmap.c128
-rw-r--r--src/pixmap.h8
-rw-r--r--src/scrollbar.c24
-rw-r--r--src/term.c4
-rw-r--r--src/windows.c2
-rw-r--r--utils/Makefile.am1
27 files changed, 206 insertions, 2148 deletions
diff --git a/ChangeLog b/ChangeLog
index 038c930..dab1702 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3921,3 +3921,14 @@ Tue Oct 17 10:24:43 PDT 2000 Michael Jennings <mej@eterm.org>
Malaquias <romildo@urano.iceb.ufop.br>.
-------------------------------------------------------------------------------
+Mon Oct 30 07:45:16 PST 2000 Michael Jennings <mej@eterm.org>
+
+ Several small changes, like freeing pixmaps which won't be needed
+ later, reducing the default Imlib2 cache size to 0 bytes (we don't
+ really use it well), and an image path bugfix spotted by Teodor
+ Zlatanov <tzz@iglou.com>.
+
+ The big change, of course, is the disappearance of libmej and the new
+ dependency on libast, which is now distributed separately.
+
+-------------------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 7520b2d..b0a10b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,6 @@
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = libmej src themes utils doc bg pix
+SUBDIRS = src themes utils doc bg pix
EXTRA_DIST = README ReleaseNotes ReleaseNotes.1 CVS-README COPYING ChangeLog autogen.sh Eterm.spec
diff --git a/README b/README
index 950fafd..1557888 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-Release notes for Eterm 0.9
----------------------------
+Eterm 0.9 README
+----------------
Software Requirements
---------------------
@@ -15,9 +15,9 @@ Software Requirements
Documentation
-------------
-- The FAQ and message forum at http://eterm.i-docs.org/
-- The man page at http://www.eterm.org/
- Running "Eterm --help" will show you the command line options.
+- "man Eterm"
+- The online FAQ's at and man pages at http://www.eterm.org/docs/
- The Technical Reference, also at the above web site, if you want more
technical details about Eterm.
@@ -76,6 +76,7 @@ the problem. Make sure that you compiled Eterm with the "-O0 -g3" compiler
flags (for gcc, or the equivalent flags for your compiler) if you choose to
submit a stack trace.
-You'll also find people on the EFNet IRC channel #E who might be able to answer
-your questions, but please be sure you've read all the documentation mentioned
-above before asking a question there.
+You'll also find people on the IRC channel #E (now on the OpenProjects
+IRC Network at irc.openprojects.net) who might be able to answer your
+questions, but please be sure you've read all the documentation
+mentioned above before asking a question there.
diff --git a/acconfig.h b/acconfig.h
index d7ce8e0..c18b4c1 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -333,6 +333,10 @@
#undef PKGDATADIR
#undef HAVE_LIBIMLIB2
#undef HAVE_MMX
+#undef HAVE_LIBAST
+#undef LIBAST_X11_SUPPORT
+#undef LIBAST_IMLIB2_SUPPORT
+#undef LIBAST_MMX_SUPPORT
/* Leave that blank line there!! Autoheader needs it.
diff --git a/configure.in b/configure.in
index 211d2c1..1f68f3f 100644
--- a/configure.in
+++ b/configure.in
@@ -106,6 +106,7 @@ AC_LN_S
AC_PATH_PROG(PERL, perl, /usr/bin/perl, $PATH:/usr/bin:/bin:/usr/local/bin:/usr/ccs/bin:/usr/contrib/bin)
AC_PATH_PROG(AWK, awk, /usr/bin/awk, $PATH:/usr/bin:/bin:/usr/local/bin:/usr/ccs/bin:/usr/contrib/bin)
export PERL AWK
+AC_CHECK_PROG(LIBAST_CONFIG, libast-config, libast-config, false)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
@@ -375,6 +376,58 @@ else
AC_MSG_RESULT(no)
fi
+dnl#
+dnl# LibAST
+dnl#
+AC_CHECK_LIB(ast, libast_malloc, FOUND_LIBAST=1, FOUND_LIBAST=0, $GRLIBS)
+test -z "$LIBAST_CONFIG" && FOUND_LIBAST=0
+
+if test "$FOUND_LIBAST" -eq "1"; then
+ if test ! -z "$LIBAST_CONFIG"; then
+ GRLIBS="-last $GRLIBS"
+ AC_DEFINE(HAVE_LIBAST)
+ AC_PREFIX(libast-config)
+ CPPFLAGS="$CPPFLAGS `$LIBAST_CONFIG --cppflags`"
+ LDFLAGS="$LDFLAGS `$LIBAST_CONFIG --ldflags`"
+ SUPPORT_FLAGS="`$LIBAST_CONFIG --support`"
+ for i in $SUPPORT_FLAGS ; do
+ case $i in
+ MMX)
+ AC_DEFINE(LIBAST_MMX_SUPPORT)
+ ;;
+ X11)
+ AC_DEFINE(LIBAST_X11_SUPPORT)
+ ;;
+ Imlib2)
+ AC_DEFINE(LIBAST_IMLIB2_SUPPORT)
+ ;;
+ esac
+ done
+ fi
+else
+ echo "ERROR: You need the LibAST package to build Eterm. If you already have it,";
+ echo " you may have it installed in a strange place, or you may need to run";
+ echo " /sbin/ldconfig. If you don't have it, I can download it for you.";
+ echo " Shall I retrieve and build LibAST now (y/n)?";
+ read ANS
+ if test "x$ANS" = "xy" -o "x$ANS" = "xyes" -o "x$ANS" = "xY" -o "x$ANS" = "xYES"; then
+ if test -d CVS ; then
+ # Download from CVS server
+ cvs -z3 -d :pserver:anonymous@cvs.enlightenment.sourceforge.net:/cvsroot/enlightenment co -d libast eterm/libast
+ (cd libast && ./autogen.sh "$@" && make install && cd .. && rm -rf libast)
+ if test $? -ne 0; then
+ echo 'ERROR: Unable to auto-get libast, sorry.' 1>&2
+ exit 1
+ fi
+ else
+ # Download tarball
+ :
+ fi
+ else
+ AC_MSG_ERROR(Fatal: libast not found.)
+ fi
+fi
+
AC_MSG_CHECKING(for utmp support)
AC_ARG_ENABLE(utmp,
[ --enable-utmp compile with utmp support],
@@ -717,10 +770,10 @@ fi
AC_SUBST(GDB_CMD_FILE)
CPPFLAGS=`eval eval eval eval eval echo "-I$includedir -I$prefix/include $CPPFLAGS"`
-CPPFLAGS=`echo $CPPFLAGS | tr ' ' '\n' | uniq | tr '\n' ' '`
+CPPFLAGS=`echo $CPPFLAGS | tr ' ' '\n' | uniq | grep -v NONE | tr '\n' ' '`
CFLAGS=${CFLAGS--O}
LDFLAGS=`eval eval eval eval eval echo "-L$libdir -L$prefix/lib ${LDFLAGS--O}"`
-LDFLAGS=`echo $LDFLAGS | tr ' ' '\n' | uniq | tr '\n' ' '`
+LDFLAGS=`echo $LDFLAGS | tr ' ' '\n' | uniq | grep -v NONE | tr '\n' ' '`
LIBS="$GRLIBS $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
AC_SUBST(CC)
diff --git a/libmej/.cvsignore b/libmej/.cvsignore
deleted file mode 100644
index 923c18f..0000000
--- a/libmej/.cvsignore
+++ /dev/null
@@ -1,7 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-libmej.la
-*.da
-*.lo
diff --git a/libmej/Makefile.am b/libmej/Makefile.am
deleted file mode 100644
index 8963f73..0000000
--- a/libmej/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-# $Id$
-
-lib_LTLIBRARIES = libmej.la
-include_HEADERS = libmej.h
-
-libmej_la_SOURCES = debug.c mem.c msgs.c strings.c snprintf.c libmej.h
-
-LIBS = -lm
-
-libmej_la_LDFLAGS = -release $(VERSION)
diff --git a/libmej/debug.c b/libmej/debug.c
deleted file mode 100644
index e1d9067..0000000
--- a/libmej/debug.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 1997-2000, Michael Jennings
- *
- * 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 of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- *
- * 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 AUTHORS 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.
- */
-
-static const char cvs_ident[] = "$Id$";
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "libmej.h"
-
-/* FIXME: Change this to an unsigned short once the
- options parser can handle function pointers. */
-unsigned int libmej_debug_level = 0;
-unsigned long libmej_debug_flags = 0;
-
diff --git a/libmej/libmej.h b/libmej/libmej.h
deleted file mode 100644
index fa61f79..0000000
--- a/libmej/libmej.h
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright (C) 1997-2000, Michael Jennings
- *
- * 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 of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- *
- * 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 AUTHORS 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.
- */
-
-#ifndef _LIBMEJ_H_
-#define _LIBMEJ_H_
-
-/* This GNU goop has to go before the system headers */
-#ifdef __GNUC__
-# ifndef __USE_GNU
-# define __USE_GNU
-# endif
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-# endif
-# ifndef _BSD_SOURCE
-# define _BSD_SOURCE
-# endif
-# ifndef inline
-# define inline __inline__
-# endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include <signal.h>
-#ifdef HAVE_REGEX_H
-# include <regex.h>
-#endif
-#ifdef HAVE_STDARG_H
-# include <stdarg.h>
-#endif
-#ifdef WITH_DMALLOC
-# include <dmalloc.h>
-#elif defined(HAVE_MALLOC_H)
-# include <malloc.h>
-#endif
-
-#include <X11/Xatom.h>
-#include <X11/X.h>
-#include <X11/Intrinsic.h>
-#ifdef HAVE_LIBIMLIB2
-# include <Imlib2.h>
-#endif
-
-/******************************* GENERIC GOOP *********************************/
-#ifndef TRUE
-# define TRUE ((unsigned char)(1))
-# define FALSE ((unsigned char)(0))
-#endif
-
-#ifndef PACKAGE
-# define PACKAGE "libmej"
-#endif
-
-
-
-/****************************** DEBUGGING GOOP ********************************/
-#ifndef LIBMEJ_DEBUG_FD
-# define LIBMEJ_DEBUG_FD (stderr)
-#endif
-#ifndef DEBUG
-# define DEBUG 0
-#endif
-
-#define DEBUG_LEVEL (libmej_debug_level)
-#define DEBUG_FLAGS (libmej_debug_flags)
-
-/* A NOP. Does nothing. */
-#define NOP ((void)0)
-
-/* A macro and an #define to FIXME-ize individual calls or entire code blocks. */
-#define FIXME_NOP(x)
-#define FIXME_BLOCK 0
-
-/* An "unused block" marker similar to the above. */
-#define UNUSED_BLOCK 0
-
-/* The basic debugging output leader. */
-#if defined(__FILE__) && defined(__LINE__)
-# ifdef __GNUC__
-# define __DEBUG() fprintf(LIBMEJ_DEBUG_FD, "[%lu] %12s | %4d: %s(): ", (unsigned long) time(NULL), __FILE__, __LINE__, __FUNCTION__)
-# else
-# define __DEBUG() fprintf(LIBMEJ_DEBUG_FD, "[%lu] %12s | %4d: ", (unsigned long) time(NULL), __FILE__, __LINE__)
-# endif
-#else
-# define __DEBUG() NOP
-#endif
-
-/* A quick and dirty macro to say, "Hi! I got here without crashing!" */
-#define MOO() do {__DEBUG(); libmej_dprintf("Moo.\n");} while (0)
-
-/* Assertion/abort macros which are quite a bit more useful than assert() and abort(). */
-#if DEBUG >= 1
-# if defined(__FILE__) && defined(__LINE__)
-# ifdef __GNUC__
-# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
- else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);}}} while (0)
-# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
- else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
- return (val);}} while (0)
-# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
- else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
- } while (0)
-# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
- else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
- return (val);} while (0)
-# define ABORT() fatal_error("Aborting in %s() at %s:%d.", __FUNCTION__, __FILE__, __LINE__)
-# else
-# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
- else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);}}} while (0)
-# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
- else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
- return (val);}} while (0)
-# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
- else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
- } while (0)
-# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
- else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
- return (val);} while (0)
-# define ABORT() fatal_error("Aborting at %s:%d.", __FILE__, __LINE__)
-# endif
-# else
-# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
- else {print_warning("ASSERT failed: %s", #x);}}} while (0)
-# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
- else {print_warning("ASSERT failed: %s", #x);} return (val);}} while (0)
-# define ASSERT_NOTREACHED() return
-# define ASSERT_NOTREACHED_RVAL(x) return (x)
-# define ABORT() fatal_error("Aborting.\n")
-# endif
-# define REQUIRE(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return;}} while (0)
-# define REQUIRE_RVAL(x, v) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return (v);}} while (0)
-#else
-# define ASSERT(x) NOP
-# define ASSERT_RVAL(x, val) NOP
-# define ASSERT_NOTREACHED() return
-# define ASSERT_NOTREACHED_RVAL(val) return (val)
-# define ABORT() fatal_error("Aborting.\n")
-# define REQUIRE(x) do {if (!(x)) return;} while (0)
-# define REQUIRE_RVAL(x, v) do {if (!(x)) return (v);} while (0)
-#endif
-
-#define NONULL(x) ((x) ? (x) : ("<null>"))
-
-/* Macros for printing debugging messages */
-#if DEBUG >= 1
-# ifndef DPRINTF
-# define DPRINTF(x) do { __DEBUG(); libmej_dprintf x; } while (0)
-# endif
-# define DPRINTF1(x) do { if (DEBUG_LEVEL >= 1) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF2(x) do { if (DEBUG_LEVEL >= 2) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF3(x) do { if (DEBUG_LEVEL >= 3) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF4(x) do { if (DEBUG_LEVEL >= 4) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF5(x) do { if (DEBUG_LEVEL >= 5) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF6(x) do { if (DEBUG_LEVEL >= 6) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF7(x) do { if (DEBUG_LEVEL >= 7) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF8(x) do { if (DEBUG_LEVEL >= 8) {__DEBUG(); libmej_dprintf x;} } while (0)
-# define DPRINTF9(x) do { if (DEBUG_LEVEL >= 9) {__DEBUG(); libmej_dprintf x;} } while (0)
-#else
-# ifndef DPRINTF
-# define DPRINTF(x) NOP
-# endif
-# define DPRINTF1(x) NOP
-# define DPRINTF2(x) NOP
-# define DPRINTF3(x) NOP
-# define DPRINTF4(x) NOP
-# define DPRINTF5(x) NOP
-# define DPRINTF6(x) NOP
-# define DPRINTF7(x) NOP
-# define DPRINTF8(x) NOP
-# define DPRINTF9(x) NOP
-#endif
-
-/* Use this for stuff that you only want turned on in dire situations */
-#define D_NEVER(x) NOP
-
-#define DEBUG_MEM 5
-#define D_MEM(x) DPRINTF5(x)
-#define DEBUG_STRINGS 9999
-#define D_STRINGS(x) D_NEVER(x)
-
-
-
-/********************************* MEM GOOP ***********************************/
-#define LIBMEJ_FNAME_LEN 20
-
-typedef struct ptr_struct {
- void *ptr;
- size_t size;
- char file[LIBMEJ_FNAME_LEN + 1];
- unsigned long line;
-} ptr_t;
-typedef struct memrec_struct {
- unsigned long cnt;
- ptr_t *ptrs;
-} memrec_t;
-
-#if (DEBUG >= DEBUG_MEM)
-# define MALLOC(sz) libmej_malloc(__FILE__, __LINE__, (sz))
-# define CALLOC(type,n) libmej_calloc(__FILE__, __LINE__, (n), (sizeof(type)))
-# define REALLOC(mem,sz) libmej_realloc(#mem, __FILE__, __LINE__, (mem), (sz))
-# define FREE(ptr) do { libmej_free(#ptr, __FILE__, __LINE__, (ptr)); (ptr) = NULL; } while (0)
-# define STRDUP(s) libmej_strdup(#s, __FILE__, __LINE__, (s))
-# define MALLOC_DUMP() libmej_dump_mem_tables()
-# define X_CREATE_PIXMAP(d, win, w, h, depth) libmej_x_create_pixmap(__FILE__, __LINE__, (d), (win), (w), (h), (depth))
-# define X_FREE_PIXMAP(d, p) libmej_x_free_pixmap(#p, __FILE__, __LINE__, (d), (p))
-# ifdef HAVE_LIBIMLIB2
-# define IMLIB_REGISTER_PIXMAP(p) libmej_imlib_register_pixmap(#p, __FILE__, __LINE__, (p))
-# define IMLIB_FREE_PIXMAP(p) libmej_imlib_free_pixmap(#p, __FILE__, __LINE__, (p))
-# else
-# define IMLIB_REGISTER_PIXMAP(p) NOP
-# define IMLIB_FREE_PIXMAP(p) NOP
-# endif
-# define PIXMAP_DUMP() libmej_dump_pixmap_tables()
-# define X_CREATE_GC(d, win, f, gcv) libmej_x_create_gc(__FILE__, __LINE__, (d), (win), (f), (gcv))
-# define X_FREE_GC(d, gc) libmej_x_free_gc(#gc, __FILE__, __LINE__, (d), (gc))
-# define GC_DUMP() libmej_dump_gc_tables()
-# define MALLOC_MOD 25
-# define REALLOC_MOD 25
-# define CALLOC_MOD 25
-# define FREE_MOD 25
-#else
-# define MALLOC(sz) malloc(sz)
-# define CALLOC(type,n) calloc((n),(sizeof(type)))
-# define REALLOC(mem,sz) ((sz) ? ((mem) ? (realloc((mem), (sz))) : (malloc(sz))) : ((mem) ? (free(mem), NULL) : (NULL)))
-# define FREE(ptr) do { free(ptr); (ptr) = NULL; } while (0)
-# define STRDUP(s) strdup(s)
-# define MALLOC_DUMP() NOP
-# define X_CREATE_PIXMAP(d, win, w, h, depth) XCreatePixmap((d), (win), (w), (h), (depth))
-# define X_FREE_PIXMAP(d, p) XFreePixmap((d), (p))
-# ifdef HAVE_LIBIMLIB2
-# define IMLIB_REGISTER_PIXMAP(p) NOP
-# define IMLIB_FREE_PIXMAP(p) imlib_free_pixmap_and_mask(p)
-# else
-# define IMLIB_REGISTER_PIXMAP(p) NOP
-# define IMLIB_FREE_PIXMAP(p) NOP
-# endif
-# define PIXMAP_DUMP() NOP
-# define X_CREATE_GC(d, win, f, gcv) XCreateGC((d), (win), (f), (gcv))
-# define X_FREE_GC(d, gc) XFreeGC((d), (gc))
-# define GC_DUMP() NOP
-#endif
-
-/* Fast memset() macro contributed by vendu */
-#if (SIZEOF_LONG == 8)
-# define MEMSET_LONG() l |= l<<32
-#else
-# define MEMSET_LONG() ((void)0)
-#endif
-
-#define MEMSET(s, c, count) do { \
- char *end = (char *)(s) + (count); \
- long l; \
- long *l_dest = (long *)(s); \
- char *c_dest; \
- \
- /* areas of less than 4 * sizeof(long) are set in 1-byte chunks. */ \
- if (((unsigned long) count) >= 4 * sizeof(long)) { \
- /* fill l with c. */ \
- l = (c) | (c)<<8; \
- l |= l<<16; \
- MEMSET_LONG(); \
- \
- /* fill in 1-byte chunks until boundary of long is reached. */ \
- if ((unsigned long)l_dest & (unsigned long)(sizeof(long) -1)) { \
- c_dest = (char *)l_dest; \
- while ((unsigned long)c_dest & (unsigned long)(sizeof(long) -1)) { \
- *(c_dest++) = (c); \
- } \
- l_dest = (long *)c_dest; \
- } \
- \
- /* fill in long-size chunks as long as possible. */ \
- while (((unsigned long) (end - (char *)l_dest)) >= sizeof(long)) { \
- *(l_dest++) = l; \
- } \
- } \
- \
- /* fill the tail in 1-byte chunks. */ \
- if ((char *)l_dest < end) { \
- c_dest = (char *)l_dest; \
- *(c_dest++) = (c); \
- while (c_dest < end) { \
- *(c_dest++) = (c); \
- } \
- } \
- } while (0)
-
-
-
-/******************************* STRINGS GOOP *********************************/
-
-#ifdef __GNUC__
-# define SWAP(a, b) __extension__ ({__typeof__(a) tmp = (a); (a) = (b); (b) = tmp;})
-#else
-# define SWAP(a, b) do {void *tmp = ((void *)(a)); (a) = (b); (b) = tmp;} while (0)
-#endif
-
-#define CONST_STRLEN(x) (sizeof(x) - 1)
-#define BEG_STRCASECMP(s, constr) (strncasecmp(s, constr, CONST_STRLEN(constr)))
-
-
-
-/******************************** PROTOTYPES **********************************/
-
-/* msgs.c */
-extern int libmej_dprintf(const char *, ...);
-extern void print_error(const char *fmt, ...);
-extern void print_warning(const char *fmt, ...);
-extern void fatal_error(const char *fmt, ...);
-
-/* debug.c */
-extern unsigned int DEBUG_LEVEL;
-
-/* mem.c */
-extern void memrec_init(void);
-extern void *libmej_malloc(const char *, unsigned long, size_t);
-extern void *libmej_realloc(const char *, const char *, unsigned long, void *, size_t);
-extern void *libmej_calloc(const char *, unsigned long, size_t, size_t);
-extern void libmej_free(const char *, const char *, unsigned long, void *);
-extern char *libmej_strdup(const char *, const char *, unsigned long, const char *);
-extern void libmej_dump_mem_tables(void);
-extern Pixmap libmej_x_create_pixmap(const char *, unsigned long, Display *, Drawable, unsigned int, unsigned int, unsigned int);
-extern void libmej_x_free_pixmap(const char *, const char *, unsigned long, Display *, Pixmap);
-extern void libmej_dump_pixmap_tables(void);
-extern GC libmej_x_create_gc(const char *, unsigned long, Display *, Drawable, unsigned long, XGCValues *);
-extern void libmej_x_free_gc(const char *, const char *, unsigned long, Display *, GC);
-extern void libmej_dump_gc_tables(void);
-
-/* strings.c */
-extern char *left_str(const char *, unsigned long);
-extern char *mid_str(const char *, unsigned long, unsigned long);
-extern char *right_str(const char *, unsigned long);
-#ifdef HAVE_REGEX_H
-extern unsigned char regexp_match(const char *, const char *);
-#endif
-extern char *get_word(unsigned long, const char *);
-extern char *get_pword(unsigned long, const char *);
-extern unsigned long num_words(const char *);
-extern char *strip_whitespace(char *);
-extern char *downcase_str(char *);
-extern char *upcase_str(char *);
-#ifndef HAVE_STRCASESTR
-extern char *strcasestr(char *, const char *);
-#endif
-#ifndef HAVE_STRCASECHR
-extern char *strcasechr(char *, char);
-#endif
-#ifndef HAVE_STRCASEPBRK
-extern char *strcasepbrk(char *, char *);
-#endif
-#ifndef HAVE_STRREV
-extern char *strrev(char *);
-#endif
-#if !(HAVE_STRSEP)
-extern char *strsep(char **, char *);
-#endif
-extern char *safe_str(char *, unsigned short);
-extern char *garbage_collect(char *, size_t);
-extern char *file_garbage_collect(char *, size_t);
-extern char *condense_whitespace(char *);
-extern void hex_dump(void *, size_t);
-#ifndef HAVE_MEMMEM
-extern void *memmem(void *, size_t, void *, size_t);
-#endif
-#ifndef HAVE_USLEEP
-extern void usleep(unsigned long);
-#endif
-#ifndef HAVE_SNPRINTF
-extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
-extern int snprintf(char *str, size_t count, const char *fmt, ...);
-#endif
-
-#endif /* _LIBMEJ_H_ */
diff --git a/libmej/mem.c b/libmej/mem.c
deleted file mode 100644
index a2dc1a2..0000000
--- a/libmej/mem.c
+++ /dev/null
@@ -1,446 +0,0 @@
-
-/*
- * Copyright (C) 1997-2000, Michael Jennings
- *
- * 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 of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- *
- * 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 AUTHORS 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.
- */
-
-static const char cvs_ident[] = "$Id$";
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "libmej.h"
-
-static void memrec_add_var(memrec_t *, const char *, unsigned long, void *, size_t);
-static ptr_t *memrec_find_var(memrec_t *, const void *);
-static void memrec_rem_var(memrec_t *, const char *, const char *, unsigned long, const void *);
-static void memrec_chg_var(memrec_t *, const char *, const char *, unsigned long, const void *, void *, size_t);
-static void memrec_dump_pointers(memrec_t *);
-static void memrec_dump_resources(memrec_t *);
-
-/*
- * These're added for a pretty obvious reason -- they're implemented towards
- * The beginning of each one's respective function. (The ones with capitalized
- * letters. I'm not sure that they'll be useful outside of gdb. Maybe.
- */
-#ifdef MALLOC_CALL_DEBUG
-static int malloc_count = 0;
-static int calloc_count = 0;
-static int realloc_count = 0;
-static int free_count = 0;
-#endif
-
-static memrec_t malloc_rec, pixmap_rec, gc_rec;
-
-void
-memrec_init(void)
-{
- D_MEM(("Constructing memory allocation records\n"));
- malloc_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
- pixmap_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
- gc_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
-}
-
-static void
-memrec_add_var(memrec_t *memrec, const char *filename, unsigned long line, void *ptr, size_t size)
-{
- register ptr_t *p;
-
- ASSERT(memrec != NULL);
- memrec->cnt++;
- if ((memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt)) == NULL) {
- D_MEM(("Unable to reallocate pointer list -- %s\n", strerror(errno)));
- }
- p = memrec->ptrs + memrec->cnt - 1;
- D_MEM(("Adding variable (%8p, %lu bytes) from %s:%lu.\n", ptr, size, filename, line));
- D_MEM(("Storing as pointer #%lu at %8p (from %8p).\n", memrec->cnt, p, memrec->ptrs));
- p->ptr = ptr;
- p->size = size;
- strncpy(p->file, filename, LIBMEJ_FNAME_LEN);
- p->file[LIBMEJ_FNAME_LEN] = 0;
- p->line = line;
-}
-
-static ptr_t *
-memrec_find_var(memrec_t *memrec, const void *ptr)
-{
- register ptr_t *p;
- register unsigned long i;
-
- ASSERT(memrec != NULL);
- REQUIRE_RVAL(ptr != NULL, NULL);
-
- for (i = 0, p = memrec->ptrs; i < memrec->cnt; i++, p++) {
- if (p->ptr == ptr) {
- D_MEM(("Found pointer #%lu stored at %8p (from %8p)\n", i + 1, p, memrec->ptrs));
- return p;
- }
- }
- return NULL;
-}
-
-static void
-memrec_rem_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, const void *ptr)
-{
- register ptr_t *p;
-
- ASSERT(memrec != NULL);
-
- if ((p = memrec_find_var(memrec, ptr)) == NULL) {
- D_MEM(("ERROR: File %s, line %d attempted to free variable %s (%8p) which was not allocated with MALLOC/REALLOC\n", filename, line, var, ptr));
- return;
- }
- memrec->cnt--;
- D_MEM(("Removing variable %s (%8p) of size %lu\n", var, ptr, p->size));
- memmove(p, p + 1, sizeof(ptr_t) * (memrec->cnt - (p - memrec->ptrs)));
- memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt);
-}
-
-static void
-memrec_chg_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, const void *oldp, void *newp, size_t size)
-{
- register ptr_t *p;
-
- ASSERT(memrec != NULL);
-
- if ((p = memrec_find_var(memrec, oldp)) == NULL) {
- D_MEM(("ERROR: File %s, line %d attempted to realloc variable %s (%8p) which was not allocated with MALLOC/REALLOC\n", filename, line, var, oldp));
- return;
- }
- D_MEM(("Changing variable %s (%8p, %lu -> %8p, %lu)\n", var, oldp, p->size, newp, size));
- p->ptr = newp;
- p->size = size;
- strncpy(p->file, filename, LIBMEJ_FNAME_LEN);
- p->line = line;
-}
-
-static void
-memrec_dump_pointers(memrec_t *memrec)
-{
- register ptr_t *p;
- unsigned long i, j, k, l, total = 0;
- unsigned long len;
- unsigned char buff[9];
-
- ASSERT(memrec != NULL);
- fprintf(LIBMEJ_DEBUG_FD, "PTR: %lu pointers stored.\n", memrec->cnt);
- fprintf(LIBMEJ_DEBUG_FD, "PTR: Pointer | Filename | Line | Address | Size | Offset | 00 01 02 03 04 05 06 07 | ASCII \n");
- fprintf(LIBMEJ_DEBUG_FD, "PTR: ---------+----------------------+--------+----------+--------+---------+-------------------------+---------\n");
- fflush(LIBMEJ_DEBUG_FD);
- len = sizeof(ptr_t) * memrec->cnt;
- memset(buff, 0, sizeof(buff));
-
- /* First, dump the contents of the memrec->ptrs[] array. */
- for (p = memrec->ptrs, j = 0; j < len; j += 8) {
- fprintf(LIBMEJ_DEBUG_FD, "PTR: %07lu | %20s | %6lu | %8p | %06lu | %07x | ", (unsigned long) 0, "", (unsigned long) 0, memrec->ptrs,
- (unsigned long) (sizeof(ptr_t) * memrec->cnt), (unsigned int) j);
- /* l is the number of characters we're going to output */
- l = ((len - j < 8) ? (len - j) : (8));
- /* Copy l bytes (up to 8) from memrec->ptrs[] (p) to buffer */
- memcpy(buff, ((char *) p) + j, l);
- buff[l] = 0;
- for (k = 0; k < l; k++) {
- fprintf(LIBMEJ_DEBUG_FD, "%02x ", buff[k]);
- }
- /* If we printed less than 8 bytes worth, pad with 3 spaces per byte */
- for (; k < 8; k++) {
- fprintf(LIBMEJ_DEBUG_FD, " ");
- }
- /* Finally, print the printable ASCII string for those l bytes */
- fprintf(LIBMEJ_DEBUG_FD, "| %-8s\n", safe_str((char *) buff, l));
- /* Flush after every line in case we crash */
- fflush(LIBMEJ_DEBUG_FD);
- }
-
- /* Now print out each pointer and its contents. */
- for (i = 0; i < memrec->cnt; p++, i++) {
- /* Add this pointer's size to our total */
- total += p->size;
- for (j = 0; j < p->size; j += 8) {
- fprintf(LIBMEJ_DEBUG_FD, "PTR: %07lu | %20s | %6lu | %8p | %06lu | %07x | ", i + 1, NONULL(p->file), p->line, p->ptr, (unsigned long) p->size, (unsigned int) j);
- /* l is the number of characters we're going to output */
- l = ((p->size - j < 8) ? (p->size - j) : (8));
- /* Copy l bytes (up to 8) from p->ptr to buffer */
- memcpy(buff, ((char *) p->ptr) + j, l);
- buff[l] = 0;
- for (k = 0; k < l; k++) {
- fprintf(LIBMEJ_DEBUG_FD, "%02x ", buff[k]);
- }
- /* If we printed less than 8 bytes worth, pad with 3 spaces per byte */
- for (; k < 8; k++) {
- fprintf(LIBMEJ_DEBUG_FD, " ");
- }
- /* Finally, print the printable ASCII string for those l bytes */
- fprintf(LIBMEJ_DEBUG_FD, "| %-8s\n", safe_str((char *) buff, l));
- /* Flush after every line in case we crash */
- fflush(LIBMEJ_DEBUG_FD);
- }
- }
- fprintf(LIBMEJ_DEBUG_FD, "PTR: Total allocated memory: %10lu bytes\n", total);
- fflush(LIBMEJ_DEBUG_FD);
-}
-
-static void
-memrec_dump_resources(memrec_t *memrec)
-{
- register ptr_t *p;
- unsigned long i, total;
- unsigned long len;
-
- ASSERT(memrec != NULL);
- len = memrec->cnt;
- fprintf(LIBMEJ_DEBUG_FD, "RES: %lu resources stored.\n", memrec->cnt);
- fprintf(LIBMEJ_DEBUG_FD, "RES: Index | Resource ID | Filename | Line | Size \n");
- fprintf(LIBMEJ_DEBUG_FD, "RES: -------+-------------+----------------------+--------+--------\n");
- fflush(LIBMEJ_DEBUG_FD);
-
- for (p = memrec->ptrs, i = 0, total = 0; i < len; i++, p++) {
- total += p->size;
- fprintf(LIBMEJ_DEBUG_FD, "RES: %5lu | 0x%08x | %20s | %6lu | %6lu\n", i, (unsigned) p->ptr, NONULL(p->file), p->line, (unsigned long) p->size);
- /* Flush after every line in case we crash */
- fflush(LIBMEJ_DEBUG_FD);
- }
- fprintf(LIBMEJ_DEBUG_FD, "RES: Total size: %lu bytes\n", total);
- fflush(LIBMEJ_DEBUG_FD);
-}
-
-/******************** MEMORY ALLOCATION INTERFACE ********************/
-void *
-libmej_malloc(const char *filename, unsigned long line, size_t size)
-{
- void *temp;
-
-#ifdef MALLOC_CALL_DEBUG
- ++malloc_count;
- if (!(malloc_count % MALLOC_MOD)) {
- fprintf(LIBMEJ_DEBUG_FD, "Calls to malloc(): %d\n", malloc_count);
- }
-#endif
-
- D_MEM(("%lu bytes requested at %s:%lu\n", size, filename, line));
-
- temp = (void *) malloc(size);
- ASSERT_RVAL(temp != NULL, NULL);
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_add_var(&malloc_rec, filename, line, temp, size);
- }
- return (temp);
-}
-
-void *
-libmej_realloc(const char *var, const char *filename, unsigned long line, void *ptr, size_t size)
-{
- void *temp;
-
-#ifdef MALLOC_CALL_DEBUG
- ++realloc_count;
- if (!(realloc_count % REALLOC_MOD)) {
- D_MEM(("Calls to realloc(): %d\n", realloc_count));
- }
-#endif
-
- D_MEM(("Variable %s (%8p -> %lu) at %s:%lu\n", var, ptr, (unsigned long) size, filename, line));
- if (ptr == NULL) {
- temp = (void *) libmej_malloc(__FILE__, __LINE__, size);
- } else {
- temp = (void *) realloc(ptr, size);
- ASSERT_RVAL(temp != NULL, ptr);
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_chg_var(&malloc_rec, var, filename, line, ptr, temp, size);
- }
- }
- return (temp);
-}
-
-void *
-libmej_calloc(const char *filename, unsigned long line, size_t count, size_t size)
-{
- void *temp;
-
-#ifdef MALLOC_CALL_DEBUG
- ++calloc_count;
- if (!(calloc_count % CALLOC_MOD)) {
- fprintf(LIBMEJ_DEBUG_FD, "Calls to calloc(): %d\n", calloc_count);
- }
-#endif
-
- D_MEM(("%lu units of %lu bytes each requested at %s:%lu\n", count, size, filename, line));
- temp = (void *) calloc(count, size);
- ASSERT_RVAL(temp != NULL, NULL);
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_add_var(&malloc_rec, filename, line, temp, size * count);
- }
- return (temp);
-}
-
-void
-libmej_free(const char *var, const char *filename, unsigned long line, void *ptr)
-{
-#ifdef MALLOC_CALL_DEBUG
- ++free_count;
- if (!(free_count % FREE_MOD)) {
- fprintf(LIBMEJ_DEBUG_FD, "Calls to free(): %d\n", free_count);
- }
-#endif
-
- D_MEM(("Variable %s (%8p) at %s:%lu\n", var, ptr, filename, line));
- if (ptr) {
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_rem_var(&malloc_rec, var, filename, line, ptr);
- }
- free(ptr);
- } else {
- D_MEM(("ERROR: Caught attempt to free NULL pointer\n"));
- }
-}
-
-char *
-libmej_strdup(const char *var, const char *filename, unsigned long line, const char *str)
-{
- register char *newstr;
- register size_t len;
-
- D_MEM(("Variable %s (%8p) at %s:%lu\n", var, str, filename, line));
-
- len = strlen(str) + 1; /* Copy NUL byte also */
- newstr = (char *) libmej_malloc(filename, line, len);
- strcpy(newstr, str);
- return (newstr);
-}
-
-void
-libmej_dump_mem_tables(void)
-{
- fprintf(LIBMEJ_DEBUG_FD, "Dumping memory allocation table:\n");
- memrec_dump_pointers(&malloc_rec);
-}
-
-
-
-/******************** PIXMAP ALLOCATION INTERFACE ********************/
-
-Pixmap
-libmej_x_create_pixmap(const char *filename, unsigned long line, Display *d, Drawable win, unsigned int w, unsigned int h, unsigned int depth)
-{
- Pixmap p;
-
- D_MEM(("Creating %ux%u pixmap of depth %u for window 0x%08x at %s:%lu\n", w, h, depth, win, filename, line));
-
- p = XCreatePixmap(d, win, w, h, depth);
- ASSERT_RVAL(p != None, None);
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_add_var(&pixmap_rec, filename, line, (void *) p, w * h * (depth / 8));
- }
- return (p);
-}
-
-void
-libmej_x_free_pixmap(const char *var, const char *filename, unsigned long line, Display *d, Pixmap p)
-{
- D_MEM(("Freeing pixmap %s (0x%08x) at %s:%lu\n", var, p, filename, line));
- if (p) {
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_rem_var(&pixmap_rec, var, filename, line, (void *) p);
- }
- XFreePixmap(d, p);
- } else {
- D_MEM(("ERROR: Caught attempt to free NULL pixmap\n"));
- }
-}
-
-void
-libmej_imlib_register_pixmap(const char *var, const char *filename, unsigned long line, Pixmap p)
-{
- D_MEM(("Registering pixmap %s (0x%08x) created by Imlib2 at %s:%lu\n", var, p, filename, line));
- if (p) {
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- if (!memrec_find_var(&pixmap_rec, (void *) p)) {
- memrec_add_var(&pixmap_rec, filename, line, (void *) p, 1);
- } else {
- D_MEM(("Pixmap 0x%08x already registered.\n"));
- }
- }
- } else {
- D_MEM(("ERROR: Refusing to register a NULL pixmap\n"));
- }
-}
-
-void
-libmej_imlib_free_pixmap(const char *var, const char *filename, unsigned long line, Pixmap p)
-{
- D_MEM(("Freeing pixmap %s (0x%08x) at %s:%lu using Imlib2\n", var, p, filename, line));
- if (p) {
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_rem_var(&pixmap_rec, var, filename, line, (void *) p);
- }
- imlib_free_pixmap_and_mask(p);
- } else {
- D_MEM(("ERROR: Caught attempt to free NULL pixmap\n"));
- }
-}
-
-void
-libmej_dump_pixmap_tables(void)
-{
- fprintf(LIBMEJ_DEBUG_FD, "Dumping X11 Pixmap allocation table:\n");
- memrec_dump_resources(&pixmap_rec);
-}
-
-
-
-/********************** GC ALLOCATION INTERFACE **********************/
-
-GC
-libmej_x_create_gc(const char *filename, unsigned long line, Display *d, Drawable win, unsigned long mask, XGCValues *gcv)
-{
- GC gc;
-
- D_MEM(("Creating gc for window 0x%08x at %s:%lu\n", win, filename, line));
-
- gc = XCreateGC(d, win, mask, gcv);
- ASSERT_RVAL(gc != None, None);
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_add_var(&gc_rec, filename, line, (void *) gc, sizeof(XGCValues));
- }
- return (gc);
-}
-
-void
-libmej_x_free_gc(const char *var, const char *filename, unsigned long line, Display *d, GC gc)
-{
- D_MEM(("libmej_x_free_gc() called for variable %s (0x%08x) at %s:%lu\n", var, gc, filename, line));
- if (gc) {
- if (DEBUG_LEVEL >= DEBUG_MEM) {
- memrec_rem_var(&gc_rec, var, filename, line, (void *) gc);
- }
- XFreeGC(d, gc);
- } else {
- D_MEM(("ERROR: Caught attempt to free NULL GC\n"));
- }
-}
-
-void
-libmej_dump_gc_tables(void)
-{
- fprintf(LIBMEJ_DEBUG_FD, "Dumping X11 GC allocation table:\n");
- memrec_dump_resources(&gc_rec);
-}
diff --git a/libmej/msgs.c b/libmej/msgs.c
deleted file mode 100644
index 1e982dd..0000000
--- a/libmej/msgs.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 1997-2000, Michael Jennings
- *
- * 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 of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- *
- * 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 AUTHORS 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.
- */
-
-static const char cvs_ident[] = "$Id$";
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "libmej.h"
-
-int
-libmej_dprintf(const char *format, ...)
-{
- va_list args;
- int n;
-
- va_start(args, format);
- n = vfprintf(LIBMEJ_DEBUG_FD, format, args);
- va_end(args);
- fflush(LIBMEJ_DEBUG_FD);
- return (n);
-}
-
-/* Print a non-terminal error message */
-void
-print_error(const char *fmt, ...)
-{
- va_list arg_ptr;
-
- va_start(arg_ptr, fmt);
- fprintf(stderr, PACKAGE ": Error: ");
- vfprintf(stderr, fmt, arg_ptr);
- va_end(arg_ptr);
-}
-
-/* Print a simple warning */
-void
-print_warning(const char *fmt, ...)
-{
- va_list arg_ptr;
-
- va_start(arg_ptr, fmt);
- fprintf(stderr, PACKAGE ": Warning: ");
- vfprintf(stderr, fmt, arg_ptr);
- va_end(arg_ptr);
-}
-
-/* Print a fatal error message and terminate */
-void
-fatal_error(const char *fmt, ...)
-{
- va_list arg_ptr;
-
- va_start(arg_ptr, fmt);
- fprintf(stderr, PACKAGE ": FATAL: ");
- vfprintf(stderr, fmt, arg_ptr);
- va_end(arg_ptr);
- exit(-1);
-}
-
diff --git a/libmej/snprintf.c b/libmej/snprintf.c
deleted file mode 100644
index d479382..0000000
--- a/libmej/snprintf.c
+++ /dev/null
@@ -1,521 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <errno.h>
-#ifdef HAVE_STDARG_H
-# include <stdarg.h>
-#endif
-
-static const char cvs_ident[] = "$Id$";
-
-/*
- * Shamelessly snarfed from Enlightenment...
- * which shamelessly snarfed from sane...
- * which shamelessly snarfed from LPR
- * which probably shamelessly snarfed from....
- *
- * Moved comments to end so I can actually read the code.. cleaned out useless
- * junk....
- */
-
-#if !defined(HAVE_SNPRINTF) || (HAVE_SNPRINTF_BUG == 1)
-
-#define VA_LOCAL_DECL va_list ap
-#define VA_START(f) va_start(ap, f)
-#define VA_SHIFT(v,t) ; /* no-op for ANSI */
-#define VA_END va_end(ap)
-
-/*
- * dopr(): poor man's version of doprintf
- */
-
-static void dopr(char *buffer, const char *format, va_list args);
-static void fmtstr(char *value, int ljust, int len, int zpad, int precision);
-static void fmtnum(long value, int base, int dosign,
- int ljust, int len, int zpad, int precision);
-static void fmtdouble(int fmt, double value,
- int ljust, int len, int zpad, int precision);
-static void dostr(char *);
-static char *output;
-static void dopr_outch(int c);
-static char *end;
-int visible_control = 1;
-
-int
-vsnprintf(char *str, size_t count, const char *fmt, va_list args)
-{
- str[0] = 0;
- end = str + count - 1;
- dopr(str, fmt, args);
- if (count > 0) {
- end[0] = 0;
- }
- return (strlen(str));
-}
-
-#ifdef HAVE_STDARG_H
-int
-snprintf(char *str, size_t count, const char *fmt,...)
-#else
-int
-snprintf(va_alist)
- va_dcl
-
-#endif
-{
-#ifndef HAVE_STDARG_H
- char *str;
- size_t count;
- char *fmt;
-
-#endif
- VA_LOCAL_DECL;
-
- VA_START(fmt);
- VA_SHIFT(str, char *);
-
- VA_SHIFT(count, size_t);
- VA_SHIFT(fmt, char *);
-
- (void) vsnprintf(str, count, fmt, ap);
- VA_END;
- return (strlen(str));
-}
-
-static void
-dopr(char *buffer, const char *format, va_list args)
-{
- int ch;
- long value;
- int longflag = 0;
- char *strvalue;
- int ljust;
- int len;
- int zpad;
- int precision;
- int set_precision;
- double dval;
-
- output = buffer;
- while ((ch = *format++)) {
- switch (ch) {
- case '%':
- ljust = len = zpad = 0;
- precision = -1;
- set_precision = 0;
- nextch:
- ch = *format++;
- switch (ch) {
- case 0:
- dostr("**end of format**");
- return;
- case '-':
- ljust = 1;
- goto nextch;
- case '.':
- set_precision = 1;
- precision = 0;
- goto nextch;
- case '*':
- len = va_arg(args, int);
-
- goto nextch;
- case '0': /* set zero padding if len not set */
- if (len == 0 && set_precision == 0)
- zpad = '0';
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (set_precision) {
- precision = precision * 10 + ch - '0';
- } else {
- len = len * 10 + ch - '0';
- }
- goto nextch;
- case 'l':
- longflag = 1;
- goto nextch;
- case 'u':
- case 'U':
- /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
- if (longflag) {
- value = va_arg(args, long);
- } else {
- value = va_arg(args, int);
- }
- fmtnum(value, 10, 0, ljust, len, zpad, precision);
- break;
- case 'o':
- case 'O':
- /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */
- if (longflag) {
- value = va_arg(args, long);
- } else {
- value = va_arg(args, int);
- }
- fmtnum(value, 8, 0, ljust, len, zpad, precision);
- break;
- case 'd':
- case 'i':
- case 'D':
- if (longflag) {
- value = va_arg(args, long);
- } else {
- value = va_arg(args, int);
- }
- fmtnum(value, 10, 1, ljust, len, zpad, precision);
- break;
- case 'x':
- if (longflag) {
- value = va_arg(args, long);
- } else {
- value = va_arg(args, int);
- }
- fmtnum(value, 16, 0, ljust, len, zpad, precision);
- break;
- case 'X':
- if (longflag) {
- value = va_arg(args, long);
- } else {
- value = va_arg(args, int);
- }
- fmtnum(value, -16, 0, ljust, len, zpad, precision);
- break;
- case 's':
- strvalue = va_arg(args, char *);
-
- fmtstr(strvalue, ljust, len, zpad, precision);
- break;
- case 'c':
- ch = va_arg(args, int);
-
- {
- char b[2];
- int vsb = visible_control;
-
- b[0] = ch;
- b[1] = 0;
- visible_control = 0;
- fmtstr(b, ljust, len, zpad, precision);
- visible_control = vsb;
- }
- break;
- case 'f':
- case 'g':
- dval = va_arg(args, double);
-
- fmtdouble(ch, dval, ljust, len, zpad, precision);
- break;
- case '%':
- dopr_outch(ch);
- continue;
- default:
- dostr("???????");
- }
- longflag = 0;
- break;
- default:
- dopr_outch(ch);
- break;
- }
- }
- *output = 0;
-}
-
-/*
- * Format '%[-]len[.precision]s'
- * - = left justify (ljust)
- * len = minimum length
- * precision = numbers of chars in string to use
- */
-static void
-fmtstr(char *value, int ljust, int len, int zpad, int precision)
-{
- int padlen, strlen, i, c; /* amount to pad */
-
- zpad = 0;
- if (value == 0) {
- value = "<NULL>";
- }
- if (precision > 0) {
- strlen = precision;
- } else {
- /* cheap strlen so you do not have library call */
- for (strlen = 0; (c = value[strlen]); ++strlen) {
- if (visible_control && iscntrl(c) && !isspace(c)) {
- ++strlen;
- }
- }
- }
- padlen = len - strlen;
- if (padlen < 0)
- padlen = 0;
- if (ljust)
- padlen = -padlen;
- while (padlen > 0) {
- dopr_outch(' ');
- --padlen;
- }
- /* output characters */
- for (i = 0; (c = value[i]); ++i) {
- if (visible_control && iscntrl(c) && !isspace(c)) {
- dopr_outch('^');
- c = ('@' | (c & 0x1F));
- }
- dopr_outch(c);
- }
- while (padlen < 0) {
- dopr_outch(' ');
- ++padlen;
- }
-}
-
-static void
-fmtnum(long value, int base, int dosign, int ljust,
- int len, int zpad, int precision)
-{
- int signvalue = 0;
- unsigned long uvalue;
- char convert[20];
- int place = 0;
- int padlen = 0; /* amount to pad */
- int caps = 0;
-
- precision = 0;
- /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n",
- * value, base, dosign, ljust, len, zpad )); */
- uvalue = value;
- if (dosign) {
- if (value < 0) {
- signvalue = '-';
- uvalue = -value;
- }
- }
- if (base < 0) {
- caps = 1;
- base = -base;
- }
- do {
- convert[place++] =
- (caps ? "0123456789ABCDEF" : "0123456789abcdef")
- [uvalue % (unsigned) base];
- uvalue = (uvalue / (unsigned) base);
- }
- while (uvalue);
- convert[place] = 0;
- padlen = len - place;
- if (padlen < 0)
- padlen = 0;
- if (ljust)
- padlen = -padlen;
- /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n",
- * convert,place,signvalue,padlen)); */
- if (zpad && padlen > 0) {
- if (signvalue) {
- dopr_outch(signvalue);
- --padlen;
- signvalue = 0;
- }
- while (padlen > 0) {
- dopr_outch(zpad);
- --padlen;
- }
- }
- while (padlen > 0) {
- dopr_outch(' ');
- --padlen;
- }
- if (signvalue)
- dopr_outch(signvalue);
- while (place > 0)
- dopr_outch(convert[--place]);
- while (padlen < 0) {
- dopr_outch(' ');
- ++padlen;
- }
-}
-
-static void
-fmtdouble(int fmt, double value, int ljust, int len, int zpad, int precision)
-{
- char convert[128];
- char fmtstr[128];
- int l;
-
- zpad = 0;
- if (len == 0)
- len = 10;
- if (len > (int) sizeof(convert) - 10) {
- len = (int) sizeof(convert) - 10;
- }
- if (precision > (int) sizeof(convert) - 10) {
- precision = (int) sizeof(convert) - 10;
- }
- if (precision > len)
- precision = len;
- strcpy(fmtstr, "%");
- if (ljust)
- strcat(fmtstr, "-");
- if (len) {
- sprintf(fmtstr + strlen(fmtstr), "%d", len);
- }
- if (precision > 0) {
- sprintf(fmtstr + strlen(fmtstr), ".%d", precision);
- }
- l = strlen(fmtstr);
- fmtstr[l] = fmt;
- fmtstr[l + 1] = 0;
- sprintf(convert, fmtstr, value);
- dostr(convert);
-}
-
-static void
-dostr(char *str)
-{
- while (*str)
- dopr_outch(*str++);
-}
-
-static void
-dopr_outch(int c)
-{
- if (end == 0 || output < end) {
- *output++ = c;
- }
-}
-
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * plp_snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- **************************************************************/
-
-/***************************************************************************
- * LPRng - An Extended Print Spooler System
- *
- * Copyright 1988-1997, Patrick Powell, San Diego, CA
- * papowell@sdsu.edu
- * See below for conditions of use.
- *
- ***************************************************************************
- * MODULE: snprintf.c
- * PURPOSE: LPRng version of printf - absolutely bombproof (hopefully!)
- **************************************************************************/
-
-/*
- * The "Artistic License"
- *
- * Preamble
- *
- * The intent of this document is to state the conditions under which a
- * Package may be copied, such that the Copyright Holder maintains some
- * semblance of artistic control over the development of the package,
- * while giving the users of the package the right to use and distribute
- * the Package in a more-or-less customary fashion, plus the right to make
- * reasonable modifications.
- *
- * Definitions:
- *
- * "Package" refers to the collection of files distributed by the
- * Copyright Holder, and derivatives of that collection of files
- * created through textual modification.
- *
- * "Standard Version" refers to such a Package if it has not been
- * modified, or has been modified in accordance with the wishes
- * of the Copyright Holder as specified below.
- *
- * "Copyright Holder" is whoever is named in the copyright or
- * copyrights for the package.
- *
- * "You" is you, if you are thinking about copying or distributing
- * this Package.
- *
- * "Reasonable copying fee" is whatever you can justify on the
- * basis of media cost, duplication charges, time of people involved,
- * and so on. (You will not be required to justify it to the
- * Copyright Holder, but only to the computing community at large
- * as a market that must bear the fee.)
- *
- * "libmej_freely Available" means that no fee is charged for the item
- * itself, though there may be fees involved in handling the item.
- * It also means that recipients of the item may redistribute it
- * under the same conditions they received it.
- *
- * 1. You may make and give away verbatim copies of the source form of the
- * Standard Version of this Package without restriction, provided that you
- * duplicate all of the original copyright notices and associated disclaimers.
- *
- * 2. You may apply bug fixes, portability fixes and other modifications
- * derived from the Public Domain or from the Copyright Holder. A Package
- * modified in such a way shall still be considered the Standard Version.
- *
- * 3. You may otherwise modify your copy of this Package in any way, provided
- * that you insert a prominent notice in each changed file stating how and
- * when you changed that file, and provided that you do at least ONE of the
- * following:
- *
- * a) place your modifications in the Public Domain or otherwise make them
- * libmej_freely Available, such as by posting said modifications to Usenet or
- * an equivalent medium, or placing the modifications on a major archive
- * site such as uunet.uu.net, or by allowing the Copyright Holder to include
- * your modifications in the Standard Version of the Package.
- *
- * b) use the modified Package only within your corporation or organization.
- *
- * c) rename any non-standard executables so the names do not conflict
- * with standard executables, which must also be provided, and provide
- * a separate manual page for each non-standard executable that clearly
- * documents how it differs from the Standard Version.
- *
- * d) make other distribution arrangements with the Copyright Holder.
- *
- * 4. You may distribute the programs of this Package in object code or
- * executable form, provided that you do at least ONE of the following:
- *
- * a) distribute a Standard Version of the executables and library files,
- * together with instructions (in the manual page or equivalent) on where
- * to get the Standard Version.
- *
- * b) accompany the distribution with the machine-readable source of
- * the Package with your modifications.
- *
- * c) give non-standard executables non-standard names, and clearly
- * document the differences in manual pages (or equivalent), together
- * with instructions on where to get the Standard Version.
- *
- * d) make other distribution arrangements with the Copyright Holder.
- *
- * 5. You may charge a reasonable copying fee for any distribution of this
- * Package. You may charge any fee you choose for support of this
- * Package. You may not charge a fee for this Package itself. However,
- * you may distribute this Package in aggregate with other (possibly
- * commercial) programs as part of a larger (possibly commercial) software
- * distribution provided that you do not advertise this Package as a
- * product of your own.
- *
- * 6. The name of the Copyright Holder may not be used to endorse or promote
- * products derived from this software without specific prior written permission.
- *
- * 7. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * The End
- */
-
-#endif /* HAVE_SNPRINTF */
diff --git a/libmej/strings.c b/libmej/strings.c
deleted file mode 100644
index 6c00f29..0000000
--- a/libmej/strings.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * Copyright (C) 1997-2000, Michael Jennings
- *
- * 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 of the Software, its documentation and marketing & publicity
- * materials, and acknowledgment shall be given in the documentation, materials
- * and software packages that this Software was used.
- *
- * 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 AUTHORS 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.
- */
-
-static const char cvs_ident[] = "$Id$";
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <libmej.h>
-
-#ifndef HAVE_MEMMEM
-/* Find first occurance of bytestring needle of size needlelen in memory region
- haystack of size haystacklen */
-void *
-memmem(void *haystack, register size_t haystacklen, void *needle, register size_t needlelen)
-{
- register char *hs = (char *) haystack;
- register char *n = (char *) needle;
- register unsigned long i;
- register size_t len = haystacklen - needlelen;
-
- for (i = 0; i < len; i++) {
- if (!memcmp(hs + i, n, needlelen)) {
- return (hs + i);
- }
- }
- return (NULL);
-}
-#endif
-
-#ifndef HAVE_USLEEP
-void
-usleep(unsigned long usec)
-{
- struct timeval delay;
-
- delay.tv_sec = 0;
- delay.tv_usec = usec;
- select(0, NULL, NULL, NULL, &delay);
-
-}
-
-#endif
-
-/***** Not needed ******
-#ifndef HAVE_NANOSLEEP
-__inline__ void
-nanosleep(unsigned long nsec) {
- usleep(nsec / 1000);
-}
-#endif
-************************/
-
-/* Return the leftmost cnt characters of str */
-char *
-left_str(const char *str, unsigned long cnt)
-{
- char *tmpstr;
-
- tmpstr = (char *) MALLOC(cnt + 1);
- strncpy(tmpstr, str, cnt);
- tmpstr[cnt] = 0;
- return (tmpstr);
-}
-
-/* Return cnt characters from str, starting at position index (from 0) */
-char *
-mid_str(const char *str, unsigned long index, unsigned long cnt)
-{
- char *tmpstr;
- const char *pstr = str;
-
- tmpstr = (char *) MALLOC(cnt + 1);
- pstr += index;
- strncpy(tmpstr, pstr, cnt);
- tmpstr[cnt] = 0;
- return (tmpstr);
-}
-
-/* Return the rightmost characters of str */
-char *
-right_str(const char *str, unsigned long cnt)
-{
- char *tmpstr;
- const char *pstr = str;
-
- tmpstr = (char *) MALLOC(cnt + 1);
- pstr += strlen(str);
- pstr -= cnt;
- strcpy(tmpstr, pstr);
- return (tmpstr);
-}
-
-/* Returns TRUE if str matches regular expression pattern, FALSE otherwise */
-#if defined(HAVE_REGEX_H) || defined(IRIX)
-unsigned char
-regexp_match(register const char *str, register const char *pattern)
-{
- register regex_t *rexp;
- register int result;
- char errbuf[256];
-
- rexp = (regex_t *) MALLOC(sizeof(regex_t));
-
- if ((result = regcomp(rexp, pattern, REG_EXTENDED)) != 0) {
- regerror(result, rexp, errbuf, 256);
- fprintf(stderr, "Unable to compile regexp %s -- %s.\n", pattern, errbuf);
- FREE(rexp);
- return (FALSE);
- }
-
- if (((result = regexec(rexp, str, (size_t) 0, (regmatch_t *) NULL, 0))
- != 0) && (result != REG_NOMATCH)) {
- regerror(result, rexp, errbuf, 256);
- fprintf(stderr, "Error testing input string %s -- %s.\n", str, errbuf);
- FREE(rexp);
- return (FALSE);
- }
- FREE(rexp);
- return (!result);
-}
-#endif
-
-/* Return malloc'd pointer to index-th word in str. "..." counts as 1 word. */
-#define IS_DELIM(c) (delim ? ((c) == delim) : (isspace(c)))
-
-char *
-get_word(unsigned long index, const char *str)
-{
- char *tmpstr;
- char delim = 0;
- register unsigned long i, j, k;
-
- k = strlen(str) + 1;
- if ((tmpstr = (char *) MALLOC(k)) == NULL) {
- fprintf(stderr, "get_word(%lu, %s): Unable to allocate memory -- %s.\n",
- index, str, strerror(errno));
- return ((char *) NULL);
- }
- *tmpstr = 0;
- for (i = 0, j = 0; j < index && str[i]; j++) {
- for (; isspace(str[i]); i++);
- switch (str[i]) {
- case '\"':
- delim = '\"';
- i++;
- break;
- case '\'':
- delim = '\'';
- i++;
- break;
- default:
- delim = 0;
- }
- for (k = 0; str[i] && !IS_DELIM(str[i]);) {
- if (str[i] == '\\') {
- if (str[i + 1] == '\'' || str[i + 1] == '\"') {
- i++;
- }
- }
- tmpstr[k++] = str[i++];
- }
- switch (str[i]) {
- case '\"':
- case '\'':
- i++;
- break;
- }
- tmpstr[k] = 0;
- }
-
- if (j != index) {
- FREE(tmpstr);
- D_STRINGS(("get_word(%lu, %s) returning NULL.\n", index, str));
- return ((char *) NULL);
- } else {
- tmpstr = (char *) REALLOC(tmpstr, strlen(tmpstr) + 1);
- D_STRINGS(("get_word(%lu, %s) returning \"%s\".\n", index, str, tmpstr));
- return (tmpstr);
- }
-}
-
-/* Return pointer into str to index-th word in str. "..." counts as 1 word. */
-char *
-get_pword(unsigned long index, const char *str)
-{
- register const char *tmpstr = str;
- register unsigned long j;
-
- if (!str)
- return ((char *) NULL);
- for (; isspace(*tmpstr) && *tmpstr; tmpstr++);
- for (j = 1; j < index && *tmpstr; j++) {
- for (; !isspace(*tmpstr) && *tmpstr; tmpstr++);
- for (; isspace(*tmpstr) && *tmpstr; tmpstr++);
- }
-
- if (*tmpstr == '\"' || *tmpstr == '\'') {
- tmpstr++;
- }
- if (*tmpstr == '\0') {
- D_STRINGS(("get_pword(%lu, %s) returning NULL.\n", index, str));
- return ((char *) NULL);
- } else {
- D_STRINGS(("get_pword(%lu, %s) returning \"%s\"\n", index, str, tmpstr));
- return (char *) tmpstr;
- }
-}
-
-/* Returns the number of words in str, for use with get_word() and get_pword(). "..." counts as 1 word. */
-unsigned long
-num_words(const char *str)
-{
- register unsigned long cnt = 0;
- char delim = 0;
- register unsigned long i;
-
- for (i = 0; str[i] && IS_DELIM(str[i]); i++);
- for (; str[i]; cnt++) {
- switch (str[i]) {
- case '\"':
- delim = '\"';
- i++;
- break;
- case '\'':
- delim = '\'';
- i++;
- break;
- default:
- delim = 0;
- }
- for (; str[i] && !IS_DELIM(str[i]); i++);
- switch (str[i]) {
- case '\"':
- case '\'':
- i++;
- break;
- }
- for (; str[i] && isspace(str[i]); i++);
- }
-
- D_STRINGS(("num_words() returning %lu\n", cnt));
- return (cnt);
-}
-
-char *
-strip_whitespace(register char *str)
-{
- register unsigned long i, j;
-
- if ((j = strlen(str))) {
- for (i = j - 1; isspace(*(str + i)); i--);
- str[j = i + 1] = 0;
- for (i = 0; isspace(*(str + i)); i++);
- j -= i;
- memmove(str, str + i, j + 1);
- }
- return (str);
-}
-
-char *
-downcase_str(char *str)
-{
- register char *tmp;
-
- for (tmp = str; *tmp; tmp++) {
- *tmp = tolower(*tmp);
- }
- D_STRINGS(("downcase_str() returning %s\n", str));
- return (str);
-}
-
-char *
-upcase_str(char *str)
-{
- register char *tmp;
-
- for (tmp = str; *tmp; tmp++) {
- *tmp = toupper(*tmp);
- }
- D_STRINGS(("upcase_str() returning %s\n", str));
- return (str);
-}
-
-#ifndef HAVE_STRCASESTR
-char *
-strcasestr(char *haystack, register const char *needle)
-{
- register char *t;
- register size_t len = strlen(needle);
-
- for (t = haystack; t && *t; t++) {
- if (!strncasecmp(t, needle, len)) {
- return (t);
- }
- }
- return (NULL);
-}
-#endif
-
-#ifndef HAVE_STRCASECHR
-char *
-strcasechr(char *haystack, register char needle)
-{
- register char *t;
-
- for (t = haystack; t && *t; t++) {
- if (tolower(*t) == tolower(needle)) {
- return (t);
- }
- }
- return (NULL);
-}
-#endif
-
-#ifndef HAVE_STRCASEPBRK
-char *
-strcasepbrk(char *haystack, register char *needle)
-{
- register char *t;
-
- for (t = haystack; t && *t; t++) {
- if (strcasechr(needle, *t)) {
- return (t);
- }
- }
- return (NULL);
-}
-#endif
-
-#ifndef HAVE_STRREV
-char *
-strrev(register char *str)
-{
- register int i, j;
-
- i = strlen(str);
- for (j = 0, i--; i > j; i--, j++) {
- SWAP(str[j], str[i]);
- }
- return (str);
-
-}
-#endif
-
-#if !(HAVE_STRSEP)
-char *
-strsep(char **str, register char *sep)
-{
-
- register char *s = *str;
- char *sptr;
-
- D_STRINGS(("strsep(%s, %s) called.\n", *str, sep));
- sptr = s;
- for (; *s && !strchr(sep, *s); s++);
- if (!*s) {
- if (s != sptr) {
- *str = s;
- D_STRINGS(("Reached end of string with token \"%s\" in buffer\n", sptr));
- return (sptr);
- } else {
- D_STRINGS(("Reached end of string\n"));
- return ((char *) NULL);
- }
- }
- *s = 0;
- *str = s + 1;
- D_STRINGS(("Got token \"%s\", *str == \"%s\"\n", sptr, *str));
- return (sptr);
-}
-#endif
-
-char *
-garbage_collect(char *buff, size_t len)
-{
-
- register char *tbuff = buff, *pbuff = buff;
- register unsigned long i, j;
-
- D_STRINGS(("Garbage collecting on %lu bytes at %10.8p\n", len, buff));
- for (i = 0, j = 0; j < len; j++)
- if (pbuff[j])
- tbuff[i++] = pbuff[j];
- tbuff[i++] = '\0';
- D_STRINGS(("Garbage collecting gives: \n%s\n", buff));
- return ((char *) REALLOC(buff, sizeof(char) * i));
-}
-
-char *
-file_garbage_collect(char *buff, size_t len)
-{
-
- register char *tbuff = buff, *pbuff = buff;
- char *tmp1, *tmp2;
- register unsigned long j;
-
- D_STRINGS(("File garbage collecting on %lu bytes at %10.8p\n", len, buff));
- for (j = 0; j < len;) {
- switch (pbuff[j]) {
- case '#':
- for (; !strchr("\r\n", pbuff[j]) && j < len; j++)
- pbuff[j] = '\0'; /* First null out the line up to the CR and/or LF */
- for (; strchr("\r\n", pbuff[j]) && j < len; j++)
- pbuff[j] = '\0'; /* Then null out the CR and/or LF */
- break;
- case '\r':
- case '\n':
- case '\f':
- case ' ':
- case '\t':
- case '\v':
- for (; isspace(pbuff[j]) && j < len; j++)
- pbuff[j] = '\0'; /* Null out the whitespace */
- break;
- default:
- /* Find the end of this line and the occurence of the
- next mid-line comment. */
- tmp1 = strpbrk(pbuff + j, "\r\n");
- tmp2 = strstr(pbuff + j, " #");
-
- /* If either is null, take the non-null one. Otherwise,
- take the lesser of the two. */
- if (!tmp1 || !tmp2) {
- tbuff = ((tmp1) ? (tmp1) : (tmp2));
- } else {
- tbuff = ((tmp1 < tmp2) ? (tmp1) : (tmp2));
- }
-
- /* Now let j catch up so that pbuff+j = tbuff; i.e., let
- pbuff[j] refer to the same character that tbuff does */
- j += tbuff - (pbuff + j);
-
- /* Finally, change whatever is at pbuff[j] to a newline.
- This will accomplish several things at once:
- o It will change a \r to a \n if that's what's there
- o If it's a \n, it'll stay the same. No biggie.
- o If it's a space, it will end the line there and the
- next line will begin with a comment, which is handled
- above. */
- if (j < len)
- pbuff[j++] = '\n';
-
- }
- }
-
- /* Change all occurances of a backslash followed by a newline to nulls
- and null out all whitespace up to the next non-whitespace character.
- This handles support for breaking a string across multiple lines. */
- for (j = 0; j < len; j++) {
- if (pbuff[j] == '\\' && pbuff[j + 1] == '\n') {
- pbuff[j++] = '\0';
- for (; isspace(pbuff[j]) && j < len; j++)
- pbuff[j] = '\0'; /* Null out the whitespace */
- }
- }
-
- /* And the final step, garbage collect the buffer to condense all
- those nulls we just put in. */
- return (garbage_collect(buff, len));
-}
-
-char *
-condense_whitespace(char *s)
-{
-
- register unsigned char gotspc = 0;
- register char *pbuff = s, *pbuff2 = s;
-
- D_STRINGS(("condense_whitespace(%s) called.\n", s));
- for (; *pbuff2; pbuff2++) {
- if (isspace(*pbuff2)) {
- if (!gotspc) {
- *pbuff = ' ';
- gotspc = 1;
- pbuff++;
- }
- } else {
- *pbuff = *pbuff2;
- gotspc = 0;
- pbuff++;
- }
- }
- if ((pbuff >= s) && (isspace(*(pbuff - 1))))
- pbuff--;
- *pbuff = 0;
- D_STRINGS(("condense_whitespace() returning \"%s\".\n", s));
- return (REALLOC(s, strlen(s) + 1));
-}
-
-char *
-safe_str(register char *str, unsigned short len)
-{
- register unsigned short i;
-
- for (i = 0; i < len; i++) {
- if (iscntrl(str[i])) {
- str[i] = '.';
- }
- }
-
- return (str);
-}
-
-void
-hex_dump(void *buff, register size_t count)
-{
-
- register unsigned long j, k, l;
- register unsigned char *ptr;
- unsigned char buffr[9];
-
- fprintf(stderr, " Address | Size | Offset | 00 01 02 03 04 05 06 07 | ASCII \n");
- fprintf(stderr, "---------+--------+---------+-------------------------+---------\n");
- for (ptr = (unsigned char *) buff, j = 0; j < count; j += 8) {
- fprintf(stderr, " %8p | %06lu | %07x | ", buff, (unsigned long) count, (unsigned int) j);
- l = ((count - j < 8) ? (count - j) : (8));
- memset(buffr, 0, 9);
- memcpy(buffr, ptr + j, l);
- for (k = 0; k < l; k++) {
- fprintf(stderr, "%02x ", buffr[k]);
- }
- for (; k < 8; k++) {
- fprintf(stderr, " ");
- }
- fprintf(stderr, "| %-8s\n", safe_str((char *) buffr, l));
- }
-}
diff --git a/src/Makefile.am b/src/Makefile.am
index d912475..550e4da 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,5 @@
# $Id$
-INCLUDES = -I$(top_srcdir)/libmej
-
lib_LTLIBRARIES = libEterm.la
bin_PROGRAMS = Eterm
@@ -13,13 +11,13 @@ libEterm_la_SOURCES = actions.c actions.h buttons.c buttons.h command.c
screen.h scrollbar.c scrollbar.h startup.c startup.h \
system.c system.h term.c term.h timer.c timer.h utmp.c \
windows.c windows.h mmx_cmod.S
-libEterm_la_DEPENDENCIES = $(top_builddir)/libmej/libmej.la feature.h
+libEterm_la_DEPENDENCIES = feature.h
libEterm_la_LDFLAGS = -release $(VERSION)
Eterm_SOURCES = main.c
Eterm_DEPENDENCIES = libEterm.la
Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir)
-Eterm_LDADD = libEterm.la $(top_builddir)/libmej/libmej.la
+Eterm_LDADD = libEterm.la
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
diff --git a/src/buttons.c b/src/buttons.c
index 6b4a78e..85f5792 100644
--- a/src/buttons.c
+++ b/src/buttons.c
@@ -100,7 +100,7 @@ bbar_create(void)
XSelectInput(Xdisplay, bbar->win, mask);
XStoreName(Xdisplay, bbar->win, "Eterm Button Bar");
- bbar->gc = LIBMEJ_X_CREATE_GC(GCForeground | GCFont, &gcvalue);
+ bbar->gc = LIBAST_X_CREATE_GC(GCForeground | GCFont, &gcvalue);
bbar_set_docked(bbar, BBAR_DOCKED_TOP);
bbar_set_visible(bbar, 1);
diff --git a/src/draw.c b/src/draw.c
index 51f0e08..641a1ea 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -54,8 +54,8 @@ draw_shadow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
- gc_top = LIBMEJ_X_CREATE_GC(0, NULL);
- gc_bottom = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc_top = LIBAST_X_CREATE_GC(0, NULL);
+ gc_bottom = LIBAST_X_CREATE_GC(0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
@@ -109,8 +109,8 @@ draw_arrow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w,
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
- gc_top = LIBMEJ_X_CREATE_GC(0, NULL);
- gc_bottom = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc_top = LIBAST_X_CREATE_GC(0, NULL);
+ gc_bottom = LIBAST_X_CREATE_GC(0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
@@ -230,8 +230,8 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border *bord, unsigned char up)
MOD_PIXEL_HIGH(x, y, !up);
}
}
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
XDestroyImage(ximg);
}
diff --git a/src/encoding.c b/src/encoding.c
index e688e56..9a81e22 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -31,9 +31,9 @@ static const char cvs_ident[] = "$Id$";
#include <errno.h>
#include <limits.h>
-#include "../libmej/debug.h"
-#include "../libmej/mem.h"
-#include "../libmej/strings.h"
+#include "../libast/debug.h"
+#include "../libast/mem.h"
+#include "../libast/strings.h"
#include "debug.h"
#include "command.h"
#include "encoding.h"
diff --git a/src/events.h b/src/events.h
index 38ab697..13e04d0 100644
--- a/src/events.h
+++ b/src/events.h
@@ -50,7 +50,7 @@
# define COUNT_EVENT(x) NOP
#endif
#ifdef PROFILE_X_EVENTS
-# define P_EVENT_TIME(type, start, stop) libmej_dprintf(type ": %ld microseconds\n", P_CMPTIMEVALS_USEC((start), (stop)))
+# define P_EVENT_TIME(type, start, stop) libast_dprintf(type ": %ld microseconds\n", P_CMPTIMEVALS_USEC((start), (stop)))
#else
# define P_EVENT_TIME(type, start, stop) NOP
#endif
diff --git a/src/feature.h b/src/feature.h
index 970fa51..c3c1100 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -89,7 +89,7 @@
# include <stdio.h>
# include <stdlib.h>
-# include <libmej.h>
+# include <libast.h>
# include "eterm_debug.h"
/********************* Color, screen, and image stuff *********************/
diff --git a/src/menus.c b/src/menus.c
index 32cf530..159fa78 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -124,9 +124,9 @@ menu_init(void)
return;
}
gcvalue.foreground = PixColors[menuTopShadowColor];
- topShadowGC = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ topShadowGC = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[menuBottomShadowColor];
- botShadowGC = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ botShadowGC = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
event_register_dispatcher(menu_dispatch_event, menu_event_init_dispatcher);
}
@@ -428,8 +428,8 @@ menulist_clear(menulist_t *list)
menu_delete(list->menus[i]);
}
FREE(list->menus);
- LIBMEJ_X_FREE_GC(topShadowGC);
- LIBMEJ_X_FREE_GC(botShadowGC);
+ LIBAST_X_FREE_GC(topShadowGC);
+ LIBAST_X_FREE_GC(botShadowGC);
FREE(list);
}
@@ -463,7 +463,7 @@ menu_create(char *title)
menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBorderPixel | CWColormap, &xattr);
- menu->gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ menu->gc = LIBAST_X_CREATE_GC(0, NULL);
menuitem_clear_current(menu);
return menu;
@@ -484,10 +484,10 @@ menu_delete(menu_t *menu)
FREE(menu->title);
}
if (menu->bg) {
- LIBMEJ_X_FREE_PIXMAP(menu->bg);
+ LIBAST_X_FREE_PIXMAP(menu->bg);
}
if (menu->gc) {
- LIBMEJ_X_FREE_GC(menu->gc);
+ LIBAST_X_FREE_GC(menu->gc);
}
#ifdef MULTI_CHARSET
if (menu->fontset) {
diff --git a/src/options.c b/src/options.c
index ab1a99b..9ef55e3 100644
--- a/src/options.c
+++ b/src/options.c
@@ -3966,7 +3966,9 @@ post_parse(void)
FREE(rs_cmod_blue);
}
- if (rs_cache_size != (unsigned long) -1) {
+ if (rs_cache_size == (unsigned long) -1) {
+ imlib_set_cache_size(0);
+ } else {
imlib_set_cache_size(rs_cache_size);
}
#endif
diff --git a/src/pixmap.c b/src/pixmap.c
index 186f266..c8afae5 100644
--- a/src/pixmap.c
+++ b/src/pixmap.c
@@ -521,8 +521,8 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
} else {
XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
}
- p = LIBMEJ_X_CREATE_PIXMAP(width, height);
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ p = LIBAST_X_CREATE_PIXMAP(width, height);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y, desktop_window));
if (p != None) {
if (pw < scr->width || ph < scr->height) {
@@ -544,7 +544,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
}
}
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return p;
}
@@ -619,10 +619,10 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
}
}
if (p == None) {
- p = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ p = LIBAST_X_CREATE_PIXMAP(width, height);
D_PIXMAP(("Created p == 0x%08x\n", p));
}
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
D_PIXMAP(("Translated coords are %d, %d\n", x, y));
if ((images[image_bg].current->pmap->w > 0) || (images[image_bg].current->pmap->op & OP_SCALE)) {
@@ -633,7 +633,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
}
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return p;
}
@@ -678,13 +678,13 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
FREE(reply);
enl_ipc_sync();
if (pmap) {
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y);
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y);
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return;
} else {
print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
@@ -697,22 +697,26 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
} else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
Pixmap p;
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_trans_pixmap(simg, which, win, x, y, w, h);
- XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
- LIBMEJ_X_FREE_PIXMAP(p);
- LIBMEJ_X_FREE_GC(gc);
+ if (p != None) {
+ XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
+ if (p != desktop_pixmap) {
+ LIBAST_X_FREE_PIXMAP(p);
+ }
+ }
+ LIBAST_X_FREE_GC(gc);
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p;
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, win, x, y, w, h);
if (simg->iml->bevel != NULL) {
bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up);
}
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
- LIBMEJ_X_FREE_PIXMAP(p);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_PIXMAP(p);
+ LIBAST_X_FREE_GC(gc);
}
}
@@ -740,14 +744,14 @@ paste_simage(simage_t *simg, unsigned char which, Window win, Drawable d, unsign
return;
}
IMLIB_REGISTER_PIXMAP(pmap);
- gc = LIBMEJ_X_CREATE_GC(0, NULL);
+ gc = LIBAST_X_CREATE_GC(0, NULL);
if (mask) {
XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y);
}
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y);
IMLIB_FREE_PIXMAP(pmap);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
}
}
@@ -806,9 +810,9 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
XGCValues gcvalue;
ASSERT(buffer_pixmap == None);
- buffer_pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ buffer_pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
gcvalue.foreground = (Pixel) fill;
- gc = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ gc = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
XSetGraphicsExposures(Xdisplay, gc, False);
if (mode == MODE_SOLID) {
@@ -816,15 +820,15 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
simg = images[image_bg].current;
if (simg->pmap->pixmap) {
- LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
+ LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
}
- simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
} else {
XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
}
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
}
void
@@ -862,11 +866,11 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
return;
gcvalue.foreground = gcvalue.background = PixColors[bgColor];
- gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
+ gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
pixmap = simg->pmap->pixmap; /* Save this for later */
if ((which == image_bg) && (buffer_pixmap != None)) {
- LIBMEJ_X_FREE_PIXMAP(buffer_pixmap);
+ LIBAST_X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None;
}
@@ -908,11 +912,16 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
XSetClipOrigin(Xdisplay, gc, 0, 0);
}
if (simg->pmap->pixmap) {
- LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
+ LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
+ simg->pmap->pixmap = None;
+ }
+ if (renderop & RENDER_FORCE_PIXMAP) {
+ simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
+ XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
+ XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
+ } else {
+ XSetWindowBackgroundPixmap(Xdisplay, win, pmap);
}
- simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
- XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
- XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff);
} else {
@@ -924,7 +933,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else {
snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state);
enl_ipc_send(buff);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return;
}
}
@@ -934,7 +943,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
# ifdef PIXMAP_OFFSET
if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
if (simg->pmap->pixmap != None) {
- LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
+ LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = create_trans_pixmap(simg, which, win, 0, 0, width, height);
if (simg->pmap->pixmap != None) {
@@ -944,6 +953,10 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else {
XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
}
+ if (!(renderop & RENDER_FORCE_PIXMAP)) {
+ IMLIB_FREE_PIXMAP(simg->pmap->pixmap);
+ simg->pmap->pixmap = None;
+ }
} else {
image_mode_fallback(which);
}
@@ -954,7 +967,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
p = create_viewport_pixmap(simg, win, 0, 0, width, height);
if (p && (p != simg->pmap->pixmap)) {
if (simg->pmap->pixmap != None) {
- LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
+ LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = p;
}
@@ -966,6 +979,10 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else {
XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
}
+ if (!(renderop & RENDER_FORCE_PIXMAP)) {
+ IMLIB_FREE_PIXMAP(simg->pmap->pixmap);
+ simg->pmap->pixmap = None;
+ }
} else {
image_mode_fallback(which);
}
@@ -1049,7 +1066,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0;
pixmap = simg->pmap->pixmap;
- simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
if (single) {
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
}
@@ -1064,7 +1081,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
IMLIB_FREE_PIXMAP(pixmap);
} else if (renderop & RENDER_FORCE_PIXMAP) {
pixmap = simg->pmap->pixmap;
- simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
XCopyArea(Xdisplay, pixmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
IMLIB_FREE_PIXMAP(pixmap);
}
@@ -1080,6 +1097,10 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
and handle exposes by copying from simg->pmap->pixmap. */
XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
}
+ if (!(renderop & RENDER_FORCE_PIXMAP)) {
+ IMLIB_FREE_PIXMAP(simg->pmap->pixmap);
+ simg->pmap->pixmap = None;
+ }
} else {
print_error("Delayed image load failure for \"%s\". Using solid color mode.\n", imlib_image_get_filename());
image_set_mode(which, MODE_SOLID);
@@ -1100,9 +1121,9 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
} else {
if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel != NULL)) {
if (simg->pmap->pixmap) {
- LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
+ LIBAST_X_FREE_PIXMAP(simg->pmap->pixmap);
}
- simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
+ simg->pmap->pixmap = LIBAST_X_CREATE_PIXMAP(width, height);
XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) {
@@ -1117,7 +1138,7 @@ render_simage(simage_t *simg, Window win, unsigned short width, unsigned short h
}
}
XClearWindow(Xdisplay, win);
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return;
}
@@ -1172,7 +1193,6 @@ search_path(const char *pathlist, const char *file)
return name;
}
for (path = pathlist; path != NULL && *path != '\0'; path = p) {
-
int n;
/* colon delimited */
@@ -1185,7 +1205,21 @@ search_path(const char *pathlist, const char *file)
if (n > 0 && n <= maxpath) {
- strncpy(name, path, n);
+ if (*path == '~') {
+ unsigned int l;
+ char *home_dir = getenv("HOME");
+
+ if (home_dir && *home_dir) {
+ l = strlen(home_dir);
+ if (l + n < (unsigned) maxpath) {
+ strcpy(name, home_dir);
+ strncat(name, path + 1, n - 1);
+ n += l - 1;
+ }
+ }
+ } else {
+ strncpy(name, path, n);
+ }
if (name[n - 1] != '/')
name[n++] = '/';
name[n] = '\0';
@@ -1830,7 +1864,7 @@ get_desktop_pixmap(void)
}
if (color_pixmap != None) {
D_PIXMAP(("Removing old solid color pixmap 0x%08x.\n", color_pixmap));
- LIBMEJ_X_FREE_PIXMAP(color_pixmap);
+ LIBAST_X_FREE_PIXMAP(color_pixmap);
color_pixmap = None;
}
if (prop != None) {
@@ -1855,19 +1889,19 @@ get_desktop_pixmap(void)
Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen);
gcvalue.foreground = gcvalue.background = PixColors[bgColor];
- gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
+ gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
XGetGeometry(Xdisplay, p, &w, &px, &py, &pw, &ph, &pb, &pd);
D_PIXMAP(("XGetGeometry() returned w = 0x%08x, pw == %u, ph == %u\n", w, pw, ph));
if (pw < (unsigned int) scr->width || ph < (unsigned int) scr->height) {
- desktop_pixmap = LIBMEJ_X_CREATE_PIXMAP(pw, ph);
+ desktop_pixmap = LIBAST_X_CREATE_PIXMAP(pw, ph);
XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, pw, ph, 0, 0);
colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, pw, ph);
} else {
- desktop_pixmap = LIBMEJ_X_CREATE_PIXMAP(scr->width, scr->height);
+ desktop_pixmap = LIBAST_X_CREATE_PIXMAP(scr->width, scr->height);
XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, scr->width, scr->height, 0, 0);
colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, scr->width, scr->height);
}
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
desktop_pixmap_is_mine = 1;
D_PIXMAP(("Returning 0x%08x\n", (unsigned int) desktop_pixmap));
return (desktop_pixmap);
@@ -1893,12 +1927,12 @@ get_desktop_pixmap(void)
D_PIXMAP((" Found solid color 0x%08x\n", pix));
gcvalue.foreground = pix;
gcvalue.background = pix;
- gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
+ gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
- color_pixmap = LIBMEJ_X_CREATE_PIXMAP(16, 16);
+ color_pixmap = LIBAST_X_CREATE_PIXMAP(16, 16);
XFillRectangle(Xdisplay, color_pixmap, gc, 0, 0, 16, 16);
D_PIXMAP(("Created solid color pixmap 0x%08x for desktop_pixmap.\n", color_pixmap));
- LIBMEJ_X_FREE_GC(gc);
+ LIBAST_X_FREE_GC(gc);
return (desktop_pixmap = color_pixmap);
}
}
@@ -1913,7 +1947,7 @@ free_desktop_pixmap(void)
{
if (desktop_pixmap_is_mine && desktop_pixmap != None) {
- LIBMEJ_X_FREE_PIXMAP(desktop_pixmap);
+ LIBAST_X_FREE_PIXMAP(desktop_pixmap);
desktop_pixmap_is_mine = 0;
}
desktop_pixmap = None;
diff --git a/src/pixmap.h b/src/pixmap.h
index 4fd904a..3a67466 100644
--- a/src/pixmap.h
+++ b/src/pixmap.h
@@ -63,10 +63,10 @@ typedef void *Imlib_Color_Modifier;
# define get_image_type_string(t) ((char *) "")
# define delete_simage(simg) NOP
#endif
-#define LIBMEJ_X_CREATE_PIXMAP(w, h) X_CREATE_PIXMAP(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (w), (h), Xdepth)
-#define LIBMEJ_X_FREE_PIXMAP(p) X_FREE_PIXMAP(Xdisplay, p)
-#define LIBMEJ_X_CREATE_GC(f, gcv) X_CREATE_GC(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (f), (gcv))
-#define LIBMEJ_X_FREE_GC(gc) X_FREE_GC(Xdisplay, gc)
+#define LIBAST_X_CREATE_PIXMAP(w, h) X_CREATE_PIXMAP(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (w), (h), Xdepth)
+#define LIBAST_X_FREE_PIXMAP(p) X_FREE_PIXMAP(Xdisplay, p)
+#define LIBAST_X_CREATE_GC(f, gcv) X_CREATE_GC(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (f), (gcv))
+#define LIBAST_X_FREE_GC(gc) X_FREE_GC(Xdisplay, gc)
#define GEOM_LEN 19
diff --git a/src/scrollbar.c b/src/scrollbar.c
index a0ff818..fbc2012 100644
--- a/src/scrollbar.c
+++ b/src/scrollbar.c
@@ -562,10 +562,14 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) {
return;
}
if (scrollbar_anchor_height() > 1) {
- render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, 0);
+ unsigned char thumb;
+ Pixmap pmap;
+ thumb = (images[image_st].current->iml) ? 1 : 0;
+ render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa, thumb);
+ pmap = images[image_sa].current->pmap->pixmap;
/* Draw the thumb if there is one. */
- if (images[image_st].current->iml) {
+ if (thumb) {
unsigned short tw = 0, th = 0;
imlib_t *iml = images[image_st].current->iml, *siml = images[image_sa].current->iml;
@@ -589,10 +593,12 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) {
UPPER_BOUND(th, scrollbar_anchor_height() >> 1);
D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th));
if ((tw > 0) && (th > 0)) {
- paste_simage(images[image_st].current, image_st, scrollbar.sa_win, images[image_sa].current->pmap->pixmap,
+ paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap,
(scrollbar_anchor_width() - tw) >> 1, (scrollbar_anchor_height() - th) >> 1, tw, th);
- XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, images[image_sa].current->pmap->pixmap);
+ XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap);
XClearWindow(Xdisplay, scrollbar.sa_win);
+ IMLIB_FREE_PIXMAP(pmap);
+ images[image_sa].current->pmap->pixmap = None;
}
}
}
@@ -886,19 +892,19 @@ scrollbar_drawing_init(void) {
gcvalue.fill_style = FillOpaqueStippled;
gcvalue.foreground = PixColors[fgColor];
gcvalue.background = PixColors[bgColor];
- gc_stipple = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue);
+ gc_stipple = LIBAST_X_CREATE_GC(GCForeground | GCBackground | GCFillStyle | GCStipple, &gcvalue);
gcvalue.foreground = PixColors[borderColor];
- gc_border = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ gc_border = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
}
#endif /* XTERM_SCROLLBAR */
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
gcvalue.foreground = images[image_sb].norm->bg;
- gc_scrollbar = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ gc_scrollbar = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[topShadowColor];
- gc_top = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ gc_top = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[bottomShadowColor];
- gc_bottom = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
+ gc_bottom = LIBAST_X_CREATE_GC(GCForeground, &gcvalue);
#endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */
}
diff --git a/src/term.c b/src/term.c
index b4bd996..d283db8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1869,7 +1869,7 @@ xterm_seq(int op, const char *str)
if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) {
free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) {
- LIBMEJ_X_FREE_PIXMAP(viewport_pixmap);
+ LIBAST_X_FREE_PIXMAP(viewport_pixmap);
viewport_pixmap = None; /* Force the re-read */
}
# endif
@@ -1885,7 +1885,7 @@ xterm_seq(int op, const char *str)
if (image_mode_is(which, MODE_TRANS) && (desktop_pixmap != None)) {
free_desktop_pixmap();
} else if (image_mode_is(which, MODE_VIEWPORT) && (viewport_pixmap != None)) {
- LIBMEJ_X_FREE_PIXMAP(viewport_pixmap);
+ LIBAST_X_FREE_PIXMAP(viewport_pixmap);
viewport_pixmap = None; /* Force the re-read */
}
# endif
diff --git a/src/windows.c b/src/windows.c
index 2fcb2b5..21a14ae 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -456,7 +456,7 @@ Create_Windows(int argc, char *argv[])
gcvalue.foreground = PixColors[fgColor];
gcvalue.background = PixColors[bgColor];
gcvalue.graphics_exposures = 0;
- TermWin.gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground | GCFont | GCGraphicsExposures, &gcvalue);
+ TermWin.gc = LIBAST_X_CREATE_GC(GCForeground | GCBackground | GCFont | GCGraphicsExposures, &gcvalue);
}
if (Options & Opt_no_cursor) {
diff --git a/utils/Makefile.am b/utils/Makefile.am
index a1a5c44..533cd94 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -5,7 +5,6 @@ bin_SCRIPTS = Etcolors Etwinop Etsearch kEsetroot
Esetroot_SOURCES = Esetroot.c
Esetroot_LDFLAGS = -rpath $(libdir):$(pkglibdir)
-Esetroot_LDADD = -L$(DIST_ROOT)/libmej
Etbg_SOURCES = Etbg.c
Ettable_SOURCES = Ettable.c