Module Name:    xsrc
Committed By:   martin
Date:           Mon Dec 19 13:20:17 UTC 2022

Modified Files:
        xsrc/external/mit/libX11/dist: ChangeLog README.md aclocal.m4 configure
            configure.ac
        xsrc/external/mit/libX11/dist/include/X11: Xlib.h Xlibint.h
        xsrc/external/mit/libX11/dist/man: XInitThreads.man
        xsrc/external/mit/libX11/dist/modules/im/ximcp: imLcLkup.c imLcPrs.c
        xsrc/external/mit/libX11/dist/nls/en_US.UTF-8: XLC_LOCALE.pre
        xsrc/external/mit/libX11/dist/src: ChkIfEv.c CrGlCur.c IfEvent.c
            OpenDis.c PeekIfEv.c PutBEvent.c globals.c locking.c
        xsrc/external/mit/libX11/dist/src/xkb: XKBBind.c

Log Message:
Argh, undo "revert" commit to wrong branch


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libX11/dist/ChangeLog \
    xsrc/external/mit/libX11/dist/README.md \
    xsrc/external/mit/libX11/dist/aclocal.m4 \
    xsrc/external/mit/libX11/dist/configure \
    xsrc/external/mit/libX11/dist/configure.ac
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libX11/dist/include/X11/Xlib.h \
    xsrc/external/mit/libX11/dist/include/X11/Xlibint.h
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libX11/dist/man/XInitThreads.man
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c
cvs rdiff -u -r1.2 -r1.3 \
    xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c
cvs rdiff -u -r1.2 -r1.3 \
    xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libX11/dist/src/ChkIfEv.c \
    xsrc/external/mit/libX11/dist/src/CrGlCur.c \
    xsrc/external/mit/libX11/dist/src/IfEvent.c \
    xsrc/external/mit/libX11/dist/src/OpenDis.c \
    xsrc/external/mit/libX11/dist/src/PeekIfEv.c \
    xsrc/external/mit/libX11/dist/src/PutBEvent.c \
    xsrc/external/mit/libX11/dist/src/globals.c \
    xsrc/external/mit/libX11/dist/src/locking.c
cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/libX11/dist/ChangeLog
diff -u xsrc/external/mit/libX11/dist/ChangeLog:1.2 xsrc/external/mit/libX11/dist/ChangeLog:1.3
--- xsrc/external/mit/libX11/dist/ChangeLog:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/ChangeLog	Mon Dec 19 13:20:16 2022
@@ -1,3 +1,125 @@
+commit 48487c4b9028e9eec5371742f51e1d64c2e17296
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Thu Dec 15 14:52:20 2022 -0800
+
+    libX11 1.8.3
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit d6d6cba90215d323567fef13d6565756c9956f60
+Author: Keith Packard <kei...@keithp.com>
+Date:   Sun Dec 11 10:32:26 2022 -0800
+
+    Update XPutBackEvent() to support clients that put back unpadded events
+    
+    It seems to be common practice of some X11 clients to pass specific event
+    types into APIs that take XEvent*.  For example, freeglut does:
+    
+       XConfigureEvent fakeEvent = {0};
+       ...
+       XPutBackEvent(fgDisplay.Display, (XEvent*)&fakeEvent);
+    
+    This can result in reads overflowing the input event when libX11 does:
+    
+       XEvent store = *event;
+    
+    =================================================================
+    ==75304==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00016ee4a8e8 at pc 0x000101c54d14 bp 0x00016ee4a0d0 sp 0x00016ee49888
+    READ of size 192 at 0x00016ee4a8e8 thread T0
+        #0 0x101c54d10 in __asan_memcpy+0x1a4 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x3cd10)
+        #1 0x102848a18 in _XPutBackEvent PutBEvent.c:41
+        #2 0x1028490a4 in XPutBackEvent PutBEvent.c:84
+        #3 0x1013295c8 in fgOpenWindow freeglut_window.c:1178
+        #4 0x101321984 in fgCreateWindow freeglut_structure.c:108
+        #5 0x10132b138 in glutCreateWindow freeglut_window.c:1551
+        #6 0x100fb7d94 in main+0x78 (checkeredTriangles:arm64+0x100003d94)
+        #7 0x197de3e4c  (<unknown module>)
+    
+    Address 0x00016ee4a8e8 is located in stack of thread T0 at offset 840 in frame
+        #0 0x1013282f8 in fgOpenWindow freeglut_window.c:1063
+    
+      This frame has 8 object(s):
+        [32, 40) 'title.addr'
+        [64, 176) 'winAttr' (line 1066)
+        [208, 240) 'textProperty' (line 1067)
+        [272, 352) 'sizeHints' (line 1068)
+        [384, 440) 'wmHints' (line 1069)
+        [480, 672) 'eventReturnBuffer' (line 1070)
+        [736, 740) 'num_FBConfigs' (line 1072)
+        [752, 840) 'fakeEvent' (line 1074) <== Memory access at offset 840 overflows this variable
+    
+    This change allows XPutBackEvent() to support such clients without
+    risk of memory read overflow.
+    
+    Reviewed-by: Jeremy Huddleston Sequoia <jerem...@apple.com>
+    Tested-by: Jeremy Huddleston Sequoia <jerem...@apple.com>
+
+commit 496d9bfeedda89a2211ec665f9214c2693c022f4
+Author: Jeremy Huddleston Sequoia <jerem...@apple.com>
+Date:   Sat Dec 3 16:26:47 2022 -0800
+
+    ximcp: Address warning found by UBSan when growing an empty tree
+    
+    imLcPrs.c:681:52: runtime error: applying zero offset to null pointer
+    
+    Signed-off-by: Jeremy Huddleston Sequoia <jerem...@apple.com>
+
+commit 7f7bcd7b6f569e9f70e3ddd134924f178e2596b1
+Author: Takao Fujiwara <tfuji...@redhat.com>
+Date:   Tue Dec 6 16:59:56 2022 +0000
+
+    nls: consecutive cs number in en_US.UTF-8/XLC_LOCALE
+
+commit ba095967349dff583bd0989d0ba78aa334e9bedf
+Author: Ulrich Sibiller <ul...@gmx.de>
+Date:   Wed Nov 30 23:47:29 2022 +0100
+
+    ChkIfEv.c: fix wrong handling of dpy->in_ifevent
+    
+    Is no longer a bool but a counter.
+    
+    Signed-off-by: Ulrich Sibiller <ul...@gmx.de>
+
+commit 70eaf1174e2809d1a6c43868d53f8cd844ef636a
+Author: Ulrich Sibiller <ul...@gmx.de>
+Date:   Wed Nov 30 23:42:02 2022 +0100
+
+    Indentation fixes around recent dpy->in_ifevent changes
+    
+    Use the same indentation as the surrounding code.
+    
+    Signed-off-by: Ulrich Sibiller <ul...@gmx.de>
+    Reviewed-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit a9e845809bcaae22496bc8aa3ca252b410d5f39b
+Author: Matthieu Herrb <matth...@herrb.eu>
+Date:   Fri Nov 11 18:55:23 2022 +0100
+
+    Fix 797755 Allow X*IfEvent() to reenter libX11
+    
+    - the activation logic is reversed
+    - there is also _XInternalLockDisplay() that needs protection
+    - I've found cases (in fvwm2) where the callback calls XCheckIfEvent()
+      recursively. So the flag needs to be a counter.
+    
+    Reviewed-by: Adam Jackson <a...@redhat.com>
+
+commit bccd787a565d3a88673bfc06574c1939f98d8d72
+Author: Nia Alarie <n...@netbsd.org>
+Date:   Thu Nov 10 22:31:47 2022 +0100
+
+    Don't use pragma inside a function, it breaks compiling with older GCCs.
+    
+    XKBBind.c:230: error: #pragma GCC diagnostic not allowed inside functions
+    
+    Signed-off-by: Thomas Klausner <w...@gatalith.at>
+
+commit 696d19d5db7bcb1c1f582c2b1846520e7e0870cb
+Author: Oliver <halt...@riseup.net>
+Date:   Fri Nov 11 17:04:00 2022 +0000
+
+    Add XFreeThreads function.
+
 commit b4f24b272c6ef888b6fcfcf80670c196b2e8f755
 Author: Alan Coopersmith <alan.coopersm...@oracle.com>
 Date:   Thu Nov 10 12:18:17 2022 -0800
