COPYING | 2 configure.ac | 123 ++++++++++++++++++++++++++--------------------- include/X11/Intrinsic.h | 9 +++ include/X11/IntrinsicI.h | 33 ------------ man/Makefile.am | 3 - man/XtAsprintf.man | 1 man/XtMalloc.man | 18 ++++++ src/Alloc.c | 41 +++++++++++++++ src/Error.c | 18 ------ src/Initialize.c | 25 +++------ src/Keyboard.c | 26 +++++---- src/ResConfig.c | 42 +++------------- src/Resources.c | 95 +----------------------------------- src/Selection.c | 2 src/Shell.c | 9 ++- src/Varargs.c | 5 - util/makestrs.c | 3 - 17 files changed, 192 insertions(+), 263 deletions(-)
New commits: commit 994443524ade46bad03eea0acbd1410d561c591d Author: Jeremy Huddleston <jerem...@apple.com> Date: Fri Mar 4 16:30:58 2011 -0800 configure: Bump version to 1.1.0 for release Signed-off-by: Jeremy Huddleston <jerem...@apple.com> diff --git a/configure.ac b/configure.ac index 2c35ea4..e268aa6 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libXt], [1.0.99.1], +AC_INIT([libXt], [1.1.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXt]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) commit c0a233895cc8270ec0ff0bd2abb88d3f6dd524c3 Author: Jeremy Huddleston <jerem...@apple.com> Date: Fri Mar 4 12:49:48 2011 -0800 darwin: Don't use poll() when expected to run on darwin10 and prior Signed-off-by: Jeremy Huddleston <jerem...@apple.com> diff --git a/configure.ac b/configure.ac index 77ce341..2c35ea4 100644 --- a/configure.ac +++ b/configure.ac @@ -67,11 +67,25 @@ AC_SUBST(LDFLAGS_FOR_BUILD) # Map function checks to old Imake #defines case $host_os in - # darwin has poll() but can't be used to poll character devices (atleast through SnowLeopard) - darwin*) ;; + # darwin through Snow Leopard has poll() but can't be used to poll character devices. + darwin@<:@789@:>@*|darwin10*) ;; + darwin*) + _ac_xorg_macosx_version_min="" + if echo $CPPFLAGS $CFLAGS | grep -q mmacosx-version-min ; then + _ac_xorg_macosx_version_min=`echo $CPPFLAGS $CFLAGS | sed 's/^.*-mmacosx-version-min=\(@<:@^ @:>@*\).*$/\1/'` + else + _ac_xorg_macosx_version_min=$MACOSX_DEPLOYMENT_TARGET + fi + case $_ac_xorg_macosx_version_min in + 10.@<:@0123456@:>@|10.@<:@0123456@:>@.*) ;; + *) + AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], ) + ;; + esac + unset _ac_xorg_macosx_version_min + ;; *) - AC_CHECK_FUNC(poll, AC_DEFINE(USE_POLL,1, - [Define to 1 if you have the "poll" function.])) + AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], ) ;; esac commit abf6062715c7d1390e516261a31abde4ed7ea64e Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Feb 2 23:29:46 2011 -0800 Shell.c: TopLevelSetValues ignores iconic state if shell not yet realized Fix originally created by Leo Binchy for Sun to fix Solaris bug 1243761 The XmNiconic resource doesn't work Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/Shell.c b/src/Shell.c index ef6dad2..8a44651 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -2482,6 +2482,10 @@ static Boolean TopLevelSetValues( XFree((XPointer)icon_name.value); } } + else if (new->topLevel.iconic != old->topLevel.iconic) { + if (new->topLevel.iconic) + new->wm.wm_hints.initial_state = IconicState; + } return False; } commit b1eaa18835ec7c3a11e580340625b35c18edf7ca Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Feb 2 23:21:02 2011 -0800 GetResources: protect against underflow when type conversion fails Fix originally created by Leo Binchy for Sun to fix Solaris bug 1211553: XtVaCreateManagedWidget with list of resources XtVaTypedArg cause core dump Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/Resources.c b/src/Resources.c index 304d3d5..dc0f563 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -857,7 +857,7 @@ static XtCacheRef *GetResources( register XtTypedArg* arg = typed_args + typed[j] - 1; register int i; - for (i = num_typed_args - typed[j]; i; i--, arg++) { + for (i = num_typed_args - typed[j]; i > 0; i--, arg++) { *arg = *(arg+1); } num_typed_args--; commit 21c1cc98d8210a3ce2a4bf62ecee9168fdd99dcb Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Feb 2 22:42:13 2011 -0800 Remove unused #ifdef UNALIGNED version of Xt macros & functions Trying to outsmart the compiler and libc is a losing battle, but since UNALIGNED was never defined, we weren't even trying. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/include/X11/IntrinsicI.h b/include/X11/IntrinsicI.h index 26d6036..845ab48 100644 --- a/include/X11/IntrinsicI.h +++ b/include/X11/IntrinsicI.h @@ -108,37 +108,6 @@ SOFTWARE. #define _XBCOPYFUNC _XtBcopy #include <X11/Xfuncs.h> -/* If the alignment characteristics of your machine are right, these may be - faster */ - -#ifdef UNALIGNED - -#define XtMemmove(dst, src, size) \ - if ((char *)(dst) != (char *)(src)) { \ - if (size == sizeof(int)) \ - *((int *) (dst)) = *((int *) (src)); \ - else if (size == sizeof(char)) \ - *((char *) (dst)) = *((char *) (src)); \ - else if (size == sizeof(short)) \ - *((short *) (dst)) = *((short *) (src)); \ - else \ - (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \ - } - -#define XtBZero(dst, size) \ - if (size == sizeof(int)) \ - *((int *) (dst)) = 0; \ - else \ - bzero((char *) (dst), (int) (size)) - -#define XtMemcmp(b1, b2, size) \ - (size == sizeof(int) ? \ - *((int *) (b1)) != *((int *) (b2)) \ - : memcmp((char *) (b1), (char *) (b2), (int) (size)) \ - ) - -#else - #define XtMemmove(dst, src, size) \ if ((char *)(dst) != (char *)(src)) { \ (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \ @@ -150,8 +119,6 @@ SOFTWARE. #define XtMemcmp(b1, b2, size) \ memcmp((char *) (b1), (char *) (b2), (int) (size)) -#endif - /**************************************************************** * diff --git a/src/Resources.c b/src/Resources.c index 67d6860..304d3d5 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -109,92 +109,6 @@ void _XtCopyFromParent( } /* _XtCopyFromParent */ -/* If the alignment characteristics of your machine are right, these may be - faster */ - -#ifdef UNALIGNED - -void _XtCopyFromArg( - XtArgVal src, - char* dst, - register unsigned int size) -{ - if (size == sizeof(long)) *(long *)dst = (long)src; - else if (size == sizeof(short)) *(short *)dst = (short)src; - else if (size == sizeof(char)) *(char *)dst = (char)src; - else if (size == sizeof(XtPointer)) *(XtPointer *)dst = (XtPointer)src; - else if (size == sizeof(char*)) *(char **)dst = (char*)src; - else if (size == sizeof(XtArgVal)) *(XtArgVal *)dst = src; - else if (size > sizeof(XtArgVal)) - (void) memmove((char *) dst, (char *) src, (int) size); - else - (void) memmove((char *) dst, (char *) &src, (int) size); -} /* _XtCopyFromArg */ - -void _XtCopyToArg( - char* src, - XtArgVal *dst, - register unsigned int size) -{ - if (! (*dst)) { -#ifdef GETVALUES_BUG - /* old GetValues semantics (storing directly into arglists) are bad, - * but preserve for compatibility as long as arglist contains NULL. - */ - if (size == sizeof(long)) *dst = (XtArgVal)*(long*)src; - else if (size == sizeof(short)) *dst = (XtArgVal)*(short*)src; - else if (size == sizeof(char)) *dst = (XtArgVal)*(char*)src; - else if (size == sizeof(XtPointer)) *dst = (XtArgVal)*(XtPointer*)src; - else if (size == sizeof(char*)) *dst = (XtArgVal)*(char**)src; - else if (size == sizeof(XtArgVal)) *dst = *(XtArgVal*)src; - else (void) memmove((char*)dst, (char*)src, (int)size); -#else - XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError, - "NULL ArgVal in XtGetValues", (String*) NULL, (Cardinal*) NULL); -#endif - } - else { - /* proper GetValues semantics: argval is pointer to destination */ - if (size == sizeof(long)) *((long*)*dst) = *(long*)src; - else if (size == sizeof(short)) *((short*)*dst) = *(short*)src; - else if (size == sizeof(char)) *((char*)*dst) = *(char*)src; - else if (size == sizeof(XtPointer)) *((XtPointer*)*dst) = *(XtPointer*)src; - else if (size == sizeof(char*)) *((char**)*dst) = *(char**)src; - else if (size == sizeof(XtArgVal)) *((XtArgVal*)*dst)= *(XtArgVal*)src; - else (void) memmove((char*)*dst, (char*)src, (int)size); - } -} /* _XtCopyToArg */ - -static void CopyToArg( - char* src, - XtArgVal *dst, - register unsigned int size) -{ - if (! (*dst)) { - /* old GetValues semantics (storing directly into arglists) are bad, - * but preserve for compatibility as long as arglist contains NULL. - */ - if (size == sizeof(long)) *dst = (XtArgVal)*(long*)src; - else if (size == sizeof(short)) *dst = (XtArgVal)*(short*)src; - else if (size == sizeof(char)) *dst = (XtArgVal)*(char*)src; - else if (size == sizeof(XtPointer)) *dst = (XtArgVal)*(XtPointer*)src; - else if (size == sizeof(char*)) *dst = (XtArgVal)*(char**)src; - else if (size == sizeof(XtArgVal)) *dst = *(XtArgVal*)src; - else (void) memmove((char*)dst, (char*)src, (int)size); - } - else { - /* proper GetValues semantics: argval is pointer to destination */ - if (size == sizeof(long)) *((long*)*dst) = *(long*)src; - else if (size == sizeof(short)) *((short*)*dst) = *(short*)src; - else if (size == sizeof(char)) *((char*)*dst) = *(char*)src; - else if (size == sizeof(XtPointer)) *((XtPointer*)*dst) = *(XtPointer*)src; - else if (size == sizeof(char*)) *((char**)*dst) = *(char**)src; - else if (size == sizeof(XtArgVal)) *((XtArgVal*)*dst)= *(XtArgVal*)src; - else (void) memmove((char*)*dst, (char*)src, (int)size); - } -} /* CopyToArg */ - -#else void _XtCopyFromArg( XtArgVal src, char* dst, @@ -313,7 +227,6 @@ static void CopyToArg( } } /* CopyToArg */ -#endif static Cardinal CountTreeDepth( Widget w) commit 19538f2b4553221b35831e13ec70ed9db436dd32 Author: Gaetan Nadon <mems...@videotron.ca> Date: Wed Feb 2 11:43:44 2011 -0500 config: comment, minor upgrade, quote and layout configure.ac Group statements per section as per Autoconf standard layout Quote statements where appropriate. Autoconf recommends not using dnl instead of # for comments Use AC_CONFIG_FILES to replace the deprecated AC_OUTPUT with parameters. Add AC_CONFIG_SRCDIR([Makefile.am]) This helps automated maintenance and release activities. Details can be found in http://wiki.x.org/wiki/NewModuleGuidelines diff --git a/configure.ac b/configure.ac index 359b2e6..77ce341 100644 --- a/configure.ac +++ b/configure.ac @@ -1,48 +1,57 @@ -dnl -dnl Copyright © 2003 Keith Packard, Noah Levitt -dnl -dnl Permission to use, copy, modify, distribute, and sell this software and its -dnl documentation for any purpose is hereby granted without fee, provided that -dnl the above copyright notice appear in all copies and that both that -dnl copyright notice and this permission notice appear in supporting -dnl documentation, and that the name of Keith Packard not be used in -dnl advertising or publicity pertaining to distribution of the software without -dnl specific, written prior permission. Keith Packard makes no -dnl representations about the suitability of this software for any purpose. It -dnl is provided "as is" without express or implied warranty. -dnl -dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR -dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -dnl PERFORMANCE OF THIS SOFTWARE. -dnl -dnl Process this file with autoconf to create configure. +# +# Copyright © 2003 Keith Packard, Noah Levitt +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Keith Packard not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Keith Packard makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([libXt], [1.0.99.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXt]) -AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) # Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE +# Initialize libtool +AC_PROG_LIBTOOL + # Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS m4_ifndef([XORG_MACROS_VERSION], [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS +XORG_CHECK_MALLOC_ZERO -# Check for progs -AC_PROG_LIBTOOL +# Some compilers do not support per target -c and -o flags AM_PROG_CC_C_O +# Checks for header files. +AC_CHECK_HEADER([alloca.h], AC_DEFINE(INCLUDE_ALLOCA_H, 1, [Define to 1 if Xalloca.h should include <alloca.h>])) + +# Obtain compiler/linker options for depedencies +PKG_CHECK_MODULES(XT, sm ice x11 xproto kbproto) + +# Set-up variables to use build machine compiler when cross-compiling if test x"$CC_FOR_BUILD" = x; then if test x"$cross_compiling" = xyes; then AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) @@ -56,11 +65,6 @@ AC_SUBST(CFLAGS_FOR_BUILD) LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} AC_SUBST(LDFLAGS_FOR_BUILD) -PKG_CHECK_MODULES(XT, sm ice x11 xproto kbproto) - -# Needed for including Xalloca.h -AC_CHECK_HEADER([alloca.h], AC_DEFINE(INCLUDE_ALLOCA_H, 1, [Define to 1 if Xalloca.h should include <alloca.h>])) - # Map function checks to old Imake #defines case $host_os in # darwin has poll() but can't be used to poll character devices (atleast through SnowLeopard) @@ -123,12 +127,11 @@ esac XT_CFLAGS="$XT_CFLAGS $OS_CFLAGS" -XORG_CHECK_MALLOC_ZERO - -AC_OUTPUT([Makefile - src/Makefile - util/Makefile - include/Makefile - man/Makefile - specs/Makefile - xt.pc]) +AC_CONFIG_FILES([Makefile + src/Makefile + util/Makefile + include/Makefile + man/Makefile + specs/Makefile + xt.pc]) +AC_OUTPUT commit 7fd1e98987967b23f66da4b18ebf9798a68cd370 Author: Gaetan Nadon <mems...@videotron.ca> Date: Fri Jan 28 16:07:07 2011 -0500 config: replace deprecated AC_HELP_STRING with AS_HELP_STRING This silences an Automake warning. Signed-off-by: Gaetan Nadon <mems...@videotron.ca> diff --git a/configure.ac b/configure.ac index f429f12..359b2e6 100644 --- a/configure.ac +++ b/configure.ac @@ -74,7 +74,7 @@ esac AC_HAVE_LIBRARY(ws2_32) # Options -AC_ARG_ENABLE(xkb, AC_HELP_STRING([--disable-xkb], [Disable XKB support]), +AC_ARG_ENABLE(xkb, AS_HELP_STRING([--disable-xkb], [Disable XKB support]), XKB="$enableval", XKB="yes") if test "x$XKB" = "xyes" ; then AC_DEFINE(XKB, 1, [Define to 1 to use XKB for keysym resolution.]) @@ -84,13 +84,13 @@ fi XFILESEARCHPATHDEFAULT='$(sysconfdir)/X11/%L/%T/%N%C%S:$(sysconfdir)/X11/%l/%T/%N%C%S:$(sysconfdir)/X11/%T/%N%C%S:$(sysconfdir)/X11/%L/%T/%N%S:$(sysconfdir)/X11/%l/%T/%N%S:$(sysconfdir)/X11/%T/%N%S:$(datadir)/X11/%L/%T/%N%C%S:$(datadir)/X11/%l/%T/%N%C%S:$(datadir)/X11/%T/%N%C%S:$(datadir)/X11/%L/%T/%N%S:$(datadir)/X11/%l/%T/%N%S:$(datadir)/X11/%T/%N%S:$(libdir)/X11/%L/%T/%N%C%S:$(libdir)/X11/%l/%T/%N%C%S:$(libdir)/X11/%T/%N%C%S:$(libdir)/X11/%L/%T/%N%S:$(libdir)/X11/%l/%T/%N%S:$(libdir)/X11/%T/%N%S' AC_ARG_WITH(xfile-search-path, - AC_HELP_STRING([--with-xfile-search-path=<path>], + AS_HELP_STRING([--with-xfile-search-path=<path>], [Set path to search for app-defaults and other files]), [XFILESEARCHPATHDEFAULT="$withval"], []) AC_SUBST([XFILESEARCHPATHDEFAULT]) AC_ARG_WITH(appdefaultdir, - AC_HELP_STRING([--with-appdefaultdir=<path>], + AS_HELP_STRING([--with-appdefaultdir=<path>], [Set app-default directory (default: ${datadir}/X11/app-defaults)]), [appdefaultdir="$withval"], [appdefaultdir=${datadir}/X11/app-defaults]) commit 84e512a94295387bd0625ce619fc8bd381395c71 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Dec 22 10:49:42 2010 -0800 Convert ALLOCATE_LOCAL + sprintf to XtAsprintf Now that we don't need to separately strlen the format string, put it directly into the function call to clear gcc warnings of: Initialize.c:397: warning: format not a string literal, argument types not checked Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/Initialize.c b/src/Initialize.c index 2e70e39..e9543da 100644 --- a/src/Initialize.c +++ b/src/Initialize.c @@ -380,7 +380,7 @@ static void CombineAppUserDefaults( XrmDatabase *pdb) { char* filename; - char* path; + char* path = NULL; Boolean deallocate = False; if (!(path = getenv("XUSERFILESEARCHPATH"))) { @@ -389,20 +389,14 @@ static void CombineAppUserDefaults( char homedir[PATH_MAX]; GetRootDirName(homedir, PATH_MAX); if (!(old_path = getenv("XAPPLRESDIR"))) { - char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N"; - if (!(path = - ALLOCATE_LOCAL(6*strlen(homedir) + strlen(path_default)))) - _XtAllocError(NULL); - sprintf( path, path_default, - homedir, homedir, homedir, homedir, homedir, homedir ); + XtAsprintf(&path, + "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N", + homedir, homedir, homedir, homedir, homedir, homedir); } else { - char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N"; - if (!(path = - ALLOCATE_LOCAL( 6*strlen(old_path) + 2*strlen(homedir) - + strlen(path_default)))) - _XtAllocError(NULL); - sprintf(path, path_default, old_path, old_path, old_path, homedir, - old_path, old_path, old_path, homedir ); + XtAsprintf(&path, + "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N", + old_path, old_path, old_path, homedir, + old_path, old_path, old_path, homedir); } deallocate = True; #endif @@ -414,7 +408,8 @@ static void CombineAppUserDefaults( XtFree(filename); } - if (deallocate) DEALLOCATE_LOCAL(path); + if (deallocate) + XtFree(path); } static void CombineUserDefaults( commit c80650fddec8596ef7278e37aa12ce2076c54e93 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Thu Dec 9 23:36:31 2010 -0800 Convert ResConfig.c to use XtAsprintf() instead of XtMalloc + sprintf Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/ResConfig.c b/src/ResConfig.c index 63afb18..68da536 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -174,18 +174,13 @@ _set_resource_values ( * create resource name string */ if (resource_name) { - temp = XtMalloc (sizeof(char) * - (2 + strlen(cur->core.name) - + strlen(resource_name))); - sprintf (temp, ".%s%s", cur->core.name, resource_name); + XtAsprintf (&temp, ".%s%s", cur->core.name, resource_name); XtFree (resource_name); } else if (!XtIsWidget (cur) || !cur->core.name) { cur = XtParent(cur); continue; } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen(cur->core.name))); - sprintf (temp, ".%s", cur->core.name); + XtAsprintf (&temp, ".%s", cur->core.name); } resource_name = temp; @@ -197,31 +192,19 @@ _set_resource_values ( (ApplicationShellWidget) (cur); if (resource_class) { - temp = XtMalloc (sizeof(char) * - (2 + strlen(top->application.class) - + strlen(resource_class))); - sprintf (temp, ".%s%s", + XtAsprintf (&temp, ".%s%s", top->application.class, resource_class); } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen(top->application.class))); - sprintf (temp, ".%s", + XtAsprintf (&temp, ".%s", top->application.class); } } else { if (resource_class) { - temp = XtMalloc (sizeof(char) * - (2 + strlen( - cur->core.widget_class->core_class.class_name) - + strlen(resource_class))); - sprintf (temp, ".%s%s", + XtAsprintf (&temp, ".%s%s", cur->core.widget_class->core_class.class_name, resource_class); } else { - temp = XtMalloc (sizeof(char) * - (2 + strlen( - cur->core.widget_class->core_class.class_name))); - sprintf (temp, ".%s", + XtAsprintf (&temp, ".%s", cur->core.widget_class->core_class.class_name); } } @@ -235,9 +218,7 @@ _set_resource_values ( /* * add the resource name to the end of the resource name string */ - temp = XtMalloc (2 + strlen(resource_name) + - strlen(resources_return[res_index].resource_name)); - sprintf (temp, "%s.%s", resource_name, + XtAsprintf (&temp, "%s.%s", resource_name, resources_return[res_index].resource_name); if (resource_name != NULL) XtFree (resource_name); @@ -246,9 +227,7 @@ _set_resource_values ( /* * add the resource class to the end of the resource class string */ - temp = XtMalloc (2 + strlen(resource_class) + - strlen(resources_return[res_index].resource_class)); - sprintf (temp, "%s.%s", resource_class, + XtAsprintf (&temp, "%s.%s", resource_class, resources_return[res_index].resource_class); if (resource_class != NULL) XtFree (resource_class); @@ -757,8 +736,7 @@ _search_widget_tree ( */ } else { if (remainder[0] != '*' && remainder[0] != '.') { - copy = XtMalloc (strlen(remainder) + 2); - sprintf (copy, ".%s", remainder); + XtAsprintf (©, ".%s", remainder); XtFree (remainder); remainder = copy; } commit ac07da253415ccb8b6322feedf7969967357050e Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Wed Jan 12 23:09:29 2011 -0800 Add XtAsprintf() as a new exported API Like asprintf() but using XtMalloc() to tie into the Xt memory allocation and error handling subsystems. Bumps libXt version to 1.0.99.1 so that modules can set their pkg-config dependency to libXt >= 1.0.99.1 to require XtAsprintf(). Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/COPYING b/COPYING index 5507aa4..9e121b1 100644 --- a/COPYING +++ b/COPYING @@ -19,7 +19,7 @@ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1993, 2011, Oracle and/or its affiliates. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/configure.ac b/configure.ac index ed295e0..f429f12 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl Process this file with autoconf to create configure. # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libXt], [1.0.9], +AC_INIT([libXt], [1.0.99.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXt]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([Makefile.am]) diff --git a/include/X11/Intrinsic.h b/include/X11/Intrinsic.h index 5111537..d09acad 100644 --- a/include/X11/Intrinsic.h +++ b/include/X11/Intrinsic.h @@ -1855,6 +1855,15 @@ extern void XtFree( char* /* ptr */ ); +#ifndef _X_RESTRICT_KYWD +# define _X_RESTRICT_KYWD +#endif +extern Cardinal XtAsprintf( + String *new_string, + _Xconst char * _X_RESTRICT_KYWD format, + ... +) _X_ATTRIBUTE_PRINTF(2,3); + #ifdef XTTRACEMEMORY extern char *_XtMalloc( /* implementation-private */ diff --git a/man/Makefile.am b/man/Makefile.am index 005c2d5..305598d 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -330,7 +330,8 @@ XtMalloc_shadows = \ XtRealloc \ XtFree \ XtNew \ - XtNewString + XtNewString \ + XtAsprintf XtManageChildren_shadows = \ XtManageChild \ diff --git a/man/XtAsprintf.man b/man/XtAsprintf.man new file mode 100644 index 0000000..50eaf76 --- /dev/null +++ b/man/XtAsprintf.man @@ -0,0 +1 @@ +.so man__libmansuffix__/XtMalloc.__libmansuffix__ diff --git a/man/XtMalloc.man b/man/XtMalloc.man index 396218b..70183ec 100644 --- a/man/XtMalloc.man +++ b/man/XtMalloc.man @@ -139,6 +139,8 @@ void XtFree(char *\fIptr\fP); \fItype\fP *XtNew(\fItype\fP); .HP String XtNewString(String \fIstring\fP); +.HP +Cardinal XtAsprintf(String *\fInew_string\fP, const char *\fIformat\fP, ...); .SH ARGUMENTS .IP \fInum\fP 1i Specifies the number of bytes or array elements. @@ -152,6 +154,10 @@ desired. Specifies a previously declared string. .IP \fItype\fP 1i Specifies a previously declared data type. +.IP \fInew_string\fP 1i +Specifies a pointer to write a newly allocated string to. +.IP \fIformat\fP 1i +Specifies a formatting string as defined by sprintf(3c) .SH DESCRIPTION The .ZN XtMalloc @@ -226,6 +232,18 @@ with the following arguments specified: .ta .5i (strcpy(XtMalloc((unsigned) strlen(str) + 1), str)) .De +.LP +The +.ZN XtAsprintf +function allocates space for a string large enough to hold the string +specified by the sprintf(3c) format pattern when used with the remaining +arguments, and fills it with the formatted results. +The address of the allocated string is placed into the pointer passed as ret. +The length of the string (not including the terminating null byte) is returned. +If there is insufficient memory to allocate the new block, +.ZN XtAsprintf +calls +.ZN XtErrorMsg . .SH "SEE ALSO" .br \fI\*(xT\fP diff --git a/src/Alloc.c b/src/Alloc.c index 94cb90a..67413ab 100644 --- a/src/Alloc.c +++ b/src/Alloc.c @@ -1,5 +1,5 @@ /*********************************************************** -Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 1993, 2011, Oracle and/or its affiliates. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -82,6 +82,8 @@ in this Software without prior written authorization from The Open Group. #undef _XBCOPYFUNC #include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> #define Xmalloc(size) malloc((size)) #define Xrealloc(ptr, size) realloc((ptr), (size)) @@ -121,6 +123,43 @@ void _XtHeapInit( heap->bytes_remaining = 0; } +/* Version of asprintf() using XtMalloc + * Not currently available in XTTRACEMEMORY version, since that would + * require varargs macros everywhere, which are only standard in C99 & later. + */ +Cardinal XtAsprintf( + String *new_string, + _Xconst char * _X_RESTRICT_KYWD format, + ...) +{ + char buf[256]; + Cardinal len; + va_list ap; + + va_start(ap, format); + len = vsnprintf(buf, sizeof(buf), format, ap); + va_end(ap); + + if (len < 0) + _XtAllocError("vsnprintf"); + + *new_string = XtMalloc(len + 1); /* snprintf doesn't count trailing '\0' */ + if (len < sizeof(buf)) + { + strncpy(*new_string, buf, len); + new_string[len] = '\0'; + } + else + { + va_start(ap, format); + if (vsnprintf(*new_string, len + 1, format, ap) < 0) + _XtAllocError("vsnprintf"); + va_end(ap); + } + return len; +} + + #ifndef XTTRACEMEMORY char *XtMalloc( commit 84f73c49db8071c06f27609ce7cc7a32a17351a9 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Thu Dec 9 23:44:42 2010 -0800 Convert some sprintf calls to snprintf Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Julien Cristau <jcris...@debian.org> diff --git a/src/Selection.c b/src/Selection.c index 1759c02..101ea6a 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -226,7 +226,7 @@ static Atom GetSelectionProperty( propCount = sarray->propCount++; sarray->list = (SelectionProp) XtRealloc((XtPointer)sarray->list, (unsigned)(sarray->propCount*sizeof(SelectionPropRec))); - (void) sprintf(propname, "%s%d", "_XT_SELECTION_", propCount); + (void) snprintf(propname, sizeof(propname), "_XT_SELECTION_%d", propCount); sarray->list[propCount].prop = XInternAtom(dpy, propname, FALSE); sarray->list[propCount].avail = FALSE; return(sarray->list[propCount].prop); diff --git a/src/Shell.c b/src/Shell.c index 732e978..ef6dad2 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -1780,7 +1780,8 @@ static void GetGeometry( } else hints.flags = 0; - sprintf( def_geom, "%dx%d+%d+%d", width, height, x, y ); + snprintf( def_geom, sizeof(def_geom), "%dx%d+%d+%d", + width, height, x, y ); flag = XWMGeometry( XtDisplay(W), XScreenNumberOfScreen(XtScreen(W)), w->shell.geometry, def_geom, @@ -3013,7 +3014,7 @@ static void SetSessionProperties( user_name = _XtGetUserName(nam_buf, sizeof nam_buf); if (user_name) props[num_props++] = ArrayPack(SmUserID, &user_name); - sprintf(pid, "%ld", (long)getpid()); + snprintf(pid, sizeof(pid), "%ld", (long)getpid()); props[num_props++] = ArrayPack(SmProcessID, &pidp); if (num_props) { commit 14145f3e87a039640cd8bdb2e2f4f30ca9b2a710 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Dec 5 01:21:06 2010 -0800 config: AC_PROG_CC is provided by XORG_DEFAULT_OPTIONS now Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 82b2699..ed295e0 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,6 @@ XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS # Check for progs -AC_PROG_CC AC_PROG_LIBTOOL AM_PROG_CC_C_O commit a73b8f06b95216083c8335fad45dd0de7f44a529 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Dec 5 01:19:10 2010 -0800 config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS Regroup AC statements under the Autoconf initialization section. Regroup AM statements under the Automake initialization section. Add missing AC_CONFIG_SRCDIR Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index c75e832..82b2699 100644 --- a/configure.ac +++ b/configure.ac @@ -21,13 +21,15 @@ dnl PERFORMANCE OF THIS SOFTWARE. dnl dnl Process this file with autoconf to create configure. +# Initialize Autoconf AC_PREREQ([2.60]) - -dnl -dnl AC_INIT([libXt], [1.0.9], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXt]) AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) + +# Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE @@ -36,7 +38,6 @@ m4_ifndef([XORG_MACROS_VERSION], [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS -AM_CONFIG_HEADER(config.h) # Check for progs AC_PROG_CC commit 2bf988d229d2b85208cc42094ce7202204d628af Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Dec 5 00:33:44 2010 -0800 Remove ancient #if defined(macII) hack for A/UX from makestrs.c Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/util/makestrs.c b/util/makestrs.c index 3551cc1..902d461 100644 --- a/util/makestrs.c +++ b/util/makestrs.c @@ -30,9 +30,6 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xos.h> #include <stdlib.h> #include <unistd.h> -#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */ -char *malloc(); -#endif /* macII */ typedef struct _TableEnt { struct _TableEnt* next; commit 96508e1b9da790d4b824a42246d1e86379101733 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Dec 5 00:19:30 2010 -0800 Remove non-USE_SNPRINTF case from src/Error.c unifdef -DUSE_SNPRINTF src/Error.c Plus manual removal of old #ifdef notyet section that said not enough platforms had snprintf support yet. Welcome to the new millenium! Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index ae3db02..c75e832 100644 --- a/configure.ac +++ b/configure.ac @@ -70,8 +70,6 @@ case $host_os in [Define to 1 if you have the "poll" function.])) ;; esac -AC_CHECK_FUNC(snprintf, AC_DEFINE(USE_SNPRINTF,1, - [Define to 1 if you have the "snprintf" function.])) AC_HAVE_LIBRARY(ws2_32) diff --git a/src/Error.c b/src/Error.c index 1112ef9..fc9b11a 100644 --- a/src/Error.c +++ b/src/Error.c -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1pvti2-00040n...@alioth.debian.org