Index: xsrc/external/mit/libX11/dist/README.md
diff -u xsrc/external/mit/libX11/dist/README.md:1.2 xsrc/external/mit/libX11/dist/README.md:1.3
--- xsrc/external/mit/libX11/dist/README.md:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/README.md	Mon Dec 19 13:20:16 2022
@@ -31,6 +31,15 @@ For patch submission instructions, see:
 
   https://www.x.org/wiki/Development/Documentation/SubmittingPatches
 
+## Release 1.8.3
+
+ * Improved handling of reentering libX11 via X*IfEvent() calls (!171, !173)
+ * Fix loading of en_US.UTF-8/XLC_LOCALE (#167, !174)
+ * Add XFreeThreads() and automatic call from a destructor function when
+   thread-safety-constructor is enabled (!167).
+ * Address issues found by UBSan and AddressSanitizer
+ * Fix build with older gcc versions (!169)
+
 ## Release 1.8.2
 
  * Allow X*IfEvent() to reenter libX11 to avoid deadlock from unsafe
Index: xsrc/external/mit/libX11/dist/aclocal.m4
diff -u xsrc/external/mit/libX11/dist/aclocal.m4:1.2 xsrc/external/mit/libX11/dist/aclocal.m4:1.3
--- xsrc/external/mit/libX11/dist/aclocal.m4:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/aclocal.m4	Mon Dec 19 13:20:16 2022
@@ -1793,7 +1793,7 @@ AC_SUBST(MAKE_HTML)
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-xmlto option, it allows maximum flexibilty in making decisions
+# the --with-xmlto option, it allows maximum flexibility in making decisions
 # as whether or not to use the xmlto package. When DEFAULT is not specified,
 # --with-xmlto assumes 'auto'.
 #
@@ -2007,7 +2007,7 @@ AM_CONDITIONAL([HAVE_PERL], [test "$have
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-asciidoc option, it allows maximum flexibilty in making decisions
+# the --with-asciidoc option, it allows maximum flexibility in making decisions
 # as whether or not to use the asciidoc package. When DEFAULT is not specified,
 # --with-asciidoc assumes 'auto'.
 #
@@ -2077,7 +2077,7 @@ AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-doxygen option, it allows maximum flexibilty in making decisions
+# the --with-doxygen option, it allows maximum flexibility in making decisions
 # as whether or not to use the doxygen package. When DEFAULT is not specified,
 # --with-doxygen assumes 'auto'.
 #
@@ -2161,7 +2161,7 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test "$h
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-groff option, it allows maximum flexibilty in making decisions
+# the --with-groff option, it allows maximum flexibility in making decisions
 # as whether or not to use the groff package. When DEFAULT is not specified,
 # --with-groff assumes 'auto'.
 #
@@ -2269,7 +2269,7 @@ AM_CONDITIONAL([HAVE_GROFF_HTML], [test 
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-fop option, it allows maximum flexibilty in making decisions
+# the --with-fop option, it allows maximum flexibility in making decisions
 # as whether or not to use the fop package. When DEFAULT is not specified,
 # --with-fop assumes 'auto'.
 #
@@ -2363,7 +2363,7 @@ AC_SUBST([M4], [$ac_cv_path_M4])
 # Documentation tools are not always available on all platforms and sometimes
 # not at the appropriate level. This macro enables a module to test for the
 # presence of the tool and obtain it's path in separate variables. Coupled with
-# the --with-ps2pdf option, it allows maximum flexibilty in making decisions
+# the --with-ps2pdf option, it allows maximum flexibility in making decisions
 # as whether or not to use the ps2pdf package. When DEFAULT is not specified,
 # --with-ps2pdf assumes 'auto'.
 #
@@ -2418,7 +2418,7 @@ AM_CONDITIONAL([HAVE_PS2PDF], [test "$ha
 # not at the appropriate level. This macro enables a builder to skip all
 # documentation targets except traditional man pages.
 # Combined with the specific tool checking macros XORG_WITH_*, it provides
-# maximum flexibilty in controlling documentation building.
+# maximum flexibility in controlling documentation building.
 # Refer to:
 # XORG_WITH_XMLTO         --with-xmlto
 # XORG_WITH_ASCIIDOC      --with-asciidoc
@@ -2451,7 +2451,7 @@ AC_MSG_RESULT([$build_docs])
 #
 # This macro enables a builder to skip all developer documentation.
 # Combined with the specific tool checking macros XORG_WITH_*, it provides
-# maximum flexibilty in controlling documentation building.
+# maximum flexibility in controlling documentation building.
 # Refer to:
 # XORG_WITH_XMLTO         --with-xmlto
 # XORG_WITH_ASCIIDOC      --with-asciidoc
@@ -2484,7 +2484,7 @@ AC_MSG_RESULT([$build_devel_docs])
 #
 # This macro enables a builder to skip all functional specification targets.
 # Combined with the specific tool checking macros XORG_WITH_*, it provides
-# maximum flexibilty in controlling documentation building.
+# maximum flexibility in controlling documentation building.
 # Refer to:
 # XORG_WITH_XMLTO         --with-xmlto
 # XORG_WITH_ASCIIDOC      --with-asciidoc
@@ -2975,7 +2975,7 @@ AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"
 # Minimum version: 1.16.0
 #
 # Test if the compiler works when passed the given flag as a command line argument.
-# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
+# If it succeeds, the flag is appended to the given variable.  If not, it tries the
 # next flag in the list until there are no more options.
 #
 # Note that this does not guarantee that the compiler supports the flag as some
@@ -3132,7 +3132,7 @@ XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]
 # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
 # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
 
-# Turn some warnings into errors, so we don't accidently get successful builds
+# Turn some warnings into errors, so we don't accidentally get successful builds
 # when there are problems that should be fixed.
 
 if test "x$SELECTIVE_WERROR" = "xyes" ; then
Index: xsrc/external/mit/libX11/dist/configure
diff -u xsrc/external/mit/libX11/dist/configure:1.2 xsrc/external/mit/libX11/dist/configure:1.3
--- xsrc/external/mit/libX11/dist/configure:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/configure	Mon Dec 19 13:20:17 2022
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for libX11 1.8.2.
+# Generated by GNU Autoconf 2.71 for libX11 1.8.3.
 #
 # Report bugs to <https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues>.
 #
@@ -682,8 +682,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libX11'
 PACKAGE_TARNAME='libX11'
-PACKAGE_VERSION='1.8.2'
-PACKAGE_STRING='libX11 1.8.2'
+PACKAGE_VERSION='1.8.3'
+PACKAGE_STRING='libX11 1.8.3'
 PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues'
 PACKAGE_URL=''
 
@@ -1551,7 +1551,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libX11 1.8.2 to adapt to many kinds of systems.
+\`configure' configures libX11 1.8.3 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1622,7 +1622,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libX11 1.8.2:";;
+     short | recursive ) echo "Configuration of libX11 1.8.3:";;
    esac
   cat <<\_ACEOF
 
@@ -1794,7 +1794,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libX11 configure 1.8.2
+libX11 configure 1.8.3
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2262,7 +2262,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libX11 $as_me 1.8.2, which was
+It was created by libX11 $as_me 1.8.3, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -4910,7 +4910,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libX11'
- VERSION='1.8.2'
+ VERSION='1.8.3'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -15908,7 +15908,7 @@ printf "%s\n" "$supported" >&6; }
 # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align])
 # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual])
 
-# Turn some warnings into errors, so we don't accidently get successful builds
+# Turn some warnings into errors, so we don't accidentally get successful builds
 # when there are problems that should be fixed.
 
 if test "x$SELECTIVE_WERROR" = "xyes" ; then
@@ -23674,7 +23674,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libX11 $as_me 1.8.2, which was
+This file was extended by libX11 $as_me 1.8.3, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -23742,7 +23742,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-libX11 config.status 1.8.2
+libX11 config.status 1.8.3
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
Index: xsrc/external/mit/libX11/dist/configure.ac
diff -u xsrc/external/mit/libX11/dist/configure.ac:1.2 xsrc/external/mit/libX11/dist/configure.ac:1.3
--- xsrc/external/mit/libX11/dist/configure.ac:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/configure.ac	Mon Dec 19 13:20:17 2022
@@ -1,7 +1,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([libX11], [1.8.2],
+AC_INIT([libX11], [1.8.3],
         [https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues], [libX11])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([src/config.h include/X11/XlibConf.h])

Index: xsrc/external/mit/libX11/dist/include/X11/Xlib.h
diff -u xsrc/external/mit/libX11/dist/include/X11/Xlib.h:1.2 xsrc/external/mit/libX11/dist/include/X11/Xlib.h:1.3
--- xsrc/external/mit/libX11/dist/include/X11/Xlib.h:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/include/X11/Xlib.h	Mon Dec 19 13:20:17 2022
@@ -1735,6 +1735,10 @@ extern Status XInitThreads(
     void
 );
 
+extern Status XFreeThreads(
+    void
+);
+
 extern void XLockDisplay(
     Display*		/* display */
 );
Index: xsrc/external/mit/libX11/dist/include/X11/Xlibint.h
diff -u xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.2 xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.3
--- xsrc/external/mit/libX11/dist/include/X11/Xlibint.h:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/include/X11/Xlibint.h	Mon Dec 19 13:20:17 2022
@@ -207,7 +207,7 @@ struct _XDisplay
 
 	XIOErrorExitHandler exit_handler;
 	void *exit_handler_data;
-        Bool in_ifevent;
+        CARD32 in_ifevent;
 };
 
 #define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)

Index: xsrc/external/mit/libX11/dist/man/XInitThreads.man
diff -u xsrc/external/mit/libX11/dist/man/XInitThreads.man:1.2 xsrc/external/mit/libX11/dist/man/XInitThreads.man:1.3
--- xsrc/external/mit/libX11/dist/man/XInitThreads.man:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/man/XInitThreads.man	Mon Dec 19 13:20:17 2022
@@ -52,6 +52,8 @@ XInitThreads, XLockDisplay, XUnlockDispl
 .HP
 Status XInitThreads\^(void);
 .HP
+Status XFreeThreads\^(void);
+.HP
 void XLockDisplay\^(\^Display *\fIdisplay\fP\^);
 .HP
 void XUnlockDisplay\^(\^Display *\fIdisplay\fP\^);
@@ -76,7 +78,11 @@ are protected by some other access mecha
 a mutual exclusion lock in a toolkit or through explicit client
 programming), Xlib thread initialization is not required.
 It is recommended that single-threaded programs not call this function.
-
+.LP
+The
+.B XFreeThreads
+function frees the memory allocated by
+.BR XInitThreads .
 .LP
 The
 .B XLockDisplay

Index: xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c
diff -u xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c:1.3 xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c:1.4
--- xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c:1.3	Tue Aug 28 05:52:12 2018
+++ xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcLkup.c	Mon Dec 19 13:20:17 2022
@@ -219,9 +219,9 @@ _XimLocalUtf8LookupString(XIC xic, XKeyE
 		if(status) *status = XBufferOverflow;
 		return (ret);
 	    }
-	    buffer[0] = (char)(0xe0 | ((BRL_UC_ROW >> 12) & 0x0f));
-	    buffer[1] = (char)(0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6));
-	    buffer[2] = (char)(0x80 | (pattern & 0x3f));
+	    buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f);
+	    buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6);
+	    buffer[2] = 0x80 | (pattern & 0x3f);
 	    if(keysym) {
 		*keysym = XK_braille_blank | pattern;
 		if(status) *status = XLookupBoth;

Index: xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c
diff -u xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c:1.2 xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c:1.3
--- xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/modules/im/ximcp/imLcPrs.c	Mon Dec 19 13:20:17 2022
@@ -678,7 +678,7 @@ parseline(
 		b->treesize = newsize;
 		/* Re-derive top after realloc() to avoid undefined behaviour
 		   (and crashes on architectures that track pointer bounds). */
-		if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
+		if (old && top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
 		    top = (DTIndex *) (((char *)new) + (((char *)top)-(char *)old));
 	    }
 	    p = &b->tree[b->treeused];

Index: xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre
diff -u xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre:1.2 xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre:1.3
--- xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre:1.2	Mon Dec 19 13:19:00 2022
+++ xsrc/external/mit/libX11/dist/nls/en_US.UTF-8/XLC_LOCALE.pre	Mon Dec 19 13:20:17 2022
@@ -219,73 +219,73 @@ cs5     {
         ct_encoding     ISO8859-5:GR
 }
  
-XCOMM	cs7 class
-cs7     {
+XCOMM	cs6 class
+cs6     {
         side            GR
         length          1
         ct_encoding     ISO8859-7:GR
 }
  
-XCOMM	cs8 class
-cs8     {
+XCOMM	cs7 class
+cs7     {
         side            GR
         length          1
         ct_encoding     ISO8859-9:GR
 }
  
-XCOMM	cs9 class
-cs9     {
+XCOMM	cs8 class
+cs8     {
         side            GR
         length          1
         ct_encoding     ISO8859-13:GR
 }
  
-XCOMM	cs10 class
-cs10     {
+XCOMM	cs9 class
+cs9     {
         side            GR
         length          1
         ct_encoding     ISO8859-14:GR
 }
  
-XCOMM	cs11 class
-cs11     {
+XCOMM	cs10 class
+cs10    {
         side            GR
         length          1
         ct_encoding     ISO8859-15:GR
 }
  
-XCOMM	cs12 class
-cs12	{
+XCOMM	cs11 class
+cs11	{
 	side		GR
 	length		2
 	ct_encoding	JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
 			JISX0208.1983-1:GL; JISX0208.1983-1:GR
 }
 
-XCOMM	cs13 class
-cs13     {
+XCOMM	cs12 class
+cs12    {
         side            GL
         length          2
         ct_encoding     KSC5601.1987-0:GL; KSC5601.1987-0:GR;\
                         KSC5601.1987-1:GL; KSC5601.1987-1:GR
 }
  
-XCOMM	cs14 class
-cs14     {
+XCOMM	cs13 class
+cs13    {
         side            GR
         length          2
         ct_encoding     GB2312.1980-0:GL; GB2312.1980-0:GR
 }
  
-XCOMM	cs15 class
-cs15	{
+XCOMM	cs14 class
+cs14	{
 	side		GR
 	length		1
 	ct_encoding	JISX0201.1976-0:GR
 }
  
-XCOMM	cs16 class
-cs16	{
+XCOMM	cs15 class
+cs15	{
 	side		none
 	ct_encoding	ISO10646-1
 }

Index: xsrc/external/mit/libX11/dist/src/ChkIfEv.c
diff -u xsrc/external/mit/libX11/dist/src/ChkIfEv.c:1.2 xsrc/external/mit/libX11/dist/src/ChkIfEv.c:1.3
--- xsrc/external/mit/libX11/dist/src/ChkIfEv.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/ChkIfEv.c	Mon Dec 19 13:20:17 2022
@@ -49,8 +49,8 @@ Bool XCheckIfEvent (
 	unsigned long qe_serial = 0;
 	int n;			/* time through count */
 
-        LockDisplay(dpy);
-        dpy->in_ifevent = True;
+	dpy->in_ifevent++;
+	LockDisplay(dpy);
 	prev = NULL;
 	for (n = 3; --n >= 0;) {
 	    for (qelt = prev ? prev->next : dpy->head;
@@ -61,7 +61,7 @@ Bool XCheckIfEvent (
 		    *event = qelt->event;
 		    _XDeq(dpy, prev, qelt);
 		    _XStoreEventCookie(dpy, event);
-                    dpy->in_ifevent = False;
+		    dpy->in_ifevent--;
 		    UnlockDisplay(dpy);
 		    return True;
 		}
@@ -80,7 +80,7 @@ Bool XCheckIfEvent (
 		/* another thread has snatched this event */
 		prev = NULL;
 	}
-        dpy->in_ifevent = False;
+	dpy->in_ifevent--;
 	UnlockDisplay(dpy);
 	return False;
 }
Index: xsrc/external/mit/libX11/dist/src/CrGlCur.c
diff -u xsrc/external/mit/libX11/dist/src/CrGlCur.c:1.2 xsrc/external/mit/libX11/dist/src/CrGlCur.c:1.3
--- xsrc/external/mit/libX11/dist/src/CrGlCur.c:1.2	Tue Sep 15 14:29:04 2020
+++ xsrc/external/mit/libX11/dist/src/CrGlCur.c	Mon Dec 19 13:20:17 2022
@@ -55,7 +55,7 @@ typedef void *XModuleType;
 #endif
 
 #ifndef LIBXCURSOR
-#define LIBXCURSOR "libXcursor.so"
+#define LIBXCURSOR "libXcursor.so.1"
 #endif
 
 static char libraryName[] = LIBXCURSOR;
Index: xsrc/external/mit/libX11/dist/src/IfEvent.c
diff -u xsrc/external/mit/libX11/dist/src/IfEvent.c:1.2 xsrc/external/mit/libX11/dist/src/IfEvent.c:1.3
--- xsrc/external/mit/libX11/dist/src/IfEvent.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/IfEvent.c	Mon Dec 19 13:20:17 2022
@@ -48,8 +48,8 @@ XIfEvent (
 	register _XQEvent *qelt, *prev;
 	unsigned long qe_serial = 0;
 
-        LockDisplay(dpy);
-        dpy->in_ifevent = True;
+	dpy->in_ifevent++;
+	LockDisplay(dpy);
 	prev = NULL;
 	while (1) {
 	    for (qelt = prev ? prev->next : dpy->head;
@@ -60,7 +60,7 @@ XIfEvent (
 		    *event = qelt->event;
 		    _XDeq(dpy, prev, qelt);
 		    _XStoreEventCookie(dpy, event);
-                    dpy->in_ifevent = False;
+		    dpy->in_ifevent--;
 		    UnlockDisplay(dpy);
 		    return 0;
 		}
Index: xsrc/external/mit/libX11/dist/src/OpenDis.c
diff -u xsrc/external/mit/libX11/dist/src/OpenDis.c:1.2 xsrc/external/mit/libX11/dist/src/OpenDis.c:1.3
--- xsrc/external/mit/libX11/dist/src/OpenDis.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/OpenDis.c	Mon Dec 19 13:20:17 2022
@@ -189,7 +189,7 @@ XOpenDisplay (
 	dpy->xcmisc_opcode	= 0;
 	dpy->xkb_info		= NULL;
 	dpy->exit_handler_data	= NULL;
-        dpy->in_ifevent         = False;
+	dpy->in_ifevent         = 0;
 
 /*
  * Setup other information in this display structure.
Index: xsrc/external/mit/libX11/dist/src/PeekIfEv.c
diff -u xsrc/external/mit/libX11/dist/src/PeekIfEv.c:1.2 xsrc/external/mit/libX11/dist/src/PeekIfEv.c:1.3
--- xsrc/external/mit/libX11/dist/src/PeekIfEv.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/PeekIfEv.c	Mon Dec 19 13:20:17 2022
@@ -49,8 +49,8 @@ XPeekIfEvent (
 	register _XQEvent *prev, *qelt;
 	unsigned long qe_serial = 0;
 
+	dpy->in_ifevent++;
 	LockDisplay(dpy);
-        dpy->in_ifevent = True;
 	prev = NULL;
 	while (1) {
 	    for (qelt = prev ? prev->next : dpy->head;
@@ -64,7 +64,7 @@ XPeekIfEvent (
 			_XStoreEventCookie(dpy, &copy);
 			*event = copy;
 		    }
-                    dpy->in_ifevent = False;
+		    dpy->in_ifevent--;
 		    UnlockDisplay(dpy);
 		    return 0;
 		}
Index: xsrc/external/mit/libX11/dist/src/PutBEvent.c
diff -u xsrc/external/mit/libX11/dist/src/PutBEvent.c:1.2 xsrc/external/mit/libX11/dist/src/PutBEvent.c:1.3
--- xsrc/external/mit/libX11/dist/src/PutBEvent.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/PutBEvent.c	Mon Dec 19 13:20:17 2022
@@ -79,9 +79,22 @@ XPutBackEvent (
     register XEvent *event)
 	{
 	int ret;
+	xEvent wire = {0};
+	XEvent lib = {0};
+	Status (*fp)(Display *, XEvent *, xEvent *);
+	int type = event->type & 0177;
 
 	LockDisplay(dpy);
-	ret = _XPutBackEvent(dpy, event);
+	fp = dpy->wire_vec[type];
+	if (fp == NULL)
+		fp = _XEventToWire;
+	ret = (*fp)(dpy, event, &wire);
+	if (ret)
+	{
+		ret = (*dpy->event_vec[type])(dpy, &lib, &wire);
+		if (ret)
+			ret = _XPutBackEvent(dpy, &lib);
+	}
 	UnlockDisplay(dpy);
 	return ret;
 	}
Index: xsrc/external/mit/libX11/dist/src/globals.c
diff -u xsrc/external/mit/libX11/dist/src/globals.c:1.2 xsrc/external/mit/libX11/dist/src/globals.c:1.3
--- xsrc/external/mit/libX11/dist/src/globals.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/globals.c	Mon Dec 19 13:20:17 2022
@@ -105,4 +105,10 @@ xlib_ctor(void)
 {
     XInitThreads();
 }
+
+__attribute__((destructor)) static void
+xlib_dtor(void)
+{
+    XFreeThreads();
+}
 #endif
Index: xsrc/external/mit/libX11/dist/src/locking.c
diff -u xsrc/external/mit/libX11/dist/src/locking.c:1.2 xsrc/external/mit/libX11/dist/src/locking.c:1.3
--- xsrc/external/mit/libX11/dist/src/locking.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/locking.c	Mon Dec 19 13:20:17 2022
@@ -465,17 +465,33 @@ static void _XIfEventLockDisplay(
     /* assert(dpy->in_ifevent); */
 }
 
+static void _XInternalLockDisplay(
+    Display *dpy,
+    Bool wskip
+    XTHREADS_FILE_LINE_ARGS
+    );
+
+static void _XIfEventInternalLockDisplay(
+    Display *dpy,
+    Bool wskip
+    XTHREADS_FILE_LINE_ARGS
+    )
+{
+    /* assert(dpy->in_ifevent); */
+}
+
 static void _XIfEventUnlockDisplay(
     Display *dpy
     XTHREADS_FILE_LINE_ARGS
     )
 {
-    if (dpy->in_ifevent)
-        return;
-
-    dpy->lock_fns->lock_display = _XLockDisplay;
-    dpy->lock_fns->unlock_display = _XUnlockDisplay;
-    UnlockDisplay(dpy);
+    if (dpy->in_ifevent == 0) {
+	dpy->lock_fns->lock_display = _XLockDisplay;
+	dpy->lock_fns->unlock_display = _XUnlockDisplay;
+	dpy->lock->internal_lock_display = _XInternalLockDisplay;
+	UnlockDisplay(dpy);
+    } else
+	return;
 }
 
 static void _XLockDisplay(
@@ -505,8 +521,9 @@ static void _XLockDisplay(
     _XIDHandler(dpy);
     _XSeqSyncFunction(dpy);
     if (dpy->in_ifevent) {
-        dpy->lock_fns->lock_display = _XIfEventLockDisplay;
-        dpy->lock_fns->unlock_display = _XIfEventUnlockDisplay;
+	dpy->lock_fns->lock_display = _XIfEventLockDisplay;
+	dpy->lock_fns->unlock_display = _XIfEventUnlockDisplay;
+	dpy->lock->internal_lock_display = _XIfEventInternalLockDisplay;
     }
 }
 
@@ -673,9 +690,32 @@ Status XInitThreads(void)
     return 1;
 }
 
+Status XFreeThreads(void)
+{
+    if (global_lock.lock != NULL) {
+	xmutex_free(global_lock.lock);
+	global_lock.lock = NULL;
+    }
+    if (i18n_lock.lock != NULL) {
+	xmutex_free(i18n_lock.lock);
+	i18n_lock.lock = NULL;
+    }
+    if (conv_lock.lock != NULL) {
+	xmutex_free(conv_lock.lock);
+	conv_lock.lock = NULL;
+    }
+
+    return 1;
+}
+
 #else /* XTHREADS */
 Status XInitThreads(void)
 {
     return 0;
 }
+
+Status XFreeThreads(void)
+{
+    return 0;
+}
 #endif /* XTHREADS */

Index: xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c
diff -u xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c:1.2 xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c:1.3
--- xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c:1.2	Mon Dec 19 13:19:01 2022
+++ xsrc/external/mit/libX11/dist/src/xkb/XKBBind.c	Mon Dec 19 13:20:17 2022
@@ -202,6 +202,14 @@ XkbKeysymToModifiers(Display *dpy, KeySy
     return mods;
 }
 
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#elif defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 KeySym
 XLookupKeysym(register XKeyEvent * event, int col)
 {
@@ -211,22 +219,15 @@ XLookupKeysym(register XKeyEvent * event
         return _XLookupKeysym(event, col);
     _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
 
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
     return XKeycodeToKeysym(dpy, event->keycode, col);
+}
+
 #ifdef __clang__
 #pragma clang diagnostic pop
 #elif defined(__GNUC__)
 #pragma GCC diagnostic pop
 #endif
 
-}
-
    /*
     * Not a public entry point -- XkbTranslateKey is an obsolete name
     * that is preserved here so that functions linked against the old

Reply via email to