aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/include/Xfuncproto.h69
-rw-r--r--nx-X11/include/extensions/Imakefile2
-rw-r--r--nx-X11/include/extensions/xf86bigfproto.h (renamed from nx-X11/include/extensions/xf86bigfstr.h)6
-rw-r--r--nx-X11/lib/X11/AllCells.c1
-rw-r--r--nx-X11/lib/X11/CCC.c5
-rw-r--r--nx-X11/lib/X11/ChProp.c8
-rw-r--r--nx-X11/lib/X11/ChkTypEv.c1
-rw-r--r--nx-X11/lib/X11/ChkTypWEv.c1
-rw-r--r--nx-X11/lib/X11/Cmap.h2
-rw-r--r--nx-X11/lib/X11/Context.c20
-rw-r--r--nx-X11/lib/X11/Cr.h2
-rw-r--r--nx-X11/lib/X11/CrBFData.c47
-rw-r--r--nx-X11/lib/X11/CrGC.c2
-rw-r--r--nx-X11/lib/X11/CrPFBData.c54
-rw-r--r--nx-X11/lib/X11/CvCols.c6
-rw-r--r--nx-X11/lib/X11/Depths.c2
-rw-r--r--nx-X11/lib/X11/DrArc.c1
-rw-r--r--nx-X11/lib/X11/ErrDes.c9
-rw-r--r--nx-X11/lib/X11/ErrHndlr.c10
-rw-r--r--nx-X11/lib/X11/FSWrap.c11
-rw-r--r--nx-X11/lib/X11/FetchName.c4
-rw-r--r--nx-X11/lib/X11/FillRcts.c1
-rw-r--r--nx-X11/lib/X11/Font.c93
-rw-r--r--nx-X11/lib/X11/FontInfo.c18
-rw-r--r--nx-X11/lib/X11/FontNames.c31
-rw-r--r--nx-X11/lib/X11/FreeEData.c4
-rw-r--r--nx-X11/lib/X11/FreeGC.c3
-rw-r--r--nx-X11/lib/X11/GetAtomNm.c8
-rw-r--r--nx-X11/lib/X11/GetDflt.c2
-rw-r--r--nx-X11/lib/X11/GetFPath.c10
-rw-r--r--nx-X11/lib/X11/GetFProp.c24
-rw-r--r--nx-X11/lib/X11/GetHints.c37
-rw-r--r--nx-X11/lib/X11/GetImage.c29
-rw-r--r--nx-X11/lib/X11/GetNrmHint.c4
-rw-r--r--nx-X11/lib/X11/GetProp.c2
-rw-r--r--nx-X11/lib/X11/GetRGBCMap.c13
-rw-r--r--nx-X11/lib/X11/GetStCmap.c6
-rw-r--r--nx-X11/lib/X11/GetWAttrs.c4
-rw-r--r--nx-X11/lib/X11/GetWMCMapW.c2
-rw-r--r--nx-X11/lib/X11/GetWMProto.c2
-rw-r--r--nx-X11/lib/X11/HVC.c8
-rw-r--r--nx-X11/lib/X11/Host.c2
-rw-r--r--nx-X11/lib/X11/ICWrap.c29
-rw-r--r--nx-X11/lib/X11/IMWrap.c2
-rw-r--r--nx-X11/lib/X11/Iconify.c26
-rw-r--r--nx-X11/lib/X11/IdOfPr.c4
-rw-r--r--nx-X11/lib/X11/ImUtil.c21
-rw-r--r--nx-X11/lib/X11/Imakefile11
-rw-r--r--nx-X11/lib/X11/InitExt.c9
-rw-r--r--nx-X11/lib/X11/IntAtom.c12
-rw-r--r--nx-X11/lib/X11/Key.h3
-rw-r--r--nx-X11/lib/X11/KeyBind.c100
-rw-r--r--nx-X11/lib/X11/KeysymStr.c26
-rw-r--r--nx-X11/lib/X11/LRGB.c69
-rw-r--r--nx-X11/lib/X11/Lab.c4
-rw-r--r--nx-X11/lib/X11/LiHosts.c3
-rw-r--r--nx-X11/lib/X11/ListExt.c20
-rw-r--r--nx-X11/lib/X11/LoadFont.c2
-rw-r--r--nx-X11/lib/X11/Luv.c4
-rw-r--r--nx-X11/lib/X11/Macros.c21
-rw-r--r--nx-X11/lib/X11/ModMap.c30
-rw-r--r--nx-X11/lib/X11/OpenDis.c71
-rw-r--r--nx-X11/lib/X11/PixFormats.c4
-rw-r--r--nx-X11/lib/X11/PolyReg.c19
-rw-r--r--nx-X11/lib/X11/PolyTxt.c14
-rw-r--r--nx-X11/lib/X11/PolyTxt16.c17
-rw-r--r--nx-X11/lib/X11/PrOfId.c11
-rw-r--r--nx-X11/lib/X11/PropAlloc.c16
-rw-r--r--nx-X11/lib/X11/PutBEvent.c2
-rw-r--r--nx-X11/lib/X11/PutImage.c30
-rw-r--r--nx-X11/lib/X11/QuColors.c34
-rw-r--r--nx-X11/lib/X11/Quarks.c14
-rw-r--r--nx-X11/lib/X11/RdBitF.c11
-rw-r--r--nx-X11/lib/X11/ReconfWM.c37
-rw-r--r--nx-X11/lib/X11/Region.c58
-rw-r--r--nx-X11/lib/X11/RegstFlt.c12
-rw-r--r--nx-X11/lib/X11/RestackWs.c2
-rw-r--r--nx-X11/lib/X11/ScrResStr.c3
-rw-r--r--nx-X11/lib/X11/SetCRects.c1
-rw-r--r--nx-X11/lib/X11/SetDashes.c2
-rw-r--r--nx-X11/lib/X11/SetFPath.c4
-rw-r--r--nx-X11/lib/X11/SetGetCols.c10
-rw-r--r--nx-X11/lib/X11/SetHints.c12
-rw-r--r--nx-X11/lib/X11/SetLocale.c52
-rw-r--r--nx-X11/lib/X11/SetPntMap.c3
-rw-r--r--nx-X11/lib/X11/SetRGBCMap.c2
-rw-r--r--nx-X11/lib/X11/StBytes.c4
-rw-r--r--nx-X11/lib/X11/StColor.c1
-rw-r--r--nx-X11/lib/X11/StCols.c4
-rw-r--r--nx-X11/lib/X11/StName.c6
-rw-r--r--nx-X11/lib/X11/StrKeysym.c27
-rw-r--r--nx-X11/lib/X11/StrToText.c2
-rw-r--r--nx-X11/lib/X11/Text.c22
-rw-r--r--nx-X11/lib/X11/TextExt.c8
-rw-r--r--nx-X11/lib/X11/TextExt16.c8
-rw-r--r--nx-X11/lib/X11/TextToStr.c8
-rw-r--r--nx-X11/lib/X11/UIThrStubs.c4
-rw-r--r--nx-X11/lib/X11/VisUtil.c12
-rw-r--r--nx-X11/lib/X11/WMGeom.c14
-rw-r--r--nx-X11/lib/X11/Withdraw.c22
-rw-r--r--nx-X11/lib/X11/WrBitF.c2
-rw-r--r--nx-X11/lib/X11/XDefaultIMIF.c80
-rw-r--r--nx-X11/lib/X11/XDefaultOMIF.c266
-rw-r--r--nx-X11/lib/X11/XErrorDB12
-rw-r--r--nx-X11/lib/X11/XKB.c762
-rw-r--r--nx-X11/lib/X11/XKBAlloc.c653
-rw-r--r--nx-X11/lib/X11/XKBBell.c123
-rw-r--r--nx-X11/lib/X11/XKBBind.c1012
-rw-r--r--nx-X11/lib/X11/XKBCompat.c295
-rw-r--r--nx-X11/lib/X11/XKBCtrls.c347
-rw-r--r--nx-X11/lib/X11/XKBCvt.c294
-rw-r--r--nx-X11/lib/X11/XKBExtDev.c1180
-rw-r--r--nx-X11/lib/X11/XKBGAlloc.c1236
-rw-r--r--nx-X11/lib/X11/XKBGeom.c1041
-rw-r--r--nx-X11/lib/X11/XKBGetByName.c290
-rw-r--r--nx-X11/lib/X11/XKBGetMap.c1102
-rw-r--r--nx-X11/lib/X11/XKBList.c331
-rw-r--r--nx-X11/lib/X11/XKBMAlloc.c1675
-rw-r--r--nx-X11/lib/X11/XKBMisc.c1653
-rw-r--r--nx-X11/lib/X11/XKBNames.c1398
-rw-r--r--nx-X11/lib/X11/XKBRdBuf.c178
-rw-r--r--nx-X11/lib/X11/XKBSetGeom.c606
-rw-r--r--nx-X11/lib/X11/XKBSetMap.c769
-rw-r--r--nx-X11/lib/X11/XKBUse.c1363
-rw-r--r--nx-X11/lib/X11/XKBleds.c377
-rw-r--r--nx-X11/lib/X11/XKBlibint.h364
-rw-r--r--nx-X11/lib/X11/XKeysymDB382
-rw-r--r--nx-X11/lib/X11/XYZ.c4
-rw-r--r--nx-X11/lib/X11/Xcms.h12
-rw-r--r--nx-X11/lib/X11/XimTrInt.h4
-rw-r--r--nx-X11/lib/X11/XimTrX.h2
-rw-r--r--nx-X11/lib/X11/XimTrans.h2
-rw-r--r--nx-X11/lib/X11/Ximint.h7
-rw-r--r--nx-X11/lib/X11/XimintP.h42
-rw-r--r--nx-X11/lib/X11/Xintatom.h1
-rw-r--r--nx-X11/lib/X11/Xintconn.h1
-rw-r--r--nx-X11/lib/X11/XlcDL.c93
-rw-r--r--nx-X11/lib/X11/XlcPubI.h11
-rw-r--r--nx-X11/lib/X11/XlcSL.c8
-rw-r--r--nx-X11/lib/X11/Xlcint.h15
-rw-r--r--nx-X11/lib/X11/Xlib.h64
-rw-r--r--nx-X11/lib/X11/XlibInt.c72
-rw-r--r--nx-X11/lib/X11/Xlibint.h151
-rw-r--r--nx-X11/lib/X11/Xlocale.h22
-rw-r--r--nx-X11/lib/X11/Xprivate.h10
-rw-r--r--nx-X11/lib/X11/Xregion.h7
-rw-r--r--nx-X11/lib/X11/Xresinternal.h2
-rw-r--r--nx-X11/lib/X11/Xrm.c79
-rw-r--r--nx-X11/lib/X11/XrmI.h48
-rw-r--r--nx-X11/lib/X11/Xutil.h16
-rw-r--r--nx-X11/lib/X11/cmsCmap.c11
-rw-r--r--nx-X11/lib/X11/cmsColNm.c22
-rw-r--r--nx-X11/lib/X11/cmsInt.c11
-rw-r--r--nx-X11/lib/X11/cmsMath.c4
-rw-r--r--nx-X11/lib/X11/cmsProp.c17
-rw-r--r--nx-X11/lib/X11/cmsTrig.c11
-rw-r--r--nx-X11/lib/X11/globals.c127
-rw-r--r--nx-X11/lib/X11/imCallbk.c83
-rw-r--r--nx-X11/lib/X11/imDefFlt.c56
-rw-r--r--nx-X11/lib/X11/imDefIc.c132
-rw-r--r--nx-X11/lib/X11/imDefIm.c193
-rw-r--r--nx-X11/lib/X11/imDefLkup.c134
-rw-r--r--nx-X11/lib/X11/imDispch.c10
-rw-r--r--nx-X11/lib/X11/imExten.c44
-rw-r--r--nx-X11/lib/X11/imImSw.c2
-rw-r--r--nx-X11/lib/X11/imInsClbk.c16
-rw-r--r--nx-X11/lib/X11/imInt.c42
-rw-r--r--nx-X11/lib/X11/imKStoUCS.c2
-rw-r--r--nx-X11/lib/X11/imLcFlt.c82
-rw-r--r--nx-X11/lib/X11/imLcGIc.c2
-rw-r--r--nx-X11/lib/X11/imLcIc.c23
-rw-r--r--nx-X11/lib/X11/imLcIm.c153
-rw-r--r--nx-X11/lib/X11/imLcLkup.c40
-rw-r--r--nx-X11/lib/X11/imLcPrs.c44
-rw-r--r--nx-X11/lib/X11/imLcSIc.c2
-rw-r--r--nx-X11/lib/X11/imRm.c339
-rw-r--r--nx-X11/lib/X11/imRmAttr.c121
-rw-r--r--nx-X11/lib/X11/imThaiFlt.c109
-rw-r--r--nx-X11/lib/X11/imThaiIc.c45
-rw-r--r--nx-X11/lib/X11/imThaiIm.c10
-rw-r--r--nx-X11/lib/X11/imTrX.c68
-rw-r--r--nx-X11/lib/X11/imTrans.c41
-rw-r--r--nx-X11/lib/X11/imTransR.c38
-rw-r--r--nx-X11/lib/X11/lcCT.c18
-rw-r--r--nx-X11/lib/X11/lcCharSet.c13
-rw-r--r--nx-X11/lib/X11/lcConv.c10
-rw-r--r--nx-X11/lib/X11/lcDB.c47
-rw-r--r--nx-X11/lib/X11/lcDefConv.c47
-rw-r--r--nx-X11/lib/X11/lcDynamic.c4
-rw-r--r--nx-X11/lib/X11/lcEuc.c1537
-rw-r--r--nx-X11/lib/X11/lcFile.c209
-rw-r--r--nx-X11/lib/X11/lcGenConv.c95
-rw-r--r--nx-X11/lib/X11/lcGeneric.c134
-rw-r--r--nx-X11/lib/X11/lcInit.c31
-rw-r--r--nx-X11/lib/X11/lcJis.c945
-rw-r--r--nx-X11/lib/X11/lcPrTxt.c15
-rw-r--r--nx-X11/lib/X11/lcPubWrap.c3
-rw-r--r--nx-X11/lib/X11/lcPublic.c34
-rw-r--r--nx-X11/lib/X11/lcRM.c10
-rw-r--r--nx-X11/lib/X11/lcSjis.c1612
-rw-r--r--nx-X11/lib/X11/lcStd.c10
-rw-r--r--nx-X11/lib/X11/lcTxtPr.c4
-rw-r--r--nx-X11/lib/X11/lcUTF8.c24
-rw-r--r--nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c6
-rw-r--r--nx-X11/lib/X11/lcUniConv/big5hkscs.h1
-rw-r--r--nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c14
-rw-r--r--nx-X11/lib/X11/lcWrap.c19
-rw-r--r--nx-X11/lib/X11/locking.c22
-rw-r--r--nx-X11/lib/X11/locking.h4
-rw-r--r--nx-X11/lib/X11/mbWMProps.c4
-rw-r--r--nx-X11/lib/X11/mbWrap.c12
-rw-r--r--nx-X11/lib/X11/omGeneric.c262
-rw-r--r--nx-X11/lib/X11/omImText.c4
-rw-r--r--nx-X11/lib/X11/omXChar.c24
-rw-r--r--nx-X11/lib/X11/os2Stubs.c42
-rw-r--r--nx-X11/lib/X11/pathmax.h1
-rw-r--r--nx-X11/lib/X11/udcInf.c716
-rw-r--r--nx-X11/lib/X11/utf8WMProps.c4
-rw-r--r--nx-X11/lib/X11/utf8Wrap.c12
-rw-r--r--nx-X11/lib/X11/utlist.h1
-rw-r--r--nx-X11/lib/X11/uvY.c8
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/Imakefile2
-rw-r--r--nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile14
-rw-r--r--nx-X11/lib/X11/xyY.c4
-rw-r--r--nx-X11/programs/Xserver/Xext/xf86bigfont.c2
-rw-r--r--nx-X11/programs/Xserver/mi/miinitext.c2
226 files changed, 11173 insertions, 16852 deletions
diff --git a/nx-X11/include/Xfuncproto.h b/nx-X11/include/Xfuncproto.h
index 88113c086..7760b6e44 100644
--- a/nx-X11/include/Xfuncproto.h
+++ b/nx-X11/include/Xfuncproto.h
@@ -67,15 +67,15 @@ in this Software without prior written authorization from The Open Group.
#endif
#endif /* _XFUNCPROTOBEGIN */
+/* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && (__GNUC__ >= 4)
# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
-# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
#else
# define _X_SENTINEL(x)
-# define _X_ATTRIBUTE_PRINTF(x,y)
#endif /* GNUC >= 4 */
-#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# define _X_EXPORT __attribute__((visibility("default")))
# define _X_HIDDEN __attribute__((visibility("hidden")))
# define _X_INTERNAL __attribute__((visibility("internal")))
@@ -83,18 +83,52 @@ in this Software without prior written authorization from The Open Group.
# define _X_EXPORT __global
# define _X_HIDDEN __hidden
# define _X_INTERNAL __hidden
-#else /* not gcc >= 3.3 and not Sun Studio >= 8 */
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
# define _X_EXPORT
# define _X_HIDDEN
# define _X_INTERNAL
+#endif /* GNUC >= 4 */
+
+/* Branch prediction hints for individual conditionals */
+/* requires xproto >= 7.0.9 */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+# define _X_LIKELY(x) __builtin_expect(!!(x), 1)
+# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else /* not gcc >= 3.3 */
+# define _X_LIKELY(x) (x)
+# define _X_UNLIKELY(x) (x)
#endif
+/* Bulk branch prediction hints via marking error path functions as "cold" */
+/* requires xproto >= 7.0.25 */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */
+# define _X_COLD __attribute__((__cold__))
+#else
+# define _X_COLD /* nothing */
+#endif
+
+/* Added in X11R6.9, so available in any version of modular xproto */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)
# define _X_DEPRECATED __attribute__((deprecated))
#else /* not gcc >= 3.1 */
# define _X_DEPRECATED
#endif
+/* requires xproto >= 7.0.17 */
+#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define _X_NORETURN __attribute((noreturn))
+#else
+# define _X_NORETURN
+#endif /* GNUC */
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
+#else /* not gcc >= 2.3 */
+# define _X_ATTRIBUTE_PRINTF(x,y)
+#endif
+
/* requires xproto >= 7.0.22 */
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
#define _X_UNUSED __attribute__((__unused__))
@@ -102,4 +136,31 @@ in this Software without prior written authorization from The Open Group.
#define _X_UNUSED /* */
#endif
+/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.9
+ (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */
+#if defined(inline) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \
+ (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))
+# define _X_INLINE inline
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_INLINE __inline__
+#else
+# define _X_INLINE
+#endif
+
+/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.21 */
+#ifndef _X_RESTRICT_KYWD
+# if defined(restrict) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
+ && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
+# define _X_RESTRICT_KYWD restrict
+# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_RESTRICT_KYWD __restrict__
+# else
+# define _X_RESTRICT_KYWD
+# endif
+#endif
+
#endif /* _XFUNCPROTO_H_ */
diff --git a/nx-X11/include/extensions/Imakefile b/nx-X11/include/extensions/Imakefile
index d2be4b324..2d8f63494 100644
--- a/nx-X11/include/extensions/Imakefile
+++ b/nx-X11/include/extensions/Imakefile
@@ -13,7 +13,7 @@ SCREENSAVERHEADERS = saver.h saverproto.h scrnsaver.h
#endif
#if BuildXF86BigfontExt
-XF86BIGFONTHEADERS = xf86bigfont.h xf86bigfstr.h
+XF86BIGFONTHEADERS = xf86bigfont.h xf86bigfproto.h
#endif
#if BuildXvExt
XVHEADERS = Xv.h Xvlib.h Xvproto.h
diff --git a/nx-X11/include/extensions/xf86bigfstr.h b/nx-X11/include/extensions/xf86bigfproto.h
index 4a8eda47a..b4b791fb9 100644
--- a/nx-X11/include/extensions/xf86bigfstr.h
+++ b/nx-X11/include/extensions/xf86bigfproto.h
@@ -7,8 +7,8 @@
/* THIS IS NOT AN X CONSORTIUM STANDARD */
-#ifndef _XF86BIGFSTR_H_
-#define _XF86BIGFSTR_H_
+#ifndef _XF86BIGFPROTO_H_
+#define _XF86BIGFPROTO_H_
#include <nx-X11/extensions/xf86bigfont.h>
@@ -85,4 +85,4 @@ typedef struct {
/* Bit masks that can be set in the flags */
#define XF86Bigfont_FLAGS_Shm 1
-#endif /* _XF86BIGFSTR_H_ */
+#endif /* _XF86BIGFPROTO_H_ */
diff --git a/nx-X11/lib/X11/AllCells.c b/nx-X11/lib/X11/AllCells.c
index 6d9548f0d..6e97e1181 100644
--- a/nx-X11/lib/X11/AllCells.c
+++ b/nx-X11/lib/X11/AllCells.c
@@ -24,7 +24,6 @@ in this Software without prior written authorization from The Open Group.
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/nx-X11/lib/X11/CCC.c b/nx-X11/lib/X11/CCC.c
index 090b1078c..de6d6318a 100644
--- a/nx-X11/lib/X11/CCC.c
+++ b/nx-X11/lib/X11/CCC.c
@@ -111,7 +111,7 @@ XcmsCreateCCC(
XcmsPerScrnInfo *pNewScrnInfo;
if (pDefaultCCC == NULL ||
- !(newccc = (XcmsCCC) Xcalloc(1, (unsigned) sizeof(XcmsCCCRec)))) {
+ !(newccc = Xcalloc(1, sizeof(XcmsCCCRec)))) {
return(NULL);
}
@@ -144,8 +144,7 @@ XcmsCreateCCC(
* If one exists replace the pPerScrnInfo.
*/
if ((pIMap = _XcmsGetIntensityMap(dpy, visual)) != NULL) {
- if (!(pNewScrnInfo = (XcmsPerScrnInfo *)
- Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ if (!(pNewScrnInfo = Xcalloc(1, sizeof(XcmsPerScrnInfo)))) {
Xfree(newccc);
return(NULL);
}
diff --git a/nx-X11/lib/X11/ChProp.c b/nx-X11/lib/X11/ChProp.c
index 347c3d7a1..190a224f8 100644
--- a/nx-X11/lib/X11/ChProp.c
+++ b/nx-X11/lib/X11/ChProp.c
@@ -62,16 +62,16 @@ XChangeProperty (
len = ((long)nelements + 3)>>2;
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
- Data (dpy, (char *)data, nelements);
+ Data (dpy, (_Xconst char *)data, nelements);
} /* else force BadLength */
break;
-
+
case 16:
len = ((long)nelements + 1)>>1;
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 1;
- Data16 (dpy, (short *) data, len);
+ Data16 (dpy, (_Xconst short *) data, len);
} /* else force BadLength */
break;
@@ -80,7 +80,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 2;
- Data32 (dpy, (long *) data, len);
+ Data32 (dpy, (_Xconst long *) data, len);
} /* else force BadLength */
break;
diff --git a/nx-X11/lib/X11/ChkTypEv.c b/nx-X11/lib/X11/ChkTypEv.c
index 8ca1c8048..2e9bcdd0a 100644
--- a/nx-X11/lib/X11/ChkTypEv.c
+++ b/nx-X11/lib/X11/ChkTypEv.c
@@ -57,6 +57,7 @@ Bool XCheckTypedEvent (
if (qelt->event.type == type) {
*event = qelt->event;
_XDeq(dpy, prev, qelt);
+ _XStoreEventCookie(dpy, event);
UnlockDisplay(dpy);
return True;
}
diff --git a/nx-X11/lib/X11/ChkTypWEv.c b/nx-X11/lib/X11/ChkTypWEv.c
index 92b3f5d94..2f247be26 100644
--- a/nx-X11/lib/X11/ChkTypWEv.c
+++ b/nx-X11/lib/X11/ChkTypWEv.c
@@ -59,6 +59,7 @@ Bool XCheckTypedWindowEvent (
(qelt->event.type == type)) {
*event = qelt->event;
_XDeq(dpy, prev, qelt);
+ _XStoreEventCookie(dpy, event);
UnlockDisplay(dpy);
return True;
}
diff --git a/nx-X11/lib/X11/Cmap.h b/nx-X11/lib/X11/Cmap.h
index 062b5383b..db2de5697 100644
--- a/nx-X11/lib/X11/Cmap.h
+++ b/nx-X11/lib/X11/Cmap.h
@@ -2,6 +2,8 @@
#ifndef _CMAP_H_
#define _CMAP_H_
+#include <nx-X11/Xlib.h>
+
extern void
_XcmsDeleteCmapRec(
Display *dpy,
diff --git a/nx-X11/lib/X11/Context.c b/nx-X11/lib/X11/Context.c
index 79ae7d66c..8a078713a 100644
--- a/nx-X11/lib/X11/Context.c
+++ b/nx-X11/lib/X11/Context.c
@@ -111,7 +111,7 @@ static void ResizeTable(DB db)
otable = db->table;
for (i = INITHASHMASK+1; (i + i) < db->numentries; )
i += i;
- db->table = (TableEntry *) Xcalloc((unsigned)i, sizeof(TableEntry));
+ db->table = Xcalloc(i, sizeof(TableEntry));
if (!db->table) {
db->table = otable;
return;
@@ -126,7 +126,7 @@ static void ResizeTable(DB db)
*head = entry;
}
}
- Xfree((char *) otable);
+ Xfree(otable);
}
static void _XFreeContextDB(Display *display)
@@ -140,12 +140,12 @@ static void _XFreeContextDB(Display *display)
for (i = db->mask + 1, pentry = db->table ; --i >= 0; pentry++) {
for (entry = *pentry; entry; entry = next) {
next = entry->next;
- Xfree((char *)entry);
+ Xfree(entry);
}
}
- Xfree((char *) db->table);
+ Xfree(db->table);
_XFreeMutex(&db->linfo);
- Xfree((char *) db);
+ Xfree(db);
}
}
@@ -180,13 +180,13 @@ int XSaveContext(
UnlockDisplay(display);
}
if (!db) {
- db = (DB) Xmalloc(sizeof(DBRec));
+ db = Xmalloc(sizeof(DBRec));
if (!db)
return XCNOMEM;
db->mask = INITHASHMASK;
- db->table = (TableEntry *)Xcalloc(db->mask + 1, sizeof(TableEntry));
+ db->table = Xcalloc(db->mask + 1, sizeof(TableEntry));
if (!db->table) {
- Xfree((char *)db);
+ Xfree(db);
return XCNOMEM;
}
db->numentries = 0;
@@ -210,7 +210,7 @@ int XSaveContext(
return 0;
}
}
- entry = (TableEntry) Xmalloc(sizeof(TableEntryRec));
+ entry = Xmalloc(sizeof(TableEntryRec));
if (!entry)
return XCNOMEM;
entry->rid = rid;
@@ -289,7 +289,7 @@ int XDeleteContext(Display *display, XID rid, XContext context)
prev = &entry->next) {
if (entry->rid == rid && entry->context == context) {
*prev = entry->next;
- Xfree((char *) entry);
+ Xfree(entry);
db->numentries--;
if (db->numentries < db->mask && db->mask > INITHASHMASK)
ResizeTable(db);
diff --git a/nx-X11/lib/X11/Cr.h b/nx-X11/lib/X11/Cr.h
index 800c9ab1c..e71d86d1c 100644
--- a/nx-X11/lib/X11/Cr.h
+++ b/nx-X11/lib/X11/Cr.h
@@ -2,6 +2,8 @@
#ifndef _CR_H_
#define _CR_H_
+#include <nx-X11/Xlib.h>
+
extern int _XUpdateGCCache(
register GC gc,
register unsigned long mask,
diff --git a/nx-X11/lib/X11/CrBFData.c b/nx-X11/lib/X11/CrBFData.c
index 449095690..6708a9b91 100644
--- a/nx-X11/lib/X11/CrBFData.c
+++ b/nx-X11/lib/X11/CrBFData.c
@@ -53,27 +53,28 @@ Pixmap XCreateBitmapFromData(
unsigned int width,
unsigned int height)
{
- XImage ximage;
- GC gc;
- Pixmap pix;
-
- pix = XCreatePixmap(display, d, width, height, 1);
- if (! (gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0)))
- return (Pixmap) None;
- ximage.height = height;
- ximage.width = width;
- ximage.depth = 1;
- ximage.bits_per_pixel = 1;
- ximage.xoffset = 0;
- ximage.format = XYPixmap;
- ximage.data = (char *)data;
- ximage.byte_order = LSBFirst;
- ximage.bitmap_unit = 8;
- ximage.bitmap_bit_order = LSBFirst;
- ximage.bitmap_pad = 8;
- ximage.bytes_per_line = (width+7)/8;
-
- XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
- XFreeGC(display, gc);
- return(pix);
+ Pixmap pix = XCreatePixmap(display, d, width, height, 1);
+ GC gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0);
+ if (gc == NULL) {
+ XFreePixmap(display, pix);
+ return (Pixmap) None;
+ } else {
+ XImage ximage = {
+ .height = height,
+ .width = width,
+ .depth = 1,
+ .bits_per_pixel = 1,
+ .xoffset = 0,
+ .format = XYPixmap,
+ .data = (char *) data,
+ .byte_order = LSBFirst,
+ .bitmap_unit = 8,
+ .bitmap_bit_order = LSBFirst,
+ .bitmap_pad = 8,
+ .bytes_per_line = (width + 7) / 8,
+ };
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+ }
}
diff --git a/nx-X11/lib/X11/CrGC.c b/nx-X11/lib/X11/CrGC.c
index 11de94c1f..2d5f17c00 100644
--- a/nx-X11/lib/X11/CrGC.c
+++ b/nx-X11/lib/X11/CrGC.c
@@ -72,7 +72,7 @@ GC XCreateGC (
register _XExtension *ext;
LockDisplay(dpy);
- if ((gc = (GC)Xmalloc (sizeof(struct _XGC))) == NULL) {
+ if ((gc = Xmalloc (sizeof(struct _XGC))) == NULL) {
UnlockDisplay(dpy);
SyncHandle();
return (NULL);
diff --git a/nx-X11/lib/X11/CrPFBData.c b/nx-X11/lib/X11/CrPFBData.c
index 57cd15303..17d551bb7 100644
--- a/nx-X11/lib/X11/CrPFBData.c
+++ b/nx-X11/lib/X11/CrPFBData.c
@@ -58,30 +58,32 @@ Pixmap XCreatePixmapFromBitmapData(
unsigned long bg,
unsigned int depth)
{
- XImage ximage;
- GC gc;
- XGCValues gcv;
- Pixmap pix;
-
- pix = XCreatePixmap(display, d, width, height, depth);
- gcv.foreground = fg;
- gcv.background = bg;
- if (! (gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv)))
- return (Pixmap) NULL;
- ximage.height = height;
- ximage.width = width;
- ximage.depth = 1;
- ximage.bits_per_pixel = 1;
- ximage.xoffset = 0;
- ximage.format = XYBitmap;
- ximage.data = data;
- ximage.byte_order = LSBFirst;
- ximage.bitmap_unit = 8;
- ximage.bitmap_bit_order = LSBFirst;
- ximage.bitmap_pad = 8;
- ximage.bytes_per_line = (width+7)/8;
-
- XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
- XFreeGC(display, gc);
- return(pix);
+ Pixmap pix = XCreatePixmap(display, d, width, height, depth);
+ XGCValues gcv = {
+ .foreground = fg,
+ .background = bg
+ };
+ GC gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv);
+ if (gc == NULL) {
+ XFreePixmap(display, pix);
+ return (Pixmap) None;
+ } else {
+ XImage ximage = {
+ .height = height,
+ .width = width,
+ .depth = 1,
+ .bits_per_pixel = 1,
+ .xoffset = 0,
+ .format = XYBitmap,
+ .data = data,
+ .byte_order = LSBFirst,
+ .bitmap_unit = 8,
+ .bitmap_bit_order = LSBFirst,
+ .bitmap_pad = 8,
+ .bytes_per_line = (width + 7) / 8
+ };
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+ }
}
diff --git a/nx-X11/lib/X11/CvCols.c b/nx-X11/lib/X11/CvCols.c
index ed3582663..87d49311c 100644
--- a/nx-X11/lib/X11/CvCols.c
+++ b/nx-X11/lib/X11/CvCols.c
@@ -796,7 +796,7 @@ XcmsConvertColors(
* Make copy of array of color specifications
*/
if (nColors > 1) {
- pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
} else {
pColors_tmp = &Color1;
}
@@ -987,13 +987,13 @@ XcmsConvertColors(
nColors * sizeof(XcmsColor));
}
if (nColors > 1) {
- Xfree((char *)pColors_tmp);
+ Xfree(pColors_tmp);
}
return(retval);
Failure:
if (nColors > 1) {
- Xfree((char *)pColors_tmp);
+ Xfree(pColors_tmp);
}
return(XcmsFailure);
}
diff --git a/nx-X11/lib/X11/Depths.c b/nx-X11/lib/X11/Depths.c
index f49655cb2..a8b719d00 100644
--- a/nx-X11/lib/X11/Depths.c
+++ b/nx-X11/lib/X11/Depths.c
@@ -49,7 +49,7 @@ int *XListDepths (
register Depth *dp;
register int i;
- depths = (int *) Xmalloc (count * sizeof(int));
+ depths = Xmalloc (count * sizeof(int));
if (!depths) return NULL;
for (i = 0, dp = scr->depths; i < count; i++, dp++)
depths[i] = dp->depth;
diff --git a/nx-X11/lib/X11/DrArc.c b/nx-X11/lib/X11/DrArc.c
index 61102e9b2..d72fac9d7 100644
--- a/nx-X11/lib/X11/DrArc.c
+++ b/nx-X11/lib/X11/DrArc.c
@@ -66,6 +66,7 @@ XDrawArc(
arc->angle1 = angle1;
arc->angle2 = angle2;
+
UnlockDisplay(dpy);
SyncHandle();
return 1;
diff --git a/nx-X11/lib/X11/ErrDes.c b/nx-X11/lib/X11/ErrDes.c
index ac13b480b..f13e3dce4 100644
--- a/nx-X11/lib/X11/ErrDes.c
+++ b/nx-X11/lib/X11/ErrDes.c
@@ -109,7 +109,7 @@ XGetErrorText(
if (nbytes == 0) return 0;
if (code <= BadImplementation && code > 0) {
- sprintf(buf, "%d", code);
+ snprintf(buf, sizeof(buf), "%d", code);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf,
_XErrorList + _XErrorOffsets[code],
buffer, nbytes);
@@ -125,11 +125,12 @@ XGetErrorText(
bext = ext;
}
if (!buffer[0] && bext) {
- sprintf(buf, "%s.%d", bext->name, code - bext->codes.first_error);
+ snprintf(buf, sizeof(buf), "%s.%d",
+ bext->name, code - bext->codes.first_error);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes);
}
if (!buffer[0])
- sprintf(buffer, "%d", code);
+ snprintf(buffer, nbytes, "%d", code);
return 0;
}
@@ -190,7 +191,7 @@ XGetErrorDatabaseText(
else
tptr = Xmalloc (tlen);
if (tptr) {
- sprintf(tptr, "%s.%s", name, type);
+ snprintf(tptr, tlen, "%s.%s", name, type);
XrmGetResource(db, tptr, "ErrorType.ErrorNumber",
&type_str, &result);
if (tptr != temp)
diff --git a/nx-X11/lib/X11/ErrHndlr.c b/nx-X11/lib/X11/ErrHndlr.c
index 4785ca157..167a68b1e 100644
--- a/nx-X11/lib/X11/ErrHndlr.c
+++ b/nx-X11/lib/X11/ErrHndlr.c
@@ -29,12 +29,12 @@ in this Software without prior written authorization from The Open Group.
#endif
#include "Xlibint.h"
-/*
+/*
* XErrorHandler - This procedure sets the X non-fatal error handler
* (_XErrorFunction) to be the specified routine. If NULL is passed in
* the original error handler is restored.
*/
-
+
XErrorHandler
XSetErrorHandler(XErrorHandler handler)
{
@@ -57,12 +57,12 @@ XSetErrorHandler(XErrorHandler handler)
return (XErrorHandler) oldhandler;
}
-/*
+/*
* XIOErrorHandler - This procedure sets the X fatal I/O error handler
- * (_XIOErrorFunction) to be the specified routine. If NULL is passed in
+ * (_XIOErrorFunction) to be the specified routine. If NULL is passed in
* the original error handler is restored.
*/
-
+
XIOErrorHandler
XSetIOErrorHandler(XIOErrorHandler handler)
{
diff --git a/nx-X11/lib/X11/FSWrap.c b/nx-X11/lib/X11/FSWrap.c
index 35bf33d2a..015965779 100644
--- a/nx-X11/lib/X11/FSWrap.c
+++ b/nx-X11/lib/X11/FSWrap.c
@@ -85,10 +85,9 @@ _XParseBaseFontNameList(
if (!*str)
return (char **)NULL;
- if (!(ptr = Xmalloc((unsigned)strlen(str) + 1))) {
+ if (!(ptr = strdup(str))) {
return (char **)NULL;
}
- strcpy(ptr, str);
psave = ptr;
/* somebody who specifies more than XMAXLIST basefontnames will lose */
@@ -113,7 +112,7 @@ _XParseBaseFontNameList(
if (!*ptr)
break;
}
- if (!(list = (char **) Xmalloc((unsigned)sizeof(char *) * (*num + 1)))) {
+ if (!(list = Xmalloc(sizeof(char *) * (*num + 1)))) {
Xfree(psave);
return (char **)NULL;
}
@@ -131,10 +130,10 @@ copy_string_list(
char **string_list_ret, **list_src, **list_dst, *dst;
int length, count;
- if (string_list == NULL)
+ if (string_list == NULL || list_count <= 0)
return (char **) NULL;
- string_list_ret = (char **) Xmalloc(sizeof(char *) * list_count);
+ string_list_ret = Xmalloc(sizeof(char *) * list_count);
if (string_list_ret == NULL)
return (char **) NULL;
@@ -143,7 +142,7 @@ copy_string_list(
for (length = 0; count-- > 0; list_src++)
length += strlen(*list_src) + 1;
- dst = (char *) Xmalloc(length);
+ dst = Xmalloc(length);
if (dst == NULL) {
Xfree(string_list_ret);
return (char **) NULL;
diff --git a/nx-X11/lib/X11/FetchName.c b/nx-X11/lib/X11/FetchName.c
index 7503482fa..52c65c52c 100644
--- a/nx-X11/lib/X11/FetchName.c
+++ b/nx-X11/lib/X11/FetchName.c
@@ -58,7 +58,7 @@ Status XFetchName (
*name = (char *)data;
return(1);
}
- if (data) Xfree ((char *)data);
+ Xfree (data);
*name = NULL;
return(0);
}
@@ -89,7 +89,7 @@ Status XGetIconName (
*icon_name = (char*)data;
return(1);
}
- if (data) Xfree ((char *)data);
+ Xfree (data);
*icon_name = NULL;
return(0);
}
diff --git a/nx-X11/lib/X11/FillRcts.c b/nx-X11/lib/X11/FillRcts.c
index 7d9569124..ad334244f 100644
--- a/nx-X11/lib/X11/FillRcts.c
+++ b/nx-X11/lib/X11/FillRcts.c
@@ -63,3 +63,4 @@ XFillRectangles(
SyncHandle();
return 1;
}
+
diff --git a/nx-X11/lib/X11/Font.c b/nx-X11/lib/X11/Font.c
index d311cd0f7..6bbab3f19 100644
--- a/nx-X11/lib/X11/Font.c
+++ b/nx-X11/lib/X11/Font.c
@@ -45,7 +45,7 @@ authorization from the X Consortium and the XFree86 Project.
#include <stdio.h>
#include <stdlib.h>
-#include <nx-X11/extensions/xf86bigfstr.h>
+#include <nx-X11/extensions/xf86bigfproto.h>
#endif
#include "Xlcint.h"
@@ -166,13 +166,13 @@ XFreeFont(
#ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs);
#else
- Xfree ((char *) fs->per_char);
+ Xfree (fs->per_char);
#endif
}
_XFreeExtData(fs->ext_data);
- if (fs->properties)
- Xfree ((char *) fs->properties);
- Xfree ((char *) fs);
+
+ Xfree (fs->properties);
+ Xfree (fs);
return 1;
}
@@ -215,7 +215,7 @@ _XQueryFont (
DeqAsyncHandler(dpy, &async);
reply_left = reply.length -
((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2);
- if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) {
+ if (! (fs = Xmalloc (sizeof (XFontStruct)))) {
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -249,7 +249,7 @@ _XQueryFont (
fs->properties = Xmalloc (pbytes);
}
if (! fs->properties) {
- Xfree((char *) fs);
+ Xfree(fs);
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -260,7 +260,6 @@ _XQueryFont (
* If no characters in font, then it is a bad font, but
* shouldn't try to read nothing.
*/
- /* have to unpack charinfos on some machines (CRAY) */
fs->per_char = NULL;
if (reply.nCharInfos > 0){
/* nCharInfos is a CARD32 */
@@ -272,8 +271,8 @@ _XQueryFont (
}
}
if (! fs->per_char) {
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(fs->properties);
+ Xfree(fs);
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -324,7 +323,7 @@ _XF86BigfontCodes (
if (pData)
return (XF86BigfontCodes *) pData->private_data;
- pData = (XExtData *) Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes));
+ pData = Xmalloc(sizeof(XExtData) + sizeof(XF86BigfontCodes));
if (!pData) {
/* Out of luck. */
return (XF86BigfontCodes *) NULL;
@@ -460,7 +459,7 @@ _XF86BigfontQueryFont (
DeqAsyncHandler(dpy, &async1);
reply_left = reply.length -
((SIZEOF(xXF86BigfontQueryFontReply) - SIZEOF(xReply)) >> 2);
- if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) {
+ if (! (fs = Xmalloc (sizeof (XFontStruct)))) {
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -494,7 +493,7 @@ _XF86BigfontQueryFont (
fs->properties = Xmalloc (pbytes);
}
if (! fs->properties) {
- Xfree((char *) fs);
+ Xfree(fs);
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -507,11 +506,11 @@ _XF86BigfontQueryFont (
/* compares each part to half the maximum, which should be far more than
any real font needs, so the combined total doesn't overflow either */
if (reply.nUniqCharInfos > ((ULONG_MAX / 2) / SIZEOF(xCharInfo)) ||
- reply.nCharInfos > ((ULONG_MAX / 2) / sizeof(CARD16))) {
- Xfree(fs->properties);
- Xfree((char *) fs);
- _XEatDataWords(dpy, reply_left);
- return (XFontStruct *)NULL;
+ reply.nCharInfos > ((ULONG_MAX / 2) / sizeof(CARD16))) {
+ Xfree(fs->properties);
+ Xfree(fs);
+ _XEatDataWords(dpy, reply_left);
+ return (XFontStruct *)NULL;
}
#endif
if (reply.nCharInfos > 0) {
@@ -523,17 +522,17 @@ _XF86BigfontQueryFont (
nbytes = reply.nUniqCharInfos * SIZEOF(xCharInfo)
+ (reply.nCharInfos+1)/2 * 2 * sizeof(CARD16);
- pUniqCI = (xCharInfo *) Xmalloc (nbytes);
+ pUniqCI = Xmalloc (nbytes);
if (!pUniqCI) {
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(fs->properties);
+ Xfree(fs);
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
- if (! (fs->per_char = (XCharStruct *) Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) {
- Xfree((char *) pUniqCI);
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ if (! (fs->per_char = Xmalloc (reply.nCharInfos * sizeof(XCharStruct)))) {
+ Xfree(pUniqCI);
+ Xfree(fs->properties);
+ Xfree(fs);
_XEatDataWords(dpy, reply_left);
return (XFontStruct *)NULL;
}
@@ -542,25 +541,25 @@ _XF86BigfontQueryFont (
for (i = 0; i < reply.nCharInfos; i++) {
if (pIndex2UniqIndex[i] >= reply.nUniqCharInfos) {
fprintf(stderr, "_XF86BigfontQueryFont: server returned wrong data\n");
- Xfree((char *) pUniqCI);
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(pUniqCI);
+ Xfree(fs->properties);
+ Xfree(fs);
return (XFontStruct *)NULL;
}
/* XXX the next statement won't work if short isn't 16 bits */
fs->per_char[i] = * (XCharStruct *) &pUniqCI[pIndex2UniqIndex[i]];
}
- Xfree((char *) pUniqCI);
+ Xfree(pUniqCI);
} else {
#ifdef HAS_SHM
XExtData *pData;
XEDataObject fs_union;
char *addr;
- pData = (XExtData *) Xmalloc(sizeof(XExtData));
+ pData = Xmalloc(sizeof(XExtData));
if (!pData) {
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(fs->properties);
+ Xfree(fs);
return (XFontStruct *)NULL;
}
@@ -578,9 +577,9 @@ _XF86BigfontQueryFont (
if ((addr = shmat(reply.shmid, NULL, SHM_RDONLY)) == (char *)-1) {
if (extcodes->serverCapabilities & CAP_VerifiedLocal)
fprintf(stderr, "_XF86BigfontQueryFont: could not attach shm segment\n");
- Xfree((char *) pData);
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(pData);
+ Xfree(fs->properties);
+ Xfree(fs);
/* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL;
@@ -589,13 +588,13 @@ _XF86BigfontQueryFont (
if (!(extcodes->serverCapabilities & CAP_VerifiedLocal)) {
struct shmid_ds buf;
if (!(shmctl(reply.shmid, IPC_STAT, &buf) >= 0
- && reply.nCharInfos < (LONG_MAX / sizeof(XCharStruct))
+ && reply.nCharInfos < (INT_MAX / sizeof(XCharStruct))
&& buf.shm_segsz >= reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct) + sizeof(CARD32)
&& *(CARD32 *)(addr + reply.shmsegoffset + reply.nCharInfos * sizeof(XCharStruct)) == extcodes->serverSignature)) {
shmdt(addr);
- Xfree((char *) pData);
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ Xfree(pData);
+ Xfree(fs->properties);
+ Xfree(fs);
/* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL;
@@ -612,8 +611,8 @@ _XF86BigfontQueryFont (
fs->per_char = (XCharStruct *) (addr + reply.shmsegoffset);
#else
fprintf(stderr, "_XF86BigfontQueryFont: try recompiling libX11 with HasShm, Xserver has shm support\n");
- if (fs->properties) Xfree((char *) fs->properties);
- Xfree((char *) fs);
+ if (fs->properties) Xfree(fs->properties);
+ Xfree(fs);
/* Stop requesting shared memory transport from now on. */
extcodes->serverCapabilities &= ~ XF86Bigfont_CAP_LocalShm;
return (XFontStruct *)NULL;
@@ -639,9 +638,9 @@ _XF86BigfontFreeFontMetrics (XFontStruct *fs)
XF86BigfontNumber)))
shmdt ((char *) pData->private_data);
else
- Xfree ((char *) fs->per_char);
+ Xfree (fs->per_char);
#else
- Xfree ((char *) fs->per_char);
+ Xfree (fs->per_char);
#endif
}
@@ -694,14 +693,14 @@ int _XF86LoadQueryLocaleFont(
#ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs);
#else
- Xfree ((char *) fs->per_char);
+ Xfree (fs->per_char);
#endif
}
_XFreeExtData(fs->ext_data);
- if (fs->properties)
- Xfree ((char *) fs->properties);
+
+ Xfree (fs->properties);
*fidp = fs->fid;
- Xfree ((char *) fs);
+ Xfree (fs);
} else {
XFreeFont(dpy, fs);
}
diff --git a/nx-X11/lib/X11/FontInfo.c b/nx-X11/lib/X11/FontInfo.c
index 0cb5b1910..a2d12c2ec 100644
--- a/nx-X11/lib/X11/FontInfo.c
+++ b/nx-X11/lib/X11/FontInfo.c
@@ -107,7 +107,7 @@ XFontStruct **info) /* RETURN */
if (! (finfo = Xmalloc(sizeof(XFontStruct) * size)))
goto clearwire;
if (! (flist = Xmalloc(sizeof(char *) * (size+1)))) {
- Xfree((char *) finfo);
+ Xfree(finfo);
goto clearwire;
}
}
@@ -152,7 +152,7 @@ XFontStruct **info) /* RETURN */
nbytes++; /* make first string 1 byte longer, to match XListFonts */
flist[i] = Xmalloc (nbytes);
if (! flist[i]) {
- if (finfo[i].properties) Xfree((char *) finfo[i].properties);
+ if (finfo[i].properties) Xfree(finfo[i].properties);
goto badmem;
}
if (!i) {
@@ -177,10 +177,10 @@ XFontStruct **info) /* RETURN */
if (j == 0)
flist[j]--; /* was incremented above */
Xfree(flist[j]);
- if (finfo[j].properties) Xfree((char *) finfo[j].properties);
+ if (finfo[j].properties) Xfree(finfo[j].properties);
}
- if (flist) Xfree((char *) flist);
- if (finfo) Xfree((char *) finfo);
+ Xfree(flist);
+ Xfree(finfo);
clearwire:
/* Clear the wire. */
@@ -208,7 +208,7 @@ XFreeFontInfo (
for (i = 1; i < actualCount; i++) {
Xfree (names[i]);
}
- Xfree((char *) names);
+ Xfree(names);
}
if (info) {
for (i = 0; i < actualCount; i++) {
@@ -216,12 +216,12 @@ XFreeFontInfo (
#ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(&info[i]);
#else
- Xfree ((char *) info[i].per_char);
+ Xfree (info[i].per_char);
#endif
if (info[i].properties)
- Xfree ((char *) info[i].properties);
+ Xfree (info[i].properties);
}
- Xfree((char *) info);
+ Xfree(info);
}
return 1;
}
diff --git a/nx-X11/lib/X11/FontNames.c b/nx-X11/lib/X11/FontNames.c
index b5bc7b4ba..e55f338ca 100644
--- a/nx-X11/lib/X11/FontNames.c
+++ b/nx-X11/lib/X11/FontNames.c
@@ -47,7 +47,7 @@ int *actualCount) /* RETURN */
int count = 0;
xListFontsReply rep;
register xListFontsReq *req;
- unsigned long rlen;
+ unsigned long rlen = 0;
LockDisplay(dpy);
GetReq(ListFonts, req);
@@ -66,15 +66,15 @@ int *actualCount) /* RETURN */
if (rep.nFonts) {
flist = Xmalloc (rep.nFonts * sizeof(char *));
- if (rep.length < (LONG_MAX >> 2)) {
+ if (rep.length > 0 && rep.length < (INT_MAX >> 2)) {
rlen = rep.length << 2;
ch = Xmalloc(rlen + 1);
/* +1 to leave room for last null-terminator */
}
if ((! flist) || (! ch)) {
- if (flist) Xfree((char *) flist);
- if (ch) Xfree(ch);
+ Xfree(flist);
+ Xfree(ch);
_XEatDataWords(dpy, rep.length);
*actualCount = 0;
UnlockDisplay(dpy);
@@ -93,11 +93,22 @@ int *actualCount) /* RETURN */
if (ch + length < chend) {
flist[i] = ch + 1; /* skip over length */
ch += length + 1; /* find next length ... */
- length = *(unsigned char *)ch;
- *ch = '\0'; /* and replace with null-termination */
- count++;
- } else
- flist[i] = NULL;
+ if (ch <= chend) {
+ length = *(unsigned char *)ch;
+ *ch = '\0'; /* and replace with null-termination */
+ count++;
+ } else {
+ Xfree(flist);
+ flist = NULL;
+ count = 0;
+ break;
+ }
+ } else {
+ Xfree(flist);
+ flist = NULL;
+ count = 0;
+ break;
+ }
}
}
*actualCount = count;
@@ -116,7 +127,7 @@ XFreeFontNames(char **list)
Xfree (*names);
}
Xfree (list[0]-1);
- Xfree ((char *)list);
+ Xfree (list);
}
return 1;
}
diff --git a/nx-X11/lib/X11/FreeEData.c b/nx-X11/lib/X11/FreeEData.c
index 3a7abca74..ce78467d3 100644
--- a/nx-X11/lib/X11/FreeEData.c
+++ b/nx-X11/lib/X11/FreeEData.c
@@ -36,9 +36,9 @@ _XFreeExtData (XExtData *extension)
while (extension) {
if (extension->free_private)
(*extension->free_private)(extension);
- else Xfree ((char *)extension->private_data);
+ else Xfree (extension->private_data);
temp = extension->next;
- Xfree ((char *)extension);
+ Xfree (extension);
extension = temp;
}
return 0;
diff --git a/nx-X11/lib/X11/FreeGC.c b/nx-X11/lib/X11/FreeGC.c
index cc9765551..926d50745 100644
--- a/nx-X11/lib/X11/FreeGC.c
+++ b/nx-X11/lib/X11/FreeGC.c
@@ -44,6 +44,7 @@ XFreeGC (
UnlockDisplay(dpy);
SyncHandle();
_XFreeExtData(gc->ext_data);
- Xfree ((char *) gc);
+ Xfree (gc);
return 1;
}
+
diff --git a/nx-X11/lib/X11/GetAtomNm.c b/nx-X11/lib/X11/GetAtomNm.c
index 996f7ebf9..32de50d23 100644
--- a/nx-X11/lib/X11/GetAtomNm.c
+++ b/nx-X11/lib/X11/GetAtomNm.c
@@ -46,7 +46,7 @@ char *_XGetAtomName(
for (idx = TABLESIZE; --idx >= 0; ) {
if ((e = *table++) && (e->atom == atom)) {
idx = strlen(EntryName(e)) + 1;
- if ((name = (char *)Xmalloc(idx)))
+ if ((name = Xmalloc(idx)))
strcpy(name, EntryName(e));
return name;
}
@@ -73,7 +73,7 @@ char *XGetAtomName(
SyncHandle();
return(NULL);
}
- if ((name = (char *) Xmalloc(rep.nameLength+1))) {
+ if ((name = Xmalloc(rep.nameLength + 1))) {
_XReadPad(dpy, name, (long)rep.nameLength);
name[rep.nameLength] = '\0';
_XUpdateAtomCache(dpy, name, atom, 0, -1, 0);
@@ -124,7 +124,7 @@ Bool _XGetAtomNameHandler(
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2,
False);
- state->names[state->idx] = (char *) Xmalloc(repl->nameLength+1);
+ state->names[state->idx] = Xmalloc(repl->nameLength + 1);
_XGetAsyncData(dpy, state->names[state->idx], buf, len,
SIZEOF(xGetAtomNameReply), repl->nameLength,
repl->length << 2);
@@ -170,7 +170,7 @@ XGetAtomNames (
}
if (missed >= 0) {
if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- if ((names_return[missed] = (char *) Xmalloc(rep.nameLength+1))) {
+ if ((names_return[missed] = Xmalloc(rep.nameLength + 1))) {
_XReadPad(dpy, names_return[missed], (long)rep.nameLength);
names_return[missed][rep.nameLength] = '\0';
_XUpdateAtomCache(dpy, names_return[missed], atoms[missed],
diff --git a/nx-X11/lib/X11/GetDflt.c b/nx-X11/lib/X11/GetDflt.c
index 749893c7e..f2098dff3 100644
--- a/nx-X11/lib/X11/GetDflt.c
+++ b/nx-X11/lib/X11/GetDflt.c
@@ -87,7 +87,7 @@ GetHomeDir(
len2 = strlen (ptr2);
}
if ((len1 + len2 + 1) < len)
- sprintf (dest, "%s%s", ptr1, (ptr2) ? ptr2 : "");
+ snprintf (dest, len, "%s%s", ptr1, (ptr2) ? ptr2 : "");
else
*dest = '\0';
#else
diff --git a/nx-X11/lib/X11/GetFPath.c b/nx-X11/lib/X11/GetFPath.c
index abd4a5dbd..8c3f49c95 100644
--- a/nx-X11/lib/X11/GetFPath.c
+++ b/nx-X11/lib/X11/GetFPath.c
@@ -35,7 +35,7 @@ char **XGetFontPath(
int *npaths) /* RETURN */
{
xGetFontPathReply rep;
- unsigned long nbytes;
+ unsigned long nbytes = 0;
char **flist = NULL;
char *ch = NULL;
char *chend;
@@ -50,15 +50,15 @@ char **XGetFontPath(
if (rep.nPaths) {
flist = Xmalloc(rep.nPaths * sizeof (char *));
- if (rep.length < (LONG_MAX >> 2)) {
+ if (rep.length < (INT_MAX >> 2)) {
nbytes = (unsigned long) rep.length << 2;
ch = Xmalloc (nbytes + 1);
/* +1 to leave room for last null-terminator */
}
if ((! flist) || (! ch)) {
- if (flist) Xfree((char *) flist);
- if (ch) Xfree(ch);
+ Xfree(flist);
+ Xfree(ch);
_XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy);
SyncHandle();
@@ -93,7 +93,7 @@ XFreeFontPath (char **list)
{
if (list != NULL) {
Xfree (list[0]-1);
- Xfree ((char *)list);
+ Xfree (list);
}
return 1;
}
diff --git a/nx-X11/lib/X11/GetFProp.c b/nx-X11/lib/X11/GetFProp.c
index 78e69c941..1e0cd3285 100644
--- a/nx-X11/lib/X11/GetFProp.c
+++ b/nx-X11/lib/X11/GetFProp.c
@@ -29,24 +29,24 @@ in this Software without prior written authorization from The Open Group.
#endif
#include "Xlibint.h"
-Bool XGetFontProperty (
+Bool
+XGetFontProperty(
XFontStruct *fs,
register Atom name,
unsigned long *valuePtr)
{
/* XXX this is a simple linear search for now. If the
- protocol is changed to sort the property list, this should
- become a binary search. */
+ protocol is changed to sort the property list, this should
+ become a binary search. */
register XFontProp *prop = fs->properties;
register XFontProp *last = prop + fs->n_properties;
+
while (prop != last) {
- if (prop->name == name) {
- *valuePtr = prop->card32;
- return (1);
- }
- prop++;
- }
- return (0);
+ if (prop->name == name) {
+ *valuePtr = prop->card32;
+ return (1);
+ }
+ prop++;
}
-
-
+ return (0);
+}
diff --git a/nx-X11/lib/X11/GetHints.c b/nx-X11/lib/X11/GetHints.c
index 1b522c8ef..7bfd35358 100644
--- a/nx-X11/lib/X11/GetHints.c
+++ b/nx-X11/lib/X11/GetHints.c
@@ -75,7 +75,7 @@ Status XGetSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) {
- if (prop != NULL) Xfree ((char *)prop);
+ Xfree (prop);
return(0);
}
hints->flags = (prop->flags & (USPosition|USSize|PAllHints));
@@ -93,7 +93,7 @@ Status XGetSizeHints (
hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
- Xfree((char *)prop);
+ Xfree(prop);
return(1);
}
@@ -124,11 +124,11 @@ XWMHints *XGetWMHints (
if ((actual_type != XA_WM_HINTS) ||
(nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) {
- if (prop != NULL) Xfree ((char *)prop);
+ Xfree (prop);
return(NULL);
}
/* static copies not allowed in library, due to reentrancy constraint*/
- if ((hints = (XWMHints *) Xcalloc (1, (unsigned) sizeof(XWMHints)))) {
+ if ((hints = Xcalloc (1, sizeof(XWMHints)))) {
hints->flags = prop->flags;
hints->input = (prop->input ? True : False);
hints->initial_state = cvtINT32toInt (prop->initialState);
@@ -142,7 +142,7 @@ XWMHints *XGetWMHints (
else
hints->window_group = 0;
}
- Xfree ((char *)prop);
+ Xfree (prop);
return(hints);
}
@@ -196,16 +196,15 @@ Status XGetIconSizes (
(nitems < NumPropIconSizeElements) ||
(nitems % NumPropIconSizeElements != 0) ||
(actual_format != 32)) {
- if (prop != NULL) Xfree ((char *)prop);
+ Xfree (prop);
return(0);
}
/* static copies not allowed in library, due to reentrancy constraint*/
nitems /= NumPropIconSizeElements;
- if (! (hp = hints = (XIconSize *)
- Xcalloc ((unsigned) nitems, (unsigned) sizeof(XIconSize)))) {
- if (prop) Xfree ((char *) prop);
+ if (! (hp = hints = Xcalloc (nitems, sizeof(XIconSize)))) {
+ Xfree (prop);
return 0;
}
@@ -222,7 +221,7 @@ Status XGetIconSizes (
}
*count = nitems;
*size_list = hints;
- Xfree ((char *)prop);
+ Xfree (prop);
return(1);
}
@@ -240,7 +239,7 @@ Status XGetCommand (
if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0;
if (tp.encoding != XA_STRING || tp.format != 8) {
- if (tp.value) Xfree ((char *) tp.value);
+ Xfree (tp.value);
return 0;
}
@@ -255,11 +254,11 @@ Status XGetCommand (
* create a string list and return if successful
*/
if (!XTextPropertyToStringList (&tp, &argv, &argc)) {
- if (tp.value) Xfree ((char *) tp.value);
+ Xfree (tp.value);
return (0);
}
- if (tp.value) Xfree ((char *) tp.value);
+ Xfree (tp.value);
*argvp = argv;
*argcp = argc;
return 1;
@@ -292,7 +291,7 @@ XGetTransientForHint(
return (1);
}
*propWindow = None;
- if (data) Xfree( (char *) data);
+ Xfree( (char *) data);
return(0);
}
@@ -317,23 +316,23 @@ XGetClassHint(
if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
len_name = strlen((char *) data);
- if (! (classhint->res_name = Xmalloc((unsigned) (len_name+1)))) {
- Xfree((char *) data);
+ if (! (classhint->res_name = Xmalloc(len_name + 1))) {
+ Xfree(data);
return (0);
}
strcpy(classhint->res_name, (char *) data);
if (len_name == nitems) len_name--;
len_class = strlen((char *) (data+len_name+1));
- if (! (classhint->res_class = Xmalloc((unsigned) (len_class+1)))) {
+ if (! (classhint->res_class = Xmalloc(len_class + 1))) {
Xfree(classhint->res_name);
classhint->res_name = (char *) NULL;
- Xfree((char *) data);
+ Xfree(data);
return (0);
}
strcpy(classhint->res_class, (char *) (data+len_name+1));
Xfree( (char *) data);
return(1);
}
- if (data) Xfree( (char *) data);
+ Xfree( (char *) data);
return(0);
}
diff --git a/nx-X11/lib/X11/GetImage.c b/nx-X11/lib/X11/GetImage.c
index 59fb45eb1..d80f6715f 100644
--- a/nx-X11/lib/X11/GetImage.c
+++ b/nx-X11/lib/X11/GetImage.c
@@ -59,6 +59,7 @@ XImage *XGetImage (
char *data;
unsigned long nbytes;
XImage *image;
+ int planes;
LockDisplay(dpy);
GetReq (GetImage, req);
/*
@@ -91,18 +92,28 @@ XImage *XGetImage (
return (XImage *) NULL;
}
_XReadPad (dpy, data, nbytes);
- if (format == XYPixmap)
- image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual),
- Ones (plane_mask &
- (((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))),
- format, 0, data, width, height, dpy->bitmap_pad, 0);
- else /* format == ZPixmap */
- image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual),
- rep.depth, ZPixmap, 0, data, width, height,
- _XGetScanlinePad(dpy, (int) rep.depth), 0);
+ if (format == XYPixmap) {
+ image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual),
+ Ones (plane_mask &
+ (((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))),
+ format, 0, data, width, height, dpy->bitmap_pad, 0);
+ planes = image->depth;
+ } else { /* format == ZPixmap */
+ image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual),
+ rep.depth, ZPixmap, 0, data, width, height,
+ _XGetScanlinePad(dpy, (int) rep.depth), 0);
+ planes = 1;
+ }
if (!image)
Xfree(data);
+ if (planes < 1 || image->height < 1 || image->bytes_per_line < 1 ||
+ INT_MAX / image->height <= image->bytes_per_line ||
+ INT_MAX / planes <= image->height * image->bytes_per_line ||
+ nbytes < planes * image->height * image->bytes_per_line) {
+ XDestroyImage(image);
+ image = NULL;
+ }
UnlockDisplay(dpy);
SyncHandle();
return (image);
diff --git a/nx-X11/lib/X11/GetNrmHint.c b/nx-X11/lib/X11/GetNrmHint.c
index 939d353b9..cc8fd235e 100644
--- a/nx-X11/lib/X11/GetNrmHint.c
+++ b/nx-X11/lib/X11/GetNrmHint.c
@@ -83,7 +83,7 @@ Status XGetWMSizeHints (
if ((actual_type != XA_WM_SIZE_HINTS) ||
(nitems < OldNumPropSizeElements) || (actual_format != 32)) {
- if (prop != NULL) Xfree ((char *)prop);
+ Xfree (prop);
return False;
}
@@ -112,7 +112,7 @@ Status XGetWMSizeHints (
*supplied |= (PBaseSize | PWinGravity);
}
hints->flags &= (*supplied); /* get rid of unwanted bits */
- Xfree((char *)prop);
+ Xfree(prop);
return True;
}
diff --git a/nx-X11/lib/X11/GetProp.c b/nx-X11/lib/X11/GetProp.c
index 4149199f5..9eb422ee3 100644
--- a/nx-X11/lib/X11/GetProp.c
+++ b/nx-X11/lib/X11/GetProp.c
@@ -47,7 +47,7 @@ XGetWindowProperty(
{
xGetPropertyReply reply;
register xGetPropertyReq *req;
- xError error;
+ xError error = {0};
/* Always initialize return values, in case callers fail to initialize
them and fail to check the return code for an error. */
diff --git a/nx-X11/lib/X11/GetRGBCMap.c b/nx-X11/lib/X11/GetRGBCMap.c
index b58468bab..746b53fbf 100644
--- a/nx-X11/lib/X11/GetRGBCMap.c
+++ b/nx-X11/lib/X11/GetRGBCMap.c
@@ -63,7 +63,7 @@ Status XGetRGBColormaps (
/* if wrong type or format, or too small for us, then punt */
if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) ||
(nitems < OldNumPropStandardColormapElements)) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
@@ -78,7 +78,7 @@ Status XGetRGBColormaps (
Screen *sp = _XScreenOfWindow (dpy, w);
if (!sp) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
def_visual = sp->root_visual->visualid;
@@ -90,7 +90,7 @@ Status XGetRGBColormaps (
ncmaps = (nitems / NumPropStandardColormapElements);
if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) !=
nitems) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
}
@@ -99,10 +99,9 @@ Status XGetRGBColormaps (
/*
* allocate array
*/
- cmaps = (XStandardColormap *) Xmalloc (ncmaps *
- sizeof (XStandardColormap));
+ cmaps = Xmalloc (ncmaps * sizeof (XStandardColormap));
if (!cmaps) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
@@ -127,7 +126,7 @@ Status XGetRGBColormaps (
map->killid = (old_style ? None : prop->killid);
}
}
- Xfree ((char *) data);
+ Xfree (data);
*stdcmap = cmaps;
*count = ncmaps;
return True;
diff --git a/nx-X11/lib/X11/GetStCmap.c b/nx-X11/lib/X11/GetStCmap.c
index 1ca6a0c70..560de67ba 100644
--- a/nx-X11/lib/X11/GetStCmap.c
+++ b/nx-X11/lib/X11/GetStCmap.c
@@ -81,7 +81,7 @@ Status XGetStandardColormap (
int i;
if (!sp) {
- if (stdcmaps) Xfree ((char *) stdcmaps);
+ Xfree (stdcmaps);
return False;
}
vid = sp->root_visual->visualid;
@@ -91,7 +91,7 @@ Status XGetStandardColormap (
}
if (i == nstdcmaps) { /* not found */
- Xfree ((char *) stdcmaps);
+ Xfree (stdcmaps);
return False;
}
use = &stdcmaps[i];
@@ -111,7 +111,7 @@ Status XGetStandardColormap (
cmap->blue_mult = use->blue_mult;
cmap->base_pixel = use->base_pixel;
- Xfree ((char *) stdcmaps); /* don't need alloced memory */
+ Xfree (stdcmaps); /* don't need alloced memory */
}
return stat;
}
diff --git a/nx-X11/lib/X11/GetWAttrs.c b/nx-X11/lib/X11/GetWAttrs.c
index 4d51893d6..c10824cf4 100644
--- a/nx-X11/lib/X11/GetWAttrs.c
+++ b/nx-X11/lib/X11/GetWAttrs.c
@@ -89,14 +89,14 @@ _XGetWindowAttributes(
register Display *dpy,
Window w,
XWindowAttributes *attr)
-{
+{
xGetGeometryReply rep;
register xResourceReq *req;
register int i;
register Screen *sp;
_XAsyncHandler async;
_XWAttrsState async_state;
-
+
GetResReq(GetWindowAttributes, w, req);
async_state.attr_seq = dpy->request;
diff --git a/nx-X11/lib/X11/GetWMCMapW.c b/nx-X11/lib/X11/GetWMCMapW.c
index 04f98a8a8..722ec60f8 100644
--- a/nx-X11/lib/X11/GetWMCMapW.c
+++ b/nx-X11/lib/X11/GetWMCMapW.c
@@ -77,7 +77,7 @@ Status XGetWMColormapWindows (
return False;
if (actual_type != XA_WINDOW || actual_format != 32) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
diff --git a/nx-X11/lib/X11/GetWMProto.c b/nx-X11/lib/X11/GetWMProto.c
index 1303382fe..1ea4f55d5 100644
--- a/nx-X11/lib/X11/GetWMProto.c
+++ b/nx-X11/lib/X11/GetWMProto.c
@@ -77,7 +77,7 @@ Status XGetWMProtocols (
return False;
if (actual_type != XA_ATOM || actual_format != 32) {
- if (data) Xfree ((char *) data);
+ Xfree (data);
return False;
}
diff --git a/nx-X11/lib/X11/HVC.c b/nx-X11/lib/X11/HVC.c
index f790b1335..98d7142c3 100644
--- a/nx-X11/lib/X11/HVC.c
+++ b/nx-X11/lib/X11/HVC.c
@@ -176,13 +176,13 @@ TekHVC_ParseString(
* XcmsSuccess if valid.
*/
{
- int n;
+ size_t n;
char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure);
}
- n = (int)(pchar - spec);
+ n = (size_t)(pchar - spec);
/*
* Check for proper prefix.
@@ -349,7 +349,7 @@ XcmsTekHVCToCIEuvY(
XcmsCIEuvY uvY_return;
XcmsFloat tempHue, u, v;
XcmsFloat tmpVal;
- register int i;
+ unsigned int i;
/*
* Check arguments
@@ -468,7 +468,7 @@ XcmsCIEuvYToTekHVC(
XcmsColor *pColor = pColors_in_out;
XcmsColor whitePt;
XcmsTekHVC HVC_return;
- register int i;
+ unsigned int i;
/*
* Check arguments
diff --git a/nx-X11/lib/X11/Host.c b/nx-X11/lib/X11/Host.c
index bfa87507d..b07c9c312 100644
--- a/nx-X11/lib/X11/Host.c
+++ b/nx-X11/lib/X11/Host.c
@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group.
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2004 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/nx-X11/lib/X11/ICWrap.c b/nx-X11/lib/X11/ICWrap.c
index 1eacfa5f1..69f080d87 100644
--- a/nx-X11/lib/X11/ICWrap.c
+++ b/nx-X11/lib/X11/ICWrap.c
@@ -128,7 +128,7 @@ _XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
return;
}
- args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg));
+ args = Xmalloc(((unsigned)max_count + 1) * sizeof(XIMArg));
*args_return = args;
if (!args) return;
@@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...)
va_list var;
int total_count;
XIMArg *args;
- char *ret;
+ char *ret = NULL;
/*
* so count the stuff dangling here
@@ -185,8 +185,9 @@ XSetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args);
va_end(var);
- ret = (*im->methods->set_values) (im, args);
- if (args) Xfree((char *)args);
+ if (im && im->methods)
+ ret = (*im->methods->set_values) (im, args);
+ Xfree(args);
return ret;
}
@@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...)
va_list var;
int total_count;
XIMArg *args;
- char *ret;
+ char *ret = NULL;
/*
* so count the stuff dangling here
@@ -212,8 +213,9 @@ XGetIMValues(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args);
va_end(var);
- ret = (*im->methods->get_values) (im, args);
- if (args) Xfree((char *)args);
+ if (im && im->methods)
+ ret = (*im->methods->get_values) (im, args);
+ Xfree(args);
return ret;
}
@@ -228,7 +230,7 @@ XCreateIC(XIM im, ...)
va_list var;
int total_count;
XIMArg *args;
- XIC ic;
+ XIC ic = NULL;
/*
* so count the stuff dangling here
@@ -244,8 +246,9 @@ XCreateIC(XIM im, ...)
_XIMVaToNestedList(var, total_count, &args);
va_end(var);
- ic = (XIC) (*im->methods->create_ic) (im, args);
- if (args) Xfree((char *)args);
+ if (im && im->methods)
+ ic = (XIC) (*im->methods->create_ic) (im, args);
+ Xfree(args);
if (ic) {
ic->core.next = im->core.ic_chain;
im->core.ic_chain = ic;
@@ -271,7 +274,7 @@ XDestroyIC(XIC ic)
}
}
}
- Xfree ((char *) ic);
+ Xfree (ic);
}
char *
@@ -300,7 +303,7 @@ XGetICValues(XIC ic, ...)
va_end(var);
ret = (*ic->methods->get_values) (ic, args);
- if (args) Xfree((char *)args);
+ Xfree(args);
return ret;
}
@@ -330,7 +333,7 @@ XSetICValues(XIC ic, ...)
va_end(var);
ret = (*ic->methods->set_values) (ic, args);
- if (args) Xfree((char *)args);
+ Xfree(args);
return ret;
}
diff --git a/nx-X11/lib/X11/IMWrap.c b/nx-X11/lib/X11/IMWrap.c
index 0f6ed5593..a7c1d98c1 100644
--- a/nx-X11/lib/X11/IMWrap.c
+++ b/nx-X11/lib/X11/IMWrap.c
@@ -134,7 +134,7 @@ XCloseIM(XIM im)
s = (im->methods->close) (im);
for (ic = im->core.ic_chain; ic; ic = ic->core.next)
ic->core.im = (XIM)NULL;
- Xfree ((char *) im);
+ Xfree (im);
_XCloseLC (lcd);
return (s);
}
diff --git a/nx-X11/lib/X11/Iconify.c b/nx-X11/lib/X11/Iconify.c
index 9e24c6b86..542f5885c 100644
--- a/nx-X11/lib/X11/Iconify.c
+++ b/nx-X11/lib/X11/Iconify.c
@@ -67,19 +67,23 @@ Status XIconifyWindow (
Window w,
int screen)
{
- XClientMessageEvent ev;
- Window root = RootWindow (dpy, screen);
Atom prop;
prop = XInternAtom (dpy, "WM_CHANGE_STATE", False);
- if (prop == None) return False;
+ if (prop == None)
+ return False;
+ else {
+ XClientMessageEvent ev = {
+ .type = ClientMessage,
+ .window = w,
+ .message_type = prop,
+ .format = 32,
+ .data.l[0] = IconicState
+ };
+ Window root = RootWindow (dpy, screen);
- ev.type = ClientMessage;
- ev.window = w;
- ev.message_type = prop;
- ev.format = 32;
- ev.data.l[0] = IconicState;
- return (XSendEvent (dpy, root, False,
- SubstructureRedirectMask|SubstructureNotifyMask,
- (XEvent *)&ev));
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+ }
}
diff --git a/nx-X11/lib/X11/IdOfPr.c b/nx-X11/lib/X11/IdOfPr.c
index 3a92e0a11..9f43dd387 100644
--- a/nx-X11/lib/X11/IdOfPr.c
+++ b/nx-X11/lib/X11/IdOfPr.c
@@ -61,13 +61,13 @@ XcmsFormatOfPrefix(char *prefix)
XcmsColorSpace **papColorSpaces;
char string_buf[64];
char *string_lowered;
- int len;
+ size_t len;
/*
* While copying prefix to string_lowered, convert to lowercase
*/
if ((len = strlen(prefix)) >= sizeof(string_buf)) {
- string_lowered = (char *) Xmalloc(len+1);
+ string_lowered = Xmalloc(len+1);
} else {
string_lowered = string_buf;
}
diff --git a/nx-X11/lib/X11/ImUtil.c b/nx-X11/lib/X11/ImUtil.c
index 00b6f7db8..b0d421680 100644
--- a/nx-X11/lib/X11/ImUtil.c
+++ b/nx-X11/lib/X11/ImUtil.c
@@ -332,7 +332,7 @@ XImage *XCreateImage (
(xpad != 8 && xpad != 16 && xpad != 32) ||
offset < 0)
return (XImage *) NULL;
- if ((image = (XImage *) Xcalloc(1, (unsigned) sizeof(XImage))) == NULL)
+ if ((image = Xcalloc(1, sizeof(XImage))) == NULL)
return (XImage *) NULL;
image->width = width;
@@ -372,6 +372,7 @@ XImage *XCreateImage (
if (image_bytes_per_line == 0) {
image->bytes_per_line = min_bytes_per_line;
} else if (image_bytes_per_line < min_bytes_per_line) {
+ Xfree(image);
return NULL;
} else {
image->bytes_per_line = image_bytes_per_line;
@@ -433,9 +434,9 @@ Status XInitImage (XImage *image)
static int _XDestroyImage (XImage *ximage)
{
- if (ximage->data != NULL) Xfree((char *)ximage->data);
- if (ximage->obdata != NULL) Xfree((char *)ximage->obdata);
- Xfree((char *)ximage);
+ Xfree(ximage->data);
+ Xfree(ximage->obdata);
+ Xfree(ximage);
return 1;
}
@@ -542,8 +543,7 @@ static unsigned long _XGetPixel32 (
[y * ximage->bytes_per_line + (x << 2)];
if (*((const char *)&byteorderpixel) == ximage->byte_order)
pixel = *((CARD32 *)addr);
- else
- if (ximage->byte_order == MSBFirst)
+ else if (ximage->byte_order == MSBFirst)
pixel = ((unsigned long)addr[0] << 24 |
(unsigned long)addr[1] << 16 |
(unsigned long)addr[2] << 8 |
@@ -731,8 +731,7 @@ static int _XPutPixel32 (
[y * ximage->bytes_per_line + (x << 2)];
if (*((const char *)&byteorderpixel) == ximage->byte_order)
*((CARD32 *)addr) = pixel;
- else
- if (ximage->byte_order == MSBFirst) {
+ else if (ximage->byte_order == MSBFirst) {
addr[0] = pixel >> 24;
addr[1] = pixel >> 16;
addr[2] = pixel >> 8;
@@ -843,7 +842,7 @@ static XImage *_XSubImage (
register unsigned long pixel;
char *data;
- if ((subimage = (XImage *) Xcalloc (1, sizeof (XImage))) == NULL)
+ if ((subimage = Xcalloc (1, sizeof (XImage))) == NULL)
return (XImage *) NULL;
subimage->width = width;
subimage->height = height;
@@ -869,8 +868,8 @@ static XImage *_XSubImage (
_XInitImageFuncPtrs (subimage);
dsize = subimage->bytes_per_line * height;
if (subimage->format == XYPixmap) dsize = dsize * subimage->depth;
- if (((data = Xcalloc (1, (unsigned) dsize)) == NULL) && (dsize > 0)) {
- Xfree((char *) subimage);
+ if (((data = Xcalloc (1, dsize)) == NULL) && (dsize > 0)) {
+ Xfree(subimage);
return (XImage *) NULL;
}
subimage->data = data;
diff --git a/nx-X11/lib/X11/Imakefile b/nx-X11/lib/X11/Imakefile
index 5a1fc5ff2..8549f69cd 100644
--- a/nx-X11/lib/X11/Imakefile
+++ b/nx-X11/lib/X11/Imakefile
@@ -159,8 +159,7 @@ EXTRA_LIBRARIES = /**/
XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines
EDB_DEFINES = -DERRORDB=\"$(USRDATADIR)/XErrorDB\"
- KDB_DEFINES = -DKEYSYMDB=\"$(USRDATADIR)/XKeysymDB\"
- CMS_DEFINES = -DXCMSDB=\"$(USRDATADIR)/Xcms.txt\"
+ CMS_DEFINES = -DXCMSDB=\"$(USRDATADIR)/Xcms.txt\" -DXCMSDIR=\"$(USRDATADIR)\"
#if HasSnprintf
MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11
#endif
@@ -925,10 +924,7 @@ STATICI18NSTATICSRCS = \
imTrX.c \
imTransR.c \
imTrans.c \
- lcEuc.c \
lcGenConv.c \
- lcJis.c \
- lcSjis.c \
lcUTF8Load.c \
omDefault.c \
omGeneric.c \
@@ -999,10 +995,7 @@ STATICI18NSTATICOBJS = \
imTrX.o \
imTransR.o \
imTrans.o \
- lcEuc.o \
lcGenConv.o \
- lcJis.o \
- lcSjis.o \
lcUTF8Load.o \
omDefault.o \
omGeneric.o \
@@ -1063,7 +1056,6 @@ EXTRASHAREDOBJS = $(STATICLCOBJS)
#include <Library.tmpl>
SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
-SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES))
SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS))
SpecialCLibObjectRule(x11_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES))
SpecialCLibObjectRule(xim_trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES))
@@ -1100,7 +1092,6 @@ SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_D
InstallNonExecFile(Xcms.txt,$(LIBDIR))
#endif
InstallNonExecFile(XErrorDB,$(LIBDIR))
-InstallNonExecFile(XKeysymDB,$(LIBDIR))
InstallLintLibrary(X11,$(LINTLIBDIR))
#ifdef QNX4Architecture
diff --git a/nx-X11/lib/X11/InitExt.c b/nx-X11/lib/X11/InitExt.c
index 21c392c0e..d02527d5c 100644
--- a/nx-X11/lib/X11/InitExt.c
+++ b/nx-X11/lib/X11/InitExt.c
@@ -49,15 +49,14 @@ XExtCodes *XInitExtension (
&codes.first_error)) return (NULL);
LockDisplay (dpy);
- if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) ||
- ! (ext->name = Xmalloc((unsigned) strlen(name) + 1))) {
- if (ext) Xfree((char *) ext);
+ if (! (ext = Xcalloc (1, sizeof (_XExtension))) ||
+ ! (ext->name = strdup(name))) {
+ Xfree(ext);
UnlockDisplay(dpy);
return (XExtCodes *) NULL;
}
codes.extension = dpy->ext_number++;
ext->codes = codes;
- (void) strcpy(ext->name, name);
/* chain it onto the display list */
ext->next = dpy->ext_procs;
@@ -72,7 +71,7 @@ XExtCodes *XAddExtension (Display *dpy)
register _XExtension *ext;
LockDisplay (dpy);
- if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) {
+ if (! (ext = Xcalloc (1, sizeof (_XExtension)))) {
UnlockDisplay(dpy);
return (XExtCodes *) NULL;
}
diff --git a/nx-X11/lib/X11/IntAtom.c b/nx-X11/lib/X11/IntAtom.c
index 7a5625840..3042b65dd 100644
--- a/nx-X11/lib/X11/IntAtom.c
+++ b/nx-X11/lib/X11/IntAtom.c
@@ -47,9 +47,9 @@ _XFreeAtomTable(Display *dpy)
table = dpy->atoms->table;
for (i = TABLESIZE; --i >= 0; ) {
if ((e = *table++) && (e != RESERVED))
- Xfree((char *)e);
+ Xfree(e);
}
- Xfree((char *)dpy->atoms);
+ Xfree(dpy->atoms);
}
}
@@ -72,7 +72,7 @@ Atom _XInternAtom(
/* look in the cache first */
if (!(atoms = dpy->atoms)) {
- dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->atoms = atoms = Xcalloc(1, sizeof(AtomTable));
dpy->free_funcs->atoms = _XFreeAtomTable;
}
sig = 0;
@@ -127,7 +127,7 @@ _XUpdateAtomCache(
if (!dpy->atoms) {
if (idx < 0) {
- dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->atoms = Xcalloc(1, sizeof(AtomTable));
dpy->free_funcs->atoms = _XFreeAtomTable;
}
if (!dpy->atoms)
@@ -147,13 +147,13 @@ _XUpdateAtomCache(
}
}
}
- e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1);
+ e = Xmalloc(sizeof(EntryRec) + n + 1);
if (e) {
e->sig = sig;
e->atom = atom;
strcpy(EntryName(e), name);
if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED))
- Xfree((char *)oe);
+ Xfree(oe);
dpy->atoms->table[idx] = e;
}
}
diff --git a/nx-X11/lib/X11/Key.h b/nx-X11/lib/X11/Key.h
index 0fe89ba37..3a1639c5c 100644
--- a/nx-X11/lib/X11/Key.h
+++ b/nx-X11/lib/X11/Key.h
@@ -2,6 +2,9 @@
#ifndef _KEY_H_
#define _KEY_H_
+#include <nx-X11/Xlib.h>
+#include <nx-X11/Xresource.h>
+
#ifndef NEEDKTABLE
extern const unsigned char _XkeyTable[];
#endif
diff --git a/nx-X11/lib/X11/KeyBind.c b/nx-X11/lib/X11/KeyBind.c
index c7f17c4da..acaf7fd8f 100644
--- a/nx-X11/lib/X11/KeyBind.c
+++ b/nx-X11/lib/X11/KeyBind.c
@@ -44,14 +44,10 @@ in this Software without prior written authorization from The Open Group.
#define XK_CAUCASUS
#define XK_VIETNAMESE
#define XK_XKB_KEYS
+#define XK_SINHALA
#include <nx-X11/keysymdef.h>
#include <stdio.h>
-#ifdef USE_OWN_COMPOSE
-#include "imComp.h"
-
-#endif
-
#include "Xresource.h"
#include "Key.h"
@@ -238,7 +234,7 @@ XRefreshKeyboardMapping(register XMappingEvent *event)
*/
LockDisplay(event->display);
if (event->display->keysyms) {
- Xfree ((char *)event->display->keysyms);
+ Xfree (event->display->keysyms);
event->display->keysyms = NULL;
}
UnlockDisplay(event->display);
@@ -275,12 +271,13 @@ _XKeyInitialize(
if (! keysyms) return 0;
LockDisplay(dpy);
- if (dpy->keysyms)
- Xfree ((char *)dpy->keysyms);
+
+ Xfree (dpy->keysyms);
dpy->keysyms = keysyms;
dpy->keysyms_per_keycode = per;
if (dpy->modifiermap)
ResetModMap(dpy);
+
UnlockDisplay(dpy);
}
if (!dpy->modifiermap)
@@ -890,73 +887,6 @@ XLookupString (
&modifiers, &symbol))
return 0;
-#ifdef USE_OWN_COMPOSE
- if ( status ) {
- static int been_here= 0;
- if ( !been_here ) {
- XimCompInitTables();
- been_here = 1;
- }
- if ( !XimCompLegalStatus(status) ) {
- status->compose_ptr = NULL;
- status->chars_matched = 0;
- }
- if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
- XimCompIsComposeKey(symbol,event->keycode,status) ) {
- XimCompRtrn rtrn;
- switch (XimCompProcessSym(status,symbol,&rtrn)) {
- case XIM_COMP_IGNORE:
- break;
- case XIM_COMP_IN_PROGRESS:
- if ( keysym!=NULL )
- *keysym = NoSymbol;
- return 0;
- case XIM_COMP_FAIL:
- {
- int n = 0, len= 0;
- for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
- if ( nbytes-len > 0 ) {
- len+= _XTranslateKeySym(event->display,rtrn.sym[n],
- event->state,
- buffer+len,nbytes-len);
- }
- }
- if ( keysym!=NULL ) {
- if ( n==1 ) *keysym = rtrn.sym[0];
- else *keysym = NoSymbol;
- }
- return len;
- }
- case XIM_COMP_SUCCEED:
- {
- int len,n = 0;
-
- symbol = rtrn.matchSym;
- if ( keysym!=NULL ) *keysym = symbol;
- if ( rtrn.str[0]!='\0' ) {
- strncpy(buffer,rtrn.str,nbytes-1);
- buffer[nbytes-1]= '\0';
- len = strlen(buffer);
- }
- else {
- len = _XTranslateKeySym(event->display,symbol,
- event->state,
- buffer,nbytes);
- }
- for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
- if ( nbytes-len > 0 ) {
- len+= _XTranslateKeySym(event->display,rtrn.sym[n],
- event->state,
- buffer+len,nbytes-len);
- }
- }
- return len;
- }
- }
- }
- }
-#endif
-
if (keysym)
*keysym = symbol;
/* arguable whether to use (event->state & ~modifiers) here */
@@ -973,8 +903,8 @@ _XFreeKeyBindings(
for (p = dpy->key_bindings; p; p = np) {
np = p->next;
Xfree(p->string);
- Xfree((char *)p->modifiers);
- Xfree((char *)p);
+ Xfree(p->modifiers);
+ Xfree(p);
}
}
@@ -996,15 +926,13 @@ XRebindKeysym (
tmp = dpy->key_bindings;
nb = sizeof(KeySym) * nm;
- if ((! (p = (struct _XKeytrans *) Xmalloc( sizeof(struct _XKeytrans)))) ||
- ((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) &&
- (nbytes > 0)) ||
- ((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) &&
- (nb > 0))) {
+ if ((! (p = Xcalloc( 1, sizeof(struct _XKeytrans)))) ||
+ ((! (p->string = Xmalloc(nbytes))) && (nbytes > 0)) ||
+ ((! (p->modifiers = Xmalloc(nb))) && (nb > 0))) {
if (p) {
- if (p->string) Xfree(p->string);
- if (p->modifiers) Xfree((char *) p->modifiers);
- Xfree((char *) p);
+ Xfree(p->string);
+ Xfree(p->modifiers);
+ Xfree(p);
}
UnlockDisplay(dpy);
return 0;
@@ -1013,7 +941,7 @@ XRebindKeysym (
dpy->key_bindings = p;
dpy->free_funcs->key_bindings = _XFreeKeyBindings;
p->next = tmp; /* chain onto list */
- memcpy (p->string, (char *) str, nbytes);
+ memcpy (p->string, str, nbytes);
p->len = nbytes;
memcpy ((char *) p->modifiers, (char *) mlist, nb);
p->key = keysym;
diff --git a/nx-X11/lib/X11/KeysymStr.c b/nx-X11/lib/X11/KeysymStr.c
index 96c49227a..ba6c8450a 100644
--- a/nx-X11/lib/X11/KeysymStr.c
+++ b/nx-X11/lib/X11/KeysymStr.c
@@ -70,11 +70,6 @@ SameValue(
char *XKeysymToString(KeySym ks)
{
- register int i, n;
- int h;
- register int idx;
- const unsigned char *entry;
- unsigned char val1, val2, val3, val4;
XrmDatabase keysymdb;
if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
@@ -83,16 +78,17 @@ char *XKeysymToString(KeySym ks)
ks = 0;
if (ks <= 0x1fffffff)
{
- val1 = ks >> 24;
- val2 = (ks >> 16) & 0xff;
- val3 = (ks >> 8) & 0xff;
- val4 = ks & 0xff;
- i = ks % VTABLESIZE;
- h = i + 1;
- n = VMAXHASH;
+ unsigned char val1 = ks >> 24;
+ unsigned char val2 = (ks >> 16) & 0xff;
+ unsigned char val3 = (ks >> 8) & 0xff;
+ unsigned char val4 = ks & 0xff;
+ int i = ks % VTABLESIZE;
+ int h = i + 1;
+ int n = VMAXHASH;
+ int idx;
while ((idx = hashKeysym[i]))
{
- entry = &_XkeyTable[idx];
+ const unsigned char *entry = &_XkeyTable[idx];
if ((entry[0] == val1) && (entry[1] == val2) &&
(entry[2] == val3) && (entry[3] == val4))
return ((char *)entry + 4);
@@ -111,7 +107,7 @@ char *XKeysymToString(KeySym ks)
XrmQuark empty = NULLQUARK;
GRNData data;
- sprintf(buf, "%lX", ks);
+ snprintf(buf, sizeof(buf), "%lX", ks);
resval.addr = (XPointer)buf;
resval.size = strlen(buf) + 1;
data.name = (char *)NULL;
@@ -136,7 +132,7 @@ char *XKeysymToString(KeySym ks)
i--;
s[i--] = '\0';
for (; i; i--){
- val1 = val & 0xf;
+ unsigned char val1 = val & 0xf;
val >>= 4;
if (val1 < 10)
s[i] = '0'+ val1;
diff --git a/nx-X11/lib/X11/LRGB.c b/nx-X11/lib/X11/LRGB.c
index dbdddb457..4bfa3cfb1 100644
--- a/nx-X11/lib/X11/LRGB.c
+++ b/nx-X11/lib/X11/LRGB.c
@@ -511,7 +511,7 @@ LINEAR_RGB_InitSCCData(
*pValue++ = (long)_XcmsGetElement(format_return, &pChar,
&nitems) / (XcmsFloat)XDCCC_NUMBER;
}
- Xfree ((char *)property_return);
+ Xfree (property_return);
pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
pScreenData->RGBtoXYZmatrix[0][0] +
pScreenData->RGBtoXYZmatrix[0][1] +
@@ -573,7 +573,6 @@ LINEAR_RGB_InitSCCData(
if (CorrectAtom == None ||
!_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), CorrectAtom,
&format_return, &nitems, &nbytes_return, &property_return)) {
- Xfree ((char *)property_return);
goto FreeSCCData;
}
@@ -595,8 +594,7 @@ LINEAR_RGB_InitSCCData(
* intensity2
*/
if (nitems < 9) {
- Xfree ((char *)property_return);
- goto FreeSCCData;
+ goto Free_property_return;
}
count = 3;
break;
@@ -612,8 +610,7 @@ LINEAR_RGB_InitSCCData(
* intensity2
*/
if (nitems < 7) {
- Xfree ((char *)property_return);
- goto FreeSCCData;
+ goto Free_property_return;
}
count = 1;
break;
@@ -628,14 +625,12 @@ LINEAR_RGB_InitSCCData(
* intensity2
*/
if (nitems < 6) {
- Xfree ((char *)property_return);
- goto FreeSCCData;
+ goto Free_property_return;
}
count = 0;
break;
default:
- Xfree ((char *)property_return);
- goto FreeSCCData;
+ goto Free_property_return;
}
/*
@@ -658,7 +653,7 @@ LINEAR_RGB_InitSCCData(
*/
if (!(pScreenData = (LINEAR_RGB_SCCData *)
Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
- return(XcmsFailure);
+ goto Free_property_return;
}
/* copy matrices */
memcpy((char *)pScreenData, (char *)pScreenDefaultData,
@@ -667,8 +662,8 @@ LINEAR_RGB_InitSCCData(
/* Create, initialize, and add map */
if (!(pNewMap = (XcmsIntensityMap *)
Xcalloc (1, sizeof(XcmsIntensityMap)))) {
- Xfree((char *)pScreenData);
- return(XcmsFailure);
+ Xfree(pScreenData);
+ goto Free_property_return;
}
pNewMap->visualID = visualID;
pNewMap->screenData = (XPointer)pScreenData;
@@ -687,7 +682,7 @@ LINEAR_RGB_InitSCCData(
/* Red Intensity Table */
if (!(pScreenData->pRedTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) {
- goto FreeSCCData;
+ goto Free_property_return;
}
if (_XcmsGetTableType0(pScreenData->pRedTbl, format_return, &pChar,
&nitems) == XcmsFailure) {
@@ -724,7 +719,7 @@ LINEAR_RGB_InitSCCData(
/* Red Intensity Table */
if (!(pScreenData->pRedTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) {
- goto FreeSCCData;
+ goto Free_property_return;
}
if (_XcmsGetTableType1(pScreenData->pRedTbl, format_return, &pChar,
&nitems) == XcmsFailure) {
@@ -753,7 +748,7 @@ LINEAR_RGB_InitSCCData(
/* Blue Intensity Table */
if (!(pScreenData->pBlueTbl = (IntensityTbl *)
Xcalloc (1, sizeof(IntensityTbl)))) {
- goto FreeBlueTblElements;
+ goto FreeGreenTblElements;
}
if (_XcmsGetTableType1(pScreenData->pBlueTbl, format_return, &pChar,
&nitems) == XcmsFailure) {
@@ -761,8 +756,7 @@ LINEAR_RGB_InitSCCData(
}
}
} else {
- Xfree ((char *)property_return);
- goto FreeSCCData;
+ goto Free_property_return;
}
#ifdef ALLDEBUG
@@ -788,7 +782,7 @@ LINEAR_RGB_InitSCCData(
#endif /* ALLDEBUG */
}
- Xfree ((char *)property_return);
+ Xfree (property_return);
/* Free the old memory and use the new structure created. */
LINEAR_RGB_FreeSCCData(pPerScrnInfo->screenData);
@@ -802,25 +796,28 @@ LINEAR_RGB_InitSCCData(
return(XcmsSuccess);
FreeBlueTblElements:
- Xfree((char *)pScreenData->pBlueTbl->pBase);
+ Xfree(pScreenData->pBlueTbl->pBase);
FreeBlueTbl:
- Xfree((char *)pScreenData->pBlueTbl);
+ Xfree(pScreenData->pBlueTbl);
FreeGreenTblElements:
- Xfree((char *)pScreenData->pBlueTbl->pBase);
+ Xfree(pScreenData->pGreenTbl->pBase);
FreeGreenTbl:
- Xfree((char *)pScreenData->pGreenTbl);
+ Xfree(pScreenData->pGreenTbl);
FreeRedTblElements:
- Xfree((char *)pScreenData->pRedTbl->pBase);
+ Xfree(pScreenData->pRedTbl->pBase);
FreeRedTbl:
- Xfree((char *)pScreenData->pRedTbl);
+ Xfree(pScreenData->pRedTbl);
+
+Free_property_return:
+ Xfree (property_return);
FreeSCCData:
- Xfree((char *)pScreenData);
+ Xfree(pScreenDefaultData);
pPerScrnInfo->state = XcmsInitNone;
return(XcmsFailure);
}
@@ -852,30 +849,30 @@ LINEAR_RGB_FreeSCCData(
if (pScreenData->pRedTbl->pBase !=
pScreenData->pGreenTbl->pBase) {
if (pScreenData->pGreenTbl->pBase) {
- Xfree ((char *)pScreenData->pGreenTbl->pBase);
+ Xfree (pScreenData->pGreenTbl->pBase);
}
}
if (pScreenData->pGreenTbl != pScreenData->pRedTbl) {
- Xfree ((char *)pScreenData->pGreenTbl);
+ Xfree (pScreenData->pGreenTbl);
}
}
if (pScreenData->pBlueTbl) {
if (pScreenData->pRedTbl->pBase !=
pScreenData->pBlueTbl->pBase) {
if (pScreenData->pBlueTbl->pBase) {
- Xfree ((char *)pScreenData->pBlueTbl->pBase);
+ Xfree (pScreenData->pBlueTbl->pBase);
}
}
if (pScreenData->pBlueTbl != pScreenData->pRedTbl) {
- Xfree ((char *)pScreenData->pBlueTbl);
+ Xfree (pScreenData->pBlueTbl);
}
}
if (pScreenData->pRedTbl->pBase) {
- Xfree ((char *)pScreenData->pRedTbl->pBase);
+ Xfree (pScreenData->pRedTbl->pBase);
}
- Xfree ((char *)pScreenData->pRedTbl);
+ Xfree (pScreenData->pRedTbl);
}
- Xfree ((char *)pScreenData);
+ Xfree (pScreenData);
}
}
@@ -969,7 +966,7 @@ _XcmsGetTableType1(
*
*/
{
- int count;
+ unsigned int count;
unsigned int max_index;
IntensityRec *pIRec;
@@ -1408,13 +1405,13 @@ XcmsLRGB_RGBi_ParseString(
* 0 if failed, non-zero otherwise.
*/
{
- int n;
+ size_t n;
char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure);
}
- n = (int)(pchar - spec);
+ n = (size_t)(pchar - spec);
/*
* Check for proper prefix.
diff --git a/nx-X11/lib/X11/Lab.c b/nx-X11/lib/X11/Lab.c
index 642886ec2..6f7075643 100644
--- a/nx-X11/lib/X11/Lab.c
+++ b/nx-X11/lib/X11/Lab.c
@@ -251,7 +251,7 @@ XcmsCIELabToCIEXYZ(
XcmsCIEXYZ XYZ_return;
XcmsFloat tmpFloat, tmpL;
XcmsColor whitePt;
- int i;
+ unsigned int i;
XcmsColor *pColor = pColors_in_out;
/*
@@ -354,7 +354,7 @@ XcmsCIEXYZToCIELab(
XcmsCIELab Lab_return;
XcmsFloat fX_Xn, fY_Yn, fZ_Zn;
XcmsColor whitePt;
- int i;
+ unsigned int i;
XcmsColor *pColor = pColors_in_out;
/*
diff --git a/nx-X11/lib/X11/LiHosts.c b/nx-X11/lib/X11/LiHosts.c
index 6ec956e72..83cf3c791 100644
--- a/nx-X11/lib/X11/LiHosts.c
+++ b/nx-X11/lib/X11/LiHosts.c
@@ -34,7 +34,7 @@ X Window System is a trademark of The Open Group.
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2004 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"),
@@ -154,3 +154,4 @@ XHostAddress *XListHosts (
+
diff --git a/nx-X11/lib/X11/ListExt.c b/nx-X11/lib/X11/ListExt.c
index e925c4773..0516e4596 100644
--- a/nx-X11/lib/X11/ListExt.c
+++ b/nx-X11/lib/X11/ListExt.c
@@ -42,7 +42,7 @@ char **XListExtensions(
register unsigned i;
register int length;
register xReq *req;
- unsigned long rlen;
+ unsigned long rlen = 0;
LockDisplay(dpy);
GetEmptyReq (ListExtensions, req);
@@ -55,15 +55,15 @@ char **XListExtensions(
if (rep.nExtensions) {
list = Xmalloc (rep.nExtensions * sizeof (char *));
- if (rep.length < (LONG_MAX >> 2)) {
+ if (rep.length > 0 && rep.length < (INT_MAX >> 2)) {
rlen = rep.length << 2;
ch = Xmalloc (rlen + 1);
/* +1 to leave room for last null-terminator */
}
if ((!list) || (!ch)) {
- if (list) Xfree((char *) list);
- if (ch) Xfree((char *) ch);
+ Xfree(list);
+ Xfree(ch);
_XEatDataWords(dpy, rep.length);
UnlockDisplay(dpy);
SyncHandle();
@@ -80,9 +80,13 @@ char **XListExtensions(
if (ch + length < chend) {
list[i] = ch+1; /* skip over length */
ch += length + 1; /* find next length ... */
- length = *ch;
- *ch = '\0'; /* and replace with null-termination */
- count++;
+ if (ch <= chend) {
+ length = *ch;
+ *ch = '\0'; /* and replace with null-termination */
+ count++;
+ } else {
+ list[i] = NULL;
+ }
} else
list[i] = NULL;
}
@@ -99,7 +103,7 @@ XFreeExtensionList (char **list)
{
if (list != NULL) {
Xfree (list[0]-1);
- Xfree ((char *)list);
+ Xfree (list);
}
return 1;
}
diff --git a/nx-X11/lib/X11/LoadFont.c b/nx-X11/lib/X11/LoadFont.c
index 88171a633..f547976ba 100644
--- a/nx-X11/lib/X11/LoadFont.c
+++ b/nx-X11/lib/X11/LoadFont.c
@@ -49,7 +49,7 @@ XLoadFont (
Data (dpy, name, nbytes);
UnlockDisplay(dpy);
SyncHandle();
- return (fid);
+ return (fid);
/* can't return (req->fid) since request may have already been sent */
}
diff --git a/nx-X11/lib/X11/Luv.c b/nx-X11/lib/X11/Luv.c
index 8af5ee98b..2bce977ea 100644
--- a/nx-X11/lib/X11/Luv.c
+++ b/nx-X11/lib/X11/Luv.c
@@ -251,7 +251,7 @@ XcmsCIELuvToCIEuvY(
XcmsColor whitePt;
XcmsCIEuvY uvY_return;
XcmsFloat tmpVal;
- register int i;
+ unsigned int i;
/*
* Check arguments
@@ -343,7 +343,7 @@ XcmsCIEuvYToCIELuv(
XcmsColor whitePt;
XcmsCIELuv Luv_return;
XcmsFloat tmpVal;
- register int i;
+ unsigned int i;
/*
* Check arguments
diff --git a/nx-X11/lib/X11/Macros.c b/nx-X11/lib/X11/Macros.c
index cfc083a01..d5a3a0485 100644
--- a/nx-X11/lib/X11/Macros.c
+++ b/nx-X11/lib/X11/Macros.c
@@ -30,6 +30,9 @@ in this Software without prior written authorization from The Open Group.
#include "Xlibint.h"
#define XUTIL_DEFINE_FUNCTIONS
#include "Xutil.h"
+#if USE_XCB
+#include "Xxcbint.h"
+#endif
/*
* This file makes full definitions of routines for each macro.
@@ -135,10 +138,28 @@ int XBitmapPad(Display *dpy) { return (BitmapPad(dpy)); }
int XImageByteOrder(Display *dpy) { return (ImageByteOrder(dpy)); }
+#if !USE_XCB
unsigned long XNextRequest(Display *dpy)
{
return (NextRequest(dpy));
}
+#else
+/* XNextRequest() differs from the rest of the functions here because it is
+ * no longer a macro wrapper - when libX11 is being used mixed together
+ * with direct use of xcb, the next request field of the Display structure will
+ * not be updated. We can't fix the NextRequest() macro in any easy way,
+ * but we can at least make XNextRequest() do the right thing.
+ */
+unsigned long XNextRequest(Display *dpy)
+{
+ unsigned long next_request;
+ LockDisplay(dpy);
+ next_request = _XNextRequest(dpy);
+ UnlockDisplay(dpy);
+
+ return next_request;
+}
+#endif
unsigned long XLastKnownRequestProcessed(Display *dpy)
{
diff --git a/nx-X11/lib/X11/ModMap.c b/nx-X11/lib/X11/ModMap.c
index 122ca80db..49a5d08e8 100644
--- a/nx-X11/lib/X11/ModMap.c
+++ b/nx-X11/lib/X11/ModMap.c
@@ -42,7 +42,8 @@ XGetModifierMapping(register Display *dpy)
GetEmptyReq(GetModifierMapping, req);
(void) _XReply (dpy, (xReply *)&rep, 0, xFalse);
- if (rep.length < (LONG_MAX >> 2)) {
+ if (rep.length < (INT_MAX >> 2) &&
+ (rep.length >> 1) == rep.numKeyPerModifier) {
nbytes = (unsigned long)rep.length << 2;
res = Xmalloc(sizeof (XModifierKeymap));
if (res)
@@ -50,7 +51,7 @@ XGetModifierMapping(register Display *dpy)
} else
res = NULL;
if ((! res) || (! res->modifiermap)) {
- if (res) Xfree((char *) res);
+ Xfree(res);
res = (XModifierKeymap *) NULL;
_XEatDataWords(dpy, rep.length);
} else {
@@ -65,9 +66,9 @@ XGetModifierMapping(register Display *dpy)
/*
* Returns:
- * 0 Success
- * 1 Busy - one or more old or new modifiers are down
- * 2 Failed - one or more new modifiers unacceptable
+ * MappingSuccess (0) Success
+ * MappingBusy (1) Busy - one or more old or new modifiers are down
+ * MappingFailed (2) Failed - one or more new modifiers unacceptable
*/
int
XSetModifierMapping(
@@ -79,13 +80,11 @@ XSetModifierMapping(
int mapSize = modifier_map->max_keypermod << 3; /* 8 modifiers */
LockDisplay(dpy);
- GetReqExtra(SetModifierMapping, mapSize, req);
-
+ GetReq(SetModifierMapping, req);
+ req->length += mapSize >> 2;
req->numKeyPerModifier = modifier_map->max_keypermod;
- memcpy((char *) NEXTPTR(req,xSetModifierMappingReq),
- (char *) modifier_map->modifiermap,
- mapSize);
+ Data(dpy, modifier_map->modifiermap, mapSize);
(void) _XReply(dpy, (xReply *) & rep,
(SIZEOF(xSetModifierMappingReply) - SIZEOF(xReply)) >> 2, xTrue);
@@ -97,14 +96,14 @@ XSetModifierMapping(
XModifierKeymap *
XNewModifiermap(int keyspermodifier)
{
- XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap)));
+ XModifierKeymap *res = Xmalloc((sizeof (XModifierKeymap)));
if (res) {
res->max_keypermod = keyspermodifier;
res->modifiermap = (keyspermodifier > 0 ?
- (KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier))
+ Xmalloc(8 * keyspermodifier)
: (KeyCode *) NULL);
if (keyspermodifier && (res->modifiermap == NULL)) {
- Xfree((char *) res);
+ Xfree(res);
return (XModifierKeymap *) NULL;
}
}
@@ -116,9 +115,8 @@ int
XFreeModifiermap(XModifierKeymap *map)
{
if (map) {
- if (map->modifiermap)
- Xfree((char *) map->modifiermap);
- Xfree((char *) map);
+ Xfree(map->modifiermap);
+ Xfree(map);
}
return 1;
}
diff --git a/nx-X11/lib/X11/OpenDis.c b/nx-X11/lib/X11/OpenDis.c
index 4036572a8..965924650 100644
--- a/nx-X11/lib/X11/OpenDis.c
+++ b/nx-X11/lib/X11/OpenDis.c
@@ -73,12 +73,6 @@ extern void *_X11TransSocketProxyConnInfo(XtransConnInfo);
#endif
#if !USE_XCB
-#ifdef X_NOT_POSIX
-#define Size_t unsigned int
-#else
-#define Size_t size_t
-#endif
-
#define bignamelen (sizeof(XBigReqExtensionName) - 1)
typedef struct {
@@ -182,7 +176,7 @@ XOpenDisplay (
/*
* Attempt to allocate a display structure. Return NULL if allocation fails.
*/
- if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ if ((dpy = Xcalloc(1, sizeof(Display))) == NULL) {
return(NULL);
}
@@ -356,9 +350,7 @@ fallback_success:
dpy->qlen = 0;
/* Set up free-function record */
- if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
- sizeof(_XFreeFuncRec)))
- == NULL) {
+ if ((dpy->free_funcs = Xcalloc(1, sizeof(_XFreeFuncRec))) == NULL) {
OutOfMemory (dpy, setup);
return(NULL);
}
@@ -459,8 +451,8 @@ fallback_success:
if (prefix.lengthReason > setuplength) {
fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
}else{
- (void) fwrite (u.failure, (Size_t)sizeof(char),
- (Size_t)prefix.lengthReason, stderr);
+ (void) fwrite (u.failure, (size_t)sizeof(char),
+ (size_t)prefix.lengthReason, stderr);
(void) fwrite ("\r\n", sizeof(char), 2, stderr);
}
@@ -523,7 +515,7 @@ fallback_success:
return (NULL);
}
- dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ dpy->vendor = Xmalloc(u.setup->nbytesVendor + 1);
if (dpy->vendor == NULL) {
OutOfMemory(dpy, setup);
return (NULL);
@@ -713,6 +705,9 @@ fallback_success:
#endif /* !USE_XCB */
#if USE_XCB
+/*
+ * get availability of large requests
+ */
dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcb->connection);
if(dpy->bigreq_size <= dpy->max_request_size)
dpy->bigreq_size = 0;
@@ -740,7 +735,6 @@ fallback_success:
(void) XSynchronize(dpy, _Xdebug);
/*
- * get availability of large requests, and
* get the resource manager database off the root window.
*/
LockDisplay(dpy);
@@ -870,9 +864,8 @@ void _XFreeDisplayStructure(Display *dpy)
while (dpy->ext_procs) {
_XExtension *ext = dpy->ext_procs;
dpy->ext_procs = ext->next;
- if (ext->name)
- Xfree (ext->name);
- Xfree ((char *)ext);
+ Xfree (ext->name);
+ Xfree (ext);
}
if (dpy->im_filters)
(*dpy->free_funcs->im_filters)(dpy);
@@ -914,17 +907,17 @@ void _XFreeDisplayStructure(Display *dpy)
for (k = 0; k < dp->nvisuals; k++)
_XFreeExtData (dp->visuals[k].ext_data);
- Xfree ((char *) dp->visuals);
+ Xfree (dp->visuals);
}
}
- Xfree ((char *) sp->depths);
+ Xfree (sp->depths);
}
_XFreeExtData (sp->ext_data);
}
- Xfree ((char *)dpy->screens);
+ Xfree (dpy->screens);
}
if (dpy->pixmap_format) {
@@ -932,28 +925,21 @@ void _XFreeDisplayStructure(Display *dpy)
for (i = 0; i < dpy->nformats; i++)
_XFreeExtData (dpy->pixmap_format[i].ext_data);
- Xfree ((char *)dpy->pixmap_format);
+ Xfree (dpy->pixmap_format);
}
- if (dpy->display_name)
- Xfree (dpy->display_name);
- if (dpy->vendor)
- Xfree (dpy->vendor);
+ free(dpy->display_name);
- if (dpy->buffer)
- Xfree (dpy->buffer);
- if (dpy->keysyms)
- Xfree ((char *) dpy->keysyms);
- if (dpy->xdefaults)
- Xfree (dpy->xdefaults);
- if (dpy->error_vec)
- Xfree ((char *)dpy->error_vec);
+ Xfree (dpy->vendor);
+ Xfree (dpy->buffer);
+ Xfree (dpy->keysyms);
+ Xfree (dpy->xdefaults);
+ Xfree (dpy->error_vec);
_XFreeExtData (dpy->ext_data);
- if (dpy->free_funcs)
- Xfree ((char *)dpy->free_funcs);
- if (dpy->scratch_buffer)
- Xfree (dpy->scratch_buffer);
+
+ Xfree (dpy->free_funcs);
+ Xfree (dpy->scratch_buffer);
FreeDisplayLock(dpy);
if (dpy->qfree) {
@@ -961,15 +947,14 @@ void _XFreeDisplayStructure(Display *dpy)
while (qelt) {
register _XQEvent *qnxt = qelt->next;
- Xfree ((char *) qelt);
+ Xfree (qelt);
qelt = qnxt;
}
}
while (dpy->im_fd_info) {
struct _XConnectionInfo *conni = dpy->im_fd_info;
dpy->im_fd_info = conni->next;
- if (conni->watch_data)
- Xfree (conni->watch_data);
+ Xfree (conni->watch_data);
Xfree (conni);
}
if (dpy->conn_watchers) {
@@ -977,14 +962,14 @@ void _XFreeDisplayStructure(Display *dpy)
dpy->conn_watchers = watcher->next;
Xfree (watcher);
}
- if (dpy->filedes)
- Xfree (dpy->filedes);
+
+ Xfree (dpy->filedes);
#if USE_XCB
_XFreeX11XCBStructure(dpy);
#endif /* USE_XCB */
- Xfree ((char *)dpy);
+ Xfree (dpy);
}
/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
diff --git a/nx-X11/lib/X11/PixFormats.c b/nx-X11/lib/X11/PixFormats.c
index 8e4a10027..6d9f64d2c 100644
--- a/nx-X11/lib/X11/PixFormats.c
+++ b/nx-X11/lib/X11/PixFormats.c
@@ -38,8 +38,8 @@ XPixmapFormatValues *XListPixmapFormats (
Display *dpy,
int *count) /* RETURN */
{
- XPixmapFormatValues *formats = (XPixmapFormatValues *)
- Xmalloc((unsigned) (dpy->nformats * sizeof (XPixmapFormatValues)));
+ XPixmapFormatValues *formats =
+ Xmalloc(dpy->nformats * sizeof (XPixmapFormatValues));
if (formats) {
register int i;
diff --git a/nx-X11/lib/X11/PolyReg.c b/nx-X11/lib/X11/PolyReg.c
index 6ac2e2897..cb30f8422 100644
--- a/nx-X11/lib/X11/PolyReg.c
+++ b/nx-X11/lib/X11/PolyReg.c
@@ -95,8 +95,7 @@ InsertEdgeInET(
{
if (*iSLLBlock > SLLSPERBLOCK-1)
{
- tmpSLLBlock =
- (ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock));
+ tmpSLLBlock = Xmalloc(sizeof(ScanLineListBlock));
(*SLLBlock)->next = tmpSLLBlock;
tmpSLLBlock->next = (ScanLineListBlock *)NULL;
*SLLBlock = tmpSLLBlock;
@@ -379,7 +378,7 @@ FreeStorage(
while (pSLLBlock)
{
tmpSLLBlock = pSLLBlock->next;
- Xfree((char *)pSLLBlock);
+ Xfree(pSLLBlock);
pSLLBlock = tmpSLLBlock;
}
}
@@ -410,8 +409,7 @@ static int PtsToRegion(
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
- if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects,
- (unsigned) (sizeof(BOX) * numRects)))) {
+ if (!(reg->rects = Xrealloc(reg->rects, sizeof(BOX) * numRects))) {
Xfree(prevRects);
return(0);
}
@@ -521,8 +519,7 @@ XPolygonRegion(
if (Count < 2) return region;
- if (! (pETEs = (EdgeTableEntry *)
- Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count)))) {
+ if (! (pETEs = Xmalloc(sizeof(EdgeTableEntry) * Count))) {
XDestroyRegion(region);
return (Region) NULL;
}
@@ -559,7 +556,7 @@ XPolygonRegion(
* send out the buffer
*/
if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
pts = curPtBlock->pts;
@@ -605,7 +602,7 @@ XPolygonRegion(
* send out the buffer
*/
if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ tmpPtBlock = Xmalloc(sizeof(POINTBLOCK));
curPtBlock->next = tmpPtBlock;
curPtBlock = tmpPtBlock;
pts = curPtBlock->pts;
@@ -630,9 +627,9 @@ XPolygonRegion(
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
tmpPtBlock = curPtBlock->next;
- Xfree((char *)curPtBlock);
+ Xfree(curPtBlock);
curPtBlock = tmpPtBlock;
}
- Xfree((char *)pETEs);
+ Xfree(pETEs);
return(region);
}
diff --git a/nx-X11/lib/X11/PolyTxt.c b/nx-X11/lib/X11/PolyTxt.c
index 2f43c43d3..471383b57 100644
--- a/nx-X11/lib/X11/PolyTxt.c
+++ b/nx-X11/lib/X11/PolyTxt.c
@@ -121,9 +121,9 @@ XDrawText(
{
int nb = SIZEOF(xTextElt);
- BufAlloc (char *, tbuf, nb);
+ BufAlloc (char *, tbuf, nb);
*tbuf = 0; /* elt->len */
- if (PartialDelta > 0 )
+ if (PartialDelta > 0 )
{
*(tbuf+1) = 127; /* elt->delta */
PartialDelta = PartialDelta - 127;
@@ -148,9 +148,9 @@ XDrawText(
{
FirstTimeThrough = False;
if (!item->delta)
- {
+ {
nbytes += SIZEOF(xTextElt);
- BufAlloc (char *, tbuf, nbytes);
+ BufAlloc (char *, tbuf, nbytes);
*(tbuf+1) = 0; /* elt->delta */
}
else
@@ -179,9 +179,9 @@ XDrawText(
{
FirstTimeThrough = False;
if (!item->delta)
- {
+ {
nbytes += SIZEOF(xTextElt);
- BufAlloc (char *, tbuf, nbytes);
+ BufAlloc (char *, tbuf, nbytes);
*(tbuf+1) = 0; /* elt->delta */
}
else
@@ -193,7 +193,7 @@ XDrawText(
else
{
nbytes += SIZEOF(xTextElt);
- BufAlloc (char *, tbuf, nbytes);
+ BufAlloc (char *, tbuf, nbytes);
*(tbuf+1) = 0; /* elt->delta */
}
*tbuf = PartialNChars; /* elt->len */
diff --git a/nx-X11/lib/X11/PolyTxt16.c b/nx-X11/lib/X11/PolyTxt16.c
index 6c7cc49ec..2e4be1673 100644
--- a/nx-X11/lib/X11/PolyTxt16.c
+++ b/nx-X11/lib/X11/PolyTxt16.c
@@ -120,9 +120,9 @@ XDrawText16(
{
int nb = SIZEOF(xTextElt);
- BufAlloc (xTextElt *, elt, nb);
+ BufAlloc (xTextElt *, elt, nb);
elt->len = 0;
- if (PartialDelta > 0 )
+ if (PartialDelta > 0 )
{
elt->delta = 127;
PartialDelta = PartialDelta - 127;
@@ -146,9 +146,9 @@ XDrawText16(
{
FirstTimeThrough = False;
if (!item->delta)
- {
+ {
nbytes += SIZEOF(xTextElt);
- BufAlloc (xTextElt *, elt, nbytes);
+ BufAlloc (xTextElt *, elt, nbytes);
elt->delta = 0;
}
else
@@ -180,9 +180,9 @@ XDrawText16(
{
FirstTimeThrough = False;
if (!item->delta)
- {
+ {
nbytes += SIZEOF(xTextElt);
- BufAlloc (xTextElt *, elt, nbytes);
+ BufAlloc (xTextElt *, elt, nbytes);
elt->delta = 0;
}
else
@@ -197,13 +197,14 @@ XDrawText16(
else
{
nbytes += SIZEOF(xTextElt);
- BufAlloc (xTextElt *, elt, nbytes);
+ BufAlloc (xTextElt *, elt, nbytes);
elt->delta = 0;
}
elt->len = PartialNChars;
memcpy ((char *) (elt + 1), (char *)CharacterOffset,
- PartialNChars * 2);
+ PartialNChars *
+2);
}
}
item++;
diff --git a/nx-X11/lib/X11/PrOfId.c b/nx-X11/lib/X11/PrOfId.c
index 831f17ab9..a96d28cec 100644
--- a/nx-X11/lib/X11/PrOfId.c
+++ b/nx-X11/lib/X11/PrOfId.c
@@ -66,7 +66,6 @@ XcmsPrefixOfFormat(
*/
{
XcmsColorSpace **papColorSpaces;
- char *prefix;
/*
* First try Device-Independent color spaces
@@ -75,10 +74,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) {
- prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
- 1) * sizeof(char));
- strcpy(prefix, (*papColorSpaces)->prefix);
- return(prefix);
+ return strdup((*papColorSpaces)->prefix);
}
papColorSpaces++;
}
@@ -91,10 +87,7 @@ XcmsPrefixOfFormat(
if (papColorSpaces != NULL) {
while (*papColorSpaces != NULL) {
if ((*papColorSpaces)->id == id) {
- prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
- 1) * sizeof(char));
- strcpy(prefix, (*papColorSpaces)->prefix);
- return(prefix);
+ return strdup((*papColorSpaces)->prefix);
}
papColorSpaces++;
}
diff --git a/nx-X11/lib/X11/PropAlloc.c b/nx-X11/lib/X11/PropAlloc.c
index bad768153..87817d88a 100644
--- a/nx-X11/lib/X11/PropAlloc.c
+++ b/nx-X11/lib/X11/PropAlloc.c
@@ -39,37 +39,31 @@ in this Software without prior written authorization from The Open Group.
XSizeHints *XAllocSizeHints (void)
{
- return ((XSizeHints *) Xcalloc (1, (unsigned) sizeof (XSizeHints)));
+ return Xcalloc (1, sizeof (XSizeHints));
}
XStandardColormap *XAllocStandardColormap (void)
{
- return ((XStandardColormap *)
- Xcalloc (1, (unsigned) sizeof (XStandardColormap)));
+ return Xcalloc (1, sizeof (XStandardColormap));
}
XWMHints *XAllocWMHints (void)
{
- return ((XWMHints *) Xcalloc (1, (unsigned) sizeof (XWMHints)));
+ return Xcalloc (1, sizeof (XWMHints));
}
XClassHint *XAllocClassHint (void)
{
- register XClassHint *h;
-
- if ((h = (XClassHint *) Xcalloc (1, (unsigned) sizeof (XClassHint))))
- h->res_name = h->res_class = NULL;
-
- return h;
+ return Xcalloc (1, sizeof (XClassHint));
}
XIconSize *XAllocIconSize (void)
{
- return ((XIconSize *) Xcalloc (1, (unsigned) sizeof (XIconSize)));
+ return Xcalloc (1, sizeof (XIconSize));
}
diff --git a/nx-X11/lib/X11/PutBEvent.c b/nx-X11/lib/X11/PutBEvent.c
index f9d4c29bd..1768e032c 100644
--- a/nx-X11/lib/X11/PutBEvent.c
+++ b/nx-X11/lib/X11/PutBEvent.c
@@ -41,7 +41,7 @@ _XPutBackEvent (
XEvent store = *event;
if (!dpy->qfree) {
- if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
+ if ((dpy->qfree = Xmalloc (sizeof (_XQEvent))) == NULL) {
return 0;
}
dpy->qfree->next = NULL;
diff --git a/nx-X11/lib/X11/PutImage.c b/nx-X11/lib/X11/PutImage.c
index 6dad4f13a..de085bcde 100644
--- a/nx-X11/lib/X11/PutImage.c
+++ b/nx-X11/lib/X11/PutImage.c
@@ -600,15 +600,9 @@ static int const HalfOrderWord[12] = {
/* Cancel a GetReq operation, before doing _XSend or Data */
-#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
#define UnGetReq(name)\
dpy->bufptr -= SIZEOF(x##name##Req);\
dpy->request--
-#else
-#define UnGetReq(name)\
- dpy->bufptr -= SIZEOF(x/**/name/**/Req);\
- dpy->request--
-#endif
static void
SendXYImage(
@@ -680,7 +674,7 @@ SendXYImage(
length = ROUNDUP(length, 4);
if ((dpy->bufptr + length) > dpy->bufmax) {
- if ((buf = _XAllocScratch(dpy, (unsigned long) (length))) == NULL) {
+ if ((buf = _XAllocScratch(dpy, length)) == NULL) {
UnGetReq(PutImage);
return;
}
@@ -703,13 +697,13 @@ SendXYImage(
bytes_per_temp_plane = bytes_per_line * req->height;
temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4);
if (buf == dpy->bufptr) {
- if (! (temp = _XAllocScratch(dpy, (unsigned long) temp_length))) {
+ if (! (temp = _XAllocScratch(dpy, temp_length))) {
UnGetReq(PutImage);
return;
}
}
else
- if ((extra = temp = Xmalloc((unsigned) temp_length)) == NULL) {
+ if ((extra = temp = Xmalloc(temp_length)) == NULL) {
UnGetReq(PutImage);
return;
}
@@ -746,8 +740,7 @@ SendXYImage(
bytes_per_src, bytes_per_line,
bytes_per_dest, req->height, half_order);
- if (extra)
- Xfree(extra);
+ Xfree(extra);
if (buf == dpy->bufptr)
dpy->bufptr += length;
@@ -778,8 +771,7 @@ SendZImage(
(req_yoffset * image->bytes_per_line) +
((req_xoffset * image->bits_per_pixel) >> 3);
if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) {
- if (! (shifted_src = (unsigned char *)
- Xmalloc((unsigned) (req->height * image->bytes_per_line)))) {
+ if (! (shifted_src = Xmalloc(req->height * image->bytes_per_line))) {
UnGetReq(PutImage);
return;
}
@@ -800,8 +792,7 @@ SendZImage(
((req_xoffset == 0) ||
((req_yoffset + req->height) < (unsigned)image->height))) {
Data(dpy, (char *)src, length);
- if (shifted_src)
- Xfree((char *)shifted_src);
+ Xfree(shifted_src);
return;
}
@@ -810,8 +801,8 @@ SendZImage(
dest = (unsigned char *)dpy->bufptr;
else
if ((dest = (unsigned char *)
- _XAllocScratch(dpy, (unsigned long)(length))) == NULL) {
- if (shifted_src) Xfree((char *) shifted_src);
+ _XAllocScratch(dpy, length)) == NULL) {
+ Xfree(shifted_src);
UnGetReq(PutImage);
return;
}
@@ -838,8 +829,7 @@ SendZImage(
else
_XSend(dpy, (char *)dest, length);
- if (shifted_src)
- Xfree((char *)shifted_src);
+ Xfree(shifted_src);
}
static void
@@ -1001,7 +991,7 @@ XPutImage (
img.bits_per_pixel = dest_bits_per_pixel;
img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width),
dest_scanline_pad) >> 3;
- img.data = Xmalloc((unsigned) (img.bytes_per_line * height));
+ img.data = Xmalloc(img.bytes_per_line * height);
if (img.data == NULL)
return 0;
_XInitImageFuncPtrs(&img);
diff --git a/nx-X11/lib/X11/QuColors.c b/nx-X11/lib/X11/QuColors.c
index a8bc8837b..0b9bc508f 100644
--- a/nx-X11/lib/X11/QuColors.c
+++ b/nx-X11/lib/X11/QuColors.c
@@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group.
#endif
#include "Xlibint.h"
-int
-XQueryColors(
+static void
+_XQueryColors(
register Display *dpy,
Colormap cmap,
XColor *defs, /* RETURN */
@@ -40,11 +40,10 @@ XQueryColors(
xQueryColorsReply rep;
register xQueryColorsReq *req;
- LockDisplay(dpy);
GetReq(QueryColors, req);
req->cmap = cmap;
- req->length += ncolors; /* each pixel is a CARD32 */
+ SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */
for (i = 0; i < ncolors; i++)
Data32 (dpy, (long *)&defs[i].pixel, 4L);
@@ -65,13 +64,36 @@ XQueryColors(
def->blue = rgb->blue;
def->flags = DoRed | DoGreen | DoBlue;
}
- Xfree((char *)color);
+ Xfree(color);
}
else
_XEatDataWords(dpy, rep.length);
}
+}
+
+int
+XQueryColors(
+ register Display * const dpy,
+ const Colormap cmap,
+ XColor *defs, /* RETURN */
+ int ncolors)
+{
+ int n;
+
+ if (dpy->bigreq_size > 0)
+ n = dpy->bigreq_size - (sizeof (xQueryColorsReq) >> 2) - 1;
+ else
+ n = dpy->max_request_size - (sizeof (xQueryColorsReq) >> 2);
+
+ LockDisplay(dpy);
+ while (ncolors >= n) {
+ _XQueryColors(dpy, cmap, defs, n);
+ defs += n;
+ ncolors -= n;
+ }
+ if (ncolors > 0)
+ _XQueryColors(dpy, cmap, defs, ncolors);
UnlockDisplay(dpy);
SyncHandle();
return 1;
}
-
diff --git a/nx-X11/lib/X11/Quarks.c b/nx-X11/lib/X11/Quarks.c
index 9a7cb04d5..132ec6f67 100644
--- a/nx-X11/lib/X11/Quarks.c
+++ b/nx-X11/lib/X11/Quarks.c
@@ -186,15 +186,14 @@ ExpandQuarkTable(void)
newmask = (oldmask << 1) + 1;
else {
if (!stringTable) {
- stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) *
- CHUNKPER);
+ stringTable = Xmalloc(sizeof(XrmString *) * CHUNKPER);
if (!stringTable)
return False;
stringTable[0] = (XrmString *)NULL;
}
#ifdef PERMQ
if (!permTable)
- permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER);
+ permTable = Xmalloc(sizeof(Bits *) * CHUNKPER);
if (!permTable)
return False;
#endif
@@ -206,10 +205,9 @@ ExpandQuarkTable(void)
#endif
newmask = 0x1ff;
}
- entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1));
+ entries = Xcalloc(newmask + 1, sizeof(Entry));
if (!entries)
return False;
- bzero((char *)entries, sizeof(Entry) * (newmask + 1));
quarkTable = entries;
quarkMask = newmask;
quarkRehash = quarkMask - 2;
@@ -232,7 +230,7 @@ ExpandQuarkTable(void)
}
}
if (oldmask)
- Xfree((char *)oldentries);
+ Xfree(oldentries);
return True;
}
@@ -290,13 +288,13 @@ nomatch: if (!rehash)
q = nextQuark;
if (!(q & QUANTUMMASK)) {
if (!(q & CHUNKMASK)) {
- if (!(new = Xrealloc((char *)stringTable,
+ if (!(new = Xrealloc(stringTable,
sizeof(XrmString *) *
((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail;
stringTable = (XrmString **)new;
#ifdef PERMQ
- if (!(new = Xrealloc((char *)permTable,
+ if (!(new = Xrealloc(permTable,
sizeof(Bits *) *
((q >> QUANTUMSHIFT) + CHUNKPER))))
goto fail;
diff --git a/nx-X11/lib/X11/RdBitF.c b/nx-X11/lib/X11/RdBitF.c
index b3c21bc53..c2316ae0c 100644
--- a/nx-X11/lib/X11/RdBitF.c
+++ b/nx-X11/lib/X11/RdBitF.c
@@ -137,7 +137,7 @@ XReadBitmapFileData (
/* error cleanup and return macro */
#define RETURN(code) \
-{ if (bits) Xfree ((char *)bits); fclose (fstream); return code; }
+{ Xfree (bits); fclose (fstream); return code; }
while (fgets(line, MAX_SIZE, fstream)) {
if (strlen(line) == MAX_SIZE-1)
@@ -191,7 +191,7 @@ XReadBitmapFileData (
bytes_per_line = (ww+7)/8 + padding;
size = bytes_per_line * hh;
- bits = (unsigned char *) Xmalloc ((unsigned int) size);
+ bits = Xmalloc (size);
if (!bits)
RETURN (BitmapNoMemory);
@@ -216,6 +216,11 @@ XReadBitmapFileData (
*ptr=value;
}
}
+
+ /* If we got to this point, we read a full bitmap file. Break so we don't
+ * start reading another one from the same file and leak the memory
+ * allocated for the previous one. */
+ break;
} /* end while */
fclose(fstream);
@@ -249,7 +254,7 @@ XReadBitmapFile (
if (res != BitmapSuccess)
return res;
*pixmap = XCreateBitmapFromData(display, d, (char *)data, *width, *height);
- Xfree((char *)data);
+ Xfree(data);
if (*pixmap == None)
return (BitmapNoMemory);
return (BitmapSuccess);
diff --git a/nx-X11/lib/X11/ReconfWM.c b/nx-X11/lib/X11/ReconfWM.c
index 1776f2e15..8dc3534e0 100644
--- a/nx-X11/lib/X11/ReconfWM.c
+++ b/nx-X11/lib/X11/ReconfWM.c
@@ -41,7 +41,6 @@ Status XReconfigureWMWindow (
unsigned int mask,
XWindowChanges *changes)
{
- XConfigureRequestEvent ev;
Window root = RootWindow (dpy, screen);
_XAsyncHandler async;
_XAsyncErrorState async_state;
@@ -120,20 +119,24 @@ Status XReconfigureWMWindow (
/*
* If the request succeeded, then everything is okay; otherwise, send event
*/
- if (!async_state.error_count) return True;
-
- ev.type = ConfigureRequest;
- ev.window = w;
- ev.parent = root;
- ev.value_mask = (mask & AllMaskBits);
- ev.x = changes->x;
- ev.y = changes->y;
- ev.width = changes->width;
- ev.height = changes->height;
- ev.border_width = changes->border_width;
- ev.above = changes->sibling;
- ev.detail = changes->stack_mode;
- return (XSendEvent (dpy, root, False,
- SubstructureRedirectMask|SubstructureNotifyMask,
- (XEvent *)&ev));
+ if (!async_state.error_count)
+ return True;
+ else {
+ XConfigureRequestEvent ev = {
+ .type = ConfigureRequest,
+ .window = w,
+ .parent = root,
+ .value_mask = (mask & AllMaskBits),
+ .x = changes->x,
+ .y = changes->y,
+ .width = changes->width,
+ .height = changes->height,
+ .border_width = changes->border_width,
+ .above = changes->sibling,
+ .detail = changes->stack_mode,
+ };
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+ }
}
diff --git a/nx-X11/lib/X11/Region.c b/nx-X11/lib/X11/Region.c
index 5ce276279..28fa3e416 100644
--- a/nx-X11/lib/X11/Region.c
+++ b/nx-X11/lib/X11/Region.c
@@ -139,10 +139,10 @@ XCreateRegion(void)
{
Region temp;
- if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION ))))
+ if (! (temp = Xmalloc(sizeof( REGION ))))
return (Region) NULL;
- if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) {
- Xfree((char *) temp);
+ if (! (temp->rects = Xmalloc(sizeof( BOX )))) {
+ Xfree(temp);
return (Region) NULL;
}
temp->numRects = 0;
@@ -384,7 +384,12 @@ XShrinkRegion(
int grow;
if (!dx && !dy) return 0;
- if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0;
+ if (! (s = XCreateRegion()) )
+ return 0;
+ if (! (t = XCreateRegion()) ) {
+ XDestroyRegion(s);
+ return 0;
+ }
if ((grow = (dx < 0))) dx = -dx;
if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow);
if ((grow = (dy < 0))) dy = -dy;
@@ -502,7 +507,7 @@ XIntersectRegion(
return 1;
}
-static void
+static int
miRegionCopy(
register Region dstrgn,
register Region rgn)
@@ -516,11 +521,12 @@ miRegionCopy(
{
BOX *prevRects = dstrgn->rects;
- if (! (dstrgn->rects = (BOX *)
- Xrealloc((char *) dstrgn->rects,
- (unsigned) rgn->numRects * (sizeof(BOX))))) {
+ dstrgn->rects = Xrealloc(dstrgn->rects,
+ rgn->numRects * (sizeof(BOX)));
+ if (! dstrgn->rects) {
Xfree(prevRects);
- return;
+ dstrgn->size = 0;
+ return 0;
}
}
dstrgn->size = rgn->numRects;
@@ -534,6 +540,7 @@ miRegionCopy(
memcpy((char *) dstrgn->rects, (char *) rgn->rects,
(int) (rgn->numRects * sizeof(BOX)));
}
+ return 1;
}
/*======================================================================
@@ -783,8 +790,7 @@ miRegionOp(
*/
newReg->size = max(reg1->numRects,reg2->numRects) * 2;
- if (! (newReg->rects = (BoxPtr)
- Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) {
+ if (! (newReg->rects = Xmalloc (sizeof(BoxRec) * newReg->size))) {
newReg->size = 0;
return;
}
@@ -974,11 +980,12 @@ miRegionOp(
if (REGION_NOT_EMPTY(newReg))
{
BoxPtr prev_rects = newReg->rects;
- newReg->size = newReg->numRects;
- newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects,
- (unsigned) (sizeof(BoxRec) * newReg->size));
+ newReg->rects = Xrealloc (newReg->rects,
+ sizeof(BoxRec) * newReg->numRects);
if (! newReg->rects)
newReg->rects = prev_rects;
+ else
+ newReg->size = newReg->numRects;
}
else
{
@@ -987,11 +994,11 @@ miRegionOp(
* the region is empty
*/
newReg->size = 1;
- Xfree((char *) newReg->rects);
- newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec));
+ Xfree(newReg->rects);
+ newReg->rects = Xmalloc(sizeof(BoxRec));
}
}
- Xfree ((char *) oldRects);
+ Xfree (oldRects);
return;
}
@@ -1146,7 +1153,7 @@ XUnionRegion(
if ( (reg1 == reg2) || (!(reg1->numRects)) )
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
@@ -1156,7 +1163,7 @@ XUnionRegion(
if (!(reg2->numRects))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
@@ -1170,7 +1177,7 @@ XUnionRegion(
(reg1->extents.y2 >= reg2->extents.y2))
{
if (newReg != reg1)
- miRegionCopy(newReg, reg1);
+ return miRegionCopy(newReg, reg1);
return 1;
}
@@ -1184,7 +1191,7 @@ XUnionRegion(
(reg2->extents.y2 >= reg1->extents.y2))
{
if (newReg != reg2)
- miRegionCopy(newReg, reg2);
+ return miRegionCopy(newReg, reg2);
return 1;
}
@@ -1425,8 +1432,7 @@ XSubtractRegion(
if ( (!(regM->numRects)) || (!(regS->numRects)) ||
(!EXTENTCHECK(&regM->extents, &regS->extents)) )
{
- miRegionCopy(regD, regM);
- return 1;
+ return miRegionCopy(regD, regM);
}
miRegionOp (regD, regM, regS, miSubtractO,
@@ -1448,8 +1454,12 @@ XXorRegion(Region sra, Region srb, Region dr)
{
Region tra, trb;
- if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion())))
+ if (! (tra = XCreateRegion()) )
return 0;
+ if (! (trb = XCreateRegion()) ) {
+ XDestroyRegion(tra);
+ return 0;
+ }
(void) XSubtractRegion(sra,srb,tra);
(void) XSubtractRegion(srb,sra,trb);
(void) XUnionRegion(tra,trb,dr);
diff --git a/nx-X11/lib/X11/RegstFlt.c b/nx-X11/lib/X11/RegstFlt.c
index 1dba7e4a0..077ea424c 100644
--- a/nx-X11/lib/X11/RegstFlt.c
+++ b/nx-X11/lib/X11/RegstFlt.c
@@ -18,12 +18,12 @@
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * PERFORMANCE OF THIS SOFTWARE.
*
* Author: Seiji Kuwari OMRON Corporation
* kuwa@omron.co.jp
* kuwa%omron.co.jp@uunet.uu.net
- */
+ */
/*
Copyright 1990, 1991, 1998 The Open Group
@@ -66,7 +66,7 @@ _XFreeIMFilters(
while ((fl = display->im_filters)) {
display->im_filters = fl->next;
- Xfree((char *)fl);
+ Xfree(fl);
}
}
@@ -85,7 +85,7 @@ _XRegisterFilterByMask(
{
XFilterEventRec *rec;
- rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ rec = Xmalloc(sizeof(XFilterEventRec));
if (!rec)
return;
rec->window = window;
@@ -117,7 +117,7 @@ _XRegisterFilterByType(
{
XFilterEventRec *rec;
- rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ rec = Xmalloc(sizeof(XFilterEventRec));
if (!rec)
return;
rec->window = window;
@@ -148,7 +148,7 @@ _XUnregisterFilter(
if (fl->window == window &&
fl->filter == filter && fl->client_data == client_data) {
*prev = fl->next;
- Xfree((char *)fl);
+ Xfree(fl);
} else
prev = &fl->next;
}
diff --git a/nx-X11/lib/X11/RestackWs.c b/nx-X11/lib/X11/RestackWs.c
index b2a77fcdf..52391ecd2 100644
--- a/nx-X11/lib/X11/RestackWs.c
+++ b/nx-X11/lib/X11/RestackWs.c
@@ -57,3 +57,5 @@ XRestackWindows (
}
+
+
diff --git a/nx-X11/lib/X11/ScrResStr.c b/nx-X11/lib/X11/ScrResStr.c
index 3e8d39071..1dd04a383 100644
--- a/nx-X11/lib/X11/ScrResStr.c
+++ b/nx-X11/lib/X11/ScrResStr.c
@@ -48,8 +48,7 @@ char *XScreenResourceString(Screen *screen)
(unsigned char **) &val) == Success) {
if ((actual_type == XA_STRING) && (actual_format == 8))
return val;
- if (val)
- Xfree(val);
+ Xfree(val);
}
return (char *)NULL;
}
diff --git a/nx-X11/lib/X11/SetCRects.c b/nx-X11/lib/X11/SetCRects.c
index 21b68f8a2..c7ad3fcf2 100644
--- a/nx-X11/lib/X11/SetCRects.c
+++ b/nx-X11/lib/X11/SetCRects.c
@@ -78,3 +78,4 @@ XSetClipRectangles (
SyncHandle();
return 1;
}
+
diff --git a/nx-X11/lib/X11/SetDashes.c b/nx-X11/lib/X11/SetDashes.c
index a2d537bc5..ffe4a95ff 100644
--- a/nx-X11/lib/X11/SetDashes.c
+++ b/nx-X11/lib/X11/SetDashes.c
@@ -52,4 +52,4 @@ XSetDashes (
SyncHandle();
return 1;
}
-
+
diff --git a/nx-X11/lib/X11/SetFPath.c b/nx-X11/lib/X11/SetFPath.c
index 89955c23e..60aaef01e 100644
--- a/nx-X11/lib/X11/SetFPath.c
+++ b/nx-X11/lib/X11/SetFPath.c
@@ -52,7 +52,7 @@ XSetFontPath (
}
nbytes = (n + 3) & ~3;
req->length += nbytes >> 2;
- if ((p = (char *) Xmalloc ((unsigned) nbytes))) {
+ if ((p = Xmalloc (nbytes))) {
/*
* pack into counted strings.
*/
@@ -65,7 +65,7 @@ XSetFontPath (
p += length + 1;
}
Data (dpy, tmp, nbytes);
- Xfree ((char *) tmp);
+ Xfree (tmp);
retCode = 1;
}
else
diff --git a/nx-X11/lib/X11/SetGetCols.c b/nx-X11/lib/X11/SetGetCols.c
index 9b548dbb2..83fa4c200 100644
--- a/nx-X11/lib/X11/SetGetCols.c
+++ b/nx-X11/lib/X11/SetGetCols.c
@@ -237,7 +237,7 @@ _XcmsSetGetColors(
/*
* Allocate space for XColors
*/
- if ((pXColors_in_out = (XColor *)Xcalloc(nColors, sizeof(XColor))) ==
+ if ((pXColors_in_out = Xcalloc(nColors, sizeof(XColor))) ==
NULL) {
return(XcmsFailure);
}
@@ -251,7 +251,7 @@ _XcmsSetGetColors(
*/
if ((retval = XcmsConvertColors(ccc, pColors_in_out, nColors, XcmsRGBFormat,
pCompressed)) == XcmsFailure) {
- Xfree((char *)pXColors_in_out);
+ Xfree(pXColors_in_out);
return(XcmsFailure);
}
@@ -268,12 +268,12 @@ Query:
/* Note: XQueryColors and XStoreColors do not return any Status */
(*xColorProc)(ccc->dpy, cmap, pXColors_in_out, nColors);
} else {
- Xfree((char *)pXColors_in_out);
+ Xfree(pXColors_in_out);
return(XcmsFailure);
}
if (*xColorProc == XStoreColors) {
- Xfree((char *)pXColors_in_out);
+ Xfree(pXColors_in_out);
return(retval);
}
@@ -281,7 +281,7 @@ Query:
* Now, convert the returned XColor (i.e., rgb) to XcmsColor structures
*/
_XColor_to_XcmsRGB(ccc, pXColors_in_out, pColors_in_out, nColors);
- Xfree((char *)pXColors_in_out);
+ Xfree(pXColors_in_out);
/*
* Then, convert XcmsColor structures to the original specification
diff --git a/nx-X11/lib/X11/SetHints.c b/nx-X11/lib/X11/SetHints.c
index 7301ce42a..eed360f46 100644
--- a/nx-X11/lib/X11/SetHints.c
+++ b/nx-X11/lib/X11/SetHints.c
@@ -184,7 +184,7 @@ XSetIconSizes (
#define size_of_the_real_thing sizeof /* avoid grepping screwups */
unsigned nbytes = count * size_of_the_real_thing(xPropIconSize);
#undef size_of_the_real_thing
- if ((prop = pp = (xPropIconSize *) Xmalloc (nbytes))) {
+ if ((prop = pp = Xmalloc (nbytes))) {
for (i = 0; i < count; i++) {
pp->minWidth = list->min_width;
pp->minHeight = list->min_height;
@@ -198,7 +198,7 @@ XSetIconSizes (
XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32,
PropModeReplace, (unsigned char *) prop,
count * NumPropIconSizeElements);
- Xfree ((char *)prop);
+ Xfree (prop);
}
return 1;
}
@@ -216,7 +216,7 @@ XSetCommand (
for (i = 0, nbytes = 0; i < argc; i++) {
nbytes += safestrlen(argv[i]) + 1;
}
- if ((bp = buf = Xmalloc((unsigned) nbytes))) {
+ if ((bp = buf = Xmalloc(nbytes))) {
/* copy arguments into single buffer */
for (i = 0; i < argc; i++) {
if (argv[i]) {
@@ -259,7 +259,9 @@ XSetStandardProperties (
if (icon_string != NULL) {
XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
- PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string));
+ PropModeReplace,
+ (_Xconst unsigned char *)icon_string,
+ safestrlen(icon_string));
}
if (icon_pixmap != None) {
@@ -297,7 +299,7 @@ XSetClassHint(
len_nm = safestrlen(classhint->res_name);
len_cl = safestrlen(classhint->res_class);
- if ((class_string = s = Xmalloc((unsigned) (len_nm + len_cl + 2)))) {
+ if ((class_string = s = Xmalloc(len_nm + len_cl + 2))) {
if (len_nm) {
strcpy(s, classhint->res_name);
s += len_nm + 1;
diff --git a/nx-X11/lib/X11/SetLocale.c b/nx-X11/lib/X11/SetLocale.c
index cf068403b..f4d2aca21 100644
--- a/nx-X11/lib/X11/SetLocale.c
+++ b/nx-X11/lib/X11/SetLocale.c
@@ -66,57 +66,6 @@ from The Open Group.
#define MAXLOCALE 64 /* buffer size of locale name */
-#ifdef X_LOCALE
-
-/* alternative setlocale() for when the OS does not provide one */
-
-char *
-_Xsetlocale(
- int category,
- _Xconst char *name
-)
-{
- static char *xsl_name;
- char *old_name;
- XrmMethods methods;
- XPointer state;
-
- if (category != LC_CTYPE && category != LC_ALL)
- return NULL;
- if (!name) {
- if (xsl_name)
- return xsl_name;
- return "C";
- }
- if (!*name)
- name = getenv("LC_CTYPE");
- if (!name || !*name)
- name = getenv("LANG");
- if (name && strlen(name) >= MAXLOCALE)
- name = NULL;
- if (!name || !*name || !_XOpenLC((char *) name))
- name = "C";
- old_name = xsl_name;
- xsl_name = (char *)name;
- methods = _XrmInitParseInfo(&state);
- xsl_name = old_name;
- if (!methods)
- return NULL;
- name = (*methods->lcname)(state);
- xsl_name = Xmalloc(strlen(name) + 1);
- if (!xsl_name) {
- xsl_name = old_name;
- (*methods->destroy)(state);
- return NULL;
- }
- strcpy(xsl_name, name);
- if (old_name)
- Xfree(old_name);
- (*methods->destroy)(state);
- return xsl_name;
-}
-
-#else /* X_LOCALE */
#if defined(__DARWIN__) || defined(__APPLE__) || defined(__CYGWIN__)
char *
@@ -251,4 +200,3 @@ _XlcMapOSLocaleName(
return osname;
}
-#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/SetPntMap.c b/nx-X11/lib/X11/SetPntMap.c
index 45571ada0..14e104d6d 100644
--- a/nx-X11/lib/X11/SetPntMap.c
+++ b/nx-X11/lib/X11/SetPntMap.c
@@ -43,7 +43,7 @@ XSetPointerMapping (
GetReq (SetPointerMapping, req);
req->nElts = nmaps;
req->length += (nmaps + 3)>>2;
- Data (dpy, (char *)map, (long) nmaps);
+ Data (dpy, (_Xconst char *)map, (long) nmaps);
if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
rep.success = MappingSuccess;
UnlockDisplay(dpy);
@@ -74,3 +74,4 @@ XChangeKeyboardMapping (
SyncHandle();
return 0;
}
+
diff --git a/nx-X11/lib/X11/SetRGBCMap.c b/nx-X11/lib/X11/SetRGBCMap.c
index def7a22ca..f413c0d69 100644
--- a/nx-X11/lib/X11/SetRGBCMap.c
+++ b/nx-X11/lib/X11/SetRGBCMap.c
@@ -95,6 +95,6 @@ void XSetRGBColormaps (
XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32,
PropModeReplace, (unsigned char *) data,
(int) (count * NumPropStandardColormapElements));
- Xfree ((char *) data);
+ Xfree (data);
}
}
diff --git a/nx-X11/lib/X11/StBytes.c b/nx-X11/lib/X11/StBytes.c
index 0cbbb25f6..f058d354b 100644
--- a/nx-X11/lib/X11/StBytes.c
+++ b/nx-X11/lib/X11/StBytes.c
@@ -74,7 +74,7 @@ char *XFetchBuffer (
*nbytes = nitems;
return((char *)data);
}
- if ((char *) data != NULL) Xfree ((char *)data);
+ Xfree (data);
return(NULL);
}
@@ -94,7 +94,7 @@ XStoreBuffer (
{
if ((buffer < 0) || (buffer > 7)) return 0;
return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
- XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes);
+ XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *) bytes, nbytes);
}
int
diff --git a/nx-X11/lib/X11/StColor.c b/nx-X11/lib/X11/StColor.c
index b19f0a5dc..d5a217fb0 100644
--- a/nx-X11/lib/X11/StColor.c
+++ b/nx-X11/lib/X11/StColor.c
@@ -51,6 +51,7 @@ XStoreColor(
citem->blue = def->blue;
citem->flags = def->flags; /* do_red, do_green, do_blue */
+
UnlockDisplay(dpy);
SyncHandle();
return 1;
diff --git a/nx-X11/lib/X11/StCols.c b/nx-X11/lib/X11/StCols.c
index 24ccd386f..42a29cd7f 100644
--- a/nx-X11/lib/X11/StCols.c
+++ b/nx-X11/lib/X11/StCols.c
@@ -85,7 +85,7 @@ XcmsStoreColors(
* overwrite the contents.
*/
if (nColors > 1) {
- pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ pColors_tmp = Xmalloc(nColors * sizeof(XcmsColor));
} else {
pColors_tmp = &Color1;
}
@@ -102,7 +102,7 @@ XcmsStoreColors(
* Free copies as needed.
*/
if (nColors > 1) {
- Xfree((char *)pColors_tmp);
+ Xfree(pColors_tmp);
}
/*
diff --git a/nx-X11/lib/X11/StName.c b/nx-X11/lib/X11/StName.c
index 3f33472d3..a003a109e 100644
--- a/nx-X11/lib/X11/StName.c
+++ b/nx-X11/lib/X11/StName.c
@@ -37,7 +37,7 @@ XStoreName (
_Xconst char *name)
{
return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)name,
+ 8, PropModeReplace, (_Xconst unsigned char *)name,
name ? strlen(name) : 0);
}
@@ -47,7 +47,7 @@ XSetIconName (
Window w,
_Xconst char *icon_name)
{
- return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)icon_name,
+ return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
+ PropModeReplace, (_Xconst unsigned char *)icon_name,
icon_name ? strlen(icon_name) : 0);
}
diff --git a/nx-X11/lib/X11/StrKeysym.c b/nx-X11/lib/X11/StrKeysym.c
index 9bdc80d32..125aceca3 100644
--- a/nx-X11/lib/X11/StrKeysym.c
+++ b/nx-X11/lib/X11/StrKeysym.c
@@ -27,6 +27,7 @@ in this Software without prior written authorization from The Open Group.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <limits.h>
#include "Xlibint.h"
#include <nx-X11/Xresource.h>
#include <nx-X11/keysymdef.h>
@@ -93,7 +94,7 @@ XStringToKeysym(_Xconst char *s)
{
entry = &_XkeyTable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) &&
- !strcmp(s, (char *)entry + 6))
+ !strcmp(s, (const char *)entry + 6))
{
val = (entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | entry[5];
@@ -152,5 +153,29 @@ XStringToKeysym(_Xconst char *s)
return val;
return val | 0x01000000;
}
+
+ if (strlen(s) > 2 && s[0] == '0' && s[1] == 'x') {
+ char *tmp = NULL;
+ val = strtoul(s, &tmp, 16);
+ if (val == ULONG_MAX || (tmp && *tmp != '\0'))
+ return NoSymbol;
+ else
+ return val;
+ }
+
+ /* Stupid inconsistency between the headers and XKeysymDB: the former has
+ * no separating underscore, while some XF86* syms in the latter did.
+ * As a last ditch effort, try without. */
+ if (strncmp(s, "XF86_", 5) == 0) {
+ KeySym ret;
+ char *tmp = strdup(s);
+ if (!tmp)
+ return NoSymbol;
+ memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1);
+ ret = XStringToKeysym(tmp);
+ free(tmp);
+ return ret;
+ }
+
return NoSymbol;
}
diff --git a/nx-X11/lib/X11/StrToText.c b/nx-X11/lib/X11/StrToText.c
index 64ed5fd24..ff33492f2 100644
--- a/nx-X11/lib/X11/StrToText.c
+++ b/nx-X11/lib/X11/StrToText.c
@@ -78,7 +78,7 @@ Status XStringListToTextProperty (
}
}
} else {
- proto.value = (unsigned char *) Xmalloc (1); /* easier for client */
+ proto.value = Xmalloc (1); /* easier for client */
if (!proto.value) return False;
proto.value[0] = '\0';
diff --git a/nx-X11/lib/X11/Text.c b/nx-X11/lib/X11/Text.c
index 645aa283f..223b1cf8b 100644
--- a/nx-X11/lib/X11/Text.c
+++ b/nx-X11/lib/X11/Text.c
@@ -38,7 +38,7 @@ XDrawString(
int y,
_Xconst char *string,
int length)
-{
+{
int Datalength = 0;
register xPolyText8Req *req;
@@ -60,11 +60,11 @@ XDrawString(
req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
- /*
+ /*
* If the entire request does not fit into the remaining space in the
* buffer, flush the buffer first. If the request does fit into the
* empty buffer, then we won't have to flush it at the end to keep
- * the buffer 32-bit aligned.
+ * the buffer 32-bit aligned.
*/
if (dpy->bufptr + Datalength > dpy->bufmax)
@@ -92,11 +92,11 @@ XDrawString(
PartialNChars = PartialNChars - 254;
CharacterOffset += 254;
}
-
+
if (PartialNChars)
{
nbytes = PartialNChars + SIZEOF(xTextElt);
- BufAlloc (unsigned char *, tbuf, nbytes);
+ BufAlloc (unsigned char *, tbuf, nbytes);
/* elt->delta = 0;
* elt->len = PartialNChars;
*/
@@ -112,23 +112,23 @@ XDrawString(
if (Datalength &= 3) {
char *pad;
- /*
+ /*
* BufAlloc is a macro that uses its last argument more than
- * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
*/
length = 4 - Datalength;
BufAlloc (char *, pad, length);
- /*
+ /*
* if there are 3 bytes of padding, the first byte MUST be 0
- * so the pad bytes aren't mistaken for a final xTextElt
+ * so the pad bytes aren't mistaken for a final xTextElt
*/
*pad = 0;
}
- /*
+ /*
* If the buffer pointer is not now pointing to a 32-bit boundary,
* we must flush the buffer so that it does point to a 32-bit boundary
- * at the end of this routine.
+ * at the end of this routine.
*/
if ((dpy->bufptr - dpy->buffer) & 3)
diff --git a/nx-X11/lib/X11/TextExt.c b/nx-X11/lib/X11/TextExt.c
index 910bb3d7b..b883b01b4 100644
--- a/nx-X11/lib/X11/TextExt.c
+++ b/nx-X11/lib/X11/TextExt.c
@@ -41,7 +41,7 @@ from The Open Group.
#define max_byte2 max_char_or_byte2
-/*
+/*
* CI_GET_ROWZERO_CHAR_INFO_2D - do the same thing as CI_GET_CHAR_INFO_1D,
* except that the font has more than one row. This is special case of more
* general version used in XTextExt16.c since row == 0. This is used when
@@ -119,7 +119,7 @@ XTextExtents (
} else {
overall->ascent = max (overall->ascent, cs->ascent);
overall->descent = max (overall->descent, cs->descent);
- overall->lbearing = min (overall->lbearing,
+ overall->lbearing = min (overall->lbearing,
overall->width + cs->lbearing);
overall->rbearing = max (overall->rbearing,
overall->width + cs->rbearing);
@@ -132,7 +132,7 @@ XTextExtents (
* if there were no characters, then set everything to 0
*/
if (nfound == 0) {
- overall->width = overall->ascent = overall->descent =
+ overall->width = overall->ascent = overall->descent =
overall->lbearing = overall->rbearing = 0;
}
@@ -141,7 +141,7 @@ XTextExtents (
/*
- * XTextWidth - compute the width of a string of eightbit bytes. This is a
+ * XTextWidth - compute the width of a string of eightbit bytes. This is a
* subset of XTextExtents.
*/
int
diff --git a/nx-X11/lib/X11/TextExt16.c b/nx-X11/lib/X11/TextExt16.c
index 643aa5e30..01a0f32e4 100644
--- a/nx-X11/lib/X11/TextExt16.c
+++ b/nx-X11/lib/X11/TextExt16.c
@@ -41,7 +41,7 @@ from The Open Group.
#define max_byte2 max_char_or_byte2
/*
- * XTextExtents16 - compute the extents of string given as a sequence of
+ * XTextExtents16 - compute the extents of string given as a sequence of
* XChar2bs.
*/
int
@@ -94,7 +94,7 @@ XTextExtents16 (
} else {
overall->ascent = max (overall->ascent, cs->ascent);
overall->descent = max (overall->descent, cs->descent);
- overall->lbearing = min (overall->lbearing,
+ overall->lbearing = min (overall->lbearing,
overall->width + cs->lbearing);
overall->rbearing = max (overall->rbearing,
overall->width + cs->rbearing);
@@ -107,7 +107,7 @@ XTextExtents16 (
* if there were no characters, then set everything to 0
*/
if (nfound == 0) {
- overall->width = overall->ascent = overall->descent =
+ overall->width = overall->ascent = overall->descent =
overall->lbearing = overall->rbearing = 0;
}
@@ -116,7 +116,7 @@ XTextExtents16 (
/*
- * XTextWidth16 - compute the width of sequence of XChar2bs. This is a
+ * XTextWidth16 - compute the width of sequence of XChar2bs. This is a
* subset of XTextExtents16.
*/
int
diff --git a/nx-X11/lib/X11/TextToStr.c b/nx-X11/lib/X11/TextToStr.c
index e75b7fcea..03f71558b 100644
--- a/nx-X11/lib/X11/TextToStr.c
+++ b/nx-X11/lib/X11/TextToStr.c
@@ -72,12 +72,12 @@ Status XTextPropertyToStringList (
/*
* allocate list and duplicate
*/
- list = (char **) Xmalloc (nelements * sizeof (char *));
+ list = Xmalloc (nelements * sizeof (char *));
if (!list) return False;
- start = (char *) Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */
+ start = Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */
if (!start) {
- Xfree ((char *) list);
+ Xfree (list);
return False;
}
@@ -111,7 +111,7 @@ void XFreeStringList (char **list)
{
if (list) {
if (list[0]) Xfree (list[0]);
- Xfree ((char *) list);
+ Xfree (list);
list = NULL;
}
}
diff --git a/nx-X11/lib/X11/UIThrStubs.c b/nx-X11/lib/X11/UIThrStubs.c
index a3bcdfc41..8f4ea076b 100644
--- a/nx-X11/lib/X11/UIThrStubs.c
+++ b/nx-X11/lib/X11/UIThrStubs.c
@@ -81,9 +81,7 @@ typedef thread_t xthread_t;
#pragma weak cond_broadcast = _Xthr_zero_stub_
#else /* !SVR4 */
#ifdef WIN32
- /*
- * Don't know what to do here. Is there something do be done at all?
- */
+#include <nx-X11/Xthreads.h>
#else /* !WIN32 */
#ifdef USE_TIS_SUPPORT
#include <tis.h>
diff --git a/nx-X11/lib/X11/VisUtil.c b/nx-X11/lib/X11/VisUtil.c
index 3434c0161..17ca3631f 100644
--- a/nx-X11/lib/X11/VisUtil.c
+++ b/nx-X11/lib/X11/VisUtil.c
@@ -75,8 +75,7 @@ XVisualInfo *XGetVisualInfo(
count = 0;
total = 10;
- if (! (vip_base = vip = (XVisualInfo *)
- Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) {
+ if (! (vip_base = vip = Xmalloc(sizeof(XVisualInfo) * total))) {
UnlockDisplay(dpy);
return (XVisualInfo *) NULL;
}
@@ -132,10 +131,9 @@ XVisualInfo *XGetVisualInfo(
{
XVisualInfo *old_vip_base = vip_base;
total += 10;
- if (! (vip_base = (XVisualInfo *)
- Xrealloc((char *) vip_base,
- (unsigned) (sizeof(XVisualInfo) * total)))) {
- Xfree((char *) old_vip_base);
+ if (! (vip_base = Xrealloc(vip_base,
+ sizeof(XVisualInfo) * total))) {
+ Xfree(old_vip_base);
UnlockDisplay(dpy);
return (XVisualInfo *) NULL;
}
@@ -172,7 +170,7 @@ XVisualInfo *XGetVisualInfo(
return vip_base;
}
- Xfree((char *) vip_base);
+ Xfree(vip_base);
*nitems = 0;
return NULL;
}
diff --git a/nx-X11/lib/X11/WMGeom.c b/nx-X11/lib/X11/WMGeom.c
index 68187b583..7947536f5 100644
--- a/nx-X11/lib/X11/WMGeom.c
+++ b/nx-X11/lib/X11/WMGeom.c
@@ -72,13 +72,13 @@ XWMGeometry (
* Get the base sizes and increments. Section 4.1.2.3 of the ICCCM
* states that the base and minimum sizes are defaults for each other.
* If neither is given, then the base sizes should be 0. These parameters
- * control the sets of sizes that window managers should allow for the
+ * control the sets of sizes that window managers should allow for the
* window according to the following formulae:
*
* width = base_width + (i * width_inc)
* height = base_height + (j * height_inc)
*/
- base_width = ((hints->flags & PBaseSize) ? hints->base_width :
+ base_width = ((hints->flags & PBaseSize) ? hints->base_width :
((hints->flags & PMinSize) ? hints->min_width : 0));
base_height = ((hints->flags & PBaseSize) ? hints->base_height :
((hints->flags & PMinSize) ? hints->min_height : 0));
@@ -103,11 +103,11 @@ XWMGeometry (
* 4. multiply by the size increment
* 5. and add to the base size
*/
- rwidth = ((((umask & WidthValue) ? uwidth :
+ rwidth = ((((umask & WidthValue) ? uwidth :
((dmask & WidthValue) ? dwidth : 1)) * width_inc) +
base_width);
- rheight = ((((umask & HeightValue) ? uheight :
- ((dmask & HeightValue) ? dheight : 1)) * height_inc) +
+ rheight = ((((umask & HeightValue) ? uheight :
+ ((dmask & HeightValue) ? dheight : 1)) * height_inc) +
base_height);
/*
@@ -135,7 +135,7 @@ XWMGeometry (
if (dmask & XNegative) {
rx = (DisplayWidth (dpy, screen) + dx - rwidth - 2 * bwidth);
rmask |= XNegative;
- } else
+ } else
rx = dx;
} else {
rx = 0; /* gotta choose something... */
@@ -148,7 +148,7 @@ XWMGeometry (
if (dmask & YNegative) {
ry = (DisplayHeight(dpy, screen) + dy - rheight - 2 * bwidth);
rmask |= YNegative;
- } else
+ } else
ry = dy;
} else {
ry = 0; /* gotta choose something... */
diff --git a/nx-X11/lib/X11/Withdraw.c b/nx-X11/lib/X11/Withdraw.c
index bca1f8d9b..9c2280234 100644
--- a/nx-X11/lib/X11/Withdraw.c
+++ b/nx-X11/lib/X11/Withdraw.c
@@ -67,16 +67,18 @@ Status XWithdrawWindow (
Window w,
int screen)
{
- XUnmapEvent ev;
- Window root = RootWindow (dpy, screen);
-
XUnmapWindow (dpy, w);
- ev.type = UnmapNotify;
- ev.event = root;
- ev.window = w;
- ev.from_configure = False;
- return (XSendEvent (dpy, root, False,
- SubstructureRedirectMask|SubstructureNotifyMask,
- (XEvent *)&ev));
+ {
+ Window root = RootWindow (dpy, screen);
+ XUnmapEvent ev = {
+ .type = UnmapNotify,
+ .event = root,
+ .window = w,
+ .from_configure = False
+ };
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+ }
}
diff --git a/nx-X11/lib/X11/WrBitF.c b/nx-X11/lib/X11/WrBitF.c
index c9ed6b47e..0b27d5adf 100644
--- a/nx-X11/lib/X11/WrBitF.c
+++ b/nx-X11/lib/X11/WrBitF.c
@@ -53,7 +53,7 @@ static char *Format_Image(
bytes_per_line = (width+7)/8;
*resultsize = bytes_per_line * height; /* Calculate size of data */
- data = (char *) Xmalloc( *resultsize ); /* Get space for data */
+ data = Xmalloc( *resultsize ); /* Get space for data */
if (!data)
return(ERR_RETURN);
diff --git a/nx-X11/lib/X11/XDefaultIMIF.c b/nx-X11/lib/X11/XDefaultIMIF.c
index d36962f05..7c32ce296 100644
--- a/nx-X11/lib/X11/XDefaultIMIF.c
+++ b/nx-X11/lib/X11/XDefaultIMIF.c
@@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted.
*/
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2000 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"),
@@ -168,32 +168,25 @@ _XDefaultOpenIM(
char *res_class)
{
StaticXIM im;
- XIMStaticXIMRec *local_impart;
- XlcConv ctom_conv, ctow_conv;
int i;
char *mod;
char buf[BUFSIZ];
- if (!(ctom_conv = _XlcOpenConverter(lcd,
- XlcNCompoundText, lcd, XlcNMultiByte))) {
- return((XIM)NULL);
- }
+ if ((im = Xcalloc(1, sizeof(StaticXIMRec))) == NULL)
+ return NULL;
- if (!(ctow_conv = _XlcOpenConverter(lcd,
- XlcNCompoundText, lcd, XlcNWideChar))) {
- return((XIM)NULL);
- }
+ if ((im->private = Xcalloc(1, sizeof(XIMStaticXIMRec))) == NULL)
+ goto Error;
- if ((im = (StaticXIM)Xmalloc(sizeof(StaticXIMRec))) == (StaticXIM)NULL) {
- return((XIM)NULL);
- }
- if ((local_impart = (XIMStaticXIMRec*)Xmalloc(sizeof(XIMStaticXIMRec)))
- == (XIMStaticXIMRec *)NULL) {
- Xfree(im);
- return((XIM)NULL);
- }
- memset(im, 0, sizeof(StaticXIMRec));
- memset(local_impart, 0, sizeof(XIMStaticXIMRec));
+ if ((im->private->ctom_conv = _XlcOpenConverter(lcd, XlcNCompoundText,
+ lcd, XlcNMultiByte))
+ == NULL)
+ goto Error;
+
+ if ((im->private->ctow_conv = _XlcOpenConverter(lcd, XlcNCompoundText,
+ lcd, XlcNWideChar))
+ == NULL)
+ goto Error;
buf[0] = '\0';
i = 0;
@@ -209,11 +202,9 @@ _XDefaultOpenIM(
}
}
#undef MODIFIER
- if ((im->core.im_name = Xmalloc(i+1)) == NULL)
- goto Error2;
- strcpy(im->core.im_name, buf);
+ if ((im->core.im_name = strdup(buf)) == NULL)
+ goto Error;
- im->private = local_impart;
im->methods = (XIMMethods)&local_im_methods;
im->core.lcd = lcd;
im->core.ic_chain = (XIC)NULL;
@@ -222,25 +213,18 @@ _XDefaultOpenIM(
im->core.res_name = NULL;
im->core.res_class = NULL;
- local_impart->ctom_conv = ctom_conv;
- local_impart->ctow_conv = ctow_conv;
-
if ((res_name != NULL) && (*res_name != '\0')){
- im->core.res_name = (char *)Xmalloc(strlen(res_name)+1);
- strcpy(im->core.res_name,res_name);
+ im->core.res_name = strdup(res_name);
}
if ((res_class != NULL) && (*res_class != '\0')){
- im->core.res_class = (char *)Xmalloc(strlen(res_class)+1);
- strcpy(im->core.res_class,res_class);
+ im->core.res_class = strdup(res_class);
}
return (XIM)im;
-Error2 :
- Xfree(im->private);
- Xfree(im->core.im_name);
+
+ Error:
+ _CloseIM((XIM)im);
Xfree(im);
- _XlcCloseConverter(ctom_conv);
- _XlcCloseConverter(ctow_conv);
return(NULL);
}
@@ -248,13 +232,16 @@ static Status
_CloseIM(XIM xim)
{
StaticXIM im = (StaticXIM)xim;
- _XlcCloseConverter(im->private->ctom_conv);
- _XlcCloseConverter(im->private->ctow_conv);
+
+ if (im->private->ctom_conv != NULL)
+ _XlcCloseConverter(im->private->ctom_conv);
+ if (im->private->ctow_conv != NULL)
+ _XlcCloseConverter(im->private->ctow_conv);
XFree(im->private);
XFree(im->core.im_name);
- if (im->core.res_name) XFree(im->core.res_name);
- if (im->core.res_class) XFree(im->core.res_class);
- return 1; /*bugID 4163122*/
+ XFree(im->core.res_name);
+ XFree(im->core.res_class);
+ return 1;
}
static char *
@@ -275,11 +262,11 @@ _GetIMValues(
for (p = values; p->name != NULL; p++) {
if (strcmp(p->name, XNQueryInputStyle) == 0) {
- styles = (XIMStyles *)Xmalloc(sizeof(XIMStyles));
+ styles = Xmalloc(sizeof(XIMStyles));
*(XIMStyles **)p->value = styles;
styles->count_styles = 1;
styles->supported_styles =
- (XIMStyle*)Xmalloc(styles->count_styles * sizeof(XIMStyle));
+ Xmalloc(styles->count_styles * sizeof(XIMStyle));
styles->supported_styles[0] = (XIMPreeditNone | XIMStatusNone);
} else {
break;
@@ -346,10 +333,9 @@ _CreateIC(XIM im, XIMArg *arg)
{
XIC ic;
- if ((ic = (XIC)Xmalloc(sizeof(XICRec))) == (XIC)NULL) {
+ if ((ic = Xcalloc(1, sizeof(XICRec))) == (XIC)NULL) {
return ((XIC)NULL);
}
- memset(ic, 0, sizeof(XICRec));
ic->methods = (XICMethods)&local_ic_methods;
ic->core.im = im;
@@ -454,7 +440,7 @@ _WcLookupString(
XComposeStatus NotSupportedYet ;
int length;
/* In single-byte, mb_len = wc_len */
- char *mb_buf = (char *)Xmalloc(wlen);
+ char *mb_buf = Xmalloc(wlen);
length = XLookupString(ev, mb_buf, wlen, keysym, &NotSupportedYet);
diff --git a/nx-X11/lib/X11/XDefaultOMIF.c b/nx-X11/lib/X11/XDefaultOMIF.c
index dbadd90aa..e61344d31 100644
--- a/nx-X11/lib/X11/XDefaultOMIF.c
+++ b/nx-X11/lib/X11/XDefaultOMIF.c
@@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted.
*/
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2000 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"),
@@ -76,7 +76,7 @@ Sun Microsystems, Inc. or its licensors is granted.
#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
#define DefineLocalBuf char local_buf[BUFSIZ]
-#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define AllocLocalBuf(length) (length > BUFSIZ ? Xmalloc(length) : local_buf)
#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
typedef struct _FontDataRec {
@@ -128,10 +128,9 @@ init_fontset(
data = XOM_GENERIC(oc->core.om)->data;
- font_set = (FontSet) Xmalloc(sizeof(FontSetRec));
+ font_set = Xcalloc(1, sizeof(FontSetRec));
if (font_set == NULL)
return False;
- bzero((char *) font_set, sizeof(FontSetRec));
gen = XOC_GENERIC(oc);
gen->font_set = font_set;
@@ -183,62 +182,6 @@ check_charset(
return (FontData) NULL;
}
-#if 0 /* Unused */
-static int
-check_fontname(
- XOC oc,
- char *name)
-{
- Display *dpy = oc->core.om->core.display;
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontData data;
- FontSet font_set;
- XFontStruct *fs_list;
- char **fn_list, *fname, *prop_fname = NULL;
- int list_num, i;
- int list2_num;
- char **fn2_list = NULL;
- int found_num = 0;
-
- fn_list = XListFonts(dpy, name, MAXFONTS, &list_num);
- if (fn_list == NULL)
- return found_num;
-
- for (i = 0; i < list_num; i++) {
- fname = fn_list[i];
-
- font_set = gen->font_set;
-
- if ((data = check_charset(font_set, fname)) == NULL) {
- if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS,
- &list2_num, &fs_list))
- && (prop_fname = get_prop_name(dpy, fs_list))
- && (data = check_charset(font_set, prop_fname)))
- fname = prop_fname;
- }
- if (data) {
- font_set->font_name = (char *) Xmalloc(strlen(fname) + 1);
- if (font_set->font_name) {
- strcpy(font_set->font_name, fname);
- found_num++;
- }
- }
- if (fn2_list) {
- XFreeFontInfo(fn2_list, fs_list, list2_num);
- fn2_list = NULL;
- if (prop_fname) {
- Xfree(prop_fname);
- prop_fname = NULL;
- }
- }
- if (found_num == 1)
- break;
- }
- XFreeFontNames(fn_list);
- return found_num;
-}
-#endif
-
static Bool
load_font(
XOC oc)
@@ -258,34 +201,6 @@ load_font(
return True;
}
-#if 0
-static Bool
-load_font_info(
- XOC oc)
-{
- Display *dpy = oc->core.om->core.display;
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set = gen->font_set;
- char **fn_list;
- int fn_num;
-
- if (font_set->font_name == NULL)
- return False;
-
- if (font_set->info == NULL) {
- fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
- &font_set->info);
- if (font_set->info == NULL)
- return False;
- if (fn_num > 0)
- font_set->info->fid = XLoadFont(dpy, font_set->font_name);
-
- if (fn_list) XFreeFontNames(fn_list);
- }
- return True;
-}
-#endif
-
static void
set_fontset_extents(
XOC oc)
@@ -322,27 +237,21 @@ init_core_part(
FontSet font_set;
XFontStruct **font_struct_list;
char **font_name_list, *font_name_buf;
- int count, length;
font_set = gen->font_set;
- count = length = 0;
- if (font_set->font_name != NULL) {
- length += strlen(font_set->font_name) + 1;
- count++;
- }
- if (count == 0)
+ if (font_set->font_name == NULL)
return False;
- font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *));
+ font_struct_list = Xmalloc(sizeof(XFontStruct *));
if (font_struct_list == NULL)
return False;
- font_name_list = (char **) Xmalloc(sizeof(char *));
+ font_name_list = Xmalloc(sizeof(char *));
if (font_name_list == NULL)
goto err;
- font_name_buf = (char *) Xmalloc(length);
+ font_name_buf = strdup(font_set->font_name);
if (font_name_buf == NULL)
goto err;
@@ -350,27 +259,21 @@ init_core_part(
oc->core.font_info.font_name_list = font_name_list;
oc->core.font_info.font_struct_list = font_struct_list;
- font_set = gen->font_set;
-
- if (font_set->font_name != NULL) {
- font_set->id = 1;
- if (font_set->font)
- *font_struct_list++ = font_set->font;
- else
- *font_struct_list++ = font_set->info;
- strcpy(font_name_buf, font_set->font_name);
- Xfree(font_set->font_name);
- *font_name_list++ = font_set->font_name = font_name_buf;
- font_name_buf += strlen(font_name_buf) + 1;
- }
+ font_set->id = 1;
+ if (font_set->font)
+ *font_struct_list = font_set->font;
+ else
+ *font_struct_list = font_set->info;
+ Xfree(font_set->font_name);
+ *font_name_list = font_set->font_name = font_name_buf;
set_fontset_extents(oc);
return True;
err:
- if (font_name_list)
- Xfree(font_name_list);
+
+ Xfree(font_name_list);
Xfree(font_struct_list);
return False;
@@ -381,29 +284,21 @@ get_font_name(
XOC oc,
char *pattern)
{
- char **list, *name, *prop_name;
+ char **list, *name;
int count;
XFontStruct *fs;
Display *dpy = oc->core.om->core.display;
list = XListFonts(dpy, pattern, 1, &count);
if (list != NULL) {
- name = (char *) Xmalloc(strlen(*list) + 1);
- if (name)
- strcpy(name, *list);
+ name = strdup(*list);
XFreeFontNames(list);
} else {
fs = XLoadQueryFont(dpy, pattern);
if (fs == NULL) return NULL;
- prop_name = get_prop_name(dpy, fs);
- if (prop_name == NULL) return NULL;
-
- name = (char*) Xmalloc(strlen(prop_name) + 1);
- if (name)
- strcpy(name, prop_name);
-
+ name = get_prop_name(dpy, fs);
XFreeFont(dpy, fs);
}
return name;
@@ -466,21 +361,15 @@ parse_fontname(
if (font_data == NULL)
continue;
- font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1);
+ font_set->font_name = strdup(font_name);
+ Xfree(font_name);
if (font_set->font_name == NULL) {
- Xfree(font_name);
goto err;
}
- strcpy(font_set->font_name, font_name);
- Xfree(font_name);
found_num++;
goto found;
}
-/*
-1266793
-Limit the length of the string copy to prevent stack corruption.
- strcpy(buf, pattern);
-*/
+
strncpy(buf, pattern, BUFSIZ);
buf[BUFSIZ-1] = '\0';
length = strlen(buf);
@@ -532,11 +421,6 @@ Limit the length of the string copy to prevent stack corruption.
for ( ; font_data_count-- > 0; font_data++) {
if (append_charset)
{
-/*
-1266793
-Limit the length of the string copy to prevent stack corruption.
- strcpy(last, font_data->name);
-*/
strncpy(last, font_data->name, BUFSIZ - length);
buf[BUFSIZ-1] = '\0';
}
@@ -555,11 +439,10 @@ Limit the length of the string copy to prevent stack corruption.
}
}
found:
- base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ base_name = strdup(oc->core.base_name_list);
if (base_name == NULL)
goto err;
- strcpy(base_name, oc->core.base_name_list);
oc->core.base_name_list = base_name;
XFreeStringList(name_list);
@@ -578,24 +461,17 @@ set_missing_list(
XOCGenericPart *gen = XOC_GENERIC(oc);
FontSet font_set;
char **charset_list, *charset_buf;
- int count, length;
font_set = gen->font_set;
- count = length = 0;
-
- if (!font_set->info && !font_set->font) {
- length += strlen(font_set->font_data->name) + 1;
- count++;
- }
- if (count == 0)
+ if (font_set->info == NULL || font_set->font == NULL)
return True;
- charset_list = (char **) Xmalloc(sizeof(char *));
+ charset_list = Xmalloc(sizeof(char *));
if (charset_list == NULL)
return False;
- charset_buf = (char *) Xmalloc(length);
+ charset_buf = strdup(font_set->font_data->name);
if (charset_buf == NULL) {
Xfree(charset_list);
return False;
@@ -603,13 +479,8 @@ set_missing_list(
oc->core.missing_list.charset_list = charset_list;
- font_set = gen->font_set;
+ *charset_list = charset_buf;
- if (!font_set->info && !font_set->font) {
- strcpy(charset_buf, font_set->font_data->name);
- *charset_list++ = charset_buf;
- charset_buf += strlen(charset_buf) + 1;
- }
return True;
}
@@ -649,14 +520,10 @@ destroy_oc(
XOCGenericPart *gen = XOC_GENERIC(oc);
XFontStruct **font_list, *font;
- if (gen->font_set)
- Xfree(gen->font_set);
-
- if (oc->core.base_name_list)
- Xfree(oc->core.base_name_list);
- if (oc->core.font_info.font_name_list)
- XFreeStringList(oc->core.font_info.font_name_list);
+ Xfree(gen->font_set);
+ Xfree(oc->core.base_name_list);
+ XFreeStringList(oc->core.font_info.font_name_list);
if ((font_list = oc->core.font_info.font_struct_list)) {
if ((font = *font_list)) {
@@ -668,14 +535,12 @@ destroy_oc(
Xfree(oc->core.font_info.font_struct_list);
}
- if (oc->core.missing_list.charset_list)
- XFreeStringList(oc->core.missing_list.charset_list);
+
+ XFreeStringList(oc->core.missing_list.charset_list);
#ifdef notdef
- if (oc->core.res_name)
- Xfree(oc->core.res_name);
- if (oc->core.res_class)
- Xfree(oc->core.res_class);
+ Xfree(oc->core.res_name);
+ Xfree(oc->core.res_class);
#endif
Xfree(oc);
@@ -1011,10 +876,9 @@ create_oc(
{
XOC oc;
- oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ oc = Xcalloc(1, sizeof(XOCGenericRec));
if (oc == NULL)
return (XOC) NULL;
- bzero((char *) oc, sizeof(XOCGenericRec));
oc->core.om = om;
@@ -1057,7 +921,6 @@ close_om(
if (data->font_data) {
for (font_data = data->font_data, count = data->font_data_count;
count-- > 0 ; font_data++) {
- if (font_data->name)
Xfree(font_data->name);
}
Xfree(data->font_data);
@@ -1065,17 +928,16 @@ close_om(
Xfree(gen->data);
}
- if (om->core.res_name)
- Xfree(om->core.res_name);
- if (om->core.res_class)
- Xfree(om->core.res_class);
+
+ Xfree(om->core.res_name);
+ Xfree(om->core.res_class);
+
if (om->core.required_charset.charset_list)
XFreeStringList(om->core.required_charset.charset_list);
else
Xfree((char*)om->core.required_charset.charset_list);
- if (om->core.orientation_list.orientation)
- Xfree(om->core.orientation_list.orientation);
+ Xfree(om->core.orientation_list.orientation);
Xfree(om);
return 1;
@@ -1132,25 +994,19 @@ add_data(
XOMGenericPart *gen = XOM_GENERIC(om);
OMData new;
- new = (OMData) Xmalloc(sizeof(OMDataRec));
+ new = Xcalloc(1, sizeof(OMDataRec));
if (new == NULL)
return NULL;
gen->data = new;
- bzero((char *) new, sizeof(OMDataRec));
-
return new;
}
static _Xconst char *supported_charset_list[] = {
"ISO8859-1",
-/* fix for bug4332979 */
"adobe-fontspecific",
-/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from
- supported_charset_list because it is not a supported_charset for C locale
- "JISX0201.1976-0", */
"SUNOLCURSOR-1",
"SUNOLGLYPH-1"
};
@@ -1164,44 +1020,33 @@ init_om(
FontData font_data;
char **required_list;
XOrientation *orientation;
- char **value, buf[BUFSIZ], *bufptr;
- int count, length = 0;
+ char *bufptr;
+ int i, count;
- value = (char**)supported_charset_list;
count = XlcNumber(supported_charset_list);
data = add_data(om);
if (data == NULL)
return False;
- font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ font_data = Xcalloc(count, sizeof(FontDataRec));
if (font_data == NULL)
return False;
- bzero((char *) font_data, sizeof(FontDataRec) * count);
data->font_data = font_data;
data->font_data_count = count;
- for ( ; count-- > 0; font_data++) {
-/*
-1266793
-This one is fine. *value points to one of the local strings in
-supported_charset_list[].
-*/
- strcpy(buf, *value++);
- font_data->name = (char *) Xmalloc(strlen(buf) + 1);
+ for (i = 0; i < count; i++, font_data++) {
+ font_data->name = strdup(supported_charset_list[i]);
if (font_data->name == NULL)
return False;
- strcpy(font_data->name, buf);
}
- length += strlen(data->font_data->name) + 1;
-
/* required charset list */
- required_list = (char **) Xmalloc(sizeof(char *));
+ required_list = Xmalloc(sizeof(char *));
if (required_list == NULL)
return False;
- bufptr = (char *) Xmalloc(length);
+ bufptr = strdup(data->font_data->name);
if (bufptr == NULL) {
Xfree(required_list);
return False;
@@ -1212,12 +1057,10 @@ supported_charset_list[].
data = gen->data;
- strcpy(bufptr, data->font_data->name);
- *required_list++ = bufptr;
- bufptr += strlen(bufptr) + 1;
+ *required_list = bufptr;
/* orientation list */
- orientation = (XOrientation *) Xmalloc(sizeof(XOrientation));
+ orientation = Xmalloc(sizeof(XOrientation));
if (orientation == NULL)
return False;
@@ -1243,26 +1086,23 @@ _XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
{
XOM om;
- om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ om = Xcalloc(1, sizeof(XOMGenericRec));
if (om == NULL)
return (XOM) NULL;
- bzero((char *) om, sizeof(XOMGenericRec));
om->methods = (XOMMethods)&methods;
om->core.lcd = lcd;
om->core.display = dpy;
om->core.rdb = rdb;
if (res_name) {
- om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1);
+ om->core.res_name = strdup(res_name);
if (om->core.res_name == NULL)
goto err;
- strcpy(om->core.res_name, res_name);
}
if (res_class) {
- om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1);
+ om->core.res_class = strdup(res_class);
if (om->core.res_class == NULL)
goto err;
- strcpy(om->core.res_class, res_class);
}
if (om_resources[0].xrm_name == NULLQUARK)
diff --git a/nx-X11/lib/X11/XErrorDB b/nx-X11/lib/X11/XErrorDB
index c2efa1044..7b6d46513 100644
--- a/nx-X11/lib/X11/XErrorDB
+++ b/nx-X11/lib/X11/XErrorDB
@@ -1014,9 +1014,9 @@ XRequest.DRI2.3: DRI2CreateDrawable
XRequest.DRI2.4: DRI2DestroyDrawable
XRequest.DRI2.5: DRI2GetBuffers
XRequest.DRI2.6: DRI2CopyRegion
-XRequest.DRI2.7: DRI2GetBuffersWithFormat
-XRequest.DRI2.8: DRI2SwapBuffers
-XRequest.DRI2.9: DRI2GetMSC
-XRequest.DRI2.10: DRI2WaitMSC
-XRequest.DRI2.11: DRI2WaitSBC
-XRequest.DRI2.12: DRI2SwapInterval
+XRequest.DRI2.7: DRI2GetBuffersWithFormat
+XRequest.DRI2.8: DRI2SwapBuffers
+XRequest.DRI2.9: DRI2GetMSC
+XRequest.DRI2.10: DRI2WaitMSC
+XRequest.DRI2.11: DRI2WaitSBC
+XRequest.DRI2.12: DRI2SwapInterval
diff --git a/nx-X11/lib/X11/XKB.c b/nx-X11/lib/X11/XKB.c
index 008609608..7ecd39706 100644
--- a/nx-X11/lib/X11/XKB.c
+++ b/nx-X11/lib/X11/XKB.c
@@ -32,45 +32,47 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/extensions/XKBproto.h>
#include "XKBlibint.h"
-XkbInternAtomFunc _XkbInternAtomFunc= XInternAtom;
-XkbGetAtomNameFunc _XkbGetAtomNameFunc= XGetAtomName;
+XkbInternAtomFunc _XkbInternAtomFunc = XInternAtom;
+XkbGetAtomNameFunc _XkbGetAtomNameFunc = XGetAtomName;
Bool
-XkbQueryExtension( Display *dpy,
- int * opcodeReturn,
- int * eventBaseReturn,
- int * errorBaseReturn,
- int * majorReturn,
- int * minorReturn)
+XkbQueryExtension(Display *dpy,
+ int *opcodeReturn,
+ int *eventBaseReturn,
+ int *errorBaseReturn,
+ int *majorReturn,
+ int *minorReturn)
{
- if (!XkbUseExtension(dpy,majorReturn,minorReturn))
- return False;
+ if (!XkbUseExtension(dpy, majorReturn, minorReturn))
+ return False;
if (opcodeReturn)
- *opcodeReturn = dpy->xkb_info->codes->major_opcode;
+ *opcodeReturn = dpy->xkb_info->codes->major_opcode;
if (eventBaseReturn)
- *eventBaseReturn = dpy->xkb_info->codes->first_event;
+ *eventBaseReturn = dpy->xkb_info->codes->first_event;
if (errorBaseReturn)
- *errorBaseReturn = dpy->xkb_info->codes->first_error;
+ *errorBaseReturn = dpy->xkb_info->codes->first_error;
if (majorReturn)
- *majorReturn = dpy->xkb_info->srv_major;
+ *majorReturn = dpy->xkb_info->srv_major;
if (minorReturn)
- *minorReturn = dpy->xkb_info->srv_minor;
+ *minorReturn = dpy->xkb_info->srv_minor;
return True;
}
Bool
-XkbLibraryVersion(int *libMajorRtrn,int *libMinorRtrn)
+XkbLibraryVersion(int *libMajorRtrn, int *libMinorRtrn)
{
-int supported;
+ int supported;
if (*libMajorRtrn != XkbMajorVersion) {
- /* version 0.65 is (almost) compatible with 1.00 */
- if ((XkbMajorVersion==1)&&(((*libMajorRtrn)==0)&&((*libMinorRtrn)==65)))
- supported= True;
- else supported= False;
+ /* version 0.65 is (almost) compatible with 1.00 */
+ if ((XkbMajorVersion == 1) &&
+ (((*libMajorRtrn) == 0) && ((*libMinorRtrn) == 65)))
+ supported = True;
+ else
+ supported = False;
}
else {
- supported = True;
+ supported = True;
}
*libMajorRtrn = XkbMajorVersion;
@@ -79,49 +81,52 @@ int supported;
}
Bool
-XkbSelectEvents( Display * dpy,
- unsigned int deviceSpec,
- unsigned int affect,
- unsigned int selectAll)
+XkbSelectEvents(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int selectAll)
{
register xkbSelectEventsReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
- xkbi->selected_events&= ~affect;
- xkbi->selected_events|= (affect&selectAll);
+ xkbi->selected_events &= ~affect;
+ xkbi->selected_events |= (affect & selectAll);
GetReq(kbSelectEvents, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbSelectEvents;
req->deviceSpec = deviceSpec;
- req->affectWhich = (CARD16)affect;
- req->clear = affect&(~selectAll);
- req->selectAll = affect&selectAll;
- if (affect&XkbMapNotifyMask) {
- req->affectMap= XkbAllMapComponentsMask;
- /* the implicit support needs the client info */
- /* even if the client itself doesn't want it */
- if (selectAll&XkbMapNotifyMask)
- req->map= XkbAllMapEventsMask;
- else req->map= XkbAllClientInfoMask;
- if (selectAll&XkbMapNotifyMask)
- xkbi->selected_map_details= XkbAllMapEventsMask;
- else xkbi->selected_map_details= 0;
+ req->affectWhich = (CARD16) affect;
+ req->clear = affect & (~selectAll);
+ req->selectAll = affect & selectAll;
+ if (affect & XkbMapNotifyMask) {
+ req->affectMap = XkbAllMapComponentsMask;
+ /* the implicit support needs the client info */
+ /* even if the client itself doesn't want it */
+ if (selectAll & XkbMapNotifyMask)
+ req->map = XkbAllMapEventsMask;
+ else
+ req->map = XkbAllClientInfoMask;
+ if (selectAll & XkbMapNotifyMask)
+ xkbi->selected_map_details = XkbAllMapEventsMask;
+ else
+ xkbi->selected_map_details = 0;
}
- if (affect&XkbNewKeyboardNotifyMask) {
- if (selectAll&XkbNewKeyboardNotifyMask)
- xkbi->selected_nkn_details= XkbAllNewKeyboardEventsMask;
- else xkbi->selected_nkn_details= 0;
- if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
- /* we want it, even if the client doesn't. Don't mess */
- /* around with details -- ask for all of them and throw */
- /* away the ones we don't need */
- req->selectAll|= XkbNewKeyboardNotifyMask;
- }
+ if (affect & XkbNewKeyboardNotifyMask) {
+ if (selectAll & XkbNewKeyboardNotifyMask)
+ xkbi->selected_nkn_details = XkbAllNewKeyboardEventsMask;
+ else
+ xkbi->selected_nkn_details = 0;
+ if (!(xkbi->xlib_ctrls & XkbLC_IgnoreNewKeyboards)) {
+ /* we want it, even if the client doesn't. Don't mess */
+ /* around with details -- ask for all of them and throw */
+ /* away the ones we don't need */
+ req->selectAll |= XkbNewKeyboardNotifyMask;
+ }
}
UnlockDisplay(dpy);
SyncHandle();
@@ -129,91 +134,91 @@ XkbSelectEvents( Display * dpy,
}
Bool
-XkbSelectEventDetails( Display * dpy,
- unsigned deviceSpec,
- unsigned eventType,
- unsigned long int affect,
- unsigned long int details)
+XkbSelectEventDetails(Display *dpy,
+ unsigned deviceSpec,
+ unsigned eventType,
+ unsigned long int affect,
+ unsigned long int details)
{
register xkbSelectEventsReq *req;
- XkbInfoPtr xkbi;
- int size = 0;
- char *out;
+ XkbInfoPtr xkbi;
+ int size = 0;
+ char *out;
union {
- CARD8 *c8;
- CARD16 *c16;
- CARD32 *c32;
+ CARD8 *c8;
+ CARD16 *c16;
+ CARD32 *c32;
} u;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
- if (affect&details) xkbi->selected_events|= (1<<eventType);
- else xkbi->selected_events&= ~(1<<eventType);
+ if (affect & details)
+ xkbi->selected_events |= (1 << eventType);
+ else
+ xkbi->selected_events &= ~(1 << eventType);
GetReq(kbSelectEvents, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbSelectEvents;
req->deviceSpec = deviceSpec;
- req->clear= req->selectAll= 0;
- if (eventType==XkbMapNotify) {
- /* we need all of the client info, even if the application */
- /* doesn't. Make sure that we always request the stuff */
- /* that the implicit support needs, and just filter out anything */
- /* the client doesn't want later */
- req->affectWhich = 0;
- req->selectAll = 0;
- req->clear = 0;
- req->affectMap = (CARD16)affect;
- req->map = (CARD16)details|(XkbAllClientInfoMask&affect);
- req->affectWhich = XkbMapNotifyMask;
- xkbi->selected_map_details&= ~affect;
- xkbi->selected_map_details|= (details&affect);
+ req->clear = req->selectAll = 0;
+ if (eventType == XkbMapNotify) {
+ /* we need all of the client info, even if the application */
+ /* doesn't. Make sure that we always request the stuff */
+ /* that the implicit support needs, and just filter out anything */
+ /* the client doesn't want later */
+ req->affectMap = (CARD16) affect;
+ req->map = (CARD16) details | (XkbAllClientInfoMask & affect);
+ req->affectWhich = XkbMapNotifyMask;
+ xkbi->selected_map_details &= ~affect;
+ xkbi->selected_map_details |= (details & affect);
}
else {
- req->affectMap = req->map = 0;
- req->affectWhich= (1<<eventType);
- switch (eventType) {
- case XkbNewKeyboardNotify:
- xkbi->selected_nkn_details&= ~affect;
- xkbi->selected_nkn_details|= (details&affect);
- if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards))
- details= (affect&XkbAllNewKeyboardEventsMask);
- case XkbStateNotify:
- case XkbNamesNotify:
- case XkbAccessXNotify:
- case XkbExtensionDeviceNotify:
- size= 2;
- req->length+= 1;
- break;
- case XkbControlsNotify:
- case XkbIndicatorStateNotify:
- case XkbIndicatorMapNotify:
- size= 4;
- req->length+= 2;
- break;
- case XkbBellNotify:
- case XkbActionMessage:
- case XkbCompatMapNotify:
- size= 1;
- req->length+= 1;
- break;
- }
- BufAlloc(char *,out,(((size*2)+(unsigned)3)/4)*4);
- u.c8= (CARD8 *)out;
- if (size==2) {
- u.c16[0]= (CARD16)affect;
- u.c16[1]= (CARD16)details;
- }
- else if (size==4) {
- u.c32[0]= (CARD32)affect;
- u.c32[1]= (CARD32)details;
- }
- else {
- u.c8[0]= (CARD8)affect;
- u.c8[1]= (CARD8)details;
- }
+ req->affectMap = req->map = 0;
+ req->affectWhich = (1 << eventType);
+ switch (eventType) {
+ case XkbNewKeyboardNotify:
+ xkbi->selected_nkn_details &= ~affect;
+ xkbi->selected_nkn_details |= (details & affect);
+ if (!(xkbi->xlib_ctrls & XkbLC_IgnoreNewKeyboards))
+ details = (affect & XkbAllNewKeyboardEventsMask);
+ case XkbStateNotify:
+ case XkbNamesNotify:
+ case XkbAccessXNotify:
+ case XkbExtensionDeviceNotify:
+ size = 2;
+ req->length += 1;
+ break;
+ case XkbControlsNotify:
+ case XkbIndicatorStateNotify:
+ case XkbIndicatorMapNotify:
+ size = 4;
+ req->length += 2;
+ break;
+ case XkbBellNotify:
+ case XkbActionMessage:
+ case XkbCompatMapNotify:
+ size = 1;
+ req->length += 1;
+ break;
+ }
+ BufAlloc(char *, out, (((size * 2) + (unsigned) 3) / 4) * 4);
+
+ u.c8 = (CARD8 *) out;
+ if (size == 2) {
+ u.c16[0] = (CARD16) affect;
+ u.c16[1] = (CARD16) details;
+ }
+ else if (size == 4) {
+ u.c32[0] = (CARD32) affect;
+ u.c32[1] = (CARD32) details;
+ }
+ else {
+ u.c8[0] = (CARD8) affect;
+ u.c8[1] = (CARD8) details;
+ }
}
UnlockDisplay(dpy);
SyncHandle();
@@ -221,24 +226,24 @@ XkbSelectEventDetails( Display * dpy,
}
Bool
-XkbLockModifiers( Display * dpy,
- unsigned int deviceSpec,
- unsigned int affect,
- unsigned int values)
+XkbLockModifiers(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
{
register xkbLatchLockStateReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbLatchLockState, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbLatchLockState;
req->deviceSpec = deviceSpec;
- req->affectModLocks= affect;
+ req->affectModLocks = affect;
req->modLocks = values;
req->lockGroup = False;
req->groupLock = 0;
@@ -252,17 +257,17 @@ XkbLockModifiers( Display * dpy,
}
Bool
-XkbLatchModifiers( Display * dpy,
- unsigned int deviceSpec,
- unsigned int affect,
- unsigned int values)
+XkbLatchModifiers(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
{
register xkbLatchLockStateReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbLatchLockState, req);
@@ -270,7 +275,7 @@ XkbLatchModifiers( Display * dpy,
req->xkbReqType = X_kbLatchLockState;
req->deviceSpec = deviceSpec;
- req->affectModLatches= affect;
+ req->affectModLatches = affect;
req->modLatches = values;
req->latchGroup = False;
req->groupLatch = 0;
@@ -285,21 +290,21 @@ XkbLatchModifiers( Display * dpy,
}
Bool
-XkbLockGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+XkbLockGroup(Display *dpy, unsigned int deviceSpec, unsigned int group)
{
register xkbLatchLockStateReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbLatchLockState, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbLatchLockState;
req->deviceSpec = deviceSpec;
- req->affectModLocks= 0;
+ req->affectModLocks = 0;
req->modLocks = 0;
req->lockGroup = True;
req->groupLock = group;
@@ -313,14 +318,14 @@ XkbLockGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
}
Bool
-XkbLatchGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+XkbLatchGroup(Display *dpy, unsigned int deviceSpec, unsigned int group)
{
register xkbLatchLockStateReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbLatchLockState, req);
@@ -328,7 +333,7 @@ XkbLatchGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
req->xkbReqType = X_kbLatchLockState;
req->deviceSpec = deviceSpec;
- req->affectModLatches= 0;
+ req->affectModLatches = 0;
req->modLatches = 0;
req->latchGroup = True;
req->groupLatch = group;
@@ -343,15 +348,15 @@ XkbLatchGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
}
unsigned
-XkbSetXlibControls(Display *dpy,unsigned affect,unsigned values)
+XkbSetXlibControls(Display *dpy, unsigned affect, unsigned values)
{
if (!dpy->xkb_info)
- XkbUseExtension(dpy,NULL,NULL);
+ XkbUseExtension(dpy, NULL, NULL);
if (!dpy->xkb_info)
- return 0;
- affect&= XkbLC_AllControls;
- dpy->xkb_info->xlib_ctrls&= ~affect;
- dpy->xkb_info->xlib_ctrls|= (affect&values);
+ return 0;
+ affect &= XkbLC_AllControls;
+ dpy->xkb_info->xlib_ctrls &= ~affect;
+ dpy->xkb_info->xlib_ctrls |= (affect & values);
return dpy->xkb_info->xlib_ctrls;
}
@@ -359,9 +364,9 @@ unsigned
XkbGetXlibControls(Display *dpy)
{
if (!dpy->xkb_info)
- XkbUseExtension(dpy,NULL,NULL);
+ XkbUseExtension(dpy, NULL, NULL);
if (!dpy->xkb_info)
- return 0;
+ return 0;
return dpy->xkb_info->xlib_ctrls;
}
@@ -371,155 +376,157 @@ XkbXlibControlsImplemented(void)
#ifdef __sgi
return XkbLC_AllControls;
#else
- return XkbLC_AllControls&~XkbLC_AllComposeControls;
+ return XkbLC_AllControls & ~XkbLC_AllComposeControls;
#endif
}
Bool
-XkbSetDebuggingFlags( Display * dpy,
- unsigned int mask,
- unsigned int flags,
- char * msg,
- unsigned int ctrls_mask,
- unsigned int ctrls,
- unsigned int * rtrn_flags,
- unsigned int * rtrn_ctrls)
+XkbSetDebuggingFlags(Display *dpy,
+ unsigned int mask,
+ unsigned int flags,
+ char *msg,
+ unsigned int ctrls_mask,
+ unsigned int ctrls,
+ unsigned int *rtrn_flags,
+ unsigned int *rtrn_ctrls)
{
register xkbSetDebuggingFlagsReq *req;
xkbSetDebuggingFlagsReply rep;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetDebuggingFlags, req);
- req->reqType= xkbi->codes->major_opcode;
- req->xkbReqType= X_kbSetDebuggingFlags;
- req->affectFlags= mask;
- req->flags= flags;
- req->affectCtrls= ctrls_mask;
- req->ctrls= ctrls;
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetDebuggingFlags;
+ req->affectFlags = mask;
+ req->flags = flags;
+ req->affectCtrls = ctrls_mask;
+ req->ctrls = ctrls;
if (msg) {
- char *out;
- req->msgLength= (unsigned short)strlen(msg)+1;
- req->length+= (req->msgLength+(unsigned)3)>>2;
- BufAlloc(char *,out,((req->msgLength+(unsigned)3)/4)*4);
- memcpy(out,msg,req->msgLength);
+ char *out;
+
+ req->msgLength = (unsigned short) strlen(msg) + 1;
+ req->length += (req->msgLength + (unsigned) 3) >> 2;
+ BufAlloc(char *, out, ((req->msgLength + (unsigned) 3) / 4) * 4);
+ memcpy(out, msg, req->msgLength);
}
- else req->msgLength= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ else
+ req->msgLength = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
if (rtrn_flags)
- *rtrn_flags= rep.currentFlags;
+ *rtrn_flags = rep.currentFlags;
if (rtrn_ctrls)
- *rtrn_ctrls= rep.currentCtrls;
+ *rtrn_ctrls = rep.currentCtrls;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
-XkbComputeEffectiveMap( XkbDescPtr xkb,
- XkbKeyTypePtr type,
- unsigned char * map_rtrn)
+XkbComputeEffectiveMap(XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned char *map_rtrn)
{
-register int i;
-unsigned tmp;
-XkbKTMapEntryPtr entry = NULL;
-
- if ((!xkb)||(!type)||(!xkb->server))
- return False;
-
- if (type->mods.vmods!=0) {
- if (!XkbVirtualModsToReal(xkb,type->mods.vmods,&tmp))
- return False;
-
- type->mods.mask= tmp|type->mods.real_mods;
- entry= type->map;
- for (i=0;i<type->map_count;i++,entry++) {
- tmp= 0;
- if (entry->mods.vmods!=0) {
- if (!XkbVirtualModsToReal(xkb,entry->mods.vmods,&tmp))
- return False;
- if (tmp==0) {
- entry->active= False;
- continue;
- }
- }
- entry->active= True;
- entry->mods.mask= (entry->mods.real_mods|tmp)&type->mods.mask;
- }
+ register int i;
+ unsigned tmp;
+ XkbKTMapEntryPtr entry = NULL;
+
+ if ((!xkb) || (!type) || (!xkb->server))
+ return False;
+
+ if (type->mods.vmods != 0) {
+ if (!XkbVirtualModsToReal(xkb, type->mods.vmods, &tmp))
+ return False;
+
+ type->mods.mask = tmp | type->mods.real_mods;
+ entry = type->map;
+ for (i = 0; i < type->map_count; i++, entry++) {
+ tmp = 0;
+ if (entry->mods.vmods != 0) {
+ if (!XkbVirtualModsToReal(xkb, entry->mods.vmods, &tmp))
+ return False;
+ if (tmp == 0) {
+ entry->active = False;
+ continue;
+ }
+ }
+ entry->active = True;
+ entry->mods.mask = (entry->mods.real_mods | tmp) & type->mods.mask;
+ }
}
else {
- type->mods.mask= type->mods.real_mods;
+ type->mods.mask = type->mods.real_mods;
}
- if (map_rtrn!=NULL) {
- bzero(map_rtrn,type->mods.mask+1);
- for (i=0;i<type->map_count;i++) {
- if (entry->active) {
- map_rtrn[type->map[i].mods.mask]= type->map[i].level;
- }
- }
+ if (map_rtrn != NULL) {
+ bzero(map_rtrn, type->mods.mask + 1);
+ for (i = 0; i < type->map_count; i++) {
+ if (entry && entry->active) {
+ map_rtrn[type->map[i].mods.mask] = type->map[i].level;
+ }
+ }
}
return True;
}
Status
-XkbGetState(Display *dpy,unsigned deviceSpec,XkbStatePtr rtrn)
+XkbGetState(Display *dpy, unsigned deviceSpec, XkbStatePtr rtrn)
{
- register xkbGetStateReq *req;
+ register xkbGetStateReq *req;
xkbGetStateReply rep;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetState, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetState;
req->deviceSpec = deviceSpec;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadImplementation;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
}
- rtrn->mods= rep.mods;
- rtrn->base_mods= rep.baseMods;
- rtrn->latched_mods= rep.latchedMods;
- rtrn->locked_mods= rep.lockedMods;
- rtrn->group= rep.group;
- rtrn->base_group= rep.baseGroup;
- rtrn->latched_group= rep.latchedGroup;
- rtrn->locked_group= rep.lockedGroup;
- rtrn->compat_state= rep.compatState;
- rtrn->grab_mods= rep.grabMods;
- rtrn->compat_grab_mods= rep.compatGrabMods;
- rtrn->lookup_mods= rep.lookupMods;
- rtrn->compat_lookup_mods= rep.compatLookupMods;
- rtrn->ptr_buttons= rep.ptrBtnState;
+ rtrn->mods = rep.mods;
+ rtrn->base_mods = rep.baseMods;
+ rtrn->latched_mods = rep.latchedMods;
+ rtrn->locked_mods = rep.lockedMods;
+ rtrn->group = rep.group;
+ rtrn->base_group = rep.baseGroup;
+ rtrn->latched_group = rep.latchedGroup;
+ rtrn->locked_group = rep.lockedGroup;
+ rtrn->compat_state = rep.compatState;
+ rtrn->grab_mods = rep.grabMods;
+ rtrn->compat_grab_mods = rep.compatGrabMods;
+ rtrn->lookup_mods = rep.lookupMods;
+ rtrn->compat_lookup_mods = rep.compatLookupMods;
+ rtrn->ptr_buttons = rep.ptrBtnState;
UnlockDisplay(dpy);
SyncHandle();
return Success;
}
Bool
-XkbSetDetectableAutoRepeat(Display *dpy,Bool detectable,Bool *supported)
+XkbSetDetectableAutoRepeat(Display *dpy, Bool detectable, Bool *supported)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -528,31 +535,32 @@ XkbInfoPtr xkbi;
req->deviceSpec = XkbUseCoreKbd;
req->change = XkbPCF_DetectableAutoRepeatMask;
if (detectable)
- req->value = XkbPCF_DetectableAutoRepeatMask;
- else req->value = 0;
- req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->value = XkbPCF_DetectableAutoRepeatMask;
+ else
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
- if (supported!=NULL)
- *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
- return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+ if (supported != NULL)
+ *supported = ((rep.supported & XkbPCF_DetectableAutoRepeatMask) != 0);
+ return ((rep.value & XkbPCF_DetectableAutoRepeatMask) != 0);
}
Bool
-XkbGetDetectableAutoRepeat(Display *dpy,Bool *supported)
+XkbGetDetectableAutoRepeat(Display *dpy, Bool *supported)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -561,32 +569,32 @@ XkbInfoPtr xkbi;
req->deviceSpec = XkbUseCoreKbd;
req->change = 0;
req->value = 0;
- req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
- if (supported!=NULL)
- *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
- return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+ if (supported != NULL)
+ *supported = ((rep.supported & XkbPCF_DetectableAutoRepeatMask) != 0);
+ return ((rep.value & XkbPCF_DetectableAutoRepeatMask) != 0);
}
Bool
-XkbSetAutoResetControls( Display * dpy,
- unsigned changes,
- unsigned * auto_ctrls,
- unsigned * auto_values)
+XkbSetAutoResetControls(Display *dpy,
+ unsigned changes,
+ unsigned *auto_ctrls,
+ unsigned *auto_values)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -595,33 +603,33 @@ XkbInfoPtr xkbi;
req->change = XkbPCF_AutoResetControlsMask;
req->deviceSpec = XkbUseCoreKbd;
req->value = XkbPCF_AutoResetControlsMask;
- req->ctrlsToChange= changes;
- req->autoCtrls= *auto_ctrls;
- req->autoCtrlValues= *auto_values;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->ctrlsToChange = changes;
+ req->autoCtrls = *auto_ctrls;
+ req->autoCtrlValues = *auto_values;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
- *auto_ctrls= rep.autoCtrls;
- *auto_values= rep.autoCtrlValues;
- return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+ *auto_ctrls = rep.autoCtrls;
+ *auto_values = rep.autoCtrlValues;
+ return ((rep.value & XkbPCF_AutoResetControlsMask) != 0);
}
Bool
-XkbGetAutoResetControls( Display * dpy,
- unsigned * auto_ctrls,
- unsigned * auto_ctrl_values)
+XkbGetAutoResetControls(Display *dpy,
+ unsigned *auto_ctrls,
+ unsigned *auto_ctrl_values)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -630,35 +638,35 @@ XkbInfoPtr xkbi;
req->deviceSpec = XkbUseCoreKbd;
req->change = 0;
req->value = 0;
- req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
if (auto_ctrls)
- *auto_ctrls= rep.autoCtrls;
+ *auto_ctrls = rep.autoCtrls;
if (auto_ctrl_values)
- *auto_ctrl_values= rep.autoCtrlValues;
- return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+ *auto_ctrl_values = rep.autoCtrlValues;
+ return ((rep.value & XkbPCF_AutoResetControlsMask) != 0);
}
Bool
-XkbSetPerClientControls( Display * dpy,
- unsigned change,
- unsigned * values)
+XkbSetPerClientControls(Display *dpy, unsigned change, unsigned *values)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
-unsigned value_hold = *values;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
+ unsigned value_hold = *values;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
- (change & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) ||
+ (change & ~(XkbPCF_GrabsUseXKBStateMask |
+ XkbPCF_LookupStateWhenGrabbed |
+ XkbPCF_SendEventUsesXKBState)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -667,30 +675,29 @@ unsigned value_hold = *values;
req->change = change;
req->deviceSpec = XkbUseCoreKbd;
req->value = *values;
- req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
*values = rep.value;
- return ((rep.value&value_hold)!=0);
+ return ((rep.value & value_hold) != 0);
}
Bool
-XkbGetPerClientControls( Display * dpy,
- unsigned * ctrls)
+XkbGetPerClientControls(Display *dpy, unsigned *ctrls)
{
-register xkbPerClientFlagsReq * req;
-xkbPerClientFlagsReply rep;
-XkbInfoPtr xkbi;
+ register xkbPerClientFlagsReq *req;
+ xkbPerClientFlagsReply rep;
+ XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
- (*ctrls & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) ||
+ (ctrls == NULL))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbPerClientFlags, req);
@@ -699,69 +706,70 @@ XkbInfoPtr xkbi;
req->deviceSpec = XkbUseCoreKbd;
req->change = 0;
req->value = 0;
- req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues = 0;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
- if (ctrls)
- *ctrls= (rep.value & (XkbPCF_GrabsUseXKBStateMask |
- XkbPCF_LookupStateWhenGrabbed |
- XkbPCF_SendEventUsesXKBState));
+ *ctrls = (rep.value & (XkbPCF_GrabsUseXKBStateMask |
+ XkbPCF_LookupStateWhenGrabbed |
+ XkbPCF_SendEventUsesXKBState));
return (True);
}
Display *
-XkbOpenDisplay( char * name,
- int * ev_rtrn,
- int * err_rtrn,
- int * major_rtrn,
- int * minor_rtrn,
- int * reason)
+XkbOpenDisplay(char *name,
+ int *ev_rtrn,
+ int *err_rtrn,
+ int *major_rtrn,
+ int *minor_rtrn,
+ int *reason)
{
- Display* dpy;
- int major_num,minor_num;
-
- if ((major_rtrn!=NULL) && (minor_rtrn!=NULL)) {
- if (!XkbLibraryVersion(major_rtrn,minor_rtrn)) {
- if (reason!=NULL)
- *reason= XkbOD_BadLibraryVersion;
- return NULL;
- }
+ Display *dpy;
+ int major_num, minor_num;
+
+ if ((major_rtrn != NULL) && (minor_rtrn != NULL)) {
+ if (!XkbLibraryVersion(major_rtrn, minor_rtrn)) {
+ if (reason != NULL)
+ *reason = XkbOD_BadLibraryVersion;
+ return NULL;
+ }
}
else {
- major_num= XkbMajorVersion;
- minor_num= XkbMinorVersion;
- major_rtrn= &major_num;
- minor_rtrn= &minor_num;
+ major_num = XkbMajorVersion;
+ minor_num = XkbMinorVersion;
+ major_rtrn = &major_num;
+ minor_rtrn = &minor_num;
}
- dpy= XOpenDisplay(name);
- if (dpy==NULL) {
- if (reason!=NULL)
- *reason= XkbOD_ConnectionRefused;
- return NULL;
+ dpy = XOpenDisplay(name);
+ if (dpy == NULL) {
+ if (reason != NULL)
+ *reason = XkbOD_ConnectionRefused;
+ return NULL;
}
- if (!XkbQueryExtension(dpy,NULL,ev_rtrn,err_rtrn,major_rtrn,minor_rtrn)) {
- if (reason!=NULL) {
- if ((*major_rtrn!=0)||(*minor_rtrn!=0))
- *reason= XkbOD_BadServerVersion;
- else *reason= XkbOD_NonXkbServer;
- }
- XCloseDisplay(dpy);
- return NULL;
+ if (!XkbQueryExtension(dpy, NULL, ev_rtrn, err_rtrn,
+ major_rtrn, minor_rtrn)) {
+ if (reason != NULL) {
+ if ((*major_rtrn != 0) || (*minor_rtrn != 0))
+ *reason = XkbOD_BadServerVersion;
+ else
+ *reason = XkbOD_NonXkbServer;
+ }
+ XCloseDisplay(dpy);
+ return NULL;
}
- if (reason!=NULL)
- *reason= XkbOD_Success;
+ if (reason != NULL)
+ *reason = XkbOD_Success;
return dpy;
}
void
-XkbSetAtomFuncs(XkbInternAtomFunc getAtom,XkbGetAtomNameFunc getName)
+XkbSetAtomFuncs(XkbInternAtomFunc getAtom, XkbGetAtomNameFunc getName)
{
- _XkbInternAtomFunc= (getAtom?getAtom:XInternAtom);
- _XkbGetAtomNameFunc= (getName?getName:XGetAtomName);
+ _XkbInternAtomFunc = (getAtom ? getAtom : XInternAtom);
+ _XkbGetAtomNameFunc = (getName ? getName : XGetAtomName);
return;
}
diff --git a/nx-X11/lib/X11/XKBAlloc.c b/nx-X11/lib/X11/XKBAlloc.c
index 995c955cc..9c3430c1a 100644
--- a/nx-X11/lib/X11/XKBAlloc.c
+++ b/nx-X11/lib/X11/XKBAlloc.c
@@ -24,13 +24,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#elif defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifndef XKB_IN_SERVER
#include <stdio.h>
#include "Xlibint.h"
@@ -39,89 +36,78 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/extensions/XKBproto.h>
#include "XKBlibint.h"
-#else
-
-#include <stdio.h>
-#include <nx-X11/X.h>
-#include <nx-X11/Xproto.h>
-#include "misc.h"
-#include "inputstr.h"
-#include <nx-X11/extensions/XKBsrv.h>
-#include <nx-X11/extensions/XKBgeom.h>
-
-#endif /* XKB_IN_SERVER */
/***===================================================================***/
/*ARGSUSED*/
Status
-XkbAllocCompatMap(XkbDescPtr xkb,unsigned which,unsigned nSI)
+XkbAllocCompatMap(XkbDescPtr xkb, unsigned which, unsigned nSI)
{
-XkbCompatMapPtr compat;
-XkbSymInterpretRec *prev_interpret;
+ XkbCompatMapPtr compat;
+ XkbSymInterpretRec *prev_interpret;
if (!xkb)
- return BadMatch;
+ return BadMatch;
if (xkb->compat) {
- if (xkb->compat->size_si>=nSI)
- return Success;
- compat= xkb->compat;
- compat->size_si= nSI;
- if (compat->sym_interpret==NULL)
- compat->num_si= 0;
- prev_interpret = compat->sym_interpret;
- compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
- nSI,XkbSymInterpretRec);
- if (compat->sym_interpret==NULL) {
- _XkbFree(prev_interpret);
- compat->size_si= compat->num_si= 0;
- return BadAlloc;
- }
- if (compat->num_si!=0) {
- _XkbClearElems(compat->sym_interpret,compat->num_si,
- compat->size_si-1,XkbSymInterpretRec);
- }
- return Success;
+ if (xkb->compat->size_si >= nSI)
+ return Success;
+ compat = xkb->compat;
+ compat->size_si = nSI;
+ if (compat->sym_interpret == NULL)
+ compat->num_si = 0;
+ prev_interpret = compat->sym_interpret;
+ compat->sym_interpret = _XkbTypedRealloc(compat->sym_interpret,
+ nSI, XkbSymInterpretRec);
+ if (compat->sym_interpret == NULL) {
+ _XkbFree(prev_interpret);
+ compat->size_si = compat->num_si = 0;
+ return BadAlloc;
+ }
+ if (compat->num_si != 0) {
+ _XkbClearElems(compat->sym_interpret, compat->num_si,
+ compat->size_si - 1, XkbSymInterpretRec);
+ }
+ return Success;
}
- compat= _XkbTypedCalloc(1,XkbCompatMapRec);
- if (compat==NULL)
- return BadAlloc;
- if (nSI>0) {
- compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec);
- if (!compat->sym_interpret) {
- _XkbFree(compat);
- return BadAlloc;
- }
+ compat = _XkbTypedCalloc(1, XkbCompatMapRec);
+ if (compat == NULL)
+ return BadAlloc;
+ if (nSI > 0) {
+ compat->sym_interpret = _XkbTypedCalloc(nSI, XkbSymInterpretRec);
+ if (!compat->sym_interpret) {
+ _XkbFree(compat);
+ return BadAlloc;
+ }
}
- compat->size_si= nSI;
- compat->num_si= 0;
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
- xkb->compat= compat;
+ compat->size_si = nSI;
+ compat->num_si = 0;
+ bzero((char *) &compat->groups[0], XkbNumKbdGroups * sizeof(XkbModsRec));
+ xkb->compat = compat;
return Success;
}
void
-XkbFreeCompatMap(XkbDescPtr xkb,unsigned which,Bool freeMap)
+XkbFreeCompatMap(XkbDescPtr xkb, unsigned which, Bool freeMap)
{
-register XkbCompatMapPtr compat;
+ register XkbCompatMapPtr compat;
- if ((xkb==NULL)||(xkb->compat==NULL))
- return;
- compat= xkb->compat;
+ if ((xkb == NULL) || (xkb->compat == NULL))
+ return;
+ compat = xkb->compat;
if (freeMap)
- which= XkbAllCompatMask;
- if (which&XkbGroupCompatMask)
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
- if (which&XkbSymInterpMask) {
- if ((compat->sym_interpret)&&(compat->size_si>0))
- _XkbFree(compat->sym_interpret);
- compat->size_si= compat->num_si= 0;
- compat->sym_interpret= NULL;
+ which = XkbAllCompatMask;
+ if (which & XkbGroupCompatMask)
+ bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(XkbModsRec));
+ if (which & XkbSymInterpMask) {
+ if ((compat->sym_interpret) && (compat->size_si > 0))
+ _XkbFree(compat->sym_interpret);
+ compat->size_si = compat->num_si = 0;
+ compat->sym_interpret = NULL;
}
if (freeMap) {
- _XkbFree(compat);
- xkb->compat= NULL;
+ _XkbFree(compat);
+ xkb->compat = NULL;
}
return;
}
@@ -129,127 +115,132 @@ register XkbCompatMapPtr compat;
/***===================================================================***/
Status
-XkbAllocNames(XkbDescPtr xkb,unsigned which,int nTotalRG,int nTotalAliases)
+XkbAllocNames(XkbDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
{
-XkbNamesPtr names;
-
- if (xkb==NULL)
- return BadMatch;
- if (xkb->names==NULL) {
- xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
- if (xkb->names==NULL)
- return BadAlloc;
+ XkbNamesPtr names;
+
+ if (xkb == NULL)
+ return BadMatch;
+ if (xkb->names == NULL) {
+ xkb->names = _XkbTypedCalloc(1, XkbNamesRec);
+ if (xkb->names == NULL)
+ return BadAlloc;
}
- names= xkb->names;
- if ((which&XkbKTLevelNamesMask)&&(xkb->map!=NULL)&&(xkb->map->types!=NULL)){
- register int i;
- XkbKeyTypePtr type;
-
- type= xkb->map->types;
- for (i=0;i<xkb->map->num_types;i++,type++) {
- if (type->level_names==NULL) {
- type->level_names= _XkbTypedCalloc(type->num_levels,Atom);
- if (type->level_names==NULL)
- return BadAlloc;
- }
- }
+ names = xkb->names;
+ if ((which & XkbKTLevelNamesMask) && (xkb->map != NULL) &&
+ (xkb->map->types != NULL)) {
+ register int i;
+ XkbKeyTypePtr type = xkb->map->types;
+
+ for (i = 0; i < xkb->map->num_types; i++, type++) {
+ if (type->level_names == NULL) {
+ type->level_names = _XkbTypedCalloc(type->num_levels, Atom);
+ if (type->level_names == NULL)
+ return BadAlloc;
+ }
+ }
}
- if ((which&XkbKeyNamesMask)&&(names->keys==NULL)) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadValue;
- names->keys= _XkbTypedCalloc((xkb->max_key_code+1),XkbKeyNameRec);
- if (names->keys==NULL)
- return BadAlloc;
+ if ((which & XkbKeyNamesMask) && (names->keys == NULL)) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadValue;
+ names->keys = _XkbTypedCalloc((xkb->max_key_code + 1), XkbKeyNameRec);
+ if (names->keys == NULL)
+ return BadAlloc;
}
- if ((which&XkbKeyAliasesMask)&&(nTotalAliases>0)) {
- if (names->key_aliases==NULL) {
- names->key_aliases= _XkbTypedCalloc(nTotalAliases,XkbKeyAliasRec);
- }
- else if (nTotalAliases>names->num_key_aliases) {
- XkbKeyAliasRec *prev_aliases = names->key_aliases;
-
- names->key_aliases= _XkbTypedRealloc(names->key_aliases,
- nTotalAliases,XkbKeyAliasRec);
- if (names->key_aliases!=NULL) {
- _XkbClearElems(names->key_aliases,names->num_key_aliases,
- nTotalAliases-1,XkbKeyAliasRec);
- } else {
- _XkbFree(prev_aliases);
- }
- }
- if (names->key_aliases==NULL) {
- names->num_key_aliases= 0;
- return BadAlloc;
- }
- names->num_key_aliases= nTotalAliases;
+ if ((which & XkbKeyAliasesMask) && (nTotalAliases > 0)) {
+ if (names->key_aliases == NULL) {
+ names->key_aliases = _XkbTypedCalloc(nTotalAliases, XkbKeyAliasRec);
+ }
+ else if (nTotalAliases > names->num_key_aliases) {
+ XkbKeyAliasRec *prev_aliases = names->key_aliases;
+
+ names->key_aliases = _XkbTypedRealloc(names->key_aliases,
+ nTotalAliases,
+ XkbKeyAliasRec);
+ if (names->key_aliases != NULL) {
+ _XkbClearElems(names->key_aliases, names->num_key_aliases,
+ nTotalAliases - 1, XkbKeyAliasRec);
+ }
+ else {
+ _XkbFree(prev_aliases);
+ }
+ }
+ if (names->key_aliases == NULL) {
+ names->num_key_aliases = 0;
+ return BadAlloc;
+ }
+ names->num_key_aliases = nTotalAliases;
}
- if ((which&XkbRGNamesMask)&&(nTotalRG>0)) {
- if (names->radio_groups==NULL) {
- names->radio_groups= _XkbTypedCalloc(nTotalRG,Atom);
- }
- else if (nTotalRG>names->num_rg) {
- Atom *prev_radio_groups = names->radio_groups;
-
- names->radio_groups= _XkbTypedRealloc(names->radio_groups,nTotalRG,
- Atom);
- if (names->radio_groups!=NULL) {
- _XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1,
- Atom);
- } else {
- _XkbFree(prev_radio_groups);
- }
- }
- if (names->radio_groups==NULL)
- return BadAlloc;
- names->num_rg= nTotalRG;
+ if ((which & XkbRGNamesMask) && (nTotalRG > 0)) {
+ if (names->radio_groups == NULL) {
+ names->radio_groups = _XkbTypedCalloc(nTotalRG, Atom);
+ }
+ else if (nTotalRG > names->num_rg) {
+ Atom *prev_radio_groups = names->radio_groups;
+
+ names->radio_groups =
+ _XkbTypedRealloc(names->radio_groups, nTotalRG, Atom);
+ if (names->radio_groups != NULL) {
+ _XkbClearElems(names->radio_groups, names->num_rg, nTotalRG - 1,
+ Atom);
+ }
+ else {
+ _XkbFree(prev_radio_groups);
+ }
+ }
+ if (names->radio_groups == NULL)
+ return BadAlloc;
+ names->num_rg = nTotalRG;
}
return Success;
}
void
-XkbFreeNames(XkbDescPtr xkb,unsigned which,Bool freeMap)
+XkbFreeNames(XkbDescPtr xkb, unsigned which, Bool freeMap)
{
-XkbNamesPtr names;
+ XkbNamesPtr names;
- if ((xkb==NULL)||(xkb->names==NULL))
- return;
- names= xkb->names;
+ if ((xkb == NULL) || (xkb->names == NULL))
+ return;
+ names = xkb->names;
if (freeMap)
- which= XkbAllNamesMask;
- if (which&XkbKTLevelNamesMask) {
- XkbClientMapPtr map= xkb->map;
- if ((map!=NULL)&&(map->types!=NULL)) {
- register int i;
- register XkbKeyTypePtr type;
- type= map->types;
- for (i=0;i<map->num_types;i++,type++) {
- if (type->level_names!=NULL) {
- _XkbFree(type->level_names);
- type->level_names= NULL;
- }
- }
- }
+ which = XkbAllNamesMask;
+ if (which & XkbKTLevelNamesMask) {
+ XkbClientMapPtr map = xkb->map;
+
+ if ((map != NULL) && (map->types != NULL)) {
+ register int i;
+ register XkbKeyTypePtr type;
+
+ type = map->types;
+ for (i = 0; i < map->num_types; i++, type++) {
+ if (type->level_names != NULL) {
+ _XkbFree(type->level_names);
+ type->level_names = NULL;
+ }
+ }
+ }
}
- if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
- _XkbFree(names->keys);
- names->keys= NULL;
- names->num_keys= 0;
+ if ((which & XkbKeyNamesMask) && (names->keys != NULL)) {
+ _XkbFree(names->keys);
+ names->keys = NULL;
+ names->num_keys = 0;
}
- if ((which&XkbKeyAliasesMask)&&(names->key_aliases)){
- _XkbFree(names->key_aliases);
- names->key_aliases=NULL;
- names->num_key_aliases=0;
+ if ((which & XkbKeyAliasesMask) && (names->key_aliases)) {
+ _XkbFree(names->key_aliases);
+ names->key_aliases = NULL;
+ names->num_key_aliases = 0;
}
- if ((which&XkbRGNamesMask)&&(names->radio_groups)) {
- _XkbFree(names->radio_groups);
- names->radio_groups= NULL;
- names->num_rg= 0;
+ if ((which & XkbRGNamesMask) && (names->radio_groups)) {
+ _XkbFree(names->radio_groups);
+ names->radio_groups = NULL;
+ names->num_rg = 0;
}
if (freeMap) {
- _XkbFree(names);
- xkb->names= NULL;
+ _XkbFree(names);
+ xkb->names = NULL;
}
return;
}
@@ -258,26 +249,26 @@ XkbNamesPtr names;
/*ARGSUSED*/
Status
-XkbAllocControls(XkbDescPtr xkb,unsigned which)
+XkbAllocControls(XkbDescPtr xkb, unsigned which)
{
- if (xkb==NULL)
- return BadMatch;
+ if (xkb == NULL)
+ return BadMatch;
- if (xkb->ctrls==NULL) {
- xkb->ctrls= _XkbTypedCalloc(1,XkbControlsRec);
- if (!xkb->ctrls)
- return BadAlloc;
+ if (xkb->ctrls == NULL) {
+ xkb->ctrls = _XkbTypedCalloc(1, XkbControlsRec);
+ if (!xkb->ctrls)
+ return BadAlloc;
}
return Success;
}
/*ARGSUSED*/
void
-XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
+XkbFreeControls(XkbDescPtr xkb, unsigned which, Bool freeMap)
{
- if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) {
- _XkbFree(xkb->ctrls);
- xkb->ctrls= NULL;
+ if (freeMap && (xkb != NULL) && (xkb->ctrls != NULL)) {
+ _XkbFree(xkb->ctrls);
+ xkb->ctrls = NULL;
}
return;
}
@@ -287,12 +278,12 @@ XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
Status
XkbAllocIndicatorMaps(XkbDescPtr xkb)
{
- if (xkb==NULL)
- return BadMatch;
- if (xkb->indicators==NULL) {
- xkb->indicators= _XkbTypedCalloc(1,XkbIndicatorRec);
- if (!xkb->indicators)
- return BadAlloc;
+ if (xkb == NULL)
+ return BadMatch;
+ if (xkb->indicators == NULL) {
+ xkb->indicators = _XkbTypedCalloc(1, XkbIndicatorRec);
+ if (!xkb->indicators)
+ return BadAlloc;
}
return Success;
}
@@ -300,199 +291,205 @@ XkbAllocIndicatorMaps(XkbDescPtr xkb)
void
XkbFreeIndicatorMaps(XkbDescPtr xkb)
{
- if ((xkb!=NULL)&&(xkb->indicators!=NULL)) {
- _XkbFree(xkb->indicators);
- xkb->indicators= NULL;
+ if ((xkb != NULL) && (xkb->indicators != NULL)) {
+ _XkbFree(xkb->indicators);
+ xkb->indicators = NULL;
}
return;
}
/***====================================================================***/
-XkbDescRec *
+XkbDescRec *
XkbAllocKeyboard(void)
{
-XkbDescRec *xkb;
+ XkbDescRec *xkb;
- xkb = _XkbTypedCalloc(1,XkbDescRec);
+ xkb = _XkbTypedCalloc(1, XkbDescRec);
if (xkb)
- xkb->device_spec= XkbUseCoreKbd;
+ xkb->device_spec = XkbUseCoreKbd;
return xkb;
}
void
-XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll)
+XkbFreeKeyboard(XkbDescPtr xkb, unsigned which, Bool freeAll)
{
- if (xkb==NULL)
- return;
+ if (xkb == NULL)
+ return;
if (freeAll)
- which= XkbAllComponentsMask;
- if (which&XkbClientMapMask)
- XkbFreeClientMap(xkb,XkbAllClientInfoMask,True);
- if (which&XkbServerMapMask)
- XkbFreeServerMap(xkb,XkbAllServerInfoMask,True);
- if (which&XkbCompatMapMask)
- XkbFreeCompatMap(xkb,XkbAllCompatMask,True);
- if (which&XkbIndicatorMapMask)
- XkbFreeIndicatorMaps(xkb);
- if (which&XkbNamesMask)
- XkbFreeNames(xkb,XkbAllNamesMask,True);
- if ((which&XkbGeometryMask) && (xkb->geom!=NULL))
- XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
- if (which&XkbControlsMask)
- XkbFreeControls(xkb,XkbAllControlsMask,True);
+ which = XkbAllComponentsMask;
+ if (which & XkbClientMapMask)
+ XkbFreeClientMap(xkb, XkbAllClientInfoMask, True);
+ if (which & XkbServerMapMask)
+ XkbFreeServerMap(xkb, XkbAllServerInfoMask, True);
+ if (which & XkbCompatMapMask)
+ XkbFreeCompatMap(xkb, XkbAllCompatMask, True);
+ if (which & XkbIndicatorMapMask)
+ XkbFreeIndicatorMaps(xkb);
+ if (which & XkbNamesMask)
+ XkbFreeNames(xkb, XkbAllNamesMask, True);
+ if ((which & XkbGeometryMask) && (xkb->geom != NULL))
+ XkbFreeGeometry(xkb->geom, XkbGeomAllMask, True);
+ if (which & XkbControlsMask)
+ XkbFreeControls(xkb, XkbAllControlsMask, True);
if (freeAll)
- _XkbFree(xkb);
+ _XkbFree(xkb);
return;
}
/***====================================================================***/
XkbDeviceLedInfoPtr
-XkbAddDeviceLedInfo(XkbDeviceInfoPtr devi,unsigned ledClass,unsigned ledId)
+XkbAddDeviceLedInfo(XkbDeviceInfoPtr devi, unsigned ledClass, unsigned ledId)
{
-XkbDeviceLedInfoPtr devli;
-register int i;
-
- if ((!devi)||(!XkbSingleXIClass(ledClass))||(!XkbSingleXIId(ledId)))
- return NULL;
- for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
- if ((devli->led_class==ledClass)&&(devli->led_id==ledId))
- return devli;
+ XkbDeviceLedInfoPtr devli;
+ register int i;
+
+ if ((!devi) || (!XkbSingleXIClass(ledClass)) || (!XkbSingleXIId(ledId)))
+ return NULL;
+ for (i = 0, devli = devi->leds; i < devi->num_leds; i++, devli++) {
+ if ((devli->led_class == ledClass) && (devli->led_id == ledId))
+ return devli;
}
- if (devi->num_leds>=devi->sz_leds) {
- XkbDeviceLedInfoRec *prev_leds = devi->leds;
-
- if (devi->sz_leds>0) devi->sz_leds*= 2;
- else devi->sz_leds= 1;
- devi->leds= _XkbTypedRealloc(devi->leds,devi->sz_leds,
- XkbDeviceLedInfoRec);
- if (!devi->leds) {
- _XkbFree(prev_leds);
- devi->sz_leds= devi->num_leds= 0;
- return NULL;
- }
- i= devi->num_leds;
- for (devli=&devi->leds[i];i<devi->sz_leds;i++,devli++) {
- bzero(devli,sizeof(XkbDeviceLedInfoRec));
- devli->led_class= XkbXINone;
- devli->led_id= XkbXINone;
- }
+ if (devi->num_leds >= devi->sz_leds) {
+ XkbDeviceLedInfoRec *prev_leds = devi->leds;
+
+ if (devi->sz_leds > 0)
+ devi->sz_leds *= 2;
+ else
+ devi->sz_leds = 1;
+ devi->leds = _XkbTypedRealloc(devi->leds, devi->sz_leds,
+ XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ _XkbFree(prev_leds);
+ devi->sz_leds = devi->num_leds = 0;
+ return NULL;
+ }
+ i = devi->num_leds;
+ for (devli = &devi->leds[i]; i < devi->sz_leds; i++, devli++) {
+ bzero(devli, sizeof(XkbDeviceLedInfoRec));
+ devli->led_class = XkbXINone;
+ devli->led_id = XkbXINone;
+ }
}
- devli= &devi->leds[devi->num_leds++];
- bzero(devli,sizeof(XkbDeviceLedInfoRec));
- devli->led_class= ledClass;
- devli->led_id= ledId;
+ devli = &devi->leds[devi->num_leds++];
+ bzero(devli, sizeof(XkbDeviceLedInfoRec));
+ devli->led_class = ledClass;
+ devli->led_id = ledId;
return devli;
}
Status
-XkbResizeDeviceButtonActions(XkbDeviceInfoPtr devi,unsigned newTotal)
+XkbResizeDeviceButtonActions(XkbDeviceInfoPtr devi, unsigned newTotal)
{
XkbAction *prev_btn_acts;
- if ((!devi)||(newTotal>255))
- return BadValue;
- if ((devi->btn_acts!=NULL)&&(newTotal==devi->num_btns))
- return Success;
- if (newTotal==0) {
- if (devi->btn_acts!=NULL) {
- _XkbFree(devi->btn_acts);
- devi->btn_acts= NULL;
- }
- devi->num_btns= 0;
- return Success;
+ if ((!devi) || (newTotal > 255))
+ return BadValue;
+ if ((devi->btn_acts != NULL) && (newTotal == devi->num_btns))
+ return Success;
+ if (newTotal == 0) {
+ if (devi->btn_acts != NULL) {
+ _XkbFree(devi->btn_acts);
+ devi->btn_acts = NULL;
+ }
+ devi->num_btns = 0;
+ return Success;
}
prev_btn_acts = devi->btn_acts;
- devi->btn_acts= _XkbTypedRealloc(devi->btn_acts,newTotal,XkbAction);
- if (devi->btn_acts==NULL) {
- _XkbFree(prev_btn_acts);
- devi->num_btns= 0;
- return BadAlloc;
+ devi->btn_acts = _XkbTypedRealloc(devi->btn_acts, newTotal, XkbAction);
+ if (devi->btn_acts == NULL) {
+ _XkbFree(prev_btn_acts);
+ devi->num_btns = 0;
+ return BadAlloc;
}
- if (newTotal>devi->num_btns) {
- XkbAction *act;
- act= &devi->btn_acts[devi->num_btns];
- bzero((char *)act,(newTotal-devi->num_btns)*sizeof(XkbAction));
+ if (newTotal > devi->num_btns) {
+ XkbAction *act;
+
+ act = &devi->btn_acts[devi->num_btns];
+ bzero((char *) act, (newTotal - devi->num_btns) * sizeof(XkbAction));
}
- devi->num_btns= newTotal;
+ devi->num_btns = newTotal;
return Success;
}
/*ARGSUSED*/
XkbDeviceInfoPtr
-XkbAllocDeviceInfo(unsigned deviceSpec,unsigned nButtons,unsigned szLeds)
+XkbAllocDeviceInfo(unsigned deviceSpec, unsigned nButtons, unsigned szLeds)
{
-XkbDeviceInfoPtr devi;
-
- devi= _XkbTypedCalloc(1,XkbDeviceInfoRec);
- if (devi!=NULL) {
- devi->device_spec= deviceSpec;
- devi->has_own_state= False;
- devi->num_btns= 0;
- devi->btn_acts= NULL;
- if (nButtons>0) {
- devi->num_btns= nButtons;
- devi->btn_acts= _XkbTypedCalloc(nButtons,XkbAction);
- if (!devi->btn_acts) {
- _XkbFree(devi);
- return NULL;
- }
- }
- devi->dflt_kbd_fb= XkbXINone;
- devi->dflt_led_fb= XkbXINone;
- devi->num_leds= 0;
- devi->sz_leds= 0;
- devi->leds= NULL;
- if (szLeds>0) {
- devi->sz_leds= szLeds;
- devi->leds= _XkbTypedCalloc(szLeds,XkbDeviceLedInfoRec);
- if (!devi->leds) {
- if (devi->btn_acts)
- _XkbFree(devi->btn_acts);
- _XkbFree(devi);
- return NULL;
- }
- }
+ XkbDeviceInfoPtr devi;
+
+ devi = _XkbTypedCalloc(1, XkbDeviceInfoRec);
+ if (devi != NULL) {
+ devi->device_spec = deviceSpec;
+ devi->has_own_state = False;
+ devi->num_btns = 0;
+ devi->btn_acts = NULL;
+ if (nButtons > 0) {
+ devi->num_btns = nButtons;
+ devi->btn_acts = _XkbTypedCalloc(nButtons, XkbAction);
+ if (!devi->btn_acts) {
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
+ devi->dflt_kbd_fb = XkbXINone;
+ devi->dflt_led_fb = XkbXINone;
+ devi->num_leds = 0;
+ devi->sz_leds = 0;
+ devi->leds = NULL;
+ if (szLeds > 0) {
+ devi->sz_leds = szLeds;
+ devi->leds = _XkbTypedCalloc(szLeds, XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ _XkbFree(devi->btn_acts);
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
}
return devi;
}
void
-XkbFreeDeviceInfo(XkbDeviceInfoPtr devi,unsigned which,Bool freeDevI)
+XkbFreeDeviceInfo(XkbDeviceInfoPtr devi, unsigned which, Bool freeDevI)
{
if (devi) {
- if (freeDevI) {
- which= XkbXI_AllDeviceFeaturesMask;
- if (devi->name) {
- _XkbFree(devi->name);
- devi->name= NULL;
- }
- }
- if ((which&XkbXI_ButtonActionsMask)&&(devi->btn_acts)) {
- _XkbFree(devi->btn_acts);
- devi->num_btns= 0;
- devi->btn_acts= NULL;
- }
- if ((which&XkbXI_IndicatorsMask)&&(devi->leds)) {
- register int i;
- if ((which&XkbXI_IndicatorsMask)==XkbXI_IndicatorsMask) {
- _XkbFree(devi->leds);
- devi->sz_leds= devi->num_leds= 0;
- devi->leds= NULL;
- }
- else {
- XkbDeviceLedInfoPtr devli;
- for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
- if (which&XkbXI_IndicatorMapsMask)
- bzero((char *)&devli->maps[0],sizeof(devli->maps));
- else bzero((char *)&devli->names[0],sizeof(devli->names));
- }
- }
- }
- if (freeDevI)
- _XkbFree(devi);
+ if (freeDevI) {
+ which = XkbXI_AllDeviceFeaturesMask;
+ if (devi->name) {
+ _XkbFree(devi->name);
+ devi->name = NULL;
+ }
+ }
+ if ((which & XkbXI_ButtonActionsMask) && (devi->btn_acts)) {
+ _XkbFree(devi->btn_acts);
+ devi->num_btns = 0;
+ devi->btn_acts = NULL;
+ }
+ if ((which & XkbXI_IndicatorsMask) && (devi->leds)) {
+ register int i;
+
+ if ((which & XkbXI_IndicatorsMask) == XkbXI_IndicatorsMask) {
+ _XkbFree(devi->leds);
+ devi->sz_leds = devi->num_leds = 0;
+ devi->leds = NULL;
+ }
+ else {
+ XkbDeviceLedInfoPtr devli;
+
+ for (i = 0, devli = devi->leds; i < devi->num_leds;
+ i++, devli++) {
+ if (which & XkbXI_IndicatorMapsMask)
+ bzero((char *) &devli->maps[0], sizeof(devli->maps));
+ else
+ bzero((char *) &devli->names[0], sizeof(devli->names));
+ }
+ }
+ }
+ if (freeDevI)
+ _XkbFree(devi);
}
return;
}
diff --git a/nx-X11/lib/X11/XKBBell.c b/nx-X11/lib/X11/XKBBell.c
index ff2d5543a..d3e3a57ff 100644
--- a/nx-X11/lib/X11/XKBBell.c
+++ b/nx-X11/lib/X11/XKBBell.c
@@ -34,145 +34,146 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
Bool
-XkbDeviceBell( Display * dpy,
- Window window,
- int deviceID,
- int bellClass,
- int bellID,
- int percent,
- Atom name)
+XkbDeviceBell(Display *dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
{
register xkbBellReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
- GetReq(kbBell,req);
+ GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
- req->window = (CARD32)window;
- req->bellClass = (CARD16)bellClass;
- req->bellID = (CARD16)bellID;
+ req->window = (CARD32) window;
+ req->bellClass = (CARD16) bellClass;
+ req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = False;
req->eventOnly = False;
req->pitch = 0;
req->duration = 0;
- req->name = (CARD32)name;
- req->pad1= 0; req->pad2= 0;
+ req->name = (CARD32) name;
+ req->pad1 = 0;
+ req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
-XkbForceDeviceBell( Display * dpy,
- int deviceID,
- int bellClass,
- int bellID,
- int percent)
+XkbForceDeviceBell(Display *dpy,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent)
{
register xkbBellReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
- GetReq(kbBell,req);
+ GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
- req->window = (CARD32)None;
- req->bellClass = (CARD16)bellClass;
- req->bellID = (CARD16)bellID;
+ req->window = (CARD32) None;
+ req->bellClass = (CARD16) bellClass;
+ req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = True;
req->eventOnly = False;
req->pitch = 0;
req->duration = 0;
req->name = None;
- req->pad1= 0; req->pad2= 0;
+ req->pad1 = 0;
+ req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
-XkbDeviceBellEvent( Display * dpy,
- Window window,
- int deviceID,
- int bellClass,
- int bellID,
- int percent,
- Atom name)
+XkbDeviceBellEvent(Display *dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
{
register xkbBellReq *req;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
- GetReq(kbBell,req);
+ GetReq(kbBell, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbBell;
req->deviceSpec = deviceID;
- req->window = (CARD32)window;
- req->bellClass = (CARD16)bellClass;
- req->bellID = (CARD16)bellID;
+ req->window = (CARD32) window;
+ req->bellClass = (CARD16) bellClass;
+ req->bellID = (CARD16) bellID;
req->percent = percent;
req->forceSound = False;
req->eventOnly = True;
req->pitch = 0;
req->duration = 0;
- req->name = (CARD32)name;
- req->pad1= 0; req->pad2= 0;
+ req->name = (CARD32) name;
+ req->pad1 = 0;
+ req->pad2 = 0;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
-XkbBell(Display *dpy,Window window,int percent,Atom name)
+XkbBell(Display *dpy, Window window, int percent, Atom name)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
- XBell(dpy,percent);
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
+ XBell(dpy, percent);
+ return False;
}
- return XkbDeviceBell(dpy,window,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
- percent,name);
+ return XkbDeviceBell(dpy, window, XkbUseCoreKbd,
+ XkbDfltXIClass, XkbDfltXIId, percent, name);
}
Bool
-XkbForceBell(Display *dpy,int percent)
+XkbForceBell(Display *dpy, int percent)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
- XBell(dpy,percent);
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
+ XBell(dpy, percent);
+ return False;
}
- return XkbForceDeviceBell(dpy,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
- percent);
+ return XkbForceDeviceBell(dpy, XkbUseCoreKbd, XkbDfltXIClass, XkbDfltXIId,
+ percent);
}
Bool
-XkbBellEvent(Display *dpy,Window window,int percent,Atom name)
+XkbBellEvent(Display *dpy, Window window, int percent, Atom name)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
+ return False;
}
/* class 0 = KbdFeedbackClass (X Input Extension) */
- return XkbDeviceBellEvent(dpy,window,XkbUseCoreKbd,
- XkbDfltXIClass,XkbDfltXIId,
- percent,name);
+ return XkbDeviceBellEvent(dpy, window, XkbUseCoreKbd,
+ XkbDfltXIClass, XkbDfltXIId, percent, name);
}
-
diff --git a/nx-X11/lib/X11/XKBBind.c b/nx-X11/lib/X11/XKBBind.c
index 2d67e9e1e..c679dc552 100644
--- a/nx-X11/lib/X11/XKBBind.c
+++ b/nx-X11/lib/X11/XKBBind.c
@@ -26,7 +26,7 @@ from The Open Group.
*/
- /* the new monsters ate the old ones */
+ /* the new monsters ate the old ones */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -41,113 +41,112 @@ from The Open Group.
#include <nx-X11/extensions/XKBproto.h>
#include "XKBlibint.h"
-#ifdef USE_OWN_COMPOSE
-#define COMPOSE_NO_CONST_MEMBERS
-#include "imComp.h"
-#endif
-
#define AllMods (ShiftMask|LockMask|ControlMask| \
- Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
-static int _XkbLoadDpy(
- Display *dpy
-);
+static int _XkbLoadDpy(Display *dpy);
struct _XKeytrans {
- struct _XKeytrans *next;/* next on list */
- char *string; /* string to return when the time comes */
- int len; /* length of string (since NULL is legit)*/
- KeySym key; /* keysym rebound */
- unsigned int state; /* modifier state */
- KeySym *modifiers; /* modifier keysyms you want */
- int mlen; /* length of modifier list */
+ struct _XKeytrans *next; /* next on list */
+ char *string; /* string to return when the time comes */
+ int len; /* length of string (since NULL is legit) */
+ KeySym key; /* keysym rebound */
+ unsigned int state; /* modifier state */
+ KeySym *modifiers; /* modifier keysyms you want */
+ int mlen; /* length of modifier list */
};
KeySym
XkbKeycodeToKeysym(Display *dpy,
#if NeedWidePrototypes
- unsigned int kc,
+ unsigned int kc,
#else
- KeyCode kc,
+ KeyCode kc,
#endif
- int group,
- int level)
+ int group,
+ int level)
{
- XkbDescRec *xkb;
+ XkbDescRec *xkb;
if (_XkbUnavailable(dpy))
- return NoSymbol;
+ return NoSymbol;
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
xkb = dpy->xkb_info->desc;
- if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
- return NoSymbol;
-
- if ((group<0)||(level<0)||(group>=XkbKeyNumGroups(xkb,kc)))
- return NoSymbol;
- if (level>=XkbKeyGroupWidth(xkb,kc,group)) {
- /* for compatibility with the core protocol, _always_ allow */
- /* two symbols in the first two groups. If either of the */
- /* two is of type ONE_LEVEL, just replicate the first symbol */
- if ((group>XkbGroup2Index)||(XkbKeyGroupWidth(xkb,kc,group)!=1)||
- (level!=1)) {
- return NoSymbol;
- }
- level= 0;
+ if ((kc < xkb->min_key_code) || (kc > xkb->max_key_code))
+ return NoSymbol;
+
+ if ((group < 0) || (level < 0) || (group >= XkbKeyNumGroups(xkb, kc)))
+ return NoSymbol;
+ if (level >= XkbKeyGroupWidth(xkb, kc, group)) {
+ /* for compatibility with the core protocol, _always_ allow */
+ /* two symbols in the first two groups. If either of the */
+ /* two is of type ONE_LEVEL, just replicate the first symbol */
+ if ((group > XkbGroup2Index) || (XkbKeyGroupWidth(xkb, kc, group) != 1)
+ || (level != 1)) {
+ return NoSymbol;
+ }
+ level = 0;
}
- return XkbKeySymEntry(xkb,kc,level,group);
+ return XkbKeySymEntry(xkb, kc, level, group);
}
KeySym
XKeycodeToKeysym(Display *dpy,
#if NeedWidePrototypes
- unsigned int kc,
+ unsigned int kc,
#else
- KeyCode kc,
+ KeyCode kc,
#endif
- int col)
+ int col)
{
- XkbDescRec *xkb;
+ XkbDescRec *xkb;
if (_XkbUnavailable(dpy))
- return _XKeycodeToKeysym(dpy, kc, col);
+ return _XKeycodeToKeysym(dpy, kc, col);
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
xkb = dpy->xkb_info->desc;
- if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
- return NoSymbol;
-
- if (col>3) {
- int lastSym,tmp,nGrp;
-
- lastSym= 3;
- nGrp= XkbKeyNumGroups(xkb,kc);
- if ((nGrp>0)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup1Index))>2)) {
- if (col<=(lastSym+tmp-2))
- return XkbKeycodeToKeysym(dpy,kc,XkbGroup1Index,col-lastSym+2);
- lastSym+= tmp-2;
- }
- if ((nGrp>1)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup2Index))>2)) {
- if (col<=(lastSym+tmp-2))
- return XkbKeycodeToKeysym(dpy,kc,XkbGroup2Index,col-lastSym+2);
- lastSym+= tmp-2;
- }
- if (nGrp>2) {
- tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup3Index);
- if (col<=lastSym+tmp)
- return XkbKeycodeToKeysym(dpy,kc,XkbGroup3Index,col-lastSym);
- lastSym+= tmp;
- }
- if (nGrp>3) {
- tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup4Index);
- if (col<=lastSym+tmp)
- return XkbKeycodeToKeysym(dpy,kc,XkbGroup4Index,col-lastSym);
- }
- return NoSymbol;
+ if ((kc < xkb->min_key_code) || (kc > xkb->max_key_code))
+ return NoSymbol;
+
+ if (col > 3) {
+ int lastSym, tmp, nGrp;
+
+ lastSym = 3;
+ nGrp = XkbKeyNumGroups(xkb, kc);
+ if ((nGrp > 0) &&
+ ((tmp = XkbKeyGroupWidth(xkb, kc, XkbGroup1Index)) > 2)) {
+ if (col <= (lastSym + tmp - 2))
+ return XkbKeycodeToKeysym(dpy, kc, XkbGroup1Index,
+ col - lastSym + 2);
+ lastSym += tmp - 2;
+ }
+ if ((nGrp > 1) &&
+ ((tmp = XkbKeyGroupWidth(xkb, kc, XkbGroup2Index)) > 2)) {
+ if (col <= (lastSym + tmp - 2))
+ return XkbKeycodeToKeysym(dpy, kc, XkbGroup2Index,
+ col - lastSym + 2);
+ lastSym += tmp - 2;
+ }
+ if (nGrp > 2) {
+ tmp = XkbKeyGroupWidth(xkb, kc, XkbGroup3Index);
+ if (col <= lastSym + tmp)
+ return XkbKeycodeToKeysym(dpy, kc, XkbGroup3Index,
+ col - lastSym);
+ lastSym += tmp;
+ }
+ if (nGrp > 3) {
+ tmp = XkbKeyGroupWidth(xkb, kc, XkbGroup4Index);
+ if (col <= lastSym + tmp)
+ return XkbKeycodeToKeysym(dpy, kc, XkbGroup4Index,
+ col - lastSym);
+ }
+ return NoSymbol;
}
- return XkbKeycodeToKeysym(dpy,kc,(col>>1),(col&1));
+ return XkbKeycodeToKeysym(dpy, kc, (col >> 1), (col & 1));
}
KeyCode
@@ -156,21 +155,21 @@ XKeysymToKeycode(Display *dpy, KeySym ks)
register int i, j, gotOne;
if (_XkbUnavailable(dpy))
- return _XKeysymToKeycode(dpy,ks);
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return _XKeysymToKeycode(dpy, ks);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
- j= 0;
+ j = 0;
do {
- register XkbDescRec *xkb = dpy->xkb_info->desc;
- gotOne= 0;
- for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
- if ( j<(int)XkbKeyNumSyms(xkb,i) ) {
- gotOne = 1;
- if ((XkbKeySym(xkb,i,j)==ks))
- return i;
- }
- }
- j++;
+ register XkbDescRec *xkb = dpy->xkb_info->desc;
+ gotOne = 0;
+ for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+ if (j < (int) XkbKeyNumSyms(xkb, i)) {
+ gotOne = 1;
+ if ((XkbKeySym(xkb, i, j) == ks))
+ return i;
+ }
+ }
+ j++;
} while (gotOne);
return 0;
}
@@ -178,50 +177,51 @@ XKeysymToKeycode(Display *dpy, KeySym ks)
static int
_XkbComputeModmap(Display *dpy)
{
-register XkbDescPtr xkb;
+ register XkbDescPtr xkb;
- xkb= dpy->xkb_info->desc;
- if (XkbGetUpdatedMap(dpy,XkbModifierMapMask,xkb)==Success)
- return 1;
+ xkb = dpy->xkb_info->desc;
+ if (XkbGetUpdatedMap(dpy, XkbModifierMapMask, xkb) == Success)
+ return 1;
return 0;
}
unsigned
-XkbKeysymToModifiers(Display *dpy,KeySym ks)
+XkbKeysymToModifiers(Display *dpy, KeySym ks)
{
XkbDescRec *xkb;
- register int i,j;
+ register int i, j;
register KeySym *pSyms;
CARD8 mods;
if (_XkbUnavailable(dpy))
- return _XKeysymToModifiers(dpy,ks);
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
-
- if (_XkbNeedModmap(dpy->xkb_info)&&(!_XkbComputeModmap(dpy)))
- return _XKeysymToModifiers(dpy,ks);
-
- xkb= dpy->xkb_info->desc;
- mods= 0;
- for (i = xkb->min_key_code; i <= (int)xkb->max_key_code; i++) {
- pSyms= XkbKeySymsPtr(xkb,i);
- for (j=XkbKeyNumSyms(xkb,i)-1;j>=0;j--) {
- if (pSyms[j]==ks) {
- mods|= xkb->map->modmap[i];
- break;
- }
- }
+ return _XKeysymToModifiers(dpy, ks);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
+
+ if (_XkbNeedModmap(dpy->xkb_info) && (!_XkbComputeModmap(dpy)))
+ return _XKeysymToModifiers(dpy, ks);
+
+ xkb = dpy->xkb_info->desc;
+ mods = 0;
+ for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++) {
+ pSyms = XkbKeySymsPtr(xkb, i);
+ for (j = XkbKeyNumSyms(xkb, i) - 1; j >= 0; j--) {
+ if (pSyms[j] == ks) {
+ mods |= xkb->map->modmap[i];
+ break;
+ }
+ }
}
return mods;
}
KeySym
-XLookupKeysym(register XKeyEvent *event, int col)
+XLookupKeysym(register XKeyEvent * event, int col)
{
Display *dpy = event->display;
+
if (_XkbUnavailable(dpy))
- return _XLookupKeysym(event, col);
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return _XLookupKeysym(event, col);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
return XKeycodeToKeysym(dpy, event->keycode, col);
}
@@ -231,159 +231,165 @@ XLookupKeysym(register XKeyEvent *event, int col)
* version will continue to work in a shared library environment.
*/
int
-XkbTranslateKey( register Display * dpy,
- KeyCode key,
- register unsigned int mods,
- unsigned int * mods_rtrn,
- KeySym * keysym_rtrn);
+XkbTranslateKey(register Display *dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int *mods_rtrn,
+ KeySym *keysym_rtrn);
+
int
-XkbTranslateKey( register Display * dpy,
- KeyCode key,
- register unsigned int mods,
- unsigned int * mods_rtrn,
- KeySym * keysym_rtrn)
+XkbTranslateKey(register Display *dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int *mods_rtrn,
+ KeySym *keysym_rtrn)
{
- return XkbLookupKeySym(dpy,key,mods,mods_rtrn,keysym_rtrn);
+ return XkbLookupKeySym(dpy, key, mods, mods_rtrn, keysym_rtrn);
}
Bool
-XkbLookupKeySym( register Display * dpy,
- KeyCode key,
- register unsigned int mods,
- unsigned int * mods_rtrn,
- KeySym * keysym_rtrn)
+XkbLookupKeySym(register Display *dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int *mods_rtrn,
+ KeySym *keysym_rtrn)
{
if (_XkbUnavailable(dpy))
- return _XTranslateKey(dpy, key, mods, mods_rtrn, keysym_rtrn);
- _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
- return XkbTranslateKeyCode(dpy->xkb_info->desc,key,mods,mods_rtrn,
- keysym_rtrn);
+ return _XTranslateKey(dpy, key, mods, mods_rtrn, keysym_rtrn);
+ _XkbCheckPendingRefresh(dpy, dpy->xkb_info);
+ return XkbTranslateKeyCode(dpy->xkb_info->desc, key, mods, mods_rtrn,
+ keysym_rtrn);
}
Bool
-XkbTranslateKeyCode( register XkbDescPtr xkb,
- KeyCode key,
- register unsigned int mods,
- unsigned int * mods_rtrn,
- KeySym * keysym_rtrn)
+XkbTranslateKeyCode(register XkbDescPtr xkb,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int *mods_rtrn,
+ KeySym *keysym_rtrn)
{
XkbKeyTypeRec *type;
- int col,nKeyGroups;
- unsigned preserve,effectiveGroup;
+ int col, nKeyGroups;
+ unsigned preserve, effectiveGroup;
KeySym *syms;
- if (mods_rtrn!=NULL)
- *mods_rtrn = 0;
+ if (mods_rtrn != NULL)
+ *mods_rtrn = 0;
- nKeyGroups= XkbKeyNumGroups(xkb,key);
- if ((!XkbKeycodeInRange(xkb,key))||(nKeyGroups==0)) {
- if (keysym_rtrn!=NULL)
- *keysym_rtrn = NoSymbol;
- return False;
+ nKeyGroups = XkbKeyNumGroups(xkb, key);
+ if ((!XkbKeycodeInRange(xkb, key)) || (nKeyGroups == 0)) {
+ if (keysym_rtrn != NULL)
+ *keysym_rtrn = NoSymbol;
+ return False;
}
- syms = XkbKeySymsPtr(xkb,key);
+ syms = XkbKeySymsPtr(xkb, key);
/* find the offset of the effective group */
col = 0;
- effectiveGroup= XkbGroupForCoreState(mods);
- if ( effectiveGroup>=nKeyGroups ) {
- unsigned groupInfo= XkbKeyGroupInfo(xkb,key);
- switch (XkbOutOfRangeGroupAction(groupInfo)) {
- default:
- effectiveGroup %= nKeyGroups;
- break;
- case XkbClampIntoRange:
- effectiveGroup = nKeyGroups-1;
- break;
- case XkbRedirectIntoRange:
- effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
- if (effectiveGroup>=nKeyGroups)
- effectiveGroup= 0;
- break;
- }
+ effectiveGroup = XkbGroupForCoreState(mods);
+ if (effectiveGroup >= nKeyGroups) {
+ unsigned groupInfo = XkbKeyGroupInfo(xkb, key);
+
+ switch (XkbOutOfRangeGroupAction(groupInfo)) {
+ default:
+ effectiveGroup %= nKeyGroups;
+ break;
+ case XkbClampIntoRange:
+ effectiveGroup = nKeyGroups - 1;
+ break;
+ case XkbRedirectIntoRange:
+ effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
+ if (effectiveGroup >= nKeyGroups)
+ effectiveGroup = 0;
+ break;
+ }
}
- col= effectiveGroup*XkbKeyGroupsWidth(xkb,key);
- type = XkbKeyKeyType(xkb,key,effectiveGroup);
-
- preserve= 0;
- if (type->map) { /* find the column (shift level) within the group */
- register int i;
- register XkbKTMapEntryPtr entry;
- for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
- if ((entry->active)&&((mods&type->mods.mask)==entry->mods.mask)) {
- col+= entry->level;
- if (type->preserve)
- preserve= type->preserve[i].mask;
- break;
- }
- }
+ col = effectiveGroup * XkbKeyGroupsWidth(xkb, key);
+ type = XkbKeyKeyType(xkb, key, effectiveGroup);
+
+ preserve = 0;
+ if (type->map) { /* find the column (shift level) within the group */
+ register int i;
+ register XkbKTMapEntryPtr entry;
+
+ for (i = 0, entry = type->map; i < type->map_count; i++, entry++) {
+ if ((entry->active) &&
+ ((mods & type->mods.mask) == entry->mods.mask)) {
+ col += entry->level;
+ if (type->preserve)
+ preserve = type->preserve[i].mask;
+ break;
+ }
+ }
}
- if (keysym_rtrn!=NULL)
- *keysym_rtrn= syms[col];
+ if (keysym_rtrn != NULL)
+ *keysym_rtrn = syms[col];
if (mods_rtrn) {
- *mods_rtrn= type->mods.mask&(~preserve);
- /* The Motif VTS doesn't get the help callback called if help
- * is bound to Shift+<whatever>, and it appears as though it
- * is XkbTranslateKeyCode that is causing the problem. The
- * core X version of XTranslateKey always OR's in ShiftMask
- * and LockMask for mods_rtrn, so this "fix" keeps this behavior
- * and solves the VTS problem.
- */
- if ((xkb->dpy)&&(xkb->dpy->xkb_info)&&
- (xkb->dpy->xkb_info->xlib_ctrls&XkbLC_AlwaysConsumeShiftAndLock)) {
- *mods_rtrn|= (ShiftMask|LockMask);
- }
+ *mods_rtrn = type->mods.mask & (~preserve);
+ /* The Motif VTS doesn't get the help callback called if help
+ * is bound to Shift+<whatever>, and it appears as though it
+ * is XkbTranslateKeyCode that is causing the problem. The
+ * core X version of XTranslateKey always OR's in ShiftMask
+ * and LockMask for mods_rtrn, so this "fix" keeps this behavior
+ * and solves the VTS problem.
+ */
+ if ((xkb->dpy) && (xkb->dpy->xkb_info) &&
+ (xkb->dpy->xkb_info->
+ xlib_ctrls & XkbLC_AlwaysConsumeShiftAndLock)) {
+ *mods_rtrn |= (ShiftMask | LockMask);
+ }
}
- return (syms[col]!=NoSymbol);
+ return (syms[col] != NoSymbol);
}
Status
-XkbRefreshKeyboardMapping(register XkbMapNotifyEvent *event)
+XkbRefreshKeyboardMapping(register XkbMapNotifyEvent * event)
{
Display *dpy = event->display;
XkbInfoPtr xkbi;
if (_XkbUnavailable(dpy)) {
- _XRefreshKeyboardMapping((XMappingEvent *)event);
- return Success;
+ _XRefreshKeyboardMapping((XMappingEvent *) event);
+ return Success;
}
- xkbi= dpy->xkb_info;
+ xkbi = dpy->xkb_info;
- if (((event->type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
- return BadMatch;
- if (event->xkb_type==XkbNewKeyboardNotify) {
- _XkbReloadDpy(dpy);
- return Success;
+ if (((event->type & 0x7f) - xkbi->codes->first_event) != XkbEventCode)
+ return BadMatch;
+ if (event->xkb_type == XkbNewKeyboardNotify) {
+ _XkbReloadDpy(dpy);
+ return Success;
}
- if (event->xkb_type==XkbMapNotify) {
- XkbMapChangesRec changes;
- Status rtrn;
-
- if (xkbi->flags&XkbMapPending)
- changes= xkbi->changes;
- else bzero(&changes,sizeof(changes));
- XkbNoteMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
- if ((rtrn=XkbGetMapChanges(dpy,xkbi->desc,&changes))!=Success) {
+ if (event->xkb_type == XkbMapNotify) {
+ XkbMapChangesRec changes;
+ Status rtrn;
+
+ if (xkbi->flags & XkbMapPending)
+ changes = xkbi->changes;
+ else
+ bzero(&changes, sizeof(changes));
+ XkbNoteMapChanges(&changes, event, XKB_XLIB_MAP_MASK);
+ if ((rtrn = XkbGetMapChanges(dpy, xkbi->desc, &changes)) != Success) {
#ifdef DEBUG
- fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
+ fprintf(stderr, "Internal Error! XkbGetMapChanges failed:\n");
#endif
- xkbi->changes= changes;
- }
- else if (xkbi->flags&XkbMapPending) {
- xkbi->flags&= ~XkbMapPending;
- bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
- }
- return rtrn;
+ xkbi->changes = changes;
+ }
+ else if (xkbi->flags & XkbMapPending) {
+ xkbi->flags &= ~XkbMapPending;
+ bzero(&xkbi->changes, sizeof(XkbMapChangesRec));
+ }
+ return rtrn;
}
return BadMatch;
}
int
-XRefreshKeyboardMapping(register XMappingEvent *event)
+XRefreshKeyboardMapping(register XMappingEvent * event)
{
- XkbEvent *xkbevent = (XkbEvent *)event;
+ XkbEvent *xkbevent = (XkbEvent *) event;
Display *dpy = event->display;
XkbMapChangesRec changes;
XkbInfoPtr xkbi;
@@ -392,99 +398,107 @@ XRefreshKeyboardMapping(register XMappingEvent *event)
(void) _XRefreshKeyboardMapping(event);
if (_XkbUnavailable(dpy))
- return 1;
+ return 1;
xkbi = dpy->xkb_info;
- if (((event->type&0x7f)-xkbi->codes->first_event)==XkbEventCode)
- return XkbRefreshKeyboardMapping(&xkbevent->map);
+ if (((event->type & 0x7f) - xkbi->codes->first_event) == XkbEventCode)
+ return XkbRefreshKeyboardMapping(&xkbevent->map);
- if (xkbi->flags&XkbXlibNewKeyboard) {
- _XkbReloadDpy(dpy);
- return 1;
+ if (xkbi->flags & XkbXlibNewKeyboard) {
+ _XkbReloadDpy(dpy);
+ return 1;
}
- if ((xkbi->flags&XkbMapPending)||(event->request==MappingKeyboard)) {
- if (xkbi->flags&XkbMapPending) {
- changes= xkbi->changes;
- _XkbNoteCoreMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
- }
- else {
- bzero(&changes,sizeof(changes));
- changes.changed= XkbKeySymsMask;
- if (xkbi->desc->min_key_code<xkbi->desc->max_key_code) {
- changes.first_key_sym= xkbi->desc->min_key_code;
- changes.num_key_syms= xkbi->desc->max_key_code-
- xkbi->desc->min_key_code+1;
- }
- else {
- changes.first_key_sym= event->first_keycode;
- changes.num_key_syms= event->count;
- }
- }
-
- if (XkbGetMapChanges(dpy,xkbi->desc, &changes)!=Success) {
+ if ((xkbi->flags & XkbMapPending) || (event->request == MappingKeyboard)) {
+ if (xkbi->flags & XkbMapPending) {
+ changes = xkbi->changes;
+ _XkbNoteCoreMapChanges(&changes, event, XKB_XLIB_MAP_MASK);
+ }
+ else {
+ bzero(&changes, sizeof(changes));
+ changes.changed = XkbKeySymsMask;
+ if (xkbi->desc->min_key_code < xkbi->desc->max_key_code) {
+ changes.first_key_sym = xkbi->desc->min_key_code;
+ changes.num_key_syms = xkbi->desc->max_key_code -
+ xkbi->desc->min_key_code + 1;
+ }
+ else {
+ changes.first_key_sym = event->first_keycode;
+ changes.num_key_syms = event->count;
+ }
+ }
+
+ if (XkbGetMapChanges(dpy, xkbi->desc, &changes) != Success) {
#ifdef DEBUG
- fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
- if (changes.changed&XkbKeyTypesMask) {
- int first= changes.first_type;
- int last= changes.first_type+changes.num_types-1;
- fprintf(stderr," types: %d..%d\n",first,last);
- }
- if (changes.changed&XkbKeySymsMask) {
- int first= changes.first_key_sym;
- int last= changes.first_key_sym+changes.num_key_syms-1;
- fprintf(stderr," symbols: %d..%d\n",first,last);
- }
- if (changes.changed&XkbKeyActionsMask) {
- int last,first= changes.first_key_act;
- last= changes.first_key_act+changes.num_key_acts-1;
- fprintf(stderr," acts: %d..%d\n",first,last);
- }
- if (changes.changed&XkbKeyBehaviorsMask) {
- int last,first= changes.first_key_behavior;
- last= first+changes.num_key_behaviors-1;
- fprintf(stderr," behaviors: %d..%d\n",first,last);
- }
- if (changes.changed&XkbVirtualModsMask) {
- fprintf(stderr,"virtual mods: 0x%04x\n",
- changes.vmods);
- }
- if (changes.changed&XkbExplicitComponentsMask) {
- int last,first= changes.first_key_explicit;
- last= first+changes.num_key_explicit-1;
- fprintf(stderr," explicit: %d..%d\n",first,last);
- }
+ fprintf(stderr, "Internal Error! XkbGetMapChanges failed:\n");
+ if (changes.changed & XkbKeyTypesMask) {
+ int first = changes.first_type;
+ int last = changes.first_type + changes.num_types - 1;
+
+ fprintf(stderr, " types: %d..%d\n", first, last);
+ }
+ if (changes.changed & XkbKeySymsMask) {
+ int first = changes.first_key_sym;
+ int last = changes.first_key_sym + changes.num_key_syms - 1;
+
+ fprintf(stderr, " symbols: %d..%d\n", first, last);
+ }
+ if (changes.changed & XkbKeyActionsMask) {
+ int first = changes.first_key_act;
+ int last = changes.first_key_act + changes.num_key_acts - 1;
+
+ fprintf(stderr, " acts: %d..%d\n", first, last);
+ }
+ if (changes.changed & XkbKeyBehaviorsMask) {
+ int first = changes.first_key_behavior;
+ int last = first + changes.num_key_behaviors - 1;
+
+ fprintf(stderr, " behaviors: %d..%d\n", first, last);
+ }
+ if (changes.changed & XkbVirtualModsMask) {
+ fprintf(stderr, "virtual mods: 0x%04x\n", changes.vmods);
+ }
+ if (changes.changed & XkbExplicitComponentsMask) {
+ int first = changes.first_key_explicit;
+ int last = first + changes.num_key_explicit - 1;
+
+ fprintf(stderr, " explicit: %d..%d\n", first, last);
+ }
#endif
- }
- LockDisplay(dpy);
- if (xkbi->flags&XkbMapPending) {
- xkbi->flags&= ~XkbMapPending;
- bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
- }
- UnlockDisplay(dpy);
+ }
+ LockDisplay(dpy);
+ if (xkbi->flags & XkbMapPending) {
+ xkbi->flags &= ~XkbMapPending;
+ bzero(&xkbi->changes, sizeof(XkbMapChangesRec));
+ }
+ UnlockDisplay(dpy);
}
- if (event->request==MappingModifier) {
- LockDisplay(dpy);
- if (xkbi->desc->map->modmap) {
- _XkbFree(xkbi->desc->map->modmap);
- xkbi->desc->map->modmap= NULL;
- }
- if (dpy->key_bindings) {
- register struct _XKeytrans *p;
- for (p = dpy->key_bindings; p; p = p->next) {
- register int i;
- p->state= 0;
- if (p->mlen>0) {
- for (i = 0; i < p->mlen; i++) {
- p->state|= XkbKeysymToModifiers(dpy,p->modifiers[i]);
- }
- if (p->state) p->state &= AllMods;
- else p->state = AnyModifier;
- }
- }
- }
- UnlockDisplay(dpy);
+ if (event->request == MappingModifier) {
+ LockDisplay(dpy);
+ if (xkbi->desc->map->modmap) {
+ _XkbFree(xkbi->desc->map->modmap);
+ xkbi->desc->map->modmap = NULL;
+ }
+ if (dpy->key_bindings) {
+ register struct _XKeytrans *p;
+
+ for (p = dpy->key_bindings; p; p = p->next) {
+ register int i;
+
+ p->state = 0;
+ if (p->mlen > 0) {
+ for (i = 0; i < p->mlen; i++) {
+ p->state |= XkbKeysymToModifiers(dpy, p->modifiers[i]);
+ }
+ if (p->state)
+ p->state &= AllMods;
+ else
+ p->state = AnyModifier;
+ }
+ }
+ }
+ UnlockDisplay(dpy);
}
return 1;
}
@@ -493,35 +507,36 @@ static int
_XkbLoadDpy(Display *dpy)
{
XkbInfoPtr xkbi;
- unsigned query,oldEvents;
+ unsigned query, oldEvents;
XkbDescRec *desc;
- if (!XkbUseExtension(dpy,NULL,NULL))
- return 0;
+ if (!XkbUseExtension(dpy, NULL, NULL))
+ return 0;
xkbi = dpy->xkb_info;
query = XkbAllClientInfoMask;
- desc = XkbGetMap(dpy,query,XkbUseCoreKbd);
+ desc = XkbGetMap(dpy, query, XkbUseCoreKbd);
if (!desc) {
#ifdef DEBUG
- fprintf(stderr,"Warning! XkbGetMap failed!\n");
+ fprintf(stderr, "Warning! XkbGetMap failed!\n");
#endif
- return 0;
+ return 0;
}
LockDisplay(dpy);
xkbi->desc = desc;
UnlockDisplay(dpy);
- oldEvents= xkbi->selected_events;
- if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
- XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbNewKeyboardNotify,
- XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask,
- XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask);
+ oldEvents = xkbi->selected_events;
+ if (!(xkbi->xlib_ctrls & XkbLC_IgnoreNewKeyboards)) {
+ XkbSelectEventDetails(dpy, xkbi->desc->device_spec,
+ XkbNewKeyboardNotify,
+ XkbNKN_KeycodesMask | XkbNKN_DeviceIDMask,
+ XkbNKN_KeycodesMask | XkbNKN_DeviceIDMask);
}
- XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
- XkbAllClientInfoMask,XkbAllClientInfoMask);
+ XkbSelectEventDetails(dpy, xkbi->desc->device_spec, XkbMapNotify,
+ XkbAllClientInfoMask, XkbAllClientInfoMask);
LockDisplay(dpy);
- xkbi->selected_events= oldEvents;
+ xkbi->selected_events = oldEvents;
UnlockDisplay(dpy);
return 1;
}
@@ -531,318 +546,239 @@ _XkbReloadDpy(Display *dpy)
{
XkbInfoPtr xkbi;
XkbDescRec *desc;
- unsigned oldDeviceID;
+ unsigned oldDeviceID;
if (_XkbUnavailable(dpy))
- return;
+ return;
xkbi = dpy->xkb_info;
LockDisplay(dpy);
if (xkbi->desc) {
- oldDeviceID= xkbi->desc->device_spec;
- XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
- xkbi->desc= NULL;
- xkbi->flags&= ~(XkbMapPending|XkbXlibNewKeyboard);
- xkbi->changes.changed= 0;
+ oldDeviceID = xkbi->desc->device_spec;
+ XkbFreeKeyboard(xkbi->desc, XkbAllComponentsMask, True);
+ xkbi->desc = NULL;
+ xkbi->flags &= ~(XkbMapPending | XkbXlibNewKeyboard);
+ xkbi->changes.changed = 0;
}
- else oldDeviceID= XkbUseCoreKbd;
+ else
+ oldDeviceID = XkbUseCoreKbd;
UnlockDisplay(dpy);
- desc = XkbGetMap(dpy,XkbAllClientInfoMask,XkbUseCoreKbd);
+ desc = XkbGetMap(dpy, XkbAllClientInfoMask, XkbUseCoreKbd);
if (!desc)
- return;
+ return;
LockDisplay(dpy);
xkbi->desc = desc;
UnlockDisplay(dpy);
- if (desc->device_spec!=oldDeviceID) {
- /* transfer(?) event masks here */
+ if (desc->device_spec != oldDeviceID) {
+ /* transfer(?) event masks here */
#ifdef NOTYET
- unsigned oldEvents;
- oldEvents= xkbi->selected_events;
- XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
- XkbAllMapComponentsMask,XkbAllClientInfoMask);
- LockDisplay(dpy);
- xkbi->selected_events= oldEvents;
- UnlockDisplay(dpy);
+ unsigned oldEvents;
+
+ oldEvents = xkbi->selected_events;
+ XkbSelectEventDetails(dpy, xkbi->desc->device_spec, XkbMapNotify,
+ XkbAllMapComponentsMask, XkbAllClientInfoMask);
+ LockDisplay(dpy);
+ xkbi->selected_events = oldEvents;
+ UnlockDisplay(dpy);
#endif
}
return;
}
int
-XkbTranslateKeySym( register Display * dpy,
- register KeySym * sym_rtrn,
- unsigned int mods,
- char * buffer,
- int nbytes,
- int * extra_rtrn)
+XkbTranslateKeySym(register Display *dpy,
+ register KeySym *sym_rtrn,
+ unsigned int mods,
+ char *buffer,
+ int nbytes,
+ int *extra_rtrn)
{
- register XkbInfoPtr xkb;
+ register XkbInfoPtr xkb;
XkbKSToMBFunc cvtr;
XPointer priv;
char tmp[4];
int n;
- xkb= dpy->xkb_info;
+ xkb = dpy->xkb_info;
if (!xkb->cvt.KSToMB) {
- _XkbGetConverters(_XkbGetCharset(),&xkb->cvt);
- _XkbGetConverters("ISO8859-1",&xkb->latin1cvt);
+ _XkbGetConverters(_XkbGetCharset(), &xkb->cvt);
+ _XkbGetConverters("ISO8859-1", &xkb->latin1cvt);
}
if (extra_rtrn)
- *extra_rtrn= 0;
+ *extra_rtrn = 0;
- if ((buffer==NULL)||(nbytes==0)) {
- buffer= tmp;
- nbytes= 4;
+ if ((buffer == NULL) || (nbytes == 0)) {
+ buffer = tmp;
+ nbytes = 4;
}
/* see if symbol rebound, if so, return that string. */
- n = XkbLookupKeyBinding(dpy,*sym_rtrn,mods,buffer,nbytes,extra_rtrn);
+ n = XkbLookupKeyBinding(dpy, *sym_rtrn, mods, buffer, nbytes, extra_rtrn);
if (n)
return n;
- if ( nbytes>0 )
- buffer[0]= '\0';
+ if (nbytes > 0)
+ buffer[0] = '\0';
- if ( xkb->cvt.KSToUpper && (mods&LockMask) ) {
- *sym_rtrn = (*xkb->cvt.KSToUpper)(*sym_rtrn);
+ if (xkb->cvt.KSToUpper && (mods & LockMask)) {
+ *sym_rtrn = (*xkb->cvt.KSToUpper) (*sym_rtrn);
}
if (xkb->xlib_ctrls & XkbLC_ForceLatin1Lookup) {
- cvtr = xkb->latin1cvt.KSToMB;
- priv = xkb->latin1cvt.KSToMBPriv;
- } else {
- cvtr = xkb->cvt.KSToMB;
- priv = xkb->cvt.KSToMBPriv;
+ cvtr = xkb->latin1cvt.KSToMB;
+ priv = xkb->latin1cvt.KSToMBPriv;
}
+ else {
+ cvtr = xkb->cvt.KSToMB;
+ priv = xkb->cvt.KSToMBPriv;
+ }
+
+ n = (*cvtr) (priv, *sym_rtrn, buffer, nbytes, extra_rtrn);
- n = (*cvtr)(priv,*sym_rtrn,buffer,nbytes,extra_rtrn);
-
- if ((!xkb->cvt.KSToUpper)&&( mods&LockMask )) {
- register int i;
- int change;
- char ch;
- for (i=change=0;i<n;i++) {
- ch= toupper(buffer[i]);
- change= (change||(buffer[i]!=ch));
- buffer[i] = ch;
- }
- if (change) {
- if (n==1)
- *sym_rtrn=(*xkb->cvt.MBToKS)(xkb->cvt.MBToKSPriv,buffer,n,NULL);
- else *sym_rtrn= NoSymbol;
- }
+ if ((!xkb->cvt.KSToUpper) && (mods & LockMask)) {
+ register int i;
+ int change;
+
+ for (i = change = 0; i < n; i++) {
+ char ch = toupper(buffer[i]);
+ change = (change || (buffer[i] != ch));
+ buffer[i] = ch;
+ }
+ if (change) {
+ if (n == 1)
+ *sym_rtrn =
+ (*xkb->cvt.MBToKS) (xkb->cvt.MBToKSPriv, buffer, n, NULL);
+ else
+ *sym_rtrn = NoSymbol;
+ }
}
- if ( mods&ControlMask ) {
- if ( n==1 ) {
- buffer[0]= XkbToControl(buffer[0]);
- if ( nbytes>1 )
- buffer[1]= '\0';
- return 1;
- }
- if ( nbytes > 0 )
- buffer[0]= '\0';
- return 0;
+ if (mods & ControlMask) {
+ if (n == 1) {
+ buffer[0] = XkbToControl(buffer[0]);
+ if (nbytes > 1)
+ buffer[1] = '\0';
+ return 1;
+ }
+ if (nbytes > 0)
+ buffer[0] = '\0';
+ return 0;
}
return n;
}
int
-XLookupString ( register XKeyEvent * event,
- char * buffer,
- int nbytes,
- KeySym * keysym,
- XComposeStatus * status)
+XLookupString(register XKeyEvent *event,
+ char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status)
{
- KeySym dummy;
+ KeySym dummy;
int rtrnLen;
unsigned int new_mods;
Display *dpy = event->display;
- if (keysym==NULL)
- keysym= &dummy;
- if (!XkbLookupKeySym(dpy,event->keycode,event->state, &new_mods,keysym))
- return 0;
- new_mods= (event->state&(~new_mods));
+ if (keysym == NULL)
+ keysym = &dummy;
+ if (!XkbLookupKeySym(dpy, event->keycode, event->state, &new_mods, keysym))
+ return 0;
+ new_mods = (event->state & (~new_mods));
/* find the group where a symbol can be converted to control one */
- if (new_mods&ControlMask && *keysym > 0x7F &&
- (dpy->xkb_info->xlib_ctrls & XkbLC_ControlFallback)) {
- XKeyEvent tmp_ev = *event;
- KeySym tmp_keysym;
- unsigned int tmp_new_mods;
- if (_XkbUnavailable(dpy)) {
- tmp_ev.state= event->state ^ dpy->mode_switch;
+ if (new_mods & ControlMask && *keysym > 0x7F &&
+ (dpy->xkb_info->xlib_ctrls & XkbLC_ControlFallback)) {
+ XKeyEvent tmp_ev = *event;
+ KeySym tmp_keysym;
+ unsigned int tmp_new_mods;
+
+ if (_XkbUnavailable(dpy)) {
+ tmp_ev.state = event->state ^ dpy->mode_switch;
if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
&tmp_new_mods, &tmp_keysym) &&
- tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+ tmp_keysym != NoSymbol && tmp_keysym < 0x80) {
*keysym = tmp_keysym;
}
- } else {
+ }
+ else {
int n = XkbKeyNumGroups(dpy->xkb_info->desc, tmp_ev.keycode);
int i;
+
for (i = 0; i < n; i++) {
if (XkbGroupForCoreState(event->state) == i)
continue;
- tmp_ev.state= XkbBuildCoreState(tmp_ev.state, i);
+ tmp_ev.state = XkbBuildCoreState(tmp_ev.state, i);
if (XkbLookupKeySym(dpy, tmp_ev.keycode, tmp_ev.state,
- &tmp_new_mods, &tmp_keysym) &&
- tmp_keysym != NoSymbol && tmp_keysym < 0x80 ) {
+ &tmp_new_mods, &tmp_keysym) &&
+ tmp_keysym != NoSymbol && tmp_keysym < 0x80) {
*keysym = tmp_keysym;
- new_mods= (event->state&(~tmp_new_mods));
+ new_mods = (event->state & (~tmp_new_mods));
break;
}
}
}
}
-#ifdef USE_OWN_COMPOSE
- if ( status ) {
- static int been_here= 0;
- if ( !been_here ) {
- XimCompInitTables();
- been_here = 1;
- }
- if ( !XimCompLegalStatus(status) ) {
- status->compose_ptr = NULL;
- status->chars_matched = 0;
- }
- if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
- XimCompIsComposeKey(*keysym,event->keycode,status) ) {
- XimCompRtrn rtrn;
-
- switch (XimCompProcessSym(status,*keysym,&rtrn)) {
- case XIM_COMP_IGNORE:
- break;
- case XIM_COMP_IN_PROGRESS:
- if ( keysym!=NULL )
- *keysym = NoSymbol;
-#ifndef NO_COMPOSE_LED
- if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
- XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
- True,True,False,NULL);
- }
-#endif
- return 0;
- case XIM_COMP_FAIL:
- {
- static Atom _ComposeFail= None;
- int n = 0, len= 0;
-#ifndef NO_COMPOSE_LED
- if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
- XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
- True,False,False,NULL);
- }
-#endif
-#ifndef NO_BELL_ON_COMPOSE_FAIL
- if (dpy->xkb_info->xlib_ctrls&XkbLC_BeepOnComposeFail) {
- if (_ComposeFail==None)
- _ComposeFail= XInternAtom(dpy,"ComposeFail",0);
- XkbBell(dpy,event->window,0,_ComposeFail);
- }
-#endif
- for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
- if ( nbytes-len > 0 ) {
- len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],new_mods,
- buffer+len,nbytes-len,
- NULL);
- }
- }
- if ( keysym!=NULL ) {
- if ( n==1 ) *keysym = rtrn.sym[0];
- else *keysym = NoSymbol;
- }
- return len;
- }
- case XIM_COMP_SUCCEED:
- {
- int len,n = 0;
-
-#ifndef NO_COMPOSE_LED
- if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
- XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
- True,False,False,NULL);
- }
-#endif
- *keysym = rtrn.matchSym;
- if ( rtrn.str[0]!='\0' ) {
- strncpy(buffer,rtrn.str,nbytes-1);
- buffer[nbytes-1]= '\0';
- len = (int)strlen(buffer);
- }
- else {
- len = XkbTranslateKeySym(dpy,keysym,new_mods,
- buffer,nbytes,
- NULL);
- }
- for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
- if ( nbytes-len > 0 ) {
- len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],
- event->state,
- buffer+len,nbytes-len,
- NULL);
- }
- }
- return len;
- }
- }
- }
- }
-#endif
-
/* We *should* use the new_mods (which does not contain any modifiers */
/* that were used to compute the symbol here, but pre-XKB XLookupString */
/* did not and we have to remain compatible. Sigh. */
if (_XkbUnavailable(dpy) ||
- (dpy->xkb_info->xlib_ctrls&XkbLC_ConsumeLookupMods)==0)
- new_mods= event->state;
+ (dpy->xkb_info->xlib_ctrls & XkbLC_ConsumeLookupMods) == 0)
+ new_mods = event->state;
- rtrnLen= XkbLookupKeyBinding(dpy,*keysym,new_mods,buffer,nbytes,NULL);
- if (rtrnLen>0)
- return rtrnLen;
+ rtrnLen = XkbLookupKeyBinding(dpy, *keysym, new_mods, buffer, nbytes, NULL);
+ if (rtrnLen > 0)
+ return rtrnLen;
- return XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
+ return XkbTranslateKeySym(dpy, keysym, new_mods, buffer, nbytes, NULL);
}
int
-XkbLookupKeyBinding( Display * dpy,
- register KeySym sym,
- unsigned int mods,
- char * buffer,
- int nbytes,
- int * extra_rtrn)
+XkbLookupKeyBinding(Display *dpy,
+ register KeySym sym,
+ unsigned int mods,
+ char *buffer,
+ int nbytes,
+ int *extra_rtrn)
{
register struct _XKeytrans *p;
if (extra_rtrn)
- *extra_rtrn= 0;
+ *extra_rtrn = 0;
for (p = dpy->key_bindings; p; p = p->next) {
- if (((mods & AllMods) == p->state) && (sym == p->key)) {
- int tmp = p->len;
- if (tmp > nbytes) {
- if (extra_rtrn)
- *extra_rtrn= (tmp-nbytes);
- tmp = nbytes;
- }
- memcpy (buffer, p->string, tmp);
- if (tmp < nbytes) buffer[tmp]= '\0';
- return tmp;
- }
+ if (((mods & AllMods) == p->state) && (sym == p->key)) {
+ int tmp = p->len;
+
+ if (tmp > nbytes) {
+ if (extra_rtrn)
+ *extra_rtrn = (tmp - nbytes);
+ tmp = nbytes;
+ }
+ memcpy(buffer, p->string, tmp);
+ if (tmp < nbytes)
+ buffer[tmp] = '\0';
+ return tmp;
+ }
}
return 0;
}
char
-XkbToControl( char ch )
+XkbToControl(char ch)
{
register char c = ch;
- if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
- else if (c == '2') c = '\000';
- else if (c >= '3' && c <= '7') c -= ('3' - '\033');
- else if (c == '8') c = '\177';
- else if (c == '/') c = '_' & 0x1F;
+ if ((c >= '@' && c < '\177') || c == ' ')
+ c &= 0x1F;
+ else if (c == '2')
+ c = '\000';
+ else if (c >= '3' && c <= '7')
+ c -= ('3' - '\033');
+ else if (c == '8')
+ c = '\177';
+ else if (c == '/')
+ c = '_' & 0x1F;
return c;
}
diff --git a/nx-X11/lib/X11/XKBCompat.c b/nx-X11/lib/X11/XKBCompat.c
index 35359522c..a5222b56e 100644
--- a/nx-X11/lib/X11/XKBCompat.c
+++ b/nx-X11/lib/X11/XKBCompat.c
@@ -34,191 +34,196 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "XKBlibint.h"
Status
-_XkbReadGetCompatMapReply( Display * dpy,
- xkbGetCompatMapReply * rep,
- XkbDescPtr xkb,
- int * nread_rtrn)
+_XkbReadGetCompatMapReply(Display *dpy,
+ xkbGetCompatMapReply *rep,
+ XkbDescPtr xkb,
+ int *nread_rtrn)
{
-register int i;
-XkbReadBufferRec buf;
+ register int i;
+ XkbReadBufferRec buf;
- if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
- return BadAlloc;
+ if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4))
+ return BadAlloc;
if (nread_rtrn)
- *nread_rtrn= (int)rep->length*4;
-
- i= rep->firstSI+rep->nSI;
- if ((!xkb->compat)&&
- (XkbAllocCompatMap(xkb,XkbAllCompatMask,i)!=Success))
- return BadAlloc;
-
- if (rep->nSI!=0) {
- XkbSymInterpretRec *syms;
- xkbSymInterpretWireDesc *wire;
-
- wire= (xkbSymInterpretWireDesc *)_XkbGetReadBufferPtr(&buf,
- rep->nSI*SIZEOF(xkbSymInterpretWireDesc));
- if (wire==NULL)
- goto BAILOUT;
- syms= &xkb->compat->sym_interpret[rep->firstSI];
-
- for (i=0;i<rep->nSI;i++,syms++,wire++) {
- syms->sym= wire->sym;
- syms->mods= wire->mods;
- syms->match= wire->match;
- syms->virtual_mod= wire->virtualMod;
- syms->flags= wire->flags;
- syms->act= *((XkbAnyAction *)&wire->act);
- }
- xkb->compat->num_si+= rep->nSI;
+ *nread_rtrn = (int) rep->length * 4;
+
+ i = rep->firstSI + rep->nSI;
+ if ((!xkb->compat) &&
+ (XkbAllocCompatMap(xkb, XkbAllCompatMask, i) != Success))
+ return BadAlloc;
+
+ if (rep->nSI != 0) {
+ XkbSymInterpretRec *syms;
+ xkbSymInterpretWireDesc *wire;
+
+ wire = (xkbSymInterpretWireDesc *) _XkbGetReadBufferPtr(&buf,
+ rep->nSI * SIZEOF (xkbSymInterpretWireDesc));
+ if (wire == NULL)
+ goto BAILOUT;
+ syms = &xkb->compat->sym_interpret[rep->firstSI];
+
+ for (i = 0; i < rep->nSI; i++, syms++, wire++) {
+ syms->sym = wire->sym;
+ syms->mods = wire->mods;
+ syms->match = wire->match;
+ syms->virtual_mod = wire->virtualMod;
+ syms->flags = wire->flags;
+ syms->act = *((XkbAnyAction *) &wire->act);
+ }
+ xkb->compat->num_si += rep->nSI;
}
- if (rep->groups&XkbAllGroupsMask) {
- register unsigned bit,nGroups;
- xkbModsWireDesc * wire;
- for (i=0,nGroups=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
- if (rep->groups&bit)
- nGroups++;
- }
- wire= (xkbModsWireDesc *)_XkbGetReadBufferPtr(&buf,
- nGroups*SIZEOF(xkbModsWireDesc));
- if (wire==NULL)
- goto BAILOUT;
- for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
- if ((rep->groups&bit)==0)
- continue;
- xkb->compat->groups[i].mask= wire->mask;
- xkb->compat->groups[i].real_mods= wire->realMods;
- xkb->compat->groups[i].vmods= wire->virtualMods;
- wire++;
- }
+ if (rep->groups & XkbAllGroupsMask) {
+ register unsigned bit, nGroups;
+ xkbModsWireDesc *wire;
+
+ for (i = 0, nGroups = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
+ if (rep->groups & bit)
+ nGroups++;
+ }
+ wire = (xkbModsWireDesc *)
+ _XkbGetReadBufferPtr(&buf, nGroups * SIZEOF(xkbModsWireDesc));
+ if (wire == NULL)
+ goto BAILOUT;
+ for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
+ if ((rep->groups & bit) == 0)
+ continue;
+ xkb->compat->groups[i].mask = wire->mask;
+ xkb->compat->groups[i].real_mods = wire->realMods;
+ xkb->compat->groups[i].vmods = wire->virtualMods;
+ wire++;
+ }
}
- i= _XkbFreeReadBuffer(&buf);
+ i = _XkbFreeReadBuffer(&buf);
if (i)
- fprintf(stderr,"CompatMapReply! Bad length (%d extra bytes)\n",i);
+ fprintf(stderr, "CompatMapReply! Bad length (%d extra bytes)\n", i);
if (i || buf.error)
- return BadLength;
+ return BadLength;
return Success;
-BAILOUT:
+ BAILOUT:
_XkbFreeReadBuffer(&buf);
return BadLength;
}
Status
-XkbGetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+XkbGetCompatMap(Display *dpy, unsigned which, XkbDescPtr xkb)
{
register xkbGetCompatMapReq *req;
- xkbGetCompatMapReply rep;
- Status status;
+ xkbGetCompatMapReply rep;
+ Status status;
XkbInfoPtr xkbi;
- if ( (!dpy) || (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
- ((xkb->dpy!=NULL)&&(xkb->dpy!=dpy)) ||
- (!dpy->xkb_info && (!XkbUseExtension(dpy,NULL,NULL))))
- return BadAccess;
+ if ((!dpy) || (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ ((xkb->dpy != NULL) && (xkb->dpy != dpy)) ||
+ (!dpy->xkb_info && (!XkbUseExtension(dpy, NULL, NULL))))
+ return BadAccess;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetCompatMap, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetCompatMap;
req->deviceSpec = xkb->device_spec;
- if (which&XkbSymInterpMask)
- req->getAllSI= True;
- else req->getAllSI= False;
- req->firstSI= req->nSI= 0;
-
- if (which&XkbGroupCompatMask)
- req->groups= XkbAllGroupsMask;
- else req->groups= 0;
-
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadLength;
+ if (which & XkbSymInterpMask)
+ req->getAllSI = True;
+ else
+ req->getAllSI = False;
+ req->firstSI = req->nSI = 0;
+
+ if (which & XkbGroupCompatMask)
+ req->groups = XkbAllGroupsMask;
+ else
+ req->groups = 0;
+
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
}
- if (xkb->dpy==NULL)
- xkb->dpy= dpy;
- if (xkb->device_spec==XkbUseCoreKbd)
- xkb->device_spec= rep.deviceID;
+ if (xkb->dpy == NULL)
+ xkb->dpy = dpy;
+ if (xkb->device_spec == XkbUseCoreKbd)
+ xkb->device_spec = rep.deviceID;
- status = _XkbReadGetCompatMapReply(dpy,&rep,xkb,NULL);
+ status = _XkbReadGetCompatMapReply(dpy, &rep, xkb, NULL);
UnlockDisplay(dpy);
SyncHandle();
return status;
}
static Bool
-_XkbWriteSetCompatMap(Display *dpy,xkbSetCompatMapReq *req,XkbDescPtr xkb)
+_XkbWriteSetCompatMap(Display *dpy, xkbSetCompatMapReq *req, XkbDescPtr xkb)
{
-CARD16 firstSI;
-CARD16 nSI;
-int size;
-register int i,nGroups;
-register unsigned bit;
-unsigned groups;
-char * buf;
+ CARD16 firstSI;
+ CARD16 nSI;
+ int size;
+ register int i, nGroups;
+ register unsigned bit;
+ unsigned groups;
+ char *buf;
firstSI = req->firstSI;
nSI = req->nSI;
- size= nSI*SIZEOF(xkbSymInterpretWireDesc);
- nGroups= 0;
- groups= req->groups;
- if (groups&XkbAllGroupsMask) {
- for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
- if (groups&bit)
- nGroups++;
- }
- size+= SIZEOF(xkbModsWireDesc)*nGroups;
+ size = nSI * SIZEOF(xkbSymInterpretWireDesc);
+ nGroups = 0;
+ groups = req->groups;
+ if (groups & XkbAllGroupsMask) {
+ for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
+ if (groups & bit)
+ nGroups++;
+ }
+ size += SIZEOF(xkbModsWireDesc) * nGroups;
}
- req->length+= size/4;
- BufAlloc(char *,buf,size);
+ req->length += size / 4;
+ BufAlloc(char *, buf, size);
+
if (!buf)
- return False;
+ return False;
if (nSI) {
- XkbSymInterpretPtr sym= &xkb->compat->sym_interpret[firstSI];
- xkbSymInterpretWireDesc *wire= (xkbSymInterpretWireDesc *)buf;
- for (i=0;i<nSI;i++,wire++,sym++) {
- wire->sym= (CARD32)sym->sym;
- wire->mods= sym->mods;
- wire->match= sym->match;
- wire->flags= sym->flags;
- wire->virtualMod= sym->virtual_mod;
- memcpy(&wire->act,&sym->act,sz_xkbActionWireDesc);
- }
- buf+= nSI*SIZEOF(xkbSymInterpretWireDesc);
+ XkbSymInterpretPtr sym = &xkb->compat->sym_interpret[firstSI];
+ xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) buf;
+
+ for (i = 0; i < nSI; i++, wire++, sym++) {
+ wire->sym = (CARD32) sym->sym;
+ wire->mods = sym->mods;
+ wire->match = sym->match;
+ wire->flags = sym->flags;
+ wire->virtualMod = sym->virtual_mod;
+ memcpy(&wire->act, &sym->act, sz_xkbActionWireDesc);
+ }
+ buf += nSI * SIZEOF(xkbSymInterpretWireDesc);
}
- if (groups&XkbAllGroupsMask) {
- xkbModsWireDesc * out;
-
- out= (xkbModsWireDesc *)buf;
- for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
- if ((groups&bit)!=0) {
- out->mask= xkb->compat->groups[i].mask;
- out->realMods= xkb->compat->groups[i].real_mods;
- out->virtualMods= xkb->compat->groups[i].vmods;
- out++;
- }
- }
- buf+= nGroups*SIZEOF(xkbModsWireDesc);
+ if (groups & XkbAllGroupsMask) {
+ xkbModsWireDesc *out = (xkbModsWireDesc *) buf;
+
+ for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) {
+ if ((groups & bit) != 0) {
+ out->mask = xkb->compat->groups[i].mask;
+ out->realMods = xkb->compat->groups[i].real_mods;
+ out->virtualMods = xkb->compat->groups[i].vmods;
+ out++;
+ }
+ }
+ buf += nGroups * SIZEOF(xkbModsWireDesc);
}
return True;
}
Bool
-XkbSetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb,Bool updateActions)
+XkbSetCompatMap(Display *dpy, unsigned which, XkbDescPtr xkb,
+ Bool updateActions)
{
register xkbSetCompatMapReq *req;
- Status ok;
+ Status ok;
XkbInfoPtr xkbi;
- if ((dpy->flags & XlibDisplayNoXkb) || (dpy!=xkb->dpy) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ if ((dpy->flags & XlibDisplayNoXkb) || (dpy != xkb->dpy) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
if ((!xkb->compat) ||
- ((which&XkbSymInterpMask)&&(!xkb->compat->sym_interpret)))
- return False;
+ ((which & XkbSymInterpMask) && (!xkb->compat->sym_interpret)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetCompatMap, req);
@@ -226,22 +231,22 @@ XkbSetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb,Bool updateActions)
req->xkbReqType = X_kbSetCompatMap;
req->deviceSpec = xkb->device_spec;
req->recomputeActions = updateActions;
- if (which&XkbSymInterpMask) {
- req->truncateSI = True;
- req->firstSI= 0;
- req->nSI= xkb->compat->num_si;
+ if (which & XkbSymInterpMask) {
+ req->truncateSI = True;
+ req->firstSI = 0;
+ req->nSI = xkb->compat->num_si;
}
else {
- req->truncateSI = False;
- req->firstSI= 0;
- req->nSI= 0;
+ req->truncateSI = False;
+ req->firstSI = 0;
+ req->nSI = 0;
}
- if (which&XkbGroupCompatMask)
- req->groups= XkbAllGroupsMask;
- else req->groups= 0;
- ok= _XkbWriteSetCompatMap(dpy,req,xkb);
+ if (which & XkbGroupCompatMask)
+ req->groups = XkbAllGroupsMask;
+ else
+ req->groups = 0;
+ ok = _XkbWriteSetCompatMap(dpy, req, xkb);
UnlockDisplay(dpy);
SyncHandle();
return ok;
}
-
diff --git a/nx-X11/lib/X11/XKBCtrls.c b/nx-X11/lib/X11/XKBCtrls.c
index 198953d79..2e8546d92 100644
--- a/nx-X11/lib/X11/XKBCtrls.c
+++ b/nx-X11/lib/X11/XKBCtrls.c
@@ -34,32 +34,32 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
static xkbSetControlsReq *
-_XkbGetSetControlsReq(Display *dpy,XkbInfoPtr xkbi,unsigned int deviceSpec)
+_XkbGetSetControlsReq(Display *dpy, XkbInfoPtr xkbi, unsigned int deviceSpec)
{
-xkbSetControlsReq *req;
+ xkbSetControlsReq *req;
- GetReq(kbSetControls,req);
- bzero(req,SIZEOF(xkbSetControlsReq));
+ GetReq(kbSetControls, req);
+ bzero(req, SIZEOF(xkbSetControlsReq));
req->reqType = xkbi->codes->major_opcode;
- req->length = (SIZEOF(xkbSetControlsReq)>>2);
+ req->length = (SIZEOF(xkbSetControlsReq) >> 2);
req->xkbReqType = X_kbSetControls;
req->deviceSpec = deviceSpec;
return req;
}
Bool
-XkbSetAutoRepeatRate( Display *dpy,
- unsigned int deviceSpec,
- unsigned int timeout,
- unsigned int interval)
+XkbSetAutoRepeatRate(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int timeout,
+ unsigned int interval)
{
register xkbSetControlsReq *req;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
- req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req = _XkbGetSetControlsReq(dpy, dpy->xkb_info, deviceSpec);
req->changeCtrls = XkbRepeatKeysMask;
req->repeatDelay = timeout;
req->repeatInterval = interval;
@@ -69,29 +69,29 @@ XkbSetAutoRepeatRate( Display *dpy,
}
Bool
-XkbGetAutoRepeatRate( Display * dpy,
- unsigned int deviceSpec,
- unsigned int * timeoutp,
- unsigned int * intervalp)
+XkbGetAutoRepeatRate(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int *timeoutp,
+ unsigned int *intervalp)
{
register xkbGetControlsReq *req;
xkbGetControlsReply rep;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetControls, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetControls;
req->deviceSpec = deviceSpec;
- if (!_XReply(dpy, (xReply *)&rep,
- (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ if (!_XReply(dpy, (xReply *) &rep,
+ (SIZEOF(xkbGetControlsReply) - SIZEOF(xReply)) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
@@ -101,24 +101,24 @@ XkbGetAutoRepeatRate( Display * dpy,
}
Bool
-XkbSetServerInternalMods( Display * dpy,
- unsigned deviceSpec,
- unsigned affectReal,
- unsigned realValues,
- unsigned affectVirtual,
- unsigned virtualValues)
+XkbSetServerInternalMods(Display *dpy,
+ unsigned deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
{
register xkbSetControlsReq *req;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
- req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req = _XkbGetSetControlsReq(dpy, dpy->xkb_info, deviceSpec);
req->affectInternalMods = affectReal;
req->internalMods = realValues;
- req->affectInternalVMods= affectVirtual;
- req->internalVMods= virtualValues;
+ req->affectInternalVMods = affectVirtual;
+ req->internalVMods = virtualValues;
req->changeCtrls = XkbInternalModsMask;
UnlockDisplay(dpy);
SyncHandle();
@@ -126,24 +126,24 @@ XkbSetServerInternalMods( Display * dpy,
}
Bool
-XkbSetIgnoreLockMods( Display * dpy,
- unsigned int deviceSpec,
- unsigned affectReal,
- unsigned realValues,
- unsigned affectVirtual,
- unsigned virtualValues)
+XkbSetIgnoreLockMods(Display *dpy,
+ unsigned int deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
{
register xkbSetControlsReq *req;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
- req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
- req->affectIgnoreLockMods= affectReal;
+ req = _XkbGetSetControlsReq(dpy, dpy->xkb_info, deviceSpec);
+ req->affectIgnoreLockMods = affectReal;
req->ignoreLockMods = realValues;
- req->affectIgnoreLockVMods= affectVirtual;
- req->ignoreLockVMods= virtualValues;
+ req->affectIgnoreLockVMods = affectVirtual;
+ req->ignoreLockVMods = virtualValues;
req->changeCtrls = XkbIgnoreLockModsMask;
UnlockDisplay(dpy);
SyncHandle();
@@ -151,20 +151,20 @@ XkbSetIgnoreLockMods( Display * dpy,
}
Bool
-XkbChangeEnabledControls( Display * dpy,
- unsigned deviceSpec,
- unsigned affect,
- unsigned values)
+XkbChangeEnabledControls(Display *dpy,
+ unsigned deviceSpec,
+ unsigned affect,
+ unsigned values)
{
register xkbSetControlsReq *req;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
- req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
- req->affectEnabledCtrls= affect;
- req->enabledCtrls= (affect&values);
+ req = _XkbGetSetControlsReq(dpy, dpy->xkb_info, deviceSpec);
+ req->affectEnabledCtrls = affect;
+ req->enabledCtrls = (affect & values);
req->changeCtrls = XkbControlsEnabledMask;
UnlockDisplay(dpy);
SyncHandle();
@@ -176,91 +176,90 @@ XkbGetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
{
register xkbGetControlsReq *req;
xkbGetControlsReply rep;
- XkbControlsPtr ctrls;
+ XkbControlsPtr ctrls;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
if ((!xkb) || (!which))
- return BadMatch;
+ return BadMatch;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetControls, req);
- if (!xkb->ctrls) {
- xkb->ctrls = _XkbTypedCalloc(1,XkbControlsRec);
- if (!xkb->ctrls) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadAlloc;
- }
+ if (!xkb->ctrls) {
+ xkb->ctrls = _XkbTypedCalloc(1, XkbControlsRec);
+ if (!xkb->ctrls) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
}
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetControls;
req->deviceSpec = xkb->device_spec;
- if (!_XReply(dpy, (xReply *)&rep,
- (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadImplementation;
+ if (!_XReply(dpy, (xReply *) &rep,
+ (SIZEOF(xkbGetControlsReply) - SIZEOF(xReply)) >> 2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
}
- if (xkb->device_spec==XkbUseCoreKbd)
- xkb->device_spec= rep.deviceID;
- ctrls= xkb->ctrls;
- if (which&XkbControlsEnabledMask)
- ctrls->enabled_ctrls = rep.enabledCtrls;
- ctrls->num_groups= rep.numGroups;
- if (which&XkbGroupsWrapMask)
- ctrls->groups_wrap= rep.groupsWrap;
- if (which&XkbInternalModsMask) {
- ctrls->internal.mask = rep.internalMods;
- ctrls->internal.real_mods = rep.internalRealMods;
- ctrls->internal.vmods = rep.internalVMods;
+ if (xkb->device_spec == XkbUseCoreKbd)
+ xkb->device_spec = rep.deviceID;
+ ctrls = xkb->ctrls;
+ if (which & XkbControlsEnabledMask)
+ ctrls->enabled_ctrls = rep.enabledCtrls;
+ ctrls->num_groups = rep.numGroups;
+ if (which & XkbGroupsWrapMask)
+ ctrls->groups_wrap = rep.groupsWrap;
+ if (which & XkbInternalModsMask) {
+ ctrls->internal.mask = rep.internalMods;
+ ctrls->internal.real_mods = rep.internalRealMods;
+ ctrls->internal.vmods = rep.internalVMods;
}
- if (which&XkbIgnoreLockModsMask) {
- ctrls->ignore_lock.mask = rep.ignoreLockMods;
- ctrls->ignore_lock.real_mods = rep.ignoreLockRealMods;
- ctrls->ignore_lock.vmods = rep.ignoreLockVMods;
+ if (which & XkbIgnoreLockModsMask) {
+ ctrls->ignore_lock.mask = rep.ignoreLockMods;
+ ctrls->ignore_lock.real_mods = rep.ignoreLockRealMods;
+ ctrls->ignore_lock.vmods = rep.ignoreLockVMods;
}
- if (which&XkbRepeatKeysMask) {
- ctrls->repeat_delay = rep.repeatDelay;
- ctrls->repeat_interval = rep.repeatInterval;
+ if (which & XkbRepeatKeysMask) {
+ ctrls->repeat_delay = rep.repeatDelay;
+ ctrls->repeat_interval = rep.repeatInterval;
}
- if (which&XkbSlowKeysMask)
- ctrls->slow_keys_delay = rep.slowKeysDelay;
- if (which&XkbBounceKeysMask)
- ctrls->debounce_delay = rep.debounceDelay;
- if (which&XkbMouseKeysMask) {
- ctrls->mk_dflt_btn = rep.mkDfltBtn;
+ if (which & XkbSlowKeysMask)
+ ctrls->slow_keys_delay = rep.slowKeysDelay;
+ if (which & XkbBounceKeysMask)
+ ctrls->debounce_delay = rep.debounceDelay;
+ if (which & XkbMouseKeysMask) {
+ ctrls->mk_dflt_btn = rep.mkDfltBtn;
}
- if (which&XkbMouseKeysAccelMask) {
- ctrls->mk_delay = rep.mkDelay;
- ctrls->mk_interval = rep.mkInterval;
- ctrls->mk_time_to_max = rep.mkTimeToMax;
- ctrls->mk_max_speed = rep.mkMaxSpeed;
- ctrls->mk_curve = rep.mkCurve;
+ if (which & XkbMouseKeysAccelMask) {
+ ctrls->mk_delay = rep.mkDelay;
+ ctrls->mk_interval = rep.mkInterval;
+ ctrls->mk_time_to_max = rep.mkTimeToMax;
+ ctrls->mk_max_speed = rep.mkMaxSpeed;
+ ctrls->mk_curve = rep.mkCurve;
}
- if (which&XkbAccessXKeysMask)
- ctrls->ax_options= rep.axOptions;
- if (which&XkbStickyKeysMask) {
- ctrls->ax_options &= ~XkbAX_SKOptionsMask;
- ctrls->ax_options |= rep.axOptions & XkbAX_SKOptionsMask;
+ if (which & XkbAccessXKeysMask)
+ ctrls->ax_options = rep.axOptions;
+ if (which & XkbStickyKeysMask) {
+ ctrls->ax_options &= ~XkbAX_SKOptionsMask;
+ ctrls->ax_options |= rep.axOptions & XkbAX_SKOptionsMask;
}
- if (which&XkbAccessXFeedbackMask) {
- ctrls->ax_options &= ~XkbAX_FBOptionsMask;
- ctrls->ax_options |= rep.axOptions & XkbAX_FBOptionsMask;
+ if (which & XkbAccessXFeedbackMask) {
+ ctrls->ax_options &= ~XkbAX_FBOptionsMask;
+ ctrls->ax_options |= rep.axOptions & XkbAX_FBOptionsMask;
}
- if (which&XkbAccessXTimeoutMask) {
- ctrls->ax_timeout = rep.axTimeout;
- ctrls->axt_ctrls_mask = rep.axtCtrlsMask;
- ctrls->axt_ctrls_values = rep.axtCtrlsValues;
- ctrls->axt_opts_mask = rep.axtOptsMask;
- ctrls->axt_opts_values= rep.axtOptsValues;
+ if (which & XkbAccessXTimeoutMask) {
+ ctrls->ax_timeout = rep.axTimeout;
+ ctrls->axt_ctrls_mask = rep.axtCtrlsMask;
+ ctrls->axt_ctrls_values = rep.axtCtrlsValues;
+ ctrls->axt_opts_mask = rep.axtOptsMask;
+ ctrls->axt_opts_values = rep.axtOptsValues;
}
- if (which&XkbPerKeyRepeatMask) {
- memcpy(ctrls->per_key_repeat,rep.perKeyRepeat,
- XkbPerKeyBitArraySize);
+ if (which & XkbPerKeyRepeatMask) {
+ memcpy(ctrls->per_key_repeat, rep.perKeyRepeat, XkbPerKeyBitArraySize);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -271,66 +270,66 @@ Bool
XkbSetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
{
register xkbSetControlsReq *req;
- XkbControlsPtr ctrls;
+ XkbControlsPtr ctrls;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!xkb)||(!xkb->ctrls))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!xkb) || (!xkb->ctrls))
+ return False;
- ctrls= xkb->ctrls;
+ ctrls = xkb->ctrls;
LockDisplay(dpy);
- req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,xkb->device_spec);
- req->changeCtrls = (CARD32)which;
- if (which&XkbInternalModsMask) {
- req->affectInternalMods= ~0;
- req->internalMods= ctrls->internal.real_mods;
- req->affectInternalVMods = ~0;
- req->internalVMods= ctrls->internal.vmods;
+ req = _XkbGetSetControlsReq(dpy, dpy->xkb_info, xkb->device_spec);
+ req->changeCtrls = (CARD32) which;
+ if (which & XkbInternalModsMask) {
+ req->affectInternalMods = ~0;
+ req->internalMods = ctrls->internal.real_mods;
+ req->affectInternalVMods = ~0;
+ req->internalVMods = ctrls->internal.vmods;
}
- if (which&XkbIgnoreLockModsMask) {
- req->affectIgnoreLockMods= ~0;
- req->ignoreLockMods= ctrls->ignore_lock.real_mods;
- req->affectIgnoreLockVMods= ~0;
- req->ignoreLockVMods= ctrls->ignore_lock.vmods;
+ if (which & XkbIgnoreLockModsMask) {
+ req->affectIgnoreLockMods = ~0;
+ req->ignoreLockMods = ctrls->ignore_lock.real_mods;
+ req->affectIgnoreLockVMods = ~0;
+ req->ignoreLockVMods = ctrls->ignore_lock.vmods;
}
- if (which&XkbControlsEnabledMask) {
- req->affectEnabledCtrls= XkbAllBooleanCtrlsMask;
- req->enabledCtrls= ctrls->enabled_ctrls;
+ if (which & XkbControlsEnabledMask) {
+ req->affectEnabledCtrls = XkbAllBooleanCtrlsMask;
+ req->enabledCtrls = ctrls->enabled_ctrls;
}
- if (which&XkbRepeatKeysMask) {
- req->repeatDelay = ctrls->repeat_delay;
- req->repeatInterval = ctrls->repeat_interval;
+ if (which & XkbRepeatKeysMask) {
+ req->repeatDelay = ctrls->repeat_delay;
+ req->repeatInterval = ctrls->repeat_interval;
}
- if (which&XkbSlowKeysMask)
- req->slowKeysDelay = ctrls->slow_keys_delay;
- if (which&XkbBounceKeysMask)
- req->debounceDelay = ctrls->debounce_delay;
- if (which&XkbMouseKeysMask) {
- req->mkDfltBtn = ctrls->mk_dflt_btn;
+ if (which & XkbSlowKeysMask)
+ req->slowKeysDelay = ctrls->slow_keys_delay;
+ if (which & XkbBounceKeysMask)
+ req->debounceDelay = ctrls->debounce_delay;
+ if (which & XkbMouseKeysMask) {
+ req->mkDfltBtn = ctrls->mk_dflt_btn;
}
- if (which&XkbGroupsWrapMask)
- req->groupsWrap= ctrls->groups_wrap;
- if (which&(XkbAccessXKeysMask|XkbStickyKeysMask|XkbAccessXFeedbackMask))
- req->axOptions= ctrls->ax_options;
- if (which&XkbMouseKeysAccelMask) {
- req->mkDelay = ctrls->mk_delay;
- req->mkInterval = ctrls->mk_interval;
- req->mkTimeToMax = ctrls->mk_time_to_max;
- req->mkMaxSpeed = ctrls->mk_max_speed;
- req->mkCurve = ctrls->mk_curve;
+ if (which & XkbGroupsWrapMask)
+ req->groupsWrap = ctrls->groups_wrap;
+ if (which &
+ (XkbAccessXKeysMask | XkbStickyKeysMask | XkbAccessXFeedbackMask))
+ req->axOptions = ctrls->ax_options;
+ if (which & XkbMouseKeysAccelMask) {
+ req->mkDelay = ctrls->mk_delay;
+ req->mkInterval = ctrls->mk_interval;
+ req->mkTimeToMax = ctrls->mk_time_to_max;
+ req->mkMaxSpeed = ctrls->mk_max_speed;
+ req->mkCurve = ctrls->mk_curve;
}
- if (which&XkbAccessXTimeoutMask) {
- req->axTimeout = ctrls->ax_timeout;
- req->axtCtrlsMask = ctrls->axt_ctrls_mask;
- req->axtCtrlsValues = ctrls->axt_ctrls_values;
- req->axtOptsMask = ctrls->axt_opts_mask;
- req->axtOptsValues=ctrls->axt_opts_values;
+ if (which & XkbAccessXTimeoutMask) {
+ req->axTimeout = ctrls->ax_timeout;
+ req->axtCtrlsMask = ctrls->axt_ctrls_mask;
+ req->axtCtrlsValues = ctrls->axt_ctrls_values;
+ req->axtOptsMask = ctrls->axt_opts_mask;
+ req->axtOptsValues = ctrls->axt_opts_values;
}
- if (which&XkbPerKeyRepeatMask) {
- memcpy(req->perKeyRepeat,ctrls->per_key_repeat,
- XkbPerKeyBitArraySize);
+ if (which & XkbPerKeyRepeatMask) {
+ memcpy(req->perKeyRepeat, ctrls->per_key_repeat, XkbPerKeyBitArraySize);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -340,13 +339,13 @@ XkbSetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
/***====================================================================***/
void
-XkbNoteControlsChanges( XkbControlsChangesPtr old,
- XkbControlsNotifyEvent * new,
- unsigned int wanted)
+XkbNoteControlsChanges(XkbControlsChangesPtr old,
+ XkbControlsNotifyEvent *new,
+ unsigned int wanted)
{
- old->changed_ctrls|= (new->changed_ctrls&wanted);
- if (new->changed_ctrls&XkbControlsEnabledMask&wanted)
- old->enabled_ctrls_changes^= new->enabled_ctrl_changes;
+ old->changed_ctrls |= (new->changed_ctrls & wanted);
+ if (new->changed_ctrls & XkbControlsEnabledMask & wanted)
+ old->enabled_ctrls_changes ^= new->enabled_ctrl_changes;
/* num_groups_changed?? */
return;
}
diff --git a/nx-X11/lib/X11/XKBCvt.c b/nx-X11/lib/X11/XKBCvt.c
index d8ceddbdc..f4df3fcfc 100644
--- a/nx-X11/lib/X11/XKBCvt.c
+++ b/nx-X11/lib/X11/XKBCvt.c
@@ -60,94 +60,99 @@ _XkbHandleSpecialSym(KeySym keysym, char *buffer, int nbytes, int *extra_rtrn)
/* try to convert to Latin-1, handling ctrl */
if (!(((keysym >= XK_BackSpace) && (keysym <= XK_Clear)) ||
- (keysym == XK_Return) || (keysym == XK_Escape) ||
- (keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
- (keysym == XK_KP_Enter) ||
- ((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
- (keysym == XK_KP_Equal) ||
- (keysym == XK_Delete)))
- return 0;
-
- if (nbytes<1) {
- if (extra_rtrn)
- *extra_rtrn= 1;
- return 0;
+ (keysym == XK_Return) || (keysym == XK_Escape) ||
+ (keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
+ (keysym == XK_KP_Enter) ||
+ ((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
+ (keysym == XK_KP_Equal) || (keysym == XK_Delete)))
+ return 0;
+
+ if (nbytes < 1) {
+ if (extra_rtrn)
+ *extra_rtrn = 1;
+ return 0;
}
/* if X keysym, convert to ascii by grabbing low 7 bits */
if (keysym == XK_KP_Space)
- buffer[0] = XK_space & 0x7F; /* patch encoding botch */
+ buffer[0] = XK_space & 0x7F; /* patch encoding botch */
else if (keysym == XK_hyphen)
- buffer[0] = (char)(XK_minus & 0xFF); /* map to equiv character */
- else buffer[0] = (char)(keysym & 0x7F);
+ buffer[0] = (char) (XK_minus & 0xFF); /* map to equiv character */
+ else
+ buffer[0] = (char) (keysym & 0x7F);
return 1;
}
/*ARGSUSED*/
static int
-_XkbKSToKnownSet ( XPointer priv,
- KeySym keysym,
- char * buffer,
- int nbytes,
- int * extra_rtrn)
+_XkbKSToKnownSet(XPointer priv,
+ KeySym keysym,
+ char *buffer,
+ int nbytes,
+ int *extra_rtrn)
{
- char tbuf[8],*buf;
+ char tbuf[8], *buf;
if (extra_rtrn)
- *extra_rtrn= 0;
+ *extra_rtrn = 0;
/* convert "dead" diacriticals for dumb applications */
- if ( (keysym&0xffffff00)== 0xfe00 ) {
- switch ( keysym ) {
- case XK_dead_grave: keysym = XK_grave; break;
- case XK_dead_acute: keysym = XK_acute; break;
- case XK_dead_circumflex: keysym = XK_asciicircum; break;
- case XK_dead_tilde: keysym = XK_asciitilde; break;
- case XK_dead_macron: keysym = XK_macron; break;
- case XK_dead_breve: keysym = XK_breve; break;
- case XK_dead_abovedot: keysym = XK_abovedot; break;
- case XK_dead_diaeresis: keysym = XK_diaeresis; break;
- case XK_dead_abovering: keysym = XK_degree; break;
- case XK_dead_doubleacute: keysym = XK_doubleacute; break;
- case XK_dead_caron: keysym = XK_caron; break;
- case XK_dead_cedilla: keysym = XK_cedilla; break;
- case XK_dead_ogonek : keysym = XK_ogonek; break;
- case XK_dead_iota: keysym = XK_Greek_iota; break;
+ if ((keysym & 0xffffff00) == 0xfe00) {
+ switch (keysym) {
+ case XK_dead_grave: keysym = XK_grave; break;
+ case XK_dead_acute: keysym = XK_acute; break;
+ case XK_dead_circumflex: keysym = XK_asciicircum; break;
+ case XK_dead_tilde: keysym = XK_asciitilde; break;
+ case XK_dead_macron: keysym = XK_macron; break;
+ case XK_dead_breve: keysym = XK_breve; break;
+ case XK_dead_abovedot: keysym = XK_abovedot; break;
+ case XK_dead_diaeresis: keysym = XK_diaeresis; break;
+ case XK_dead_abovering: keysym = XK_degree; break;
+ case XK_dead_doubleacute: keysym = XK_doubleacute; break;
+ case XK_dead_caron: keysym = XK_caron; break;
+ case XK_dead_cedilla: keysym = XK_cedilla; break;
+ case XK_dead_ogonek: keysym = XK_ogonek; break;
+ case XK_dead_iota: keysym = XK_Greek_iota; break;
#ifdef XK_KATAKANA
- case XK_dead_voiced_sound: keysym = XK_voicedsound; break;
- case XK_dead_semivoiced_sound:keysym = XK_semivoicedsound; break;
+ case XK_dead_voiced_sound: keysym = XK_voicedsound; break;
+ case XK_dead_semivoiced_sound: keysym = XK_semivoicedsound; break;
#endif
- }
+ }
}
- if (nbytes<1) buf= tbuf;
- else buf= buffer;
+ if (nbytes < 1)
+ buf = tbuf;
+ else
+ buf = buffer;
- if ((keysym&0xffffff00)==0xff00) {
- return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
+ if ((keysym & 0xffffff00) == 0xff00) {
+ return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
}
- return _XimGetCharCode (priv, keysym, (unsigned char *)buf, nbytes);
+ return _XimGetCharCode(priv, keysym, (unsigned char *) buf, nbytes);
}
typedef struct _XkbToKS {
- unsigned prefix;
- char *map;
+ unsigned prefix;
+ char *map;
} XkbToKS;
/*ARGSUSED*/
static KeySym
-_XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
+_XkbKnownSetToKS(XPointer priv, char *buffer, int nbytes, Status *status)
{
- if (nbytes!=1)
- return NoSymbol;
- if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
- return buffer[0];
- else if ((buffer[0]&0x7f)>=32) {
- XkbToKS *map= (XkbToKS *)priv;
- if ( map ) {
- if ( map->map ) return map->prefix|map->map[buffer[0]&0x7f];
- else return map->prefix|buffer[0];
- }
- return buffer[0];
+ if (nbytes != 1)
+ return NoSymbol;
+ if (((buffer[0] & 0x80) == 0) && (buffer[0] >= 32))
+ return buffer[0];
+ else if ((buffer[0] & 0x7f) >= 32) {
+ XkbToKS *map = (XkbToKS *) priv;
+
+ if (map) {
+ if (map->map)
+ return map->prefix | map->map[buffer[0] & 0x7f];
+ else
+ return map->prefix | buffer[0];
+ }
+ return buffer[0];
}
return NoSymbol;
}
@@ -155,7 +160,7 @@ _XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
static KeySym
__XkbDefaultToUpper(KeySym sym)
{
- KeySym lower,upper;
+ KeySym lower, upper;
XConvertCase(sym, &lower, &upper);
return upper;
@@ -172,13 +177,13 @@ Strcmp(char *str1, char *str2)
* unchecked strings from the environment can end up here, so check
* the length before copying.
*/
- if (strlen(str1) >= sizeof(str)) /* almost certain it's a mismatch */
- return 1;
+ if (strlen(str1) >= sizeof(str)) /* almost certain it's a mismatch */
+ return 1;
- for (s = str; (c = *str1++); ) {
- if (isupper(c))
- c = tolower(c);
- *s++ = c;
+ for (s = str; (c = *str1++);) {
+ if (isupper(c))
+ c = tolower(c);
+ *s++ = c;
}
*s = '\0';
return (strcmp(str, str2));
@@ -186,9 +191,10 @@ Strcmp(char *str1, char *str2)
#endif
int
-_XkbGetConverters(const char *encoding_name, XkbConverters *cvt_rtrn)
+_XkbGetConverters(const char *encoding_name, XkbConverters * cvt_rtrn)
{
- if ( !cvt_rtrn ) return 0;
+ if (!cvt_rtrn)
+ return 0;
cvt_rtrn->KSToMB = _XkbKSToKnownSet;
cvt_rtrn->KSToMBPriv = _XimGetLocaleCode(encoding_name);
@@ -214,9 +220,14 @@ _XkbGetConverters(const char *encoding_name, XkbConverters *cvt_rtrn)
*/
#define CHARSET_FILE "/usr/lib/X11/input/charsets"
-static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:th,th_TH,th_TH.iso8859-11=iso8859-11:th_TH.TIS620=tis620:hy=armscii-8:vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
-
-char *
+static char *_XkbKnownLanguages =
+ "c=ascii:da,de,en,es,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:"
+ "eo=iso8859-3:sp=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:he=iso8859-8:"
+ "tr=iso8859-9:lt,lv=iso8859-13:et,fi=iso8859-15:ru=koi8-r:uk=koi8-u:"
+ "th,th_TH,th_TH.iso8859-11=iso8859-11:th_TH.TIS620=tis620:hy=armscii-8:"
+ "vi=tcvn-5712:ka=georgian-academy:be,bg=microsoft-cp1251";
+
+char *
_XkbGetCharset(void)
{
/*
@@ -225,49 +236,51 @@ _XkbGetCharset(void)
*/
static char buf[100] = { 0 };
char lang[256];
- char *start,*tmp,*end,*next,*set;
- char *country,*charset;
+ char *start, *tmp, *end, *next, *set;
+ char *country, *charset;
char *locale;
- tmp = getenv( "_XKB_CHARSET" );
- if ( tmp )
- return tmp;
- locale = setlocale(LC_CTYPE,NULL);
+ tmp = getenv("_XKB_CHARSET");
+ if (tmp)
+ return tmp;
+ locale = setlocale(LC_CTYPE, NULL);
- if ( locale == NULL )
- return NULL;
+ if (locale == NULL)
+ return NULL;
if (strlen(locale) >= sizeof(lang))
- return NULL;
+ return NULL;
for (tmp = lang; *tmp = *locale++; tmp++) {
- if (isupper(*tmp))
- *tmp = tolower(*tmp);
+ if (isupper(*tmp))
+ *tmp = tolower(*tmp);
}
- country = strchr( lang, '_');
- if ( country ) {
- *country++ = '\0';
- charset = strchr( country, '.' );
- if ( charset ) *charset++ = '\0';
- if ( charset ) {
- strncpy(buf,charset,99);
- buf[99] = '\0';
- return buf;
- }
+ country = strchr(lang, '_');
+ if (country) {
+ *country++ = '\0';
+ charset = strchr(country, '.');
+ if (charset)
+ *charset++ = '\0';
+ if (charset) {
+ strncpy(buf, charset, 99);
+ buf[99] = '\0';
+ return buf;
+ }
}
else {
- charset = NULL;
+ charset = NULL;
}
- if ((tmp = getenv("_XKB_LOCALE_CHARSETS"))!=NULL) {
- start = _XkbAlloc(strlen(tmp) + 1);
- strcpy(start, tmp);
- tmp = start;
- } else {
- struct stat sbuf;
- FILE *file;
+ if ((tmp = getenv("_XKB_LOCALE_CHARSETS")) != NULL) {
+ start = _XkbAlloc(strlen(tmp) + 1);
+ strcpy(start, tmp);
+ tmp = start;
+ }
+ else {
+ struct stat sbuf;
+ FILE *file;
#ifndef __UNIXOS2__
- char *cf = CHARSET_FILE;
+ char *cf = CHARSET_FILE;
#else
char *cf = __XOS2RedirRoot(CHARSET_FILE);
#endif
@@ -276,62 +289,61 @@ _XkbGetCharset(void)
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
- if ( (stat(cf,&sbuf)==0) && S_ISREG(sbuf.st_mode) &&
- (file = fopen(cf,"r")) ) {
- tmp = _XkbAlloc(sbuf.st_size+1);
- if (tmp!=NULL) {
- sbuf.st_size = (long)fread(tmp,1,sbuf.st_size,file);
- tmp[sbuf.st_size] = '\0';
- }
- fclose(file);
- }
+ if ((stat(cf, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
+ (file = fopen(cf, "r"))) {
+ tmp = _XkbAlloc(sbuf.st_size + 1);
+ if (tmp != NULL) {
+ sbuf.st_size = (long) fread(tmp, 1, sbuf.st_size, file);
+ tmp[sbuf.st_size] = '\0';
+ }
+ fclose(file);
+ }
}
- if ( tmp == NULL ) {
- tmp = _XkbAlloc(strlen(_XkbKnownLanguages) + 1);
- if (!tmp)
- return NULL;
- strcpy(tmp, _XkbKnownLanguages);
+ if (tmp == NULL) {
+ tmp = _XkbAlloc(strlen(_XkbKnownLanguages) + 1);
+ if (!tmp)
+ return NULL;
+ strcpy(tmp, _XkbKnownLanguages);
}
start = tmp;
do {
- if ( (set=strchr(tmp,'=')) == NULL )
- break;
- *set++ = '\0';
- if ( (next=strchr(set,':')) != NULL )
- *next++ = '\0';
- while ( tmp && *tmp ) {
- if ( (end=strchr(tmp,',')) != NULL )
- *end++ = '\0';
- if ( Strcmp( tmp, lang ) == 0 ) {
- strncpy(buf,set,100);
- buf[99] = '\0';
- Xfree(start);
- return buf;
- }
- tmp = end;
- }
- tmp = next;
- } while ( tmp && *tmp );
+ if ((set = strchr(tmp, '=')) == NULL)
+ break;
+ *set++ = '\0';
+ if ((next = strchr(set, ':')) != NULL)
+ *next++ = '\0';
+ while (tmp && *tmp) {
+ if ((end = strchr(tmp, ',')) != NULL)
+ *end++ = '\0';
+ if (Strcmp(tmp, lang) == 0) {
+ strncpy(buf, set, 100);
+ buf[99] = '\0';
+ Xfree(start);
+ return buf;
+ }
+ tmp = end;
+ }
+ tmp = next;
+ } while (tmp && *tmp);
Xfree(start);
return NULL;
}
#else
-char *
+char *
_XkbGetCharset(void)
{
char *tmp;
XLCd lcd;
- tmp = getenv( "_XKB_CHARSET" );
- if ( tmp )
- return tmp;
+ tmp = getenv("_XKB_CHARSET");
+ if (tmp)
+ return tmp;
lcd = _XlcCurrentLC();
- if ( lcd )
- return XLC_PUBLIC(lcd,encoding_name);
+ if (lcd)
+ return XLC_PUBLIC(lcd, encoding_name);
return NULL;
}
#endif
-
diff --git a/nx-X11/lib/X11/XKBExtDev.c b/nx-X11/lib/X11/XKBExtDev.c
index 47b94a3aa..183647fc6 100644
--- a/nx-X11/lib/X11/XKBExtDev.c
+++ b/nx-X11/lib/X11/XKBExtDev.c
@@ -37,68 +37,72 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
extern void
-XkbNoteDeviceChanges( XkbDeviceChangesPtr old,
- XkbExtensionDeviceNotifyEvent * new,
- unsigned int wanted)
+XkbNoteDeviceChanges(XkbDeviceChangesPtr old,
+ XkbExtensionDeviceNotifyEvent *new,
+ unsigned int wanted)
{
- if ((!old)||(!new)||(!wanted)||((new->reason&wanted)==0))
- return;
- if ((wanted&new->reason)&XkbXI_ButtonActionsMask) {
- if (old->changed&XkbXI_ButtonActionsMask) {
- int first,last,newLast;
- if (new->first_btn<old->first_btn)
- first= new->first_btn;
- else first= old->first_btn;
- last= old->first_btn+old->num_btns-1;
- newLast= new->first_btn+new->num_btns-1;
- if (newLast>last)
- last= newLast;
- old->first_btn= first;
- old->num_btns= (last-first)+1;
- }
- else {
- old->changed|= XkbXI_ButtonActionsMask;
- old->first_btn= new->first_btn;
- old->num_btns= new->num_btns;
- }
+ if ((!old) || (!new) || (!wanted) || ((new->reason & wanted) == 0))
+ return;
+ if ((wanted & new->reason) & XkbXI_ButtonActionsMask) {
+ if (old->changed & XkbXI_ButtonActionsMask) {
+ int first, last, newLast;
+
+ if (new->first_btn < old->first_btn)
+ first = new->first_btn;
+ else
+ first = old->first_btn;
+ last = old->first_btn + old->num_btns - 1;
+ newLast = new->first_btn + new->num_btns - 1;
+ if (newLast > last)
+ last = newLast;
+ old->first_btn = first;
+ old->num_btns = (last - first) + 1;
+ }
+ else {
+ old->changed |= XkbXI_ButtonActionsMask;
+ old->first_btn = new->first_btn;
+ old->num_btns = new->num_btns;
+ }
}
- if ((wanted&new->reason)&XkbXI_IndicatorsMask) {
- XkbDeviceLedChangesPtr this;
- if (old->changed&XkbXI_IndicatorsMask) {
- XkbDeviceLedChangesPtr found;
- found= NULL;
- for (this= &old->leds;this&&(!found);this=this->next) {
- if ((this->led_class==new->led_class)&&
- (this->led_id==new->led_id)) {
- found= this;
- }
- }
- if (!found) {
- found= _XkbTypedCalloc(1,XkbDeviceLedChangesRec);
- if (!found)
- return;
- found->next= old->leds.next;
- found->led_class= new->led_class;
- found->led_id= new->led_id;
- old->leds.next= found;
- }
- if ((wanted&new->reason)&XkbXI_IndicatorNamesMask)
- found->defined= new->leds_defined;
- }
- else {
- old->changed|= ((wanted&new->reason)&XkbXI_IndicatorsMask);
- old->leds.led_class= new->led_class;
- old->leds.led_id= new->led_id;
- old->leds.defined= new->leds_defined;
- if (old->leds.next) {
- XkbDeviceLedChangesPtr next;
- for (this=old->leds.next;this;this=next) {
- next= this->next;
- _XkbFree(this);
- }
- old->leds.next= NULL;
- }
- }
+ if ((wanted & new->reason) & XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr this;
+
+ if (old->changed & XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr found = NULL;
+
+ for (this = &old->leds; this && (!found); this = this->next) {
+ if ((this->led_class == new->led_class) &&
+ (this->led_id == new->led_id)) {
+ found = this;
+ }
+ }
+ if (!found) {
+ found = _XkbTypedCalloc(1, XkbDeviceLedChangesRec);
+ if (!found)
+ return;
+ found->next = old->leds.next;
+ found->led_class = new->led_class;
+ found->led_id = new->led_id;
+ old->leds.next = found;
+ }
+ if ((wanted & new->reason) & XkbXI_IndicatorNamesMask)
+ found->defined = new->leds_defined;
+ }
+ else {
+ old->changed |= ((wanted & new->reason) & XkbXI_IndicatorsMask);
+ old->leds.led_class = new->led_class;
+ old->leds.led_id = new->led_id;
+ old->leds.defined = new->leds_defined;
+ if (old->leds.next) {
+ XkbDeviceLedChangesPtr next;
+
+ for (this = old->leds.next; this; this = next) {
+ next = this->next;
+ _XkbFree(this);
+ }
+ old->leds.next = NULL;
+ }
+ }
}
return;
}
@@ -106,162 +110,168 @@ XkbNoteDeviceChanges( XkbDeviceChangesPtr old,
/***====================================================================***/
static Status
-_XkbReadDeviceLedInfo( XkbReadBufferPtr buf,
- unsigned present,
- XkbDeviceInfoPtr devi)
+_XkbReadDeviceLedInfo(XkbReadBufferPtr buf,
+ unsigned present,
+ XkbDeviceInfoPtr devi)
{
-register unsigned i,bit;
-XkbDeviceLedInfoPtr devli;
-xkbDeviceLedsWireDesc * wireli;
+ register unsigned i, bit;
+ XkbDeviceLedInfoPtr devli;
+ xkbDeviceLedsWireDesc *wireli;
- wireli= _XkbGetTypedRdBufPtr(buf,1,xkbDeviceLedsWireDesc);
+ wireli = _XkbGetTypedRdBufPtr(buf, 1, xkbDeviceLedsWireDesc);
if (!wireli)
- return BadLength;
- devli= XkbAddDeviceLedInfo(devi,wireli->ledClass,wireli->ledID);
+ return BadLength;
+ devli = XkbAddDeviceLedInfo(devi, wireli->ledClass, wireli->ledID);
if (!devli)
- return BadAlloc;
- devli->phys_indicators= wireli->physIndicators;
-
- if (present&XkbXI_IndicatorStateMask)
- devli->state= wireli->state;
-
- if (present&XkbXI_IndicatorNamesMask) {
- devli->names_present= wireli->namesPresent;
- if (devli->names_present) {
- for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
- if (wireli->namesPresent&bit) {
- if (!_XkbCopyFromReadBuffer(buf,(char *)&devli->names[i],4))
- return BadLength;
- }
- }
- }
+ return BadAlloc;
+ devli->phys_indicators = wireli->physIndicators;
+
+ if (present & XkbXI_IndicatorStateMask)
+ devli->state = wireli->state;
+
+ if (present & XkbXI_IndicatorNamesMask) {
+ devli->names_present = wireli->namesPresent;
+ if (devli->names_present) {
+ for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
+ if (wireli->namesPresent & bit) {
+ if (!_XkbCopyFromReadBuffer(buf,
+ (char *) &devli->names[i], 4))
+ return BadLength;
+ }
+ }
+ }
}
- if (present&XkbXI_IndicatorMapsMask) {
- devli->maps_present= wireli->mapsPresent;
- if (devli->maps_present) {
- XkbIndicatorMapPtr im;
- xkbIndicatorMapWireDesc * wireim;
- for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
- if (wireli->mapsPresent&bit) {
- wireim= _XkbGetTypedRdBufPtr(buf,1,xkbIndicatorMapWireDesc);
- if (!wireim)
- return BadAlloc;
- im= &devli->maps[i];
- im->flags= wireim->flags;
- im->which_groups= wireim->whichGroups;
- im->groups= wireim->groups;
- im->which_mods= wireim->whichMods;
- im->mods.mask= wireim->mods;
- im->mods.real_mods= wireim->realMods;
- im->mods.vmods= wireim->virtualMods;
- im->ctrls= wireim->ctrls;
- }
- }
- }
+ if (present & XkbXI_IndicatorMapsMask) {
+ devli->maps_present = wireli->mapsPresent;
+ if (devli->maps_present) {
+ XkbIndicatorMapPtr im;
+ xkbIndicatorMapWireDesc *wireim;
+
+ for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
+ if (wireli->mapsPresent & bit) {
+ wireim =
+ _XkbGetTypedRdBufPtr(buf, 1, xkbIndicatorMapWireDesc);
+ if (!wireim)
+ return BadAlloc;
+ im = &devli->maps[i];
+ im->flags = wireim->flags;
+ im->which_groups = wireim->whichGroups;
+ im->groups = wireim->groups;
+ im->which_mods = wireim->whichMods;
+ im->mods.mask = wireim->mods;
+ im->mods.real_mods = wireim->realMods;
+ im->mods.vmods = wireim->virtualMods;
+ im->ctrls = wireim->ctrls;
+ }
+ }
+ }
}
return Success;
}
static Status
-_XkbReadGetDeviceInfoReply( Display * dpy,
- xkbGetDeviceInfoReply * rep,
- XkbDeviceInfoPtr devi)
+_XkbReadGetDeviceInfoReply(Display *dpy,
+ xkbGetDeviceInfoReply *rep,
+ XkbDeviceInfoPtr devi)
{
-XkbReadBufferRec buf;
-XkbAction * act;
-int tmp;
+ XkbReadBufferRec buf;
+ XkbAction *act;
+ int tmp;
- if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
- return BadAlloc;
+ if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4))
+ return BadAlloc;
- if ((rep->totalBtns>0)&&(rep->totalBtns!=devi->num_btns)) {
- tmp= XkbResizeDeviceButtonActions(devi,rep->totalBtns);
- if (tmp!=Success)
- return tmp;
+ if ((rep->totalBtns > 0) && (rep->totalBtns != devi->num_btns)) {
+ tmp = XkbResizeDeviceButtonActions(devi, rep->totalBtns);
+ if (tmp != Success)
+ return tmp;
}
- if (rep->nBtnsWanted>0) {
- if (((unsigned short) rep->firstBtnWanted + rep->nBtnsWanted)
- >= devi->num_btns)
- goto BAILOUT;
- act= &devi->btn_acts[rep->firstBtnWanted];
- bzero((char *)act,(rep->nBtnsWanted*sizeof(XkbAction)));
+ if (rep->nBtnsWanted > 0) {
+ if (((unsigned short) rep->firstBtnWanted + rep->nBtnsWanted)
+ >= devi->num_btns)
+ goto BAILOUT;
+ act = &devi->btn_acts[rep->firstBtnWanted];
+ bzero((char *) act, (rep->nBtnsWanted * sizeof(XkbAction)));
}
- if (devi->name!=NULL)
- _XkbFree(devi->name);
- if (!_XkbGetReadBufferCountedString(&buf,&devi->name))
- goto BAILOUT;
- if (rep->nBtnsRtrn>0) {
- int size;
- if (((unsigned short) rep->firstBtnRtrn + rep->nBtnsRtrn)
- >= devi->num_btns)
- goto BAILOUT;
- act= &devi->btn_acts[rep->firstBtnRtrn];
- size= rep->nBtnsRtrn*SIZEOF(xkbActionWireDesc);
- if (!_XkbCopyFromReadBuffer(&buf,(char *)act,size))
- goto BAILOUT;
+
+ _XkbFree(devi->name);
+ if (!_XkbGetReadBufferCountedString(&buf, &devi->name))
+ goto BAILOUT;
+ if (rep->nBtnsRtrn > 0) {
+ int size;
+
+ if (((unsigned short) rep->firstBtnRtrn + rep->nBtnsRtrn)
+ >= devi->num_btns)
+ goto BAILOUT;
+ act = &devi->btn_acts[rep->firstBtnRtrn];
+ size = rep->nBtnsRtrn * SIZEOF(xkbActionWireDesc);
+ if (!_XkbCopyFromReadBuffer(&buf, (char *) act, size))
+ goto BAILOUT;
}
- if (rep->nDeviceLedFBs>0) {
- register int i;
- for (i=0;i<rep->nDeviceLedFBs;i++) {
- if ((tmp= _XkbReadDeviceLedInfo(&buf,rep->present,devi))!=Success)
- return tmp;
- }
+ if (rep->nDeviceLedFBs > 0) {
+ register int i;
+
+ for (i = 0; i < rep->nDeviceLedFBs; i++) {
+ if ((tmp = _XkbReadDeviceLedInfo(&buf, rep->present, devi))
+ != Success)
+ return tmp;
+ }
}
- tmp= _XkbFreeReadBuffer(&buf);
+ tmp = _XkbFreeReadBuffer(&buf);
if (tmp)
- fprintf(stderr,"GetDeviceInfo! Bad length (%d extra bytes)\n",tmp);
+ fprintf(stderr, "GetDeviceInfo! Bad length (%d extra bytes)\n", tmp);
if (tmp || buf.error)
- return BadLength;
+ return BadLength;
return Success;
-BAILOUT:
+ BAILOUT:
_XkbFreeReadBuffer(&buf);
return BadLength;
}
XkbDeviceInfoPtr
-XkbGetDeviceInfo( Display * dpy,
- unsigned which,
- unsigned deviceSpec,
- unsigned class,
- unsigned id)
+XkbGetDeviceInfo(Display *dpy,
+ unsigned which,
+ unsigned deviceSpec,
+ unsigned class,
+ unsigned id)
{
- register xkbGetDeviceInfoReq * req;
- xkbGetDeviceInfoReply rep;
- Status status;
- XkbDeviceInfoPtr devi;
+ register xkbGetDeviceInfoReq *req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+ XkbDeviceInfoPtr devi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return NULL;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return NULL;
LockDisplay(dpy);
GetReq(kbGetDeviceInfo, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbGetDeviceInfo;
req->deviceSpec = deviceSpec;
- req->wanted= which;
- req->allBtns= ((which&XkbXI_ButtonActionsMask)!=0);
- req->firstBtn= req->nBtns= 0;
- req->ledClass= class;
- req->ledID= id;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return NULL;
+ req->wanted = which;
+ req->allBtns = ((which & XkbXI_ButtonActionsMask) != 0);
+ req->firstBtn = req->nBtns = 0;
+ req->ledClass = class;
+ req->ledID = id;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
}
- devi= XkbAllocDeviceInfo(rep.deviceID,rep.totalBtns,rep.nDeviceLedFBs);
+ devi = XkbAllocDeviceInfo(rep.deviceID, rep.totalBtns, rep.nDeviceLedFBs);
if (devi) {
- devi->supported= rep.supported;
- devi->unsupported= rep.unsupported;
- devi->type= rep.devType;
- devi->has_own_state= rep.hasOwnState;
- devi->dflt_kbd_fb = rep.dfltKbdFB;
- devi->dflt_led_fb = rep.dfltLedFB;
- status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
- if (status!=Success) {
- XkbFreeDeviceInfo(devi,XkbXI_AllDeviceFeaturesMask,True);
- devi= NULL;
- }
+ devi->supported = rep.supported;
+ devi->unsupported = rep.unsupported;
+ devi->type = rep.devType;
+ devi->has_own_state = rep.hasOwnState;
+ devi->dflt_kbd_fb = rep.dfltKbdFB;
+ devi->dflt_led_fb = rep.dfltLedFB;
+ status = _XkbReadGetDeviceInfoReply(dpy, &rep, devi);
+ if (status != Success) {
+ XkbFreeDeviceInfo(devi, XkbXI_AllDeviceFeaturesMask, True);
+ devi = NULL;
+ }
}
UnlockDisplay(dpy);
SyncHandle();
@@ -269,59 +279,61 @@ XkbGetDeviceInfo( Display * dpy,
}
Status
-XkbGetDeviceInfoChanges( Display * dpy,
- XkbDeviceInfoPtr devi,
- XkbDeviceChangesPtr changes)
+XkbGetDeviceInfoChanges(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
{
- register xkbGetDeviceInfoReq * req;
- xkbGetDeviceInfoReply rep;
- Status status;
+ register xkbGetDeviceInfoReq *req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadMatch;
- if ((changes->changed&XkbXI_AllDeviceFeaturesMask)==0)
- return Success;
- changes->changed&= ~XkbXI_AllDeviceFeaturesMask;
- status= Success;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadMatch;
+ if ((changes->changed & XkbXI_AllDeviceFeaturesMask) == 0)
+ return Success;
+ changes->changed &= ~XkbXI_AllDeviceFeaturesMask;
+ status = Success;
LockDisplay(dpy);
- while ((changes->changed)&&(status==Success)) {
- GetReq(kbGetDeviceInfo, req);
- req->reqType = dpy->xkb_info->codes->major_opcode;
- req->xkbReqType = X_kbGetDeviceInfo;
- req->deviceSpec = devi->device_spec;
- req->wanted= changes->changed;
- req->allBtns= False;
- if (changes->changed&XkbXI_ButtonActionsMask) {
- req->firstBtn= changes->first_btn;
- req->nBtns= changes->num_btns;
- changes->changed&= ~XkbXI_ButtonActionsMask;
- }
- else req->firstBtn= req->nBtns= 0;
- if (changes->changed&XkbXI_IndicatorsMask) {
- req->ledClass= changes->leds.led_class;
- req->ledID= changes->leds.led_id;
- if (changes->leds.next==NULL)
- changes->changed&= ~XkbXI_IndicatorsMask;
- else {
- XkbDeviceLedChangesPtr next;
- next= changes->leds.next;
- changes->leds= *next;
- _XkbFree(next);
- }
- }
- else {
- req->ledClass= XkbDfltXIClass;
- req->ledID= XkbDfltXIId;
- }
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- status= BadLength;
- break;
- }
- devi->supported|= rep.supported;
- devi->unsupported|= rep.unsupported;
- devi->type= rep.devType;
- status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ while ((changes->changed) && (status == Success)) {
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted = changes->changed;
+ req->allBtns = False;
+ if (changes->changed & XkbXI_ButtonActionsMask) {
+ req->firstBtn = changes->first_btn;
+ req->nBtns = changes->num_btns;
+ changes->changed &= ~XkbXI_ButtonActionsMask;
+ }
+ else
+ req->firstBtn = req->nBtns = 0;
+ if (changes->changed & XkbXI_IndicatorsMask) {
+ req->ledClass = changes->leds.led_class;
+ req->ledID = changes->leds.led_id;
+ if (changes->leds.next == NULL)
+ changes->changed &= ~XkbXI_IndicatorsMask;
+ else {
+ XkbDeviceLedChangesPtr next;
+
+ next = changes->leds.next;
+ changes->leds = *next;
+ _XkbFree(next);
+ }
+ }
+ else {
+ req->ledClass = XkbDfltXIClass;
+ req->ledID = XkbDfltXIId;
+ }
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ status = BadLength;
+ break;
+ }
+ devi->supported |= rep.supported;
+ devi->unsupported |= rep.unsupported;
+ devi->type = rep.devType;
+ status = _XkbReadGetDeviceInfoReply(dpy, &rep, devi);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -329,83 +341,84 @@ XkbGetDeviceInfoChanges( Display * dpy,
}
Status
-XkbGetDeviceButtonActions( Display * dpy,
- XkbDeviceInfoPtr devi,
- Bool all,
- unsigned int first,
- unsigned int num)
+XkbGetDeviceButtonActions(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ Bool all,
+ unsigned int first,
+ unsigned int num)
{
- register xkbGetDeviceInfoReq * req;
- xkbGetDeviceInfoReply rep;
- Status status;
+ register xkbGetDeviceInfoReq *req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadMatch;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadMatch;
if (!devi)
- return BadValue;
+ return BadValue;
LockDisplay(dpy);
GetReq(kbGetDeviceInfo, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbGetDeviceInfo;
req->deviceSpec = devi->device_spec;
- req->wanted= XkbXI_ButtonActionsMask;
- req->allBtns= all;
- req->firstBtn= first;
- req->nBtns= num;
- req->ledClass= XkbDfltXIClass;
- req->ledID= XkbDfltXIId;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadLength;
+ req->wanted = XkbXI_ButtonActionsMask;
+ req->allBtns = all;
+ req->firstBtn = first;
+ req->nBtns = num;
+ req->ledClass = XkbDfltXIClass;
+ req->ledID = XkbDfltXIId;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
}
- devi->type= rep.devType;
- devi->supported= rep.supported;
- devi->unsupported= rep.unsupported;
- status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ devi->type = rep.devType;
+ devi->supported = rep.supported;
+ devi->unsupported = rep.unsupported;
+ status = _XkbReadGetDeviceInfoReply(dpy, &rep, devi);
UnlockDisplay(dpy);
SyncHandle();
return status;
}
Status
-XkbGetDeviceLedInfo( Display * dpy,
- XkbDeviceInfoPtr devi,
- unsigned int ledClass,
- unsigned int ledId,
- unsigned int which)
+XkbGetDeviceLedInfo(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int ledClass,
+ unsigned int ledId,
+ unsigned int which)
{
- register xkbGetDeviceInfoReq * req;
- xkbGetDeviceInfoReply rep;
- Status status;
+ register xkbGetDeviceInfoReq *req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadMatch;
- if (((which&XkbXI_IndicatorsMask)==0)||(which&(~XkbXI_IndicatorsMask)))
- return BadMatch;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadMatch;
+ if (((which & XkbXI_IndicatorsMask) == 0) ||
+ (which & (~XkbXI_IndicatorsMask)))
+ return BadMatch;
if (!devi)
- return BadValue;
+ return BadValue;
LockDisplay(dpy);
GetReq(kbGetDeviceInfo, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbGetDeviceInfo;
req->deviceSpec = devi->device_spec;
- req->wanted= which;
- req->allBtns= False;
- req->firstBtn= req->nBtns= 0;
- req->ledClass= ledClass;
- req->ledID= ledId;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadLength;
+ req->wanted = which;
+ req->allBtns = False;
+ req->firstBtn = req->nBtns = 0;
+ req->ledClass = ledClass;
+ req->ledID = ledId;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
}
- devi->type= rep.devType;
- devi->supported= rep.supported;
- devi->unsupported= rep.unsupported;
- status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ devi->type = rep.devType;
+ devi->supported = rep.supported;
+ devi->unsupported = rep.unsupported;
+ status = _XkbReadGetDeviceInfoReply(dpy, &rep, devi);
UnlockDisplay(dpy);
SyncHandle();
return status;
@@ -414,297 +427,298 @@ XkbGetDeviceLedInfo( Display * dpy,
/***====================================================================***/
typedef struct _LedInfoStuff {
- Bool used;
- XkbDeviceLedInfoPtr devli;
+ Bool used;
+ XkbDeviceLedInfoPtr devli;
} LedInfoStuff;
typedef struct _SetLedStuff {
- unsigned wanted;
- int num_info;
- int dflt_class;
- LedInfoStuff * dflt_kbd_fb;
- LedInfoStuff * dflt_led_fb;
- LedInfoStuff * info;
+ unsigned wanted;
+ int num_info;
+ int dflt_class;
+ LedInfoStuff *dflt_kbd_fb;
+ LedInfoStuff *dflt_led_fb;
+ LedInfoStuff *info;
} SetLedStuff;
static void
-_InitLedStuff(SetLedStuff *stuff,unsigned wanted,XkbDeviceInfoPtr devi)
+_InitLedStuff(SetLedStuff *stuff, unsigned wanted, XkbDeviceInfoPtr devi)
{
-int i;
-register XkbDeviceLedInfoPtr devli;
-
- bzero(stuff,sizeof(SetLedStuff));
- stuff->wanted= wanted;
- stuff->dflt_class= XkbXINone;
- if ((devi->num_leds<1)||((wanted&XkbXI_IndicatorsMask)==0))
- return;
- stuff->info= _XkbTypedCalloc(devi->num_leds,LedInfoStuff);
+ int i;
+ register XkbDeviceLedInfoPtr devli;
+
+ bzero(stuff, sizeof(SetLedStuff));
+ stuff->wanted = wanted;
+ stuff->dflt_class = XkbXINone;
+ if ((devi->num_leds < 1) || ((wanted & XkbXI_IndicatorsMask) == 0))
+ return;
+ stuff->info = _XkbTypedCalloc(devi->num_leds, LedInfoStuff);
if (!stuff->info)
- return;
- stuff->num_info= devi->num_leds;
- for (devli=&devi->leds[0],i=0;i<devi->num_leds;i++,devli++) {
- stuff->info[i].devli= devli;
- if (devli->led_class==KbdFeedbackClass) {
- stuff->dflt_class= KbdFeedbackClass;
- if (stuff->dflt_kbd_fb==NULL)
- stuff->dflt_kbd_fb= &stuff->info[i];
- }
- else if (devli->led_class==LedFeedbackClass) {
- if (stuff->dflt_class==XkbXINone)
- stuff->dflt_class= LedFeedbackClass;
- if (stuff->dflt_led_fb==NULL)
- stuff->dflt_led_fb= &stuff->info[i];
- }
+ return;
+ stuff->num_info = devi->num_leds;
+ for (devli = &devi->leds[0], i = 0; i < devi->num_leds; i++, devli++) {
+ stuff->info[i].devli = devli;
+ if (devli->led_class == KbdFeedbackClass) {
+ stuff->dflt_class = KbdFeedbackClass;
+ if (stuff->dflt_kbd_fb == NULL)
+ stuff->dflt_kbd_fb = &stuff->info[i];
+ }
+ else if (devli->led_class == LedFeedbackClass) {
+ if (stuff->dflt_class == XkbXINone)
+ stuff->dflt_class = LedFeedbackClass;
+ if (stuff->dflt_led_fb == NULL)
+ stuff->dflt_led_fb = &stuff->info[i];
+ }
}
return;
}
static void
-_FreeLedStuff(SetLedStuff *stuff)
+_FreeLedStuff(SetLedStuff * stuff)
{
- if ((stuff->num_info>0)&&(stuff->info!=NULL))
- _XkbFree(stuff->info);
- bzero(stuff,sizeof(SetLedStuff));
+ if (stuff->num_info > 0)
+ _XkbFree(stuff->info);
+ bzero(stuff, sizeof(SetLedStuff));
return;
}
static int
-_XkbSizeLedInfo(unsigned changed,XkbDeviceLedInfoPtr devli)
+_XkbSizeLedInfo(unsigned changed, XkbDeviceLedInfoPtr devli)
{
-register int i,size;
-register unsigned bit,namesNeeded,mapsNeeded;
-
- size= SIZEOF(xkbDeviceLedsWireDesc);
- namesNeeded= mapsNeeded= 0;
- if (changed&XkbXI_IndicatorNamesMask)
- namesNeeded= devli->names_present;
- if (changed&XkbXI_IndicatorMapsMask)
- mapsNeeded= devli->maps_present;
- if ((namesNeeded)||(mapsNeeded)) {
- for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
- if (namesNeeded&bit)
- size+= 4; /* atoms are 4 bytes on the wire */
- if (mapsNeeded&bit)
- size+= SIZEOF(xkbIndicatorMapWireDesc);
- }
+ register int i, size;
+ register unsigned bit, namesNeeded, mapsNeeded;
+
+ size = SIZEOF(xkbDeviceLedsWireDesc);
+ namesNeeded = mapsNeeded = 0;
+ if (changed & XkbXI_IndicatorNamesMask)
+ namesNeeded = devli->names_present;
+ if (changed & XkbXI_IndicatorMapsMask)
+ mapsNeeded = devli->maps_present;
+ if ((namesNeeded) || (mapsNeeded)) {
+ for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
+ if (namesNeeded & bit)
+ size += 4; /* atoms are 4 bytes on the wire */
+ if (mapsNeeded & bit)
+ size += SIZEOF(xkbIndicatorMapWireDesc);
+ }
}
return size;
}
static Bool
-_SizeMatches( SetLedStuff * stuff,
- XkbDeviceLedChangesPtr changes,
- int * sz_rtrn,
- int * nleds_rtrn)
+_SizeMatches(SetLedStuff *stuff,
+ XkbDeviceLedChangesPtr changes,
+ int *sz_rtrn,
+ int *nleds_rtrn)
{
-int i,nMatch,class,id;
-LedInfoStuff * linfo;
-Bool match;
-
- nMatch= 0;
- class= changes->led_class;
- id= changes->led_id;
- if (class==XkbDfltXIClass)
- class= stuff->dflt_class;
- for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
- XkbDeviceLedInfoPtr devli;
- LedInfoStuff * dflt;
-
- devli= linfo->devli;
- match= ((class==devli->led_class)||(class==XkbAllXIClasses));
- if (devli->led_class==KbdFeedbackClass) dflt= stuff->dflt_kbd_fb;
- else dflt= stuff->dflt_led_fb;
- match = (match && (id == devli->led_id)) ||
- (id == XkbAllXIIds) ||
- ((id == XkbDfltXIId) &&
- (linfo == dflt));
- if (match) {
- if (!linfo->used) {
- *sz_rtrn+= _XkbSizeLedInfo(stuff->wanted,devli);
- *nleds_rtrn+= 1;
- linfo->used= True;
- if ((class!=XkbAllXIClasses)&&(id!=XkbAllXIIds))
- return True;
- }
- nMatch++;
- linfo->used= True;
- }
+ int i, nMatch, class, id;
+ LedInfoStuff *linfo;
+ Bool match;
+
+ nMatch = 0;
+ class = changes->led_class;
+ id = changes->led_id;
+ if (class == XkbDfltXIClass)
+ class = stuff->dflt_class;
+ for (i = 0, linfo = &stuff->info[0]; i < stuff->num_info; i++, linfo++) {
+ XkbDeviceLedInfoPtr devli;
+ LedInfoStuff *dflt;
+
+ devli = linfo->devli;
+ match = ((class == devli->led_class) || (class == XkbAllXIClasses));
+ if (devli->led_class == KbdFeedbackClass)
+ dflt = stuff->dflt_kbd_fb;
+ else
+ dflt = stuff->dflt_led_fb;
+ match = (match && (id == devli->led_id)) ||
+ (id == XkbAllXIIds) ||
+ ((id == XkbDfltXIId) && (linfo == dflt));
+ if (match) {
+ if (!linfo->used) {
+ *sz_rtrn += _XkbSizeLedInfo(stuff->wanted, devli);
+ *nleds_rtrn += 1;
+ linfo->used = True;
+ if ((class != XkbAllXIClasses) && (id != XkbAllXIIds))
+ return True;
+ }
+ nMatch++;
+ linfo->used = True;
+ }
}
- return (nMatch>0);
+ return (nMatch > 0);
}
/***====================================================================***/
static Status
-_XkbSetDeviceInfoSize( XkbDeviceInfoPtr devi,
- XkbDeviceChangesPtr changes,
- SetLedStuff * stuff,
- int * sz_rtrn,
- int * num_leds_rtrn)
+_XkbSetDeviceInfoSize(XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff *stuff,
+ int *sz_rtrn,
+ int *num_leds_rtrn)
{
- *sz_rtrn= 0;
- if ((changes->changed&XkbXI_ButtonActionsMask)&&(changes->num_btns>0)) {
- if (!XkbXI_LegalDevBtn(devi,(changes->first_btn+changes->num_btns-1)))
- return BadMatch;
- *sz_rtrn+= changes->num_btns*SIZEOF(xkbActionWireDesc);
+ *sz_rtrn = 0;
+ if ((changes->changed & XkbXI_ButtonActionsMask) && (changes->num_btns > 0)) {
+ if (!XkbXI_LegalDevBtn
+ (devi, (changes->first_btn + changes->num_btns - 1)))
+ return BadMatch;
+ *sz_rtrn += changes->num_btns * SIZEOF(xkbActionWireDesc);
}
else {
- changes->changed&= ~XkbXI_ButtonActionsMask;
- changes->first_btn= changes->num_btns= 0;
+ changes->changed &= ~XkbXI_ButtonActionsMask;
+ changes->first_btn = changes->num_btns = 0;
}
- if ((changes->changed&XkbXI_IndicatorsMask)&&
- XkbLegalXILedClass(changes->leds.led_class)) {
- XkbDeviceLedChangesPtr leds;
-
- for (leds=&changes->leds;leds!=NULL;leds= leds->next) {
- if (!_SizeMatches(stuff,leds,sz_rtrn,num_leds_rtrn))
- return BadMatch;
- }
+ if ((changes->changed & XkbXI_IndicatorsMask) &&
+ XkbLegalXILedClass(changes->leds.led_class)) {
+ XkbDeviceLedChangesPtr leds;
+
+ for (leds = &changes->leds; leds != NULL; leds = leds->next) {
+ if (!_SizeMatches(stuff, leds, sz_rtrn, num_leds_rtrn))
+ return BadMatch;
+ }
}
else {
- changes->changed&= ~XkbXI_IndicatorsMask;
- *num_leds_rtrn= 0;
+ changes->changed &= ~XkbXI_IndicatorsMask;
+ *num_leds_rtrn = 0;
}
return Success;
}
static char *
-_XkbWriteLedInfo(char *wire,unsigned changed,XkbDeviceLedInfoPtr devli)
+_XkbWriteLedInfo(char *wire, unsigned changed, XkbDeviceLedInfoPtr devli)
{
-register int i;
-register unsigned bit,namesNeeded,mapsNeeded;
-xkbDeviceLedsWireDesc * lwire;
-
- namesNeeded= mapsNeeded= 0;
- if (changed&XkbXI_IndicatorNamesMask)
- namesNeeded= devli->names_present;
- if (changed&XkbXI_IndicatorMapsMask)
- mapsNeeded= devli->maps_present;
-
- lwire= (xkbDeviceLedsWireDesc *)wire;
- lwire->ledClass= devli->led_class;
- lwire->ledID= devli->led_id;
- lwire->namesPresent= namesNeeded;
- lwire->mapsPresent= mapsNeeded;
- lwire->physIndicators= devli->phys_indicators;
- lwire->state= devli->state;
- wire= (char *)&lwire[1];
+ register int i;
+ register unsigned bit, namesNeeded, mapsNeeded;
+ xkbDeviceLedsWireDesc *lwire;
+
+ namesNeeded = mapsNeeded = 0;
+ if (changed & XkbXI_IndicatorNamesMask)
+ namesNeeded = devli->names_present;
+ if (changed & XkbXI_IndicatorMapsMask)
+ mapsNeeded = devli->maps_present;
+
+ lwire = (xkbDeviceLedsWireDesc *) wire;
+ lwire->ledClass = devli->led_class;
+ lwire->ledID = devli->led_id;
+ lwire->namesPresent = namesNeeded;
+ lwire->mapsPresent = mapsNeeded;
+ lwire->physIndicators = devli->phys_indicators;
+ lwire->state = devli->state;
+ wire = (char *) &lwire[1];
if (namesNeeded) {
- CARD32 *awire;
- awire= (CARD32 *)wire;
- for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
- if (namesNeeded&bit) {
- *awire= (CARD32)devli->names[i];
- awire++;
- }
- }
- wire= (char *)awire;
+ CARD32 *awire = (CARD32 *) wire;
+
+ for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
+ if (namesNeeded & bit) {
+ *awire = (CARD32) devli->names[i];
+ awire++;
+ }
+ }
+ wire = (char *) awire;
}
if (mapsNeeded) {
- xkbIndicatorMapWireDesc *mwire;
-
- mwire= (xkbIndicatorMapWireDesc *)wire;
- for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
- if (mapsNeeded&bit) {
- XkbIndicatorMapPtr map;
- map= &devli->maps[i];
- mwire->flags= map->flags;
- mwire->whichGroups= map->which_groups;
- mwire->groups= map->groups;
- mwire->whichMods= map->which_mods;
- mwire->mods= map->mods.mask;
- mwire->realMods= map->mods.real_mods;
- mwire->virtualMods= map->mods.vmods;
- mwire->ctrls= map->ctrls;
- mwire++;
- }
- }
- wire= (char *)mwire;
+ xkbIndicatorMapWireDesc *mwire = (xkbIndicatorMapWireDesc *) wire;
+
+ for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
+ if (mapsNeeded & bit) {
+ XkbIndicatorMapPtr map = &devli->maps[i];
+
+ mwire->flags = map->flags;
+ mwire->whichGroups = map->which_groups;
+ mwire->groups = map->groups;
+ mwire->whichMods = map->which_mods;
+ mwire->mods = map->mods.mask;
+ mwire->realMods = map->mods.real_mods;
+ mwire->virtualMods = map->mods.vmods;
+ mwire->ctrls = map->ctrls;
+ mwire++;
+ }
+ }
+ wire = (char *) mwire;
}
return wire;
}
static int
-_XkbWriteSetDeviceInfo( char * wire,
- XkbDeviceChangesPtr changes,
- SetLedStuff * stuff,
- XkbDeviceInfoPtr devi)
+_XkbWriteSetDeviceInfo(char *wire,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff *stuff,
+ XkbDeviceInfoPtr devi)
{
-char *start;
-
- start= wire;
- if (changes->changed&XkbXI_ButtonActionsMask) {
- int size;
- size= changes->num_btns*SIZEOF(xkbActionWireDesc);
- memcpy(wire,(char *)&devi->btn_acts[changes->first_btn],size);
- wire+= size;
+ char *start = wire;
+
+ if (changes->changed & XkbXI_ButtonActionsMask) {
+ int size = changes->num_btns * SIZEOF(xkbActionWireDesc);
+
+ memcpy(wire, (char *) &devi->btn_acts[changes->first_btn], size);
+ wire += size;
}
- if (changes->changed&XkbXI_IndicatorsMask) {
- register int i;
- register LedInfoStuff *linfo;
-
- for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
- if (linfo->used) {
- register char *new_wire;
- new_wire= _XkbWriteLedInfo(wire,stuff->wanted,linfo->devli);
- if (!new_wire)
- return wire-start;
- wire= new_wire;
- }
- }
+ if (changes->changed & XkbXI_IndicatorsMask) {
+ register int i;
+ register LedInfoStuff *linfo;
+
+ for (i = 0, linfo = &stuff->info[0]; i < stuff->num_info; i++, linfo++) {
+ if (linfo->used) {
+ register char *new_wire;
+
+ new_wire = _XkbWriteLedInfo(wire, stuff->wanted, linfo->devli);
+ if (!new_wire)
+ return wire - start;
+ wire = new_wire;
+ }
+ }
}
- return wire-start;
+ return wire - start;
}
Bool
-XkbSetDeviceInfo( Display * dpy,
- unsigned which,
- XkbDeviceInfoPtr devi)
+XkbSetDeviceInfo(Display *dpy, unsigned which, XkbDeviceInfoPtr devi)
{
register xkbSetDeviceInfoReq *req;
- Status ok = 0;
- int size,nLeds;
- XkbInfoPtr xkbi;
- XkbDeviceChangesRec changes;
- SetLedStuff lstuff;
+ Status ok = 0;
+ int size, nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!devi) || (which&(~XkbXI_AllDeviceFeaturesMask)) ||
- ((which&XkbXI_ButtonActionsMask)&&(!XkbXI_DevHasBtnActs(devi)))||
- ((which&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
- return False;
-
- bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
- changes.changed= which;
- changes.first_btn= 0;
- changes.num_btns= devi->num_btns;
- changes.leds.led_class= XkbAllXIClasses;
- changes.leds.led_id= XkbAllXIIds;
- changes.leds.defined= 0;
- size= nLeds= 0;
- _InitLedStuff(&lstuff,changes.changed,devi);
- if (_XkbSetDeviceInfoSize(devi,&changes,&lstuff,&size,&nLeds)!=Success)
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!devi) || (which & (~XkbXI_AllDeviceFeaturesMask)) ||
+ ((which & XkbXI_ButtonActionsMask) && (!XkbXI_DevHasBtnActs(devi))) ||
+ ((which & XkbXI_IndicatorsMask) && (!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ bzero((char *) &changes, sizeof(XkbDeviceChangesRec));
+ changes.changed = which;
+ changes.first_btn = 0;
+ changes.num_btns = devi->num_btns;
+ changes.leds.led_class = XkbAllXIClasses;
+ changes.leds.led_id = XkbAllXIIds;
+ changes.leds.defined = 0;
+ size = nLeds = 0;
+ _InitLedStuff(&lstuff, changes.changed, devi);
+ if (_XkbSetDeviceInfoSize(devi, &changes, &lstuff, &size, &nLeds) !=
+ Success)
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetDeviceInfo, req);
- req->length+= size/4;
- req->reqType= xkbi->codes->major_opcode;
- req->xkbReqType= X_kbSetDeviceInfo;
- req->deviceSpec= devi->device_spec;
- req->firstBtn= changes.first_btn;
- req->nBtns= changes.num_btns;
- req->change= changes.changed;
- req->nDeviceLedFBs= nLeds;
- if (size>0) {
- char * wire;
- BufAlloc(char *,wire,size);
- ok= (wire!=NULL)&&
- (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ req->length += size / 4;
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->firstBtn = changes.first_btn;
+ req->nBtns = changes.num_btns;
+ req->change = changes.changed;
+ req->nDeviceLedFBs = nLeds;
+ if (size > 0) {
+ char *wire;
+
+ BufAlloc(char *, wire, size);
+ ok = (wire != NULL) &&
+ (_XkbWriteSetDeviceInfo(wire, &changes, &lstuff, devi) == size);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -714,45 +728,47 @@ XkbSetDeviceInfo( Display * dpy,
}
Bool
-XkbChangeDeviceInfo( Display * dpy,
- XkbDeviceInfoPtr devi,
- XkbDeviceChangesPtr changes)
+XkbChangeDeviceInfo(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
{
register xkbSetDeviceInfoReq *req;
- Status ok = 0;
- int size,nLeds;
- XkbInfoPtr xkbi;
- SetLedStuff lstuff;
+ Status ok = 0;
+ int size, nLeds;
+ XkbInfoPtr xkbi;
+ SetLedStuff lstuff;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!devi) || (changes->changed&(~XkbXI_AllDeviceFeaturesMask)) ||
- ((changes->changed&XkbXI_ButtonActionsMask)&&
- (!XkbXI_DevHasBtnActs(devi)))||
- ((changes->changed&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
- return False;
-
- size= nLeds= 0;
- _InitLedStuff(&lstuff,changes->changed,devi);
- if (_XkbSetDeviceInfoSize(devi,changes,&lstuff,&size,&nLeds)!=Success)
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!devi) || (changes->changed & (~XkbXI_AllDeviceFeaturesMask)) ||
+ ((changes->changed & XkbXI_ButtonActionsMask) &&
+ (!XkbXI_DevHasBtnActs(devi))) ||
+ ((changes->changed & XkbXI_IndicatorsMask) &&
+ (!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ size = nLeds = 0;
+ _InitLedStuff(&lstuff, changes->changed, devi);
+ if (_XkbSetDeviceInfoSize(devi, changes, &lstuff, &size, &nLeds) != Success)
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetDeviceInfo, req);
- req->length+= size/4;
- req->reqType= xkbi->codes->major_opcode;
- req->xkbReqType= X_kbSetDeviceInfo;
- req->deviceSpec= devi->device_spec;
- req->firstBtn= changes->first_btn;
- req->nBtns= changes->num_btns;
- req->change= changes->changed;
- req->nDeviceLedFBs= nLeds;
- if (size>0) {
- char * wire;
- BufAlloc(char *,wire,size);
- ok= (wire!=NULL)&&
- (_XkbWriteSetDeviceInfo(wire,changes,&lstuff,devi)==size);
+ req->length += size / 4;
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->firstBtn = changes->first_btn;
+ req->nBtns = changes->num_btns;
+ req->change = changes->changed;
+ req->nDeviceLedFBs = nLeds;
+ if (size > 0) {
+ char *wire;
+
+ BufAlloc(char *, wire, size);
+ ok = (wire != NULL) &&
+ (_XkbWriteSetDeviceInfo(wire, changes, &lstuff, devi) == size);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -762,62 +778,64 @@ XkbChangeDeviceInfo( Display * dpy,
}
Bool
-XkbSetDeviceLedInfo( Display * dpy,
- XkbDeviceInfoPtr devi,
- unsigned ledClass,
- unsigned ledID,
- unsigned which)
+XkbSetDeviceLedInfo(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned ledClass,
+ unsigned ledID,
+ unsigned which)
{
return False;
}
Bool
-XkbSetDeviceButtonActions( Display * dpy,
- XkbDeviceInfoPtr devi,
- unsigned int first,
- unsigned int nBtns)
+XkbSetDeviceButtonActions(Display *dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int first,
+ unsigned int nBtns)
{
register xkbSetDeviceInfoReq *req;
- Status ok = 0;
- int size,nLeds;
- XkbInfoPtr xkbi;
- XkbDeviceChangesRec changes;
- SetLedStuff lstuff;
+ Status ok = 0;
+ int size, nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!devi)||(!XkbXI_DevHasBtnActs(devi))||(first+nBtns>devi->num_btns))
- return False;
- if (nBtns==0)
- return True;
-
- bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
- changes.changed= XkbXI_ButtonActionsMask;
- changes.first_btn= first;
- changes.num_btns= nBtns;
- changes.leds.led_class= XkbXINone;
- changes.leds.led_id= XkbXINone;
- changes.leds.defined= 0;
- size= nLeds= 0;
- if (_XkbSetDeviceInfoSize(devi,&changes,NULL,&size,&nLeds)!=Success)
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!devi) || (!XkbXI_DevHasBtnActs(devi)) ||
+ (first + nBtns > devi->num_btns))
+ return False;
+ if (nBtns == 0)
+ return True;
+
+ bzero((char *) &changes, sizeof(XkbDeviceChangesRec));
+ changes.changed = XkbXI_ButtonActionsMask;
+ changes.first_btn = first;
+ changes.num_btns = nBtns;
+ changes.leds.led_class = XkbXINone;
+ changes.leds.led_id = XkbXINone;
+ changes.leds.defined = 0;
+ size = nLeds = 0;
+ if (_XkbSetDeviceInfoSize(devi, &changes, NULL, &size, &nLeds) != Success)
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetDeviceInfo, req);
- req->length+= size/4;
- req->reqType= xkbi->codes->major_opcode;
- req->xkbReqType= X_kbSetDeviceInfo;
- req->deviceSpec= devi->device_spec;
- req->firstBtn= changes.first_btn;
- req->nBtns= changes.num_btns;
- req->change= changes.changed;
- req->nDeviceLedFBs= nLeds;
- if (size>0) {
- char * wire;
- BufAlloc(char *,wire,size);
- ok= (wire!=NULL)&&
- (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ req->length += size / 4;
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->firstBtn = changes.first_btn;
+ req->nBtns = changes.num_btns;
+ req->change = changes.changed;
+ req->nDeviceLedFBs = nLeds;
+ if (size > 0) {
+ char *wire;
+
+ BufAlloc(char *, wire, size);
+ ok = (wire != NULL) &&
+ (_XkbWriteSetDeviceInfo(wire, &changes, &lstuff, devi) == size);
}
UnlockDisplay(dpy);
SyncHandle();
diff --git a/nx-X11/lib/X11/XKBGAlloc.c b/nx-X11/lib/X11/XKBGAlloc.c
index 46b997b7f..ab05f8d88 100644
--- a/nx-X11/lib/X11/XKBGAlloc.c
+++ b/nx-X11/lib/X11/XKBGAlloc.c
@@ -24,13 +24,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#elif defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifndef XKB_IN_SERVER
#include <stdio.h>
#include "Xlibint.h"
@@ -38,113 +35,97 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/extensions/XKBgeom.h>
#include <nx-X11/extensions/XKBproto.h>
-#else
-
-#include <stdio.h>
-#include <nx-X11/X.h>
-#include <nx-X11/Xproto.h>
-#include "misc.h"
-#include "inputstr.h"
-#include <nx-X11/extensions/XKBsrv.h>
-#include <nx-X11/extensions/XKBgeom.h>
-
-#endif /* XKB_IN_SERVER */
-
-#ifdef X_NOT_POSIX
-#define Size_t unsigned int
-#else
-#define Size_t size_t
-#endif
-
/***====================================================================***/
static void
-_XkbFreeGeomLeafElems( Bool freeAll,
- int first,
- int count,
- unsigned short * num_inout,
- unsigned short * sz_inout,
- char ** elems,
- unsigned int elem_sz)
-{
- if ((freeAll)||(*elems==NULL)) {
- *num_inout= *sz_inout= 0;
- if (*elems!=NULL) {
- _XkbFree(*elems);
- *elems= NULL;
- }
- return;
- }
-
- if ((first>=(*num_inout))||(first<0)||(count<1))
- return;
-
- if (first+count>=(*num_inout)) {
- /* truncating the array is easy */
- (*num_inout)= first;
+_XkbFreeGeomLeafElems(Bool freeAll,
+ int first,
+ int count,
+ unsigned short *num_inout,
+ unsigned short *sz_inout,
+ char **elems,
+ unsigned int elem_sz)
+{
+ if ((freeAll) || (*elems == NULL)) {
+ *num_inout = *sz_inout = 0;
+ if (*elems != NULL) {
+ _XkbFree(*elems);
+ *elems = NULL;
+ }
+ return;
+ }
+
+ if ((first >= (*num_inout)) || (first < 0) || (count < 1))
+ return;
+
+ if (first + count >= (*num_inout)) {
+ /* truncating the array is easy */
+ (*num_inout) = first;
}
else {
- char * ptr;
- int extra;
- ptr= *elems;
- extra= ((*num_inout)-(first+count))*elem_sz;
- if (extra>0)
- memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],extra);
- (*num_inout)-= count;
+ char *ptr;
+ int extra;
+
+ ptr = *elems;
+ extra = ((*num_inout) - (first + count)) * elem_sz;
+ if (extra > 0)
+ memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz],
+ extra);
+ (*num_inout) -= count;
}
return;
}
-typedef void (*ContentsClearFunc)(
- char * /* priv */
+typedef void (*ContentsClearFunc) (
+ char * /* priv */
);
static void
-_XkbFreeGeomNonLeafElems( Bool freeAll,
- int first,
- int count,
- unsigned short * num_inout,
- unsigned short * sz_inout,
- char ** elems,
- unsigned int elem_sz,
- ContentsClearFunc freeFunc)
-{
-register int i;
-register char *ptr;
+_XkbFreeGeomNonLeafElems(Bool freeAll,
+ int first,
+ int count,
+ unsigned short *num_inout,
+ unsigned short *sz_inout,
+ char **elems,
+ unsigned int elem_sz,
+ ContentsClearFunc freeFunc)
+{
+ register int i;
+ register char *ptr;
if (freeAll) {
- first= 0;
- count= (*num_inout);
+ first = 0;
+ count = (*num_inout);
}
- else if ((first>=(*num_inout))||(first<0)||(count<1))
- return;
- else if (first+count>(*num_inout))
- count= (*num_inout)-first;
- if (*elems==NULL)
- return;
+ else if ((first >= (*num_inout)) || (first < 0) || (count < 1))
+ return;
+ else if (first + count > (*num_inout))
+ count = (*num_inout) - first;
+ if (*elems == NULL)
+ return;
if (freeFunc) {
- ptr= *elems;
- ptr+= first*elem_sz;
- for (i=0;i<count;i++) {
- (*freeFunc)(ptr);
- ptr+= elem_sz;
- }
+ ptr = *elems;
+ ptr += first * elem_sz;
+ for (i = 0; i < count; i++) {
+ (*freeFunc) (ptr);
+ ptr += elem_sz;
+ }
}
if (freeAll) {
- (*num_inout)= (*sz_inout)= 0;
- if (*elems) {
- _XkbFree(*elems);
- *elems= NULL;
- }
- }
- else if (first+count>=(*num_inout))
- *num_inout= first;
+ (*num_inout) = (*sz_inout) = 0;
+ if (*elems) {
+ _XkbFree(*elems);
+ *elems = NULL;
+ }
+ }
+ else if (first + count >= (*num_inout))
+ *num_inout = first;
else {
- i= ((*num_inout)-(first+count))*elem_sz;
- ptr= *elems;
- memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],i);
- (*num_inout)-= count;
+ i = ((*num_inout) - (first + count)) * elem_sz;
+ ptr = *elems;
+ memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz], i);
+ (*num_inout) -= count;
}
return;
}
@@ -154,44 +135,38 @@ register char *ptr;
static void
_XkbClearProperty(char *prop_in)
{
-XkbPropertyPtr prop= (XkbPropertyPtr)prop_in;
+ XkbPropertyPtr prop = (XkbPropertyPtr) prop_in;
if (prop->name) {
- _XkbFree(prop->name);
- prop->name= NULL;
+ _XkbFree(prop->name);
+ prop->name = NULL;
}
if (prop->value) {
- _XkbFree(prop->value);
- prop->value= NULL;
+ _XkbFree(prop->value);
+ prop->value = NULL;
}
return;
}
void
-XkbFreeGeomProperties( XkbGeometryPtr geom,
- int first,
- int count,
- Bool freeAll)
-{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &geom->num_properties,&geom->sz_properties,
- (char **)&geom->properties,
- sizeof(XkbPropertyRec),_XkbClearProperty);
+XkbFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll)
+{
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &geom->num_properties, &geom->sz_properties,
+ (char **) &geom->properties,
+ sizeof(XkbPropertyRec), _XkbClearProperty);
return;
}
/***====================================================================***/
void
-XkbFreeGeomKeyAliases( XkbGeometryPtr geom,
- int first,
- int count,
- Bool freeAll)
-{
- _XkbFreeGeomLeafElems(freeAll,first,count,
- &geom->num_key_aliases,&geom->sz_key_aliases,
- (char **)&geom->key_aliases,
- sizeof(XkbKeyAliasRec));
+XkbFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll)
+{
+ _XkbFreeGeomLeafElems(freeAll, first, count,
+ &geom->num_key_aliases, &geom->sz_key_aliases,
+ (char **) &geom->key_aliases,
+ sizeof(XkbKeyAliasRec));
return;
}
@@ -200,32 +175,31 @@ XkbFreeGeomKeyAliases( XkbGeometryPtr geom,
static void
_XkbClearColor(char *color_in)
{
-XkbColorPtr color= (XkbColorPtr)color_in;
+ XkbColorPtr color = (XkbColorPtr) color_in;
- if (color->spec)
- _XkbFree(color->spec);
+ _XkbFree(color->spec);
return;
}
void
-XkbFreeGeomColors(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+XkbFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &geom->num_colors,&geom->sz_colors,
- (char **)&geom->colors,
- sizeof(XkbColorRec),_XkbClearColor);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &geom->num_colors, &geom->sz_colors,
+ (char **) &geom->colors,
+ sizeof(XkbColorRec), _XkbClearColor);
return;
}
/***====================================================================***/
void
-XkbFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
+XkbFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll)
{
- _XkbFreeGeomLeafElems(freeAll,first,count,
- &outline->num_points,&outline->sz_points,
- (char **)&outline->points,
- sizeof(XkbPointRec));
+ _XkbFreeGeomLeafElems(freeAll, first, count,
+ &outline->num_points, &outline->sz_points,
+ (char **) &outline->points,
+ sizeof(XkbPointRec));
return;
}
@@ -234,20 +208,20 @@ XkbFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
static void
_XkbClearOutline(char *outline_in)
{
-XkbOutlinePtr outline= (XkbOutlinePtr)outline_in;
+ XkbOutlinePtr outline = (XkbOutlinePtr) outline_in;
- if (outline->points!=NULL)
- XkbFreeGeomPoints(outline,0,outline->num_points,True);
+ if (outline->points != NULL)
+ XkbFreeGeomPoints(outline, 0, outline->num_points, True);
return;
}
void
-XkbFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
+XkbFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &shape->num_outlines,&shape->sz_outlines,
- (char **)&shape->outlines,
- sizeof(XkbOutlineRec),_XkbClearOutline);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &shape->num_outlines, &shape->sz_outlines,
+ (char **) &shape->outlines,
+ sizeof(XkbOutlineRec), _XkbClearOutline);
return;
}
@@ -257,32 +231,32 @@ XkbFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
static void
_XkbClearShape(char *shape_in)
{
-XkbShapePtr shape= (XkbShapePtr)shape_in;
+ XkbShapePtr shape = (XkbShapePtr) shape_in;
if (shape->outlines)
- XkbFreeGeomOutlines(shape,0,shape->num_outlines,True);
+ XkbFreeGeomOutlines(shape, 0, shape->num_outlines, True);
return;
}
void
-XkbFreeGeomShapes(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+XkbFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &geom->num_shapes,&geom->sz_shapes,
- (char **)&geom->shapes,
- sizeof(XkbShapeRec),_XkbClearShape);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &geom->num_shapes, &geom->sz_shapes,
+ (char **) &geom->shapes,
+ sizeof(XkbShapeRec), _XkbClearShape);
return;
}
/***====================================================================***/
void
-XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
+XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count, Bool freeAll)
{
- _XkbFreeGeomLeafElems(freeAll,first,count,
- &row->num_keys,&row->sz_keys,
- (char **)&row->keys,
- sizeof(XkbOverlayKeyRec));
+ _XkbFreeGeomLeafElems(freeAll, first, count,
+ &row->num_keys, &row->sz_keys,
+ (char **) &row->keys,
+ sizeof(XkbOverlayKeyRec));
return;
}
@@ -291,20 +265,21 @@ XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
static void
_XkbClearOverlayRow(char *row_in)
{
-XkbOverlayRowPtr row= (XkbOverlayRowPtr)row_in;
+ XkbOverlayRowPtr row = (XkbOverlayRowPtr) row_in;
- if (row->keys!=NULL)
- XkbFreeGeomOverlayKeys(row,0,row->num_keys,True);
+ if (row->keys != NULL)
+ XkbFreeGeomOverlayKeys(row, 0, row->num_keys, True);
return;
}
void
-XkbFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
+XkbFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
+ Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &overlay->num_rows,&overlay->sz_rows,
- (char **)&overlay->rows,
- sizeof(XkbOverlayRowRec),_XkbClearOverlayRow);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &overlay->num_rows, &overlay->sz_rows,
+ (char **) &overlay->rows,
+ sizeof(XkbOverlayRowRec), _XkbClearOverlayRow);
return;
}
@@ -313,32 +288,32 @@ XkbFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
static void
_XkbClearOverlay(char *overlay_in)
{
-XkbOverlayPtr overlay= (XkbOverlayPtr)overlay_in;
+ XkbOverlayPtr overlay = (XkbOverlayPtr) overlay_in;
- if (overlay->rows!=NULL)
- XkbFreeGeomOverlayRows(overlay,0,overlay->num_rows,True);
+ if (overlay->rows != NULL)
+ XkbFreeGeomOverlayRows(overlay, 0, overlay->num_rows, True);
return;
}
void
-XkbFreeGeomOverlays(XkbSectionPtr section,int first,int count,Bool freeAll)
+XkbFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &section->num_overlays,&section->sz_overlays,
- (char **)&section->overlays,
- sizeof(XkbOverlayRec),_XkbClearOverlay);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &section->num_overlays, &section->sz_overlays,
+ (char **) &section->overlays,
+ sizeof(XkbOverlayRec), _XkbClearOverlay);
return;
}
/***====================================================================***/
void
-XkbFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
+XkbFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll)
{
- _XkbFreeGeomLeafElems(freeAll,first,count,
- &row->num_keys,&row->sz_keys,
- (char **)&row->keys,
- sizeof(XkbKeyRec));
+ _XkbFreeGeomLeafElems(freeAll, first, count,
+ &row->num_keys, &row->sz_keys,
+ (char **) &row->keys,
+ sizeof(XkbKeyRec));
return;
}
@@ -347,20 +322,20 @@ XkbFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
static void
_XkbClearRow(char *row_in)
{
-XkbRowPtr row= (XkbRowPtr)row_in;
+ XkbRowPtr row = (XkbRowPtr) row_in;
- if (row->keys!=NULL)
- XkbFreeGeomKeys(row,0,row->num_keys,True);
+ if (row->keys != NULL)
+ XkbFreeGeomKeys(row, 0, row->num_keys, True);
return;
}
void
-XkbFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
+XkbFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &section->num_rows,&section->sz_rows,
- (char **)&section->rows,
- sizeof(XkbRowRec),_XkbClearRow);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &section->num_rows, &section->sz_rows,
+ (char **) &section->rows,
+ sizeof(XkbRowRec), _XkbClearRow);
}
/***====================================================================***/
@@ -368,24 +343,24 @@ XkbFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
static void
_XkbClearSection(char *section_in)
{
-XkbSectionPtr section= (XkbSectionPtr)section_in;
+ XkbSectionPtr section = (XkbSectionPtr) section_in;
- if (section->rows!=NULL)
- XkbFreeGeomRows(section,0,section->num_rows,True);
- if (section->doodads!=NULL) {
- XkbFreeGeomDoodads(section->doodads,section->num_doodads,True);
- section->doodads= NULL;
+ if (section->rows != NULL)
+ XkbFreeGeomRows(section, 0, section->num_rows, True);
+ if (section->doodads != NULL) {
+ XkbFreeGeomDoodads(section->doodads, section->num_doodads, True);
+ section->doodads = NULL;
}
return;
}
void
-XkbFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+XkbFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll)
{
- _XkbFreeGeomNonLeafElems(freeAll,first,count,
- &geom->num_sections,&geom->sz_sections,
- (char **)&geom->sections,
- sizeof(XkbSectionRec),_XkbClearSection);
+ _XkbFreeGeomNonLeafElems(freeAll, first, count,
+ &geom->num_sections, &geom->sz_sections,
+ (char **) &geom->sections,
+ sizeof(XkbSectionRec), _XkbClearSection);
return;
}
@@ -394,77 +369,77 @@ XkbFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
static void
_XkbClearDoodad(char *doodad_in)
{
-XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in;
+ XkbDoodadPtr doodad = (XkbDoodadPtr) doodad_in;
switch (doodad->any.type) {
- case XkbTextDoodad:
- {
- if (doodad->text.text!=NULL) {
- _XkbFree(doodad->text.text);
- doodad->text.text= NULL;
- }
- if (doodad->text.font!=NULL) {
- _XkbFree(doodad->text.font);
- doodad->text.font= NULL;
- }
- }
- break;
- case XkbLogoDoodad:
- {
- if (doodad->logo.logo_name!=NULL) {
- _XkbFree(doodad->logo.logo_name);
- doodad->logo.logo_name= NULL;
- }
- }
- break;
+ case XkbTextDoodad:
+ {
+ if (doodad->text.text != NULL) {
+ _XkbFree(doodad->text.text);
+ doodad->text.text = NULL;
+ }
+ if (doodad->text.font != NULL) {
+ _XkbFree(doodad->text.font);
+ doodad->text.font = NULL;
+ }
+ }
+ break;
+ case XkbLogoDoodad:
+ {
+ if (doodad->logo.logo_name != NULL) {
+ _XkbFree(doodad->logo.logo_name);
+ doodad->logo.logo_name = NULL;
+ }
+ }
+ break;
}
return;
}
void
-XkbFreeGeomDoodads(XkbDoodadPtr doodads,int nDoodads,Bool freeAll)
+XkbFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll)
{
-register int i;
-register XkbDoodadPtr doodad;
+ register int i;
+ register XkbDoodadPtr doodad;
if (doodads) {
- for (i=0,doodad= doodads;i<nDoodads;i++,doodad++) {
- _XkbClearDoodad((char *)doodad);
- }
- if (freeAll)
- _XkbFree(doodads);
+ for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++) {
+ _XkbClearDoodad((char *) doodad);
+ }
+ if (freeAll)
+ _XkbFree(doodads);
}
return;
}
void
-XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
+XkbFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap)
{
- if (geom==NULL)
- return;
+ if (geom == NULL)
+ return;
if (freeMap)
- which= XkbGeomAllMask;
- if ((which&XkbGeomPropertiesMask)&&(geom->properties!=NULL))
- XkbFreeGeomProperties(geom,0,geom->num_properties,True);
- if ((which&XkbGeomColorsMask)&&(geom->colors!=NULL))
- XkbFreeGeomColors(geom,0,geom->num_colors,True);
- if ((which&XkbGeomShapesMask)&&(geom->shapes!=NULL))
- XkbFreeGeomShapes(geom,0,geom->num_shapes,True);
- if ((which&XkbGeomSectionsMask)&&(geom->sections!=NULL))
- XkbFreeGeomSections(geom,0,geom->num_sections,True);
- if ((which&XkbGeomDoodadsMask)&&(geom->doodads!= NULL)) {
- XkbFreeGeomDoodads(geom->doodads,geom->num_doodads,True);
- geom->doodads= NULL;
- geom->num_doodads= geom->sz_doodads= 0;
- }
- if ((which&XkbGeomKeyAliasesMask)&&(geom->key_aliases!=NULL))
- XkbFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True);
+ which = XkbGeomAllMask;
+ if ((which & XkbGeomPropertiesMask) && (geom->properties != NULL))
+ XkbFreeGeomProperties(geom, 0, geom->num_properties, True);
+ if ((which & XkbGeomColorsMask) && (geom->colors != NULL))
+ XkbFreeGeomColors(geom, 0, geom->num_colors, True);
+ if ((which & XkbGeomShapesMask) && (geom->shapes != NULL))
+ XkbFreeGeomShapes(geom, 0, geom->num_shapes, True);
+ if ((which & XkbGeomSectionsMask) && (geom->sections != NULL))
+ XkbFreeGeomSections(geom, 0, geom->num_sections, True);
+ if ((which & XkbGeomDoodadsMask) && (geom->doodads != NULL)) {
+ XkbFreeGeomDoodads(geom->doodads, geom->num_doodads, True);
+ geom->doodads = NULL;
+ geom->num_doodads = geom->sz_doodads = 0;
+ }
+ if ((which & XkbGeomKeyAliasesMask) && (geom->key_aliases != NULL))
+ XkbFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
if (freeMap) {
- if (geom->label_font!=NULL) {
- _XkbFree(geom->label_font);
- geom->label_font= NULL;
- }
- _XkbFree(geom);
+ if (geom->label_font != NULL) {
+ _XkbFree(geom->label_font);
+ geom->label_font = NULL;
+ }
+ _XkbFree(geom);
}
return;
}
@@ -472,341 +447,338 @@ XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
/***====================================================================***/
static Status
-_XkbGeomAlloc( XPointer * old,
- unsigned short * num,
- unsigned short * total,
- int num_new,
- Size_t sz_elem)
-{
- if (num_new<1)
- return Success;
- if ((*old)==NULL)
- *num= *total= 0;
-
- if ((*num)+num_new<=(*total))
- return Success;
-
- *total= (*num)+num_new;
- if ((*old)!=NULL)
- (*old)= (XPointer)_XkbRealloc((*old),(*total)*sz_elem);
- else (*old)= (XPointer)_XkbCalloc((*total),sz_elem);
- if ((*old)==NULL) {
- *total= *num= 0;
- return BadAlloc;
- }
-
- if (*num>0) {
- char *tmp= (char *)(*old);
- bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
+_XkbGeomAlloc(XPointer *old,
+ unsigned short *num,
+ unsigned short *total,
+ int num_new,
+ size_t sz_elem)
+{
+ if (num_new < 1)
+ return Success;
+ if ((*old) == NULL)
+ *num = *total = 0;
+
+ if ((*num) + num_new <= (*total))
+ return Success;
+
+ *total = (*num) + num_new;
+ if ((*old) != NULL)
+ (*old) = (XPointer) _XkbRealloc((*old), (*total) * sz_elem);
+ else
+ (*old) = (XPointer) _XkbCalloc((*total), sz_elem);
+ if ((*old) == NULL) {
+ *total = *num = 0;
+ return BadAlloc;
+ }
+
+ if (*num > 0) {
+ char *tmp = (char *) (*old);
+ bzero(&tmp[sz_elem * (*num)], (num_new * sz_elem));
}
return Success;
}
-#define _XkbAllocProps(g,n) _XkbGeomAlloc((XPointer *)&(g)->properties,\
- &(g)->num_properties,&(g)->sz_properties,\
- (n),sizeof(XkbPropertyRec))
-#define _XkbAllocColors(g,n) _XkbGeomAlloc((XPointer *)&(g)->colors,\
- &(g)->num_colors,&(g)->sz_colors,\
- (n),sizeof(XkbColorRec))
-#define _XkbAllocShapes(g,n) _XkbGeomAlloc((XPointer *)&(g)->shapes,\
- &(g)->num_shapes,&(g)->sz_shapes,\
- (n),sizeof(XkbShapeRec))
-#define _XkbAllocSections(g,n) _XkbGeomAlloc((XPointer *)&(g)->sections,\
- &(g)->num_sections,&(g)->sz_sections,\
- (n),sizeof(XkbSectionRec))
-#define _XkbAllocDoodads(g,n) _XkbGeomAlloc((XPointer *)&(g)->doodads,\
- &(g)->num_doodads,&(g)->sz_doodads,\
- (n),sizeof(XkbDoodadRec))
-#define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases,\
- &(g)->num_key_aliases,&(g)->sz_key_aliases,\
- (n),sizeof(XkbKeyAliasRec))
-
-#define _XkbAllocOutlines(s,n) _XkbGeomAlloc((XPointer *)&(s)->outlines,\
- &(s)->num_outlines,&(s)->sz_outlines,\
- (n),sizeof(XkbOutlineRec))
-#define _XkbAllocRows(s,n) _XkbGeomAlloc((XPointer *)&(s)->rows,\
- &(s)->num_rows,&(s)->sz_rows,\
- (n),sizeof(XkbRowRec))
-#define _XkbAllocPoints(o,n) _XkbGeomAlloc((XPointer *)&(o)->points,\
- &(o)->num_points,&(o)->sz_points,\
- (n),sizeof(XkbPointRec))
-#define _XkbAllocKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
- &(r)->num_keys,&(r)->sz_keys,\
- (n),sizeof(XkbKeyRec))
-#define _XkbAllocOverlays(s,n) _XkbGeomAlloc((XPointer *)&(s)->overlays,\
- &(s)->num_overlays,&(s)->sz_overlays,\
- (n),sizeof(XkbOverlayRec))
-#define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((XPointer *)&(o)->rows,\
- &(o)->num_rows,&(o)->sz_rows,\
- (n),sizeof(XkbOverlayRowRec))
-#define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
- &(r)->num_keys,&(r)->sz_keys,\
- (n),sizeof(XkbOverlayKeyRec))
+#define _XkbAllocProps(g, n) _XkbGeomAlloc((XPointer *)&(g)->properties, \
+ &(g)->num_properties, &(g)->sz_properties, \
+ (n), sizeof(XkbPropertyRec))
+#define _XkbAllocColors(g, n) _XkbGeomAlloc((XPointer *)&(g)->colors, \
+ &(g)->num_colors, &(g)->sz_colors, \
+ (n), sizeof(XkbColorRec))
+#define _XkbAllocShapes(g, n) _XkbGeomAlloc((XPointer *)&(g)->shapes, \
+ &(g)->num_shapes, &(g)->sz_shapes, \
+ (n), sizeof(XkbShapeRec))
+#define _XkbAllocSections(g, n) _XkbGeomAlloc((XPointer *)&(g)->sections, \
+ &(g)->num_sections, &(g)->sz_sections, \
+ (n), sizeof(XkbSectionRec))
+#define _XkbAllocDoodads(g, n) _XkbGeomAlloc((XPointer *)&(g)->doodads, \
+ &(g)->num_doodads, &(g)->sz_doodads, \
+ (n), sizeof(XkbDoodadRec))
+#define _XkbAllocKeyAliases(g, n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases, \
+ &(g)->num_key_aliases, &(g)->sz_key_aliases, \
+ (n), sizeof(XkbKeyAliasRec))
+
+#define _XkbAllocOutlines(s, n) _XkbGeomAlloc((XPointer *)&(s)->outlines, \
+ &(s)->num_outlines, &(s)->sz_outlines, \
+ (n), sizeof(XkbOutlineRec))
+#define _XkbAllocRows(s, n) _XkbGeomAlloc((XPointer *)&(s)->rows, \
+ &(s)->num_rows, &(s)->sz_rows, \
+ (n), sizeof(XkbRowRec))
+#define _XkbAllocPoints(o, n) _XkbGeomAlloc((XPointer *)&(o)->points, \
+ &(o)->num_points, &(o)->sz_points, \
+ (n), sizeof(XkbPointRec))
+#define _XkbAllocKeys(r, n) _XkbGeomAlloc((XPointer *)&(r)->keys, \
+ &(r)->num_keys, &(r)->sz_keys, \
+ (n), sizeof(XkbKeyRec))
+#define _XkbAllocOverlays(s, n) _XkbGeomAlloc((XPointer *)&(s)->overlays, \
+ &(s)->num_overlays, &(s)->sz_overlays, \
+ (n), sizeof(XkbOverlayRec))
+#define _XkbAllocOverlayRows(o, n) _XkbGeomAlloc((XPointer *)&(o)->rows, \
+ &(o)->num_rows, &(o)->sz_rows, \
+ (n), sizeof(XkbOverlayRowRec))
+#define _XkbAllocOverlayKeys(r, n) _XkbGeomAlloc((XPointer *)&(r)->keys, \
+ &(r)->num_keys, &(r)->sz_keys, \
+ (n), sizeof(XkbOverlayKeyRec))
Status
-XkbAllocGeomProps(XkbGeometryPtr geom,int nProps)
+XkbAllocGeomProps(XkbGeometryPtr geom, int nProps)
{
- return _XkbAllocProps(geom,nProps);
+ return _XkbAllocProps(geom, nProps);
}
Status
-XkbAllocGeomColors(XkbGeometryPtr geom,int nColors)
+XkbAllocGeomColors(XkbGeometryPtr geom, int nColors)
{
- return _XkbAllocColors(geom,nColors);
+ return _XkbAllocColors(geom, nColors);
}
Status
-XkbAllocGeomKeyAliases(XkbGeometryPtr geom,int nKeyAliases)
+XkbAllocGeomKeyAliases(XkbGeometryPtr geom, int nKeyAliases)
{
- return _XkbAllocKeyAliases(geom,nKeyAliases);
+ return _XkbAllocKeyAliases(geom, nKeyAliases);
}
Status
-XkbAllocGeomShapes(XkbGeometryPtr geom,int nShapes)
+XkbAllocGeomShapes(XkbGeometryPtr geom, int nShapes)
{
- return _XkbAllocShapes(geom,nShapes);
+ return _XkbAllocShapes(geom, nShapes);
}
Status
-XkbAllocGeomSections(XkbGeometryPtr geom,int nSections)
+XkbAllocGeomSections(XkbGeometryPtr geom, int nSections)
{
- return _XkbAllocSections(geom,nSections);
+ return _XkbAllocSections(geom, nSections);
}
Status
-XkbAllocGeomOverlays(XkbSectionPtr section,int nOverlays)
+XkbAllocGeomOverlays(XkbSectionPtr section, int nOverlays)
{
- return _XkbAllocOverlays(section,nOverlays);
+ return _XkbAllocOverlays(section, nOverlays);
}
Status
-XkbAllocGeomOverlayRows(XkbOverlayPtr overlay,int nRows)
+XkbAllocGeomOverlayRows(XkbOverlayPtr overlay, int nRows)
{
- return _XkbAllocOverlayRows(overlay,nRows);
+ return _XkbAllocOverlayRows(overlay, nRows);
}
Status
-XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row,int nKeys)
+XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row, int nKeys)
{
- return _XkbAllocOverlayKeys(row,nKeys);
+ return _XkbAllocOverlayKeys(row, nKeys);
}
Status
-XkbAllocGeomDoodads(XkbGeometryPtr geom,int nDoodads)
+XkbAllocGeomDoodads(XkbGeometryPtr geom, int nDoodads)
{
- return _XkbAllocDoodads(geom,nDoodads);
+ return _XkbAllocDoodads(geom, nDoodads);
}
Status
-XkbAllocGeomSectionDoodads(XkbSectionPtr section,int nDoodads)
+XkbAllocGeomSectionDoodads(XkbSectionPtr section, int nDoodads)
{
- return _XkbAllocDoodads(section,nDoodads);
+ return _XkbAllocDoodads(section, nDoodads);
}
Status
-XkbAllocGeomOutlines(XkbShapePtr shape,int nOL)
+XkbAllocGeomOutlines(XkbShapePtr shape, int nOL)
{
- return _XkbAllocOutlines(shape,nOL);
+ return _XkbAllocOutlines(shape, nOL);
}
Status
-XkbAllocGeomRows(XkbSectionPtr section,int nRows)
+XkbAllocGeomRows(XkbSectionPtr section, int nRows)
{
- return _XkbAllocRows(section,nRows);
+ return _XkbAllocRows(section, nRows);
}
Status
-XkbAllocGeomPoints(XkbOutlinePtr ol,int nPts)
+XkbAllocGeomPoints(XkbOutlinePtr ol, int nPts)
{
- return _XkbAllocPoints(ol,nPts);
+ return _XkbAllocPoints(ol, nPts);
}
Status
-XkbAllocGeomKeys(XkbRowPtr row,int nKeys)
+XkbAllocGeomKeys(XkbRowPtr row, int nKeys)
{
- return _XkbAllocKeys(row,nKeys);
+ return _XkbAllocKeys(row, nKeys);
}
Status
-XkbAllocGeometry(XkbDescPtr xkb,XkbGeometrySizesPtr sizes)
+XkbAllocGeometry(XkbDescPtr xkb, XkbGeometrySizesPtr sizes)
{
-XkbGeometryPtr geom;
-Status rtrn;
+ XkbGeometryPtr geom;
+ Status rtrn;
- if (xkb->geom==NULL) {
- xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
- if (!xkb->geom)
- return BadAlloc;
+ if (xkb->geom == NULL) {
+ xkb->geom = _XkbTypedCalloc(1, XkbGeometryRec);
+ if (!xkb->geom)
+ return BadAlloc;
}
- geom= xkb->geom;
- if ((sizes->which&XkbGeomPropertiesMask)&&
- ((rtrn=_XkbAllocProps(geom,sizes->num_properties))!=Success)) {
- goto BAIL;
+ geom = xkb->geom;
+ if ((sizes->which & XkbGeomPropertiesMask) &&
+ ((rtrn = _XkbAllocProps(geom, sizes->num_properties)) != Success)) {
+ goto BAIL;
}
- if ((sizes->which&XkbGeomColorsMask)&&
- ((rtrn=_XkbAllocColors(geom,sizes->num_colors))!=Success)) {
- goto BAIL;
+ if ((sizes->which & XkbGeomColorsMask) &&
+ ((rtrn = _XkbAllocColors(geom, sizes->num_colors)) != Success)) {
+ goto BAIL;
}
- if ((sizes->which&XkbGeomShapesMask)&&
- ((rtrn=_XkbAllocShapes(geom,sizes->num_shapes))!=Success)) {
- goto BAIL;
+ if ((sizes->which & XkbGeomShapesMask) &&
+ ((rtrn = _XkbAllocShapes(geom, sizes->num_shapes)) != Success)) {
+ goto BAIL;
}
- if ((sizes->which&XkbGeomSectionsMask)&&
- ((rtrn=_XkbAllocSections(geom,sizes->num_sections))!=Success)) {
- goto BAIL;
+ if ((sizes->which & XkbGeomSectionsMask) &&
+ ((rtrn = _XkbAllocSections(geom, sizes->num_sections)) != Success)) {
+ goto BAIL;
}
- if ((sizes->which&XkbGeomDoodadsMask)&&
- ((rtrn=_XkbAllocDoodads(geom,sizes->num_doodads))!=Success)) {
- goto BAIL;
+ if ((sizes->which & XkbGeomDoodadsMask) &&
+ ((rtrn = _XkbAllocDoodads(geom, sizes->num_doodads)) != Success)) {
+ goto BAIL;
}
- if ((sizes->which&XkbGeomKeyAliasesMask)&&
- ((rtrn=_XkbAllocKeyAliases(geom,sizes->num_key_aliases))!=Success)) {
- goto BAIL;
+ if ((sizes->which & XkbGeomKeyAliasesMask) &&
+ ((rtrn = _XkbAllocKeyAliases(geom, sizes->num_key_aliases))
+ != Success)) {
+ goto BAIL;
}
return Success;
-BAIL:
- XkbFreeGeometry(geom,XkbGeomAllMask,True);
- xkb->geom= NULL;
+ BAIL:
+ XkbFreeGeometry(geom, XkbGeomAllMask, True);
+ xkb->geom = NULL;
return rtrn;
}
/***====================================================================***/
XkbPropertyPtr
-XkbAddGeomProperty(XkbGeometryPtr geom,char *name,char *value)
-{
-register int i;
-register XkbPropertyPtr prop;
-
- if ((!geom)||(!name)||(!value))
- return NULL;
- for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
- if ((prop->name)&&(strcmp(name,prop->name)==0)) {
- if (prop->value)
- _XkbFree(prop->value);
- prop->value= (char *)_XkbAlloc(strlen(value)+1);
- if (prop->value)
- strcpy(prop->value,value);
- return prop;
- }
- }
- if ((geom->num_properties>=geom->sz_properties)&&
- (_XkbAllocProps(geom,1)!=Success)) {
- return NULL;
- }
- prop= &geom->properties[geom->num_properties];
- prop->name= (char *)_XkbAlloc(strlen(name)+1);
- if (!name)
- return NULL;
- strcpy(prop->name,name);
- prop->value= (char *)_XkbAlloc(strlen(value)+1);
- if (!value) {
- _XkbFree(prop->name);
- prop->name= NULL;
- return NULL;
- }
- strcpy(prop->value,value);
+XkbAddGeomProperty(XkbGeometryPtr geom, char *name, char *value)
+{
+ register int i;
+ register XkbPropertyPtr prop;
+
+ if ((!geom) || (!name) || (!value))
+ return NULL;
+ for (i = 0, prop = geom->properties; i < geom->num_properties; i++, prop++) {
+ if ((prop->name) && (strcmp(name, prop->name) == 0)) {
+ _XkbFree(prop->value);
+ prop->value = strdup(value);
+ return prop;
+ }
+ }
+ if ((geom->num_properties >= geom->sz_properties) &&
+ (_XkbAllocProps(geom, 1) != Success)) {
+ return NULL;
+ }
+ prop = &geom->properties[geom->num_properties];
+ prop->name = strdup(name);
+ if (!prop->name)
+ return NULL;
+ prop->value = strdup(value);
+ if (!prop->value) {
+ _XkbFree(prop->name);
+ prop->name = NULL;
+ return NULL;
+ }
geom->num_properties++;
return prop;
}
XkbKeyAliasPtr
-XkbAddGeomKeyAlias(XkbGeometryPtr geom,char *aliasStr,char *realStr)
-{
-register int i;
-register XkbKeyAliasPtr alias;
-
- if ((!geom)||(!aliasStr)||(!realStr)||(!aliasStr[0])||(!realStr[0]))
- return NULL;
- for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
- if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
- bzero(alias->real,XkbKeyNameLength);
- strncpy(alias->real,realStr,XkbKeyNameLength);
- return alias;
- }
- }
- if ((geom->num_key_aliases>=geom->sz_key_aliases)&&
- (_XkbAllocKeyAliases(geom,1)!=Success)) {
- return NULL;
- }
- alias= &geom->key_aliases[geom->num_key_aliases];
- bzero(alias,sizeof(XkbKeyAliasRec));
- strncpy(alias->alias,aliasStr,XkbKeyNameLength);
- strncpy(alias->real,realStr,XkbKeyNameLength);
+XkbAddGeomKeyAlias(XkbGeometryPtr geom, char *aliasStr, char *realStr)
+{
+ register int i;
+ register XkbKeyAliasPtr alias;
+
+ if ((!geom) || (!aliasStr) || (!realStr) || (!aliasStr[0]) || (!realStr[0]))
+ return NULL;
+ for (i = 0, alias = geom->key_aliases; i < geom->num_key_aliases;
+ i++, alias++) {
+ if (strncmp(alias->alias, aliasStr, XkbKeyNameLength) == 0) {
+ bzero(alias->real, XkbKeyNameLength);
+ strncpy(alias->real, realStr, XkbKeyNameLength);
+ return alias;
+ }
+ }
+ if ((geom->num_key_aliases >= geom->sz_key_aliases) &&
+ (_XkbAllocKeyAliases(geom, 1) != Success)) {
+ return NULL;
+ }
+ alias = &geom->key_aliases[geom->num_key_aliases];
+ bzero(alias, sizeof(XkbKeyAliasRec));
+ strncpy(alias->alias, aliasStr, XkbKeyNameLength);
+ strncpy(alias->real, realStr, XkbKeyNameLength);
geom->num_key_aliases++;
return alias;
}
XkbColorPtr
-XkbAddGeomColor(XkbGeometryPtr geom,char *spec,unsigned int pixel)
-{
-register int i;
-register XkbColorPtr color;
-
- if ((!geom)||(!spec))
- return NULL;
- for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
- if ((color->spec)&&(strcmp(color->spec,spec)==0)) {
- color->pixel= pixel;
- return color;
- }
- }
- if ((geom->num_colors>=geom->sz_colors)&&
- (_XkbAllocColors(geom,1)!=Success)) {
- return NULL;
- }
- color= &geom->colors[geom->num_colors];
- color->pixel= pixel;
- color->spec= (char *)_XkbAlloc(strlen(spec)+1);
+XkbAddGeomColor(XkbGeometryPtr geom, char *spec, unsigned int pixel)
+{
+ register int i;
+ register XkbColorPtr color;
+
+ if ((!geom) || (!spec))
+ return NULL;
+ for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) {
+ if ((color->spec) && (strcmp(color->spec, spec) == 0)) {
+ color->pixel = pixel;
+ return color;
+ }
+ }
+ if ((geom->num_colors >= geom->sz_colors) &&
+ (_XkbAllocColors(geom, 1) != Success)) {
+ return NULL;
+ }
+ color = &geom->colors[geom->num_colors];
+ color->pixel = pixel;
+ color->spec = strdup(spec);
if (!color->spec)
- return NULL;
- strcpy(color->spec,spec);
+ return NULL;
geom->num_colors++;
return color;
}
XkbOutlinePtr
-XkbAddGeomOutline(XkbShapePtr shape,int sz_points)
+XkbAddGeomOutline(XkbShapePtr shape, int sz_points)
{
-XkbOutlinePtr outline;
+ XkbOutlinePtr outline;
- if ((!shape)||(sz_points<0))
- return NULL;
- if ((shape->num_outlines>=shape->sz_outlines)&&
- (_XkbAllocOutlines(shape,1)!=Success)) {
- return NULL;
+ if ((!shape) || (sz_points < 0))
+ return NULL;
+ if ((shape->num_outlines >= shape->sz_outlines) &&
+ (_XkbAllocOutlines(shape, 1) != Success)) {
+ return NULL;
}
- outline= &shape->outlines[shape->num_outlines];
- bzero(outline,sizeof(XkbOutlineRec));
- if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
- return NULL;
+ outline = &shape->outlines[shape->num_outlines];
+ bzero(outline, sizeof(XkbOutlineRec));
+ if ((sz_points > 0) && (_XkbAllocPoints(outline, sz_points) != Success))
+ return NULL;
shape->num_outlines++;
return outline;
}
XkbShapePtr
-XkbAddGeomShape(XkbGeometryPtr geom,Atom name,int sz_outlines)
-{
-XkbShapePtr shape;
-register int i;
-
- if ((!geom)||(!name)||(sz_outlines<0))
- return NULL;
- if (geom->num_shapes>0) {
- for (shape=geom->shapes,i=0;i<geom->num_shapes;i++,shape++) {
- if (name==shape->name)
- return shape;
- }
- }
- if ((geom->num_shapes>=geom->sz_shapes)&&
- (_XkbAllocShapes(geom,1)!=Success))
- return NULL;
- shape= &geom->shapes[geom->num_shapes];
- bzero(shape,sizeof(XkbShapeRec));
- if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
- return NULL;
- shape->name= name;
- shape->primary= shape->approx= NULL;
+XkbAddGeomShape(XkbGeometryPtr geom, Atom name, int sz_outlines)
+{
+ XkbShapePtr shape;
+ register int i;
+
+ if ((!geom) || (!name) || (sz_outlines < 0))
+ return NULL;
+ if (geom->num_shapes > 0) {
+ for (shape = geom->shapes, i = 0; i < geom->num_shapes; i++, shape++) {
+ if (name == shape->name)
+ return shape;
+ }
+ }
+ if ((geom->num_shapes >= geom->sz_shapes) &&
+ (_XkbAllocShapes(geom, 1) != Success))
+ return NULL;
+ shape = &geom->shapes[geom->num_shapes];
+ bzero(shape, sizeof(XkbShapeRec));
+ if ((sz_outlines > 0) && (_XkbAllocOutlines(shape, sz_outlines) != Success))
+ return NULL;
+ shape->name = name;
+ shape->primary = shape->approx = NULL;
geom->num_shapes++;
return shape;
}
@@ -814,203 +786,209 @@ register int i;
XkbKeyPtr
XkbAddGeomKey(XkbRowPtr row)
{
-XkbKeyPtr key;
+ XkbKeyPtr key;
+
if (!row)
- return NULL;
- if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
- return NULL;
- key= &row->keys[row->num_keys++];
- bzero(key,sizeof(XkbKeyRec));
+ return NULL;
+ if ((row->num_keys >= row->sz_keys) && (_XkbAllocKeys(row, 1) != Success))
+ return NULL;
+ key = &row->keys[row->num_keys++];
+ bzero(key, sizeof(XkbKeyRec));
return key;
}
XkbRowPtr
-XkbAddGeomRow(XkbSectionPtr section,int sz_keys)
-{
-XkbRowPtr row;
-
- if ((!section)||(sz_keys<0))
- return NULL;
- if ((section->num_rows>=section->sz_rows)&&
- (_XkbAllocRows(section,1)!=Success))
- return NULL;
- row= &section->rows[section->num_rows];
- bzero(row,sizeof(XkbRowRec));
- if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
- return NULL;
+XkbAddGeomRow(XkbSectionPtr section, int sz_keys)
+{
+ XkbRowPtr row;
+
+ if ((!section) || (sz_keys < 0))
+ return NULL;
+ if ((section->num_rows >= section->sz_rows) &&
+ (_XkbAllocRows(section, 1) != Success))
+ return NULL;
+ row = &section->rows[section->num_rows];
+ bzero(row, sizeof(XkbRowRec));
+ if ((sz_keys > 0) && (_XkbAllocKeys(row, sz_keys) != Success))
+ return NULL;
section->num_rows++;
return row;
}
XkbSectionPtr
-XkbAddGeomSection( XkbGeometryPtr geom,
- Atom name,
- int sz_rows,
- int sz_doodads,
- int sz_over)
-{
-register int i;
-XkbSectionPtr section;
-
- if ((!geom)||(name==None)||(sz_rows<0))
- return NULL;
- for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
- if (section->name!=name)
- continue;
- if (((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))||
- ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success))||
- ((sz_over>0)&&(_XkbAllocOverlays(section,sz_over)!=Success)))
- return NULL;
- return section;
- }
- if ((geom->num_sections>=geom->sz_sections)&&
- (_XkbAllocSections(geom,1)!=Success))
- return NULL;
- section= &geom->sections[geom->num_sections];
- if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
- return NULL;
- if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
- if (section->rows) {
- _XkbFree(section->rows);
- section->rows= NULL;
- section->sz_rows= section->num_rows= 0;
- }
- return NULL;
- }
- section->name= name;
+XkbAddGeomSection(XkbGeometryPtr geom,
+ Atom name,
+ int sz_rows,
+ int sz_doodads,
+ int sz_over)
+{
+ register int i;
+ XkbSectionPtr section;
+
+ if ((!geom) || (name == None) || (sz_rows < 0))
+ return NULL;
+ for (i = 0, section = geom->sections; i < geom->num_sections;
+ i++, section++) {
+ if (section->name != name)
+ continue;
+ if (((sz_rows > 0) && (_XkbAllocRows(section, sz_rows) != Success)) ||
+ ((sz_doodads > 0) &&
+ (_XkbAllocDoodads(section, sz_doodads) != Success)) ||
+ ((sz_over > 0) && (_XkbAllocOverlays(section, sz_over) != Success)))
+ return NULL;
+ return section;
+ }
+ if ((geom->num_sections >= geom->sz_sections) &&
+ (_XkbAllocSections(geom, 1) != Success))
+ return NULL;
+ section = &geom->sections[geom->num_sections];
+ if ((sz_rows > 0) && (_XkbAllocRows(section, sz_rows) != Success))
+ return NULL;
+ if ((sz_doodads > 0) && (_XkbAllocDoodads(section, sz_doodads) != Success)) {
+ if (section->rows) {
+ _XkbFree(section->rows);
+ section->rows = NULL;
+ section->sz_rows = section->num_rows = 0;
+ }
+ return NULL;
+ }
+ section->name = name;
geom->num_sections++;
return section;
}
XkbDoodadPtr
-XkbAddGeomDoodad(XkbGeometryPtr geom,XkbSectionPtr section,Atom name)
+XkbAddGeomDoodad(XkbGeometryPtr geom, XkbSectionPtr section, Atom name)
{
-XkbDoodadPtr old,doodad;
-register int i,nDoodads;
+ XkbDoodadPtr old, doodad;
+ register int i, nDoodads;
- if ((!geom)||(name==None))
- return NULL;
- if ((section!=NULL)&&(section->num_doodads>0)) {
- old= section->doodads;
- nDoodads= section->num_doodads;
+ if ((!geom) || (name == None))
+ return NULL;
+ if ((section != NULL) && (section->num_doodads > 0)) {
+ old = section->doodads;
+ nDoodads = section->num_doodads;
}
else {
- old= geom->doodads;
- nDoodads= geom->num_doodads;
+ old = geom->doodads;
+ nDoodads = geom->num_doodads;
}
- for (i=0,doodad=old;i<nDoodads;i++,doodad++) {
- if (doodad->any.name==name)
- return doodad;
+ for (i = 0, doodad = old; i < nDoodads; i++, doodad++) {
+ if (doodad->any.name == name)
+ return doodad;
}
if (section) {
- if ((section->num_doodads>=geom->sz_doodads)&&
- (_XkbAllocDoodads(section,1)!=Success)) {
- return NULL;
- }
- doodad= &section->doodads[section->num_doodads++];
+ if ((section->num_doodads >= geom->sz_doodads) &&
+ (_XkbAllocDoodads(section, 1) != Success)) {
+ return NULL;
+ }
+ doodad = &section->doodads[section->num_doodads++];
}
else {
- if ((geom->num_doodads>=geom->sz_doodads)&&
- (_XkbAllocDoodads(geom,1)!=Success))
- return NULL;
- doodad= &geom->doodads[geom->num_doodads++];
+ if ((geom->num_doodads >= geom->sz_doodads) &&
+ (_XkbAllocDoodads(geom, 1) != Success))
+ return NULL;
+ doodad = &geom->doodads[geom->num_doodads++];
}
- bzero(doodad,sizeof(XkbDoodadRec));
- doodad->any.name= name;
+ bzero(doodad, sizeof(XkbDoodadRec));
+ doodad->any.name = name;
return doodad;
}
XkbOverlayKeyPtr
-XkbAddGeomOverlayKey( XkbOverlayPtr overlay,
- XkbOverlayRowPtr row,
- char * over,
- char * under)
-{
-register int i;
-XkbOverlayKeyPtr key;
-XkbSectionPtr section;
-XkbRowPtr row_under;
-Bool found;
-
- if ((!overlay)||(!row)||(!over)||(!under))
- return NULL;
- section= overlay->section_under;
- if (row->row_under>=section->num_rows)
- return NULL;
- row_under= &section->rows[row->row_under];
- for (i=0,found=False;i<row_under->num_keys;i++) {
- if (strncmp(under,row_under->keys[i].name.name,XkbKeyNameLength)==0) {
- found= True;
- break;
- }
+XkbAddGeomOverlayKey(XkbOverlayPtr overlay,
+ XkbOverlayRowPtr row,
+ char *over,
+ char *under)
+{
+ register int i;
+ XkbOverlayKeyPtr key;
+ XkbSectionPtr section;
+ XkbRowPtr row_under;
+ Bool found;
+
+ if ((!overlay) || (!row) || (!over) || (!under))
+ return NULL;
+ section = overlay->section_under;
+ if (row->row_under >= section->num_rows)
+ return NULL;
+ row_under = &section->rows[row->row_under];
+ for (i = 0, found = False; i < row_under->num_keys; i++) {
+ if (strncmp(under, row_under->keys[i].name.name, XkbKeyNameLength) == 0) {
+ found = True;
+ break;
+ }
}
if (!found)
- return NULL;
- if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
- return NULL;
- key= &row->keys[row->num_keys];
- strncpy(key->under.name,under,XkbKeyNameLength);
- strncpy(key->over.name,over,XkbKeyNameLength);
+ return NULL;
+ if ((row->num_keys >= row->sz_keys) &&
+ (_XkbAllocOverlayKeys(row, 1) != Success))
+ return NULL;
+ key = &row->keys[row->num_keys];
+ strncpy(key->under.name, under, XkbKeyNameLength);
+ strncpy(key->over.name, over, XkbKeyNameLength);
row->num_keys++;
return key;
}
XkbOverlayRowPtr
-XkbAddGeomOverlayRow(XkbOverlayPtr overlay,int row_under,int sz_keys)
-{
-register int i;
-XkbOverlayRowPtr row;
-
- if ((!overlay)||(sz_keys<0))
- return NULL;
- if (row_under>=overlay->section_under->num_rows)
- return NULL;
- for (i=0;i<overlay->num_rows;i++) {
- if (overlay->rows[i].row_under==row_under) {
- row= &overlay->rows[i];
- if ((row->sz_keys<sz_keys)&&
- (_XkbAllocOverlayKeys(row,sz_keys)!=Success)) {
- return NULL;
- }
- return &overlay->rows[i];
- }
- }
- if ((overlay->num_rows>=overlay->sz_rows)&&
- (_XkbAllocOverlayRows(overlay,1)!=Success))
- return NULL;
- row= &overlay->rows[overlay->num_rows];
- bzero(row,sizeof(XkbOverlayRowRec));
- if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
- return NULL;
- row->row_under= row_under;
+XkbAddGeomOverlayRow(XkbOverlayPtr overlay, int row_under, int sz_keys)
+{
+ register int i;
+ XkbOverlayRowPtr row;
+
+ if ((!overlay) || (sz_keys < 0))
+ return NULL;
+ if (row_under >= overlay->section_under->num_rows)
+ return NULL;
+ for (i = 0; i < overlay->num_rows; i++) {
+ if (overlay->rows[i].row_under == row_under) {
+ row = &overlay->rows[i];
+ if ((row->sz_keys < sz_keys) &&
+ (_XkbAllocOverlayKeys(row, sz_keys) != Success)) {
+ return NULL;
+ }
+ return &overlay->rows[i];
+ }
+ }
+ if ((overlay->num_rows >= overlay->sz_rows) &&
+ (_XkbAllocOverlayRows(overlay, 1) != Success))
+ return NULL;
+ row = &overlay->rows[overlay->num_rows];
+ bzero(row, sizeof(XkbOverlayRowRec));
+ if ((sz_keys > 0) && (_XkbAllocOverlayKeys(row, sz_keys) != Success))
+ return NULL;
+ row->row_under = row_under;
overlay->num_rows++;
return row;
}
XkbOverlayPtr
-XkbAddGeomOverlay(XkbSectionPtr section,Atom name,int sz_rows)
-{
-register int i;
-XkbOverlayPtr overlay;
-
- if ((!section)||(name==None)||(sz_rows==0))
- return NULL;
-
- for (i=0,overlay=section->overlays;i<section->num_overlays;i++,overlay++) {
- if (overlay->name==name) {
- if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
- return NULL;
- return overlay;
- }
- }
- if ((section->num_overlays>=section->sz_overlays)&&
- (_XkbAllocOverlays(section,1)!=Success))
- return NULL;
- overlay= &section->overlays[section->num_overlays];
- if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
- return NULL;
- overlay->name= name;
- overlay->section_under= section;
+XkbAddGeomOverlay(XkbSectionPtr section, Atom name, int sz_rows)
+{
+ register int i;
+ XkbOverlayPtr overlay;
+
+ if ((!section) || (name == None) || (sz_rows == 0))
+ return NULL;
+
+ for (i = 0, overlay = section->overlays; i < section->num_overlays;
+ i++, overlay++) {
+ if (overlay->name == name) {
+ if ((sz_rows > 0) &&
+ (_XkbAllocOverlayRows(overlay, sz_rows) != Success))
+ return NULL;
+ return overlay;
+ }
+ }
+ if ((section->num_overlays >= section->sz_overlays) &&
+ (_XkbAllocOverlays(section, 1) != Success))
+ return NULL;
+ overlay = &section->overlays[section->num_overlays];
+ if ((sz_rows > 0) && (_XkbAllocOverlayRows(overlay, sz_rows) != Success))
+ return NULL;
+ overlay->name = name;
+ overlay->section_under = section;
section->num_overlays++;
return overlay;
}
diff --git a/nx-X11/lib/X11/XKBGeom.c b/nx-X11/lib/X11/XKBGeom.c
index 1f9628bea..f57fe7cf6 100644
--- a/nx-X11/lib/X11/XKBGeom.c
+++ b/nx-X11/lib/X11/XKBGeom.c
@@ -47,149 +47,160 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
static void
-_XkbCheckBounds(XkbBoundsPtr bounds,int x,int y)
+_XkbCheckBounds(XkbBoundsPtr bounds, int x, int y)
{
- if (x<bounds->x1) bounds->x1= x;
- if (x>bounds->x2) bounds->x2= x;
- if (y<bounds->y1) bounds->y1= y;
- if (y>bounds->y2) bounds->y2= y;
+ if (x < bounds->x1)
+ bounds->x1 = x;
+ if (x > bounds->x2)
+ bounds->x2 = x;
+ if (y < bounds->y1)
+ bounds->y1 = y;
+ if (y > bounds->y2)
+ bounds->y2 = y;
return;
}
Bool
XkbComputeShapeBounds(XkbShapePtr shape)
{
-register int o,p;
-XkbOutlinePtr outline;
-XkbPointPtr pt;
-
- if ((!shape)||(shape->num_outlines<1))
- return False;
- shape->bounds.x1= shape->bounds.y1= MAXSHORT;
- shape->bounds.x2= shape->bounds.y2= MINSHORT;
- for (outline=shape->outlines,o=0;o<shape->num_outlines;o++,outline++) {
- for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
- _XkbCheckBounds(&shape->bounds,pt->x,pt->y);
- }
- if (outline->num_points<2) {
- _XkbCheckBounds(&shape->bounds,0,0);
+ register int o, p;
+ XkbOutlinePtr outline;
+ XkbPointPtr pt;
+
+ if ((!shape) || (shape->num_outlines < 1))
+ return False;
+ shape->bounds.x1 = shape->bounds.y1 = MAXSHORT;
+ shape->bounds.x2 = shape->bounds.y2 = MINSHORT;
+ for (outline = shape->outlines, o = 0; o < shape->num_outlines;
+ o++, outline++) {
+ for (pt = outline->points, p = 0; p < outline->num_points; p++, pt++) {
+ _XkbCheckBounds(&shape->bounds, pt->x, pt->y);
+ }
+ if (outline->num_points < 2) {
+ _XkbCheckBounds(&shape->bounds, 0, 0);
}
}
return True;
}
Bool
-XkbComputeShapeTop(XkbShapePtr shape,XkbBoundsPtr bounds)
+XkbComputeShapeTop(XkbShapePtr shape, XkbBoundsPtr bounds)
{
-register int p;
-XkbOutlinePtr outline;
-XkbPointPtr pt;
-
- if ((!shape)||(shape->num_outlines<1))
- return False;
- if (shape->approx) outline= shape->approx;
- else outline= &shape->outlines[shape->num_outlines-1];
- if (outline->num_points<2) {
- bounds->x1= bounds->y1= 0;
- bounds->x2= bounds->y2= 0;
+ register int p;
+ XkbOutlinePtr outline;
+ XkbPointPtr pt;
+
+ if ((!shape) || (shape->num_outlines < 1))
+ return False;
+ if (shape->approx)
+ outline = shape->approx;
+ else
+ outline = &shape->outlines[shape->num_outlines - 1];
+ if (outline->num_points < 2) {
+ bounds->x1 = bounds->y1 = 0;
+ bounds->x2 = bounds->y2 = 0;
}
else {
- bounds->x1= bounds->y1= MAXSHORT;
- bounds->x2= bounds->y2= MINSHORT;
+ bounds->x1 = bounds->y1 = MAXSHORT;
+ bounds->x2 = bounds->y2 = MINSHORT;
}
- for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
- _XkbCheckBounds(bounds,pt->x,pt->y);
+ for (pt = outline->points, p = 0; p < outline->num_points; p++, pt++) {
+ _XkbCheckBounds(bounds, pt->x, pt->y);
}
return True;
}
Bool
-XkbComputeRowBounds(XkbGeometryPtr geom,XkbSectionPtr section,XkbRowPtr row)
+XkbComputeRowBounds(XkbGeometryPtr geom, XkbSectionPtr section, XkbRowPtr row)
{
-register int k,pos;
-XkbKeyPtr key;
-XkbBoundsPtr bounds,sbounds;
-
- if ((!geom)||(!section)||(!row))
- return False;
- pos= 0;
- bounds= &row->bounds;
- bzero(bounds,sizeof(XkbBoundsRec));
- for (key=row->keys,pos=k=0;k<row->num_keys;k++,key++) {
- sbounds= &XkbKeyShape(geom,key)->bounds;
- _XkbCheckBounds(bounds,pos,0);
- if (!row->vertical) {
- if (key->gap!=0) {
- pos+= key->gap;
- _XkbCheckBounds(bounds,pos,0);
- }
- _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
- _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
- pos+= sbounds->x2;
- }
- else {
- if (key->gap!=0) {
- pos+= key->gap;
- _XkbCheckBounds(bounds,0,pos);
- }
- _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
- _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
- pos+= sbounds->y2;
- }
+ register int k, pos;
+ XkbKeyPtr key;
+ XkbBoundsPtr bounds, sbounds;
+
+ if ((!geom) || (!section) || (!row))
+ return False;
+ bounds = &row->bounds;
+ bzero(bounds, sizeof(XkbBoundsRec));
+ for (key = row->keys, pos = k = 0; k < row->num_keys; k++, key++) {
+ sbounds = &XkbKeyShape(geom, key)->bounds;
+ _XkbCheckBounds(bounds, pos, 0);
+ if (!row->vertical) {
+ if (key->gap != 0) {
+ pos += key->gap;
+ _XkbCheckBounds(bounds, pos, 0);
+ }
+ _XkbCheckBounds(bounds, pos + sbounds->x1, sbounds->y1);
+ _XkbCheckBounds(bounds, pos + sbounds->x2, sbounds->y2);
+ pos += sbounds->x2;
+ }
+ else {
+ if (key->gap != 0) {
+ pos += key->gap;
+ _XkbCheckBounds(bounds, 0, pos);
+ }
+ _XkbCheckBounds(bounds, pos + sbounds->x1, sbounds->y1);
+ _XkbCheckBounds(bounds, pos + sbounds->x2, sbounds->y2);
+ pos += sbounds->y2;
+ }
}
return True;
}
Bool
-XkbComputeSectionBounds(XkbGeometryPtr geom,XkbSectionPtr section)
+XkbComputeSectionBounds(XkbGeometryPtr geom, XkbSectionPtr section)
{
-register int i;
-XkbShapePtr shape;
-XkbRowPtr row;
-XkbDoodadPtr doodad;
-XkbBoundsPtr bounds,rbounds=NULL;
-
- if ((!geom)||(!section))
- return False;
- bounds= &section->bounds;
- bzero(bounds,sizeof(XkbBoundsRec));
- for (i=0,row=section->rows;i<section->num_rows;i++,row++) {
- if (!XkbComputeRowBounds(geom,section,row))
- return False;
- rbounds= &row->bounds;
- _XkbCheckBounds(bounds,row->left+rbounds->x1,row->top+rbounds->y1);
- _XkbCheckBounds(bounds,row->left+rbounds->x2,row->top+rbounds->y2);
+ register int i;
+ XkbShapePtr shape;
+ XkbRowPtr row;
+ XkbDoodadPtr doodad;
+ XkbBoundsPtr bounds, rbounds;
+
+ if ((!geom) || (!section))
+ return False;
+ bounds = &section->bounds;
+ bzero(bounds, sizeof(XkbBoundsRec));
+ for (i = 0, row = section->rows; i < section->num_rows; i++, row++) {
+ if (!XkbComputeRowBounds(geom, section, row))
+ return False;
+ rbounds = &row->bounds;
+ _XkbCheckBounds(bounds, row->left + rbounds->x1,
+ row->top + rbounds->y1);
+ _XkbCheckBounds(bounds, row->left + rbounds->x2,
+ row->top + rbounds->y2);
}
- for (i=0,doodad=section->doodads;i<section->num_doodads;i++,doodad++) {
- static XkbBoundsRec tbounds;
- switch (doodad->any.type) {
- case XkbOutlineDoodad:
- case XkbSolidDoodad:
- shape= XkbShapeDoodadShape(geom,&doodad->shape);
- rbounds= &shape->bounds;
- break;
- case XkbTextDoodad:
- tbounds.x1= doodad->text.left;
- tbounds.y1= doodad->text.top;
- tbounds.x2= tbounds.x1+doodad->text.width;
- tbounds.y2= tbounds.y1+doodad->text.height;
- rbounds= &tbounds;
- break;
- case XkbIndicatorDoodad:
- shape= XkbIndicatorDoodadShape(geom,&doodad->indicator);
- rbounds= &shape->bounds;
- break;
- case XkbLogoDoodad:
- shape= XkbLogoDoodadShape(geom,&doodad->logo);
- rbounds= &shape->bounds;
- break;
- default:
- tbounds.x1= tbounds.x2= doodad->any.left;
- tbounds.y1= tbounds.y2= doodad->any.top;
- break;
- }
- _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1);
- _XkbCheckBounds(bounds,rbounds->x2,rbounds->y2);
+ for (i = 0, doodad = section->doodads; i < section->num_doodads;
+ i++, doodad++) {
+ static XkbBoundsRec tbounds;
+
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ shape = XkbShapeDoodadShape(geom, &doodad->shape);
+ rbounds = &shape->bounds;
+ break;
+ case XkbTextDoodad:
+ tbounds.x1 = doodad->text.left;
+ tbounds.y1 = doodad->text.top;
+ tbounds.x2 = tbounds.x1 + doodad->text.width;
+ tbounds.y2 = tbounds.y1 + doodad->text.height;
+ rbounds = &tbounds;
+ break;
+ case XkbIndicatorDoodad:
+ shape = XkbIndicatorDoodadShape(geom, &doodad->indicator);
+ rbounds = &shape->bounds;
+ break;
+ case XkbLogoDoodad:
+ shape = XkbLogoDoodadShape(geom, &doodad->logo);
+ rbounds = &shape->bounds;
+ break;
+ default:
+ tbounds.x1 = tbounds.x2 = doodad->any.left;
+ tbounds.y1 = tbounds.y2 = doodad->any.top;
+ rbounds = &tbounds;
+ break;
+ }
+ _XkbCheckBounds(bounds, rbounds->x1, rbounds->y1);
+ _XkbCheckBounds(bounds, rbounds->x2, rbounds->y2);
}
return True;
}
@@ -197,39 +208,42 @@ XkbBoundsPtr bounds,rbounds=NULL;
/***====================================================================***/
char *
-XkbFindOverlayForKey(XkbGeometryPtr geom,XkbSectionPtr wanted,char *under)
+XkbFindOverlayForKey(XkbGeometryPtr geom, XkbSectionPtr wanted, char *under)
{
-int s;
-XkbSectionPtr section;
+ int s;
+ XkbSectionPtr section;
- if ((geom==NULL)||(under==NULL)||(geom->num_sections<1))
- return NULL;
+ if ((geom == NULL) || (under == NULL) || (geom->num_sections < 1))
+ return NULL;
if (wanted)
- section= wanted;
- else section= geom->sections;
-
- for (s=0;s<geom->num_sections;s++,section++) {
- XkbOverlayPtr ol;
- int o;
-
- if (section->num_overlays<1)
- continue;
- for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
- XkbOverlayRowPtr row;
- int r;
-
- for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
- XkbOverlayKeyPtr key;
- int k;
- for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
- if (strncmp(under,key->under.name,XkbKeyNameLength)==0)
- return key->over.name;
- }
- }
- }
- if (wanted!=NULL)
- break;
+ section = wanted;
+ else
+ section = geom->sections;
+
+ for (s = 0; s < geom->num_sections; s++, section++) {
+ XkbOverlayPtr ol;
+ int o;
+
+ if (section->num_overlays < 1)
+ continue;
+ for (o = 0, ol = section->overlays; o < section->num_overlays;
+ o++, ol++) {
+ XkbOverlayRowPtr row;
+ int r;
+
+ for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
+ XkbOverlayKeyPtr key;
+ int k;
+
+ for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
+ if (strncmp(under, key->under.name, XkbKeyNameLength) == 0)
+ return key->over.name;
+ }
+ }
+ }
+ if (wanted != NULL)
+ break;
}
return NULL;
}
@@ -237,463 +251,474 @@ XkbSectionPtr section;
/***====================================================================***/
static Status
-_XkbReadGeomProperties( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomProperties(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-Status rtrn;
-
- if (rep->nProperties<1)
- return Success;
- if ((rtrn=XkbAllocGeomProps(geom,rep->nProperties))==Success) {
- register int i;
- register Bool ok;
- char *name,*value;
- ok= True;
- for (i=0;(i<rep->nProperties)&&ok;i++) {
- name=NULL;
- value=NULL;
- ok= _XkbGetReadBufferCountedString(buf,&name)&&ok;
- ok= _XkbGetReadBufferCountedString(buf,&value)&&ok;
- ok= ok&&(XkbAddGeomProperty(geom,name,value)!=NULL);
- if (name)
- _XkbFree(name);
- if (value)
- _XkbFree(value);
- }
- if (ok) rtrn= Success;
- else rtrn= BadLength;
+ Status rtrn;
+
+ if (rep->nProperties < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomProps(geom, rep->nProperties)) == Success) {
+ register int i;
+ register Bool ok = True;
+
+ for (i = 0; (i < rep->nProperties) && ok; i++) {
+ char *name = NULL;
+ char *value = NULL;
+ ok = _XkbGetReadBufferCountedString(buf, &name) && ok;
+ ok = _XkbGetReadBufferCountedString(buf, &value) && ok;
+ ok = ok && (XkbAddGeomProperty(geom, name, value) != NULL);
+
+ _XkbFree(name);
+ _XkbFree(value);
+ }
+ if (ok)
+ rtrn = Success;
+ else
+ rtrn = BadLength;
}
return rtrn;
}
static Status
-_XkbReadGeomKeyAliases( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomKeyAliases(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-Status rtrn;
-
- if (rep->nKeyAliases<1)
- return Success;
- if ((rtrn=XkbAllocGeomKeyAliases(geom,rep->nKeyAliases))==Success) {
- if (!_XkbCopyFromReadBuffer(buf,(char *)geom->key_aliases,
- (rep->nKeyAliases*XkbKeyNameLength*2)))
- return BadLength;
- geom->num_key_aliases= rep->nKeyAliases;
- return Success;
+ Status rtrn;
+
+ if (rep->nKeyAliases < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomKeyAliases(geom, rep->nKeyAliases)) == Success) {
+ if (!_XkbCopyFromReadBuffer(buf, (char *) geom->key_aliases,
+ (rep->nKeyAliases * XkbKeyNameLength * 2)))
+ return BadLength;
+ geom->num_key_aliases = rep->nKeyAliases;
+ return Success;
}
- else { /* alloc failed, just skip the aliases */
- _XkbSkipReadBufferData(buf,(rep->nKeyAliases*XkbKeyNameLength*2));
+ else { /* alloc failed, just skip the aliases */
+ _XkbSkipReadBufferData(buf, (rep->nKeyAliases * XkbKeyNameLength * 2));
}
return rtrn;
}
static Status
-_XkbReadGeomColors( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomColors(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-Status rtrn;
-
- if (rep->nColors<1)
- return Success;
- if ((rtrn=XkbAllocGeomColors(geom,rep->nColors))==Success) {
- register int i;
- char *spec;
- for (i=0;i<rep->nColors;i++) {
- spec = NULL;
- if (!_XkbGetReadBufferCountedString(buf,&spec))
- rtrn = BadLength;
- else if (XkbAddGeomColor(geom,spec,geom->num_colors)==NULL)
- rtrn = BadAlloc;
- if (spec)
- _XkbFree(spec);
- if (rtrn != Success)
- return rtrn;
- }
- return Success;
+ Status rtrn;
+
+ if (rep->nColors < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomColors(geom, rep->nColors)) == Success) {
+ register int i;
+
+ for (i = 0; i < rep->nColors; i++) {
+ char *spec = NULL;
+ if (!_XkbGetReadBufferCountedString(buf, &spec))
+ rtrn = BadLength;
+ else if (XkbAddGeomColor(geom, spec, geom->num_colors) == NULL)
+ rtrn = BadAlloc;
+
+ _XkbFree(spec);
+ if (rtrn != Success)
+ return rtrn;
+ }
+ return Success;
}
return rtrn;
}
static Status
-_XkbReadGeomShapes( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomShapes(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-register int i;
-Status rtrn;
-
- if (rep->nShapes<1)
- return Success;
- if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success)
- return rtrn;
- for (i=0;i<rep->nShapes;i++) {
- xkbShapeWireDesc *shapeWire;
- XkbShapePtr shape;
- register int o;
- shapeWire= (xkbShapeWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc));
- if (!shapeWire)
- return BadLength;
- shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines);
- if (!shape)
- return BadAlloc;
- for (o=0;o<shapeWire->nOutlines;o++) {
- xkbOutlineWireDesc *olWire;
- XkbOutlinePtr ol;
- register int p;
- XkbPointPtr pt;
- olWire= (xkbOutlineWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc));
- if (!olWire)
- return BadLength;
- ol= XkbAddGeomOutline(shape,olWire->nPoints);
- if (!ol)
- return BadAlloc;
- ol->corner_radius= olWire->cornerRadius;
- for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) {
- xkbPointWireDesc * ptWire;
- ptWire= (xkbPointWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc));
- if (!ptWire)
- return BadLength;
- pt->x= ptWire->x;
- pt->y= ptWire->y;
- }
- ol->num_points= olWire->nPoints;
- }
- if ((shapeWire->primaryNdx!=XkbNoShape) &&
- (shapeWire->primaryNdx < shapeWire->nOutlines))
- shape->primary= &shape->outlines[shapeWire->primaryNdx];
- else
- shape->primary= NULL;
- if ((shapeWire->approxNdx!=XkbNoShape) &&
- (shapeWire->approxNdx < shapeWire->nOutlines))
- shape->approx= &shape->outlines[shapeWire->approxNdx];
- else
- shape->approx= NULL;
- XkbComputeShapeBounds(shape);
+ register int i;
+ Status rtrn;
+
+ if (rep->nShapes < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomShapes(geom, rep->nShapes)) != Success)
+ return rtrn;
+ for (i = 0; i < rep->nShapes; i++) {
+ xkbShapeWireDesc *shapeWire;
+ XkbShapePtr shape;
+ register int o;
+
+ shapeWire = (xkbShapeWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbShapeWireDesc));
+ if (!shapeWire)
+ return BadLength;
+ shape = XkbAddGeomShape(geom, shapeWire->name, shapeWire->nOutlines);
+ if (!shape)
+ return BadAlloc;
+ for (o = 0; o < shapeWire->nOutlines; o++) {
+ xkbOutlineWireDesc *olWire;
+ XkbOutlinePtr ol;
+ register int p;
+ XkbPointPtr pt;
+
+ olWire = (xkbOutlineWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbOutlineWireDesc));
+ if (!olWire)
+ return BadLength;
+ ol = XkbAddGeomOutline(shape, olWire->nPoints);
+ if (!ol)
+ return BadAlloc;
+ ol->corner_radius = olWire->cornerRadius;
+ for (p = 0, pt = ol->points; p < olWire->nPoints; p++, pt++) {
+ xkbPointWireDesc *ptWire;
+
+ ptWire = (xkbPointWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbPointWireDesc));
+ if (!ptWire)
+ return BadLength;
+ pt->x = ptWire->x;
+ pt->y = ptWire->y;
+ }
+ ol->num_points = olWire->nPoints;
+ }
+ if ((shapeWire->primaryNdx != XkbNoShape) &&
+ (shapeWire->primaryNdx < shapeWire->nOutlines))
+ shape->primary = &shape->outlines[shapeWire->primaryNdx];
+ else
+ shape->primary = NULL;
+ if ((shapeWire->approxNdx != XkbNoShape) &&
+ (shapeWire->approxNdx < shapeWire->nOutlines))
+ shape->approx = &shape->outlines[shapeWire->approxNdx];
+ else
+ shape->approx = NULL;
+ XkbComputeShapeBounds(shape);
}
return Success;
}
static Status
-_XkbReadGeomDoodad( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- XkbSectionPtr section)
+_XkbReadGeomDoodad(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
{
-XkbDoodadPtr doodad;
-xkbDoodadWireDesc * doodadWire;
+ XkbDoodadPtr doodad;
+ xkbDoodadWireDesc *doodadWire;
- doodadWire= (xkbDoodadWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc));
+ doodadWire = (xkbDoodadWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbDoodadWireDesc));
if (!doodadWire)
- return BadLength;
- doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name);
+ return BadLength;
+ doodad = XkbAddGeomDoodad(geom, section, doodadWire->any.name);
if (!doodad)
- return BadAlloc;
- doodad->any.type= doodadWire->any.type;
- doodad->any.priority= doodadWire->any.priority;
- doodad->any.top= doodadWire->any.top;
- doodad->any.left= doodadWire->any.left;
- doodad->any.angle= doodadWire->any.angle;
+ return BadAlloc;
+ doodad->any.type = doodadWire->any.type;
+ doodad->any.priority = doodadWire->any.priority;
+ doodad->any.top = doodadWire->any.top;
+ doodad->any.left = doodadWire->any.left;
+ doodad->any.angle = doodadWire->any.angle;
switch (doodad->any.type) {
- case XkbOutlineDoodad:
- case XkbSolidDoodad:
- doodad->shape.color_ndx= doodadWire->shape.colorNdx;
- doodad->shape.shape_ndx= doodadWire->shape.shapeNdx;
- break;
- case XkbTextDoodad:
- doodad->text.width= doodadWire->text.width;
- doodad->text.height= doodadWire->text.height;
- doodad->text.color_ndx= doodadWire->text.colorNdx;
- if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text))
- return BadLength;
- if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font))
- return BadLength;
- break;
- case XkbIndicatorDoodad:
- doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx;
- doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx;
- doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx;
- break;
- case XkbLogoDoodad:
- doodad->logo.color_ndx= doodadWire->logo.colorNdx;
- doodad->logo.shape_ndx= doodadWire->logo.shapeNdx;
- if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name))
- return BadLength;
- break;
- default:
- return BadValue;
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodad->shape.color_ndx = doodadWire->shape.colorNdx;
+ doodad->shape.shape_ndx = doodadWire->shape.shapeNdx;
+ break;
+ case XkbTextDoodad:
+ doodad->text.width = doodadWire->text.width;
+ doodad->text.height = doodadWire->text.height;
+ doodad->text.color_ndx = doodadWire->text.colorNdx;
+ if (!_XkbGetReadBufferCountedString(buf, &doodad->text.text))
+ return BadLength;
+ if (!_XkbGetReadBufferCountedString(buf, &doodad->text.font))
+ return BadLength;
+ break;
+ case XkbIndicatorDoodad:
+ doodad->indicator.shape_ndx = doodadWire->indicator.shapeNdx;
+ doodad->indicator.on_color_ndx = doodadWire->indicator.onColorNdx;
+ doodad->indicator.off_color_ndx = doodadWire->indicator.offColorNdx;
+ break;
+ case XkbLogoDoodad:
+ doodad->logo.color_ndx = doodadWire->logo.colorNdx;
+ doodad->logo.shape_ndx = doodadWire->logo.shapeNdx;
+ if (!_XkbGetReadBufferCountedString(buf, &doodad->logo.logo_name))
+ return BadLength;
+ break;
+ default:
+ return BadValue;
}
return Success;
}
static Status
-_XkbReadGeomOverlay( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- XkbSectionPtr section)
+_XkbReadGeomOverlay(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
{
-XkbOverlayPtr ol;
-xkbOverlayWireDesc * olWire;
-register int r;
-
- olWire= (xkbOverlayWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayWireDesc));
- if (olWire==NULL)
- return BadLength;
- ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows);
- if (ol==NULL)
- return BadLength;
- for (r=0;r<olWire->nRows;r++) {
- register int k;
- XkbOverlayRowPtr row;
- xkbOverlayRowWireDesc * rowWire;
- xkbOverlayKeyWireDesc * keyWire;
- rowWire= (xkbOverlayRowWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayRowWireDesc));
- if (rowWire==NULL)
- return BadLength;
- row= XkbAddGeomOverlayRow(ol,rowWire->rowUnder,rowWire->nKeys);
- row->row_under= rowWire->rowUnder;
- if (!row)
- return BadAlloc;
- if (rowWire->nKeys<1)
- continue;
- keyWire= (xkbOverlayKeyWireDesc *)
- _XkbGetReadBufferPtr(buf,
- SIZEOF(xkbOverlayKeyWireDesc)*rowWire->nKeys);
- if (keyWire==NULL)
- return BadLength;
- for (k=0;k<rowWire->nKeys;k++,keyWire++,row->num_keys++) {
- memcpy(row->keys[row->num_keys].over.name,keyWire->over,
- XkbKeyNameLength);
- memcpy(row->keys[row->num_keys].under.name,keyWire->under,
- XkbKeyNameLength);
- }
+ XkbOverlayPtr ol;
+ xkbOverlayWireDesc *olWire;
+ register int r;
+
+ olWire = (xkbOverlayWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbOverlayWireDesc));
+ if (olWire == NULL)
+ return BadLength;
+ ol = XkbAddGeomOverlay(section, olWire->name, olWire->nRows);
+ if (ol == NULL)
+ return BadLength;
+ for (r = 0; r < olWire->nRows; r++) {
+ register int k;
+ XkbOverlayRowPtr row;
+ xkbOverlayRowWireDesc *rowWire;
+ xkbOverlayKeyWireDesc *keyWire;
+
+ rowWire = (xkbOverlayRowWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbOverlayRowWireDesc));
+ if (rowWire == NULL)
+ return BadLength;
+ row = XkbAddGeomOverlayRow(ol, rowWire->rowUnder, rowWire->nKeys);
+ if (!row)
+ return BadAlloc;
+ row->row_under = rowWire->rowUnder;
+ if (rowWire->nKeys < 1)
+ continue;
+ keyWire = (xkbOverlayKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbOverlayKeyWireDesc) * rowWire->nKeys);
+ if (keyWire == NULL)
+ return BadLength;
+ for (k = 0; k < rowWire->nKeys; k++, keyWire++, row->num_keys++) {
+ memcpy(row->keys[row->num_keys].over.name, keyWire->over,
+ XkbKeyNameLength);
+ memcpy(row->keys[row->num_keys].under.name, keyWire->under,
+ XkbKeyNameLength);
+ }
}
return Success;
}
static Status
-_XkbReadGeomSections( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomSections(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-register int s;
-XkbSectionPtr section;
-xkbSectionWireDesc * sectionWire;
-Status rtrn;
-
- if (rep->nSections<1)
- return Success;
- if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success)
- return rtrn;
- for (s=0;s<rep->nSections;s++) {
- sectionWire= (xkbSectionWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc));
- if (!sectionWire)
- return BadLength;
- section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows,
- sectionWire->nDoodads,
- sectionWire->nOverlays);
- if (!section)
- return BadAlloc;
- section->top= sectionWire->top;
- section->left= sectionWire->left;
- section->width= sectionWire->width;
- section->height= sectionWire->height;
- section->angle= sectionWire->angle;
- section->priority= sectionWire->priority;
- if (sectionWire->nRows>0) {
- register int r;
- XkbRowPtr row;
- xkbRowWireDesc * rowWire;
- for (r=0;r<sectionWire->nRows;r++) {
- rowWire= (xkbRowWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc));
- if (!rowWire)
- return BadLength;
- row= XkbAddGeomRow(section,rowWire->nKeys);
- if (!row)
- return BadAlloc;
- row->top= rowWire->top;
- row->left= rowWire->left;
- row->vertical= rowWire->vertical;
- if (rowWire->nKeys>0) {
- register int k;
- XkbKeyPtr key;
- xkbKeyWireDesc * keyWire;
- for (k=0;k<rowWire->nKeys;k++) {
- keyWire= (xkbKeyWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc));
- if (!keyWire)
- return BadLength;
- key= XkbAddGeomKey(row);
- if (!key)
- return BadAlloc;
- memcpy(key->name.name,keyWire->name,XkbKeyNameLength);
- key->gap= keyWire->gap;
- key->shape_ndx= keyWire->shapeNdx;
- key->color_ndx= keyWire->colorNdx;
- }
- }
- }
- }
- if (sectionWire->nDoodads>0) {
- register int d;
- for (d=0;d<sectionWire->nDoodads;d++) {
- if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success)
- return rtrn;
- }
- }
- if (sectionWire->nOverlays>0) {
- register int o;
- for (o=0;o<sectionWire->nOverlays;o++) {
- if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success)
- return rtrn;
- }
- }
+ register int s;
+ XkbSectionPtr section;
+ xkbSectionWireDesc *sectionWire;
+ Status rtrn;
+
+ if (rep->nSections < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomSections(geom, rep->nSections)) != Success)
+ return rtrn;
+ for (s = 0; s < rep->nSections; s++) {
+ sectionWire = (xkbSectionWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbSectionWireDesc));
+ if (!sectionWire)
+ return BadLength;
+ section = XkbAddGeomSection(geom, sectionWire->name, sectionWire->nRows,
+ sectionWire->nDoodads,
+ sectionWire->nOverlays);
+ if (!section)
+ return BadAlloc;
+ section->top = sectionWire->top;
+ section->left = sectionWire->left;
+ section->width = sectionWire->width;
+ section->height = sectionWire->height;
+ section->angle = sectionWire->angle;
+ section->priority = sectionWire->priority;
+ if (sectionWire->nRows > 0) {
+ register int r;
+
+ for (r = 0; r < sectionWire->nRows; r++) {
+ XkbRowPtr row;
+ xkbRowWireDesc *rowWire;
+
+ rowWire = (xkbRowWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbRowWireDesc));
+ if (!rowWire)
+ return BadLength;
+ row = XkbAddGeomRow(section, rowWire->nKeys);
+ if (!row)
+ return BadAlloc;
+ row->top = rowWire->top;
+ row->left = rowWire->left;
+ row->vertical = rowWire->vertical;
+ if (rowWire->nKeys > 0) {
+ register int k;
+
+ for (k = 0; k < rowWire->nKeys; k++) {
+ XkbKeyPtr key;
+ xkbKeyWireDesc *keyWire;
+
+ keyWire = (xkbKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbKeyWireDesc));
+ if (!keyWire)
+ return BadLength;
+ key = XkbAddGeomKey(row);
+ if (!key)
+ return BadAlloc;
+ memcpy(key->name.name, keyWire->name, XkbKeyNameLength);
+ key->gap = keyWire->gap;
+ key->shape_ndx = keyWire->shapeNdx;
+ key->color_ndx = keyWire->colorNdx;
+ }
+ }
+ }
+ }
+ if (sectionWire->nDoodads > 0) {
+ register int d;
+
+ for (d = 0; d < sectionWire->nDoodads; d++) {
+ if ((rtrn = _XkbReadGeomDoodad(buf, geom, section)) != Success)
+ return rtrn;
+ }
+ }
+ if (sectionWire->nOverlays > 0) {
+ register int o;
+
+ for (o = 0; o < sectionWire->nOverlays; o++) {
+ if ((rtrn = _XkbReadGeomOverlay(buf, geom, section)) != Success)
+ return rtrn;
+ }
+ }
}
return Success;
}
static Status
-_XkbReadGeomDoodads( XkbReadBufferPtr buf,
- XkbGeometryPtr geom,
- xkbGetGeometryReply * rep)
+_XkbReadGeomDoodads(XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply *rep)
{
-register int d;
-Status rtrn;
-
- if (rep->nDoodads<1)
- return Success;
- if ((rtrn=XkbAllocGeomDoodads(geom,rep->nDoodads))!=Success)
- return rtrn;
- for (d=0;d<rep->nDoodads;d++) {
- if ((rtrn=_XkbReadGeomDoodad(buf,geom,NULL))!=Success)
- return rtrn;
+ register int d;
+ Status rtrn;
+
+ if (rep->nDoodads < 1)
+ return Success;
+ if ((rtrn = XkbAllocGeomDoodads(geom, rep->nDoodads)) != Success)
+ return rtrn;
+ for (d = 0; d < rep->nDoodads; d++) {
+ if ((rtrn = _XkbReadGeomDoodad(buf, geom, NULL)) != Success)
+ return rtrn;
}
return Success;
}
Status
-_XkbReadGetGeometryReply( Display * dpy,
- xkbGetGeometryReply * rep,
- XkbDescPtr xkb,
- int * nread_rtrn)
+_XkbReadGetGeometryReply(Display *dpy,
+ xkbGetGeometryReply *rep,
+ XkbDescPtr xkb,
+ int *nread_rtrn)
{
-XkbGeometryPtr geom;
+ XkbGeometryPtr geom;
- geom= _XkbTypedCalloc(1,XkbGeometryRec);
+ geom = _XkbTypedCalloc(1, XkbGeometryRec);
if (!geom)
- return BadAlloc;
+ return BadAlloc;
if (xkb->geom)
- XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
- xkb->geom= geom;
+ XkbFreeGeometry(xkb->geom, XkbGeomAllMask, True);
+ xkb->geom = geom;
- geom->name= rep->name;
- geom->width_mm= rep->widthMM;
- geom->height_mm= rep->heightMM;
+ geom->name = rep->name;
+ geom->width_mm = rep->widthMM;
+ geom->height_mm = rep->heightMM;
if (rep->length) {
- XkbReadBufferRec buf;
- int left;
- if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) {
- Status status= Success;
- if (nread_rtrn)
- *nread_rtrn= (int)rep->length*4;
- if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font))
- status= BadLength;
- if (status==Success)
- status= _XkbReadGeomProperties(&buf,geom,rep);
- if (status==Success)
- status= _XkbReadGeomColors(&buf,geom,rep);
- if (status==Success)
- status= _XkbReadGeomShapes(&buf,geom,rep);
- if (status==Success)
- status= _XkbReadGeomSections(&buf,geom,rep);
- if (status==Success)
- status= _XkbReadGeomDoodads(&buf,geom,rep);
- if (status==Success)
- status= _XkbReadGeomKeyAliases(&buf,geom,rep);
- left= _XkbFreeReadBuffer(&buf);
- if ((rep->baseColorNdx > geom->num_colors) ||
- (rep->labelColorNdx > geom->num_colors))
- status = BadLength;
- if ((status!=Success) || left || buf.error) {
- if (status==Success)
- status= BadLength;
- XkbFreeGeometry(geom,XkbGeomAllMask,True);
- xkb->geom= NULL;
- return status;
- }
- geom->base_color= &geom->colors[rep->baseColorNdx];
- geom->label_color= &geom->colors[rep->labelColorNdx];
- }
- else {
- XkbFreeGeometry(geom,XkbGeomAllMask,True);
- xkb->geom= NULL;
- return BadAlloc;
- }
+ XkbReadBufferRec buf;
+ int left;
+
+ if (_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4)) {
+ Status status = Success;
+
+ if (nread_rtrn)
+ *nread_rtrn = (int) rep->length * 4;
+ if (!_XkbGetReadBufferCountedString(&buf, &geom->label_font))
+ status = BadLength;
+ if (status == Success)
+ status = _XkbReadGeomProperties(&buf, geom, rep);
+ if (status == Success)
+ status = _XkbReadGeomColors(&buf, geom, rep);
+ if (status == Success)
+ status = _XkbReadGeomShapes(&buf, geom, rep);
+ if (status == Success)
+ status = _XkbReadGeomSections(&buf, geom, rep);
+ if (status == Success)
+ status = _XkbReadGeomDoodads(&buf, geom, rep);
+ if (status == Success)
+ status = _XkbReadGeomKeyAliases(&buf, geom, rep);
+ left = _XkbFreeReadBuffer(&buf);
+ if ((rep->baseColorNdx > geom->num_colors) ||
+ (rep->labelColorNdx > geom->num_colors))
+ status = BadLength;
+ if ((status != Success) || left || buf.error) {
+ if (status == Success)
+ status = BadLength;
+ XkbFreeGeometry(geom, XkbGeomAllMask, True);
+ xkb->geom = NULL;
+ return status;
+ }
+ geom->base_color = &geom->colors[rep->baseColorNdx];
+ geom->label_color = &geom->colors[rep->labelColorNdx];
+ }
+ else {
+ XkbFreeGeometry(geom, XkbGeomAllMask, True);
+ xkb->geom = NULL;
+ return BadAlloc;
+ }
}
return Success;
}
Status
-XkbGetGeometry(Display *dpy,XkbDescPtr xkb)
+XkbGetGeometry(Display *dpy, XkbDescPtr xkb)
{
-xkbGetGeometryReq *req;
-xkbGetGeometryReply rep;
-Status status;
+ xkbGetGeometryReq *req;
+ xkbGetGeometryReply rep;
+ Status status;
- if ( (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ if ((!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
GetReq(kbGetGeometry, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbGetGeometry;
req->deviceSpec = xkb->device_spec;
- req->name= None;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
- status = BadImplementation;
+ req->name = None;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse))
+ status = BadImplementation;
else if (!rep.found)
- status = BadName;
+ status = BadName;
else
- status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+ status = _XkbReadGetGeometryReply(dpy, &rep, xkb, NULL);
UnlockDisplay(dpy);
SyncHandle();
return status;
}
Status
-XkbGetNamedGeometry(Display *dpy,XkbDescPtr xkb,Atom name)
+XkbGetNamedGeometry(Display *dpy, XkbDescPtr xkb, Atom name)
{
-xkbGetGeometryReq *req;
-xkbGetGeometryReply rep;
-Status status;
+ xkbGetGeometryReq *req;
+ xkbGetGeometryReply rep;
+ Status status;
- if ( (name==None) || (dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
- return BadAccess;
+ if ((name == None) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
GetReq(kbGetGeometry, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbGetGeometry;
req->deviceSpec = xkb->device_spec;
- req->name= (CARD32)name;
- if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.found))
- status = BadImplementation;
+ req->name = (CARD32) name;
+ if ((!_XReply(dpy, (xReply *) &rep, 0, xFalse)) || (!rep.found))
+ status = BadImplementation;
else if (!rep.found)
- status = BadName;
+ status = BadName;
else
- status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+ status = _XkbReadGetGeometryReply(dpy, &rep, xkb, NULL);
UnlockDisplay(dpy);
SyncHandle();
return status;
}
-
diff --git a/nx-X11/lib/X11/XKBGetByName.c b/nx-X11/lib/X11/XKBGetByName.c
index 5c6eca0e2..c673781ed 100644
--- a/nx-X11/lib/X11/XKBGetByName.c
+++ b/nx-X11/lib/X11/XKBGetByName.c
@@ -35,32 +35,32 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
XkbDescPtr
-XkbGetKeyboardByName( Display * dpy,
- unsigned deviceSpec,
- XkbComponentNamesPtr names,
- unsigned want,
- unsigned need,
- Bool load)
+XkbGetKeyboardByName(Display *dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ Bool load)
{
- register xkbGetKbdByNameReq * req;
- xkbGetKbdByNameReply rep;
- int len,extraLen;
- char * str;
- XkbDescPtr xkb;
- int mapLen,codesLen,typesLen,compatLen;
- int symsLen,geomLen;
- XkbInfoPtr xkbi;
-
- if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
- return NULL;
-
- xkbi= dpy->xkb_info;
- xkb = (XkbDescRec *)_XkbCalloc(1,sizeof(XkbDescRec));
+ register xkbGetKbdByNameReq *req;
+ xkbGetKbdByNameReply rep;
+ int len, extraLen = 0;
+ char *str;
+ XkbDescPtr xkb;
+ int mapLen, codesLen, typesLen, compatLen;
+ int symsLen, geomLen;
+ XkbInfoPtr xkbi;
+
+ if ((dpy == NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return NULL;
+
+ xkbi = dpy->xkb_info;
+ xkb = (XkbDescRec *) _XkbCalloc(1, sizeof(XkbDescRec));
if (!xkb)
- return NULL;
+ return NULL;
xkb->device_spec = deviceSpec;
- xkb->map = (XkbClientMapRec *)_XkbCalloc(1,sizeof(XkbClientMapRec));
+ xkb->map = (XkbClientMapRec *) _XkbCalloc(1, sizeof(XkbClientMapRec));
xkb->dpy = dpy;
LockDisplay(dpy);
@@ -68,147 +68,159 @@ XkbGetKeyboardByName( Display * dpy,
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetKbdByName;
req->deviceSpec = xkb->device_spec;
- req->want= want;
- req->need= need;
- req->load= load;
+ req->want = want;
+ req->need = need;
+ req->load = load;
- mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ mapLen = codesLen = typesLen = compatLen = symsLen = geomLen = 0;
if (names) {
- if (names->keymap)
- mapLen= (int)strlen(names->keymap);
- if (names->keycodes)
- codesLen= (int)strlen(names->keycodes);
- if (names->types)
- typesLen= (int)strlen(names->types);
- if (names->compat)
- compatLen= (int)strlen(names->compat);
- if (names->symbols)
- symsLen= (int)strlen(names->symbols);
- if (names->geometry)
- geomLen= (int)strlen(names->geometry);
- if (mapLen>255) mapLen= 255;
- if (codesLen>255) codesLen= 255;
- if (typesLen>255) typesLen= 255;
- if (compatLen>255) compatLen= 255;
- if (symsLen>255) symsLen= 255;
- if (geomLen>255) geomLen= 255;
+ if (names->keymap)
+ mapLen = (int) strlen(names->keymap);
+ if (names->keycodes)
+ codesLen = (int) strlen(names->keycodes);
+ if (names->types)
+ typesLen = (int) strlen(names->types);
+ if (names->compat)
+ compatLen = (int) strlen(names->compat);
+ if (names->symbols)
+ symsLen = (int) strlen(names->symbols);
+ if (names->geometry)
+ geomLen = (int) strlen(names->geometry);
+ if (mapLen > 255)
+ mapLen = 255;
+ if (codesLen > 255)
+ codesLen = 255;
+ if (typesLen > 255)
+ typesLen = 255;
+ if (compatLen > 255)
+ compatLen = 255;
+ if (symsLen > 255)
+ symsLen = 255;
+ if (geomLen > 255)
+ geomLen = 255;
}
- else mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
-
- len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
- len= XkbPaddedSize(len);
- req->length+= len/4;
- BufAlloc(char *,str,len);
- *str++= mapLen;
- if (mapLen>0) {
- memcpy(str,names->keymap,mapLen);
- str+= mapLen;
+ else
+ mapLen = codesLen = typesLen = compatLen = symsLen = geomLen = 0;
+
+ len = mapLen + codesLen + typesLen + compatLen + symsLen + geomLen + 6;
+ len = XkbPaddedSize(len);
+ req->length += len / 4;
+ BufAlloc(char *, str, len);
+
+ *str++ = mapLen;
+ if (mapLen > 0) {
+ memcpy(str, names->keymap, mapLen);
+ str += mapLen;
}
- *str++= codesLen;
- if (codesLen>0) {
- memcpy(str,names->keycodes,codesLen);
- str+= codesLen;
+ *str++ = codesLen;
+ if (codesLen > 0) {
+ memcpy(str, names->keycodes, codesLen);
+ str += codesLen;
}
- *str++= typesLen;
- if (typesLen>0) {
- memcpy(str,names->types,typesLen);
- str+= typesLen;
+ *str++ = typesLen;
+ if (typesLen > 0) {
+ memcpy(str, names->types, typesLen);
+ str += typesLen;
}
- *str++= compatLen;
- if (compatLen>0) {
- memcpy(str,names->compat,compatLen);
- str+= compatLen;
+ *str++ = compatLen;
+ if (compatLen > 0) {
+ memcpy(str, names->compat, compatLen);
+ str += compatLen;
}
- *str++= symsLen;
- if (symsLen>0) {
- memcpy(str,names->symbols,symsLen);
- str+= symsLen;
+ *str++ = symsLen;
+ if (symsLen > 0) {
+ memcpy(str, names->symbols, symsLen);
+ str += symsLen;
}
- *str++= geomLen;
- if (geomLen>0) {
- memcpy(str,names->geometry,geomLen);
- str+= geomLen;
+ *str++ = geomLen;
+ if (geomLen > 0) {
+ memcpy(str, names->geometry, geomLen);
+ str += geomLen;
}
- if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.reported))
- goto BAILOUT;
- extraLen= (int)rep.length*4;
+ if ((!_XReply(dpy, (xReply *) &rep, 0, xFalse)) || (!rep.reported))
+ goto BAILOUT;
+ extraLen = (int) rep.length * 4;
- xkb->device_spec= rep.deviceID;
+ xkb->device_spec = rep.deviceID;
xkb->min_key_code = rep.minKeyCode;
xkb->max_key_code = rep.maxKeyCode;
- if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) {
- xkbGetMapReply mrep;
- Status status;
- int nread= 0;
-
- _XRead(dpy, (char *)&mrep, SIZEOF(xkbGetMapReply));
- extraLen-= SIZEOF(xkbGetMapReply);
- status= _XkbReadGetMapReply(dpy,&mrep,xkb,&nread);
- extraLen-= nread;
- if (status!=Success)
- goto BAILOUT;
+ if (rep.reported & (XkbGBN_SymbolsMask | XkbGBN_TypesMask)) {
+ xkbGetMapReply mrep;
+ Status status;
+ int nread = 0;
+
+ _XRead(dpy, (char *) &mrep, SIZEOF(xkbGetMapReply));
+ extraLen -= SIZEOF(xkbGetMapReply);
+ status = _XkbReadGetMapReply(dpy, &mrep, xkb, &nread);
+ extraLen -= nread;
+ if (status != Success)
+ goto BAILOUT;
}
- if (rep.reported&XkbGBN_CompatMapMask) {
- xkbGetCompatMapReply crep;
- Status status;
- int nread= 0;
-
- _XRead(dpy, (char *)&crep, SIZEOF(xkbGetCompatMapReply));
- extraLen-= SIZEOF(xkbGetCompatMapReply);
- status= _XkbReadGetCompatMapReply(dpy,&crep,xkb,&nread);
- extraLen-= nread;
- if (status!=Success)
- goto BAILOUT;
+ if (rep.reported & XkbGBN_CompatMapMask) {
+ xkbGetCompatMapReply crep;
+ Status status;
+ int nread = 0;
+
+ _XRead(dpy, (char *) &crep, SIZEOF(xkbGetCompatMapReply));
+ extraLen -= SIZEOF(xkbGetCompatMapReply);
+ status = _XkbReadGetCompatMapReply(dpy, &crep, xkb, &nread);
+ extraLen -= nread;
+ if (status != Success)
+ goto BAILOUT;
}
- if (rep.reported&XkbGBN_IndicatorMapMask) {
- xkbGetIndicatorMapReply irep;
- Status status;
- int nread= 0;
-
- _XRead(dpy, (char *)&irep, SIZEOF(xkbGetIndicatorMapReply));
- extraLen-= SIZEOF(xkbGetIndicatorMapReply);
- status= _XkbReadGetIndicatorMapReply(dpy,&irep,xkb,&nread);
- extraLen-= nread;
- if (status!=Success)
- goto BAILOUT;
+ if (rep.reported & XkbGBN_IndicatorMapMask) {
+ xkbGetIndicatorMapReply irep;
+ Status status;
+ int nread = 0;
+
+ _XRead(dpy, (char *) &irep, SIZEOF(xkbGetIndicatorMapReply));
+ extraLen -= SIZEOF(xkbGetIndicatorMapReply);
+ status = _XkbReadGetIndicatorMapReply(dpy, &irep, xkb, &nread);
+ extraLen -= nread;
+ if (status != Success)
+ goto BAILOUT;
}
- if (rep.reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask)) {
- xkbGetNamesReply nrep;
- Status status;
- int nread= 0;
-
- _XRead(dpy, (char *)&nrep, SIZEOF(xkbGetNamesReply));
- extraLen-= SIZEOF(xkbGetNamesReply);
- status= _XkbReadGetNamesReply(dpy,&nrep,xkb,&nread);
- extraLen-= nread;
- if (status!=Success)
- goto BAILOUT;
+ if (rep.reported & (XkbGBN_KeyNamesMask | XkbGBN_OtherNamesMask)) {
+ xkbGetNamesReply nrep;
+ Status status;
+ int nread = 0;
+
+ _XRead(dpy, (char *) &nrep, SIZEOF(xkbGetNamesReply));
+ extraLen -= SIZEOF(xkbGetNamesReply);
+ status = _XkbReadGetNamesReply(dpy, &nrep, xkb, &nread);
+ extraLen -= nread;
+ if (status != Success)
+ goto BAILOUT;
}
- if (rep.reported&XkbGBN_GeometryMask) {
- xkbGetGeometryReply grep;
- Status status;
- int nread= 0;
-
- _XRead(dpy, (char *)&grep, SIZEOF(xkbGetGeometryReply));
- extraLen-= SIZEOF(xkbGetGeometryReply);
- status= _XkbReadGetGeometryReply(dpy,&grep,xkb,&nread);
- extraLen-= nread;
- if (status!=Success)
- goto BAILOUT;
+ if (rep.reported & XkbGBN_GeometryMask) {
+ xkbGetGeometryReply grep;
+ Status status;
+ int nread = 0;
+
+ _XRead(dpy, (char *) &grep, SIZEOF(xkbGetGeometryReply));
+ extraLen -= SIZEOF(xkbGetGeometryReply);
+ status = _XkbReadGetGeometryReply(dpy, &grep, xkb, &nread);
+ extraLen -= nread;
+ if (status != Success)
+ goto BAILOUT;
}
+ if (extraLen > 0)
+ goto BAILOUT;
UnlockDisplay(dpy);
SyncHandle();
return xkb;
-BAILOUT:
- if (xkb!=NULL)
- XkbFreeKeyboard(xkb,XkbAllComponentsMask,xTrue);
+ BAILOUT:
+ if (xkb != NULL)
+ XkbFreeKeyboard(xkb, XkbAllComponentsMask, xTrue);
+ if (extraLen > 0)
+ _XEatData(dpy, extraLen);
UnlockDisplay(dpy);
SyncHandle();
return NULL;
}
XkbDescPtr
-XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec)
+XkbGetKeyboard(Display *dpy, unsigned which, unsigned deviceSpec)
{
- return XkbGetKeyboardByName(dpy,deviceSpec,NULL,which,which,False);
+ return XkbGetKeyboardByName(dpy, deviceSpec, NULL, which, which, False);
}
diff --git a/nx-X11/lib/X11/XKBGetMap.c b/nx-X11/lib/X11/XKBGetMap.c
index 391d7aa89..6e3c74343 100644
--- a/nx-X11/lib/X11/XKBGetMap.c
+++ b/nx-X11/lib/X11/XKBGetMap.c
@@ -24,7 +24,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-
#define NEED_MAP_READERS
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -34,429 +33,445 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "XKBlibint.h"
static Status
-_XkbReadKeyTypes(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadKeyTypes(XkbReadBufferPtr buf, XkbDescPtr xkb, xkbGetMapReply *rep)
{
-int i,n,lastMapCount;
-XkbKeyTypePtr type;
-
- if ( rep->nTypes>0 ) {
- n = rep->firstType+rep->nTypes;
- if (xkb->map->num_types>=n)
- n= xkb->map->num_types;
- else if (XkbAllocClientMap(xkb,XkbKeyTypesMask,n)!=Success)
- return BadAlloc;
-
- type = &xkb->map->types[rep->firstType];
- for (i=0;i<(int)rep->nTypes;i++,type++) {
- xkbKeyTypeWireDesc *desc;
- register int ndx;
-
- ndx= i+rep->firstType;
- if (ndx>=xkb->map->num_types)
- xkb->map->num_types= ndx+1;
-
- desc= (xkbKeyTypeWireDesc *)_XkbGetReadBufferPtr(buf,
- SIZEOF(xkbKeyTypeWireDesc));
- if (desc==NULL)
- return BadLength;
-
- lastMapCount= type->map_count;
- if ( desc->nMapEntries>0 ) {
- if ((type->map==NULL)||(desc->nMapEntries>type->map_count)) {
- XkbKTMapEntryRec *prev_map = type->map;
-
- type->map= _XkbTypedRealloc(type->map,desc->nMapEntries,
- XkbKTMapEntryRec);
- if (type->map==NULL) {
- _XkbFree(prev_map);
- return BadAlloc;
- }
- }
- }
- else if (type->map!=NULL) {
- Xfree(type->map);
- type->map_count= 0;
- type->map= NULL;
- }
-
- if ( desc->preserve && (desc->nMapEntries>0) ) {
- if ((!type->preserve)||
- (desc->nMapEntries>lastMapCount)) {
- XkbModsRec *prev_preserve = type->preserve;
-
- type->preserve= _XkbTypedRealloc(type->preserve,
- desc->nMapEntries,
- XkbModsRec);
- if (type->preserve==NULL) {
- _XkbFree(prev_preserve);
- return BadAlloc;
- }
- }
- }
- else if (type->preserve!=NULL) {
- Xfree(type->preserve);
- type->preserve= NULL;
- }
-
- type->mods.mask = desc->mask;
- type->mods.real_mods = desc->realMods;
- type->mods.vmods = desc->virtualMods;
- type->num_levels = desc->numLevels;
- type->map_count = desc->nMapEntries;
- if (desc->nMapEntries>0) {
- register xkbKTMapEntryWireDesc *wire;
- register XkbKTMapEntryPtr entry;
- register int size;
-
- size= type->map_count*SIZEOF(xkbKTMapEntryWireDesc);
- wire= (xkbKTMapEntryWireDesc *)_XkbGetReadBufferPtr(buf,size);
- if (wire==NULL)
- return BadLength;
- entry= type->map;
- for (n=0;n<type->map_count;n++,wire++,entry++) {
- entry->active= wire->active;
- entry->level= wire->level;
- entry->mods.mask= wire->mask;
- entry->mods.real_mods= wire->realMods;
- entry->mods.vmods= wire->virtualMods;
- }
-
- if (desc->preserve) {
- register xkbModsWireDesc * pwire;
- register XkbModsPtr preserve;
- register int sz;
-
- sz= desc->nMapEntries*SIZEOF(xkbModsWireDesc);
- pwire=(xkbModsWireDesc *)_XkbGetReadBufferPtr(buf,sz);
- if (pwire==NULL)
- return BadLength;
- preserve= type->preserve;
- for (n=0;n<desc->nMapEntries;n++,pwire++,preserve++) {
- preserve->mask= pwire->mask;
- preserve->vmods= pwire->virtualMods;
- preserve->real_mods= pwire->realMods;
- }
- }
- }
- }
+ int i, n, lastMapCount;
+ XkbKeyTypePtr type;
+
+ if (rep->nTypes > 0) {
+ n = rep->firstType + rep->nTypes;
+ if (xkb->map->num_types >= n)
+ n = xkb->map->num_types;
+ else if (XkbAllocClientMap(xkb, XkbKeyTypesMask, n) != Success)
+ return BadAlloc;
+
+ type = &xkb->map->types[rep->firstType];
+ for (i = 0; i < (int) rep->nTypes; i++, type++) {
+ xkbKeyTypeWireDesc *desc;
+ register int ndx;
+
+ ndx = i + rep->firstType;
+ if (ndx >= xkb->map->num_types)
+ xkb->map->num_types = ndx + 1;
+
+ desc = (xkbKeyTypeWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbKeyTypeWireDesc));
+ if (desc == NULL)
+ return BadLength;
+
+ lastMapCount = type->map_count;
+ if (desc->nMapEntries > 0) {
+ if ((type->map == NULL) ||
+ (desc->nMapEntries > type->map_count)) {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ type->map = _XkbTypedRealloc(type->map, desc->nMapEntries,
+ XkbKTMapEntryRec);
+ if (type->map == NULL) {
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->map != NULL) {
+ Xfree(type->map);
+ type->map_count = 0;
+ type->map = NULL;
+ }
+
+ if (desc->preserve && (desc->nMapEntries > 0)) {
+ if ((!type->preserve) || (desc->nMapEntries > lastMapCount)) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ type->preserve = _XkbTypedRealloc(type->preserve,
+ desc->nMapEntries,
+ XkbModsRec);
+ if (type->preserve == NULL) {
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->preserve != NULL) {
+ Xfree(type->preserve);
+ type->preserve = NULL;
+ }
+
+ type->mods.mask = desc->mask;
+ type->mods.real_mods = desc->realMods;
+ type->mods.vmods = desc->virtualMods;
+ type->num_levels = desc->numLevels;
+ type->map_count = desc->nMapEntries;
+ if (desc->nMapEntries > 0) {
+ register xkbKTMapEntryWireDesc *wire;
+ register XkbKTMapEntryPtr entry;
+ register int size;
+
+ size = type->map_count * SIZEOF(xkbKTMapEntryWireDesc);
+ wire =
+ (xkbKTMapEntryWireDesc *) _XkbGetReadBufferPtr(buf, size);
+ if (wire == NULL)
+ return BadLength;
+ entry = type->map;
+ for (n = 0; n < type->map_count; n++, wire++, entry++) {
+ entry->active = wire->active;
+ entry->level = wire->level;
+ entry->mods.mask = wire->mask;
+ entry->mods.real_mods = wire->realMods;
+ entry->mods.vmods = wire->virtualMods;
+ }
+
+ if (desc->preserve) {
+ register xkbModsWireDesc *pwire;
+ register XkbModsPtr preserve;
+ register int sz;
+
+ sz = desc->nMapEntries * SIZEOF(xkbModsWireDesc);
+ pwire = (xkbModsWireDesc *) _XkbGetReadBufferPtr(buf, sz);
+ if (pwire == NULL)
+ return BadLength;
+ preserve = type->preserve;
+ for (n = 0; n < desc->nMapEntries; n++, pwire++, preserve++) {
+ preserve->mask = pwire->mask;
+ preserve->vmods = pwire->virtualMods;
+ preserve->real_mods = pwire->realMods;
+ }
+ }
+ }
+ }
}
return Success;
}
static Status
-_XkbReadKeySyms(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadKeySyms(XkbReadBufferPtr buf, XkbDescPtr xkb, xkbGetMapReply *rep)
{
-register int i;
-XkbClientMapPtr map;
-
- map= xkb->map;
- if (map->key_sym_map==NULL) {
- register int offset;
- int size = xkb->max_key_code + 1;
- XkbSymMapPtr oldMap;
- xkbSymMapWireDesc *newMap;
- if (((unsigned short)rep->firstKeySym + rep->nKeySyms) > size)
- return BadLength;
- map->key_sym_map= _XkbTypedCalloc(size,XkbSymMapRec);
- if (map->key_sym_map==NULL)
- return BadAlloc;
- if (map->syms==NULL) {
- int sz;
- sz= (rep->totalSyms*12)/10;
- sz= ((sz+(unsigned)128)/128)*128;
- map->syms = _XkbTypedCalloc(sz,KeySym);
- if (map->syms==NULL)
- return BadAlloc;
- map->size_syms = sz;
- }
- offset = 1;
- oldMap = &map->key_sym_map[rep->firstKeySym];
- for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
- newMap= (xkbSymMapWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
- if (newMap==NULL)
- return BadLength;
- oldMap->kt_index[0]= newMap->ktIndex[0];
- oldMap->kt_index[1]= newMap->ktIndex[1];
- oldMap->kt_index[2]= newMap->ktIndex[2];
- oldMap->kt_index[3]= newMap->ktIndex[3];
- oldMap->group_info= newMap->groupInfo;
- oldMap->width= newMap->width;
- oldMap->offset= offset;
- if (offset+newMap->nSyms>=map->size_syms) {
- register int sz;
- KeySym *prev_syms = map->syms;
-
- sz= map->size_syms+128;
- map->syms= _XkbTypedRealloc(map->syms,sz,KeySym);
- if (map->syms==NULL) {
- _XkbFree(prev_syms);
- map->size_syms= 0;
- return BadAlloc;
- }
- map->size_syms= sz;
- }
- if (newMap->nSyms>0) {
- _XkbReadBufferCopyKeySyms(buf,(KeySym *)&map->syms[offset],
- newMap->nSyms);
- offset+= newMap->nSyms;
- }
- else {
- map->syms[offset]= 0;
- }
- }
- map->num_syms= offset;
+ register int i;
+ XkbClientMapPtr map;
+ int size = xkb->max_key_code + 1;
+
+ if (((unsigned short) rep->firstKeySym + rep->nKeySyms) > size)
+ return BadLength;
+
+ map = xkb->map;
+ if (map->key_sym_map == NULL) {
+ register int offset;
+ XkbSymMapPtr oldMap;
+ xkbSymMapWireDesc *newMap;
+
+ map->key_sym_map = _XkbTypedCalloc(size, XkbSymMapRec);
+ if (map->key_sym_map == NULL)
+ return BadAlloc;
+ if (map->syms == NULL) {
+ int sz;
+
+ sz = (rep->totalSyms * 12) / 10;
+ sz = ((sz + (unsigned) 128) / 128) * 128;
+ map->syms = _XkbTypedCalloc(sz, KeySym);
+ if (map->syms == NULL)
+ return BadAlloc;
+ map->size_syms = sz;
+ }
+ offset = 1;
+ oldMap = &map->key_sym_map[rep->firstKeySym];
+ for (i = 0; i < (int) rep->nKeySyms; i++, oldMap++) {
+ newMap = (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbSymMapWireDesc));
+ if (newMap == NULL)
+ return BadLength;
+ oldMap->kt_index[0] = newMap->ktIndex[0];
+ oldMap->kt_index[1] = newMap->ktIndex[1];
+ oldMap->kt_index[2] = newMap->ktIndex[2];
+ oldMap->kt_index[3] = newMap->ktIndex[3];
+ oldMap->group_info = newMap->groupInfo;
+ oldMap->width = newMap->width;
+ oldMap->offset = offset;
+ if (offset + newMap->nSyms >= map->size_syms) {
+ register int sz;
+ KeySym *prev_syms = map->syms;
+
+ sz = map->size_syms + 128;
+ map->syms = _XkbTypedRealloc(map->syms, sz, KeySym);
+ if (map->syms == NULL) {
+ _XkbFree(prev_syms);
+ map->size_syms = 0;
+ return BadAlloc;
+ }
+ map->size_syms = sz;
+ }
+ if (newMap->nSyms > 0) {
+ _XkbReadBufferCopyKeySyms(buf, (KeySym *) &map->syms[offset],
+ newMap->nSyms);
+ offset += newMap->nSyms;
+ }
+ else {
+ map->syms[offset] = 0;
+ }
+ }
+ map->num_syms = offset;
}
else {
- xkbSymMapWireDesc * newMap;
- XkbSymMapPtr oldMap;
- KeySym * newSyms;
- int tmp;
-
- if (((unsigned short)rep->firstKeySym + rep->nKeySyms) > map->num_syms)
- return BadLength;
- oldMap = &map->key_sym_map[rep->firstKeySym];
- for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
- newMap= (xkbSymMapWireDesc *)
- _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
- if (newMap==NULL)
- return BadLength;
-
- if (newMap->nSyms>0)
- tmp= newMap->nSyms;
- else tmp= 0;
-
- newSyms = XkbResizeKeySyms(xkb,i+rep->firstKeySym,tmp);
- if (newSyms==NULL)
- return BadAlloc;
- if (newMap->nSyms>0)
- _XkbReadBufferCopyKeySyms(buf,newSyms,newMap->nSyms);
- else newSyms[0]= NoSymbol;
- oldMap->kt_index[0] = newMap->ktIndex[0];
- oldMap->kt_index[1] = newMap->ktIndex[1];
- oldMap->kt_index[2] = newMap->ktIndex[2];
- oldMap->kt_index[3] = newMap->ktIndex[3];
- oldMap->group_info = newMap->groupInfo;
- oldMap->width = newMap->width;
- }
+ XkbSymMapPtr oldMap = &map->key_sym_map[rep->firstKeySym];
+
+ for (i = 0; i < (int) rep->nKeySyms; i++, oldMap++) {
+ xkbSymMapWireDesc *newMap;
+ KeySym *newSyms;
+ int tmp;
+
+ newMap = (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf, SIZEOF(xkbSymMapWireDesc));
+ if (newMap == NULL)
+ return BadLength;
+
+ if (newMap->nSyms > 0)
+ tmp = newMap->nSyms;
+ else
+ tmp = 0;
+
+ newSyms = XkbResizeKeySyms(xkb, i + rep->firstKeySym, tmp);
+ if (newSyms == NULL)
+ return BadAlloc;
+ if (newMap->nSyms > 0)
+ _XkbReadBufferCopyKeySyms(buf, newSyms, newMap->nSyms);
+ else
+ newSyms[0] = NoSymbol;
+ oldMap->kt_index[0] = newMap->ktIndex[0];
+ oldMap->kt_index[1] = newMap->ktIndex[1];
+ oldMap->kt_index[2] = newMap->ktIndex[2];
+ oldMap->kt_index[3] = newMap->ktIndex[3];
+ oldMap->group_info = newMap->groupInfo;
+ oldMap->width = newMap->width;
+ }
}
return Success;
}
static Status
-_XkbReadKeyActions(XkbReadBufferPtr buf,XkbDescPtr info,xkbGetMapReply *rep)
+_XkbReadKeyActions(XkbReadBufferPtr buf, XkbDescPtr info, xkbGetMapReply *rep)
{
-int i;
-CARD8 numDescBuf[248];
-CARD8* numDesc = NULL;
-register int nKeyActs;
-Status ret = Success;
-
- if ( (nKeyActs=rep->nKeyActs)>0 ) {
- XkbSymMapPtr symMap;
-
- if (nKeyActs < sizeof numDescBuf) numDesc = numDescBuf;
- else numDesc = Xmalloc (nKeyActs * sizeof(CARD8));
-
- if (!_XkbCopyFromReadBuffer(buf, (char *)numDesc, nKeyActs)) {
- ret = BadLength;
- goto done;
- }
- i= XkbPaddedSize(nKeyActs)-nKeyActs;
- if ((i>0)&&(!_XkbSkipReadBufferData(buf,i))) {
- ret = BadLength;
- goto done;
- }
- symMap = &info->map->key_sym_map[rep->firstKeyAct];
- for (i=0;i<(int)rep->nKeyActs;i++,symMap++) {
- if (numDesc[i]==0) {
- if ((i + rep->firstKeyAct) > (info->max_key_code + 1)) {
- ret = BadLength;
- goto done;
- }
- info->server->key_acts[i+rep->firstKeyAct]= 0;
- }
- else {
- XkbAction *newActs;
- /* 8/16/93 (ef) -- XXX! Verify size here (numdesc must be */
- /* either zero or XkbKeyNumSyms(info,key) */
- newActs=XkbResizeKeyActions(info,i+rep->firstKeyAct,
- numDesc[i]);
- if (newActs==NULL) {
- ret = BadAlloc;
- goto done;
- }
- if (!_XkbCopyFromReadBuffer(buf,(char *)newActs,
- (int)(numDesc[i]*sizeof(XkbAction)))) {
- ret = BadLength;
- goto done;
- }
- }
- }
+ int i;
+ CARD8 numDescBuf[248];
+ CARD8 *numDesc = NULL;
+ register int nKeyActs;
+ Status ret = Success;
+
+ if ((nKeyActs = rep->nKeyActs) > 0) {
+ XkbSymMapPtr symMap;
+
+ if (nKeyActs < sizeof numDescBuf)
+ numDesc = numDescBuf;
+ else
+ numDesc = Xmalloc(nKeyActs * sizeof(CARD8));
+
+ if (!_XkbCopyFromReadBuffer(buf, (char *) numDesc, nKeyActs)) {
+ ret = BadLength;
+ goto done;
+ }
+ i = XkbPaddedSize(nKeyActs) - nKeyActs;
+ if ((i > 0) && (!_XkbSkipReadBufferData(buf, i))) {
+ ret = BadLength;
+ goto done;
+ }
+ symMap = &info->map->key_sym_map[rep->firstKeyAct];
+ for (i = 0; i < (int) rep->nKeyActs; i++, symMap++) {
+ if (numDesc[i] == 0) {
+ if ((i + rep->firstKeyAct) > (info->max_key_code + 1)) {
+ ret = BadLength;
+ goto done;
+ }
+ info->server->key_acts[i + rep->firstKeyAct] = 0;
+ }
+ else {
+ XkbAction *newActs;
+
+ /* 8/16/93 (ef) -- XXX! Verify size here (numdesc must be */
+ /* either zero or XkbKeyNumSyms(info,key) */
+ newActs = XkbResizeKeyActions(info, i + rep->firstKeyAct,
+ numDesc[i]);
+ if (newActs == NULL) {
+ ret = BadAlloc;
+ goto done;
+ }
+ if (!_XkbCopyFromReadBuffer(buf, (char *) newActs,
+ (int) (numDesc[i] * sizeof(XkbAction)))) {
+ ret = BadLength;
+ goto done;
+ }
+ }
+ }
}
-done:
- if (numDesc != NULL && numDesc != numDescBuf) Xfree (numDesc);
+ done:
+ if (numDesc != NULL && numDesc != numDescBuf)
+ Xfree(numDesc);
return ret;
}
static Status
-_XkbReadKeyBehaviors(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadKeyBehaviors(XkbReadBufferPtr buf, XkbDescPtr xkb, xkbGetMapReply *rep)
{
-register int i;
-xkbBehaviorWireDesc *wire;
-
- if ( rep->totalKeyBehaviors>0 ) {
- int size = xkb->max_key_code + 1;
- if ( ((int) rep->firstKeyBehavior + rep->nKeyBehaviors) > size)
- return BadLength;
- if ( xkb->server->behaviors == NULL ) {
- xkb->server->behaviors = _XkbTypedCalloc(size,XkbBehavior);
- if (xkb->server->behaviors==NULL)
- return BadAlloc;
- }
- else {
- bzero(&xkb->server->behaviors[rep->firstKeyBehavior],
- (rep->nKeyBehaviors*sizeof(XkbBehavior)));
- }
- for (i=0;i<rep->totalKeyBehaviors;i++) {
- wire= (xkbBehaviorWireDesc *)_XkbGetReadBufferPtr(buf,
- SIZEOF(xkbBehaviorWireDesc));
- if (wire==NULL || wire->key >= size)
- return BadLength;
- xkb->server->behaviors[wire->key].type= wire->type;
- xkb->server->behaviors[wire->key].data= wire->data;
- }
+ register int i;
+
+ if (rep->totalKeyBehaviors > 0) {
+ int size = xkb->max_key_code + 1;
+
+ if (((int) rep->firstKeyBehavior + rep->nKeyBehaviors) > size)
+ return BadLength;
+ if (xkb->server->behaviors == NULL) {
+ xkb->server->behaviors = _XkbTypedCalloc(size, XkbBehavior);
+ if (xkb->server->behaviors == NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->behaviors[rep->firstKeyBehavior],
+ (rep->nKeyBehaviors * sizeof(XkbBehavior)));
+ }
+ for (i = 0; i < rep->totalKeyBehaviors; i++) {
+ xkbBehaviorWireDesc *wire;
+
+ wire = (xkbBehaviorWireDesc *) _XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbBehaviorWireDesc));
+ if (wire == NULL || wire->key >= size)
+ return BadLength;
+ xkb->server->behaviors[wire->key].type = wire->type;
+ xkb->server->behaviors[wire->key].data = wire->data;
+ }
}
return Success;
}
static Status
-_XkbReadVirtualMods(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadVirtualMods(XkbReadBufferPtr buf, XkbDescPtr xkb, xkbGetMapReply *rep)
{
- if ( rep->virtualMods ) {
- register int i,bit,nVMods;
- register char *data;
-
- for (i=nVMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if (rep->virtualMods&bit)
- nVMods++;
- }
- data= _XkbGetReadBufferPtr(buf,XkbPaddedSize(nVMods));
- if (data==NULL)
- return BadLength;
- for (i=0,bit=1;(i<XkbNumVirtualMods)&&(nVMods>0);i++,bit<<=1) {
- if (rep->virtualMods&bit) {
- xkb->server->vmods[i]= *data++;
- nVMods--;
- }
- }
+ if (rep->virtualMods) {
+ register int i, bit, nVMods;
+ register char *data;
+
+ for (i = nVMods = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (rep->virtualMods & bit)
+ nVMods++;
+ }
+ data = _XkbGetReadBufferPtr(buf, XkbPaddedSize(nVMods));
+ if (data == NULL)
+ return BadLength;
+ for (i = 0, bit = 1; (i < XkbNumVirtualMods) && (nVMods > 0);
+ i++, bit <<= 1) {
+ if (rep->virtualMods & bit) {
+ xkb->server->vmods[i] = *data++;
+ nVMods--;
+ }
+ }
}
return Success;
}
static Status
-_XkbReadExplicitComponents( XkbReadBufferPtr buf,
- XkbDescPtr xkb,
- xkbGetMapReply * rep)
+_XkbReadExplicitComponents(XkbReadBufferPtr buf,
+ XkbDescPtr xkb,
+ xkbGetMapReply *rep)
{
-register int i;
-unsigned char *wire;
-
- if ( rep->totalKeyExplicit>0 ) {
- int size = xkb->max_key_code + 1;
- if ( ((int) rep->firstKeyExplicit + rep->nKeyExplicit) > size)
- return BadLength;
- if ( xkb->server->explicit == NULL ) {
- xkb->server->explicit = _XkbTypedCalloc(size,unsigned char);
- if (xkb->server->explicit==NULL)
- return BadAlloc;
- }
- else {
- bzero(&xkb->server->explicit[rep->firstKeyExplicit],
- rep->nKeyExplicit);
- }
- i= XkbPaddedSize(2*rep->totalKeyExplicit);
- wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
- if (!wire)
- return BadLength;
- for (i=0;i<rep->totalKeyExplicit;i++,wire+=2) {
- if (wire[0] > xkb->max_key_code || wire[1] > xkb->max_key_code)
- return BadLength;
- xkb->server->explicit[wire[0]]= wire[1];
- }
+ register int i;
+ unsigned char *wire;
+
+ if (rep->totalKeyExplicit > 0) {
+ int size = xkb->max_key_code + 1;
+
+ if (((int) rep->firstKeyExplicit + rep->nKeyExplicit) > size)
+ return BadLength;
+ if (xkb->server->explicit == NULL) {
+ xkb->server->explicit = _XkbTypedCalloc(size, unsigned char);
+
+ if (xkb->server->explicit == NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->explicit[rep->firstKeyExplicit],
+ rep->nKeyExplicit);
+ }
+ i = XkbPaddedSize(2 * rep->totalKeyExplicit);
+ wire = (unsigned char *) _XkbGetReadBufferPtr(buf, i);
+ if (!wire)
+ return BadLength;
+ for (i = 0; i < rep->totalKeyExplicit; i++, wire += 2) {
+ if (wire[0] > xkb->max_key_code || wire[1] > xkb->max_key_code)
+ return BadLength;
+ xkb->server->explicit[wire[0]] = wire[1];
+ }
}
return Success;
}
static Status
-_XkbReadModifierMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadModifierMap(XkbReadBufferPtr buf, XkbDescPtr xkb, xkbGetMapReply *rep)
{
-register int i;
-unsigned char *wire;
-
- if ( rep->totalModMapKeys>0 ) {
- if ( ((int)rep->firstModMapKey + rep->nModMapKeys) >
- (xkb->max_key_code + 1))
- return BadLength;
- if ((xkb->map->modmap==NULL)&&
- (XkbAllocClientMap(xkb,XkbModifierMapMask,0)!=Success)) {
- return BadAlloc;
- }
- else {
- bzero(&xkb->map->modmap[rep->firstModMapKey],rep->nModMapKeys);
- }
- i= XkbPaddedSize(2*rep->totalModMapKeys);
- wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
- if (!wire)
- return BadLength;
- for (i=0;i<rep->totalModMapKeys;i++,wire+=2) {
- if (wire[0] > xkb->max_key_code || wire[1] > xkb->max_key_code)
- return BadLength;
- xkb->map->modmap[wire[0]]= wire[1];
- }
+ register int i;
+ unsigned char *wire;
+
+ if (rep->totalModMapKeys > 0) {
+ if (((int) rep->firstModMapKey + rep->nModMapKeys) >
+ (xkb->max_key_code + 1))
+ return BadLength;
+ if ((xkb->map->modmap == NULL) &&
+ (XkbAllocClientMap(xkb, XkbModifierMapMask, 0) != Success)) {
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->map->modmap[rep->firstModMapKey], rep->nModMapKeys);
+ }
+ i = XkbPaddedSize(2 * rep->totalModMapKeys);
+ wire = (unsigned char *) _XkbGetReadBufferPtr(buf, i);
+ if (!wire)
+ return BadLength;
+ for (i = 0; i < rep->totalModMapKeys; i++, wire += 2) {
+ if (wire[0] > xkb->max_key_code || wire[1] > xkb->max_key_code)
+ return BadLength;
+ xkb->map->modmap[wire[0]] = wire[1];
+ }
}
return Success;
}
static Status
-_XkbReadVirtualModMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+_XkbReadVirtualModMap(XkbReadBufferPtr buf,
+ XkbDescPtr xkb,
+ xkbGetMapReply *rep)
{
-register int i;
-xkbVModMapWireDesc * wire;
-XkbServerMapPtr srv;
-
- if ( rep->totalVModMapKeys>0 ) {
- if (((int) rep->firstVModMapKey + rep->nVModMapKeys)
- > xkb->max_key_code + 1)
- return BadLength;
- if (((xkb->server==NULL)||(xkb->server->vmodmap==NULL))&&
- (XkbAllocServerMap(xkb,XkbVirtualModMapMask,0)!=Success)) {
- return BadAlloc;
- }
- else {
- srv= xkb->server;
- if (rep->nVModMapKeys > rep->firstVModMapKey)
- bzero((char *)&srv->vmodmap[rep->firstVModMapKey],
- (rep->nVModMapKeys - rep->firstVModMapKey) *
- sizeof(unsigned short));
- }
- srv= xkb->server;
- i= rep->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
- wire=(xkbVModMapWireDesc *)_XkbGetReadBufferPtr(buf,i);
- if (!wire)
- return BadLength;
- for (i=0;i<rep->totalVModMapKeys;i++,wire++) {
- if ((wire->key>=xkb->min_key_code)&&(wire->key<=xkb->max_key_code))
- srv->vmodmap[wire->key]= wire->vmods;
- }
+ register int i;
+ xkbVModMapWireDesc *wire;
+ XkbServerMapPtr srv;
+
+ if (rep->totalVModMapKeys > 0) {
+ if (((int) rep->firstVModMapKey + rep->nVModMapKeys)
+ > xkb->max_key_code + 1)
+ return BadLength;
+ if (((xkb->server == NULL) || (xkb->server->vmodmap == NULL)) &&
+ (XkbAllocServerMap(xkb, XkbVirtualModMapMask, 0) != Success)) {
+ return BadAlloc;
+ }
+ else {
+ srv = xkb->server;
+ if (rep->nVModMapKeys > rep->firstVModMapKey)
+ bzero((char *) &srv->vmodmap[rep->firstVModMapKey],
+ (rep->nVModMapKeys - rep->firstVModMapKey) *
+ sizeof(unsigned short));
+ }
+ srv = xkb->server;
+ i = rep->totalVModMapKeys * SIZEOF(xkbVModMapWireDesc);
+ wire = (xkbVModMapWireDesc *) _XkbGetReadBufferPtr(buf, i);
+ if (!wire)
+ return BadLength;
+ for (i = 0; i < rep->totalVModMapKeys; i++, wire++) {
+ if ((wire->key >= xkb->min_key_code) &&
+ (wire->key <= xkb->max_key_code))
+ srv->vmodmap[wire->key] = wire->vmods;
+ }
}
return Success;
}
static xkbGetMapReq *
-_XkbGetGetMapReq(Display *dpy,XkbDescPtr xkb)
+_XkbGetGetMapReq(Display *dpy, XkbDescPtr xkb)
{
-xkbGetMapReq *req;
+ xkbGetMapReq *req;
GetReq(kbGetMap, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
@@ -475,142 +490,147 @@ xkbGetMapReq *req;
}
Status
-_XkbReadGetMapReply( Display * dpy,
- xkbGetMapReply *rep,
- XkbDescPtr xkb,
- int * nread_rtrn)
+_XkbReadGetMapReply(Display *dpy,
+ xkbGetMapReply *rep,
+ XkbDescPtr xkb,
+ int *nread_rtrn)
{
-int extraData;
-unsigned mask;
+ int extraData;
+ unsigned mask;
- if ( xkb->device_spec == XkbUseCoreKbd )
- xkb->device_spec= rep->deviceID;
- if ( rep->maxKeyCode < rep->minKeyCode )
- return BadImplementation;
+ if (xkb->device_spec == XkbUseCoreKbd)
+ xkb->device_spec = rep->deviceID;
+ if (rep->maxKeyCode < rep->minKeyCode)
+ return BadImplementation;
xkb->min_key_code = rep->minKeyCode;
xkb->max_key_code = rep->maxKeyCode;
if (!xkb->map) {
- mask= rep->present&XkbAllClientInfoMask;
- if (mask&&(XkbAllocClientMap(xkb,mask,rep->nTypes)!=Success))
- return BadAlloc;
+ mask = rep->present & XkbAllClientInfoMask;
+ if (mask && (XkbAllocClientMap(xkb, mask, rep->nTypes) != Success))
+ return BadAlloc;
}
if (!xkb->server) {
- mask= rep->present&XkbAllServerInfoMask;
- if (mask&&(XkbAllocServerMap(xkb,mask,rep->totalActs)!=Success))
- return BadAlloc;
+ mask = rep->present & XkbAllServerInfoMask;
+ if (mask && (XkbAllocServerMap(xkb, mask, rep->totalActs) != Success))
+ return BadAlloc;
}
- extraData= (int)(rep->length*4);
- extraData-= (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
+ extraData = (int) (rep->length * 4);
+ extraData -= (SIZEOF(xkbGetMapReply) - SIZEOF(xGenericReply));
if (rep->length) {
- XkbReadBufferRec buf;
- int left;
- if (_XkbInitReadBuffer(dpy,&buf,extraData)) {
- Status status= Success;
- if (nread_rtrn!=NULL)
- *nread_rtrn= extraData;
- if (status==Success)
- status= _XkbReadKeyTypes(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadKeySyms(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadKeyActions(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadKeyBehaviors(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadVirtualMods(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadExplicitComponents(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadModifierMap(&buf,xkb,rep);
- if (status==Success)
- status= _XkbReadVirtualModMap(&buf,xkb,rep);
- left= _XkbFreeReadBuffer(&buf);
- if (status!=Success) return status;
- else if ( left || buf.error ) return BadLength;
- }
- else return BadAlloc;
+ XkbReadBufferRec buf;
+ int left;
+
+ if (_XkbInitReadBuffer(dpy, &buf, extraData)) {
+ Status status = Success;
+
+ if (nread_rtrn != NULL)
+ *nread_rtrn = extraData;
+ if (status == Success)
+ status = _XkbReadKeyTypes(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadKeySyms(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadKeyActions(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadKeyBehaviors(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadVirtualMods(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadExplicitComponents(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadModifierMap(&buf, xkb, rep);
+ if (status == Success)
+ status = _XkbReadVirtualModMap(&buf, xkb, rep);
+ left = _XkbFreeReadBuffer(&buf);
+ if (status != Success)
+ return status;
+ else if (left || buf.error)
+ return BadLength;
+ }
+ else
+ return BadAlloc;
}
return Success;
}
static Status
-_XkbHandleGetMapReply(Display *dpy,XkbDescPtr xkb)
+_XkbHandleGetMapReply(Display *dpy, XkbDescPtr xkb)
{
-xkbGetMapReply rep;
+ xkbGetMapReply rep;
- if (!_XReply(dpy, (xReply *)&rep,
- ( (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)) >> 2 ),
- xFalse)) {
- return BadImplementation;
+ if (!_XReply(dpy, (xReply *) &rep,
+ ((SIZEOF(xkbGetMapReply) - SIZEOF(xGenericReply)) >> 2),
+ xFalse)) {
+ return BadImplementation;
}
- return _XkbReadGetMapReply(dpy,&rep,xkb,NULL);
+ return _XkbReadGetMapReply(dpy, &rep, xkb, NULL);
}
Status
-XkbGetUpdatedMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+XkbGetUpdatedMap(Display *dpy, unsigned which, XkbDescPtr xkb)
{
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
if (which) {
- register xkbGetMapReq *req;
- Status status;
+ register xkbGetMapReq *req;
+ Status status;
- LockDisplay(dpy);
+ LockDisplay(dpy);
- req = _XkbGetGetMapReq(dpy, xkb);
- req->full = which;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = which;
+ status = _XkbHandleGetMapReply(dpy, xkb);
- UnlockDisplay(dpy);
- SyncHandle();
- return status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
}
return Success;
}
XkbDescPtr
-XkbGetMap(Display *dpy,unsigned which,unsigned deviceSpec)
+XkbGetMap(Display *dpy, unsigned which, unsigned deviceSpec)
{
-XkbDescPtr xkb;
+ XkbDescPtr xkb;
- xkb = _XkbTypedCalloc(1,XkbDescRec);
+ xkb = _XkbTypedCalloc(1, XkbDescRec);
if (xkb) {
- xkb->device_spec = deviceSpec;
- xkb->map = _XkbTypedCalloc(1,XkbClientMapRec);
- if ((xkb->map==NULL)||
- ((which)&&(XkbGetUpdatedMap(dpy,which,xkb)!=Success))) {
- if (xkb->map) {
- Xfree(xkb->map);
- xkb->map= NULL;
- }
- Xfree(xkb);
- return NULL;
- }
- xkb->dpy= dpy;
+ xkb->device_spec = deviceSpec;
+ xkb->map = _XkbTypedCalloc(1, XkbClientMapRec);
+ if ((xkb->map == NULL) ||
+ ((which) && (XkbGetUpdatedMap(dpy, which, xkb) != Success))) {
+ if (xkb->map) {
+ Xfree(xkb->map);
+ xkb->map = NULL;
+ }
+ Xfree(xkb);
+ return NULL;
+ }
+ xkb->dpy = dpy;
}
return xkb;
}
Status
-XkbGetKeyTypes(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeyTypes(Display *dpy, unsigned first, unsigned num, XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
- if ((num<1)||(num>XkbMaxKeyTypes))
- return BadValue;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
+ if ((num < 1) || (num > XkbMaxKeyTypes))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstType = first;
req->nTypes = num;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
UnlockDisplay(dpy);
SyncHandle();
@@ -618,24 +638,24 @@ XkbGetKeyTypes(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetKeyActions(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeyActions(Display *dpy, unsigned first, unsigned num, XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstKeyAct = first;
req->nKeyActs = num;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
UnlockDisplay(dpy);
SyncHandle();
@@ -643,24 +663,24 @@ XkbGetKeyActions(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetKeySyms(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeySyms(Display *dpy, unsigned first, unsigned num, XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstKeySym = first;
req->nKeySyms = num;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
UnlockDisplay(dpy);
SyncHandle();
@@ -669,24 +689,24 @@ XkbGetKeySyms(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetKeyBehaviors(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeyBehaviors(Display *dpy, unsigned first, unsigned num, XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstKeyBehavior = first;
req->nKeyBehaviors = num;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
UnlockDisplay(dpy);
SyncHandle();
@@ -694,20 +714,20 @@ XkbGetKeyBehaviors(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetVirtualMods(Display *dpy,unsigned which,XkbDescPtr xkb)
+XkbGetVirtualMods(Display *dpy, unsigned which, XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->virtualMods = which;
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
UnlockDisplay(dpy);
SyncHandle();
@@ -715,32 +735,34 @@ XkbGetVirtualMods(Display *dpy,unsigned which,XkbDescPtr xkb)
}
Status
-XkbGetKeyExplicitComponents( Display * dpy,
- unsigned first,
- unsigned num,
- XkbDescPtr xkb)
+XkbGetKeyExplicitComponents(Display *dpy,
+ unsigned first,
+ unsigned num,
+ XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstKeyExplicit = first;
req->nKeyExplicit = num;
- if ((xkb!=NULL) && (xkb->server!=NULL) && (xkb->server->explicit!=NULL)) {
- if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
- bzero(&xkb->server->explicit[first],num);
+ if ((xkb != NULL) && (xkb->server != NULL) &&
+ (xkb->server->explicit != NULL)) {
+ if ((num > 0) && (first >= xkb->min_key_code) &&
+ (first + num <= xkb->max_key_code))
+ bzero(&xkb->server->explicit[first], num);
}
if (xkb)
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
else
status = BadMatch;
@@ -750,29 +772,33 @@ XkbGetKeyExplicitComponents( Display * dpy,
}
Status
-XkbGetKeyModifierMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeyModifierMap(Display *dpy,
+ unsigned first,
+ unsigned num,
+ XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstModMapKey = first;
req->nModMapKeys = num;
- if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
- if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
- bzero(&xkb->map->modmap[first],num);
+ if ((xkb != NULL) && (xkb->map != NULL) && (xkb->map->modmap != NULL)) {
+ if ((num > 0) && (first >= xkb->min_key_code) &&
+ (first + num <= xkb->max_key_code))
+ bzero(&xkb->map->modmap[first], num);
}
if (xkb)
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
else
status = BadMatch;
@@ -782,30 +808,32 @@ XkbGetKeyModifierMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetKeyVirtualModMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+XkbGetKeyVirtualModMap(Display *dpy, unsigned first, unsigned num,
+ XkbDescPtr xkb)
{
register xkbGetMapReq *req;
Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
- if ((num<1)||(num>XkbMaxKeyCount))
- return BadValue;
+ if ((num < 1) || (num > XkbMaxKeyCount))
+ return BadValue;
LockDisplay(dpy);
req = _XkbGetGetMapReq(dpy, xkb);
req->firstVModMapKey = first;
req->nVModMapKeys = num;
- if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
- if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
- bzero(&xkb->server->vmodmap[first],num*sizeof(unsigned short));
+ if ((xkb != NULL) && (xkb->map != NULL) && (xkb->map->modmap != NULL)) {
+ if ((num > 0) && (first >= xkb->min_key_code) &&
+ (first + num <= xkb->max_key_code))
+ bzero(&xkb->server->vmodmap[first], num * sizeof(unsigned short));
}
if (xkb)
- status= _XkbHandleGetMapReply(dpy, xkb);
+ status = _XkbHandleGetMapReply(dpy, xkb);
else
status = BadMatch;
@@ -815,40 +843,40 @@ XkbGetKeyVirtualModMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
}
Status
-XkbGetMapChanges(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+XkbGetMapChanges(Display *dpy, XkbDescPtr xkb, XkbMapChangesPtr changes)
{
xkbGetMapReq *req;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
if (changes->changed) {
- Status status= Success;
- req = _XkbGetGetMapReq(dpy, xkb);
- req->full = 0;
- req->partial = changes->changed;
- req->firstType = changes->first_type;
- req->nTypes = changes->num_types;
- req->firstKeySym = changes->first_key_sym;
- req->nKeySyms = changes->num_key_syms;
- req->firstKeyAct = changes->first_key_act;
- req->nKeyActs = changes->num_key_acts;
- req->firstKeyBehavior = changes->first_key_behavior;
- req->nKeyBehaviors = changes->num_key_behaviors;
- req->virtualMods = changes->vmods;
- req->firstKeyExplicit = changes->first_key_explicit;
- req->nKeyExplicit = changes->num_key_explicit;
- req->firstModMapKey = changes->first_modmap_key;
- req->nModMapKeys = changes->num_modmap_keys;
- req->firstVModMapKey = changes->first_vmodmap_key;
- req->nVModMapKeys = changes->num_vmodmap_keys;
- status= _XkbHandleGetMapReply(dpy, xkb);
- UnlockDisplay(dpy);
- SyncHandle();
- return status;
+ Status status = Success;
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = 0;
+ req->partial = changes->changed;
+ req->firstType = changes->first_type;
+ req->nTypes = changes->num_types;
+ req->firstKeySym = changes->first_key_sym;
+ req->nKeySyms = changes->num_key_syms;
+ req->firstKeyAct = changes->first_key_act;
+ req->nKeyActs = changes->num_key_acts;
+ req->firstKeyBehavior = changes->first_key_behavior;
+ req->nKeyBehaviors = changes->num_key_behaviors;
+ req->virtualMods = changes->vmods;
+ req->firstKeyExplicit = changes->first_key_explicit;
+ req->nKeyExplicit = changes->num_key_explicit;
+ req->firstModMapKey = changes->first_modmap_key;
+ req->nModMapKeys = changes->num_modmap_keys;
+ req->firstVModMapKey = changes->first_vmodmap_key;
+ req->nVModMapKeys = changes->num_vmodmap_keys;
+ status = _XkbHandleGetMapReply(dpy, xkb);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
}
UnlockDisplay(dpy);
return Success;
}
-
diff --git a/nx-X11/lib/X11/XKBList.c b/nx-X11/lib/X11/XKBList.c
index 569e732b4..d3d29e2a6 100644
--- a/nx-X11/lib/X11/XKBList.c
+++ b/nx-X11/lib/X11/XKBList.c
@@ -35,18 +35,18 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
static void
-_FreeComponentNames(int num,XkbComponentNamePtr names)
+_FreeComponentNames(int num, XkbComponentNamePtr names)
{
-int i;
-XkbComponentNamePtr tmp;
-
- if ((num<1)||(names==NULL))
- return;
- for (i=0,tmp=names;i<num;i++,tmp++) {
- if (tmp->name) {
- _XkbFree(tmp->name);
- tmp->name= NULL;
- }
+ int i;
+ XkbComponentNamePtr tmp;
+
+ if ((num < 1) || (names == NULL))
+ return;
+ for (i = 0, tmp = names; i < num; i++, tmp++) {
+ if (tmp->name) {
+ _XkbFree(tmp->name);
+ tmp->name = NULL;
+ }
}
_XkbFree(names);
return;
@@ -55,170 +55,179 @@ XkbComponentNamePtr tmp;
/***====================================================================***/
static XkbComponentNamePtr
-_ReadListing(XkbReadBufferPtr buf,int count,Status *status_rtrn)
+_ReadListing(XkbReadBufferPtr buf, int count, Status * status_rtrn)
{
-XkbComponentNamePtr first,this;
-register int i;
-CARD16 * flags;
-int slen,wlen;
-char * str;
-
- if (count<1)
- return NULL;
- first= _XkbTypedCalloc(count,XkbComponentNameRec);
+ XkbComponentNamePtr first, this;
+ register int i;
+ CARD16 *flags;
+ int slen, wlen;
+ char *str;
+
+ if (count < 1)
+ return NULL;
+ first = _XkbTypedCalloc(count, XkbComponentNameRec);
if (!first)
- return NULL;
- for (this=first,i=0;i<count;i++,this++) {
- flags= (CARD16 *)_XkbGetReadBufferPtr(buf,2*sizeof(CARD16));
- if (!flags)
- goto BAILOUT;
- this->flags= flags[0];
- slen= flags[1];
- wlen= ((slen+1)/2)*2; /* pad to 2 byte boundary */
- this->name= _XkbTypedCalloc(slen+1,char);
- if (!this->name)
- goto BAILOUT;
- str= (char *)_XkbGetReadBufferPtr(buf,wlen);
- memcpy(this->name,str,slen);
+ return NULL;
+ for (this = first, i = 0; i < count; i++, this++) {
+ flags = (CARD16 *) _XkbGetReadBufferPtr(buf, 2 * sizeof(CARD16));
+ if (!flags)
+ goto BAILOUT;
+ this->flags = flags[0];
+ slen = flags[1];
+ wlen = ((slen + 1) / 2) * 2; /* pad to 2 byte boundary */
+ this->name = _XkbTypedCalloc(slen + 1, char);
+
+ if (!this->name)
+ goto BAILOUT;
+ str = (char *) _XkbGetReadBufferPtr(buf, wlen);
+ if (!str)
+ goto BAILOUT;
+ memcpy(this->name, str, slen);
}
return first;
-BAILOUT:
- *status_rtrn= BadAlloc;
- _FreeComponentNames(i,first);
+ BAILOUT:
+ *status_rtrn = BadAlloc;
+ _FreeComponentNames(i, first);
return NULL;
}
/***====================================================================***/
XkbComponentListPtr
-XkbListComponents( Display * dpy,
- unsigned deviceSpec,
- XkbComponentNamesPtr ptrns,
- int * max_inout)
+XkbListComponents(Display *dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr ptrns,
+ int *max_inout)
{
-register xkbListComponentsReq* req;
-xkbListComponentsReply rep;
-XkbInfoPtr xkbi;
-XkbComponentListPtr list;
-XkbReadBufferRec buf;
-int left;
-char * str;
-int extraLen,len,mapLen,codesLen,typesLen,compatLen,symsLen,geomLen;
-
- if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
- (ptrns==NULL) || (max_inout==NULL))
- return NULL;
-
- xkbi= dpy->xkb_info;
+ register xkbListComponentsReq *req;
+ xkbListComponentsReply rep;
+ XkbInfoPtr xkbi;
+ XkbComponentListPtr list;
+ XkbReadBufferRec buf;
+ int left;
+ char *str;
+ int extraLen, len, mapLen, codesLen, typesLen, compatLen, symsLen, geomLen;
+
+ if ((dpy == NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) ||
+ (ptrns == NULL) || (max_inout == NULL))
+ return NULL;
+
+ xkbi = dpy->xkb_info;
LockDisplay(dpy);
GetReq(kbListComponents, req);
- req->reqType = xkbi->codes->major_opcode;
- req->xkbReqType = X_kbListComponents;
- req->deviceSpec = deviceSpec;
- req->maxNames = *max_inout;
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbListComponents;
+ req->deviceSpec = deviceSpec;
+ req->maxNames = *max_inout;
- mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ mapLen = codesLen = typesLen = compatLen = symsLen = geomLen = 0;
if (ptrns->keymap)
- mapLen= (int)strlen(ptrns->keymap);
+ mapLen = (int) strlen(ptrns->keymap);
if (ptrns->keycodes)
- codesLen= (int)strlen(ptrns->keycodes);
+ codesLen = (int) strlen(ptrns->keycodes);
if (ptrns->types)
- typesLen= (int)strlen(ptrns->types);
+ typesLen = (int) strlen(ptrns->types);
if (ptrns->compat)
- compatLen= (int)strlen(ptrns->compat);
+ compatLen = (int) strlen(ptrns->compat);
if (ptrns->symbols)
- symsLen= (int)strlen(ptrns->symbols);
+ symsLen = (int) strlen(ptrns->symbols);
if (ptrns->geometry)
- geomLen= (int)strlen(ptrns->geometry);
- if (mapLen>255) mapLen= 255;
- if (codesLen>255) codesLen= 255;
- if (typesLen>255) typesLen= 255;
- if (compatLen>255) compatLen= 255;
- if (symsLen>255) symsLen= 255;
- if (geomLen>255) geomLen= 255;
-
- len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
- len= XkbPaddedSize(len);
- req->length+= len/4;
- BufAlloc(char *,str,len);
- *str++= mapLen;
- if (mapLen>0) {
- memcpy(str,ptrns->keymap,mapLen);
- str+= mapLen;
+ geomLen = (int) strlen(ptrns->geometry);
+ if (mapLen > 255)
+ mapLen = 255;
+ if (codesLen > 255)
+ codesLen = 255;
+ if (typesLen > 255)
+ typesLen = 255;
+ if (compatLen > 255)
+ compatLen = 255;
+ if (symsLen > 255)
+ symsLen = 255;
+ if (geomLen > 255)
+ geomLen = 255;
+
+ len = mapLen + codesLen + typesLen + compatLen + symsLen + geomLen + 6;
+ len = XkbPaddedSize(len);
+ req->length += len / 4;
+ BufAlloc(char *, str, len);
+
+ *str++ = mapLen;
+ if (mapLen > 0) {
+ memcpy(str, ptrns->keymap, mapLen);
+ str += mapLen;
}
- *str++= codesLen;
- if (codesLen>0) {
- memcpy(str,ptrns->keycodes,codesLen);
- str+= codesLen;
+ *str++ = codesLen;
+ if (codesLen > 0) {
+ memcpy(str, ptrns->keycodes, codesLen);
+ str += codesLen;
}
- *str++= typesLen;
- if (typesLen>0) {
- memcpy(str,ptrns->types,typesLen);
- str+= typesLen;
+ *str++ = typesLen;
+ if (typesLen > 0) {
+ memcpy(str, ptrns->types, typesLen);
+ str += typesLen;
}
- *str++= compatLen;
- if (compatLen>0) {
- memcpy(str,ptrns->compat,compatLen);
- str+= compatLen;
+ *str++ = compatLen;
+ if (compatLen > 0) {
+ memcpy(str, ptrns->compat, compatLen);
+ str += compatLen;
}
- *str++= symsLen;
- if (symsLen>0) {
- memcpy(str,ptrns->symbols,symsLen);
- str+= symsLen;
+ *str++ = symsLen;
+ if (symsLen > 0) {
+ memcpy(str, ptrns->symbols, symsLen);
+ str += symsLen;
}
- *str++= geomLen;
- if (geomLen>0) {
- memcpy(str,ptrns->geometry,geomLen);
- str+= geomLen;
+ *str++ = geomLen;
+ if (geomLen > 0) {
+ memcpy(str, ptrns->geometry, geomLen);
+ str += geomLen;
}
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
- goto BAILOUT;
- extraLen= (int)rep.length*4;
- *max_inout= rep.extra;
- if (extraLen==0) { /* no matches, but we don't want to report a failure */
- list= _XkbTypedCalloc(1,XkbComponentListRec);
- UnlockDisplay(dpy);
- SyncHandle();
- return list;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse))
+ goto BAILOUT;
+ extraLen = (int) rep.length * 4;
+ *max_inout = rep.extra;
+ if (extraLen == 0) { /* no matches, but we don't want to report a failure */
+ list = _XkbTypedCalloc(1, XkbComponentListRec);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
}
- if (_XkbInitReadBuffer(dpy,&buf,extraLen)) {
- Status status;
-
- status= Success;
- list= _XkbTypedCalloc(1,XkbComponentListRec);
- if (!list) {
- _XkbFreeReadBuffer(&buf);
- goto BAILOUT;
- }
- list->num_keymaps= rep.nKeymaps;
- list->num_keycodes= rep.nKeycodes;
- list->num_types= rep.nTypes;
- list->num_compat= rep.nCompatMaps;
- list->num_symbols= rep.nSymbols;
- list->num_geometry= rep.nGeometries;
- if ((status==Success)&&(list->num_keymaps>0))
- list->keymaps= _ReadListing(&buf,list->num_keymaps,&status);
- if ((status==Success)&&(list->num_keycodes>0))
- list->keycodes= _ReadListing(&buf,list->num_keycodes,&status);
- if ((status==Success)&&(list->num_types>0))
- list->types= _ReadListing(&buf,list->num_types,&status);
- if ((status==Success)&&(list->num_compat>0))
- list->compat= _ReadListing(&buf,list->num_compat,&status);
- if ((status==Success)&&(list->num_symbols>0))
- list->symbols= _ReadListing(&buf,list->num_symbols,&status);
- if ((status==Success)&&(list->num_geometry>0))
- list->geometry= _ReadListing(&buf,list->num_geometry,&status);
- left= _XkbFreeReadBuffer(&buf);
- if ((status!=Success)||(buf.error)||(left>2)) {
- XkbFreeComponentList(list);
- goto BAILOUT;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return list;
+ if (_XkbInitReadBuffer(dpy, &buf, extraLen)) {
+ Status status = Success;
+
+ list = _XkbTypedCalloc(1, XkbComponentListRec);
+ if (!list) {
+ _XkbFreeReadBuffer(&buf);
+ goto BAILOUT;
+ }
+ list->num_keymaps = rep.nKeymaps;
+ list->num_keycodes = rep.nKeycodes;
+ list->num_types = rep.nTypes;
+ list->num_compat = rep.nCompatMaps;
+ list->num_symbols = rep.nSymbols;
+ list->num_geometry = rep.nGeometries;
+ if ((status == Success) && (list->num_keymaps > 0))
+ list->keymaps = _ReadListing(&buf, list->num_keymaps, &status);
+ if ((status == Success) && (list->num_keycodes > 0))
+ list->keycodes = _ReadListing(&buf, list->num_keycodes, &status);
+ if ((status == Success) && (list->num_types > 0))
+ list->types = _ReadListing(&buf, list->num_types, &status);
+ if ((status == Success) && (list->num_compat > 0))
+ list->compat = _ReadListing(&buf, list->num_compat, &status);
+ if ((status == Success) && (list->num_symbols > 0))
+ list->symbols = _ReadListing(&buf, list->num_symbols, &status);
+ if ((status == Success) && (list->num_geometry > 0))
+ list->geometry = _ReadListing(&buf, list->num_geometry, &status);
+ left = _XkbFreeReadBuffer(&buf);
+ if ((status != Success) || (buf.error) || (left > 2)) {
+ XkbFreeComponentList(list);
+ goto BAILOUT;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
}
-BAILOUT:
+ BAILOUT:
UnlockDisplay(dpy);
SyncHandle();
return NULL;
@@ -228,20 +237,20 @@ void
XkbFreeComponentList(XkbComponentListPtr list)
{
if (list) {
- if (list->keymaps)
- _FreeComponentNames(list->num_keymaps,list->keymaps);
- if (list->keycodes)
- _FreeComponentNames(list->num_keycodes,list->keycodes);
- if (list->types)
- _FreeComponentNames(list->num_types,list->types);
- if (list->compat)
- _FreeComponentNames(list->num_compat,list->compat);
- if (list->symbols)
- _FreeComponentNames(list->num_symbols,list->symbols);
- if (list->geometry)
- _FreeComponentNames(list->num_geometry,list->geometry);
- bzero((char *)list,sizeof(XkbComponentListRec));
- _XkbFree(list);
+ if (list->keymaps)
+ _FreeComponentNames(list->num_keymaps, list->keymaps);
+ if (list->keycodes)
+ _FreeComponentNames(list->num_keycodes, list->keycodes);
+ if (list->types)
+ _FreeComponentNames(list->num_types, list->types);
+ if (list->compat)
+ _FreeComponentNames(list->num_compat, list->compat);
+ if (list->symbols)
+ _FreeComponentNames(list->num_symbols, list->symbols);
+ if (list->geometry)
+ _FreeComponentNames(list->num_geometry, list->geometry);
+ bzero((char *) list, sizeof(XkbComponentListRec));
+ _XkbFree(list);
}
return;
}
diff --git a/nx-X11/lib/X11/XKBMAlloc.c b/nx-X11/lib/X11/XKBMAlloc.c
index 594ef7f71..2467a2024 100644
--- a/nx-X11/lib/X11/XKBMAlloc.c
+++ b/nx-X11/lib/X11/XKBMAlloc.c
@@ -24,13 +24,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#elif defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifndef XKB_IN_SERVER
#include <stdio.h>
#include "Xlibint.h"
@@ -38,192 +35,186 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/keysym.h>
#include "XKBlibint.h"
-#else
-
-#include <stdio.h>
-#include <nx-X11/X.h>
-#include <nx-X11/Xproto.h>
-#include "misc.h"
-#include "inputstr.h"
-#include <nx-X11/keysym.h>
-#define XKBSRV_NEED_FILE_FUNCS
-#include <nx-X11/extensions/XKBsrv.h>
-
-#endif /* XKB_IN_SERVER */
/***====================================================================***/
Status
-XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
+XkbAllocClientMap(XkbDescPtr xkb, unsigned which, unsigned nTotalTypes)
{
-register int i;
-XkbClientMapPtr map;
-
- if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
- return BadValue;
- if ((which&XkbKeySymsMask)&&
- ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))) {
+ register int i;
+ XkbClientMapPtr map;
+
+ if ((xkb == NULL) ||
+ ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes)))
+ return BadValue;
+ if ((which & XkbKeySymsMask) &&
+ ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))) {
#ifdef DEBUG
-fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n",
- xkb->min_key_code,xkb->max_key_code);
+ fprintf(stderr, "bad keycode (%d,%d) in XkbAllocClientMap\n",
+ xkb->min_key_code, xkb->max_key_code);
#endif
- return BadValue;
- }
-
- if (xkb->map==NULL) {
- map= _XkbTypedCalloc(1,XkbClientMapRec);
- if (map==NULL)
- return BadAlloc;
- xkb->map= map;
- }
- else map= xkb->map;
-
- if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
- if (map->types==NULL) {
- map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
- if (map->types==NULL)
- return BadAlloc;
- map->num_types= 0;
- map->size_types= nTotalTypes;
- }
- else if (map->size_types<nTotalTypes) {
- XkbKeyTypeRec *prev_types = map->types;
-
- map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
- if (map->types==NULL) {
- _XkbFree(prev_types);
- map->num_types= map->size_types= 0;
- return BadAlloc;
- }
- map->size_types= nTotalTypes;
- bzero(&map->types[map->num_types],
- ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
- }
- }
- if (which&XkbKeySymsMask) {
- int nKeys= XkbNumKeys(xkb);
- if (map->syms==NULL) {
- map->size_syms= (nKeys*15)/10;
- map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
- if (!map->syms) {
- map->size_syms= 0;
- return BadAlloc;
- }
- map->num_syms= 1;
- map->syms[0]= NoSymbol;
- }
- if (map->key_sym_map==NULL) {
- i= xkb->max_key_code+1;
- map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
- if (map->key_sym_map==NULL)
- return BadAlloc;
- }
- }
- if (which&XkbModifierMapMask) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadMatch;
- if (map->modmap==NULL) {
- i= xkb->max_key_code+1;
- map->modmap= _XkbTypedCalloc(i,unsigned char);
- if (map->modmap==NULL)
- return BadAlloc;
- }
+ return BadValue;
+ }
+
+ if (xkb->map == NULL) {
+ map = _XkbTypedCalloc(1, XkbClientMapRec);
+ if (map == NULL)
+ return BadAlloc;
+ xkb->map = map;
+ }
+ else
+ map = xkb->map;
+
+ if ((which & XkbKeyTypesMask) && (nTotalTypes > 0)) {
+ if (map->types == NULL) {
+ map->types = _XkbTypedCalloc(nTotalTypes, XkbKeyTypeRec);
+ if (map->types == NULL)
+ return BadAlloc;
+ map->num_types = 0;
+ map->size_types = nTotalTypes;
+ }
+ else if (map->size_types < nTotalTypes) {
+ XkbKeyTypeRec *prev_types = map->types;
+
+ map->types =
+ _XkbTypedRealloc(map->types, nTotalTypes, XkbKeyTypeRec);
+ if (map->types == NULL) {
+ _XkbFree(prev_types);
+ map->num_types = map->size_types = 0;
+ return BadAlloc;
+ }
+ map->size_types = nTotalTypes;
+ bzero(&map->types[map->num_types],
+ ((map->size_types - map->num_types) * sizeof(XkbKeyTypeRec)));
+ }
+ }
+ if (which & XkbKeySymsMask) {
+ int nKeys = XkbNumKeys(xkb);
+
+ if (map->syms == NULL) {
+ map->size_syms = (nKeys * 15) / 10;
+ map->syms = _XkbTypedCalloc(map->size_syms, KeySym);
+ if (!map->syms) {
+ map->size_syms = 0;
+ return BadAlloc;
+ }
+ map->num_syms = 1;
+ map->syms[0] = NoSymbol;
+ }
+ if (map->key_sym_map == NULL) {
+ i = xkb->max_key_code + 1;
+ map->key_sym_map = _XkbTypedCalloc(i, XkbSymMapRec);
+ if (map->key_sym_map == NULL)
+ return BadAlloc;
+ }
+ }
+ if (which & XkbModifierMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadMatch;
+ if (map->modmap == NULL) {
+ i = xkb->max_key_code + 1;
+ map->modmap = _XkbTypedCalloc(i, unsigned char);
+ if (map->modmap == NULL)
+ return BadAlloc;
+ }
}
return Success;
}
Status
-XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
+XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions)
{
-register int i;
-XkbServerMapPtr map;
-
- if (xkb==NULL)
- return BadMatch;
- if (xkb->server==NULL) {
- map= _XkbTypedCalloc(1,XkbServerMapRec);
- if (map==NULL)
- return BadAlloc;
- for (i=0;i<XkbNumVirtualMods;i++) {
- map->vmods[i]= XkbNoModifierMask;
- }
- xkb->server= map;
- }
- else map= xkb->server;
- if (which&XkbExplicitComponentsMask) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadMatch;
- if (map->explicit==NULL) {
- i= xkb->max_key_code+1;
- map->explicit= _XkbTypedCalloc(i,unsigned char);
- if (map->explicit==NULL)
- return BadAlloc;
- }
- }
- if (which&XkbKeyActionsMask) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadMatch;
- if (nNewActions<1)
- nNewActions= 1;
- if (map->acts==NULL) {
- map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
- if (map->acts==NULL)
- return BadAlloc;
- map->num_acts= 1;
- map->size_acts= nNewActions+1;
- }
- else if ((map->size_acts-map->num_acts)<nNewActions) {
- unsigned need;
- XkbAction *prev_acts = map->acts;
- need= map->num_acts+nNewActions;
- map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
- if (map->acts==NULL) {
- _XkbFree(prev_acts);
- map->num_acts= map->size_acts= 0;
- return BadAlloc;
- }
- map->size_acts= need;
- bzero(&map->acts[map->num_acts],
- ((map->size_acts-map->num_acts)*sizeof(XkbAction)));
- }
- if (map->key_acts==NULL) {
- i= xkb->max_key_code+1;
- map->key_acts= _XkbTypedCalloc(i,unsigned short);
- if (map->key_acts==NULL)
- return BadAlloc;
- }
- }
- if (which&XkbKeyBehaviorsMask) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadMatch;
- if (map->behaviors==NULL) {
- i= xkb->max_key_code+1;
- map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
- if (map->behaviors==NULL)
- return BadAlloc;
- }
- }
- if (which&XkbVirtualModMapMask) {
- if ((!XkbIsLegalKeycode(xkb->min_key_code))||
- (!XkbIsLegalKeycode(xkb->max_key_code))||
- (xkb->max_key_code<xkb->min_key_code))
- return BadMatch;
- if (map->vmodmap==NULL) {
- i= xkb->max_key_code+1;
- map->vmodmap= _XkbTypedCalloc(i,unsigned short);
- if (map->vmodmap==NULL)
- return BadAlloc;
- }
+ register int i;
+ XkbServerMapPtr map;
+
+ if (xkb == NULL)
+ return BadMatch;
+ if (xkb->server == NULL) {
+ map = _XkbTypedCalloc(1, XkbServerMapRec);
+ if (map == NULL)
+ return BadAlloc;
+ for (i = 0; i < XkbNumVirtualMods; i++) {
+ map->vmods[i] = XkbNoModifierMask;
+ }
+ xkb->server = map;
+ }
+ else
+ map = xkb->server;
+ if (which & XkbExplicitComponentsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadMatch;
+ if (map->explicit == NULL) {
+ i = xkb->max_key_code + 1;
+ map->explicit = _XkbTypedCalloc(i, unsigned char);
+ if (map->explicit == NULL)
+ return BadAlloc;
+ }
+ }
+ if (which & XkbKeyActionsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadMatch;
+ if (nNewActions < 1)
+ nNewActions = 1;
+ if (map->acts == NULL) {
+ map->acts = _XkbTypedCalloc((nNewActions + 1), XkbAction);
+ if (map->acts == NULL)
+ return BadAlloc;
+ map->num_acts = 1;
+ map->size_acts = nNewActions + 1;
+ }
+ else if ((map->size_acts - map->num_acts) < nNewActions) {
+ unsigned need;
+ XkbAction *prev_acts = map->acts;
+
+ need = map->num_acts + nNewActions;
+ map->acts = _XkbTypedRealloc(map->acts, need, XkbAction);
+ if (map->acts == NULL) {
+ _XkbFree(prev_acts);
+ map->num_acts = map->size_acts = 0;
+ return BadAlloc;
+ }
+ map->size_acts = need;
+ bzero(&map->acts[map->num_acts],
+ ((map->size_acts - map->num_acts) * sizeof(XkbAction)));
+ }
+ if (map->key_acts == NULL) {
+ i = xkb->max_key_code + 1;
+ map->key_acts = _XkbTypedCalloc(i, unsigned short);
+ if (map->key_acts == NULL)
+ return BadAlloc;
+ }
+ }
+ if (which & XkbKeyBehaviorsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadMatch;
+ if (map->behaviors == NULL) {
+ i = xkb->max_key_code + 1;
+ map->behaviors = _XkbTypedCalloc(i, XkbBehavior);
+ if (map->behaviors == NULL)
+ return BadAlloc;
+ }
+ }
+ if (which & XkbVirtualModMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code)) ||
+ (!XkbIsLegalKeycode(xkb->max_key_code)) ||
+ (xkb->max_key_code < xkb->min_key_code))
+ return BadMatch;
+ if (map->vmodmap == NULL) {
+ i = xkb->max_key_code + 1;
+ map->vmodmap = _XkbTypedCalloc(i, unsigned short);
+ if (map->vmodmap == NULL)
+ return BadAlloc;
+ }
}
return Success;
}
@@ -231,211 +222,211 @@ XkbServerMapPtr map;
/***====================================================================***/
Status
-XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
+XkbCopyKeyType(XkbKeyTypePtr from, XkbKeyTypePtr into)
{
- if ((!from)||(!into))
- return BadMatch;
- if (into->map) {
- _XkbFree(into->map);
- into->map= NULL;
- }
- if (into->preserve) {
- _XkbFree(into->preserve);
- into->preserve= NULL;
- }
- if (into->level_names) {
- _XkbFree(into->level_names);
- into->level_names= NULL;
- }
- *into= *from;
- if ((from->map)&&(into->map_count>0)) {
- into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
- if (!into->map)
- return BadAlloc;
- memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
- }
- if ((from->preserve)&&(into->map_count>0)) {
- into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
- if (!into->preserve)
- return BadAlloc;
- memcpy(into->preserve,from->preserve,
- into->map_count*sizeof(XkbModsRec));
- }
- if ((from->level_names)&&(into->num_levels>0)) {
- into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
- if (!into->level_names)
- return BadAlloc;
- memcpy(into->level_names,from->level_names,
- into->num_levels*sizeof(Atom));
+ if ((!from) || (!into))
+ return BadMatch;
+
+ _XkbFree(into->map);
+ into->map = NULL;
+
+ _XkbFree(into->preserve);
+ into->preserve = NULL;
+
+ _XkbFree(into->level_names);
+ into->level_names = NULL;
+
+ *into = *from;
+ if ((from->map) && (into->map_count > 0)) {
+ into->map = _XkbTypedCalloc(into->map_count, XkbKTMapEntryRec);
+ if (!into->map)
+ return BadAlloc;
+ memcpy(into->map, from->map,
+ into->map_count * sizeof(XkbKTMapEntryRec));
+ }
+ if ((from->preserve) && (into->map_count > 0)) {
+ into->preserve = _XkbTypedCalloc(into->map_count, XkbModsRec);
+ if (!into->preserve)
+ return BadAlloc;
+ memcpy(into->preserve, from->preserve,
+ into->map_count * sizeof(XkbModsRec));
+ }
+ if ((from->level_names) && (into->num_levels > 0)) {
+ into->level_names = _XkbTypedCalloc(into->num_levels, Atom);
+ if (!into->level_names)
+ return BadAlloc;
+ memcpy(into->level_names, from->level_names,
+ into->num_levels * sizeof(Atom));
}
return Success;
}
Status
-XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
+XkbCopyKeyTypes(XkbKeyTypePtr from, XkbKeyTypePtr into, int num_types)
{
-register int i,rtrn;
+ register int i, rtrn;
- if ((!from)||(!into)||(num_types<0))
- return BadMatch;
- for (i=0;i<num_types;i++) {
- if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
- return rtrn;
+ if ((!from) || (!into) || (num_types < 0))
+ return BadMatch;
+ for (i = 0; i < num_types; i++) {
+ if ((rtrn = XkbCopyKeyType(from++, into++)) != Success)
+ return rtrn;
}
return Success;
}
XkbKeyTypePtr
-XkbAddKeyType( XkbDescPtr xkb,
- Atom name,
- int map_count,
- Bool want_preserve,
- int num_lvls)
+XkbAddKeyType(XkbDescPtr xkb,
+ Atom name,
+ int map_count,
+ Bool want_preserve,
+ int num_lvls)
{
-register int i;
-unsigned tmp;
-XkbKeyTypePtr type;
-XkbClientMapPtr map;
-
- if ((!xkb)||(num_lvls<1))
- return NULL;
- map= xkb->map;
- if ((map)&&(map->types)) {
- for (i=0;i<map->num_types;i++) {
- if (map->types[i].name==name) {
- Status status;
- status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
- return (status==Success?&map->types[i]:NULL);
- }
- }
- }
- if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
- tmp= XkbNumRequiredTypes+1;
- if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
- return NULL;
+ register int i;
+ unsigned tmp;
+ XkbKeyTypePtr type;
+ XkbClientMapPtr map;
+
+ if ((!xkb) || (num_lvls < 1))
+ return NULL;
+ map = xkb->map;
+ if ((map) && (map->types)) {
+ for (i = 0; i < map->num_types; i++) {
+ if (map->types[i].name == name) {
+ Status status =
+ XkbResizeKeyType(xkb, i, map_count, want_preserve,
+ num_lvls);
+ return (status == Success ? &map->types[i] : NULL);
+ }
+ }
+ }
+ if ((!map) || (!map->types) || (map->num_types < XkbNumRequiredTypes)) {
+ tmp = XkbNumRequiredTypes + 1;
+ if (XkbAllocClientMap(xkb, XkbKeyTypesMask, tmp) != Success)
+ return NULL;
if (!map)
map = xkb->map;
- tmp= 0;
- if (map->num_types<=XkbKeypadIndex)
- tmp|= XkbKeypadMask;
- if (map->num_types<=XkbAlphabeticIndex)
- tmp|= XkbAlphabeticMask;
- if (map->num_types<=XkbTwoLevelIndex)
- tmp|= XkbTwoLevelMask;
- if (map->num_types<=XkbOneLevelIndex)
- tmp|= XkbOneLevelMask;
- if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
- for (i=0;i<map->num_types;i++) {
- Status status;
- if (map->types[i].name!=name)
- continue;
- status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
- return (status==Success?&map->types[i]:NULL);
- }
- }
- }
- if ((map->num_types<=map->size_types)&&
- (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
- return NULL;
- }
- type= &map->types[map->num_types];
+ tmp = 0;
+ if (map->num_types <= XkbKeypadIndex)
+ tmp |= XkbKeypadMask;
+ if (map->num_types <= XkbAlphabeticIndex)
+ tmp |= XkbAlphabeticMask;
+ if (map->num_types <= XkbTwoLevelIndex)
+ tmp |= XkbTwoLevelMask;
+ if (map->num_types <= XkbOneLevelIndex)
+ tmp |= XkbOneLevelMask;
+ if (XkbInitCanonicalKeyTypes(xkb, tmp, XkbNoModifier) == Success) {
+ for (i = 0; i < map->num_types; i++) {
+ Status status;
+
+ if (map->types[i].name != name)
+ continue;
+ status = XkbResizeKeyType(xkb, i, map_count, want_preserve,
+ num_lvls);
+ return (status == Success ? &map->types[i] : NULL);
+ }
+ }
+ }
+ if ((map->num_types <= map->size_types) &&
+ (XkbAllocClientMap(xkb, XkbKeyTypesMask, map->num_types + 1) !=
+ Success)) {
+ return NULL;
+ }
+ type = &map->types[map->num_types];
map->num_types++;
- bzero((char *)type,sizeof(XkbKeyTypeRec));
- type->num_levels= num_lvls;
- type->map_count= map_count;
- type->name= name;
- if (map_count>0) {
- type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec);
- if (!type->map) {
- map->num_types--;
- return NULL;
- }
- if (want_preserve) {
- type->preserve= _XkbTypedCalloc(map_count,XkbModsRec);
- if (!type->preserve) {
- _XkbFree(type->map);
- map->num_types--;
- return NULL;
- }
- }
+ bzero((char *) type, sizeof(XkbKeyTypeRec));
+ type->num_levels = num_lvls;
+ type->map_count = map_count;
+ type->name = name;
+ if (map_count > 0) {
+ type->map = _XkbTypedCalloc(map_count, XkbKTMapEntryRec);
+ if (!type->map) {
+ map->num_types--;
+ return NULL;
+ }
+ if (want_preserve) {
+ type->preserve = _XkbTypedCalloc(map_count, XkbModsRec);
+ if (!type->preserve) {
+ _XkbFree(type->map);
+ map->num_types--;
+ return NULL;
+ }
+ }
}
return type;
}
Status
-XkbResizeKeyType( XkbDescPtr xkb,
- int type_ndx,
- int map_count,
- Bool want_preserve,
- int new_num_lvls)
+XkbResizeKeyType(XkbDescPtr xkb,
+ int type_ndx,
+ int map_count,
+ Bool want_preserve,
+ int new_num_lvls)
{
-XkbKeyTypePtr type;
-KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
+ XkbKeyTypePtr type;
+ KeyCode matchingKeys[XkbMaxKeyCount], nMatchingKeys;
- if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
- (new_num_lvls<1))
- return BadValue;
+ if ((type_ndx < 0) || (type_ndx >= xkb->map->num_types) || (map_count < 0)
+ || (new_num_lvls < 1))
+ return BadValue;
switch (type_ndx) {
- case XkbOneLevelIndex:
- if (new_num_lvls!=1)
- return BadMatch;
- break;
- case XkbTwoLevelIndex:
- case XkbAlphabeticIndex:
- case XkbKeypadIndex:
- if (new_num_lvls!=2)
- return BadMatch;
- break;
- }
- type= &xkb->map->types[type_ndx];
- if (map_count==0) {
- if (type->map!=NULL)
- _XkbFree(type->map);
- type->map= NULL;
- if (type->preserve!=NULL)
- _XkbFree(type->preserve);
- type->preserve= NULL;
- type->map_count= 0;
+ case XkbOneLevelIndex:
+ if (new_num_lvls != 1)
+ return BadMatch;
+ break;
+ case XkbTwoLevelIndex:
+ case XkbAlphabeticIndex:
+ case XkbKeypadIndex:
+ if (new_num_lvls != 2)
+ return BadMatch;
+ break;
+ }
+ type = &xkb->map->types[type_ndx];
+ if (map_count == 0) {
+ _XkbFree(type->map);
+ type->map = NULL;
+ _XkbFree(type->preserve);
+ type->preserve = NULL;
+ type->map_count = 0;
}
else {
- XkbKTMapEntryRec *prev_map = type->map;
-
- if ((map_count>type->map_count)||(type->map==NULL))
- type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
- if (!type->map) {
- if (prev_map)
- _XkbFree(prev_map);
- return BadAlloc;
- }
- if (want_preserve) {
- XkbModsRec *prev_preserve = type->preserve;
-
- if ((map_count>type->map_count)||(type->preserve==NULL)) {
- type->preserve= _XkbTypedRealloc(type->preserve,map_count,
- XkbModsRec);
- }
- if (!type->preserve) {
- if (prev_preserve)
- _XkbFree(prev_preserve);
- return BadAlloc;
- }
- }
- else if (type->preserve!=NULL) {
- _XkbFree(type->preserve);
- type->preserve= NULL;
- }
- type->map_count= map_count;
- }
-
- if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
- Atom * prev_level_names = type->level_names;
-
- type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
- if (!type->level_names) {
- if (prev_level_names)
- _XkbFree(prev_level_names);
- return BadAlloc;
- }
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ if ((map_count > type->map_count) || (type->map == NULL))
+ type->map =
+ _XkbTypedRealloc(type->map, map_count, XkbKTMapEntryRec);
+ if (!type->map) {
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ if (want_preserve) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ if ((map_count > type->map_count) || (type->preserve == NULL)) {
+ type->preserve = _XkbTypedRealloc(type->preserve, map_count,
+ XkbModsRec);
+ }
+ if (!type->preserve) {
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ else {
+ _XkbFree(type->preserve);
+ type->preserve = NULL;
+ }
+ type->map_count = map_count;
+ }
+
+ if ((new_num_lvls > type->num_levels) || (type->level_names == NULL)) {
+ Atom *prev_level_names = type->level_names;
+
+ type->level_names =
+ _XkbTypedRealloc(type->level_names, new_num_lvls, Atom);
+ if (!type->level_names) {
+ _XkbFree(prev_level_names);
+ return BadAlloc;
+ }
}
/*
* Here's the theory:
@@ -458,156 +449,165 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
* The possibilities marked with '+' require us to examine the key types
* associated with each group for the key.
*/
- bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
- nMatchingKeys= 0;
- if (new_num_lvls>type->num_levels) {
- int nTotal;
- KeySym * newSyms;
- int width,match,nResize;
- register int i,g,nSyms;
-
- nResize= 0;
- for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
- width= XkbKeyGroupsWidth(xkb,i);
- if (width<type->num_levels)
- continue;
- for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
- if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
- matchingKeys[nMatchingKeys++]= i;
- match= 1;
- }
- }
- if ((!match)||(width>=new_num_lvls))
- nTotal+= XkbKeyNumSyms(xkb,i);
- else {
- nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
- nResize++;
- }
- }
- if (nResize>0) {
- int nextMatch;
- xkb->map->size_syms= (nTotal*12)/10;
- newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
- if (newSyms==NULL)
- return BadAlloc;
- nextMatch= 0;
- nSyms= 1;
- for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
- if (matchingKeys[nextMatch]==i) {
- KeySym *pOld;
- nextMatch++;
- width= XkbKeyGroupsWidth(xkb,i);
- pOld= XkbKeySymsPtr(xkb,i);
- for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
- memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
- width*sizeof(KeySym));
- }
- xkb->map->key_sym_map[i].offset= nSyms;
- nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
- }
- else {
- memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
- XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
- xkb->map->key_sym_map[i].offset= nSyms;
- nSyms+= XkbKeyNumSyms(xkb,i);
- }
- }
- type->num_levels= new_num_lvls;
- _XkbFree(xkb->map->syms);
- xkb->map->syms= newSyms;
- xkb->map->num_syms= nSyms;
- return Success;
- }
- }
- else if (new_num_lvls<type->num_levels) {
- int width,match;
- register int g,i;
- for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
- width= XkbKeyGroupsWidth(xkb,i);
- if (width<type->num_levels)
- continue;
- for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
- if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
- matchingKeys[nMatchingKeys++]= i;
- match= 1;
- }
- }
- }
- }
- if (nMatchingKeys>0) {
- int key,firstClear;
- register int i,g;
- if (new_num_lvls>type->num_levels)
- firstClear= type->num_levels;
- else firstClear= new_num_lvls;
- for (i=0;i<nMatchingKeys;i++) {
- KeySym * pSyms;
- int width,nClear;
-
- key= matchingKeys[i];
- width= XkbKeyGroupsWidth(xkb,key);
- nClear= width-firstClear;
- pSyms= XkbKeySymsPtr(xkb,key);
- for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
- if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
- if (nClear>0)
- bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
- }
- }
- }
- }
- type->num_levels= new_num_lvls;
+ bzero(matchingKeys, XkbMaxKeyCount * sizeof(KeyCode));
+ nMatchingKeys = 0;
+ if (new_num_lvls > type->num_levels) {
+ int nTotal;
+ KeySym *newSyms;
+ int width, match, nResize;
+ register int i, g, nSyms;
+
+ nResize = 0;
+ for (nTotal = 1, i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
+ width = XkbKeyGroupsWidth(xkb, i);
+ if (width < type->num_levels)
+ continue;
+ for (match = 0, g = XkbKeyNumGroups(xkb, i) - 1;
+ (g >= 0) && (!match); g--) {
+ if (XkbKeyKeyTypeIndex(xkb, i, g) == type_ndx) {
+ matchingKeys[nMatchingKeys++] = i;
+ match = 1;
+ }
+ }
+ if ((!match) || (width >= new_num_lvls))
+ nTotal += XkbKeyNumSyms(xkb, i);
+ else {
+ nTotal += XkbKeyNumGroups(xkb, i) * new_num_lvls;
+ nResize++;
+ }
+ }
+ if (nResize > 0) {
+ int nextMatch;
+
+ xkb->map->size_syms = (nTotal * 12) / 10;
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms, KeySym);
+ if (newSyms == NULL)
+ return BadAlloc;
+ nextMatch = 0;
+ nSyms = 1;
+ for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
+ if (matchingKeys[nextMatch] == i) {
+ KeySym *pOld;
+
+ nextMatch++;
+ width = XkbKeyGroupsWidth(xkb, i);
+ pOld = XkbKeySymsPtr(xkb, i);
+ for (g = XkbKeyNumGroups(xkb, i) - 1; g >= 0; g--) {
+ memcpy(&newSyms[nSyms + (new_num_lvls * g)],
+ &pOld[width * g], width * sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms += XkbKeyNumGroups(xkb, i) * new_num_lvls;
+ }
+ else {
+ memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
+ XkbKeyNumSyms(xkb, i) * sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms += XkbKeyNumSyms(xkb, i);
+ }
+ }
+ type->num_levels = new_num_lvls;
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms = newSyms;
+ xkb->map->num_syms = nSyms;
+ return Success;
+ }
+ }
+ else if (new_num_lvls < type->num_levels) {
+ int width, match;
+ register int g, i;
+
+ for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
+ width = XkbKeyGroupsWidth(xkb, i);
+ if (width < type->num_levels)
+ continue;
+ for (match = 0, g = XkbKeyNumGroups(xkb, i) - 1;
+ (g >= 0) && (!match); g--) {
+ if (XkbKeyKeyTypeIndex(xkb, i, g) == type_ndx) {
+ matchingKeys[nMatchingKeys++] = i;
+ match = 1;
+ }
+ }
+ }
+ }
+ if (nMatchingKeys > 0) {
+ int key, firstClear;
+ register int i, g;
+
+ if (new_num_lvls > type->num_levels)
+ firstClear = type->num_levels;
+ else
+ firstClear = new_num_lvls;
+ for (i = 0; i < nMatchingKeys; i++) {
+ KeySym *pSyms;
+ int width, nClear;
+
+ key = matchingKeys[i];
+ width = XkbKeyGroupsWidth(xkb, key);
+ nClear = width - firstClear;
+ pSyms = XkbKeySymsPtr(xkb, key);
+ for (g = XkbKeyNumGroups(xkb, key) - 1; g >= 0; g--) {
+ if (XkbKeyKeyTypeIndex(xkb, key, g) == type_ndx) {
+ if (nClear > 0)
+ bzero(&pSyms[g * width + firstClear],
+ nClear * sizeof(KeySym));
+ }
+ }
+ }
+ }
+ type->num_levels = new_num_lvls;
return Success;
}
KeySym *
-XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
+XkbResizeKeySyms(XkbDescPtr xkb, int key, int needed)
{
-register int i,nSyms,nKeySyms;
-unsigned nOldSyms;
-KeySym *newSyms;
-
- if (needed==0) {
- xkb->map->key_sym_map[key].offset= 0;
- return xkb->map->syms;
- }
- nOldSyms= XkbKeyNumSyms(xkb,key);
- if (nOldSyms>=(unsigned)needed) {
- return XkbKeySymsPtr(xkb,key);
- }
- if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
- if (nOldSyms>0) {
- memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
- nOldSyms*sizeof(KeySym));
- }
- if ((needed-nOldSyms)>0) {
- bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
- (needed-nOldSyms)*sizeof(KeySym));
- }
- xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
- xkb->map->num_syms+= needed;
- return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
- }
- xkb->map->size_syms+= (needed>32?needed:32);
- newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
- if (newSyms==NULL)
- return NULL;
- newSyms[0]= NoSymbol;
+ register int i, nSyms, nKeySyms;
+ unsigned nOldSyms;
+ KeySym *newSyms;
+
+ if (needed == 0) {
+ xkb->map->key_sym_map[key].offset = 0;
+ return xkb->map->syms;
+ }
+ nOldSyms = XkbKeyNumSyms(xkb, key);
+ if (nOldSyms >= (unsigned) needed) {
+ return XkbKeySymsPtr(xkb, key);
+ }
+ if (xkb->map->size_syms - xkb->map->num_syms >= (unsigned) needed) {
+ if (nOldSyms > 0) {
+ memcpy(&xkb->map->syms[xkb->map->num_syms], XkbKeySymsPtr(xkb, key),
+ nOldSyms * sizeof(KeySym));
+ }
+ if ((needed - nOldSyms) > 0) {
+ bzero(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
+ (needed - nOldSyms) * sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
+ xkb->map->num_syms += needed;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+ }
+ xkb->map->size_syms += (needed > 32 ? needed : 32);
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms, KeySym);
+ if (newSyms == NULL)
+ return NULL;
+ newSyms[0] = NoSymbol;
nSyms = 1;
- for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
- int nCopy;
-
- nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
- if ((nKeySyms==0)&&(i!=key))
- continue;
- if (i==key)
- nKeySyms= needed;
- if (nCopy!=0)
- memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
- if (nKeySyms>nCopy)
- bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
- xkb->map->key_sym_map[i].offset = nSyms;
- nSyms+= nKeySyms;
+ for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++) {
+ int nCopy;
+
+ nCopy = nKeySyms = XkbKeyNumSyms(xkb, i);
+ if ((nKeySyms == 0) && (i != key))
+ continue;
+ if (i == key)
+ nKeySyms = needed;
+ if (nCopy != 0)
+ memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
+ nCopy * sizeof(KeySym));
+ if (nKeySyms > nCopy)
+ bzero(&newSyms[nSyms + nCopy], (nKeySyms - nCopy) * sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms += nKeySyms;
}
_XkbFree(xkb->map->syms);
xkb->map->syms = newSyms;
@@ -616,404 +616,401 @@ KeySym *newSyms;
}
static unsigned
-_ExtendRange( unsigned int old_flags,
- unsigned int flag,
- KeyCode newKC,
- KeyCode * old_min,
- unsigned char * old_num)
+_ExtendRange(unsigned int old_flags,
+ unsigned int flag,
+ KeyCode newKC,
+ KeyCode *old_min,
+ unsigned char *old_num)
{
- if ((old_flags&flag)==0) {
- old_flags|= flag;
- *old_min= newKC;
- *old_num= 1;
+ if ((old_flags & flag) == 0) {
+ old_flags |= flag;
+ *old_min = newKC;
+ *old_num = 1;
}
else {
- int last= (*old_min)+(*old_num)-1;
- if (newKC<*old_min) {
- *old_min= newKC;
- *old_num= (last-newKC)+1;
- }
- else if (newKC>last) {
- *old_num= (newKC-(*old_min))+1;
- }
+ int last = (*old_min) + (*old_num) - 1;
+
+ if (newKC < *old_min) {
+ *old_min = newKC;
+ *old_num = (last - newKC) + 1;
+ }
+ else if (newKC > last) {
+ *old_num = (newKC - (*old_min)) + 1;
+ }
}
return old_flags;
}
Status
-XkbChangeKeycodeRange( XkbDescPtr xkb,
- int minKC,
- int maxKC,
- XkbChangesPtr changes)
+XkbChangeKeycodeRange(XkbDescPtr xkb,
+ int minKC,
+ int maxKC,
+ XkbChangesPtr changes)
{
-int tmp;
-
- if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
- return BadValue;
- if (minKC>maxKC)
- return BadMatch;
- if (minKC<xkb->min_key_code) {
- if (changes)
- changes->map.min_key_code= minKC;
- tmp= xkb->min_key_code-minKC;
- if (xkb->map) {
- if (xkb->map->key_sym_map) {
- bzero((char *)&xkb->map->key_sym_map[minKC],
- tmp*sizeof(XkbSymMapRec));
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeySymsMask,minKC,
- &changes->map.first_key_sym,
- &changes->map.num_key_syms);
- }
- }
- if (xkb->map->modmap) {
- bzero((char *)&xkb->map->modmap[minKC],tmp);
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbModifierMapMask,minKC,
- &changes->map.first_modmap_key,
- &changes->map.num_modmap_keys);
- }
- }
- }
- if (xkb->server) {
- if (xkb->server->behaviors) {
- bzero((char *)&xkb->server->behaviors[minKC],
- tmp*sizeof(XkbBehavior));
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeyBehaviorsMask,minKC,
- &changes->map.first_key_behavior,
- &changes->map.num_key_behaviors);
- }
- }
- if (xkb->server->key_acts) {
- bzero((char *)&xkb->server->key_acts[minKC],
- tmp*sizeof(unsigned short));
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeyActionsMask,minKC,
- &changes->map.first_key_act,
- &changes->map.num_key_acts);
- }
- }
- if (xkb->server->vmodmap) {
- bzero((char *)&xkb->server->vmodmap[minKC],
- tmp*sizeof(unsigned short));
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbVirtualModMapMask,minKC,
- &changes->map.first_modmap_key,
- &changes->map.num_vmodmap_keys);
- }
- }
- }
- if ((xkb->names)&&(xkb->names->keys)) {
- bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
- if (changes) {
- changes->names.changed= _ExtendRange(changes->names.changed,
- XkbKeyNamesMask,minKC,
- &changes->names.first_key,
- &changes->names.num_keys);
- }
- }
- xkb->min_key_code= minKC;
- }
- if (maxKC>xkb->max_key_code) {
- if (changes)
- changes->map.max_key_code= maxKC;
- tmp= maxKC-xkb->max_key_code;
- if (xkb->map) {
- if (xkb->map->key_sym_map) {
- XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
-
- xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
- (maxKC+1),XkbSymMapRec);
- if (!xkb->map->key_sym_map) {
- _XkbFree(prev_key_sym_map);
- return BadAlloc;
- }
+ int tmp;
+
+ if ((!xkb) || (minKC < XkbMinLegalKeyCode) || (maxKC > XkbMaxLegalKeyCode))
+ return BadValue;
+ if (minKC > maxKC)
+ return BadMatch;
+ if (minKC < xkb->min_key_code) {
+ if (changes)
+ changes->map.min_key_code = minKC;
+ tmp = xkb->min_key_code - minKC;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ bzero((char *) &xkb->map->key_sym_map[minKC],
+ tmp * sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeySymsMask, minKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ bzero((char *) &xkb->map->modmap[minKC], tmp);
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbModifierMapMask, minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ bzero((char *) &xkb->server->behaviors[minKC],
+ tmp * sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask, minKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ bzero((char *) &xkb->server->key_acts[minKC],
+ tmp * sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask, minKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ bzero((char *) &xkb->server->vmodmap[minKC],
+ tmp * sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask, minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names) && (xkb->names->keys)) {
+ bzero((char *) &xkb->names->keys[minKC],
+ tmp * sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed = _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask, minKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->min_key_code = minKC;
+ }
+ if (maxKC > xkb->max_key_code) {
+ if (changes)
+ changes->map.max_key_code = maxKC;
+ tmp = maxKC - xkb->max_key_code;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
+
+ xkb->map->key_sym_map = _XkbTypedRealloc(xkb->map->key_sym_map,
+ (maxKC + 1), XkbSymMapRec);
+ if (!xkb->map->key_sym_map) {
+ _XkbFree(prev_key_sym_map);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1],
- tmp*sizeof(XkbSymMapRec));
+ bzero((char *) &xkb->map->key_sym_map[xkb->max_key_code + 1],
+ tmp * sizeof(XkbSymMapRec));
#else
- bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
- tmp*sizeof(XkbSymMapRec));
+ bzero((char *) &xkb->map->key_sym_map[xkb->max_key_code],
+ tmp * sizeof(XkbSymMapRec));
#endif
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeySymsMask,maxKC,
- &changes->map.first_key_sym,
- &changes->map.num_key_syms);
- }
- }
- if (xkb->map->modmap) {
- unsigned char *prev_modmap = xkb->map->modmap;
-
- xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
- (maxKC+1),unsigned char);
- if (!xkb->map->modmap) {
- _XkbFree(prev_modmap);
- return BadAlloc;
- }
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeySymsMask, maxKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ unsigned char *prev_modmap = xkb->map->modmap;
+
+ xkb->map->modmap = _XkbTypedRealloc(xkb->map->modmap,
+ (maxKC + 1), unsigned char);
+ if (!xkb->map->modmap) {
+ _XkbFree(prev_modmap);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp);
+ bzero((char *) &xkb->map->modmap[xkb->max_key_code + 1], tmp);
#else
- bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+ bzero((char *) &xkb->map->modmap[xkb->max_key_code], tmp);
#endif
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbModifierMapMask,maxKC,
- &changes->map.first_modmap_key,
- &changes->map.num_modmap_keys);
- }
- }
- }
- if (xkb->server) {
- if (xkb->server->behaviors) {
- XkbBehavior *prev_behaviors = xkb->server->behaviors;
-
- xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
- (maxKC+1),XkbBehavior);
- if (!xkb->server->behaviors) {
- _XkbFree(prev_behaviors);
- return BadAlloc;
- }
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbModifierMapMask, maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ XkbBehavior *prev_behaviors = xkb->server->behaviors;
+
+ xkb->server->behaviors =
+ _XkbTypedRealloc(xkb->server->behaviors, (maxKC + 1),
+ XkbBehavior);
+ if (!xkb->server->behaviors) {
+ _XkbFree(prev_behaviors);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1],
- tmp*sizeof(XkbBehavior));
+ bzero((char *) &xkb->server->behaviors[xkb->max_key_code + 1],
+ tmp * sizeof(XkbBehavior));
#else
- bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
- tmp*sizeof(XkbBehavior));
+ bzero((char *) &xkb->server->behaviors[xkb->max_key_code],
+ tmp * sizeof(XkbBehavior));
#endif
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeyBehaviorsMask,maxKC,
- &changes->map.first_key_behavior,
- &changes->map.num_key_behaviors);
- }
- }
- if (xkb->server->key_acts) {
- unsigned short *prev_key_acts = xkb->server->key_acts;
-
- xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
- (maxKC+1),unsigned short);
- if (!xkb->server->key_acts) {
- _XkbFree(prev_key_acts);
- return BadAlloc;
- }
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask, maxKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ unsigned short *prev_key_acts = xkb->server->key_acts;
+
+ xkb->server->key_acts = _XkbTypedRealloc(xkb->server->key_acts,
+ (maxKC + 1), unsigned short);
+ if (!xkb->server->key_acts) {
+ _XkbFree(prev_key_acts);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1],
- tmp*sizeof(unsigned short));
+ bzero((char *) &xkb->server->key_acts[xkb->max_key_code + 1],
+ tmp * sizeof(unsigned short));
#else
- bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
- tmp*sizeof(unsigned short));
+ bzero((char *) &xkb->server->key_acts[xkb->max_key_code],
+ tmp * sizeof(unsigned short));
#endif
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbKeyActionsMask,maxKC,
- &changes->map.first_key_act,
- &changes->map.num_key_acts);
- }
- }
- if (xkb->server->vmodmap) {
- unsigned short *prev_vmodmap = xkb->server->vmodmap;
-
- xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
- (maxKC+1),unsigned short);
- if (!xkb->server->vmodmap) {
- _XkbFree(prev_vmodmap);
- return BadAlloc;
- }
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask, maxKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ unsigned short *prev_vmodmap = xkb->server->vmodmap;
+
+ xkb->server->vmodmap = _XkbTypedRealloc(xkb->server->vmodmap,
+ (maxKC + 1), unsigned short);
+ if (!xkb->server->vmodmap) {
+ _XkbFree(prev_vmodmap);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1],
- tmp*sizeof(unsigned short));
+ bzero((char *) &xkb->server->vmodmap[xkb->max_key_code + 1],
+ tmp * sizeof(unsigned short));
#else
- bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
- tmp*sizeof(unsigned short));
+ bzero((char *) &xkb->server->vmodmap[xkb->max_key_code],
+ tmp * sizeof(unsigned short));
#endif
- if (changes) {
- changes->map.changed= _ExtendRange(changes->map.changed,
- XkbVirtualModMapMask,maxKC,
- &changes->map.first_modmap_key,
- &changes->map.num_vmodmap_keys);
- }
- }
- }
- if ((xkb->names)&&(xkb->names->keys)) {
- XkbKeyNameRec *prev_keys = xkb->names->keys;
-
- xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
- (maxKC+1),XkbKeyNameRec);
- if (!xkb->names->keys) {
- _XkbFree(prev_keys);
- return BadAlloc;
- }
+ if (changes) {
+ changes->map.changed = _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask, maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names) && (xkb->names->keys)) {
+ XkbKeyNameRec *prev_keys = xkb->names->keys;
+
+ xkb->names->keys = _XkbTypedRealloc(xkb->names->keys,
+ (maxKC + 1), XkbKeyNameRec);
+ if (!xkb->names->keys) {
+ _XkbFree(prev_keys);
+ return BadAlloc;
+ }
#ifdef NXAGENT_SERVER
- bzero((char *)&xkb->names->keys[xkb->max_key_code+1],
- tmp*sizeof(XkbKeyNameRec));
+ bzero((char *) &xkb->names->keys[xkb->max_key_code + 1],
+ tmp * sizeof(XkbKeyNameRec));
#else
- bzero((char *)&xkb->names->keys[xkb->max_key_code],
- tmp*sizeof(XkbKeyNameRec));
+ bzero((char *) &xkb->names->keys[xkb->max_key_code],
+ tmp * sizeof(XkbKeyNameRec));
#endif
- if (changes) {
- changes->names.changed= _ExtendRange(changes->names.changed,
- XkbKeyNamesMask,maxKC,
- &changes->names.first_key,
- &changes->names.num_keys);
- }
- }
- xkb->max_key_code= maxKC;
+ if (changes) {
+ changes->names.changed = _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask, maxKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->max_key_code = maxKC;
}
return Success;
}
XkbAction *
-XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
+XkbResizeKeyActions(XkbDescPtr xkb, int key, int needed)
{
-register int i,nActs;
-XkbAction *newActs;
-
- if (needed==0) {
- xkb->server->key_acts[key]= 0;
- return NULL;
- }
- if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
- return XkbKeyActionsPtr(xkb,key);
- if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
- xkb->server->key_acts[key]= xkb->server->num_acts;
- xkb->server->num_acts+= needed;
- return &xkb->server->acts[xkb->server->key_acts[key]];
- }
- xkb->server->size_acts= xkb->server->num_acts+needed+8;
- newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
- if (newActs==NULL)
- return NULL;
+ register int i, nActs;
+ XkbAction *newActs;
+
+ if (needed == 0) {
+ xkb->server->key_acts[key] = 0;
+ return NULL;
+ }
+ if (XkbKeyHasActions(xkb, key) &&
+ (XkbKeyNumSyms(xkb, key) >= (unsigned) needed))
+ return XkbKeyActionsPtr(xkb, key);
+ if (xkb->server->size_acts - xkb->server->num_acts >= (unsigned) needed) {
+ xkb->server->key_acts[key] = xkb->server->num_acts;
+ xkb->server->num_acts += needed;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+ }
+ xkb->server->size_acts = xkb->server->num_acts + needed + 8;
+ newActs = _XkbTypedCalloc(xkb->server->size_acts, XkbAction);
+ if (newActs == NULL)
+ return NULL;
newActs[0].type = XkbSA_NoAction;
nActs = 1;
- for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
- int nKeyActs,nCopy;
-
- if ((xkb->server->key_acts[i]==0)&&(i!=key))
- continue;
-
- nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
- if (i==key) {
- nKeyActs= needed;
- if (needed<nCopy)
- nCopy= needed;
- }
-
- if (nCopy>0)
- memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
- nCopy*sizeof(XkbAction));
- if (nCopy<nKeyActs)
- bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
- xkb->server->key_acts[i]= nActs;
- nActs+= nKeyActs;
+ for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++) {
+ int nKeyActs, nCopy;
+
+ if ((xkb->server->key_acts[i] == 0) && (i != key))
+ continue;
+
+ nCopy = nKeyActs = XkbKeyNumActions(xkb, i);
+ if (i == key) {
+ nKeyActs = needed;
+ if (needed < nCopy)
+ nCopy = needed;
+ }
+
+ if (nCopy > 0)
+ memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
+ nCopy * sizeof(XkbAction));
+ if (nCopy < nKeyActs)
+ bzero(&newActs[nActs + nCopy],
+ (nKeyActs - nCopy) * sizeof(XkbAction));
+ xkb->server->key_acts[i] = nActs;
+ nActs += nKeyActs;
}
_XkbFree(xkb->server->acts);
xkb->server->acts = newActs;
- xkb->server->num_acts= nActs;
+ xkb->server->num_acts = nActs;
return &xkb->server->acts[xkb->server->key_acts[key]];
}
void
-XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+XkbFreeClientMap(XkbDescPtr xkb, unsigned what, Bool freeMap)
{
-XkbClientMapPtr map;
+ XkbClientMapPtr map;
- if ((xkb==NULL)||(xkb->map==NULL))
- return;
+ if ((xkb == NULL) || (xkb->map == NULL))
+ return;
if (freeMap)
- what= XkbAllClientInfoMask;
- map= xkb->map;
- if (what&XkbKeyTypesMask) {
- if (map->types!=NULL) {
- if (map->num_types>0) {
- register int i;
- XkbKeyTypePtr type;
- for (i=0,type=map->types;i<map->num_types;i++,type++) {
- if (type->map!=NULL) {
- _XkbFree(type->map);
- type->map= NULL;
- }
- if (type->preserve!=NULL) {
- _XkbFree(type->preserve);
- type->preserve= NULL;
- }
- type->map_count= 0;
- if (type->level_names!=NULL) {
- _XkbFree(type->level_names);
- type->level_names= NULL;
- }
- }
- }
- _XkbFree(map->types);
- map->num_types= map->size_types= 0;
- map->types= NULL;
- }
- }
- if (what&XkbKeySymsMask) {
- if (map->key_sym_map!=NULL) {
- _XkbFree(map->key_sym_map);
- map->key_sym_map= NULL;
- }
- if (map->syms!=NULL) {
- _XkbFree(map->syms);
- map->size_syms= map->num_syms= 0;
- map->syms= NULL;
- }
- }
- if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
- _XkbFree(map->modmap);
- map->modmap= NULL;
+ what = XkbAllClientInfoMask;
+ map = xkb->map;
+ if (what & XkbKeyTypesMask) {
+ if (map->types != NULL) {
+ if (map->num_types > 0) {
+ register int i;
+ XkbKeyTypePtr type;
+
+ for (i = 0, type = map->types; i < map->num_types; i++, type++) {
+ _XkbFree(type->map);
+ type->map = NULL;
+
+ _XkbFree(type->preserve);
+ type->preserve = NULL;
+
+ type->map_count = 0;
+
+ _XkbFree(type->level_names);
+ type->level_names = NULL;
+ }
+ }
+ _XkbFree(map->types);
+ map->num_types = map->size_types = 0;
+ map->types = NULL;
+ }
+ }
+ if (what & XkbKeySymsMask) {
+ _XkbFree(map->key_sym_map);
+ map->key_sym_map = NULL;
+
+ _XkbFree(map->syms);
+ map->size_syms = map->num_syms = 0;
+ map->syms = NULL;
+ }
+ if (what & XkbModifierMapMask) {
+ _XkbFree(map->modmap);
+ map->modmap = NULL;
}
if (freeMap) {
- _XkbFree(xkb->map);
- xkb->map= NULL;
+ _XkbFree(xkb->map);
+ xkb->map = NULL;
}
return;
}
void
-XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+XkbFreeServerMap(XkbDescPtr xkb, unsigned what, Bool freeMap)
{
-XkbServerMapPtr map;
+ XkbServerMapPtr map;
- if ((xkb==NULL)||(xkb->server==NULL))
- return;
+ if ((xkb == NULL) || (xkb->server == NULL))
+ return;
if (freeMap)
- what= XkbAllServerInfoMask;
- map= xkb->server;
- if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
- _XkbFree(map->explicit);
- map->explicit= NULL;
- }
- if (what&XkbKeyActionsMask) {
- if (map->key_acts!=NULL) {
- _XkbFree(map->key_acts);
- map->key_acts= NULL;
- }
- if (map->acts!=NULL) {
- _XkbFree(map->acts);
- map->num_acts= map->size_acts= 0;
- map->acts= NULL;
- }
- }
- if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
- _XkbFree(map->behaviors);
- map->behaviors= NULL;
- }
- if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
- _XkbFree(map->vmodmap);
- map->vmodmap= NULL;
+ what = XkbAllServerInfoMask;
+ map = xkb->server;
+ if (what & XkbExplicitComponentsMask) {
+ _XkbFree(map->explicit);
+ map->explicit = NULL;
+ }
+ if (what & XkbKeyActionsMask) {
+ _XkbFree(map->key_acts);
+ map->key_acts = NULL;
+
+ _XkbFree(map->acts);
+ map->num_acts = map->size_acts = 0;
+ map->acts = NULL;
+ }
+ if (what & XkbKeyBehaviorsMask) {
+ _XkbFree(map->behaviors);
+ map->behaviors = NULL;
+ }
+ if (what & XkbVirtualModMapMask) {
+ _XkbFree(map->vmodmap);
+ map->vmodmap = NULL;
}
if (freeMap) {
- _XkbFree(xkb->server);
- xkb->server= NULL;
+ _XkbFree(xkb->server);
+ xkb->server = NULL;
}
return;
}
diff --git a/nx-X11/lib/X11/XKBMisc.c b/nx-X11/lib/X11/XKBMisc.c
index fbd7e6852..ab48b6124 100644
--- a/nx-X11/lib/X11/XKBMisc.c
+++ b/nx-X11/lib/X11/XKBMisc.c
@@ -24,13 +24,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#elif defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#ifndef XKB_IN_SERVER
#include <stdio.h>
#include "Xlibint.h"
@@ -38,110 +35,101 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/keysym.h>
#include "XKBlibint.h"
-#else
-
-#include <stdio.h>
-#include <nx-X11/X.h>
-#include <nx-X11/Xproto.h>
-#include "misc.h"
-#include "inputstr.h"
-#include <nx-X11/keysym.h>
-#define XKBSRV_NEED_FILE_FUNCS
-#include <nx-X11/extensions/XKBsrv.h>
-
-#endif /* XKB_IN_SERVER */
/***====================================================================***/
#define mapSize(m) (sizeof(m)/sizeof(XkbKTMapEntryRec))
-static XkbKTMapEntryRec map2Level[]= {
- { True, ShiftMask, {1, ShiftMask, 0} }
+static XkbKTMapEntryRec map2Level[] = {
+ { True, ShiftMask, {1, ShiftMask, 0} }
};
-static XkbKTMapEntryRec mapAlpha[]= {
- { True, ShiftMask, { 1, ShiftMask, 0 } },
- { True, LockMask, { 0, LockMask, 0 } }
+static XkbKTMapEntryRec mapAlpha[] = {
+ { True, ShiftMask, {1, ShiftMask, 0} },
+ { True, LockMask, {0, LockMask, 0} }
};
-static XkbModsRec preAlpha[]= {
- { 0, 0, 0 },
- { LockMask, LockMask, 0 }
+static XkbModsRec preAlpha[] = {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
};
#define NL_VMOD_MASK 0
-static XkbKTMapEntryRec mapKeypad[]= {
- { True, ShiftMask, { 1, ShiftMask, 0 } },
- { False, 0, { 1, 0, NL_VMOD_MASK } }
+static XkbKTMapEntryRec mapKeypad[] = {
+ { True, ShiftMask, { 1, ShiftMask, 0 } },
+ { False, 0, { 1, 0, NL_VMOD_MASK } }
};
-static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = {
- { { 0, 0, 0 },
- 1, /* num_levels */
- 0, /* map_count */
- NULL, NULL,
- None, NULL
- },
- { { ShiftMask, ShiftMask, 0 },
- 2, /* num_levels */
- mapSize(map2Level), /* map_count */
- map2Level, NULL,
- None, NULL
- },
- { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
- 2, /* num_levels */
- mapSize(mapAlpha), /* map_count */
- mapAlpha, preAlpha,
- None, NULL
- },
- { { ShiftMask, ShiftMask, NL_VMOD_MASK },
- 2, /* num_levels */
- mapSize(mapKeypad), /* map_count */
- mapKeypad, NULL,
- None, NULL
- }
+static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = {
+ { { 0, 0, 0 },
+ 1, /* num_levels */
+ 0, /* map_count */
+ NULL, NULL,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, 0 },
+ 2, /* num_levels */
+ mapSize(map2Level), /* map_count */
+ map2Level, NULL,
+ None, NULL
+ },
+ { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2, /* num_levels */
+ mapSize(mapAlpha), /* map_count */
+ mapAlpha, preAlpha,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, NL_VMOD_MASK },
+ 2, /* num_levels */
+ mapSize(mapKeypad), /* map_count */
+ mapKeypad, NULL,
+ None, NULL
+ }
};
Status
-XkbInitCanonicalKeyTypes(XkbDescPtr xkb,unsigned which,int keypadVMod)
+XkbInitCanonicalKeyTypes(XkbDescPtr xkb, unsigned which, int keypadVMod)
{
-XkbClientMapPtr map;
-XkbKeyTypePtr from,to;
-Status rtrn;
+ XkbClientMapPtr map;
+ XkbKeyTypePtr from, to;
+ Status rtrn;
if (!xkb)
- return BadMatch;
- rtrn= XkbAllocClientMap(xkb,XkbKeyTypesMask,XkbNumRequiredTypes);
- if (rtrn!=Success)
- return rtrn;
- map= xkb->map;
- if ((which&XkbAllRequiredTypes)==0)
- return Success;
- rtrn= Success;
- from= canonicalTypes;
- to= map->types;
- if (which&XkbOneLevelMask)
- rtrn= XkbCopyKeyType(&from[XkbOneLevelIndex],&to[XkbOneLevelIndex]);
- if ((which&XkbTwoLevelMask)&&(rtrn==Success))
- rtrn= XkbCopyKeyType(&from[XkbTwoLevelIndex],&to[XkbTwoLevelIndex]);
- if ((which&XkbAlphabeticMask)&&(rtrn==Success))
- rtrn= XkbCopyKeyType(&from[XkbAlphabeticIndex],&to[XkbAlphabeticIndex]);
- if ((which&XkbKeypadMask)&&(rtrn==Success)) {
- XkbKeyTypePtr type;
- rtrn= XkbCopyKeyType(&from[XkbKeypadIndex],&to[XkbKeypadIndex]);
- type= &to[XkbKeypadIndex];
- if ((keypadVMod>=0)&&(keypadVMod<XkbNumVirtualMods)&&(rtrn==Success)) {
- type->mods.vmods= (1<<keypadVMod);
- type->map[0].active= True;
- type->map[0].mods.mask= ShiftMask;
- type->map[0].mods.real_mods= ShiftMask;
- type->map[0].mods.vmods= 0;
- type->map[0].level= 1;
- type->map[1].active= False;
- type->map[1].mods.mask= 0;
- type->map[1].mods.real_mods= 0;
- type->map[1].mods.vmods= (1<<keypadVMod);
- type->map[1].level= 1;
- }
+ return BadMatch;
+ rtrn = XkbAllocClientMap(xkb, XkbKeyTypesMask, XkbNumRequiredTypes);
+ if (rtrn != Success)
+ return rtrn;
+ map = xkb->map;
+ if ((which & XkbAllRequiredTypes) == 0)
+ return Success;
+ rtrn = Success;
+ from = canonicalTypes;
+ to = map->types;
+ if (which & XkbOneLevelMask)
+ rtrn = XkbCopyKeyType(&from[XkbOneLevelIndex], &to[XkbOneLevelIndex]);
+ if ((which & XkbTwoLevelMask) && (rtrn == Success))
+ rtrn = XkbCopyKeyType(&from[XkbTwoLevelIndex], &to[XkbTwoLevelIndex]);
+ if ((which & XkbAlphabeticMask) && (rtrn == Success))
+ rtrn =
+ XkbCopyKeyType(&from[XkbAlphabeticIndex], &to[XkbAlphabeticIndex]);
+ if ((which & XkbKeypadMask) && (rtrn == Success)) {
+ XkbKeyTypePtr type;
+
+ rtrn = XkbCopyKeyType(&from[XkbKeypadIndex], &to[XkbKeypadIndex]);
+ type = &to[XkbKeypadIndex];
+ if ((keypadVMod >= 0) && (keypadVMod < XkbNumVirtualMods) &&
+ (rtrn == Success)) {
+ type->mods.vmods = (1 << keypadVMod);
+ type->map[0].active = True;
+ type->map[0].mods.mask = ShiftMask;
+ type->map[0].mods.real_mods = ShiftMask;
+ type->map[0].mods.vmods = 0;
+ type->map[0].level = 1;
+ type->map[1].active = False;
+ type->map[1].mods.mask = 0;
+ type->map[1].mods.real_mods = 0;
+ type->map[1].mods.vmods = (1 << keypadVMod);
+ type->map[1].level = 1;
+ }
}
return Success;
}
@@ -152,264 +140,283 @@ Status rtrn;
#define XKB_OFFSET(g,l) (((g)*groupsWidth)+(l))
int
-XkbKeyTypesForCoreSymbols( XkbDescPtr xkb,
- int map_width,
- KeySym * core_syms,
- unsigned int protected,
- int * types_inout,
- KeySym * xkb_syms_rtrn)
+XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
+ int map_width,
+ KeySym *core_syms,
+ unsigned int protected,
+ int *types_inout,
+ KeySym *xkb_syms_rtrn)
{
-register int i;
-unsigned int empty;
-int nSyms[XkbNumKbdGroups];
-int nGroups,tmp,groupsWidth;
+ register int i;
+ unsigned int empty;
+ int nSyms[XkbNumKbdGroups];
+ int nGroups, tmp, groupsWidth;
/* Section 12.2 of the protocol describes this process in more detail */
/* Step 1: find the # of symbols in the core mapping per group */
- groupsWidth= 2;
- for (i=0;i<XkbNumKbdGroups;i++) {
- if ((protected&(1<<i))&&(types_inout[i]<xkb->map->num_types)) {
- nSyms[i]= xkb->map->types[types_inout[i]].num_levels;
- if (nSyms[i]>groupsWidth)
- groupsWidth= nSyms[i];
- }
- else {
- types_inout[i]= XkbTwoLevelIndex; /* don't really know, yet */
- nSyms[i]= 2;
- }
- }
- if (nSyms[XkbGroup1Index]<2)
- nSyms[XkbGroup1Index]= 2;
- if (nSyms[XkbGroup2Index]<2)
- nSyms[XkbGroup2Index]= 2;
- /* Step 2: Copy the symbols from the core ordering to XKB ordering */
- /* symbols in the core are in the order: */
- /* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,0)]= CORE_SYM(0);
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,1)]= CORE_SYM(1);
- for (i=2;i<nSyms[XkbGroup1Index];i++) {
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,i)]= CORE_SYM(2+i);
- }
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,0)]= CORE_SYM(2);
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,1)]= CORE_SYM(3);
- tmp= 2+(nSyms[XkbGroup1Index]-2); /* offset to extra group2 syms */
- for (i=2;i<nSyms[XkbGroup2Index];i++) {
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,i)]= CORE_SYM(tmp+i);
- }
- tmp= nSyms[XkbGroup1Index]+nSyms[XkbGroup2Index];
- if ((tmp>=map_width)&&
- ((protected&(XkbExplicitKeyType3Mask|XkbExplicitKeyType4Mask))==0)) {
- nSyms[XkbGroup3Index]= 0;
- nSyms[XkbGroup4Index]= 0;
- nGroups= 2;
+ groupsWidth = 2;
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ if ((protected & (1 << i)) && (types_inout[i] < xkb->map->num_types)) {
+ nSyms[i] = xkb->map->types[types_inout[i]].num_levels;
+ if (nSyms[i] > groupsWidth)
+ groupsWidth = nSyms[i];
+ }
+ else {
+ types_inout[i] = XkbTwoLevelIndex; /* don't really know, yet */
+ nSyms[i] = 2;
+ }
+ }
+ if (nSyms[XkbGroup1Index] < 2)
+ nSyms[XkbGroup1Index] = 2;
+ if (nSyms[XkbGroup2Index] < 2)
+ nSyms[XkbGroup2Index] = 2;
+ /* Step 2: Copy the symbols from the core ordering to XKB ordering */
+ /* symbols in the core are in the order: */
+ /* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, 0)] = CORE_SYM(0);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, 1)] = CORE_SYM(1);
+ for (i = 2; i < nSyms[XkbGroup1Index]; i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, i)] = CORE_SYM(2 + i);
+ }
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, 0)] = CORE_SYM(2);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, 1)] = CORE_SYM(3);
+ tmp = 2 + (nSyms[XkbGroup1Index] - 2); /* offset to extra group2 syms */
+ for (i = 2; i < nSyms[XkbGroup2Index]; i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, i)] = CORE_SYM(tmp + i);
+ }
+ tmp = nSyms[XkbGroup1Index] + nSyms[XkbGroup2Index];
+ if ((tmp >= map_width) &&
+ ((protected & (XkbExplicitKeyType3Mask | XkbExplicitKeyType4Mask)) ==
+ 0)) {
+ nSyms[XkbGroup3Index] = 0;
+ nSyms[XkbGroup4Index] = 0;
+ nGroups = 2;
}
else {
- nGroups= 3;
- for (i=0;i<nSyms[XkbGroup3Index];i++,tmp++) {
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index,i)]= CORE_SYM(tmp);
- }
- if ((tmp<map_width)||(protected&XkbExplicitKeyType4Mask)) {
- nGroups= 4;
- for (i=0;i<nSyms[XkbGroup4Index];i++,tmp++) {
- xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index,i)]= CORE_SYM(tmp);
- }
- }
- else {
- nSyms[XkbGroup4Index]= 0;
- }
+ nGroups = 3;
+ for (i = 0; i < nSyms[XkbGroup3Index]; i++, tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index, i)] = CORE_SYM(tmp);
+ }
+ if ((tmp < map_width) || (protected & XkbExplicitKeyType4Mask)) {
+ nGroups = 4;
+ for (i = 0; i < nSyms[XkbGroup4Index]; i++, tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index, i)] = CORE_SYM(tmp);
+ }
+ }
+ else {
+ nSyms[XkbGroup4Index] = 0;
+ }
}
/* steps 3&4: alphanumeric expansion, assign canonical types */
- empty= 0;
- for (i=0;i<nGroups;i++) {
- KeySym *syms;
- syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
- if ((nSyms[i]>1)&&(syms[1]==NoSymbol)&&(syms[0]!=NoSymbol)) {
- KeySym upper,lower;
- XConvertCase(syms[0],&lower,&upper);
- if (upper!=lower) {
- xkb_syms_rtrn[XKB_OFFSET(i,0)]= lower;
- xkb_syms_rtrn[XKB_OFFSET(i,1)]= upper;
- if ((protected&(1<<i))==0)
- types_inout[i]= XkbAlphabeticIndex;
- }
- else if ((protected&(1<<i))==0) {
- types_inout[i]= XkbOneLevelIndex;
- /* nSyms[i]= 1;*/
- }
- }
- if (((protected&(1<<i))==0)&&(types_inout[i]==XkbTwoLevelIndex)) {
- if (IsKeypadKey(syms[0])||IsKeypadKey(syms[1]))
- types_inout[i]= XkbKeypadIndex;
- else {
- KeySym upper,lower;
- XConvertCase(syms[0],&lower,&upper);
- if ((syms[0]==lower)&&(syms[1]==upper))
- types_inout[i]= XkbAlphabeticIndex;
- }
- }
- if (syms[0]==NoSymbol) {
- register int n;
- Bool found;
- for (n=1,found=False;(!found)&&(n<nSyms[i]);n++) {
- found= (syms[n]!=NoSymbol);
- }
- if (!found)
- empty|= (1<<i);
- }
+ empty = 0;
+ for (i = 0; i < nGroups; i++) {
+ KeySym *syms;
+
+ syms = &xkb_syms_rtrn[XKB_OFFSET(i, 0)];
+ if ((nSyms[i] > 1) && (syms[1] == NoSymbol) && (syms[0] != NoSymbol)) {
+ KeySym upper, lower;
+
+ XConvertCase(syms[0], &lower, &upper);
+ if (upper != lower) {
+ xkb_syms_rtrn[XKB_OFFSET(i, 0)] = lower;
+ xkb_syms_rtrn[XKB_OFFSET(i, 1)] = upper;
+ if ((protected & (1 << i)) == 0)
+ types_inout[i] = XkbAlphabeticIndex;
+ }
+ else if ((protected & (1 << i)) == 0) {
+ types_inout[i] = XkbOneLevelIndex;
+ /* nSyms[i]= 1; */
+ }
+ }
+ if (((protected & (1 << i)) == 0) &&
+ (types_inout[i] == XkbTwoLevelIndex)) {
+ if (IsKeypadKey(syms[0]) || IsKeypadKey(syms[1]))
+ types_inout[i] = XkbKeypadIndex;
+ else {
+ KeySym upper, lower;
+
+ XConvertCase(syms[0], &lower, &upper);
+ if ((syms[0] == lower) && (syms[1] == upper))
+ types_inout[i] = XkbAlphabeticIndex;
+ }
+ }
+ if (syms[0] == NoSymbol) {
+ register int n;
+ Bool found;
+
+ for (n = 1, found = False; (!found) && (n < nSyms[i]); n++) {
+ found = (syms[n] != NoSymbol);
+ }
+ if (!found)
+ empty |= (1 << i);
+ }
}
/* step 5: squoosh out empty groups */
if (empty) {
- for (i=nGroups-1;i>=0;i--) {
- if (((empty&(1<<i))==0)||(protected&(1<<i)))
- break;
- nGroups--;
- }
+ for (i = nGroups - 1; i >= 0; i--) {
+ if (((empty & (1 << i)) == 0) || (protected & (1 << i)))
+ break;
+ nGroups--;
+ }
}
- if (nGroups<1)
- return 0;
+ if (nGroups < 1)
+ return 0;
/* step 6: replicate group 1 into group two, if necessary */
- if ((nGroups>1)&&((empty&(XkbGroup1Mask|XkbGroup2Mask))==XkbGroup2Mask)) {
- if ((protected&(XkbExplicitKeyType1Mask|XkbExplicitKeyType2Mask))==0) {
- nSyms[XkbGroup2Index]= nSyms[XkbGroup1Index];
- types_inout[XkbGroup2Index]= types_inout[XkbGroup1Index];
- memcpy((char *)&xkb_syms_rtrn[2],(char *)xkb_syms_rtrn,
- 2*sizeof(KeySym));
- }
- else if (types_inout[XkbGroup1Index]==types_inout[XkbGroup2Index]) {
- memcpy((char *)&xkb_syms_rtrn[nSyms[XkbGroup1Index]],
- (char *)xkb_syms_rtrn,
- nSyms[XkbGroup1Index]*sizeof(KeySym));
- }
+ if ((nGroups > 1) &&
+ ((empty & (XkbGroup1Mask | XkbGroup2Mask)) == XkbGroup2Mask)) {
+ if ((protected & (XkbExplicitKeyType1Mask | XkbExplicitKeyType2Mask)) ==
+ 0) {
+ nSyms[XkbGroup2Index] = nSyms[XkbGroup1Index];
+ types_inout[XkbGroup2Index] = types_inout[XkbGroup1Index];
+ memcpy((char *) &xkb_syms_rtrn[2], (char *) xkb_syms_rtrn,
+ 2 * sizeof(KeySym));
+ }
+ else if (types_inout[XkbGroup1Index] == types_inout[XkbGroup2Index]) {
+ memcpy((char *) &xkb_syms_rtrn[nSyms[XkbGroup1Index]],
+ (char *) xkb_syms_rtrn,
+ nSyms[XkbGroup1Index] * sizeof(KeySym));
+ }
}
/* step 7: check for all groups identical or all width 1 */
- if (nGroups>1) {
- Bool sameType,allOneLevel;
- allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
- for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
- sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
- if (allOneLevel)
- allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
- }
- if ((sameType)&&
- (!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
- register int s;
- Bool identical;
- for (i=1,identical=True;identical&&(i<nGroups);i++) {
- KeySym *syms;
- syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
- for (s=0;identical&&(s<nSyms[i]);s++) {
- if (syms[s]!=xkb_syms_rtrn[s])
- identical= False;
- }
- }
- if (identical)
- nGroups= 1;
- }
- if (allOneLevel && (nGroups>1)) {
- KeySym *syms;
- syms= &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
- nSyms[XkbGroup1Index]= 1;
- for (i=1;i<nGroups;i++) {
- xkb_syms_rtrn[i]= syms[0];
- syms+= nSyms[i];
- nSyms[i]= 1;
- }
- }
+ if (nGroups > 1) {
+ Bool sameType, allOneLevel;
+
+ allOneLevel = (xkb->map->types[types_inout[0]].num_levels == 1);
+ for (i = 1, sameType = True; (allOneLevel || sameType) && (i < nGroups);
+ i++) {
+ sameType = (sameType &&
+ (types_inout[i] == types_inout[XkbGroup1Index]));
+ if (allOneLevel)
+ allOneLevel = (xkb->map->types[types_inout[i]].num_levels == 1);
+ }
+ if ((sameType) &&
+ (!(protected &
+ (XkbExplicitKeyTypesMask & ~XkbExplicitKeyType1Mask)))) {
+ register int s;
+ Bool identical;
+
+ for (i = 1, identical = True; identical && (i < nGroups); i++) {
+ KeySym *syms;
+
+ syms = &xkb_syms_rtrn[XKB_OFFSET(i, 0)];
+ for (s = 0; identical && (s < nSyms[i]); s++) {
+ if (syms[s] != xkb_syms_rtrn[s])
+ identical = False;
+ }
+ }
+ if (identical)
+ nGroups = 1;
+ }
+ if (allOneLevel && (nGroups > 1)) {
+ KeySym *syms;
+
+ syms = &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
+ nSyms[XkbGroup1Index] = 1;
+ for (i = 1; i < nGroups; i++) {
+ xkb_syms_rtrn[i] = syms[0];
+ syms += nSyms[i];
+ nSyms[i] = 1;
+ }
+ }
}
return nGroups;
}
static XkbSymInterpretPtr
-_XkbFindMatchingInterp( XkbDescPtr xkb,
- KeySym sym,
- unsigned int real_mods,
- unsigned int level)
+_XkbFindMatchingInterp(XkbDescPtr xkb,
+ KeySym sym,
+ unsigned int real_mods,
+ unsigned int level)
{
-register unsigned i;
-XkbSymInterpretPtr interp,rtrn;
-CARD8 mods;
-
- rtrn= NULL;
- interp= xkb->compat->sym_interpret;
- for (i=0;i<xkb->compat->num_si;i++,interp++) {
- if ((interp->sym==NoSymbol)||(sym==interp->sym)) {
- int match;
- if ((level==0)||((interp->match&XkbSI_LevelOneOnly)==0))
- mods= real_mods;
- else mods= 0;
- switch (interp->match&XkbSI_OpMask) {
- case XkbSI_NoneOf:
- match= ((interp->mods&mods)==0);
- break;
- case XkbSI_AnyOfOrNone:
- match= ((mods==0)||((interp->mods&mods)!=0));
- break;
- case XkbSI_AnyOf:
- match= ((interp->mods&mods)!=0);
- break;
- case XkbSI_AllOf:
- match= ((interp->mods&mods)==interp->mods);
- break;
- case XkbSI_Exactly:
- match= (interp->mods==mods);
- break;
- default:
- match= 0;
- break;
- }
- if (match) {
- if (interp->sym!=NoSymbol) {
- return interp;
- }
- else if (rtrn==NULL) {
- rtrn= interp;
- }
- }
- }
+ register unsigned i;
+ XkbSymInterpretPtr interp, rtrn;
+ CARD8 mods;
+
+ rtrn = NULL;
+ interp = xkb->compat->sym_interpret;
+ for (i = 0; i < xkb->compat->num_si; i++, interp++) {
+ if ((interp->sym == NoSymbol) || (sym == interp->sym)) {
+ int match;
+
+ if ((level == 0) || ((interp->match & XkbSI_LevelOneOnly) == 0))
+ mods = real_mods;
+ else
+ mods = 0;
+ switch (interp->match & XkbSI_OpMask) {
+ case XkbSI_NoneOf:
+ match = ((interp->mods & mods) == 0);
+ break;
+ case XkbSI_AnyOfOrNone:
+ match = ((mods == 0) || ((interp->mods & mods) != 0));
+ break;
+ case XkbSI_AnyOf:
+ match = ((interp->mods & mods) != 0);
+ break;
+ case XkbSI_AllOf:
+ match = ((interp->mods & mods) == interp->mods);
+ break;
+ case XkbSI_Exactly:
+ match = (interp->mods == mods);
+ break;
+ default:
+ match = 0;
+ break;
+ }
+ if (match) {
+ if (interp->sym != NoSymbol) {
+ return interp;
+ }
+ else if (rtrn == NULL) {
+ rtrn = interp;
+ }
+ }
+ }
}
return rtrn;
}
static void
-_XkbAddKeyChange(KeyCode *pFirst,unsigned char *pNum,KeyCode newKey)
+_XkbAddKeyChange(KeyCode *pFirst, unsigned char *pNum, KeyCode newKey)
{
-KeyCode last;
+ KeyCode last;
- last= (*pFirst)+(*pNum);
- if (newKey<*pFirst) {
- *pFirst= newKey;
- *pNum= (last-newKey)+1;
+ last = (*pFirst) + (*pNum);
+ if (newKey < *pFirst) {
+ *pFirst = newKey;
+ *pNum = (last - newKey) + 1;
}
- else if (newKey>last) {
- *pNum= (last-*pFirst)+1;
+ else if (newKey > last) {
+ *pNum = (last - *pFirst) + 1;
}
return;
}
static void
-_XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
+_XkbSetActionKeyMods(XkbDescPtr xkb, XkbAction *act, unsigned mods)
{
-unsigned tmp;
+ unsigned tmp;
switch (act->type) {
- case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
- if (act->mods.flags&XkbSA_UseModMapMods)
- act->mods.real_mods= act->mods.mask= mods;
- if ((tmp= XkbModActionVMods(&act->mods))!=0) {
- XkbVirtualModsToReal(xkb,tmp,&tmp);
- act->mods.mask|= tmp;
- }
- break;
- case XkbSA_ISOLock:
- if (act->iso.flags&XkbSA_UseModMapMods)
- act->iso.real_mods= act->iso.mask= mods;
- if ((tmp= XkbModActionVMods(&act->iso))!=0) {
- XkbVirtualModsToReal(xkb,tmp,&tmp);
- act->iso.mask|= tmp;
- }
- break;
+ case XkbSA_SetMods:
+ case XkbSA_LatchMods:
+ case XkbSA_LockMods:
+ if (act->mods.flags & XkbSA_UseModMapMods)
+ act->mods.real_mods = act->mods.mask = mods;
+ if ((tmp = XkbModActionVMods(&act->mods)) != 0) {
+ XkbVirtualModsToReal(xkb, tmp, &tmp);
+ act->mods.mask |= tmp;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if (act->iso.flags & XkbSA_UseModMapMods)
+ act->iso.real_mods = act->iso.mask = mods;
+ if ((tmp = XkbModActionVMods(&act->iso)) != 0) {
+ XkbVirtualModsToReal(xkb, tmp, &tmp);
+ act->iso.mask |= tmp;
+ }
+ break;
}
return;
}
@@ -417,357 +424,374 @@ unsigned tmp;
#define IBUF_SIZE 8
Bool
-XkbApplyCompatMapToKey(XkbDescPtr xkb,KeyCode key,XkbChangesPtr changes)
+XkbApplyCompatMapToKey(XkbDescPtr xkb, KeyCode key, XkbChangesPtr changes)
{
-KeySym * syms;
-unsigned char explicit,mods;
-XkbSymInterpretPtr *interps,ibuf[IBUF_SIZE];
-int n,nSyms,found;
-unsigned changed,tmp;
-
- if ((!xkb)||(!xkb->map)||(!xkb->map->key_sym_map)||
- (!xkb->compat)||(!xkb->compat->sym_interpret)||
- (key<xkb->min_key_code)||(key>xkb->max_key_code)) {
- return False;
- }
- if (((!xkb->server)||(!xkb->server->key_acts))&&
- (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success)) {
- return False;
- }
- changed= 0; /* keeps track of what has changed in _this_ call */
- explicit= xkb->server->explicit[key];
- if (explicit&XkbExplicitInterpretMask) /* nothing to do */
- return True;
- mods= (xkb->map->modmap?xkb->map->modmap[key]:0);
- nSyms= XkbKeyNumSyms(xkb,key);
- syms= XkbKeySymsPtr(xkb,key);
- if (nSyms>IBUF_SIZE) {
- interps= _XkbTypedCalloc(nSyms,XkbSymInterpretPtr);
- if (interps==NULL) {
- interps= ibuf;
- nSyms= IBUF_SIZE;
- }
+ KeySym *syms;
+ unsigned char explicit, mods;
+ XkbSymInterpretPtr *interps, ibuf[IBUF_SIZE];
+ int n, nSyms, found;
+ unsigned changed, tmp;
+
+ if ((!xkb) || (!xkb->map) || (!xkb->map->key_sym_map) ||
+ (!xkb->compat) || (!xkb->compat->sym_interpret) ||
+ (key < xkb->min_key_code) || (key > xkb->max_key_code)) {
+ return False;
+ }
+ if (((!xkb->server) || (!xkb->server->key_acts)) &&
+ (XkbAllocServerMap(xkb, XkbAllServerInfoMask, 0) != Success)) {
+ return False;
+ }
+ changed = 0; /* keeps track of what has changed in _this_ call */
+ explicit = xkb->server->explicit[key];
+ if (explicit & XkbExplicitInterpretMask) /* nothing to do */
+ return True;
+ mods = (xkb->map->modmap ? xkb->map->modmap[key] : 0);
+ nSyms = XkbKeyNumSyms(xkb, key);
+ syms = XkbKeySymsPtr(xkb, key);
+ if (nSyms > IBUF_SIZE) {
+ interps = _XkbTypedCalloc(nSyms, XkbSymInterpretPtr);
+ if (interps == NULL) {
+ interps = ibuf;
+ nSyms = IBUF_SIZE;
+ }
}
else {
- interps= ibuf;
- }
- found= 0;
- for (n=0;n<nSyms;n++) {
- unsigned level= (n%XkbKeyGroupsWidth(xkb,key));
- interps[n]= NULL;
- if (syms[n]!=NoSymbol) {
- interps[n]= _XkbFindMatchingInterp(xkb,syms[n],mods,level);
- if (interps[n]&&interps[n]->act.type!=XkbSA_NoAction)
- found++;
- else interps[n]= NULL;
- }
+ interps = ibuf;
+ }
+ found = 0;
+ for (n = 0; n < nSyms; n++) {
+ unsigned level = (n % XkbKeyGroupsWidth(xkb, key));
+
+ interps[n] = NULL;
+ if (syms[n] != NoSymbol) {
+ interps[n] = _XkbFindMatchingInterp(xkb, syms[n], mods, level);
+ if (interps[n] && interps[n]->act.type != XkbSA_NoAction)
+ found++;
+ else
+ interps[n] = NULL;
+ }
}
/* 1/28/96 (ef) -- XXX! WORKING HERE */
if (!found) {
- if (xkb->server->key_acts[key]!=0) {
- xkb->server->key_acts[key]= 0;
- changed|= XkbKeyActionsMask;
- }
+ if (xkb->server->key_acts[key] != 0) {
+ xkb->server->key_acts[key] = 0;
+ changed |= XkbKeyActionsMask;
+ }
}
else {
- XkbAction *pActs;
- unsigned int new_vmodmask;
- changed|= XkbKeyActionsMask;
- pActs= XkbResizeKeyActions(xkb,key,nSyms);
- if (!pActs) {
+ XkbAction *pActs;
+ unsigned int new_vmodmask;
+
+ changed |= XkbKeyActionsMask;
+ pActs = XkbResizeKeyActions(xkb, key, nSyms);
+ if (!pActs) {
if (nSyms > IBUF_SIZE)
Xfree(interps);
- return False;
- }
- new_vmodmask= 0;
- for (n=0;n<nSyms;n++) {
- if (interps[n]) {
- unsigned effMods;
-
- pActs[n]= *((XkbAction *)&interps[n]->act);
- if ((n==0)||((interps[n]->match&XkbSI_LevelOneOnly)==0)) {
- effMods= mods;
- if (interps[n]->virtual_mod!=XkbNoModifier)
- new_vmodmask|= (1<<interps[n]->virtual_mod);
- }
- else effMods= 0;
- _XkbSetActionKeyMods(xkb,&pActs[n],effMods);
- }
- else pActs[n].type= XkbSA_NoAction;
- }
- if (((explicit&XkbExplicitVModMapMask)==0)&&
- (xkb->server->vmodmap[key]!=new_vmodmask)) {
- changed|= XkbVirtualModMapMask;
- xkb->server->vmodmap[key]= new_vmodmask;
- }
- if (interps[0]) {
- if ((interps[0]->flags&XkbSI_LockingKey)&&
- ((explicit&XkbExplicitBehaviorMask)==0)) {
- xkb->server->behaviors[key].type= XkbKB_Lock;
- changed|= XkbKeyBehaviorsMask;
- }
- if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
- CARD8 old;
- old= xkb->ctrls->per_key_repeat[key/8];
- if (interps[0]->flags&XkbSI_AutoRepeat)
- xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
- else xkb->ctrls->per_key_repeat[key/8]&= ~(1<<(key%8));
- if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
- changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
- }
- }
- }
- if ((!found)||(interps[0]==NULL)) {
- if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
- CARD8 old;
- old= xkb->ctrls->per_key_repeat[key/8];
+ return False;
+ }
+ new_vmodmask = 0;
+ for (n = 0; n < nSyms; n++) {
+ if (interps[n]) {
+ unsigned effMods;
+
+ pActs[n] = *((XkbAction *) &interps[n]->act);
+ if ((n == 0) || ((interps[n]->match & XkbSI_LevelOneOnly) == 0)) {
+ effMods = mods;
+ if (interps[n]->virtual_mod != XkbNoModifier)
+ new_vmodmask |= (1 << interps[n]->virtual_mod);
+ }
+ else
+ effMods = 0;
+ _XkbSetActionKeyMods(xkb, &pActs[n], effMods);
+ }
+ else
+ pActs[n].type = XkbSA_NoAction;
+ }
+ if (((explicit & XkbExplicitVModMapMask) == 0) &&
+ (xkb->server->vmodmap[key] != new_vmodmask)) {
+ changed |= XkbVirtualModMapMask;
+ xkb->server->vmodmap[key] = new_vmodmask;
+ }
+ if (interps[0]) {
+ if ((interps[0]->flags & XkbSI_LockingKey) &&
+ ((explicit & XkbExplicitBehaviorMask) == 0)) {
+ xkb->server->behaviors[key].type = XkbKB_Lock;
+ changed |= XkbKeyBehaviorsMask;
+ }
+ if (((explicit & XkbExplicitAutoRepeatMask) == 0) && (xkb->ctrls)) {
+ CARD8 old;
+
+ old = xkb->ctrls->per_key_repeat[key / 8];
+ if (interps[0]->flags & XkbSI_AutoRepeat)
+ xkb->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
+ else
+ xkb->ctrls->per_key_repeat[key / 8] &= ~(1 << (key % 8));
+ if (changes && (old != xkb->ctrls->per_key_repeat[key / 8]))
+ changes->ctrls.changed_ctrls |= XkbPerKeyRepeatMask;
+ }
+ }
+ }
+ if ((!found) || (interps[0] == NULL)) {
+ if (((explicit & XkbExplicitAutoRepeatMask) == 0) && (xkb->ctrls)) {
+ CARD8 old;
+
+ old = xkb->ctrls->per_key_repeat[key / 8];
#ifdef RETURN_SHOULD_REPEAT
- if (*XkbKeySymsPtr(xkb,key) != XK_Return)
+ if (*XkbKeySymsPtr(xkb, key) != XK_Return)
#endif
- xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
- if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
- changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
- }
- if (((explicit&XkbExplicitBehaviorMask)==0)&&
- (xkb->server->behaviors[key].type==XkbKB_Lock)) {
- xkb->server->behaviors[key].type= XkbKB_Default;
- changed|= XkbKeyBehaviorsMask;
- }
+ xkb->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
+ if (changes && (old != xkb->ctrls->per_key_repeat[key / 8]))
+ changes->ctrls.changed_ctrls |= XkbPerKeyRepeatMask;
+ }
+ if (((explicit & XkbExplicitBehaviorMask) == 0) &&
+ (xkb->server->behaviors[key].type == XkbKB_Lock)) {
+ xkb->server->behaviors[key].type = XkbKB_Default;
+ changed |= XkbKeyBehaviorsMask;
+ }
}
if (changes) {
- XkbMapChangesPtr mc;
- mc= &changes->map;
- tmp= (changed&mc->changed);
- if (tmp&XkbKeyActionsMask)
- _XkbAddKeyChange(&mc->first_key_act,&mc->num_key_acts,key);
- else if (changed&XkbKeyActionsMask) {
- mc->changed|= XkbKeyActionsMask;
- mc->first_key_act= key;
- mc->num_key_acts= 1;
- }
- if (tmp&XkbKeyBehaviorsMask) {
- _XkbAddKeyChange(&mc->first_key_behavior,&mc->num_key_behaviors,
- key);
- }
- else if (changed&XkbKeyBehaviorsMask) {
- mc->changed|= XkbKeyBehaviorsMask;
- mc->first_key_behavior= key;
- mc->num_key_behaviors= 1;
- }
- if (tmp&XkbVirtualModMapMask)
- _XkbAddKeyChange(&mc->first_vmodmap_key,&mc->num_vmodmap_keys,key);
- else if (changed&XkbVirtualModMapMask) {
- mc->changed|= XkbVirtualModMapMask;
- mc->first_vmodmap_key= key;
- mc->num_vmodmap_keys= 1;
- }
- mc->changed|= changed;
- }
- if (interps!=ibuf)
- _XkbFree(interps);
+ XkbMapChangesPtr mc;
+
+ mc = &changes->map;
+ tmp = (changed & mc->changed);
+ if (tmp & XkbKeyActionsMask)
+ _XkbAddKeyChange(&mc->first_key_act, &mc->num_key_acts, key);
+ else if (changed & XkbKeyActionsMask) {
+ mc->changed |= XkbKeyActionsMask;
+ mc->first_key_act = key;
+ mc->num_key_acts = 1;
+ }
+ if (tmp & XkbKeyBehaviorsMask) {
+ _XkbAddKeyChange(&mc->first_key_behavior, &mc->num_key_behaviors,
+ key);
+ }
+ else if (changed & XkbKeyBehaviorsMask) {
+ mc->changed |= XkbKeyBehaviorsMask;
+ mc->first_key_behavior = key;
+ mc->num_key_behaviors = 1;
+ }
+ if (tmp & XkbVirtualModMapMask)
+ _XkbAddKeyChange(&mc->first_vmodmap_key, &mc->num_vmodmap_keys,
+ key);
+ else if (changed & XkbVirtualModMapMask) {
+ mc->changed |= XkbVirtualModMapMask;
+ mc->first_vmodmap_key = key;
+ mc->num_vmodmap_keys = 1;
+ }
+ mc->changed |= changed;
+ }
+ if (interps != ibuf)
+ _XkbFree(interps);
return True;
}
Bool
-XkbUpdateMapFromCore( XkbDescPtr xkb,
- KeyCode first_key,
- int num_keys,
- int map_width,
- KeySym * core_keysyms,
- XkbChangesPtr changes)
+XkbUpdateMapFromCore(XkbDescPtr xkb,
+ KeyCode first_key,
+ int num_keys,
+ int map_width,
+ KeySym *core_keysyms,
+ XkbChangesPtr changes)
{
-register int key,last_key;
-KeySym * syms;
+ register int key, last_key;
+ KeySym *syms;
- syms= &core_keysyms[(first_key-xkb->min_key_code)*map_width];
+ syms = &core_keysyms[(first_key - xkb->min_key_code) * map_width];
if (changes) {
- if (changes->map.changed&XkbKeySymsMask) {
- _XkbAddKeyChange(&changes->map.first_key_sym,
- &changes->map.num_key_syms,first_key);
- if (num_keys>1) {
- _XkbAddKeyChange(&changes->map.first_key_sym,
- &changes->map.num_key_syms,
- first_key+num_keys-1);
- }
- }
- else {
- changes->map.changed|= XkbKeySymsMask;
- changes->map.first_key_sym= first_key;
- changes->map.num_key_syms= num_keys;
- }
- }
- last_key= first_key+num_keys-1;
- for (key=first_key;key<=last_key;key++,syms+= map_width) {
- XkbMapChangesPtr mc;
- unsigned explicit;
- KeySym tsyms[XkbMaxSymsPerKey];
- int types[XkbNumKbdGroups];
- int nG;
-
- explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
- types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
- types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
- types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
- types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
- nG= XkbKeyTypesForCoreSymbols(xkb,map_width,syms,explicit,types,tsyms);
- if (changes)
- mc= &changes->map;
- else mc= NULL;
- XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
- memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
- XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
- XkbApplyCompatMapToKey(xkb,key,changes);
- }
-
- if ((xkb->server->vmods!=NULL)&&(xkb->map->modmap!=NULL)&&(changes)&&
- (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask))) {
- unsigned char newVMods[XkbNumVirtualMods];
- register unsigned bit,i;
- unsigned present;
-
- bzero(newVMods,XkbNumVirtualMods);
- present= 0;
- for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
- if (xkb->server->vmodmap[key]==0)
- continue;
- for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if (bit&xkb->server->vmodmap[key]) {
- present|= bit;
- newVMods[i]|= xkb->map->modmap[key];
- }
- }
- }
- for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
- changes->map.changed|= XkbVirtualModsMask;
- changes->map.vmods|= bit;
- xkb->server->vmods[i]= newVMods[i];
- }
- }
- }
- if (changes && (changes->map.changed&XkbVirtualModsMask))
- XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
+ if (changes->map.changed & XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms, first_key);
+ if (num_keys > 1) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms,
+ first_key + num_keys - 1);
+ }
+ }
+ else {
+ changes->map.changed |= XkbKeySymsMask;
+ changes->map.first_key_sym = first_key;
+ changes->map.num_key_syms = num_keys;
+ }
+ }
+ last_key = first_key + num_keys - 1;
+ for (key = first_key; key <= last_key; key++, syms += map_width) {
+ XkbMapChangesPtr mc;
+ unsigned explicit;
+ KeySym tsyms[XkbMaxSymsPerKey];
+ int types[XkbNumKbdGroups];
+ int nG;
+
+ explicit = xkb->server->explicit[key] & XkbExplicitKeyTypesMask;
+ types[XkbGroup1Index] = XkbKeyKeyTypeIndex(xkb, key, XkbGroup1Index);
+ types[XkbGroup2Index] = XkbKeyKeyTypeIndex(xkb, key, XkbGroup2Index);
+ types[XkbGroup3Index] = XkbKeyKeyTypeIndex(xkb, key, XkbGroup3Index);
+ types[XkbGroup4Index] = XkbKeyKeyTypeIndex(xkb, key, XkbGroup4Index);
+ nG = XkbKeyTypesForCoreSymbols(xkb, map_width, syms, explicit, types,
+ tsyms);
+ if (changes)
+ mc = &changes->map;
+ else
+ mc = NULL;
+ XkbChangeTypesOfKey(xkb, key, nG, XkbAllGroupsMask, types, mc);
+ memcpy((char *) XkbKeySymsPtr(xkb, key), (char *) tsyms,
+ XkbKeyNumSyms(xkb, key) * sizeof(KeySym));
+ XkbApplyCompatMapToKey(xkb, key, changes);
+ }
+
+ if ((xkb->map->modmap != NULL) && (changes) &&
+ (changes->map.changed & (XkbVirtualModMapMask | XkbModifierMapMask))) {
+ unsigned char newVMods[XkbNumVirtualMods];
+ register unsigned bit, i;
+ unsigned present;
+
+ bzero(newVMods, XkbNumVirtualMods);
+ present = 0;
+ for (key = xkb->min_key_code; key <= xkb->max_key_code; key++) {
+ if (xkb->server->vmodmap[key] == 0)
+ continue;
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (bit & xkb->server->vmodmap[key]) {
+ present |= bit;
+ newVMods[i] |= xkb->map->modmap[key];
+ }
+ }
+ }
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if ((bit & present) && (newVMods[i] != xkb->server->vmods[i])) {
+ changes->map.changed |= XkbVirtualModsMask;
+ changes->map.vmods |= bit;
+ xkb->server->vmods[i] = newVMods[i];
+ }
+ }
+ }
+ if (changes && (changes->map.changed & XkbVirtualModsMask))
+ XkbApplyVirtualModChanges(xkb, changes->map.vmods, changes);
return True;
}
Status
-XkbChangeTypesOfKey( XkbDescPtr xkb,
- int key,
- int nGroups,
- unsigned groups,
- int * newTypesIn,
- XkbMapChangesPtr changes)
+XkbChangeTypesOfKey(XkbDescPtr xkb,
+ int key,
+ int nGroups,
+ unsigned groups,
+ int *newTypesIn,
+ XkbMapChangesPtr changes)
{
-XkbKeyTypePtr pOldType,pNewType;
-register int i;
-int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
-
- if ((!xkb) || (!XkbKeycodeInRange(xkb,key)) || (!xkb->map) ||
- (!xkb->map->types)||((groups&XkbAllGroupsMask)==0)||
- (nGroups>XkbNumKbdGroups)) {
- return BadMatch;
- }
- if (nGroups==0) {
- for (i=0;i<XkbNumKbdGroups;i++) {
- xkb->map->key_sym_map[key].kt_index[i]= XkbOneLevelIndex;
- }
- i= xkb->map->key_sym_map[key].group_info;
- i= XkbSetNumGroups(i,0);
- xkb->map->key_sym_map[key].group_info= i;
- XkbResizeKeySyms(xkb,key,0);
- return Success;
- }
-
- nOldGroups= XkbKeyNumGroups(xkb,key);
- oldWidth= XkbKeyGroupsWidth(xkb,key);
- for (width=i=0;i<nGroups;i++) {
- if (groups&(1<<i))
- newTypes[i]= newTypesIn[i];
- else if (i<nOldGroups)
- newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,i);
- else if (nOldGroups>0)
- newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
- else newTypes[i]= XkbTwoLevelIndex;
- if (newTypes[i]>xkb->map->num_types)
- return BadMatch;
- pNewType= &xkb->map->types[newTypes[i]];
- if (pNewType->num_levels>width)
- width= pNewType->num_levels;
- }
- if ((xkb->ctrls)&&(nGroups>xkb->ctrls->num_groups))
- xkb->ctrls->num_groups= nGroups;
- if ((width!=oldWidth)||(nGroups!=nOldGroups)) {
- KeySym oldSyms[XkbMaxSymsPerKey],*pSyms;
- int nCopy;
-
- if (nOldGroups==0) {
- pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
- if (pSyms!=NULL) {
- i= xkb->map->key_sym_map[key].group_info;
- i= XkbSetNumGroups(i,nGroups);
- xkb->map->key_sym_map[key].group_info= i;
- xkb->map->key_sym_map[key].width= width;
- for (i=0;i<nGroups;i++) {
- xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
- }
- return Success;
- }
- return BadAlloc;
- }
- pSyms= XkbKeySymsPtr(xkb,key);
- memcpy(oldSyms,pSyms,XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
- pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
- if (pSyms==NULL)
- return BadAlloc;
- bzero(pSyms,width*nGroups*sizeof(KeySym));
- for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
- pOldType= XkbKeyKeyType(xkb,key,i);
- pNewType= &xkb->map->types[newTypes[i]];
- if (pNewType->num_levels>pOldType->num_levels)
- nCopy= pOldType->num_levels;
- else nCopy= pNewType->num_levels;
- memcpy(&pSyms[i*width],&oldSyms[i*oldWidth],nCopy*sizeof(KeySym));
- }
- if (XkbKeyHasActions(xkb,key)) {
- XkbAction oldActs[XkbMaxSymsPerKey],*pActs;
- pActs= XkbKeyActionsPtr(xkb,key);
- memcpy(oldActs,pActs,XkbKeyNumSyms(xkb,key)*sizeof(XkbAction));
- pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
- if (pActs==NULL)
- return BadAlloc;
- bzero(pActs,width*nGroups*sizeof(XkbAction));
- for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
- pOldType= XkbKeyKeyType(xkb,key,i);
- pNewType= &xkb->map->types[newTypes[i]];
- if (pNewType->num_levels>pOldType->num_levels)
- nCopy= pOldType->num_levels;
- else nCopy= pNewType->num_levels;
- memcpy(&pActs[i*width],&oldActs[i*oldWidth],
- nCopy*sizeof(XkbAction));
- }
- }
- i= xkb->map->key_sym_map[key].group_info;
- i= XkbSetNumGroups(i,nGroups);
- xkb->map->key_sym_map[key].group_info= i;
- xkb->map->key_sym_map[key].width= width;
- }
- width= 0;
- for (i=0;i<nGroups;i++) {
- xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
- if (xkb->map->types[newTypes[i]].num_levels>width)
- width= xkb->map->types[newTypes[i]].num_levels;
- }
- xkb->map->key_sym_map[key].width= width;
- if (changes!=NULL) {
- if (changes->changed&XkbKeySymsMask) {
- _XkbAddKeyChange(&changes->first_key_sym,&changes->num_key_syms,
- key);
- }
- else {
- changes->changed|= XkbKeySymsMask;
- changes->first_key_sym= key;
- changes->num_key_syms= 1;
- }
+ XkbKeyTypePtr pOldType, pNewType;
+ register int i;
+ int width, nOldGroups, oldWidth, newTypes[XkbNumKbdGroups];
+
+ if ((!xkb) || (!XkbKeycodeInRange(xkb, key)) || (!xkb->map) ||
+ (!xkb->map->types) || ((groups & XkbAllGroupsMask) == 0) ||
+ (nGroups > XkbNumKbdGroups)) {
+ return BadMatch;
+ }
+ if (nGroups == 0) {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ xkb->map->key_sym_map[key].kt_index[i] = XkbOneLevelIndex;
+ }
+ i = xkb->map->key_sym_map[key].group_info;
+ i = XkbSetNumGroups(i, 0);
+ xkb->map->key_sym_map[key].group_info = i;
+ XkbResizeKeySyms(xkb, key, 0);
+ return Success;
+ }
+
+ nOldGroups = XkbKeyNumGroups(xkb, key);
+ oldWidth = XkbKeyGroupsWidth(xkb, key);
+ for (width = i = 0; i < nGroups; i++) {
+ if (groups & (1 << i))
+ newTypes[i] = newTypesIn[i];
+ else if (i < nOldGroups)
+ newTypes[i] = XkbKeyKeyTypeIndex(xkb, key, i);
+ else if (nOldGroups > 0)
+ newTypes[i] = XkbKeyKeyTypeIndex(xkb, key, XkbGroup1Index);
+ else
+ newTypes[i] = XkbTwoLevelIndex;
+ if (newTypes[i] > xkb->map->num_types)
+ return BadMatch;
+ pNewType = &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels > width)
+ width = pNewType->num_levels;
+ }
+ if ((xkb->ctrls) && (nGroups > xkb->ctrls->num_groups))
+ xkb->ctrls->num_groups = nGroups;
+ if ((width != oldWidth) || (nGroups != nOldGroups)) {
+ KeySym oldSyms[XkbMaxSymsPerKey], *pSyms;
+ int nCopy;
+
+ if (nOldGroups == 0) {
+ pSyms = XkbResizeKeySyms(xkb, key, width * nGroups);
+ if (pSyms != NULL) {
+ i = xkb->map->key_sym_map[key].group_info;
+ i = XkbSetNumGroups(i, nGroups);
+ xkb->map->key_sym_map[key].group_info = i;
+ xkb->map->key_sym_map[key].width = width;
+ for (i = 0; i < nGroups; i++) {
+ xkb->map->key_sym_map[key].kt_index[i] = newTypes[i];
+ }
+ return Success;
+ }
+ return BadAlloc;
+ }
+ pSyms = XkbKeySymsPtr(xkb, key);
+ memcpy(oldSyms, pSyms, XkbKeyNumSyms(xkb, key) * sizeof(KeySym));
+ pSyms = XkbResizeKeySyms(xkb, key, width * nGroups);
+ if (pSyms == NULL)
+ return BadAlloc;
+ bzero(pSyms, width * nGroups * sizeof(KeySym));
+ for (i = 0; (i < nGroups) && (i < nOldGroups); i++) {
+ pOldType = XkbKeyKeyType(xkb, key, i);
+ pNewType = &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels > pOldType->num_levels)
+ nCopy = pOldType->num_levels;
+ else
+ nCopy = pNewType->num_levels;
+ memcpy(&pSyms[i * width], &oldSyms[i * oldWidth],
+ nCopy * sizeof(KeySym));
+ }
+ if (XkbKeyHasActions(xkb, key)) {
+ XkbAction oldActs[XkbMaxSymsPerKey], *pActs;
+
+ pActs = XkbKeyActionsPtr(xkb, key);
+ memcpy(oldActs, pActs, XkbKeyNumSyms(xkb, key) * sizeof(XkbAction));
+ pActs = XkbResizeKeyActions(xkb, key, width * nGroups);
+ if (pActs == NULL)
+ return BadAlloc;
+ bzero(pActs, width * nGroups * sizeof(XkbAction));
+ for (i = 0; (i < nGroups) && (i < nOldGroups); i++) {
+ pOldType = XkbKeyKeyType(xkb, key, i);
+ pNewType = &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels > pOldType->num_levels)
+ nCopy = pOldType->num_levels;
+ else
+ nCopy = pNewType->num_levels;
+ memcpy(&pActs[i * width], &oldActs[i * oldWidth],
+ nCopy * sizeof(XkbAction));
+ }
+ }
+ i = xkb->map->key_sym_map[key].group_info;
+ i = XkbSetNumGroups(i, nGroups);
+ xkb->map->key_sym_map[key].group_info = i;
+ xkb->map->key_sym_map[key].width = width;
+ }
+ width = 0;
+ for (i = 0; i < nGroups; i++) {
+ xkb->map->key_sym_map[key].kt_index[i] = newTypes[i];
+ if (xkb->map->types[newTypes[i]].num_levels > width)
+ width = xkb->map->types[newTypes[i]].num_levels;
+ }
+ xkb->map->key_sym_map[key].width = width;
+ if (changes != NULL) {
+ if (changes->changed & XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->first_key_sym, &changes->num_key_syms,
+ key);
+ }
+ else {
+ changes->changed |= XkbKeySymsMask;
+ changes->first_key_sym = key;
+ changes->num_key_syms = 1;
+ }
}
return Success;
}
@@ -775,204 +799,223 @@ int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
/***====================================================================***/
Bool
-XkbVirtualModsToReal(XkbDescPtr xkb,unsigned virtual_mask,unsigned *mask_rtrn)
+XkbVirtualModsToReal(XkbDescPtr xkb, unsigned virtual_mask, unsigned *mask_rtrn)
{
-register int i,bit;
-register unsigned mask;
-
- if (xkb==NULL)
- return False;
- if (virtual_mask==0) {
- *mask_rtrn= 0;
- return True;
- }
- if (xkb->server==NULL)
- return False;
- for (i=mask=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if (virtual_mask&bit)
- mask|= xkb->server->vmods[i];
- }
- *mask_rtrn= mask;
+ register int i, bit;
+ register unsigned mask;
+
+ if (xkb == NULL)
+ return False;
+ if (virtual_mask == 0) {
+ *mask_rtrn = 0;
+ return True;
+ }
+ if (xkb->server == NULL)
+ return False;
+ for (i = mask = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (virtual_mask & bit)
+ mask |= xkb->server->vmods[i];
+ }
+ *mask_rtrn = mask;
return True;
}
/***====================================================================***/
Bool
-XkbUpdateActionVirtualMods(XkbDescPtr xkb,XkbAction *act,unsigned changed)
+XkbUpdateActionVirtualMods(XkbDescPtr xkb, XkbAction *act, unsigned changed)
{
-unsigned int tmp;
+ unsigned int tmp;
switch (act->type) {
- case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
- if (((tmp= XkbModActionVMods(&act->mods))&changed)!=0) {
- XkbVirtualModsToReal(xkb,tmp,&tmp);
- act->mods.mask= act->mods.real_mods;
- act->mods.mask|= tmp;
- return True;
- }
- break;
- case XkbSA_ISOLock:
- if ((((tmp= XkbModActionVMods(&act->iso))!=0)&changed)!=0) {
- XkbVirtualModsToReal(xkb,tmp,&tmp);
- act->iso.mask= act->iso.real_mods;
- act->iso.mask|= tmp;
- return True;
- }
- break;
+ case XkbSA_SetMods:
+ case XkbSA_LatchMods:
+ case XkbSA_LockMods:
+ if (((tmp = XkbModActionVMods(&act->mods)) & changed) != 0) {
+ XkbVirtualModsToReal(xkb, tmp, &tmp);
+ act->mods.mask = act->mods.real_mods;
+ act->mods.mask |= tmp;
+ return True;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if ((((tmp = XkbModActionVMods(&act->iso)) != 0) & changed) != 0) {
+ XkbVirtualModsToReal(xkb, tmp, &tmp);
+ act->iso.mask = act->iso.real_mods;
+ act->iso.mask |= tmp;
+ return True;
+ }
+ break;
}
return False;
}
void
-XkbUpdateKeyTypeVirtualMods( XkbDescPtr xkb,
- XkbKeyTypePtr type,
- unsigned int changed,
- XkbChangesPtr changes)
+XkbUpdateKeyTypeVirtualMods(XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned int changed,
+ XkbChangesPtr changes)
{
-register unsigned int i;
-unsigned int mask = 0;
-
- XkbVirtualModsToReal(xkb,type->mods.vmods,&mask);
- type->mods.mask= type->mods.real_mods|mask;
- if ((type->map_count>0)&&(type->mods.vmods!=0)) {
- XkbKTMapEntryPtr entry;
- for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
- if (entry->mods.vmods!=0) {
- XkbVirtualModsToReal(xkb,entry->mods.vmods,&mask);
- entry->mods.mask=entry->mods.real_mods|mask;
- /* entry is active if vmods are bound*/
- entry->active= (mask!=0);
- }
- else entry->active= 1;
- }
+ register unsigned int i;
+ unsigned int mask = 0;
+
+ XkbVirtualModsToReal(xkb, type->mods.vmods, &mask);
+ type->mods.mask = type->mods.real_mods | mask;
+ if ((type->map_count > 0) && (type->mods.vmods != 0)) {
+ XkbKTMapEntryPtr entry;
+
+ for (i = 0, entry = type->map; i < type->map_count; i++, entry++) {
+ if (entry->mods.vmods != 0) {
+ XkbVirtualModsToReal(xkb, entry->mods.vmods, &mask);
+ entry->mods.mask = entry->mods.real_mods | mask;
+ /* entry is active if vmods are bound */
+ entry->active = (mask != 0);
+ }
+ else
+ entry->active = 1;
+ }
}
if (changes) {
- int type_ndx;
- type_ndx= type-xkb->map->types;
- if ((type_ndx<0)||(type_ndx>xkb->map->num_types))
- return;
- if (changes->map.changed&XkbKeyTypesMask) {
- int last;
- last= changes->map.first_type+changes->map.num_types-1;
- if (type_ndx<changes->map.first_type) {
- changes->map.first_type= type_ndx;
- changes->map.num_types= (last-type_ndx)+1;
- }
- else if (type_ndx>last) {
- changes->map.num_types= (type_ndx-changes->map.first_type)+1;
- }
- }
- else {
- changes->map.changed|= XkbKeyTypesMask;
- changes->map.first_type= type_ndx;
- changes->map.num_types= 1;
- }
+ int type_ndx;
+
+ type_ndx = type - xkb->map->types;
+ if ((type_ndx < 0) || (type_ndx > xkb->map->num_types))
+ return;
+ if (changes->map.changed & XkbKeyTypesMask) {
+ int last;
+
+ last = changes->map.first_type + changes->map.num_types - 1;
+ if (type_ndx < changes->map.first_type) {
+ changes->map.first_type = type_ndx;
+ changes->map.num_types = (last - type_ndx) + 1;
+ }
+ else if (type_ndx > last) {
+ changes->map.num_types =
+ (type_ndx - changes->map.first_type) + 1;
+ }
+ }
+ else {
+ changes->map.changed |= XkbKeyTypesMask;
+ changes->map.first_type = type_ndx;
+ changes->map.num_types = 1;
+ }
}
return;
}
Bool
-XkbApplyVirtualModChanges(XkbDescPtr xkb,unsigned changed,XkbChangesPtr changes)
+XkbApplyVirtualModChanges(XkbDescPtr xkb,
+ unsigned changed,
+ XkbChangesPtr changes)
{
-register int i;
-unsigned int checkState = 0;
-
- if ((!xkb) || (!xkb->map) || (changed==0))
- return False;
- for (i=0;i<xkb->map->num_types;i++) {
- if (xkb->map->types[i].mods.vmods & changed)
- XkbUpdateKeyTypeVirtualMods(xkb,&xkb->map->types[i],changed,changes);
- }
- if (changed&xkb->ctrls->internal.vmods) {
- unsigned int newMask = 0;
- XkbVirtualModsToReal(xkb,xkb->ctrls->internal.vmods,&newMask);
- newMask|= xkb->ctrls->internal.real_mods;
- if (xkb->ctrls->internal.mask!=newMask) {
- xkb->ctrls->internal.mask= newMask;
- if (changes) {
- changes->ctrls.changed_ctrls|= XkbInternalModsMask;
- checkState= True;
- }
- }
- }
- if (changed&xkb->ctrls->ignore_lock.vmods) {
- unsigned int newMask = 0;
- XkbVirtualModsToReal(xkb,xkb->ctrls->ignore_lock.vmods,&newMask);
- newMask|= xkb->ctrls->ignore_lock.real_mods;
- if (xkb->ctrls->ignore_lock.mask!=newMask) {
- xkb->ctrls->ignore_lock.mask= newMask;
- if (changes) {
- changes->ctrls.changed_ctrls|= XkbIgnoreLockModsMask;
- checkState= True;
- }
- }
- }
- if (xkb->indicators!=NULL) {
- XkbIndicatorMapPtr map;
- map= &xkb->indicators->maps[0];
- for (i=0;i<XkbNumIndicators;i++,map++) {
- if (map->mods.vmods&changed) {
- unsigned int newMask = 0;
- XkbVirtualModsToReal(xkb,map->mods.vmods,&newMask);
- newMask|= map->mods.real_mods;
- if (newMask!=map->mods.mask) {
- map->mods.mask= newMask;
- if (changes) {
- changes->indicators.map_changes|= (1<<i);
- checkState= True;
- }
- }
- }
- }
- }
- if (xkb->compat!=NULL) {
- XkbCompatMapPtr compat;
- compat= xkb->compat;
- for (i=0;i<XkbNumKbdGroups;i++) {
- unsigned int newMask = 0;
- XkbVirtualModsToReal(xkb,compat->groups[i].vmods,&newMask);
- newMask|= compat->groups[i].real_mods;
- if (compat->groups[i].mask!=newMask) {
- compat->groups[i].mask= newMask;
- if (changes) {
- changes->compat.changed_groups|= (1<<i);
- checkState= True;
- }
- }
- }
+ register int i;
+ unsigned int checkState = 0;
+
+ if ((!xkb) || (!xkb->map) || (changed == 0))
+ return False;
+ for (i = 0; i < xkb->map->num_types; i++) {
+ if (xkb->map->types[i].mods.vmods & changed)
+ XkbUpdateKeyTypeVirtualMods(xkb, &xkb->map->types[i], changed,
+ changes);
+ }
+ if (changed & xkb->ctrls->internal.vmods) {
+ unsigned int newMask = 0;
+
+ XkbVirtualModsToReal(xkb, xkb->ctrls->internal.vmods, &newMask);
+ newMask |= xkb->ctrls->internal.real_mods;
+ if (xkb->ctrls->internal.mask != newMask) {
+ xkb->ctrls->internal.mask = newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls |= XkbInternalModsMask;
+ checkState = True;
+ }
+ }
+ }
+ if (changed & xkb->ctrls->ignore_lock.vmods) {
+ unsigned int newMask = 0;
+
+ XkbVirtualModsToReal(xkb, xkb->ctrls->ignore_lock.vmods, &newMask);
+ newMask |= xkb->ctrls->ignore_lock.real_mods;
+ if (xkb->ctrls->ignore_lock.mask != newMask) {
+ xkb->ctrls->ignore_lock.mask = newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls |= XkbIgnoreLockModsMask;
+ checkState = True;
+ }
+ }
+ }
+ if (xkb->indicators != NULL) {
+ XkbIndicatorMapPtr map;
+
+ map = &xkb->indicators->maps[0];
+ for (i = 0; i < XkbNumIndicators; i++, map++) {
+ if (map->mods.vmods & changed) {
+ unsigned int newMask = 0;
+
+ XkbVirtualModsToReal(xkb, map->mods.vmods, &newMask);
+ newMask |= map->mods.real_mods;
+ if (newMask != map->mods.mask) {
+ map->mods.mask = newMask;
+ if (changes) {
+ changes->indicators.map_changes |= (1 << i);
+ checkState = True;
+ }
+ }
+ }
+ }
+ }
+ if (xkb->compat != NULL) {
+ XkbCompatMapPtr compat;
+
+ compat = xkb->compat;
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ unsigned int newMask = 0;
+
+ XkbVirtualModsToReal(xkb, compat->groups[i].vmods, &newMask);
+ newMask |= compat->groups[i].real_mods;
+ if (compat->groups[i].mask != newMask) {
+ compat->groups[i].mask = newMask;
+ if (changes) {
+ changes->compat.changed_groups |= (1 << i);
+ checkState = True;
+ }
+ }
+ }
}
if (xkb->map && xkb->server) {
- int highChange = 0, lowChange = -1;
- for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
- if (XkbKeyHasActions(xkb,i)) {
- register XkbAction *pAct;
- register int n;
-
- pAct= XkbKeyActionsPtr(xkb,i);
- for (n=XkbKeyNumActions(xkb,i);n>0;n--,pAct++) {
- if ((pAct->type!=XkbSA_NoAction)&&
- XkbUpdateActionVirtualMods(xkb,pAct,changed)) {
- if (lowChange<0)
- lowChange= i;
- highChange= i;
- }
- }
- }
- }
- if (changes && (lowChange>0)) { /* something changed */
- if (changes->map.changed&XkbKeyActionsMask) {
- int last;
- if (changes->map.first_key_act<lowChange)
- lowChange= changes->map.first_key_act;
- last= changes->map.first_key_act+changes->map.num_key_acts-1;
- if (last>highChange)
- highChange= last;
- }
- changes->map.changed|= XkbKeyActionsMask;
- changes->map.first_key_act= lowChange;
- changes->map.num_key_acts= (highChange-lowChange)+1;
- }
+ int highChange = 0, lowChange = -1;
+
+ for (i = xkb->min_key_code; i <= xkb->max_key_code; i++) {
+ if (XkbKeyHasActions(xkb, i)) {
+ register XkbAction *pAct;
+ register int n;
+
+ pAct = XkbKeyActionsPtr(xkb, i);
+ for (n = XkbKeyNumActions(xkb, i); n > 0; n--, pAct++) {
+ if ((pAct->type != XkbSA_NoAction) &&
+ XkbUpdateActionVirtualMods(xkb, pAct, changed)) {
+ if (lowChange < 0)
+ lowChange = i;
+ highChange = i;
+ }
+ }
+ }
+ }
+ if (changes && (lowChange > 0)) { /* something changed */
+ if (changes->map.changed & XkbKeyActionsMask) {
+ int last;
+
+ if (changes->map.first_key_act < lowChange)
+ lowChange = changes->map.first_key_act;
+ last =
+ changes->map.first_key_act + changes->map.num_key_acts - 1;
+ if (last > highChange)
+ highChange = last;
+ }
+ changes->map.changed |= XkbKeyActionsMask;
+ changes->map.first_key_act = lowChange;
+ changes->map.num_key_acts = (highChange - lowChange) + 1;
+ }
}
return checkState;
}
diff --git a/nx-X11/lib/X11/XKBNames.c b/nx-X11/lib/X11/XKBNames.c
index c82b59e30..951fd1da8 100644
--- a/nx-X11/lib/X11/XKBNames.c
+++ b/nx-X11/lib/X11/XKBNames.c
@@ -34,234 +34,240 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
static Status
-_XkbReadAtoms( XkbReadBufferPtr buf,
- Atom * atoms,
- int maxAtoms,
- CARD32 present)
+_XkbReadAtoms(XkbReadBufferPtr buf,
+ Atom *atoms,
+ int maxAtoms,
+ CARD32 present)
{
-register int i,bit;
+ register int i, bit;
- for (i=0,bit=1;(i<maxAtoms)&&(present);i++,bit<<=1) {
- if (present&bit) {
- if (!_XkbReadBufferCopy32(buf,(long *)&atoms[i],1))
- return BadLength;
- present&= ~bit;
- }
+ for (i = 0, bit = 1; (i < maxAtoms) && (present); i++, bit <<= 1) {
+ if (present & bit) {
+ if (!_XkbReadBufferCopy32(buf, (long *) &atoms[i], 1))
+ return BadLength;
+ present &= ~bit;
+ }
}
return Success;
}
Status
-_XkbReadGetNamesReply( Display * dpy,
- xkbGetNamesReply * rep,
- XkbDescPtr xkb,
- int * nread_rtrn)
+_XkbReadGetNamesReply(Display *dpy,
+ xkbGetNamesReply *rep,
+ XkbDescPtr xkb,
+ int *nread_rtrn)
{
- int i,len;
- XkbReadBufferRec buf;
- register XkbNamesPtr names;
+ int i, len;
+ XkbReadBufferRec buf;
+ register XkbNamesPtr names;
- if ( xkb->device_spec == XkbUseCoreKbd )
- xkb->device_spec = rep->deviceID;
+ if (xkb->device_spec == XkbUseCoreKbd)
+ xkb->device_spec = rep->deviceID;
- if ((xkb->names==NULL)&&
- (XkbAllocNames(xkb,rep->which,
- rep->nRadioGroups,rep->nKeyAliases)!=Success)) {
- return BadAlloc;
+ if ((xkb->names == NULL) &&
+ (XkbAllocNames(xkb, rep->which,
+ rep->nRadioGroups, rep->nKeyAliases) != Success)) {
+ return BadAlloc;
}
- names= xkb->names;
- if (rep->length==0)
- return Success;
+ names = xkb->names;
+ if (rep->length == 0)
+ return Success;
- if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
- return BadAlloc;
+ if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4))
+ return BadAlloc;
if (nread_rtrn)
- *nread_rtrn= (int)rep->length*4;
-
- if ((rep->which&XkbKeycodesNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->keycodes,1)))
- goto BAILOUT;
- if ((rep->which&XkbGeometryNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->geometry,1)))
- goto BAILOUT;
- if ((rep->which&XkbSymbolsNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->symbols,1)))
- goto BAILOUT;
- if ((rep->which&XkbPhysSymbolsNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->phys_symbols,1)))
- goto BAILOUT;
- if ((rep->which&XkbTypesNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->types,1)))
- goto BAILOUT;
- if ((rep->which&XkbCompatNameMask)&&
- (!_XkbReadBufferCopy32(&buf,(long *)&names->compat,1)))
- goto BAILOUT;
-
- if ( rep->which & XkbKeyTypeNamesMask ) {
- XkbClientMapPtr map= xkb->map;
- XkbKeyTypePtr type;
-
- len= rep->nTypes*4;
- if (map!=NULL) {
- type= map->types;
- for (i=0;(i<map->num_types)&&(i<rep->nTypes);i++,type++) {
- if (!_XkbReadBufferCopy32(&buf,(long *)&type->name,1))
- goto BAILOUT;
- len-= 4;
- }
- }
- if ((len>0)&&(!_XkbSkipReadBufferData(&buf,len)))
- goto BAILOUT;
- }
- if ( rep->which&XkbKTLevelNamesMask ) {
- CARD8 *nLevels;
- XkbClientMapPtr map= xkb->map;
- XkbKeyTypePtr type;
-
- nLevels=(CARD8*)_XkbGetReadBufferPtr(&buf,XkbPaddedSize(rep->nTypes));
- if (nLevels==NULL)
- goto BAILOUT;
- if (map!=NULL) {
- type= map->types;
- for (i=0;i<(int)rep->nTypes;i++,type++) {
- if (i>=map->num_types) {
- if (!_XkbSkipReadBufferData(&buf,nLevels[i]*4))
- goto BAILOUT;
- continue;
- }
- if ((nLevels[i]>0)&&(nLevels[i]!=type->num_levels)) {
- goto BAILOUT;
- }
- if (type->level_names!=NULL)
- Xfree(type->level_names);
- if (nLevels[i]==0) {
- type->level_names= NULL;
- continue;
- }
- type->level_names= _XkbTypedCalloc(nLevels[i],Atom);
- if (type->level_names!=NULL) {
- if (!_XkbReadBufferCopy32(&buf,(long *)type->level_names,
- nLevels[i]))
- goto BAILOUT;
- }
- else {
- _XkbSkipReadBufferData(&buf,nLevels[i]*4);
- }
- }
- }
- else {
- for (i=0;i<(int)rep->nTypes;i++) {
- _XkbSkipReadBufferData(&buf,nLevels[i]*4);
- }
- }
+ *nread_rtrn = (int) rep->length * 4;
+
+ if ((rep->which & XkbKeycodesNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->keycodes, 1)))
+ goto BAILOUT;
+ if ((rep->which & XkbGeometryNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->geometry, 1)))
+ goto BAILOUT;
+ if ((rep->which & XkbSymbolsNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->symbols, 1)))
+ goto BAILOUT;
+ if ((rep->which & XkbPhysSymbolsNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->phys_symbols, 1)))
+ goto BAILOUT;
+ if ((rep->which & XkbTypesNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->types, 1)))
+ goto BAILOUT;
+ if ((rep->which & XkbCompatNameMask) &&
+ (!_XkbReadBufferCopy32(&buf, (long *) &names->compat, 1)))
+ goto BAILOUT;
+
+ if (rep->which & XkbKeyTypeNamesMask) {
+ XkbClientMapPtr map = xkb->map;
+ XkbKeyTypePtr type;
+
+ len = rep->nTypes * 4;
+ if (map != NULL) {
+ type = map->types;
+ for (i = 0; (i < map->num_types) && (i < rep->nTypes); i++, type++) {
+ if (!_XkbReadBufferCopy32(&buf, (long *) &type->name, 1))
+ goto BAILOUT;
+ len -= 4;
+ }
+ }
+ if ((len > 0) && (!_XkbSkipReadBufferData(&buf, len)))
+ goto BAILOUT;
+ }
+ if (rep->which & XkbKTLevelNamesMask) {
+ CARD8 *nLevels;
+ XkbClientMapPtr map = xkb->map;
+
+ nLevels =
+ (CARD8 *) _XkbGetReadBufferPtr(&buf, XkbPaddedSize(rep->nTypes));
+ if (nLevels == NULL)
+ goto BAILOUT;
+ if (map != NULL) {
+ XkbKeyTypePtr type = map->types;
+
+ for (i = 0; i < (int) rep->nTypes; i++, type++) {
+ if (i >= map->num_types) {
+ if (!_XkbSkipReadBufferData(&buf, nLevels[i] * 4))
+ goto BAILOUT;
+ continue;
+ }
+ if ((nLevels[i] > 0) && (nLevels[i] != type->num_levels)) {
+ goto BAILOUT;
+ }
+
+ Xfree(type->level_names);
+ if (nLevels[i] == 0) {
+ type->level_names = NULL;
+ continue;
+ }
+ type->level_names = _XkbTypedCalloc(nLevels[i], Atom);
+ if (type->level_names != NULL) {
+ if (!_XkbReadBufferCopy32(&buf, (long *) type->level_names,
+ nLevels[i]))
+ goto BAILOUT;
+ }
+ else {
+ _XkbSkipReadBufferData(&buf, nLevels[i] * 4);
+ }
+ }
+ }
+ else {
+ for (i = 0; i < (int) rep->nTypes; i++) {
+ _XkbSkipReadBufferData(&buf, nLevels[i] * 4);
+ }
+ }
}
if (rep->which & XkbIndicatorNamesMask) {
- if (_XkbReadAtoms(&buf,names->indicators,XkbNumIndicators,
- rep->indicators)!=Success)
- goto BAILOUT;
- }
- if ( rep->which&XkbVirtualModNamesMask ) {
- if (_XkbReadAtoms(&buf,names->vmods,XkbNumVirtualMods,
- (CARD32)rep->virtualMods)!=Success)
- goto BAILOUT;
- }
- if ( rep->which&XkbGroupNamesMask ) {
- if (_XkbReadAtoms(&buf,names->groups,XkbNumKbdGroups,
- (CARD32)rep->groupNames)!=Success)
- goto BAILOUT;
- }
- if ( rep->which&XkbKeyNamesMask ) {
- if (names->keys==NULL) {
- int nKeys;
- if (xkb->max_key_code==0) {
- xkb->min_key_code= rep->minKeyCode;
- xkb->max_key_code= rep->maxKeyCode;
- }
- nKeys= xkb->max_key_code+1;
- names->keys= _XkbTypedCalloc(nKeys,XkbKeyNameRec);
- }
- else if ( ((int)rep->firstKey + rep->nKeys) > xkb->max_key_code + 1)
- goto BAILOUT;
- if (names->keys!=NULL) {
- if (!_XkbCopyFromReadBuffer(&buf,
- (char *)&names->keys[rep->firstKey],
- rep->nKeys*XkbKeyNameLength))
- goto BAILOUT;
- }
- else _XkbSkipReadBufferData(&buf,rep->nKeys*XkbKeyNameLength);
- }
- if ( rep->which&XkbKeyAliasesMask && (rep->nKeyAliases>0) ) {
- if (XkbAllocNames(xkb,XkbKeyAliasesMask,0,rep->nKeyAliases)!=Success)
- goto BAILOUT;
- if (!_XkbCopyFromReadBuffer(&buf,(char *)names->key_aliases,
- rep->nKeyAliases*XkbKeyNameLength*2))
- goto BAILOUT;
- }
- if ( rep->which&XkbRGNamesMask ) {
- if (rep->nRadioGroups>0) {
- Atom *rgNames;
-
- if (names->radio_groups==NULL)
- names->radio_groups = _XkbTypedCalloc(rep->nRadioGroups,Atom);
- else if (names->num_rg<rep->nRadioGroups) {
- names->radio_groups = _XkbTypedRealloc(names->radio_groups,
- rep->nRadioGroups,
- Atom);
- }
- rgNames= names->radio_groups;
- if (!rgNames) {
- goto BAILOUT;
- }
- if (!_XkbReadBufferCopy32(&buf,(long *)rgNames,rep->nRadioGroups))
- goto BAILOUT;
- names->num_rg= rep->nRadioGroups;
- }
- else if (names->num_rg>0) {
- names->num_rg= 0;
- Xfree(names->radio_groups);
- }
- }
- len= _XkbFreeReadBuffer(&buf);
- if (len!=0) return BadLength;
- else return Success;
-BAILOUT:
+ if (_XkbReadAtoms(&buf, names->indicators, XkbNumIndicators,
+ rep->indicators) != Success)
+ goto BAILOUT;
+ }
+ if (rep->which & XkbVirtualModNamesMask) {
+ if (_XkbReadAtoms(&buf, names->vmods, XkbNumVirtualMods,
+ (CARD32) rep->virtualMods) != Success)
+ goto BAILOUT;
+ }
+ if (rep->which & XkbGroupNamesMask) {
+ if (_XkbReadAtoms(&buf, names->groups, XkbNumKbdGroups,
+ (CARD32) rep->groupNames) != Success)
+ goto BAILOUT;
+ }
+ if (rep->which & XkbKeyNamesMask) {
+ if (names->keys == NULL) {
+ int nKeys;
+
+ if (xkb->max_key_code == 0) {
+ xkb->min_key_code = rep->minKeyCode;
+ xkb->max_key_code = rep->maxKeyCode;
+ }
+ nKeys = xkb->max_key_code + 1;
+ names->keys = _XkbTypedCalloc(nKeys, XkbKeyNameRec);
+ }
+ if (((int) rep->firstKey + rep->nKeys) > xkb->max_key_code + 1)
+ goto BAILOUT;
+ if (names->keys != NULL) {
+ if (!_XkbCopyFromReadBuffer(&buf,
+ (char *) &names->keys[rep->firstKey],
+ rep->nKeys * XkbKeyNameLength))
+ goto BAILOUT;
+ }
+ else
+ _XkbSkipReadBufferData(&buf, rep->nKeys * XkbKeyNameLength);
+ }
+ if (rep->which & XkbKeyAliasesMask && (rep->nKeyAliases > 0)) {
+ if (XkbAllocNames(xkb, XkbKeyAliasesMask, 0, rep->nKeyAliases) !=
+ Success)
+ goto BAILOUT;
+ if (!_XkbCopyFromReadBuffer(&buf, (char *) names->key_aliases,
+ rep->nKeyAliases * XkbKeyNameLength * 2))
+ goto BAILOUT;
+ }
+ if (rep->which & XkbRGNamesMask) {
+ if (rep->nRadioGroups > 0) {
+ Atom *rgNames;
+
+ if (names->radio_groups == NULL)
+ names->radio_groups = _XkbTypedCalloc(rep->nRadioGroups, Atom);
+ else if (names->num_rg < rep->nRadioGroups) {
+ names->radio_groups = _XkbTypedRealloc(names->radio_groups,
+ rep->nRadioGroups, Atom);
+ }
+ rgNames = names->radio_groups;
+ if (!rgNames) {
+ goto BAILOUT;
+ }
+ if (!_XkbReadBufferCopy32
+ (&buf, (long *) rgNames, rep->nRadioGroups))
+ goto BAILOUT;
+ names->num_rg = rep->nRadioGroups;
+ }
+ else if (names->num_rg > 0) {
+ names->num_rg = 0;
+ Xfree(names->radio_groups);
+ }
+ }
+ len = _XkbFreeReadBuffer(&buf);
+ if (len != 0)
+ return BadLength;
+ else
+ return Success;
+ BAILOUT:
_XkbFreeReadBuffer(&buf);
return BadLength;
}
Status
-XkbGetNames(Display *dpy,unsigned which,XkbDescPtr xkb)
+XkbGetNames(Display *dpy, unsigned which, XkbDescPtr xkb)
{
register xkbGetNamesReq *req;
- xkbGetNamesReply rep;
- Status status;
+ xkbGetNamesReply rep;
+ Status status;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
if (!xkb->names) {
- xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
- if (!xkb->names) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadAlloc;
- }
+ xkb->names = _XkbTypedCalloc(1, XkbNamesRec);
+ if (!xkb->names) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
}
GetReq(kbGetNames, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetNames;
req->deviceSpec = xkb->device_spec;
req->which = which;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadImplementation;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
}
- status = _XkbReadGetNamesReply(dpy,&rep,xkb,NULL);
+ status = _XkbReadGetNamesReply(dpy, &rep, xkb, NULL);
UnlockDisplay(dpy);
SyncHandle();
return status;
@@ -270,12 +276,12 @@ XkbGetNames(Display *dpy,unsigned which,XkbDescPtr xkb)
/***====================================================================***/
static int
-_XkbCountBits(int nBitsMax,unsigned long mask)
+_XkbCountBits(int nBitsMax, unsigned long mask)
{
-register unsigned long y, nBits;
+ register unsigned long y, nBits;
- y = (mask >> 1) &033333333333;
- y = mask - y - ((y >>1) & 033333333333);
+ y = (mask >> 1) & 033333333333;
+ y = mask - y - ((y >> 1) & 033333333333);
nBits = ((unsigned int) (((y + (y >> 3)) & 030707070707) % 077));
/* nBitsMax really means max+1 */
@@ -283,85 +289,87 @@ register unsigned long y, nBits;
}
static CARD32
-_XkbCountAtoms(Atom *atoms,int maxAtoms,int *count)
+_XkbCountAtoms(Atom *atoms, int maxAtoms, int *count)
{
-register unsigned int i,bit,nAtoms;
-register CARD32 atomsPresent;
+ register unsigned int i, bit, nAtoms;
+ register CARD32 atomsPresent;
- for (i=nAtoms=atomsPresent=0,bit=1;i<maxAtoms;i++,bit<<=1) {
- if (atoms[i]!=None) {
- atomsPresent|= bit;
+ for (i = nAtoms = atomsPresent = 0, bit = 1; i < maxAtoms; i++, bit <<= 1) {
+ if (atoms[i] != None) {
+ atomsPresent |= bit;
nAtoms++;
}
}
if (count)
- *count= nAtoms;
+ *count = nAtoms;
return atomsPresent;
}
static void
-_XkbCopyAtoms(Display *dpy,Atom *atoms,CARD32 mask,int maxAtoms)
+_XkbCopyAtoms(Display *dpy, Atom *atoms, CARD32 mask, int maxAtoms)
{
-register unsigned int i,bit;
+ register unsigned int i, bit;
- for (i=0,bit=1;i<maxAtoms;i++,bit<<=1) {
- if (mask&bit)
- Data32(dpy,&atoms[i],4);
+ for (i = 0, bit = 1; i < maxAtoms; i++, bit <<= 1) {
+ if (mask & bit)
+ Data32(dpy, &atoms[i], 4);
}
return;
}
Bool
-XkbSetNames( Display * dpy,
- unsigned int which,
- unsigned int firstType,
- unsigned int nTypes,
- XkbDescPtr xkb)
+XkbSetNames(Display *dpy,
+ unsigned int which,
+ unsigned int firstType,
+ unsigned int nTypes,
+ XkbDescPtr xkb)
{
register xkbSetNamesReq *req;
- int nLvlNames = 0;
+ int nLvlNames = 0;
XkbInfoPtr xkbi;
XkbNamesPtr names;
- unsigned firstLvlType,nLvlTypes;
- int nVMods,nLEDs,nRG,nKA,nGroups;
- int nKeys=0,firstKey=0,nAtoms;
- CARD32 leds,vmods,groups;
+ unsigned firstLvlType, nLvlTypes;
+ int nVMods, nLEDs, nRG, nKA, nGroups;
+ int nKeys = 0, firstKey = 0, nAtoms;
+ CARD32 leds, vmods, groups;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!xkb)||(!xkb->names))
- return False;
- firstLvlType= firstType;
- nLvlTypes= nTypes;
- if (nTypes<1)
- which&= ~(XkbKTLevelNamesMask|XkbKeyTypeNamesMask);
- else if (firstType<=XkbLastRequiredType) {
- int adjust;
- adjust= XkbLastRequiredType-firstType+1;
- firstType+= adjust;
- nTypes-= adjust;
- if (nTypes<1)
- which&= ~XkbKeyTypeNamesMask;
- }
- names= xkb->names;
- if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
- register int i;
- XkbKeyTypePtr type;
- if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
- (firstType+nTypes>xkb->map->num_types)||
- (firstLvlType+nLvlTypes>xkb->map->num_types))
- return False;
- if (which&XkbKTLevelNamesMask) {
- type= &xkb->map->types[firstLvlType];
- for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
- if (type->level_names!=NULL)
- nLvlNames+= type->num_levels;
- }
- }
- }
-
- nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!xkb) || (!xkb->names))
+ return False;
+ firstLvlType = firstType;
+ nLvlTypes = nTypes;
+ if (nTypes < 1)
+ which &= ~(XkbKTLevelNamesMask | XkbKeyTypeNamesMask);
+ else if (firstType <= XkbLastRequiredType) {
+ int adjust;
+
+ adjust = XkbLastRequiredType - firstType + 1;
+ firstType += adjust;
+ nTypes -= adjust;
+ if (nTypes < 1)
+ which &= ~XkbKeyTypeNamesMask;
+ }
+ names = xkb->names;
+ if (which & (XkbKTLevelNamesMask | XkbKeyTypeNamesMask)) {
+ register int i;
+ XkbKeyTypePtr type;
+
+ if ((xkb->map == NULL) || (xkb->map->types == NULL) || (nTypes == 0) ||
+ (firstType + nTypes > xkb->map->num_types) ||
+ (firstLvlType + nLvlTypes > xkb->map->num_types))
+ return False;
+ if (which & XkbKTLevelNamesMask) {
+ type = &xkb->map->types[firstLvlType];
+ for (i = nLvlNames = 0; i < nLvlTypes; i++, type++) {
+ if (type->level_names != NULL)
+ nLvlNames += type->num_levels;
+ }
+ }
+ }
+
+ nVMods = nLEDs = nRG = nKA = nAtoms = nGroups = 0;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetNames, req);
@@ -371,138 +379,149 @@ XkbSetNames( Display * dpy,
req->firstType = firstType;
req->nTypes = nTypes;
req->firstKey = xkb->min_key_code;
- req->nKeys = xkb->max_key_code-xkb->min_key_code+1;
-
- if (which&XkbKeycodesNameMask)
- nAtoms++;
- if (which&XkbGeometryNameMask)
- nAtoms++;
- if (which&XkbSymbolsNameMask)
- nAtoms++;
- if (which&XkbPhysSymbolsNameMask)
- nAtoms++;
- if (which&XkbTypesNameMask)
- nAtoms++;
- if (which&XkbCompatNameMask)
- nAtoms++;
- if (which&XkbKeyTypeNamesMask)
- nAtoms+= nTypes;
- if (which&XkbKTLevelNamesMask) {
- req->firstKTLevel= firstLvlType;
- req->nKTLevels= nLvlTypes;
- req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
- nAtoms+= nLvlNames;
- }
- else req->firstKTLevel= req->nKTLevels= 0;
-
- if (which&XkbIndicatorNamesMask) {
- req->indicators= leds=
- _XkbCountAtoms(names->indicators,XkbNumIndicators,&nLEDs);
- if (nLEDs>0)
- nAtoms+= nLEDs;
- else which&= ~XkbIndicatorNamesMask;
- }
- else req->indicators= leds= 0;
-
- if (which&XkbVirtualModNamesMask) {
- vmods= req->virtualMods= (CARD16)
- _XkbCountAtoms(names->vmods,XkbNumVirtualMods,&nVMods);
- if (nVMods>0)
- nAtoms+= nVMods;
- else which&= ~XkbVirtualModNamesMask;
- }
- else vmods= req->virtualMods= 0;
-
- if (which&XkbGroupNamesMask) {
- groups= req->groupNames= (CARD8)
- _XkbCountAtoms(names->groups,XkbNumKbdGroups,&nGroups);
- if (nGroups>0)
- nAtoms+= nGroups;
- else which&= ~XkbGroupNamesMask;
- }
- else groups= req->groupNames= 0;
-
- if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
- firstKey= req->firstKey;
- nKeys= req->nKeys;
- nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
- }
- else which&= ~XkbKeyNamesMask;
-
- if (which&XkbKeyAliasesMask) {
- nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
- if (nKA>0) {
- req->nKeyAliases= nKA;
- nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
- }
- else {
- which&= ~XkbKeyAliasesMask;
- req->nKeyAliases = 0;
- }
- }
- else req->nKeyAliases= 0;
-
- if (which&XkbRGNamesMask) {
- nRG= names->num_rg;
- if (nRG>0)
- nAtoms+= nRG;
- else which&= ~XkbRGNamesMask;
- }
-
- req->which= which;
- req->nRadioGroups= nRG;
- req->length+= (nAtoms*4)/4;
-
- if (which&XkbKeycodesNameMask)
- Data32(dpy,(long *)&names->keycodes,4);
- if (which&XkbGeometryNameMask)
- Data32(dpy,(long *)&names->geometry,4);
- if (which&XkbSymbolsNameMask)
- Data32(dpy,(long *)&names->symbols,4);
- if (which&XkbPhysSymbolsNameMask)
- Data32(dpy,(long *)&names->phys_symbols,4);
- if (which&XkbTypesNameMask)
- Data32(dpy,(long *)&names->types,4);
- if (which&XkbCompatNameMask)
- Data32(dpy,(long *)&names->compat,4);
- if (which&XkbKeyTypeNamesMask) {
- register int i;
- register XkbKeyTypePtr type;
- type= &xkb->map->types[firstType];
- for (i=0;i<nTypes;i++,type++) {
- Data32(dpy,(long *)&type->name,4);
- }
- }
- if (which&XkbKTLevelNamesMask) {
- XkbKeyTypePtr type;
- int i;
- char *tmp;
-
- BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
- type = &xkb->map->types[firstLvlType];
- for (i=0;i<nLvlTypes;i++,type++) {
- *tmp++ = type->num_levels;
- }
- type = &xkb->map->types[firstLvlType];
- for (i=0;i<nLvlTypes;i++,type++) {
- if (type->level_names!=NULL)
- Data32(dpy,(long *)type->level_names,type->num_levels*4);
- }
- }
- if (which&XkbIndicatorNamesMask)
- _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
- if (which&XkbVirtualModNamesMask)
- _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
- if (which&XkbGroupNamesMask)
- _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
- if (which&XkbKeyNamesMask) {
- Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
- }
- if (which&XkbKeyAliasesMask) {
- Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
- }
- if (which&XkbRGNamesMask) {
- Data32(dpy,(long *)names->radio_groups,nRG*4);
+ req->nKeys = xkb->max_key_code - xkb->min_key_code + 1;
+
+ if (which & XkbKeycodesNameMask)
+ nAtoms++;
+ if (which & XkbGeometryNameMask)
+ nAtoms++;
+ if (which & XkbSymbolsNameMask)
+ nAtoms++;
+ if (which & XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which & XkbTypesNameMask)
+ nAtoms++;
+ if (which & XkbCompatNameMask)
+ nAtoms++;
+ if (which & XkbKeyTypeNamesMask)
+ nAtoms += nTypes;
+ if (which & XkbKTLevelNamesMask) {
+ req->firstKTLevel = firstLvlType;
+ req->nKTLevels = nLvlTypes;
+ req->length += XkbPaddedSize(nLvlTypes) / 4; /* room for group widths */
+ nAtoms += nLvlNames;
+ }
+ else
+ req->firstKTLevel = req->nKTLevels = 0;
+
+ if (which & XkbIndicatorNamesMask) {
+ req->indicators = leds =
+ _XkbCountAtoms(names->indicators, XkbNumIndicators, &nLEDs);
+ if (nLEDs > 0)
+ nAtoms += nLEDs;
+ else
+ which &= ~XkbIndicatorNamesMask;
+ }
+ else
+ req->indicators = leds = 0;
+
+ if (which & XkbVirtualModNamesMask) {
+ vmods = req->virtualMods = (CARD16)
+ _XkbCountAtoms(names->vmods, XkbNumVirtualMods, &nVMods);
+ if (nVMods > 0)
+ nAtoms += nVMods;
+ else
+ which &= ~XkbVirtualModNamesMask;
+ }
+ else
+ vmods = req->virtualMods = 0;
+
+ if (which & XkbGroupNamesMask) {
+ groups = req->groupNames = (CARD8)
+ _XkbCountAtoms(names->groups, XkbNumKbdGroups, &nGroups);
+ if (nGroups > 0)
+ nAtoms += nGroups;
+ else
+ which &= ~XkbGroupNamesMask;
+ }
+ else
+ groups = req->groupNames = 0;
+
+ if ((which & XkbKeyNamesMask) && (names->keys != NULL)) {
+ firstKey = req->firstKey;
+ nKeys = req->nKeys;
+ nAtoms += nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else
+ which &= ~XkbKeyNamesMask;
+
+ if (which & XkbKeyAliasesMask) {
+ nKA = ((names->key_aliases != NULL) ? names->num_key_aliases : 0);
+ if (nKA > 0) {
+ req->nKeyAliases = nKA;
+ nAtoms += nKA * 2; /* not atoms, but 8 bytes on the wire */
+ }
+ else {
+ which &= ~XkbKeyAliasesMask;
+ req->nKeyAliases = 0;
+ }
+ }
+ else
+ req->nKeyAliases = 0;
+
+ if (which & XkbRGNamesMask) {
+ nRG = names->num_rg;
+ if (nRG > 0)
+ nAtoms += nRG;
+ else
+ which &= ~XkbRGNamesMask;
+ }
+
+ req->which = which;
+ req->nRadioGroups = nRG;
+ req->length += (nAtoms * 4) / 4;
+
+ if (which & XkbKeycodesNameMask)
+ Data32(dpy, (long *) &names->keycodes, 4);
+ if (which & XkbGeometryNameMask)
+ Data32(dpy, (long *) &names->geometry, 4);
+ if (which & XkbSymbolsNameMask)
+ Data32(dpy, (long *) &names->symbols, 4);
+ if (which & XkbPhysSymbolsNameMask)
+ Data32(dpy, (long *) &names->phys_symbols, 4);
+ if (which & XkbTypesNameMask)
+ Data32(dpy, (long *) &names->types, 4);
+ if (which & XkbCompatNameMask)
+ Data32(dpy, (long *) &names->compat, 4);
+ if (which & XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+
+ type = &xkb->map->types[firstType];
+ for (i = 0; i < nTypes; i++, type++) {
+ Data32(dpy, (long *) &type->name, 4);
+ }
+ }
+ if (which & XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *, tmp, XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i = 0; i < nLvlTypes; i++, type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i = 0; i < nLvlTypes; i++, type++) {
+ if (type->level_names != NULL)
+ Data32(dpy, (long *) type->level_names, type->num_levels * 4);
+ }
+ }
+ if (which & XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy, names->indicators, leds, XkbNumIndicators);
+ if (which & XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy, names->vmods, vmods, XkbNumVirtualMods);
+ if (which & XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy, names->groups, groups, XkbNumKbdGroups);
+ if (which & XkbKeyNamesMask) {
+ Data(dpy, (char *) &names->keys[firstKey], nKeys * XkbKeyNameLength);
+ }
+ if (which & XkbKeyAliasesMask) {
+ Data(dpy, (char *) names->key_aliases, nKA * XkbKeyNameLength * 2);
+ }
+ if (which & XkbRGNamesMask) {
+ Data32(dpy, (long *) names->radio_groups, nRG * 4);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -510,90 +529,94 @@ XkbSetNames( Display * dpy,
}
Bool
-XkbChangeNames(Display *dpy,XkbDescPtr xkb,XkbNameChangesPtr changes)
+XkbChangeNames(Display *dpy, XkbDescPtr xkb, XkbNameChangesPtr changes)
{
register xkbSetNamesReq *req;
- int nLvlNames = 0;
+ int nLvlNames = 0;
XkbInfoPtr xkbi;
XkbNamesPtr names;
- unsigned which,firstType,nTypes;
- unsigned firstLvlType,nLvlTypes;
- int nVMods,nLEDs,nRG,nKA,nGroups;
- int nKeys=0,firstKey=0,nAtoms;
- CARD32 leds=0,vmods=0,groups=0;
+ unsigned which, firstType, nTypes;
+ unsigned firstLvlType, nLvlTypes;
+ int nVMods, nLEDs, nRG, nKA, nGroups;
+ int nKeys = 0, firstKey = 0, nAtoms;
+ CARD32 leds = 0, vmods = 0, groups = 0;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!xkb)||(!xkb->names)||(!changes))
- return False;
- which= changes->changed;
- firstType= changes->first_type;
- nTypes= changes->num_types;
- firstLvlType= changes->first_lvl;;
- nLvlTypes= changes->num_lvls;
- if (which&XkbKeyTypeNamesMask) {
- if (nTypes<1)
- which&= ~XkbKeyTypeNamesMask;
- else if (firstType<=XkbLastRequiredType) {
- int adjust;
- adjust= XkbLastRequiredType-firstType+1;
- firstType+= adjust;
- nTypes-= adjust;
- if (nTypes<1)
- which&= ~XkbKeyTypeNamesMask;
- }
- }
- else firstType= nTypes= 0;
-
- if (which&XkbKTLevelNamesMask) {
- if (nLvlTypes<1)
- which&= ~XkbKTLevelNamesMask;
- }
- else firstLvlType= nLvlTypes= 0;
-
- names= xkb->names;
- if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
- register int i;
- XkbKeyTypePtr type;
- if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
- (firstType+nTypes>xkb->map->num_types)||
- (firstLvlType+nLvlTypes>xkb->map->num_types))
- return False;
- if (which&XkbKTLevelNamesMask) {
- type= &xkb->map->types[firstLvlType];
- for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
- if (type->level_names!=NULL)
- nLvlNames+= type->num_levels;
- }
- }
- }
-
- if (changes->num_keys<1)
- which&= ~XkbKeyNamesMask;
- if ((which&XkbKeyNamesMask)==0)
- changes->first_key= changes->num_keys= 0;
- else if ((changes->first_key<xkb->min_key_code)||
- (changes->first_key+changes->num_keys>xkb->max_key_code)) {
- return False;
- }
-
- if ((which&XkbVirtualModNamesMask)==0)
- changes->changed_vmods= 0;
- else if (changes->changed_vmods==0)
- which&= ~XkbVirtualModNamesMask;
-
- if ((which&XkbIndicatorNamesMask)==0)
- changes->changed_indicators= 0;
- else if (changes->changed_indicators==0)
- which&= ~XkbIndicatorNamesMask;
-
- if ((which&XkbGroupNamesMask)==0)
- changes->changed_groups= 0;
- else if (changes->changed_groups==0)
- which&= ~XkbGroupNamesMask;
-
- nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!xkb) || (!xkb->names) || (!changes))
+ return False;
+ which = changes->changed;
+ firstType = changes->first_type;
+ nTypes = changes->num_types;
+ firstLvlType = changes->first_lvl;
+ nLvlTypes = changes->num_lvls;
+ if (which & XkbKeyTypeNamesMask) {
+ if (nTypes < 1)
+ which &= ~XkbKeyTypeNamesMask;
+ else if (firstType <= XkbLastRequiredType) {
+ int adjust;
+
+ adjust = XkbLastRequiredType - firstType + 1;
+ firstType += adjust;
+ nTypes -= adjust;
+ if (nTypes < 1)
+ which &= ~XkbKeyTypeNamesMask;
+ }
+ }
+ else
+ firstType = nTypes = 0;
+
+ if (which & XkbKTLevelNamesMask) {
+ if (nLvlTypes < 1)
+ which &= ~XkbKTLevelNamesMask;
+ }
+ else
+ firstLvlType = nLvlTypes = 0;
+
+ names = xkb->names;
+ if (which & (XkbKTLevelNamesMask | XkbKeyTypeNamesMask)) {
+ register int i;
+
+ if ((xkb->map == NULL) || (xkb->map->types == NULL) || (nTypes == 0) ||
+ (firstType + nTypes > xkb->map->num_types) ||
+ (firstLvlType + nLvlTypes > xkb->map->num_types))
+ return False;
+ if (which & XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type = &xkb->map->types[firstLvlType];
+
+ for (i = nLvlNames = 0; i < nLvlTypes; i++, type++) {
+ if (type->level_names != NULL)
+ nLvlNames += type->num_levels;
+ }
+ }
+ }
+
+ if (changes->num_keys < 1)
+ which &= ~XkbKeyNamesMask;
+ if ((which & XkbKeyNamesMask) == 0)
+ changes->first_key = changes->num_keys = 0;
+ else if ((changes->first_key < xkb->min_key_code) ||
+ (changes->first_key + changes->num_keys > xkb->max_key_code)) {
+ return False;
+ }
+
+ if ((which & XkbVirtualModNamesMask) == 0)
+ changes->changed_vmods = 0;
+ else if (changes->changed_vmods == 0)
+ which &= ~XkbVirtualModNamesMask;
+
+ if ((which & XkbIndicatorNamesMask) == 0)
+ changes->changed_indicators = 0;
+ else if (changes->changed_indicators == 0)
+ which &= ~XkbIndicatorNamesMask;
+
+ if ((which & XkbGroupNamesMask) == 0)
+ changes->changed_groups = 0;
+ else if (changes->changed_groups == 0)
+ which &= ~XkbGroupNamesMask;
+
+ nVMods = nLEDs = nRG = nKA = nAtoms = nGroups = 0;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetNames, req);
@@ -605,132 +628,143 @@ XkbChangeNames(Display *dpy,XkbDescPtr xkb,XkbNameChangesPtr changes)
req->firstKey = changes->first_key;
req->nKeys = changes->num_keys;
- if (which&XkbKeycodesNameMask)
- nAtoms++;
- if (which&XkbGeometryNameMask)
- nAtoms++;
- if (which&XkbSymbolsNameMask)
- nAtoms++;
- if (which&XkbPhysSymbolsNameMask)
- nAtoms++;
- if (which&XkbTypesNameMask)
- nAtoms++;
- if (which&XkbCompatNameMask)
- nAtoms++;
- if (which&XkbKeyTypeNamesMask)
- nAtoms+= nTypes;
- if (which&XkbKTLevelNamesMask) {
- req->firstKTLevel= firstLvlType;
- req->nKTLevels= nLvlTypes;
- req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
- nAtoms+= nLvlNames;
- }
- else req->firstKTLevel= req->nKTLevels= 0;
-
- if (which&XkbIndicatorNamesMask) {
- leds= req->indicators= (CARD32)changes->changed_indicators;
- nLEDs= _XkbCountBits(XkbNumIndicators,changes->changed_indicators);
- if (nLEDs>0)
- nAtoms+= nLEDs;
- else which&= ~XkbIndicatorNamesMask;
- }
- else req->indicators= 0;
-
- if (which&XkbVirtualModNamesMask) {
- vmods= req->virtualMods= changes->changed_vmods;
- nVMods= _XkbCountBits(XkbNumVirtualMods,
- (unsigned long)changes->changed_vmods);
- if (nVMods>0)
- nAtoms+= nVMods;
- else which&= ~XkbVirtualModNamesMask;
- }
- else req->virtualMods= 0;
-
- if (which&XkbGroupNamesMask) {
- groups= req->groupNames= changes->changed_groups;
- nGroups= _XkbCountBits(XkbNumKbdGroups,
- (unsigned long)changes->changed_groups);
- if (nGroups>0)
- nAtoms+= nGroups;
- else which&= ~XkbGroupNamesMask;
- }
- else req->groupNames= 0;
-
- if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
- firstKey= req->firstKey;
- nKeys= req->nKeys;
- nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
- }
- else which&= ~XkbKeyNamesMask;
-
- if (which&XkbKeyAliasesMask) {
- nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
- if (nKA>0)
- nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
- else which&= ~XkbKeyAliasesMask;
- }
-
- if (which&XkbRGNamesMask) {
- nRG= names->num_rg;
- if (nRG>0)
- nAtoms+= nRG;
- else which&= ~XkbRGNamesMask;
- }
-
- req->which= which;
- req->nRadioGroups= nRG;
- req->length+= (nAtoms*4)/4;
-
- if (which&XkbKeycodesNameMask)
- Data32(dpy,(long *)&names->keycodes,4);
- if (which&XkbGeometryNameMask)
- Data32(dpy,(long *)&names->geometry,4);
- if (which&XkbSymbolsNameMask)
- Data32(dpy,(long *)&names->symbols,4);
- if (which&XkbPhysSymbolsNameMask)
- Data32(dpy,(long *)&names->phys_symbols,4);
- if (which&XkbTypesNameMask)
- Data32(dpy,(long *)&names->types,4);
- if (which&XkbCompatNameMask)
- Data32(dpy,(long *)&names->compat,4);
- if (which&XkbKeyTypeNamesMask) {
- register int i;
- register XkbKeyTypePtr type;
- type= &xkb->map->types[firstType];
- for (i=0;i<nTypes;i++,type++) {
- Data32(dpy,(long *)&type->name,4);
- }
- }
- if (which&XkbKTLevelNamesMask) {
- XkbKeyTypePtr type;
- int i;
- char *tmp;
-
- BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
- type = &xkb->map->types[firstLvlType];
- for (i=0;i<nLvlTypes;i++,type++) {
- *tmp++ = type->num_levels;
- }
- type = &xkb->map->types[firstLvlType];
- for (i=0;i<nLvlTypes;i++,type++) {
- if (type->level_names!=NULL)
- Data32(dpy,(long *)type->level_names,type->num_levels*4);
- }
- }
- if (which&XkbIndicatorNamesMask)
- _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
- if (which&XkbVirtualModNamesMask)
- _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
- if (which&XkbGroupNamesMask)
- _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
- if (which&XkbKeyNamesMask) {
- Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
- }
- if (which&XkbKeyAliasesMask) {
- Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
- }
- if (which&XkbRGNamesMask) {
- Data32(dpy,(long *)names->radio_groups,nRG*4);
+ if (which & XkbKeycodesNameMask)
+ nAtoms++;
+ if (which & XkbGeometryNameMask)
+ nAtoms++;
+ if (which & XkbSymbolsNameMask)
+ nAtoms++;
+ if (which & XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which & XkbTypesNameMask)
+ nAtoms++;
+ if (which & XkbCompatNameMask)
+ nAtoms++;
+ if (which & XkbKeyTypeNamesMask)
+ nAtoms += nTypes;
+ if (which & XkbKTLevelNamesMask) {
+ req->firstKTLevel = firstLvlType;
+ req->nKTLevels = nLvlTypes;
+ req->length += XkbPaddedSize(nLvlTypes) / 4; /* room for group widths */
+ nAtoms += nLvlNames;
+ }
+ else
+ req->firstKTLevel = req->nKTLevels = 0;
+
+ if (which & XkbIndicatorNamesMask) {
+ leds = req->indicators = (CARD32) changes->changed_indicators;
+ nLEDs = _XkbCountBits(XkbNumIndicators, changes->changed_indicators);
+ if (nLEDs > 0)
+ nAtoms += nLEDs;
+ else
+ which &= ~XkbIndicatorNamesMask;
+ }
+ else
+ req->indicators = 0;
+
+ if (which & XkbVirtualModNamesMask) {
+ vmods = req->virtualMods = changes->changed_vmods;
+ nVMods = _XkbCountBits(XkbNumVirtualMods,
+ (unsigned long) changes->changed_vmods);
+ if (nVMods > 0)
+ nAtoms += nVMods;
+ else
+ which &= ~XkbVirtualModNamesMask;
+ }
+ else
+ req->virtualMods = 0;
+
+ if (which & XkbGroupNamesMask) {
+ groups = req->groupNames = changes->changed_groups;
+ nGroups = _XkbCountBits(XkbNumKbdGroups,
+ (unsigned long) changes->changed_groups);
+ if (nGroups > 0)
+ nAtoms += nGroups;
+ else
+ which &= ~XkbGroupNamesMask;
+ }
+ else
+ req->groupNames = 0;
+
+ if ((which & XkbKeyNamesMask) && (names->keys != NULL)) {
+ firstKey = req->firstKey;
+ nKeys = req->nKeys;
+ nAtoms += nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else
+ which &= ~XkbKeyNamesMask;
+
+ if (which & XkbKeyAliasesMask) {
+ nKA = ((names->key_aliases != NULL) ? names->num_key_aliases : 0);
+ if (nKA > 0)
+ nAtoms += nKA * 2; /* not atoms, but 8 bytes on the wire */
+ else
+ which &= ~XkbKeyAliasesMask;
+ }
+
+ if (which & XkbRGNamesMask) {
+ nRG = names->num_rg;
+ if (nRG > 0)
+ nAtoms += nRG;
+ else
+ which &= ~XkbRGNamesMask;
+ }
+
+ req->which = which;
+ req->nRadioGroups = nRG;
+ req->length += (nAtoms * 4) / 4;
+
+ if (which & XkbKeycodesNameMask)
+ Data32(dpy, (long *) &names->keycodes, 4);
+ if (which & XkbGeometryNameMask)
+ Data32(dpy, (long *) &names->geometry, 4);
+ if (which & XkbSymbolsNameMask)
+ Data32(dpy, (long *) &names->symbols, 4);
+ if (which & XkbPhysSymbolsNameMask)
+ Data32(dpy, (long *) &names->phys_symbols, 4);
+ if (which & XkbTypesNameMask)
+ Data32(dpy, (long *) &names->types, 4);
+ if (which & XkbCompatNameMask)
+ Data32(dpy, (long *) &names->compat, 4);
+ if (which & XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+
+ type = &xkb->map->types[firstType];
+ for (i = 0; i < nTypes; i++, type++) {
+ Data32(dpy, (long *) &type->name, 4);
+ }
+ }
+ if (which & XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *, tmp, XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i = 0; i < nLvlTypes; i++, type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i = 0; i < nLvlTypes; i++, type++) {
+ if (type->level_names != NULL)
+ Data32(dpy, (long *) type->level_names, type->num_levels * 4);
+ }
+ }
+ if (which & XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy, names->indicators, leds, XkbNumIndicators);
+ if (which & XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy, names->vmods, vmods, XkbNumVirtualMods);
+ if (which & XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy, names->groups, groups, XkbNumKbdGroups);
+ if (which & XkbKeyNamesMask) {
+ Data(dpy, (char *) &names->keys[firstKey], nKeys * XkbKeyNameLength);
+ }
+ if (which & XkbKeyAliasesMask) {
+ Data(dpy, (char *) names->key_aliases, nKA * XkbKeyNameLength * 2);
+ }
+ if (which & XkbRGNamesMask) {
+ Data32(dpy, (long *) names->radio_groups, nRG * 4);
}
UnlockDisplay(dpy);
SyncHandle();
@@ -738,96 +772,108 @@ XkbChangeNames(Display *dpy,XkbDescPtr xkb,XkbNameChangesPtr changes)
}
void
-XkbNoteNameChanges( XkbNameChangesPtr old,
- XkbNamesNotifyEvent * new,
- unsigned int wanted)
+XkbNoteNameChanges(XkbNameChangesPtr old,
+ XkbNamesNotifyEvent *new,
+ unsigned int wanted)
{
-int first,last,old_last,new_last;
+ int first, last, old_last, new_last;
+
+ if ((old == NULL) || (new == NULL))
+ return;
- wanted&= new->changed;
- if ((old==NULL)||(new==NULL)||(wanted==0))
+ wanted &= new->changed;
+
+ if (wanted == 0)
return;
- if (wanted&XkbKeyTypeNamesMask) {
- if (old->changed&XkbKeyTypeNamesMask) {
- new_last= (new->first_type+new->num_types-1);
- old_last= (old->first_type+old->num_types-1);
-
- if (new->first_type<old->first_type)
- first= new->first_type;
- else first= old->first_type;
-
- if (old_last>new_last)
- last= old_last;
- else last= new_last;
-
- old->first_type= first;
- old->num_types= (last-first)+1;
- }
- else {
- old->first_type= new->first_type;
- old->num_types= new->num_types;
- }
- }
- if (wanted&XkbKTLevelNamesMask) {
- if (old->changed&XkbKTLevelNamesMask) {
- new_last= (new->first_lvl+new->num_lvls-1);
- old_last= (old->first_lvl+old->num_lvls-1);
-
- if (new->first_lvl<old->first_lvl)
- first= new->first_lvl;
- else first= old->first_lvl;
-
- if (old_last>new_last)
- last= old_last;
- else last= new_last;
-
- old->first_lvl= first;
- old->num_lvls= (last-first)+1;
- }
- else {
- old->first_lvl= new->first_lvl;
- old->num_lvls= new->num_lvls;
- }
- }
- if (wanted&XkbIndicatorNamesMask) {
- if (old->changed&XkbIndicatorNamesMask)
- old->changed_indicators|= new->changed_indicators;
- else old->changed_indicators= new->changed_indicators;
- }
- if (wanted&XkbKeyNamesMask) {
- if (old->changed&XkbKeyNamesMask) {
- new_last= (new->first_key+new->num_keys-1);
- old_last= (old->first_key+old->num_keys-1);
-
- first= old->first_key;
-
- if (new->first_key<old->first_key)
- first= new->first_key;
- if (old_last>new_last)
- new_last= old_last;
-
- old->first_key= first;
- old->num_keys= (new_last-first)+1;
- }
- else {
- old->first_key= new->first_key;
- old->num_keys= new->num_keys;
- }
- }
- if (wanted&XkbVirtualModNamesMask) {
- if (old->changed&XkbVirtualModNamesMask)
- old->changed_vmods|= new->changed_vmods;
- else old->changed_vmods= new->changed_vmods;
- }
- if (wanted&XkbGroupNamesMask) {
- if (old->changed&XkbGroupNamesMask)
- old->changed_groups|= new->changed_groups;
- else old->changed_groups= new->changed_groups;
- }
- if (wanted&XkbRGNamesMask)
- old->num_rg= new->num_radio_groups;
- if (wanted&XkbKeyAliasesMask)
- old->num_aliases= new->num_aliases;
- old->changed|= wanted;
+
+ if (wanted & XkbKeyTypeNamesMask) {
+ if (old->changed & XkbKeyTypeNamesMask) {
+ new_last = (new->first_type + new->num_types - 1);
+ old_last = (old->first_type + old->num_types - 1);
+
+ if (new->first_type < old->first_type)
+ first = new->first_type;
+ else
+ first = old->first_type;
+
+ if (old_last > new_last)
+ last = old_last;
+ else
+ last = new_last;
+
+ old->first_type = first;
+ old->num_types = (last - first) + 1;
+ }
+ else {
+ old->first_type = new->first_type;
+ old->num_types = new->num_types;
+ }
+ }
+ if (wanted & XkbKTLevelNamesMask) {
+ if (old->changed & XkbKTLevelNamesMask) {
+ new_last = (new->first_lvl + new->num_lvls - 1);
+ old_last = (old->first_lvl + old->num_lvls - 1);
+
+ if (new->first_lvl < old->first_lvl)
+ first = new->first_lvl;
+ else
+ first = old->first_lvl;
+
+ if (old_last > new_last)
+ last = old_last;
+ else
+ last = new_last;
+
+ old->first_lvl = first;
+ old->num_lvls = (last - first) + 1;
+ }
+ else {
+ old->first_lvl = new->first_lvl;
+ old->num_lvls = new->num_lvls;
+ }
+ }
+ if (wanted & XkbIndicatorNamesMask) {
+ if (old->changed & XkbIndicatorNamesMask)
+ old->changed_indicators |= new->changed_indicators;
+ else
+ old->changed_indicators = new->changed_indicators;
+ }
+ if (wanted & XkbKeyNamesMask) {
+ if (old->changed & XkbKeyNamesMask) {
+ new_last = (new->first_key + new->num_keys - 1);
+ old_last = (old->first_key + old->num_keys - 1);
+
+ first = old->first_key;
+
+ if (new->first_key < old->first_key)
+ first = new->first_key;
+ if (old_last > new_last)
+ new_last = old_last;
+
+ old->first_key = first;
+ old->num_keys = (new_last - first) + 1;
+ }
+ else {
+ old->first_key = new->first_key;
+ old->num_keys = new->num_keys;
+ }
+ }
+ if (wanted & XkbVirtualModNamesMask) {
+ if (old->changed & XkbVirtualModNamesMask)
+ old->changed_vmods |= new->changed_vmods;
+ else
+ old->changed_vmods = new->changed_vmods;
+ }
+ if (wanted & XkbGroupNamesMask) {
+ if (old->changed & XkbGroupNamesMask)
+ old->changed_groups |= new->changed_groups;
+ else
+ old->changed_groups = new->changed_groups;
+ }
+ if (wanted & XkbRGNamesMask)
+ old->num_rg = new->num_radio_groups;
+ if (wanted & XkbKeyAliasesMask)
+ old->num_aliases = new->num_aliases;
+ old->changed |= wanted;
return;
}
diff --git a/nx-X11/lib/X11/XKBRdBuf.c b/nx-X11/lib/X11/XKBRdBuf.c
index ca8f8e722..381f4c900 100644
--- a/nx-X11/lib/X11/XKBRdBuf.c
+++ b/nx-X11/lib/X11/XKBRdBuf.c
@@ -35,16 +35,16 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
/***====================================================================***/
int
-_XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
+_XkbInitReadBuffer(Display *dpy, XkbReadBufferPtr buf, int size)
{
- if ((dpy!=NULL) && (buf!=NULL) && (size>0)) {
- buf->error= 0;
- buf->size= size;
- buf->start= buf->data= _XkbAlloc(size);
- if (buf->start) {
- _XRead(dpy, buf->start, size);
- return 1;
- }
+ if ((dpy != NULL) && (buf != NULL) && (size > 0)) {
+ buf->error = 0;
+ buf->size = size;
+ buf->start = buf->data = _XkbAlloc(size);
+ if (buf->start) {
+ _XRead(dpy, buf->start, size);
+ return 1;
+ }
}
return 0;
}
@@ -52,56 +52,55 @@ _XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
#define _XkbReadBufferDataLeft(b) (((b)->size)-((b)->data-(b)->start))
int
-_XkbSkipReadBufferData(XkbReadBufferPtr from,int size)
+_XkbSkipReadBufferData(XkbReadBufferPtr from, int size)
{
- if (size==0)
- return 1;
- if ((from==NULL)||(from->error)||(size<1)||
- (_XkbReadBufferDataLeft(from)<size))
- return 0;
- from->data+= size;
+ if (size == 0)
+ return 1;
+ if ((from == NULL) || (from->error) || (size < 1) ||
+ (_XkbReadBufferDataLeft(from) < size))
+ return 0;
+ from->data += size;
return 1;
}
int
-_XkbCopyFromReadBuffer(XkbReadBufferPtr from,char *to,int size)
+_XkbCopyFromReadBuffer(XkbReadBufferPtr from, char *to, int size)
{
- if (size==0)
- return 1;
- if ((from==NULL)||(from->error)||(to==NULL)||(size<1)||
- (_XkbReadBufferDataLeft(from)<size))
- return 0;
- memcpy(to,from->data,size);
- from->data+= size;
+ if (size == 0)
+ return 1;
+ if ((from == NULL) || (from->error) || (to == NULL) || (size < 1) ||
+ (_XkbReadBufferDataLeft(from) < size))
+ return 0;
+ memcpy(to, from->data, size);
+ from->data += size;
return 1;
}
#ifdef XKB_FORCE_INT_KEYSYM
int
-_XkbReadCopyKeySyms(int *wire,KeySym *to,int num_words)
+_XkbReadCopyKeySyms(int *wire, KeySym * to, int num_words)
{
- while (num_words-->0) {
- *to++= *wire++;
+ while (num_words-- > 0) {
+ *to++ = *wire++;
}
return 1;
}
int
-_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from,KeySym *to,int num_words)
+_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from, KeySym * to, int num_words)
{
- if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
+ if ((unsigned) (num_words * 4) > _XkbReadBufferDataLeft(from))
return 0;
- _XkbReadCopyKeySyms((int *)from->data,to,num_words);
- from->data+= (4*num_words);
+ _XkbReadCopyKeySyms((int *) from->data, to, num_words);
+ from->data += (4 * num_words);
return True;
}
int
-_XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
+_XkbWriteCopyKeySyms(register KeySym * from, CARD32 *to, int len)
{
-
- while (len-->0) {
- *to++= (CARD32)*from++;
+ while (len-- > 0) {
+ *to++ = (CARD32) *from++;
}
return True;
}
@@ -109,57 +108,54 @@ _XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
#ifdef LONG64
int
-_XkbReadCopyData32(int *wire,long *to,int num_words)
+_XkbReadCopyData32(int *wire, long *to, int num_words)
{
- while (num_words-->0) {
- *to++= *wire++;
+ while (num_words-- > 0) {
+ *to++ = *wire++;
}
return 1;
}
-#endif
-#if defined(LONG64)
int
-_XkbReadBufferCopy32(XkbReadBufferPtr from,long *to,int num_words)
+_XkbReadBufferCopy32(XkbReadBufferPtr from, long *to, int num_words)
{
- if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
- return 0;
- _XkbReadCopyData32((int *)from->data,to,num_words);
- from->data+= (4*num_words);
+ if ((unsigned) (num_words * 4) > _XkbReadBufferDataLeft(from))
+ return 0;
+ _XkbReadCopyData32((int *) from->data, to, num_words);
+ from->data += (4 * num_words);
return True;
}
-#endif
-#ifdef LONG64
int
-_XkbWriteCopyData32 (register unsigned long *from,CARD32 *to,int len)
+_XkbWriteCopyData32(register unsigned long *from, CARD32 *to, int len)
{
-
- while (len-->0) {
- *to++= (CARD32)*from++;
+ while (len-- > 0) {
+ *to++ = (CARD32) *from++;
}
return True;
}
-#endif /* LONG64 */
+#endif /* LONG64 */
+
char *
-_XkbPeekAtReadBuffer(XkbReadBufferPtr from,int size)
+_XkbPeekAtReadBuffer(XkbReadBufferPtr from, int size)
{
- if ((from==NULL)||(from->error)||(size<1)||
- (_XkbReadBufferDataLeft(from)<size))
- return NULL;
+ if ((from == NULL) || (from->error) || (size < 1) ||
+ (_XkbReadBufferDataLeft(from) < size))
+ return NULL;
return from->data;
}
char *
-_XkbGetReadBufferPtr(XkbReadBufferPtr from,int size)
+_XkbGetReadBufferPtr(XkbReadBufferPtr from, int size)
{
-char *ptr;
- if ((from==NULL)||(from->error)||(size<1)||
- (_XkbReadBufferDataLeft(from)<size))
- return NULL;
- ptr= from->data;
- from->data+= size;
+ char *ptr;
+
+ if ((from == NULL) || (from->error) || (size < 1) ||
+ (_XkbReadBufferDataLeft(from) < size))
+ return NULL;
+ ptr = from->data;
+ from->data += size;
return ptr;
}
@@ -167,39 +163,41 @@ char *ptr;
int
_XkbFreeReadBuffer(XkbReadBufferPtr buf)
{
- if ((buf!=NULL) && (buf->start!=NULL)) {
- int left;
- left= (int)_XkbReadBufferDataLeft(buf);
- if (buf->start!=NULL)
- Xfree(buf->start);
- buf->size= 0;
- buf->start= buf->data= NULL;
- return left;
+ if ((buf != NULL) && (buf->start != NULL)) {
+ int left;
+
+ left = (int) _XkbReadBufferDataLeft(buf);
+
+ Xfree(buf->start);
+ buf->size = 0;
+ buf->start = buf->data = NULL;
+ return left;
}
return 0;
}
Bool
-_XkbGetReadBufferCountedString(XkbReadBufferPtr buf,char **rtrn)
+_XkbGetReadBufferCountedString(XkbReadBufferPtr buf, char **rtrn)
{
-CARD16 len,*pLen;
-int left;
-char * str = NULL;
-
- if ((buf==NULL)||(buf->error)||((left=(int)_XkbReadBufferDataLeft(buf))<4))
- return False;
- pLen= (CARD16 *)buf->data;
- len= *pLen;
- if (len>0) {
- if (XkbPaddedSize(len+2)>left)
- return False;
- str= _XkbAlloc(len+1);
- if (str) {
- memcpy(str,&buf->data[2],len);
- str[len]= '\0';
- }
+ CARD16 len, *pLen;
+ int left;
+ char *str = NULL;
+
+ if ((buf == NULL) || (buf->error) ||
+ ((left = (int) _XkbReadBufferDataLeft(buf)) < 4))
+ return False;
+ pLen = (CARD16 *) buf->data;
+ len = *pLen;
+ if (len > 0) {
+ if (XkbPaddedSize(len + 2) > left)
+ return False;
+ str = _XkbAlloc(len + 1);
+ if (str) {
+ memcpy(str, &buf->data[2], len);
+ str[len] = '\0';
+ }
}
- buf->data+= XkbPaddedSize(len+2);
- *rtrn= str;
+ buf->data += XkbPaddedSize(len + 2);
+ *rtrn = str;
return True;
}
diff --git a/nx-X11/lib/X11/XKBSetGeom.c b/nx-X11/lib/X11/XKBSetGeom.c
index e951afaeb..ee254e0dc 100644
--- a/nx-X11/lib/X11/XKBSetGeom.c
+++ b/nx-X11/lib/X11/XKBSetGeom.c
@@ -48,28 +48,29 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define _SizeCountedString(s) ((s)?XkbPaddedSize(2+strlen(s)):4)
static char *
-_WriteCountedString(char *wire,char *str)
+_WriteCountedString(char *wire, char *str)
{
-CARD16 len,*pLen;
+ CARD16 len, *pLen;
- len= (str?strlen(str):0);
- pLen= (CARD16 *)wire;
- *pLen= len;
+ len = (str ? strlen(str) : 0);
+ pLen = (CARD16 *) wire;
+ *pLen = len;
if (len && str)
- memcpy(&wire[2],str,len);
- wire+= XkbPaddedSize(len+2);
+ memcpy(&wire[2], str, len);
+ wire += XkbPaddedSize(len + 2);
return wire;
}
static int
_SizeGeomProperties(XkbGeometryPtr geom)
{
-register int i,size;
-XkbPropertyPtr prop;
+ register int i, size;
+ XkbPropertyPtr prop;
- for (size=i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
- size+= _SizeCountedString(prop->name);
- size+= _SizeCountedString(prop->value);
+ for (size = i = 0, prop = geom->properties; i < geom->num_properties;
+ i++, prop++) {
+ size += _SizeCountedString(prop->name);
+ size += _SizeCountedString(prop->value);
}
return size;
}
@@ -77,11 +78,11 @@ XkbPropertyPtr prop;
static int
_SizeGeomColors(XkbGeometryPtr geom)
{
-register int i,size;
-register XkbColorPtr color;
+ register int i, size;
+ register XkbColorPtr color;
- for (i=size=0,color=geom->colors;i<geom->num_colors;i++,color++) {
- size+= _SizeCountedString(color->spec);
+ for (i = size = 0, color = geom->colors; i < geom->num_colors; i++, color++) {
+ size += _SizeCountedString(color->spec);
}
return size;
}
@@ -89,35 +90,36 @@ register XkbColorPtr color;
static int
_SizeGeomShapes(XkbGeometryPtr geom)
{
-register int i,size;
-register XkbShapePtr shape;
-
- for (i=size=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
- register int n;
- register XkbOutlinePtr ol;
- size+= SIZEOF(xkbShapeWireDesc);
- for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
- size+= SIZEOF(xkbOutlineWireDesc);
- size+= ol->num_points*SIZEOF(xkbPointWireDesc);
- }
+ register int i, size;
+ register XkbShapePtr shape;
+
+ for (i = size = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) {
+ register int n;
+ register XkbOutlinePtr ol;
+
+ size += SIZEOF(xkbShapeWireDesc);
+ for (n = 0, ol = shape->outlines; n < shape->num_outlines; n++, ol++) {
+ size += SIZEOF(xkbOutlineWireDesc);
+ size += ol->num_points * SIZEOF(xkbPointWireDesc);
+ }
}
return size;
}
static int
-_SizeGeomDoodads(int num_doodads,XkbDoodadPtr doodad)
+_SizeGeomDoodads(int num_doodads, XkbDoodadPtr doodad)
{
-register int i,size;
-
- for (i=size=0;i<num_doodads;i++,doodad++) {
- size+= SIZEOF(xkbAnyDoodadWireDesc);
- if (doodad->any.type==XkbTextDoodad) {
- size+= _SizeCountedString(doodad->text.text);
- size+= _SizeCountedString(doodad->text.font);
- }
- else if (doodad->any.type==XkbLogoDoodad) {
- size+= _SizeCountedString(doodad->logo.logo_name);
- }
+ register int i, size;
+
+ for (i = size = 0; i < num_doodads; i++, doodad++) {
+ size += SIZEOF(xkbAnyDoodadWireDesc);
+ if (doodad->any.type == XkbTextDoodad) {
+ size += _SizeCountedString(doodad->text.text);
+ size += _SizeCountedString(doodad->text.font);
+ }
+ else if (doodad->any.type == XkbLogoDoodad) {
+ size += _SizeCountedString(doodad->logo.logo_name);
+ }
}
return size;
}
@@ -125,34 +127,39 @@ register int i,size;
static int
_SizeGeomSections(XkbGeometryPtr geom)
{
-register int i,size;
-XkbSectionPtr section;
-
- for (i=size=0,section=geom->sections;i<geom->num_sections;i++,section++) {
- size+= SIZEOF(xkbSectionWireDesc);
- if (section->rows) {
- int r;
- XkbRowPtr row;
- for (r=0,row=section->rows;r<section->num_rows;row++,r++) {
- size+= SIZEOF(xkbRowWireDesc);
- size+= row->num_keys*SIZEOF(xkbKeyWireDesc);
- }
- }
- if (section->doodads)
- size+= _SizeGeomDoodads(section->num_doodads,section->doodads);
- if (section->overlays) {
- int o;
- XkbOverlayPtr ol;
- for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
- int r;
- XkbOverlayRowPtr row;
- size+= SIZEOF(xkbOverlayWireDesc);
- for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
- size+= SIZEOF(xkbOverlayRowWireDesc);
- size+= row->num_keys*SIZEOF(xkbOverlayKeyWireDesc);
- }
- }
- }
+ register int i, size;
+ XkbSectionPtr section;
+
+ for (i = size = 0, section = geom->sections; i < geom->num_sections;
+ i++, section++) {
+ size += SIZEOF(xkbSectionWireDesc);
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+
+ for (r = 0, row = section->rows; r < section->num_rows; row++, r++) {
+ size += SIZEOF(xkbRowWireDesc);
+ size += row->num_keys * SIZEOF(xkbKeyWireDesc);
+ }
+ }
+ if (section->doodads)
+ size += _SizeGeomDoodads(section->num_doodads, section->doodads);
+ if (section->overlays) {
+ int o;
+ XkbOverlayPtr ol;
+
+ for (o = 0, ol = section->overlays; o < section->num_overlays;
+ o++, ol++) {
+ int r;
+ XkbOverlayRowPtr row;
+
+ size += SIZEOF(xkbOverlayWireDesc);
+ for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
+ size += SIZEOF(xkbOverlayRowWireDesc);
+ size += row->num_keys * SIZEOF(xkbOverlayKeyWireDesc);
+ }
+ }
+ }
}
return size;
}
@@ -160,224 +167,230 @@ XkbSectionPtr section;
static int
_SizeGeomKeyAliases(XkbGeometryPtr geom)
{
- return geom->num_key_aliases*(2*XkbKeyNameLength);
+ return geom->num_key_aliases * (2 * XkbKeyNameLength);
}
/***====================================================================***/
static char *
-_WriteGeomProperties(char *wire,XkbGeometryPtr geom)
+_WriteGeomProperties(char *wire, XkbGeometryPtr geom)
{
-register int i;
-register XkbPropertyPtr prop;
+ register int i;
+ register XkbPropertyPtr prop;
- for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
- wire= _WriteCountedString(wire,prop->name);
- wire= _WriteCountedString(wire,prop->value);
+ for (i = 0, prop = geom->properties; i < geom->num_properties; i++, prop++) {
+ wire = _WriteCountedString(wire, prop->name);
+ wire = _WriteCountedString(wire, prop->value);
}
return wire;
}
static char *
-_WriteGeomColors(char *wire,XkbGeometryPtr geom)
+_WriteGeomColors(char *wire, XkbGeometryPtr geom)
{
-register int i;
-register XkbColorPtr color;
+ register int i;
+ register XkbColorPtr color;
- for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
- wire= _WriteCountedString(wire,color->spec);
+ for (i = 0, color = geom->colors; i < geom->num_colors; i++, color++) {
+ wire = _WriteCountedString(wire, color->spec);
}
return wire;
}
static char *
-_WriteGeomShapes(char *wire,XkbGeometryPtr geom)
+_WriteGeomShapes(char *wire, XkbGeometryPtr geom)
{
-int i;
-XkbShapePtr shape;
-xkbShapeWireDesc * shapeWire;
-
- for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
- register int o;
- XkbOutlinePtr ol;
- xkbOutlineWireDesc * olWire;
- shapeWire= (xkbShapeWireDesc *)wire;
- shapeWire->name= shape->name;
- shapeWire->nOutlines= shape->num_outlines;
- if (shape->primary!=NULL)
- shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);
- else shapeWire->primaryNdx= XkbNoShape;
- if (shape->approx!=NULL)
- shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);
- else shapeWire->approxNdx= XkbNoShape;
- wire= (char *)&shapeWire[1];
- for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
- register int p;
- XkbPointPtr pt;
- xkbPointWireDesc * ptWire;
- olWire= (xkbOutlineWireDesc *)wire;
- olWire->nPoints= ol->num_points;
- olWire->cornerRadius= ol->corner_radius;
- wire= (char *)&olWire[1];
- ptWire= (xkbPointWireDesc *)wire;
- for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
- ptWire[p].x= pt->x;
- ptWire[p].y= pt->y;
- }
- wire= (char *)&ptWire[ol->num_points];
- }
+ int i;
+ XkbShapePtr shape;
+ xkbShapeWireDesc *shapeWire;
+
+ for (i = 0, shape = geom->shapes; i < geom->num_shapes; i++, shape++) {
+ register int o;
+ XkbOutlinePtr ol;
+ xkbOutlineWireDesc *olWire;
+
+ shapeWire = (xkbShapeWireDesc *) wire;
+ shapeWire->name = shape->name;
+ shapeWire->nOutlines = shape->num_outlines;
+ if (shape->primary != NULL)
+ shapeWire->primaryNdx = XkbOutlineIndex(shape, shape->primary);
+ else
+ shapeWire->primaryNdx = XkbNoShape;
+ if (shape->approx != NULL)
+ shapeWire->approxNdx = XkbOutlineIndex(shape, shape->approx);
+ else
+ shapeWire->approxNdx = XkbNoShape;
+ wire = (char *) &shapeWire[1];
+ for (o = 0, ol = shape->outlines; o < shape->num_outlines; o++, ol++) {
+ register int p;
+ XkbPointPtr pt;
+ xkbPointWireDesc *ptWire;
+
+ olWire = (xkbOutlineWireDesc *) wire;
+ olWire->nPoints = ol->num_points;
+ olWire->cornerRadius = ol->corner_radius;
+ wire = (char *) &olWire[1];
+ ptWire = (xkbPointWireDesc *) wire;
+ for (p = 0, pt = ol->points; p < ol->num_points; p++, pt++) {
+ ptWire[p].x = pt->x;
+ ptWire[p].y = pt->y;
+ }
+ wire = (char *) &ptWire[ol->num_points];
+ }
}
return wire;
}
static char *
-_WriteGeomDoodads(char *wire,int num_doodads,XkbDoodadPtr doodad)
+_WriteGeomDoodads(char *wire, int num_doodads, XkbDoodadPtr doodad)
{
-register int i;
-xkbDoodadWireDesc * doodadWire;
-
- for (i=0;i<num_doodads;i++,doodad++) {
- doodadWire= (xkbDoodadWireDesc *)wire;
- wire= (char *)&doodadWire[1];
- bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
- doodadWire->any.name= doodad->any.name;
- doodadWire->any.type= doodad->any.type;
- doodadWire->any.priority= doodad->any.priority;
- doodadWire->any.top= doodad->any.top;
- doodadWire->any.left= doodad->any.left;
- doodadWire->any.angle= doodad->any.angle;
- switch (doodad->any.type) {
- case XkbOutlineDoodad:
- case XkbSolidDoodad:
- doodadWire->shape.colorNdx= doodad->shape.color_ndx;
- doodadWire->shape.shapeNdx= doodad->shape.shape_ndx;
- break;
- case XkbTextDoodad:
- doodadWire->text.width= doodad->text.width;
- doodadWire->text.height= doodad->text.height;
- doodadWire->text.colorNdx= doodad->text.color_ndx;
- wire= _WriteCountedString(wire,doodad->text.text);
- wire= _WriteCountedString(wire,doodad->text.font);
- break;
- case XkbIndicatorDoodad:
- doodadWire->indicator.shapeNdx= doodad->indicator.shape_ndx;
- doodadWire->indicator.onColorNdx=doodad->indicator.on_color_ndx;
- doodadWire->indicator.offColorNdx=
- doodad->indicator.off_color_ndx;
- break;
- case XkbLogoDoodad:
- doodadWire->logo.colorNdx= doodad->logo.color_ndx;
- doodadWire->logo.shapeNdx= doodad->logo.shape_ndx;
- wire= _WriteCountedString(wire,doodad->logo.logo_name);
- break;
- default:
- break;
- }
+ register int i;
+
+ for (i = 0; i < num_doodads; i++, doodad++) {
+ xkbDoodadWireDesc *doodadWire = (xkbDoodadWireDesc *) wire;
+
+ wire = (char *) &doodadWire[1];
+ bzero(doodadWire, SIZEOF(xkbDoodadWireDesc));
+ doodadWire->any.name = doodad->any.name;
+ doodadWire->any.type = doodad->any.type;
+ doodadWire->any.priority = doodad->any.priority;
+ doodadWire->any.top = doodad->any.top;
+ doodadWire->any.left = doodad->any.left;
+ doodadWire->any.angle = doodad->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodadWire->shape.colorNdx = doodad->shape.color_ndx;
+ doodadWire->shape.shapeNdx = doodad->shape.shape_ndx;
+ break;
+ case XkbTextDoodad:
+ doodadWire->text.width = doodad->text.width;
+ doodadWire->text.height = doodad->text.height;
+ doodadWire->text.colorNdx = doodad->text.color_ndx;
+ wire = _WriteCountedString(wire, doodad->text.text);
+ wire = _WriteCountedString(wire, doodad->text.font);
+ break;
+ case XkbIndicatorDoodad:
+ doodadWire->indicator.shapeNdx = doodad->indicator.shape_ndx;
+ doodadWire->indicator.onColorNdx = doodad->indicator.on_color_ndx;
+ doodadWire->indicator.offColorNdx = doodad->indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodadWire->logo.colorNdx = doodad->logo.color_ndx;
+ doodadWire->logo.shapeNdx = doodad->logo.shape_ndx;
+ wire = _WriteCountedString(wire, doodad->logo.logo_name);
+ break;
+ default:
+ break;
+ }
}
return wire;
}
static char *
-_WriteGeomOverlay(char *wire,XkbOverlayPtr ol)
+_WriteGeomOverlay(char *wire, XkbOverlayPtr ol)
{
-register int r;
-XkbOverlayRowPtr row;
-xkbOverlayWireDesc * olWire;
-
- olWire= (xkbOverlayWireDesc *)wire;
- olWire->name= ol->name;
- olWire->nRows= ol->num_rows;
- wire= (char *)&olWire[1];
- for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
- unsigned int k;
- XkbOverlayKeyPtr key;
- xkbOverlayRowWireDesc * rowWire;
- rowWire= (xkbOverlayRowWireDesc *)wire;
- rowWire->rowUnder= row->row_under;
- rowWire->nKeys= row->num_keys;
- wire= (char *)&rowWire[1];
- for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
- xkbOverlayKeyWireDesc * keyWire;
- keyWire= (xkbOverlayKeyWireDesc *)wire;
- memcpy(keyWire->over,key->over.name,XkbKeyNameLength);
- memcpy(keyWire->under,key->under.name,XkbKeyNameLength);
- wire= (char *)&keyWire[1];
- }
- }
- return wire;
+ register int r;
+ XkbOverlayRowPtr row;
+ xkbOverlayWireDesc *olWire = (xkbOverlayWireDesc *) wire;
+
+ olWire->name = ol->name;
+ olWire->nRows = ol->num_rows;
+ wire = (char *) &olWire[1];
+ for (r = 0, row = ol->rows; r < ol->num_rows; r++, row++) {
+ unsigned int k;
+ XkbOverlayKeyPtr key;
+ xkbOverlayRowWireDesc *rowWire = (xkbOverlayRowWireDesc *) wire;
+
+ rowWire->rowUnder = row->row_under;
+ rowWire->nKeys = row->num_keys;
+ wire = (char *) &rowWire[1];
+ for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
+ xkbOverlayKeyWireDesc *keyWire = (xkbOverlayKeyWireDesc *) wire;
+
+ memcpy(keyWire->over, key->over.name, XkbKeyNameLength);
+ memcpy(keyWire->under, key->under.name, XkbKeyNameLength);
+ wire = (char *) &keyWire[1];
+ }
+ }
+ return wire;
}
static char *
-_WriteGeomSections(char *wire,XkbGeometryPtr geom)
+_WriteGeomSections(char *wire, XkbGeometryPtr geom)
{
-register int i;
-XkbSectionPtr section;
-xkbSectionWireDesc * sectionWire;
-
- for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
- sectionWire= (xkbSectionWireDesc *)wire;
- sectionWire->name= section->name;
- sectionWire->top= section->top;
- sectionWire->left= section->left;
- sectionWire->width= section->width;
- sectionWire->height= section->height;
- sectionWire->angle= section->angle;
- sectionWire->priority= section->priority;
- sectionWire->nRows= section->num_rows;
- sectionWire->nDoodads= section->num_doodads;
- sectionWire->nOverlays= section->num_overlays;
- sectionWire->pad= 0;
- wire= (char *)&sectionWire[1];
- if (section->rows) {
- int r;
- XkbRowPtr row;
- xkbRowWireDesc * rowWire;
- for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
- rowWire= (xkbRowWireDesc *)wire;
- rowWire->top= row->top;
- rowWire->left= row->left;
- rowWire->nKeys= row->num_keys;
- rowWire->vertical= row->vertical;
- rowWire->pad= 0;
- wire= (char *)&rowWire[1];
- if (row->keys) {
- int k;
- XkbKeyPtr key;
- xkbKeyWireDesc * keyWire;
- keyWire= (xkbKeyWireDesc *)wire;
- for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
- memcpy(keyWire[k].name,key->name.name,XkbKeyNameLength);
- keyWire[k].gap= key->gap;
- keyWire[k].shapeNdx= key->shape_ndx;
- keyWire[k].colorNdx= key->color_ndx;
- }
- wire= (char *)&keyWire[row->num_keys];
- }
- }
- }
- if (section->doodads) {
- wire= _WriteGeomDoodads(wire,
- section->num_doodads,section->doodads);
- }
- if (section->overlays) {
- register int o;
- for (o=0;o<section->num_overlays;o++) {
- wire= _WriteGeomOverlay(wire,&section->overlays[o]);
- }
- }
+ register int i;
+ XkbSectionPtr section;
+
+ for (i = 0, section = geom->sections; i < geom->num_sections;
+ i++, section++) {
+ xkbSectionWireDesc *sectionWire = (xkbSectionWireDesc *) wire;
+
+ sectionWire->name = section->name;
+ sectionWire->top = section->top;
+ sectionWire->left = section->left;
+ sectionWire->width = section->width;
+ sectionWire->height = section->height;
+ sectionWire->angle = section->angle;
+ sectionWire->priority = section->priority;
+ sectionWire->nRows = section->num_rows;
+ sectionWire->nDoodads = section->num_doodads;
+ sectionWire->nOverlays = section->num_overlays;
+ sectionWire->pad = 0;
+ wire = (char *) &sectionWire[1];
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+
+ for (r = 0, row = section->rows; r < section->num_rows; r++, row++) {
+ xkbRowWireDesc *rowWire = (xkbRowWireDesc *) wire;
+
+ rowWire->top = row->top;
+ rowWire->left = row->left;
+ rowWire->nKeys = row->num_keys;
+ rowWire->vertical = row->vertical;
+ rowWire->pad = 0;
+ wire = (char *) &rowWire[1];
+ if (row->keys) {
+ int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc *keyWire = (xkbKeyWireDesc *) wire;
+
+ for (k = 0, key = row->keys; k < row->num_keys; k++, key++) {
+ memcpy(keyWire[k].name, key->name.name,
+ XkbKeyNameLength);
+ keyWire[k].gap = key->gap;
+ keyWire[k].shapeNdx = key->shape_ndx;
+ keyWire[k].colorNdx = key->color_ndx;
+ }
+ wire = (char *) &keyWire[row->num_keys];
+ }
+ }
+ }
+ if (section->doodads) {
+ wire = _WriteGeomDoodads(wire,
+ section->num_doodads, section->doodads);
+ }
+ if (section->overlays) {
+ register int o;
+
+ for (o = 0; o < section->num_overlays; o++) {
+ wire = _WriteGeomOverlay(wire, &section->overlays[o]);
+ }
+ }
}
return wire;
}
static char *
-_WriteGeomKeyAliases(char *wire,XkbGeometryPtr geom)
+_WriteGeomKeyAliases(char *wire, XkbGeometryPtr geom)
{
-register int sz;
+ register int sz;
- sz= geom->num_key_aliases*(XkbKeyNameLength*2);
- if (sz>0) {
- memcpy(wire,(char *)geom->key_aliases,sz);
- wire+= sz;
+ sz = geom->num_key_aliases * (XkbKeyNameLength * 2);
+ if (sz > 0) {
+ memcpy(wire, (char *) geom->key_aliases, sz);
+ wire += sz;
}
return wire;
}
@@ -385,46 +398,46 @@ register int sz;
/***====================================================================***/
static Status
-_SendSetGeometry(Display *dpy,XkbGeometryPtr geom,xkbSetGeometryReq *req)
+_SendSetGeometry(Display *dpy, XkbGeometryPtr geom, xkbSetGeometryReq *req)
{
-int sz;
-char * wire,*tbuf;
-
- sz= 0;
- sz+= _SizeCountedString(geom->label_font);
- sz+= _SizeGeomProperties(geom);
- sz+= _SizeGeomColors(geom);
- sz+= _SizeGeomShapes(geom);
- sz+= _SizeGeomSections(geom);
- sz+= _SizeGeomDoodads(geom->num_doodads,geom->doodads);
- sz+= _SizeGeomKeyAliases(geom);
- req->length+= (sz/4);
+ int sz;
+ char *wire, *tbuf;
+
+ sz = 0;
+ sz += _SizeCountedString(geom->label_font);
+ sz += _SizeGeomProperties(geom);
+ sz += _SizeGeomColors(geom);
+ sz += _SizeGeomShapes(geom);
+ sz += _SizeGeomSections(geom);
+ sz += _SizeGeomDoodads(geom->num_doodads, geom->doodads);
+ sz += _SizeGeomKeyAliases(geom);
+ req->length += (sz / 4);
if (sz < (dpy->bufmax - dpy->buffer)) {
- BufAlloc(char *,wire,sz);
- tbuf= NULL;
+ BufAlloc(char *, wire, sz);
+ tbuf = NULL;
}
else {
- tbuf= _XAllocTemp(dpy,sz);
- if (!tbuf)
- return BadAlloc;
- wire= tbuf;
+ tbuf = _XAllocTemp(dpy, sz);
+ if (!tbuf)
+ return BadAlloc;
+ wire = tbuf;
}
- wire= _WriteCountedString(wire,geom->label_font);
- if (geom->num_properties>0)
- wire= _WriteGeomProperties(wire,geom);
- if (geom->num_colors>0)
- wire= _WriteGeomColors(wire,geom);
- if (geom->num_shapes>0)
- wire= _WriteGeomShapes(wire,geom);
- if (geom->num_sections>0)
- wire= _WriteGeomSections(wire,geom);
- if (geom->num_doodads>0)
- wire= _WriteGeomDoodads(wire,geom->num_doodads,geom->doodads);
- if (geom->num_key_aliases>0)
- wire= _WriteGeomKeyAliases(wire,geom);
- if (tbuf!=NULL) {
- Data(dpy,tbuf,sz);
- _XFreeTemp(dpy,tbuf,sz);
+ wire = _WriteCountedString(wire, geom->label_font);
+ if (geom->num_properties > 0)
+ wire = _WriteGeomProperties(wire, geom);
+ if (geom->num_colors > 0)
+ wire = _WriteGeomColors(wire, geom);
+ if (geom->num_shapes > 0)
+ wire = _WriteGeomShapes(wire, geom);
+ if (geom->num_sections > 0)
+ wire = _WriteGeomSections(wire, geom);
+ if (geom->num_doodads > 0)
+ wire = _WriteGeomDoodads(wire, geom->num_doodads, geom->doodads);
+ if (geom->num_key_aliases > 0)
+ wire = _WriteGeomKeyAliases(wire, geom);
+ if (tbuf != NULL) {
+ Data(dpy, tbuf, sz);
+ _XFreeTemp(dpy, tbuf, sz);
}
return Success;
}
@@ -432,35 +445,34 @@ char * wire,*tbuf;
/***====================================================================***/
Status
-XkbSetGeometry(Display *dpy,unsigned deviceSpec,XkbGeometryPtr geom)
+XkbSetGeometry(Display *dpy, unsigned deviceSpec, XkbGeometryPtr geom)
{
-xkbSetGeometryReq *req;
-Status ret;
+ xkbSetGeometryReq *req;
+ Status ret;
- if ( (!geom) || (dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ if ((!geom) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
GetReq(kbSetGeometry, req);
req->reqType = dpy->xkb_info->codes->major_opcode;
req->xkbReqType = X_kbSetGeometry;
req->deviceSpec = deviceSpec;
- req->nShapes= geom->num_shapes;
- req->nSections= geom->num_sections;
- req->name= geom->name;
- req->widthMM= geom->width_mm;
- req->heightMM= geom->height_mm;
- req->nProperties= geom->num_properties;
- req->nColors= geom->num_colors;
- req->nDoodads= geom->num_doodads;
- req->nKeyAliases= geom->num_key_aliases;
- req->baseColorNdx= (geom->base_color-geom->colors);
- req->labelColorNdx= (geom->label_color-geom->colors);
-
- ret = _SendSetGeometry(dpy,geom,req);
+ req->nShapes = geom->num_shapes;
+ req->nSections = geom->num_sections;
+ req->name = geom->name;
+ req->widthMM = geom->width_mm;
+ req->heightMM = geom->height_mm;
+ req->nProperties = geom->num_properties;
+ req->nColors = geom->num_colors;
+ req->nDoodads = geom->num_doodads;
+ req->nKeyAliases = geom->num_key_aliases;
+ req->baseColorNdx = (geom->base_color - geom->colors);
+ req->labelColorNdx = (geom->label_color - geom->colors);
+
+ ret = _SendSetGeometry(dpy, geom, req);
UnlockDisplay(dpy);
SyncHandle();
return ret;
}
-
diff --git a/nx-X11/lib/X11/XKBSetMap.c b/nx-X11/lib/X11/XKBSetMap.c
index 994e401d2..cb696105c 100644
--- a/nx-X11/lib/X11/XKBSetMap.c
+++ b/nx-X11/lib/X11/XKBSetMap.c
@@ -33,221 +33,222 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "XKBlibint.h"
static int
-_XkbSizeKeyTypes(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeKeyTypes(XkbDescPtr xkb, xkbSetMapReq *req)
{
- XkbKeyTypePtr map;
- int i,len;
+ XkbKeyTypePtr map;
+ int i, len;
- if (((req->present&XkbKeyTypesMask)==0)||(req->nTypes==0)) {
- req->present&= ~XkbKeyTypesMask;
- req->firstType= req->nTypes= 0;
- return 0;
+ if (((req->present & XkbKeyTypesMask) == 0) || (req->nTypes == 0)) {
+ req->present &= ~XkbKeyTypesMask;
+ req->firstType = req->nTypes = 0;
+ return 0;
}
- len= 0;
- map= &xkb->map->types[req->firstType];
- for (i=0;i<req->nTypes;i++,map++){
- len+= SIZEOF(xkbKeyTypeWireDesc);
- len+= map->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
- if (map->preserve)
- len+= map->map_count*SIZEOF(xkbModsWireDesc);
+ len = 0;
+ map = &xkb->map->types[req->firstType];
+ for (i = 0; i < req->nTypes; i++, map++) {
+ len += SIZEOF(xkbKeyTypeWireDesc);
+ len += map->map_count * SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (map->preserve)
+ len += map->map_count * SIZEOF(xkbModsWireDesc);
}
return len;
}
static void
-_XkbWriteKeyTypes(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteKeyTypes(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
- char * buf;
- XkbKeyTypePtr type;
- int i,n,sz;
+ char *buf;
+ XkbKeyTypePtr type;
+ int i, n;
xkbKeyTypeWireDesc *desc;
- if ((req->present&XkbKeyTypesMask)==0)
- return;
- type= &xkb->map->types[req->firstType];
- for (i=0;i<req->nTypes;i++,type++) {
- sz= SIZEOF(xkbKeyTypeWireDesc);
- sz+= type->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
- if (type->preserve)
- sz+= type->map_count*SIZEOF(xkbModsWireDesc);
- BufAlloc(xkbKeyTypeWireDesc *,desc,sz);
- desc->mask = type->mods.mask;
- desc->realMods = type->mods.real_mods;
- desc->virtualMods = type->mods.vmods;
- desc->numLevels = type->num_levels;
- desc->nMapEntries = type->map_count;
- desc->preserve = (type->preserve!=NULL);
- buf= (char *)&desc[1];
- if (desc->nMapEntries>0) {
- xkbKTSetMapEntryWireDesc *wire;
- wire= (xkbKTSetMapEntryWireDesc *)buf;
- for (n=0;n<type->map_count;n++,wire++) {
- wire->level= type->map[n].level;
- wire->realMods= type->map[n].mods.real_mods;
- wire->virtualMods= type->map[n].mods.vmods;
- }
- buf= (char *)wire;
- if (type->preserve) {
- xkbModsWireDesc *pwire;
- pwire= (xkbModsWireDesc *)buf;
- for (n=0;n<type->map_count;n++,pwire++) {
- pwire->realMods= type->preserve[n].real_mods;
- pwire->virtualMods= type->preserve[n].vmods;
- }
- }
- }
+ if ((req->present & XkbKeyTypesMask) == 0)
+ return;
+ type = &xkb->map->types[req->firstType];
+ for (i = 0; i < req->nTypes; i++, type++) {
+ int sz = SIZEOF(xkbKeyTypeWireDesc);
+ sz += type->map_count * SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (type->preserve)
+ sz += type->map_count * SIZEOF(xkbModsWireDesc);
+ BufAlloc(xkbKeyTypeWireDesc *, desc, sz);
+ desc->mask = type->mods.mask;
+ desc->realMods = type->mods.real_mods;
+ desc->virtualMods = type->mods.vmods;
+ desc->numLevels = type->num_levels;
+ desc->nMapEntries = type->map_count;
+ desc->preserve = (type->preserve != NULL);
+ buf = (char *) &desc[1];
+ if (desc->nMapEntries > 0) {
+ xkbKTSetMapEntryWireDesc *wire = (xkbKTSetMapEntryWireDesc *) buf;
+
+ for (n = 0; n < type->map_count; n++, wire++) {
+ wire->level = type->map[n].level;
+ wire->realMods = type->map[n].mods.real_mods;
+ wire->virtualMods = type->map[n].mods.vmods;
+ }
+ buf = (char *) wire;
+ if (type->preserve) {
+ xkbModsWireDesc *pwire = (xkbModsWireDesc *) buf;
+
+ for (n = 0; n < type->map_count; n++, pwire++) {
+ pwire->realMods = type->preserve[n].real_mods;
+ pwire->virtualMods = type->preserve[n].vmods;
+ }
+ }
+ }
}
return;
}
static int
-_XkbSizeKeySyms(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeKeySyms(XkbDescPtr xkb, xkbSetMapReq *req)
{
- int i,len;
- unsigned nSyms;
-
- if (((req->present&XkbKeySymsMask)==0)||(req->nKeySyms==0)) {
- req->present&= ~XkbKeySymsMask;
- req->firstKeySym= req->nKeySyms= 0;
- req->totalSyms= 0;
- return 0;
+ int i, len;
+ unsigned nSyms;
+
+ if (((req->present & XkbKeySymsMask) == 0) || (req->nKeySyms == 0)) {
+ req->present &= ~XkbKeySymsMask;
+ req->firstKeySym = req->nKeySyms = 0;
+ req->totalSyms = 0;
+ return 0;
}
- len= (int)(req->nKeySyms*sizeof(XkbSymMapRec));
- for (i=nSyms=0;i<req->nKeySyms;i++) {
- nSyms+= XkbKeyNumSyms(xkb,i+req->firstKeySym);
+ len = (int) (req->nKeySyms * sizeof(XkbSymMapRec));
+ for (i = nSyms = 0; i < req->nKeySyms; i++) {
+ nSyms += XkbKeyNumSyms(xkb, i + req->firstKeySym);
}
- len+= nSyms*sizeof(CARD32);
- req->totalSyms= nSyms;
+ len += nSyms * sizeof(CARD32);
+ req->totalSyms = nSyms;
return len;
}
static void
-_XkbWriteKeySyms(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteKeySyms(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-register KeySym * pSym;
-CARD32 * outSym;
-XkbSymMapPtr symMap;
-xkbSymMapWireDesc *desc;
-register int i;
-
- if ((req->present&XkbKeySymsMask)==0)
- return;
+ register KeySym *pSym;
+ CARD32 *outSym;
+ XkbSymMapPtr symMap;
+ xkbSymMapWireDesc *desc;
+ register int i;
+
+ if ((req->present & XkbKeySymsMask) == 0)
+ return;
symMap = &xkb->map->key_sym_map[req->firstKeySym];
- for (i=0;i<req->nKeySyms;i++,symMap++) {
- BufAlloc(xkbSymMapWireDesc *,desc,
- SIZEOF(xkbSymMapWireDesc)+
- (XkbKeyNumSyms(xkb,i+req->firstKeySym)*sizeof(CARD32)));
- desc->ktIndex[0] = symMap->kt_index[0];
- desc->ktIndex[1] = symMap->kt_index[1];
- desc->ktIndex[2] = symMap->kt_index[2];
- desc->ktIndex[3] = symMap->kt_index[3];
- desc->groupInfo = symMap->group_info;
- desc->width = symMap->width;
- desc->nSyms = XkbKeyNumSyms(xkb,i+req->firstKeySym);
- outSym = (CARD32 *)&desc[1];
- if (desc->nSyms>0) {
- pSym = XkbKeySymsPtr(xkb,i+req->firstKeySym);
- _XkbWriteCopyKeySyms(pSym,outSym,desc->nSyms);
- }
+ for (i = 0; i < req->nKeySyms; i++, symMap++) {
+ BufAlloc(xkbSymMapWireDesc *, desc,
+ SIZEOF(xkbSymMapWireDesc) +
+ (XkbKeyNumSyms(xkb, i + req->firstKeySym) * sizeof(CARD32)));
+ desc->ktIndex[0] = symMap->kt_index[0];
+ desc->ktIndex[1] = symMap->kt_index[1];
+ desc->ktIndex[2] = symMap->kt_index[2];
+ desc->ktIndex[3] = symMap->kt_index[3];
+ desc->groupInfo = symMap->group_info;
+ desc->width = symMap->width;
+ desc->nSyms = XkbKeyNumSyms(xkb, i + req->firstKeySym);
+ outSym = (CARD32 *) &desc[1];
+ if (desc->nSyms > 0) {
+ pSym = XkbKeySymsPtr(xkb, i + req->firstKeySym);
+ _XkbWriteCopyKeySyms(pSym, outSym, desc->nSyms);
+ }
}
return;
}
static int
-_XkbSizeKeyActions(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeKeyActions(XkbDescPtr xkb, xkbSetMapReq *req)
{
- int i,len,nActs;
+ int i, len, nActs;
- if (((req->present&XkbKeyActionsMask)==0)||(req->nKeyActs==0)) {
- req->present&= ~XkbKeyActionsMask;
- req->firstKeyAct= req->nKeyActs= 0;
- req->totalActs= 0;
- return 0;
+ if (((req->present & XkbKeyActionsMask) == 0) || (req->nKeyActs == 0)) {
+ req->present &= ~XkbKeyActionsMask;
+ req->firstKeyAct = req->nKeyActs = 0;
+ req->totalActs = 0;
+ return 0;
}
- for (nActs=i=0;i<req->nKeyActs;i++) {
- if (xkb->server->key_acts[i+req->firstKeyAct]!=0)
- nActs+= XkbKeyNumActions(xkb,i+req->firstKeyAct);
+ for (nActs = i = 0; i < req->nKeyActs; i++) {
+ if (xkb->server->key_acts[i + req->firstKeyAct] != 0)
+ nActs += XkbKeyNumActions(xkb, i + req->firstKeyAct);
}
- len= XkbPaddedSize(req->nKeyActs)+(nActs*SIZEOF(xkbActionWireDesc));
- req->totalActs= nActs;
+ len = XkbPaddedSize(req->nKeyActs) + (nActs * SIZEOF(xkbActionWireDesc));
+ req->totalActs = nActs;
return len;
}
static void
-_XkbWriteKeyActions(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteKeyActions(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
- register int i;
- int n;
- CARD8 *numDesc;
- XkbAction *actDesc;
+ register int i;
+ int n;
+ CARD8 *numDesc;
+ XkbAction *actDesc;
- if ((req->present&XkbKeyActionsMask)==0)
- return;
+ if ((req->present & XkbKeyActionsMask) == 0)
+ return;
n = XkbPaddedSize(req->nKeyActs);
- n+= (req->totalActs*SIZEOF(xkbActionWireDesc));
-
- BufAlloc(CARD8 *,numDesc,n);
- for (i=0;i<req->nKeyActs;i++) {
- if (xkb->server->key_acts[i+req->firstKeyAct]==0)
- numDesc[i] = 0;
- else numDesc[i] = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
+ n += (req->totalActs * SIZEOF(xkbActionWireDesc));
+
+ BufAlloc(CARD8 *, numDesc, n);
+ for (i = 0; i < req->nKeyActs; i++) {
+ if (xkb->server->key_acts[i + req->firstKeyAct] == 0)
+ numDesc[i] = 0;
+ else
+ numDesc[i] = XkbKeyNumActions(xkb, (i + req->firstKeyAct));
}
- actDesc = (XkbAction *)&numDesc[XkbPaddedSize(req->nKeyActs)];
- for (i=0;i<req->nKeyActs;i++) {
- if (xkb->server->key_acts[i+req->firstKeyAct]!=0) {
- n = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
- memcpy(actDesc,XkbKeyActionsPtr(xkb,(i+req->firstKeyAct)),
- n*SIZEOF(xkbActionWireDesc));
- actDesc+= n;
- }
+ actDesc = (XkbAction *) &numDesc[XkbPaddedSize(req->nKeyActs)];
+ for (i = 0; i < req->nKeyActs; i++) {
+ if (xkb->server->key_acts[i + req->firstKeyAct] != 0) {
+ n = XkbKeyNumActions(xkb, (i + req->firstKeyAct));
+ memcpy(actDesc, XkbKeyActionsPtr(xkb, (i + req->firstKeyAct)),
+ n * SIZEOF(xkbActionWireDesc));
+ actDesc += n;
+ }
}
return;
}
static int
-_XkbSizeKeyBehaviors(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeKeyBehaviors(XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last,nFound;
+ register int i, first, last, nFound;
- if (((req->present&XkbKeyBehaviorsMask)==0)||(req->nKeyBehaviors<1)) {
- req->present&= ~XkbKeyBehaviorsMask;
- req->firstKeyBehavior= req->nKeyBehaviors= 0;
- req->totalKeyBehaviors= 0;
- return 0;
+ if (((req->present & XkbKeyBehaviorsMask) == 0) || (req->nKeyBehaviors < 1)) {
+ req->present &= ~XkbKeyBehaviorsMask;
+ req->firstKeyBehavior = req->nKeyBehaviors = 0;
+ req->totalKeyBehaviors = 0;
+ return 0;
}
- first= req->firstKeyBehavior;
- last= first+req->nKeyBehaviors-1;
- for (i=first,nFound=0;i<=last;i++) {
- if (xkb->server->behaviors[i].type!=XkbKB_Default)
- nFound++;
+ first = req->firstKeyBehavior;
+ last = first + req->nKeyBehaviors - 1;
+ for (i = first, nFound = 0; i <= last; i++) {
+ if (xkb->server->behaviors[i].type != XkbKB_Default)
+ nFound++;
}
- req->totalKeyBehaviors= nFound;
- return (nFound*SIZEOF(xkbBehaviorWireDesc));
+ req->totalKeyBehaviors = nFound;
+ return (nFound * SIZEOF(xkbBehaviorWireDesc));
}
static void
-_XkbWriteKeyBehaviors(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteKeyBehaviors(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last;
-xkbBehaviorWireDesc * wire;
-char * buf;
-
- if ((req->present&XkbKeyBehaviorsMask)==0)
- return;
- first= req->firstKeyBehavior;
- last= first+req->nKeyBehaviors-1;
-
- i= req->totalKeyBehaviors*SIZEOF(xkbBehaviorWireDesc);
- BufAlloc(char *,buf,i);
- wire= (xkbBehaviorWireDesc *)buf;
- for (i=first;i<=last;i++) {
- if (xkb->server->behaviors[i].type!=XkbKB_Default) {
- wire->key= i;
- wire->type= xkb->server->behaviors[i].type;
- wire->data= xkb->server->behaviors[i].data;
- buf+= SIZEOF(xkbBehaviorWireDesc);
- wire= (xkbBehaviorWireDesc *)buf;
- }
+ register int i, first, last;
+ xkbBehaviorWireDesc *wire;
+ char *buf;
+
+ if ((req->present & XkbKeyBehaviorsMask) == 0)
+ return;
+ first = req->firstKeyBehavior;
+ last = first + req->nKeyBehaviors - 1;
+
+ i = req->totalKeyBehaviors * SIZEOF(xkbBehaviorWireDesc);
+ BufAlloc(char *, buf, i);
+ wire = (xkbBehaviorWireDesc *) buf;
+ for (i = first; i <= last; i++) {
+ if (xkb->server->behaviors[i].type != XkbKB_Default) {
+ wire->key = i;
+ wire->type = xkb->server->behaviors[i].type;
+ wire->data = xkb->server->behaviors[i].data;
+ buf += SIZEOF(xkbBehaviorWireDesc);
+ wire = (xkbBehaviorWireDesc *) buf;
+ }
}
return;
}
@@ -255,236 +256,239 @@ char * buf;
static unsigned
_XkbSizeVirtualMods(xkbSetMapReq *req)
{
-register int i,bit,nMods;
-
- if (((req->present&XkbVirtualModsMask)==0)||(req->virtualMods==0)) {
- req->present&= ~XkbVirtualModsMask;
- req->virtualMods= 0;
- return 0;
- }
- for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if (req->virtualMods&bit)
- nMods++;
- }
- return XkbPaddedSize(nMods);
+ register int i, bit, nMods;
+
+ if (((req->present & XkbVirtualModsMask) == 0) || (req->virtualMods == 0)) {
+ req->present &= ~XkbVirtualModsMask;
+ req->virtualMods = 0;
+ return 0;
+ }
+ for (i = nMods = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (req->virtualMods & bit)
+ nMods++;
+ }
+ return XkbPaddedSize(nMods);
}
static void
-_XkbWriteVirtualMods( Display * dpy,
- XkbDescPtr xkb,
- xkbSetMapReq * req,
- unsigned size)
+_XkbWriteVirtualMods(Display *dpy,
+ XkbDescPtr xkb,
+ xkbSetMapReq *req,
+ unsigned size)
{
- register int i,bit;
- CARD8 *vmods;
+ register int i, bit;
+ CARD8 *vmods;
/* This was req->present&XkbVirtualModsMask==0, and '==' beats '&' */
if (((req->present & XkbVirtualModsMask) == 0) || (size < 1))
- return;
- BufAlloc(CARD8 *,vmods,size);
- for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
- if (req->virtualMods&bit)
- *vmods++= xkb->server->vmods[i];
+ return;
+ BufAlloc(CARD8 *, vmods, size);
+ for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
+ if (req->virtualMods & bit)
+ *vmods++ = xkb->server->vmods[i];
}
return;
}
static int
-_XkbSizeKeyExplicit(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeKeyExplicit(XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last,nFound;
-
- if (((req->present&XkbExplicitComponentsMask)==0)||(req->nKeyExplicit==0)) {
- req->present&= ~XkbExplicitComponentsMask;
- req->firstKeyExplicit= req->nKeyExplicit= 0;
- req->totalKeyExplicit= 0;
- return 0;
+ register int i, first, last, nFound;
+
+ if (((req->present & XkbExplicitComponentsMask) == 0) ||
+ (req->nKeyExplicit == 0)) {
+ req->present &= ~XkbExplicitComponentsMask;
+ req->firstKeyExplicit = req->nKeyExplicit = 0;
+ req->totalKeyExplicit = 0;
+ return 0;
}
- first= req->firstKeyExplicit;
- last= first+req->nKeyExplicit-1;
+ first = req->firstKeyExplicit;
+ last = first + req->nKeyExplicit - 1;
- for (i=first,nFound=0;i<=last;i++) {
- if (xkb->server->explicit[i]!=0)
- nFound++;
+ for (i = first, nFound = 0; i <= last; i++) {
+ if (xkb->server->explicit[i] != 0)
+ nFound++;
}
- req->totalKeyExplicit= nFound;
- return XkbPaddedSize((nFound*2));
+ req->totalKeyExplicit = nFound;
+ return XkbPaddedSize((nFound * 2));
}
static void
-_XkbWriteKeyExplicit(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteKeyExplicit(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last;
-CARD8 * wire;
-
- if ((req->present&XkbExplicitComponentsMask)==0)
- return;
- first= req->firstKeyExplicit;
- last= first+req->nKeyExplicit - 1;
- i= XkbPaddedSize((req->totalKeyExplicit*2));
- BufAlloc(CARD8 *,wire,i);
- for (i=first;i<=last;i++) {
- if (xkb->server->explicit[i]!=0) {
- wire[0]= i;
- wire[1]= xkb->server->explicit[i];
- wire+= 2;
- }
+ register int i, first, last;
+ CARD8 *wire;
+
+ if ((req->present & XkbExplicitComponentsMask) == 0)
+ return;
+ first = req->firstKeyExplicit;
+ last = first + req->nKeyExplicit - 1;
+ i = XkbPaddedSize((req->totalKeyExplicit * 2));
+ BufAlloc(CARD8 *, wire, i);
+ for (i = first; i <= last; i++) {
+ if (xkb->server->explicit[i] != 0) {
+ wire[0] = i;
+ wire[1] = xkb->server->explicit[i];
+ wire += 2;
+ }
}
return;
}
static int
-_XkbSizeModifierMap(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeModifierMap(XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last,nFound;
+ register int i, first, last, nFound;
- if (((req->present&XkbModifierMapMask)==0)||(req->nModMapKeys==0)) {
- req->present&= ~XkbModifierMapMask;
- req->firstModMapKey= req->nModMapKeys= 0;
- req->totalModMapKeys= 0;
- return 0;
+ if (((req->present & XkbModifierMapMask) == 0) || (req->nModMapKeys == 0)) {
+ req->present &= ~XkbModifierMapMask;
+ req->firstModMapKey = req->nModMapKeys = 0;
+ req->totalModMapKeys = 0;
+ return 0;
}
- first= req->firstModMapKey;
- last= first+req->nModMapKeys-1;
+ first = req->firstModMapKey;
+ last = first + req->nModMapKeys - 1;
- for (i=first,nFound=0;i<=last;i++) {
- if (xkb->map->modmap[i]!=0)
- nFound++;
+ for (i = first, nFound = 0; i <= last; i++) {
+ if (xkb->map->modmap[i] != 0)
+ nFound++;
}
- req->totalModMapKeys= nFound;
- return XkbPaddedSize((nFound*2));
+ req->totalModMapKeys = nFound;
+ return XkbPaddedSize((nFound * 2));
}
static void
-_XkbWriteModifierMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteModifierMap(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last;
-CARD8 * wire;
-
- if ((req->present&XkbModifierMapMask)==0)
- return;
- first= req->firstModMapKey;
- last= first+req->nModMapKeys-1;
- if (req->totalModMapKeys>0) {
- i= XkbPaddedSize((req->totalModMapKeys*2));
- BufAlloc(CARD8 *,wire,i);
- for (i=first;i<=last;i++) {
- if (xkb->map->modmap[i]!=0) {
- wire[0]= i;
- wire[1]= xkb->map->modmap[i];
- wire+= 2;
- }
- }
+ register int i, first, last;
+ CARD8 *wire;
+
+ if ((req->present & XkbModifierMapMask) == 0)
+ return;
+ first = req->firstModMapKey;
+ last = first + req->nModMapKeys - 1;
+ if (req->totalModMapKeys > 0) {
+ i = XkbPaddedSize((req->totalModMapKeys * 2));
+ BufAlloc(CARD8 *, wire, i);
+
+ for (i = first; i <= last; i++) {
+ if (xkb->map->modmap[i] != 0) {
+ wire[0] = i;
+ wire[1] = xkb->map->modmap[i];
+ wire += 2;
+ }
+ }
}
return;
}
static int
-_XkbSizeVirtualModMap(XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbSizeVirtualModMap(XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last,nFound;
-
- if (((req->present&XkbVirtualModMapMask)==0)||(req->nVModMapKeys==0)) {
- req->present&= ~XkbVirtualModMapMask;
- req->firstVModMapKey= req->nVModMapKeys= 0;
- req->totalVModMapKeys= 0;
- return 0;
+ register int i, first, last, nFound;
+
+ if (((req->present & XkbVirtualModMapMask) == 0) ||
+ (req->nVModMapKeys == 0)) {
+ req->present &= ~XkbVirtualModMapMask;
+ req->firstVModMapKey = req->nVModMapKeys = 0;
+ req->totalVModMapKeys = 0;
+ return 0;
}
- first= req->firstVModMapKey;
- last= first+req->nVModMapKeys-1;
+ first = req->firstVModMapKey;
+ last = first + req->nVModMapKeys - 1;
- for (i=first,nFound=0;i<=last;i++) {
- if (xkb->server->vmodmap[i]!=0)
- nFound++;
+ for (i = first, nFound = 0; i <= last; i++) {
+ if (xkb->server->vmodmap[i] != 0)
+ nFound++;
}
- req->totalVModMapKeys= nFound;
- return nFound*SIZEOF(xkbVModMapWireDesc);
+ req->totalVModMapKeys = nFound;
+ return nFound * SIZEOF(xkbVModMapWireDesc);
}
static void
-_XkbWriteVirtualModMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+_XkbWriteVirtualModMap(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-register int i,first,last;
-xkbVModMapWireDesc * wire;
-
- if ((req->present&XkbVirtualModMapMask)==0)
- return;
- first= req->firstVModMapKey;
- last= first+req->nVModMapKeys-1;
- if (req->totalVModMapKeys>0) {
- i= req->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
- BufAlloc(xkbVModMapWireDesc *,wire,i);
- for (i=first;i<=last;i++) {
- if (xkb->server->vmodmap[i]!=0) {
- wire->key= i;
- wire->vmods= xkb->server->vmodmap[i];
- wire++;
- }
- }
+ register int i, first, last;
+ xkbVModMapWireDesc *wire;
+
+ if ((req->present & XkbVirtualModMapMask) == 0)
+ return;
+ first = req->firstVModMapKey;
+ last = first + req->nVModMapKeys - 1;
+ if (req->totalVModMapKeys > 0) {
+ i = req->totalVModMapKeys * SIZEOF(xkbVModMapWireDesc);
+ BufAlloc(xkbVModMapWireDesc *, wire, i);
+ for (i = first; i <= last; i++) {
+ if (xkb->server->vmodmap[i] != 0) {
+ wire->key = i;
+ wire->vmods = xkb->server->vmodmap[i];
+ wire++;
+ }
+ }
}
return;
}
static void
-SendSetMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+SendSetMap(Display *dpy, XkbDescPtr xkb, xkbSetMapReq *req)
{
-xkbSetMapReq tmp;
-unsigned szMods;
-
- req->length+= _XkbSizeKeyTypes(xkb,req)/4;
- req->length+= _XkbSizeKeySyms(xkb,req)/4;
- req->length+= _XkbSizeKeyActions(xkb,req)/4;
- req->length+= _XkbSizeKeyBehaviors(xkb,req)/4;
- szMods= _XkbSizeVirtualMods(req);
- req->length+= szMods/4;
- req->length+= _XkbSizeKeyExplicit(xkb,req)/4;
- req->length+= _XkbSizeModifierMap(xkb,req)/4;
- req->length+= _XkbSizeVirtualModMap(xkb,req)/4;
-
- tmp= *req;
- if ( tmp.nTypes>0 )
- _XkbWriteKeyTypes(dpy,xkb,&tmp);
- if ( tmp.nKeySyms>0 )
- _XkbWriteKeySyms(dpy,xkb,&tmp);
- if ( tmp.nKeyActs )
- _XkbWriteKeyActions(dpy,xkb,&tmp);
- if ( tmp.totalKeyBehaviors>0 )
- _XkbWriteKeyBehaviors(dpy,xkb,&tmp);
- if ( tmp.virtualMods )
- _XkbWriteVirtualMods(dpy,xkb,&tmp,szMods);
- if ( tmp.totalKeyExplicit>0)
- _XkbWriteKeyExplicit(dpy,xkb,&tmp);
- if ( tmp.totalModMapKeys>0)
- _XkbWriteModifierMap(dpy,xkb,&tmp);
- if ( tmp.totalVModMapKeys>0)
- _XkbWriteVirtualModMap(dpy,xkb,&tmp);
+ xkbSetMapReq tmp;
+ unsigned szMods;
+
+ req->length += _XkbSizeKeyTypes(xkb, req) / 4;
+ req->length += _XkbSizeKeySyms(xkb, req) / 4;
+ req->length += _XkbSizeKeyActions(xkb, req) / 4;
+ req->length += _XkbSizeKeyBehaviors(xkb, req) / 4;
+ szMods = _XkbSizeVirtualMods(req);
+ req->length += szMods / 4;
+ req->length += _XkbSizeKeyExplicit(xkb, req) / 4;
+ req->length += _XkbSizeModifierMap(xkb, req) / 4;
+ req->length += _XkbSizeVirtualModMap(xkb, req) / 4;
+
+ tmp = *req;
+ if (tmp.nTypes > 0)
+ _XkbWriteKeyTypes(dpy, xkb, &tmp);
+ if (tmp.nKeySyms > 0)
+ _XkbWriteKeySyms(dpy, xkb, &tmp);
+ if (tmp.nKeyActs)
+ _XkbWriteKeyActions(dpy, xkb, &tmp);
+ if (tmp.totalKeyBehaviors > 0)
+ _XkbWriteKeyBehaviors(dpy, xkb, &tmp);
+ if (tmp.virtualMods)
+ _XkbWriteVirtualMods(dpy, xkb, &tmp, szMods);
+ if (tmp.totalKeyExplicit > 0)
+ _XkbWriteKeyExplicit(dpy, xkb, &tmp);
+ if (tmp.totalModMapKeys > 0)
+ _XkbWriteModifierMap(dpy, xkb, &tmp);
+ if (tmp.totalVModMapKeys > 0)
+ _XkbWriteVirtualModMap(dpy, xkb, &tmp);
return;
}
Bool
-XkbSetMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+XkbSetMap(Display *dpy, unsigned which, XkbDescPtr xkb)
{
-register xkbSetMapReq * req;
-XkbInfoPtr xkbi;
-XkbServerMapPtr srv;
-XkbClientMapPtr map;
+ register xkbSetMapReq *req;
+ XkbInfoPtr xkbi;
+ XkbServerMapPtr srv;
+ XkbClientMapPtr map;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
- (!xkb))
- return False;
- map= xkb->map;
- srv= xkb->server;
-
- if (((which&XkbKeyTypesMask)&&((!map)||(!map->types)))||
- ((which&XkbKeySymsMask)&&((!map)||(!map->syms)||(!map->key_sym_map)))||
- ((which&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
- ((which&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
- ((which&XkbVirtualModsMask)&&(!srv))||
- ((which&XkbExplicitComponentsMask)&&((!srv)||(!srv->explicit)))||
- ((which&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
- ((which&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) || (!xkb))
+ return False;
+ map = xkb->map;
+ srv = xkb->server;
+
+ if (((which & XkbKeyTypesMask) && ((!map) || (!map->types))) ||
+ ((which & XkbKeySymsMask) &&
+ ((!map) || (!map->syms) || (!map->key_sym_map))) ||
+ ((which & XkbKeyActionsMask) && ((!srv) || (!srv->key_acts))) ||
+ ((which & XkbKeyBehaviorsMask) && ((!srv) || (!srv->behaviors))) ||
+ ((which & XkbVirtualModsMask) && (!srv)) ||
+ ((which & XkbExplicitComponentsMask) && ((!srv) || (!srv->explicit))) ||
+ ((which & XkbModifierMapMask) && ((!map) || (!map->modmap))) ||
+ ((which & XkbVirtualModMapMask) && ((!srv) || (!srv->vmodmap))))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
@@ -494,69 +498,73 @@ XkbClientMapPtr map;
req->deviceSpec = xkb->device_spec;
req->present = which;
req->flags = XkbSetMapAllFlags;
- req->minKeyCode= xkb->min_key_code;
- req->maxKeyCode= xkb->max_key_code;
+ req->minKeyCode = xkb->min_key_code;
+ req->maxKeyCode = xkb->max_key_code;
req->firstType = 0;
- if (which&XkbKeyTypesMask) req->nTypes = map->num_types;
- else req->nTypes = 0;
- if (which&XkbKeySymsMask) {
- req->firstKeySym = xkb->min_key_code;
- req->nKeySyms = XkbNumKeys(xkb);
+ if (which & XkbKeyTypesMask)
+ req->nTypes = map->num_types;
+ else
+ req->nTypes = 0;
+ if (which & XkbKeySymsMask) {
+ req->firstKeySym = xkb->min_key_code;
+ req->nKeySyms = XkbNumKeys(xkb);
}
- if (which&XkbKeyActionsMask) {
- req->firstKeyAct = xkb->min_key_code;
- req->nKeyActs = XkbNumKeys(xkb);
+ if (which & XkbKeyActionsMask) {
+ req->firstKeyAct = xkb->min_key_code;
+ req->nKeyActs = XkbNumKeys(xkb);
}
- if (which&XkbKeyBehaviorsMask) {
- req->firstKeyBehavior = xkb->min_key_code;
- req->nKeyBehaviors = XkbNumKeys(xkb);
+ if (which & XkbKeyBehaviorsMask) {
+ req->firstKeyBehavior = xkb->min_key_code;
+ req->nKeyBehaviors = XkbNumKeys(xkb);
}
- if (which&XkbVirtualModsMask)
- req->virtualMods= ~0;
- if (which&XkbExplicitComponentsMask) {
- req->firstKeyExplicit= xkb->min_key_code;
- req->nKeyExplicit = XkbNumKeys(xkb);
+ if (which & XkbVirtualModsMask)
+ req->virtualMods = ~0;
+ if (which & XkbExplicitComponentsMask) {
+ req->firstKeyExplicit = xkb->min_key_code;
+ req->nKeyExplicit = XkbNumKeys(xkb);
}
- if (which&XkbModifierMapMask) {
- req->firstModMapKey= xkb->min_key_code;
- req->nModMapKeys = XkbNumKeys(xkb);
+ if (which & XkbModifierMapMask) {
+ req->firstModMapKey = xkb->min_key_code;
+ req->nModMapKeys = XkbNumKeys(xkb);
}
- if (which&XkbVirtualModMapMask) {
- req->firstVModMapKey= xkb->min_key_code;
- req->nVModMapKeys = XkbNumKeys(xkb);
+ if (which & XkbVirtualModMapMask) {
+ req->firstVModMapKey = xkb->min_key_code;
+ req->nVModMapKeys = XkbNumKeys(xkb);
}
- SendSetMap(dpy,xkb,req);
+ SendSetMap(dpy, xkb, req);
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
-XkbChangeMap(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+XkbChangeMap(Display *dpy, XkbDescPtr xkb, XkbMapChangesPtr changes)
{
-register xkbSetMapReq * req;
-XkbInfoPtr xkbi;
-XkbServerMapPtr srv;
-XkbClientMapPtr map;
+ register xkbSetMapReq *req;
+ XkbInfoPtr xkbi;
+ XkbServerMapPtr srv;
+ XkbClientMapPtr map;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
- (!xkb)||(!changes))
- return False;
- srv= xkb->server;
- map= xkb->map;
-
- if (((changes->changed&XkbKeyTypesMask)&&((!map)||(!map->types)))||
- ((changes->changed&XkbKeySymsMask)&&((!map)||(!map->syms)||
- (!map->key_sym_map)))||
- ((changes->changed&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
- ((changes->changed&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
- ((changes->changed&XkbVirtualModsMask)&&(!srv))||
- ((changes->changed&XkbExplicitComponentsMask)&&
- ((!srv)||(!srv->explicit)))||
- ((changes->changed&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
- ((changes->changed&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)) ||
+ (!xkb) || (!changes))
+ return False;
+ srv = xkb->server;
+ map = xkb->map;
+
+ if (((changes->changed & XkbKeyTypesMask) && ((!map) || (!map->types))) ||
+ ((changes->changed & XkbKeySymsMask) && ((!map) || (!map->syms) ||
+ (!map->key_sym_map))) ||
+ ((changes->changed & XkbKeyActionsMask) && ((!srv) || (!srv->key_acts)))
+ || ((changes->changed & XkbKeyBehaviorsMask) &&
+ ((!srv) || (!srv->behaviors))) ||
+ ((changes->changed & XkbVirtualModsMask) && (!srv)) ||
+ ((changes->changed & XkbExplicitComponentsMask) &&
+ ((!srv) || (!srv->explicit))) ||
+ ((changes->changed & XkbModifierMapMask) && ((!map) || (!map->modmap)))
+ || ((changes->changed & XkbVirtualModMapMask) &&
+ ((!srv) || (!srv->vmodmap))))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
@@ -566,8 +574,8 @@ XkbClientMapPtr map;
req->deviceSpec = xkb->device_spec;
req->present = changes->changed;
req->flags = XkbSetMapRecomputeActions;
- req->minKeyCode= xkb->min_key_code;
- req->maxKeyCode= xkb->max_key_code;
+ req->minKeyCode = xkb->min_key_code;
+ req->maxKeyCode = xkb->max_key_code;
req->firstType = changes->first_type;
req->nTypes = changes->num_types;
req->firstKeySym = changes->first_key_sym;
@@ -583,9 +591,8 @@ XkbClientMapPtr map;
req->nModMapKeys = changes->num_modmap_keys;
req->firstVModMapKey = changes->first_vmodmap_key;
req->nVModMapKeys = changes->num_vmodmap_keys;
- SendSetMap(dpy,xkb,req);
+ SendSetMap(dpy, xkb, req);
UnlockDisplay(dpy);
SyncHandle();
return True;
}
-
diff --git a/nx-X11/lib/X11/XKBUse.c b/nx-X11/lib/X11/XKBUse.c
index 9ce60f12c..cf6497551 100644
--- a/nx-X11/lib/X11/XKBUse.c
+++ b/nx-X11/lib/X11/XKBUse.c
@@ -33,558 +33,552 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/extensions/XKBproto.h>
#include "XKBlibint.h"
-static Bool _XkbIgnoreExtension = False;
+static Bool _XkbIgnoreExtension = False;
void
-XkbNoteMapChanges(XkbMapChangesPtr old,XkbMapNotifyEvent *new,unsigned wanted)
+XkbNoteMapChanges(XkbMapChangesPtr old,
+ XkbMapNotifyEvent *new,
+ unsigned wanted)
{
- int first,oldLast,newLast;
- wanted&= new->changed;
-
- if (wanted&XkbKeyTypesMask) {
- if (old->changed&XkbKeyTypesMask) {
- first = old->first_type;
- oldLast = old->first_type+old->num_types-1;
- newLast = new->first_type+new->num_types-1;
-
- if (new->first_type<first)
- first = new->first_type;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_type = first;
- old->num_types = newLast-first+1;
- }
- else {
- old->first_type= new->first_type;
- old->num_types = new->num_types;
- }
- }
- if (wanted&XkbKeySymsMask) {
- if (old->changed&XkbKeySymsMask) {
- first = old->first_key_sym;
- oldLast = old->first_key_sym+old->num_key_syms-1;
- newLast = new->first_key_sym+new->num_key_syms-1;
-
- if (new->first_key_sym<first)
- first = new->first_key_sym;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_key_sym = first;
- old->num_key_syms = newLast-first+1;
- }
- else {
- old->first_key_sym = new->first_key_sym;
- old->num_key_syms = new->num_key_syms;
- }
- }
- if (wanted&XkbKeyActionsMask) {
- if (old->changed&XkbKeyActionsMask) {
- first = old->first_key_act;
- oldLast = old->first_key_act+old->num_key_acts-1;
- newLast = new->first_key_act+new->num_key_acts-1;
-
- if (new->first_key_act<first)
- first = new->first_key_act;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_key_act = first;
- old->num_key_acts = newLast-first+1;
- }
- else {
- old->first_key_act = new->first_key_act;
- old->num_key_acts = new->num_key_acts;
- }
- }
- if (wanted&XkbKeyBehaviorsMask) {
- if (old->changed&XkbKeyBehaviorsMask) {
- first = old->first_key_behavior;
- oldLast = old->first_key_behavior+old->num_key_behaviors-1;
- newLast = new->first_key_behavior+new->num_key_behaviors-1;
-
- if (new->first_key_behavior<first)
- first = new->first_key_behavior;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_key_behavior = first;
- old->num_key_behaviors = newLast-first+1;
- }
- else {
- old->first_key_behavior = new->first_key_behavior;
- old->num_key_behaviors = new->num_key_behaviors;
- }
- }
- if (wanted&XkbVirtualModsMask) {
- old->vmods|= new->vmods;
- }
- if (wanted&XkbExplicitComponentsMask) {
- if (old->changed&XkbExplicitComponentsMask) {
- first = old->first_key_explicit;
- oldLast = old->first_key_explicit+old->num_key_explicit-1;
- newLast = new->first_key_explicit+new->num_key_explicit-1;
-
- if (new->first_key_explicit<first)
- first = new->first_key_explicit;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_key_explicit = first;
- old->num_key_explicit = newLast-first+1;
- }
- else {
- old->first_key_explicit = new->first_key_explicit;
- old->num_key_explicit = new->num_key_explicit;
- }
- }
- if (wanted&XkbModifierMapMask) {
- if (old->changed&XkbModifierMapMask) {
- first = old->first_modmap_key;
- oldLast = old->first_modmap_key+old->num_modmap_keys-1;
- newLast = new->first_modmap_key+new->num_modmap_keys-1;
-
- if (new->first_modmap_key<first)
- first = new->first_modmap_key;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_modmap_key = first;
- old->num_modmap_keys = newLast-first+1;
- }
- else {
- old->first_modmap_key = new->first_modmap_key;
- old->num_modmap_keys = new->num_modmap_keys;
- }
- }
- if (wanted&XkbVirtualModMapMask) {
- if (old->changed&XkbVirtualModMapMask) {
- first = old->first_vmodmap_key;
- oldLast = old->first_vmodmap_key+old->num_vmodmap_keys-1;
- newLast = new->first_vmodmap_key+new->num_vmodmap_keys-1;
-
- if (new->first_vmodmap_key<first)
- first = new->first_vmodmap_key;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_vmodmap_key = first;
- old->num_vmodmap_keys = newLast-first+1;
- }
- else {
- old->first_vmodmap_key = new->first_vmodmap_key;
- old->num_vmodmap_keys = new->num_vmodmap_keys;
- }
- }
- old->changed|= wanted;
+ int first, oldLast, newLast;
+
+ wanted &= new->changed;
+
+ if (wanted & XkbKeyTypesMask) {
+ if (old->changed & XkbKeyTypesMask) {
+ first = old->first_type;
+ oldLast = old->first_type + old->num_types - 1;
+ newLast = new->first_type + new->num_types - 1;
+
+ if (new->first_type < first)
+ first = new->first_type;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_type = first;
+ old->num_types = newLast - first + 1;
+ }
+ else {
+ old->first_type = new->first_type;
+ old->num_types = new->num_types;
+ }
+ }
+ if (wanted & XkbKeySymsMask) {
+ if (old->changed & XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym + old->num_key_syms - 1;
+ newLast = new->first_key_sym + new->num_key_syms - 1;
+
+ if (new->first_key_sym < first)
+ first = new->first_key_sym;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast - first + 1;
+ }
+ else {
+ old->first_key_sym = new->first_key_sym;
+ old->num_key_syms = new->num_key_syms;
+ }
+ }
+ if (wanted & XkbKeyActionsMask) {
+ if (old->changed & XkbKeyActionsMask) {
+ first = old->first_key_act;
+ oldLast = old->first_key_act + old->num_key_acts - 1;
+ newLast = new->first_key_act + new->num_key_acts - 1;
+
+ if (new->first_key_act < first)
+ first = new->first_key_act;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_key_act = first;
+ old->num_key_acts = newLast - first + 1;
+ }
+ else {
+ old->first_key_act = new->first_key_act;
+ old->num_key_acts = new->num_key_acts;
+ }
+ }
+ if (wanted & XkbKeyBehaviorsMask) {
+ if (old->changed & XkbKeyBehaviorsMask) {
+ first = old->first_key_behavior;
+ oldLast = old->first_key_behavior + old->num_key_behaviors - 1;
+ newLast = new->first_key_behavior + new->num_key_behaviors - 1;
+
+ if (new->first_key_behavior < first)
+ first = new->first_key_behavior;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_key_behavior = first;
+ old->num_key_behaviors = newLast - first + 1;
+ }
+ else {
+ old->first_key_behavior = new->first_key_behavior;
+ old->num_key_behaviors = new->num_key_behaviors;
+ }
+ }
+ if (wanted & XkbVirtualModsMask) {
+ old->vmods |= new->vmods;
+ }
+ if (wanted & XkbExplicitComponentsMask) {
+ if (old->changed & XkbExplicitComponentsMask) {
+ first = old->first_key_explicit;
+ oldLast = old->first_key_explicit + old->num_key_explicit - 1;
+ newLast = new->first_key_explicit + new->num_key_explicit - 1;
+
+ if (new->first_key_explicit < first)
+ first = new->first_key_explicit;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_key_explicit = first;
+ old->num_key_explicit = newLast - first + 1;
+ }
+ else {
+ old->first_key_explicit = new->first_key_explicit;
+ old->num_key_explicit = new->num_key_explicit;
+ }
+ }
+ if (wanted & XkbModifierMapMask) {
+ if (old->changed & XkbModifierMapMask) {
+ first = old->first_modmap_key;
+ oldLast = old->first_modmap_key + old->num_modmap_keys - 1;
+ newLast = new->first_modmap_key + new->num_modmap_keys - 1;
+
+ if (new->first_modmap_key < first)
+ first = new->first_modmap_key;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_modmap_key = first;
+ old->num_modmap_keys = newLast - first + 1;
+ }
+ else {
+ old->first_modmap_key = new->first_modmap_key;
+ old->num_modmap_keys = new->num_modmap_keys;
+ }
+ }
+ if (wanted & XkbVirtualModMapMask) {
+ if (old->changed & XkbVirtualModMapMask) {
+ first = old->first_vmodmap_key;
+ oldLast = old->first_vmodmap_key + old->num_vmodmap_keys - 1;
+ newLast = new->first_vmodmap_key + new->num_vmodmap_keys - 1;
+
+ if (new->first_vmodmap_key < first)
+ first = new->first_vmodmap_key;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_vmodmap_key = first;
+ old->num_vmodmap_keys = newLast - first + 1;
+ }
+ else {
+ old->first_vmodmap_key = new->first_vmodmap_key;
+ old->num_vmodmap_keys = new->num_vmodmap_keys;
+ }
+ }
+ old->changed |= wanted;
return;
}
void
-_XkbNoteCoreMapChanges( XkbMapChangesPtr old,
- XMappingEvent * new,
- unsigned int wanted)
+_XkbNoteCoreMapChanges(XkbMapChangesPtr old,
+ XMappingEvent *new,
+ unsigned int wanted)
{
- int first,oldLast,newLast;
-
- if ((new->request==MappingKeyboard)&&(wanted&XkbKeySymsMask)) {
- if (old->changed&XkbKeySymsMask) {
- first = old->first_key_sym;
- oldLast = old->first_key_sym+old->num_key_syms-1;
- newLast = new->first_keycode+new->count-1;
-
- if (new->first_keycode<first)
- first = new->first_keycode;
- if (oldLast>newLast)
- newLast= oldLast;
- old->first_key_sym = first;
- old->num_key_syms = newLast-first+1;
- }
- else {
- old->changed|= XkbKeySymsMask;
- old->first_key_sym = new->first_keycode;
- old->num_key_syms = new->count;
- }
+ int first, oldLast, newLast;
+
+ if ((new->request == MappingKeyboard) && (wanted & XkbKeySymsMask)) {
+ if (old->changed & XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym + old->num_key_syms - 1;
+ newLast = new->first_keycode + new->count - 1;
+
+ if (new->first_keycode < first)
+ first = new->first_keycode;
+ if (oldLast > newLast)
+ newLast = oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast - first + 1;
+ }
+ else {
+ old->changed |= XkbKeySymsMask;
+ old->first_key_sym = new->first_keycode;
+ old->num_key_syms = new->count;
+ }
}
return;
}
static Bool
-wire_to_event(Display *dpy,XEvent *re,xEvent *event)
+wire_to_event(Display *dpy, XEvent *re, xEvent *event)
{
- xkbEvent *xkbevent= (xkbEvent *)event;
+ xkbEvent *xkbevent = (xkbEvent *) event;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
xkbi = dpy->xkb_info;
- if (((event->u.u.type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
- return False;
+ if (((event->u.u.type & 0x7f) - xkbi->codes->first_event) != XkbEventCode)
+ return False;
switch (xkbevent->u.any.xkbType) {
- case XkbStateNotify:
- {
- xkbStateNotify *sn = (xkbStateNotify *)event;
- if ( xkbi->selected_events&XkbStateNotifyMask ) {
- XkbStateNotifyEvent *sev=(XkbStateNotifyEvent *)re;
- sev->type = XkbEventCode+xkbi->codes->first_event;
- sev->xkb_type = XkbStateNotify;
- sev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- sev->send_event = ((event->u.u.type & 0x80) != 0);
- sev->display = dpy;
- sev->time = sn->time;
- sev->device = sn->deviceID;
- sev->keycode = sn->keycode;
- sev->event_type = sn->eventType;
- sev->req_major = sn->requestMajor;
- sev->req_minor = sn->requestMinor;
- sev->changed = sn->changed;
- sev->group = sn->group;
- sev->base_group = sn->baseGroup;
- sev->latched_group = sn->latchedGroup;
- sev->locked_group = sn->lockedGroup;
- sev->mods = sn->mods;
- sev->base_mods = sn->baseMods;
- sev->latched_mods = sn->latchedMods;
- sev->locked_mods = sn->lockedMods;
- sev->compat_state = sn->compatState;
- sev->grab_mods = sn->grabMods;
- sev->compat_grab_mods = sn->compatGrabMods;
- sev->lookup_mods = sn->lookupMods;
- sev->compat_lookup_mods = sn->compatLookupMods;
- sev->ptr_buttons = sn->ptrBtnState;
- return True;
- }
- }
- break;
- case XkbMapNotify:
- {
- xkbMapNotify *mn = (xkbMapNotify *)event;
- if ((xkbi->selected_events&XkbMapNotifyMask)&&
- (xkbi->selected_map_details&mn->changed)) {
- XkbMapNotifyEvent *mev;
- mev =(XkbMapNotifyEvent *)re;
- mev->type = XkbEventCode+xkbi->codes->first_event;
- mev->xkb_type = XkbMapNotify;
- mev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- mev->send_event = ((event->u.u.type&0x80)!=0);
- mev->display = dpy;
- mev->time = mn->time;
- mev->device = mn->deviceID;
- mev->changed = mn->changed;
- mev->min_key_code = mn->minKeyCode;
- mev->max_key_code = mn->maxKeyCode;
- mev->first_type = mn->firstType;
- mev->num_types = mn->nTypes;
- mev->first_key_sym = mn->firstKeySym;
- mev->num_key_syms = mn->nKeySyms;
- mev->first_key_act = mn->firstKeyAct;
- mev->num_key_acts = mn->nKeyActs;
- mev->first_key_behavior = mn->firstKeyBehavior;
- mev->num_key_behaviors = mn->nKeyBehaviors;
- mev->vmods = mn->virtualMods;
- mev->first_key_explicit = mn->firstKeyExplicit;
- mev->num_key_explicit = mn->nKeyExplicit;
- mev->first_modmap_key = mn->firstModMapKey;
- mev->num_modmap_keys = mn->nModMapKeys;
- mev->first_vmodmap_key = mn->firstVModMapKey;
- mev->num_vmodmap_keys = mn->nVModMapKeys;
- XkbNoteMapChanges(&xkbi->changes,mev,XKB_XLIB_MAP_MASK);
- if (xkbi->changes.changed)
- xkbi->flags|= XkbMapPending;
- return True;
- }
- else if (mn->nKeySyms>0) {
- register XMappingEvent *ev = (XMappingEvent *)re;
- ev->type = MappingNotify;
- ev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- ev->send_event = ((event->u.u.type&0x80)!=0);
- ev->display = dpy;
- ev->window = 0;
- ev->first_keycode = mn->firstKeySym;
- ev->request = MappingKeyboard;
- ev->count = mn->nKeySyms;
- _XkbNoteCoreMapChanges(&xkbi->changes,ev,XKB_XLIB_MAP_MASK);
- if (xkbi->changes.changed)
- xkbi->flags|= XkbMapPending;
- return True;
- }
- }
- break;
- case XkbControlsNotify:
- {
- if (xkbi->selected_events&XkbControlsNotifyMask) {
- xkbControlsNotify *cn =(xkbControlsNotify *)event;
- XkbControlsNotifyEvent *cev;
- cev =(XkbControlsNotifyEvent *)re;
- cev->type = XkbEventCode+xkbi->codes->first_event;
- cev->xkb_type = XkbControlsNotify;
- cev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- cev->send_event = ((event->u.u.type&0x80)!=0);
- cev->display = dpy;
- cev->time = cn->time;
- cev->device = cn->deviceID;
- cev->changed_ctrls = cn->changedControls;
- cev->enabled_ctrls = cn->enabledControls;
- cev->enabled_ctrl_changes = cn->enabledControlChanges;
- cev->keycode = cn->keycode;
- cev->num_groups = cn->numGroups;
- cev->event_type = cn->eventType;
- cev->req_major = cn->requestMajor;
- cev->req_minor = cn->requestMinor;
- return True;
- }
- }
- break;
- case XkbIndicatorMapNotify:
- {
- if (xkbi->selected_events&XkbIndicatorMapNotifyMask) {
- xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
- XkbIndicatorNotifyEvent *iev;
- iev =(XkbIndicatorNotifyEvent *)re;
- iev->type = XkbEventCode+xkbi->codes->first_event;
- iev->xkb_type = XkbIndicatorMapNotify;
- iev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- iev->send_event = ((event->u.u.type&0x80)!=0);
- iev->display = dpy;
- iev->time = in->time;
- iev->device = in->deviceID;
- iev->changed = in->changed;
- iev->state= in->state;
- return True;
- }
- }
- break;
- case XkbIndicatorStateNotify:
- {
- if (xkbi->selected_events&XkbIndicatorStateNotifyMask) {
- xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
- XkbIndicatorNotifyEvent *iev;
- iev =(XkbIndicatorNotifyEvent *)re;
- iev->type = XkbEventCode+xkbi->codes->first_event;
- iev->xkb_type = XkbIndicatorStateNotify;
- iev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- iev->send_event = ((event->u.u.type&0x80)!=0);
- iev->display = dpy;
- iev->time = in->time;
- iev->device = in->deviceID;
- iev->changed = in->changed;
- iev->state= in->state;
- return True;
- }
- }
- break;
- case XkbBellNotify:
- {
- if (xkbi->selected_events&XkbBellNotifyMask) {
- xkbBellNotify *bn =(xkbBellNotify *)event;
- XkbBellNotifyEvent *bev;
- bev =(XkbBellNotifyEvent *)re;
- bev->type = XkbEventCode+xkbi->codes->first_event;
- bev->xkb_type = XkbBellNotify;
- bev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- bev->send_event = ((event->u.u.type&0x80)!=0);
- bev->display = dpy;
- bev->time = bn->time;
- bev->device = bn->deviceID;
- bev->percent = bn->percent;
- bev->pitch = bn->pitch;
- bev->duration = bn->duration;
- bev->bell_class = bn->bellClass;
- bev->bell_id = bn->bellID;
- bev->name = bn->name;
- bev->window = bn->window;
- bev->event_only = bn->eventOnly;
- return True;
- }
- }
- break;
- case XkbAccessXNotify:
- {
- if (xkbi->selected_events&XkbAccessXNotifyMask) {
- xkbAccessXNotify *axn =(xkbAccessXNotify *)event;
- XkbAccessXNotifyEvent *axev;
- axev =(XkbAccessXNotifyEvent *)re;
- axev->type = XkbEventCode+xkbi->codes->first_event;
- axev->xkb_type = XkbAccessXNotify;
- axev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- axev->send_event = ((event->u.u.type&0x80)!=0);
- axev->display = dpy;
- axev->time = axn->time;
- axev->device = axn->deviceID;
- axev->detail = axn->detail;
- axev->keycode = axn->keycode;
- axev->sk_delay = axn->slowKeysDelay;
- axev->debounce_delay = axn->debounceDelay;
- return True;
- }
- }
- break;
- case XkbNamesNotify:
- {
- if (xkbi->selected_events&XkbNamesNotifyMask) {
- xkbNamesNotify *nn =(xkbNamesNotify *)event;
- XkbNamesNotifyEvent *nev;
- nev =(XkbNamesNotifyEvent *)re;
- nev->type = XkbEventCode+xkbi->codes->first_event;
- nev->xkb_type = XkbNamesNotify;
- nev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- nev->send_event = ((event->u.u.type&0x80)!=0);
- nev->display = dpy;
- nev->time = nn->time;
- nev->device = nn->deviceID;
- nev->changed = nn->changed;
- nev->first_type = nn->firstType;
- nev->num_types = nn->nTypes;
- nev->first_lvl = nn->firstLevelName;
- nev->num_lvls = nn->nLevelNames;
- nev->num_aliases = nn->nAliases;
- nev->num_radio_groups = nn->nRadioGroups;
- nev->changed_vmods = nn->changedVirtualMods;
- nev->changed_groups = nn->changedGroupNames;
- nev->changed_indicators = nn->changedIndicators;
- nev->first_key = nn->firstKey;
- nev->num_keys = nn->nKeys;
- return True;
- }
- }
- break;
- case XkbCompatMapNotify:
- {
- if (xkbi->selected_events&XkbCompatMapNotifyMask) {
- xkbCompatMapNotify *cmn =(xkbCompatMapNotify *)event;
- XkbCompatMapNotifyEvent *cmev;
- cmev =(XkbCompatMapNotifyEvent *)re;
- cmev->type = XkbEventCode+xkbi->codes->first_event;
- cmev->xkb_type = XkbCompatMapNotify;
- cmev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- cmev->send_event = ((event->u.u.type&0x80)!=0);
- cmev->display = dpy;
- cmev->time = cmn->time;
- cmev->device = cmn->deviceID;
- cmev->changed_groups = cmn->changedGroups;
- cmev->first_si = cmn->firstSI;
- cmev->num_si = cmn->nSI;
- cmev->num_total_si = cmn->nTotalSI;
- return True;
- }
- }
- break;
- case XkbActionMessage:
- {
- if (xkbi->selected_events&XkbActionMessageMask) {
- xkbActionMessage *am= (xkbActionMessage *)event;
- XkbActionMessageEvent *amev;
- amev= (XkbActionMessageEvent *)re;
- amev->type = XkbEventCode+xkbi->codes->first_event;
- amev->xkb_type = XkbActionMessage;
- amev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- amev->send_event = ((event->u.u.type&0x80)!=0);
- amev->display = dpy;
- amev->time = am->time;
- amev->device = am->deviceID;
- amev->keycode = am->keycode;
- amev->press = am->press;
- amev->key_event_follows = am->keyEventFollows;
- amev->group = am->group;
- amev->mods = am->mods;
- memcpy(amev->message,am->message,XkbActionMessageLength);
- amev->message[XkbActionMessageLength]= '\0';
- return True;
- }
- }
- break;
- case XkbExtensionDeviceNotify:
- {
- if (xkbi->selected_events&XkbExtensionDeviceNotifyMask) {
- xkbExtensionDeviceNotify *ed=
- (xkbExtensionDeviceNotify *)event;
- XkbExtensionDeviceNotifyEvent *edev;
- edev= (XkbExtensionDeviceNotifyEvent *)re;
- edev->type= XkbEventCode+xkbi->codes->first_event;
- edev->xkb_type= XkbExtensionDeviceNotify;
- edev->serial= _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- edev->send_event= ((event->u.u.type&0x80)!=0);
- edev->display= dpy;
- edev->time= ed->time;
- edev->device= ed->deviceID;
- edev->led_class= ed->ledClass;
- edev->led_id= ed->ledID;
- edev->reason= ed->reason;
- edev->supported= ed->supported;
- edev->leds_defined= ed->ledsDefined;
- edev->led_state= ed->ledState;
- edev->first_btn= ed->firstBtn;
- edev->num_btns= ed->nBtns;
- edev->unsupported= ed->unsupported;
- return True;
- }
- }
- break;
- case XkbNewKeyboardNotify:
- {
- xkbNewKeyboardNotify *nkn = (xkbNewKeyboardNotify *)event;
- if ((xkbi->selected_events&XkbNewKeyboardNotifyMask)&&
- (xkbi->selected_nkn_details&nkn->changed)) {
- XkbNewKeyboardNotifyEvent *nkev;
- nkev =(XkbNewKeyboardNotifyEvent *)re;
- nkev->type = XkbEventCode+xkbi->codes->first_event;
- nkev->xkb_type = XkbNewKeyboardNotify;
- nkev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- nkev->send_event = ((event->u.u.type&0x80)!=0);
- nkev->display = dpy;
- nkev->time = nkn->time;
- nkev->device = nkn->deviceID;
- nkev->old_device = nkn->oldDeviceID;
- nkev->min_key_code = nkn->minKeyCode;
- nkev->max_key_code = nkn->maxKeyCode;
- nkev->old_min_key_code = nkn->oldMinKeyCode;
- nkev->old_max_key_code = nkn->oldMaxKeyCode;
- nkev->req_major = nkn->requestMajor;
- nkev->req_minor = nkn->requestMinor;
- nkev->changed = nkn->changed;
- if ((xkbi->desc)&&(nkev->send_event==0)&&
- ((xkbi->desc->device_spec==nkev->old_device)||
- (nkev->device!=nkev->old_device))) {
- xkbi->flags= XkbMapPending|XkbXlibNewKeyboard;
- }
- return True;
- }
- else if(nkn->changed&(XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask)){
- register XMappingEvent *ev = (XMappingEvent *)re;
- ev->type = MappingNotify;
- ev->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- ev->send_event = ((event->u.u.type&0x80)!=0);
- ev->display = dpy;
- ev->window = 0;
- ev->first_keycode = dpy->min_keycode;
- ev->request = MappingKeyboard;
- ev->count = (dpy->max_keycode-dpy->min_keycode)+1;
- if ((xkbi->desc)&&(ev->send_event==0)&&
- ((xkbi->desc->device_spec==nkn->oldDeviceID)||
- (nkn->deviceID!=nkn->oldDeviceID))) {
- xkbi->flags|= XkbMapPending|XkbXlibNewKeyboard;
- }
- return True;
- }
- }
- break;
- default:
+ case XkbStateNotify:
+ {
+ xkbStateNotify *sn = (xkbStateNotify *) event;
+
+ if (xkbi->selected_events & XkbStateNotifyMask) {
+ XkbStateNotifyEvent *sev = (XkbStateNotifyEvent *) re;
+
+ sev->type = XkbEventCode + xkbi->codes->first_event;
+ sev->xkb_type = XkbStateNotify;
+ sev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ sev->send_event = ((event->u.u.type & 0x80) != 0);
+ sev->display = dpy;
+ sev->time = sn->time;
+ sev->device = sn->deviceID;
+ sev->keycode = sn->keycode;
+ sev->event_type = sn->eventType;
+ sev->req_major = sn->requestMajor;
+ sev->req_minor = sn->requestMinor;
+ sev->changed = sn->changed;
+ sev->group = sn->group;
+ sev->base_group = sn->baseGroup;
+ sev->latched_group = sn->latchedGroup;
+ sev->locked_group = sn->lockedGroup;
+ sev->mods = sn->mods;
+ sev->base_mods = sn->baseMods;
+ sev->latched_mods = sn->latchedMods;
+ sev->locked_mods = sn->lockedMods;
+ sev->compat_state = sn->compatState;
+ sev->grab_mods = sn->grabMods;
+ sev->compat_grab_mods = sn->compatGrabMods;
+ sev->lookup_mods = sn->lookupMods;
+ sev->compat_lookup_mods = sn->compatLookupMods;
+ sev->ptr_buttons = sn->ptrBtnState;
+ return True;
+ }
+ }
+ break;
+ case XkbMapNotify:
+ {
+ xkbMapNotify *mn = (xkbMapNotify *) event;
+
+ if ((xkbi->selected_events & XkbMapNotifyMask) &&
+ (xkbi->selected_map_details & mn->changed)) {
+ XkbMapNotifyEvent *mev = (XkbMapNotifyEvent *) re;
+
+ mev->type = XkbEventCode + xkbi->codes->first_event;
+ mev->xkb_type = XkbMapNotify;
+ mev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ mev->send_event = ((event->u.u.type & 0x80) != 0);
+ mev->display = dpy;
+ mev->time = mn->time;
+ mev->device = mn->deviceID;
+ mev->changed = mn->changed;
+ mev->min_key_code = mn->minKeyCode;
+ mev->max_key_code = mn->maxKeyCode;
+ mev->first_type = mn->firstType;
+ mev->num_types = mn->nTypes;
+ mev->first_key_sym = mn->firstKeySym;
+ mev->num_key_syms = mn->nKeySyms;
+ mev->first_key_act = mn->firstKeyAct;
+ mev->num_key_acts = mn->nKeyActs;
+ mev->first_key_behavior = mn->firstKeyBehavior;
+ mev->num_key_behaviors = mn->nKeyBehaviors;
+ mev->vmods = mn->virtualMods;
+ mev->first_key_explicit = mn->firstKeyExplicit;
+ mev->num_key_explicit = mn->nKeyExplicit;
+ mev->first_modmap_key = mn->firstModMapKey;
+ mev->num_modmap_keys = mn->nModMapKeys;
+ mev->first_vmodmap_key = mn->firstVModMapKey;
+ mev->num_vmodmap_keys = mn->nVModMapKeys;
+ XkbNoteMapChanges(&xkbi->changes, mev, XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags |= XkbMapPending;
+ return True;
+ }
+ else if (mn->nKeySyms > 0) {
+ register XMappingEvent *ev = (XMappingEvent *) re;
+
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ ev->send_event = ((event->u.u.type & 0x80) != 0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = mn->firstKeySym;
+ ev->request = MappingKeyboard;
+ ev->count = mn->nKeySyms;
+ _XkbNoteCoreMapChanges(&xkbi->changes, ev, XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags |= XkbMapPending;
+ return True;
+ }
+ }
+ break;
+ case XkbControlsNotify:
+ {
+ if (xkbi->selected_events & XkbControlsNotifyMask) {
+ xkbControlsNotify *cn = (xkbControlsNotify *) event;
+ XkbControlsNotifyEvent *cev = (XkbControlsNotifyEvent *) re;
+
+ cev->type = XkbEventCode + xkbi->codes->first_event;
+ cev->xkb_type = XkbControlsNotify;
+ cev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ cev->send_event = ((event->u.u.type & 0x80) != 0);
+ cev->display = dpy;
+ cev->time = cn->time;
+ cev->device = cn->deviceID;
+ cev->changed_ctrls = cn->changedControls;
+ cev->enabled_ctrls = cn->enabledControls;
+ cev->enabled_ctrl_changes = cn->enabledControlChanges;
+ cev->keycode = cn->keycode;
+ cev->num_groups = cn->numGroups;
+ cev->event_type = cn->eventType;
+ cev->req_major = cn->requestMajor;
+ cev->req_minor = cn->requestMinor;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorMapNotify:
+ {
+ if (xkbi->selected_events & XkbIndicatorMapNotifyMask) {
+ xkbIndicatorNotify *in = (xkbIndicatorNotify *) event;
+ XkbIndicatorNotifyEvent *iev = (XkbIndicatorNotifyEvent *) re;
+
+ iev->type = XkbEventCode + xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorMapNotify;
+ iev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ iev->send_event = ((event->u.u.type & 0x80) != 0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state = in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorStateNotify:
+ {
+ if (xkbi->selected_events & XkbIndicatorStateNotifyMask) {
+ xkbIndicatorNotify *in = (xkbIndicatorNotify *) event;
+ XkbIndicatorNotifyEvent *iev = (XkbIndicatorNotifyEvent *) re;
+
+ iev->type = XkbEventCode + xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorStateNotify;
+ iev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ iev->send_event = ((event->u.u.type & 0x80) != 0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state = in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbBellNotify:
+ {
+ if (xkbi->selected_events & XkbBellNotifyMask) {
+ xkbBellNotify *bn = (xkbBellNotify *) event;
+ XkbBellNotifyEvent *bev = (XkbBellNotifyEvent *) re;
+
+ bev->type = XkbEventCode + xkbi->codes->first_event;
+ bev->xkb_type = XkbBellNotify;
+ bev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ bev->send_event = ((event->u.u.type & 0x80) != 0);
+ bev->display = dpy;
+ bev->time = bn->time;
+ bev->device = bn->deviceID;
+ bev->percent = bn->percent;
+ bev->pitch = bn->pitch;
+ bev->duration = bn->duration;
+ bev->bell_class = bn->bellClass;
+ bev->bell_id = bn->bellID;
+ bev->name = bn->name;
+ bev->window = bn->window;
+ bev->event_only = bn->eventOnly;
+ return True;
+ }
+ }
+ break;
+ case XkbAccessXNotify:
+ {
+ if (xkbi->selected_events & XkbAccessXNotifyMask) {
+ xkbAccessXNotify *axn = (xkbAccessXNotify *) event;
+ XkbAccessXNotifyEvent *axev = (XkbAccessXNotifyEvent *) re;
+
+ axev->type = XkbEventCode + xkbi->codes->first_event;
+ axev->xkb_type = XkbAccessXNotify;
+ axev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ axev->send_event = ((event->u.u.type & 0x80) != 0);
+ axev->display = dpy;
+ axev->time = axn->time;
+ axev->device = axn->deviceID;
+ axev->detail = axn->detail;
+ axev->keycode = axn->keycode;
+ axev->sk_delay = axn->slowKeysDelay;
+ axev->debounce_delay = axn->debounceDelay;
+ return True;
+ }
+ }
+ break;
+ case XkbNamesNotify:
+ {
+ if (xkbi->selected_events & XkbNamesNotifyMask) {
+ xkbNamesNotify *nn = (xkbNamesNotify *) event;
+ XkbNamesNotifyEvent *nev = (XkbNamesNotifyEvent *) re;
+
+ nev->type = XkbEventCode + xkbi->codes->first_event;
+ nev->xkb_type = XkbNamesNotify;
+ nev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ nev->send_event = ((event->u.u.type & 0x80) != 0);
+ nev->display = dpy;
+ nev->time = nn->time;
+ nev->device = nn->deviceID;
+ nev->changed = nn->changed;
+ nev->first_type = nn->firstType;
+ nev->num_types = nn->nTypes;
+ nev->first_lvl = nn->firstLevelName;
+ nev->num_lvls = nn->nLevelNames;
+ nev->num_aliases = nn->nAliases;
+ nev->num_radio_groups = nn->nRadioGroups;
+ nev->changed_vmods = nn->changedVirtualMods;
+ nev->changed_groups = nn->changedGroupNames;
+ nev->changed_indicators = nn->changedIndicators;
+ nev->first_key = nn->firstKey;
+ nev->num_keys = nn->nKeys;
+ return True;
+ }
+ }
+ break;
+ case XkbCompatMapNotify:
+ {
+ if (xkbi->selected_events & XkbCompatMapNotifyMask) {
+ xkbCompatMapNotify *cmn = (xkbCompatMapNotify *) event;
+ XkbCompatMapNotifyEvent *cmev = (XkbCompatMapNotifyEvent *) re;
+
+ cmev->type = XkbEventCode + xkbi->codes->first_event;
+ cmev->xkb_type = XkbCompatMapNotify;
+ cmev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ cmev->send_event = ((event->u.u.type & 0x80) != 0);
+ cmev->display = dpy;
+ cmev->time = cmn->time;
+ cmev->device = cmn->deviceID;
+ cmev->changed_groups = cmn->changedGroups;
+ cmev->first_si = cmn->firstSI;
+ cmev->num_si = cmn->nSI;
+ cmev->num_total_si = cmn->nTotalSI;
+ return True;
+ }
+ }
+ break;
+ case XkbActionMessage:
+ {
+ if (xkbi->selected_events & XkbActionMessageMask) {
+ xkbActionMessage *am = (xkbActionMessage *) event;
+ XkbActionMessageEvent *amev = (XkbActionMessageEvent *) re;
+
+ amev->type = XkbEventCode + xkbi->codes->first_event;
+ amev->xkb_type = XkbActionMessage;
+ amev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ amev->send_event = ((event->u.u.type & 0x80) != 0);
+ amev->display = dpy;
+ amev->time = am->time;
+ amev->device = am->deviceID;
+ amev->keycode = am->keycode;
+ amev->press = am->press;
+ amev->key_event_follows = am->keyEventFollows;
+ amev->group = am->group;
+ amev->mods = am->mods;
+ memcpy(amev->message, am->message, XkbActionMessageLength);
+ amev->message[XkbActionMessageLength] = '\0';
+ return True;
+ }
+ }
+ break;
+ case XkbExtensionDeviceNotify:
+ {
+ if (xkbi->selected_events & XkbExtensionDeviceNotifyMask) {
+ xkbExtensionDeviceNotify *ed = (xkbExtensionDeviceNotify *) event;
+ XkbExtensionDeviceNotifyEvent *edev
+ = (XkbExtensionDeviceNotifyEvent *) re;
+
+ edev->type = XkbEventCode + xkbi->codes->first_event;
+ edev->xkb_type = XkbExtensionDeviceNotify;
+ edev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ edev->send_event = ((event->u.u.type & 0x80) != 0);
+ edev->display = dpy;
+ edev->time = ed->time;
+ edev->device = ed->deviceID;
+ edev->led_class = ed->ledClass;
+ edev->led_id = ed->ledID;
+ edev->reason = ed->reason;
+ edev->supported = ed->supported;
+ edev->leds_defined = ed->ledsDefined;
+ edev->led_state = ed->ledState;
+ edev->first_btn = ed->firstBtn;
+ edev->num_btns = ed->nBtns;
+ edev->unsupported = ed->unsupported;
+ return True;
+ }
+ }
+ break;
+ case XkbNewKeyboardNotify:
+ {
+ xkbNewKeyboardNotify *nkn = (xkbNewKeyboardNotify *) event;
+
+ if ((xkbi->selected_events & XkbNewKeyboardNotifyMask) &&
+ (xkbi->selected_nkn_details & nkn->changed)) {
+ XkbNewKeyboardNotifyEvent *nkev = (XkbNewKeyboardNotifyEvent *) re;
+
+ nkev->type = XkbEventCode + xkbi->codes->first_event;
+ nkev->xkb_type = XkbNewKeyboardNotify;
+ nkev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ nkev->send_event = ((event->u.u.type & 0x80) != 0);
+ nkev->display = dpy;
+ nkev->time = nkn->time;
+ nkev->device = nkn->deviceID;
+ nkev->old_device = nkn->oldDeviceID;
+ nkev->min_key_code = nkn->minKeyCode;
+ nkev->max_key_code = nkn->maxKeyCode;
+ nkev->old_min_key_code = nkn->oldMinKeyCode;
+ nkev->old_max_key_code = nkn->oldMaxKeyCode;
+ nkev->req_major = nkn->requestMajor;
+ nkev->req_minor = nkn->requestMinor;
+ nkev->changed = nkn->changed;
+ if ((xkbi->desc) && (nkev->send_event == 0) &&
+ ((xkbi->desc->device_spec == nkev->old_device) ||
+ (nkev->device != nkev->old_device))) {
+ xkbi->flags = XkbMapPending | XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ else if (nkn->changed & (XkbNKN_KeycodesMask | XkbNKN_DeviceIDMask)) {
+ register XMappingEvent *ev = (XMappingEvent *) re;
+
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+ ev->send_event = ((event->u.u.type & 0x80) != 0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = dpy->min_keycode;
+ ev->request = MappingKeyboard;
+ ev->count = (dpy->max_keycode - dpy->min_keycode) + 1;
+ if ((xkbi->desc) && (ev->send_event == 0) &&
+ ((xkbi->desc->device_spec == nkn->oldDeviceID) ||
+ (nkn->deviceID != nkn->oldDeviceID))) {
+ xkbi->flags |= XkbMapPending | XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ }
+ break;
+ default:
#ifdef DEBUG
- fprintf(stderr,"Got unknown XKEYBOARD event (%d, base=%d)\n",
- re->type,
- xkbi->codes->first_event);
+ fprintf(stderr, "Got unknown XKEYBOARD event (%d, base=%d)\n",
+ re->type, xkbi->codes->first_event);
#endif
- break;
+ break;
}
return False;
}
@@ -592,15 +586,17 @@ wire_to_event(Display *dpy,XEvent *re,xEvent *event)
Bool
XkbIgnoreExtension(Bool ignore)
{
- if (getenv("XKB_FORCE")!=NULL) {
+ if (getenv("XKB_FORCE") != NULL) {
#ifdef DEBUG
- fprintf(stderr,"Forcing use of XKEYBOARD (overriding an IgnoreExtensions)\n");
+ fprintf(stderr,
+ "Forcing use of XKEYBOARD (overriding an IgnoreExtensions)\n");
#endif
- return False;
+ return False;
}
#ifdef DEBUG
- else if (getenv("XKB_DEBUG")!=NULL) {
- fprintf(stderr,"Explicitly %signoring XKEYBOARD\n",ignore?"":"not ");
+ else if (getenv("XKB_DEBUG") != NULL) {
+ fprintf(stderr, "Explicitly %signoring XKEYBOARD\n",
+ ignore ? "" : "not ");
}
#endif
_XkbIgnoreExtension = ignore;
@@ -611,126 +607,142 @@ static void
_XkbFreeInfo(Display *dpy)
{
XkbInfoPtr xkbi = dpy->xkb_info;
+
if (xkbi) {
- if (xkbi->desc)
- XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
- Xfree(xkbi);
- }
+ if (xkbi->desc)
+ XkbFreeKeyboard(xkbi->desc, XkbAllComponentsMask, True);
+ Xfree(xkbi);
+ }
}
Bool
-XkbUseExtension(Display *dpy,int *major_rtrn,int *minor_rtrn)
+XkbUseExtension(Display *dpy, int *major_rtrn, int *minor_rtrn)
{
xkbUseExtensionReply rep;
register xkbUseExtensionReq *req;
- XExtCodes *codes;
- int ev_base,forceIgnore;
+ XExtCodes *codes;
+ int ev_base, forceIgnore;
XkbInfoPtr xkbi;
- char * str;
+ char *str;
static int debugMsg;
- static int been_here= 0;
-
- if ( dpy->xkb_info && !(dpy->flags & XlibDisplayNoXkb)) {
- if (major_rtrn) *major_rtrn= dpy->xkb_info->srv_major;
- if (minor_rtrn) *minor_rtrn= dpy->xkb_info->srv_minor;
- return True;
+ static int been_here = 0;
+
+ if (dpy->xkb_info && !(dpy->flags & XlibDisplayNoXkb)) {
+ if (major_rtrn)
+ *major_rtrn = dpy->xkb_info->srv_major;
+ if (minor_rtrn)
+ *minor_rtrn = dpy->xkb_info->srv_minor;
+ return True;
}
if (!been_here) {
- debugMsg= (getenv("XKB_DEBUG")!=NULL);
- been_here= 1;
+ debugMsg = (getenv("XKB_DEBUG") != NULL);
+ been_here = 1;
}
- if (major_rtrn) *major_rtrn= 0;
- if (minor_rtrn) *minor_rtrn= 0;
+ if (major_rtrn)
+ *major_rtrn = 0;
+ if (minor_rtrn)
+ *minor_rtrn = 0;
if (!dpy->xkb_info) {
xkbi = _XkbTypedCalloc(1, XkbInfoRec);
- if ( !xkbi )
- return False;
+ if (!xkbi)
+ return False;
dpy->xkb_info = xkbi;
dpy->free_funcs->xkb = _XkbFreeInfo;
- xkbi->xlib_ctrls|= (XkbLC_ControlFallback|XkbLC_ConsumeLookupMods);
- if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) {
- if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup;
- else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup;
- }
- if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods;
- else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods;
- }
- if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock;
- else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock;
- }
- if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards;
- else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards;
- }
- if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_ControlFallback;
- else xkbi->xlib_ctrls|= XkbLC_ControlFallback;
- }
- if ((str=getenv("_XKB_COMP_LED"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_ComposeLED;
- else {
- xkbi->xlib_ctrls|= XkbLC_ComposeLED;
- if (strlen(str)>0)
- xkbi->composeLED= XInternAtom(dpy,str,False);
- }
- }
- if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) {
- if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
- xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail;
- else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail;
- }
- }
- if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0))
- xkbi->composeLED= XInternAtom(dpy,"Compose",False);
+ xkbi->xlib_ctrls |= (XkbLC_ControlFallback | XkbLC_ConsumeLookupMods);
+ if ((str = getenv("_XKB_OPTIONS_ENABLE")) != NULL) {
+ if ((str = getenv("_XKB_LATIN1_LOOKUP")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_ForceLatin1Lookup;
+ else
+ xkbi->xlib_ctrls |= XkbLC_ForceLatin1Lookup;
+ }
+ if ((str = getenv("_XKB_CONSUME_LOOKUP_MODS")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_ConsumeLookupMods;
+ else
+ xkbi->xlib_ctrls |= XkbLC_ConsumeLookupMods;
+ }
+ if ((str = getenv("_XKB_CONSUME_SHIFT_AND_LOCK")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_AlwaysConsumeShiftAndLock;
+ else
+ xkbi->xlib_ctrls |= XkbLC_AlwaysConsumeShiftAndLock;
+ }
+ if ((str = getenv("_XKB_IGNORE_NEW_KEYBOARDS")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_IgnoreNewKeyboards;
+ else
+ xkbi->xlib_ctrls |= XkbLC_IgnoreNewKeyboards;
+ }
+ if ((str = getenv("_XKB_CONTROL_FALLBACK")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_ControlFallback;
+ else
+ xkbi->xlib_ctrls |= XkbLC_ControlFallback;
+ }
+ if ((str = getenv("_XKB_COMP_LED")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_ComposeLED;
+ else {
+ xkbi->xlib_ctrls |= XkbLC_ComposeLED;
+ if (strlen(str) > 0)
+ xkbi->composeLED = XInternAtom(dpy, str, False);
+ }
+ }
+ if ((str = getenv("_XKB_COMP_FAIL_BEEP")) != NULL) {
+ if ((strcmp(str, "off") == 0) || (strcmp(str, "0") == 0))
+ xkbi->xlib_ctrls &= ~XkbLC_BeepOnComposeFail;
+ else
+ xkbi->xlib_ctrls |= XkbLC_BeepOnComposeFail;
+ }
+ }
+ if ((xkbi->composeLED == None) &&
+ ((xkbi->xlib_ctrls & XkbLC_ComposeLED) != 0))
+ xkbi->composeLED = XInternAtom(dpy, "Compose", False);
#ifdef DEBUG
if (debugMsg) {
- register unsigned c= xkbi->xlib_ctrls;
- fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n",
- ((c&XkbLC_BeepOnComposeFail)?"on":"off"),
- ((c&XkbLC_ComposeLED)?"on":"off"));
- fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
- ((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "),
- ((c&XkbLC_ConsumeLookupMods)?"consume":"re-use"));
- fprintf(stderr,
- "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
- ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "),
- ((c&XkbLC_ControlFallback)?"":"no "));
+ register unsigned c = xkbi->xlib_ctrls;
+
+ fprintf(stderr,
+ "XKEYBOARD compose: beep on failure is %s, LED is %s\n",
+ ((c & XkbLC_BeepOnComposeFail) ? "on" : "off"),
+ ((c & XkbLC_ComposeLED) ? "on" : "off"));
+ fprintf(stderr,
+ "XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
+ ((c & XkbLC_ForceLatin1Lookup) ? "allow non-" : "force "),
+ ((c & XkbLC_ConsumeLookupMods) ? "consume" : "re-use"));
+ fprintf(stderr,
+ "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
+ ((c & XkbLC_AlwaysConsumeShiftAndLock) ? "always " :
+ "don't "), ((c & XkbLC_ControlFallback) ? "" : "no "));
}
#endif
- } else
+ }
+ else
xkbi = dpy->xkb_info;
- forceIgnore= (dpy->flags&XlibDisplayNoXkb)||dpy->keysyms;
- forceIgnore= forceIgnore&&(major_rtrn==NULL)&&(minor_rtrn==NULL);
- if ( forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) {
- LockDisplay(dpy);
- dpy->flags |= XlibDisplayNoXkb;
- UnlockDisplay(dpy);
- if (debugMsg)
- fprintf(stderr,"XKEYBOARD extension disabled or missing\n");
- return False;
- }
-
- if ( (codes=XInitExtension(dpy,XkbName))==NULL ) {
- LockDisplay(dpy);
- dpy->flags |= XlibDisplayNoXkb;
- UnlockDisplay(dpy);
- if (debugMsg)
- fprintf(stderr,"XKEYBOARD extension not present\n");
- return False;
+ forceIgnore = (dpy->flags & XlibDisplayNoXkb) || dpy->keysyms;
+ forceIgnore = forceIgnore && (major_rtrn == NULL) && (minor_rtrn == NULL);
+ if (forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ if (debugMsg)
+ fprintf(stderr, "XKEYBOARD extension disabled or missing\n");
+ return False;
+ }
+
+ if ((codes = XInitExtension(dpy, XkbName)) == NULL) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ if (debugMsg)
+ fprintf(stderr, "XKEYBOARD extension not present\n");
+ return False;
}
xkbi->codes = codes;
LockDisplay(dpy);
@@ -740,58 +752,63 @@ XkbUseExtension(Display *dpy,int *major_rtrn,int *minor_rtrn)
req->xkbReqType = X_kbUseExtension;
req->wantedMajor = XkbMajorVersion;
req->wantedMinor = XkbMinorVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.supported ) {
- Bool fail;
- fail= True;
- if (debugMsg)
- fprintf(stderr,
- "XKEYBOARD version mismatch (want %d.%02d, got %d.%02d)\n",
- XkbMajorVersion,XkbMinorVersion,
- rep.serverMajor, rep.serverMinor);
-
- /* pre-release 0.65 is very close to 1.00 */
- if ((rep.serverMajor==0)&&(rep.serverMinor==65)) {
- if (debugMsg)
- fprintf(stderr,"Trying to fall back to version 0.65...");
- GetReq(kbUseExtension, req);
- req->reqType = xkbi->codes->major_opcode;
- req->xkbReqType = X_kbUseExtension;
- req->wantedMajor = 0;
- req->wantedMinor = 65;
- if ( _XReply(dpy, (xReply *)&rep, 0, xFalse) && rep.supported ) {
- if (debugMsg)
- fprintf(stderr,"succeeded\n");
- fail= False;
- }
- else if (debugMsg) fprintf(stderr,"failed\n");
- }
- if (fail) {
- dpy->flags |= XlibDisplayNoXkb;
- UnlockDisplay(dpy);
- SyncHandle();
- if (major_rtrn) *major_rtrn= rep.serverMajor;
- if (minor_rtrn) *minor_rtrn= rep.serverMinor;
- return False;
- }
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse) || !rep.supported) {
+ Bool fail = True;
+
+ if (debugMsg)
+ fprintf(stderr,
+ "XKEYBOARD version mismatch (want %d.%02d, got %d.%02d)\n",
+ XkbMajorVersion, XkbMinorVersion,
+ rep.serverMajor, rep.serverMinor);
+
+ /* pre-release 0.65 is very close to 1.00 */
+ if ((rep.serverMajor == 0) && (rep.serverMinor == 65)) {
+ if (debugMsg)
+ fprintf(stderr, "Trying to fall back to version 0.65...");
+ GetReq(kbUseExtension, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbUseExtension;
+ req->wantedMajor = 0;
+ req->wantedMinor = 65;
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) && rep.supported) {
+ if (debugMsg)
+ fprintf(stderr, "succeeded\n");
+ fail = False;
+ }
+ else if (debugMsg)
+ fprintf(stderr, "failed\n");
+ }
+ if (fail) {
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (major_rtrn)
+ *major_rtrn = rep.serverMajor;
+ if (minor_rtrn)
+ *minor_rtrn = rep.serverMinor;
+ return False;
+ }
}
#ifdef DEBUG
- else if ( forceIgnore ) {
- fprintf(stderr,"Internal Error! XkbUseExtension succeeded with forceIgnore set\n");
+ else if (forceIgnore) {
+ fprintf(stderr,
+ "Internal Error! XkbUseExtension succeeded with forceIgnore set\n");
}
#endif
UnlockDisplay(dpy);
- xkbi->srv_major= rep.serverMajor;
- xkbi->srv_minor= rep.serverMinor;
- if (major_rtrn) *major_rtrn= rep.serverMajor;
- if (minor_rtrn) *minor_rtrn= rep.serverMinor;
+ xkbi->srv_major = rep.serverMajor;
+ xkbi->srv_minor = rep.serverMinor;
+ if (major_rtrn)
+ *major_rtrn = rep.serverMajor;
+ if (minor_rtrn)
+ *minor_rtrn = rep.serverMinor;
if (debugMsg)
- fprintf(stderr,"XKEYBOARD (version %d.%02d/%d.%02d) OK!\n",
- XkbMajorVersion,XkbMinorVersion,
- rep.serverMajor,rep.serverMinor);
+ fprintf(stderr, "XKEYBOARD (version %d.%02d/%d.%02d) OK!\n",
+ XkbMajorVersion, XkbMinorVersion,
+ rep.serverMajor, rep.serverMinor);
ev_base = codes->first_event;
- XESetWireToEvent(dpy,ev_base+XkbEventCode,wire_to_event);
+ XESetWireToEvent(dpy, ev_base + XkbEventCode, wire_to_event);
SyncHandle();
return True;
}
-
diff --git a/nx-X11/lib/X11/XKBleds.c b/nx-X11/lib/X11/XKBleds.c
index 6c1b46140..c098ee948 100644
--- a/nx-X11/lib/X11/XKBleds.c
+++ b/nx-X11/lib/X11/XKBleds.c
@@ -33,159 +33,163 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "XKBlibint.h"
Status
-XkbGetIndicatorState(Display *dpy,unsigned deviceSpec,unsigned *pStateRtrn)
+XkbGetIndicatorState(Display *dpy, unsigned deviceSpec, unsigned *pStateRtrn)
{
register xkbGetIndicatorStateReq *req;
- xkbGetIndicatorStateReply rep;
+ xkbGetIndicatorStateReply rep;
XkbInfoPtr xkbi;
Bool ok;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetIndicatorState, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetIndicatorState;
req->deviceSpec = deviceSpec;
- ok=_XReply(dpy, (xReply *)&rep, 0, xFalse);
- if (ok && (pStateRtrn!=NULL))
- *pStateRtrn= rep.state;
+ ok = _XReply(dpy, (xReply *) &rep, 0, xFalse);
+ if (ok && (pStateRtrn != NULL))
+ *pStateRtrn = rep.state;
UnlockDisplay(dpy);
SyncHandle();
- return (ok?Success:BadImplementation);
+ return (ok ? Success : BadImplementation);
}
Status
-_XkbReadGetIndicatorMapReply( Display * dpy,
- xkbGetIndicatorMapReply * rep,
- XkbDescPtr xkb,
- int * nread_rtrn)
+_XkbReadGetIndicatorMapReply(Display *dpy,
+ xkbGetIndicatorMapReply *rep,
+ XkbDescPtr xkb,
+ int *nread_rtrn)
{
-XkbIndicatorPtr leds;
-XkbReadBufferRec buf;
+ XkbIndicatorPtr leds;
+ XkbReadBufferRec buf;
- if ((!xkb->indicators)&&(XkbAllocIndicatorMaps(xkb)!=Success))
- return BadAlloc;
- leds= xkb->indicators;
+ if ((!xkb->indicators) && (XkbAllocIndicatorMaps(xkb) != Success))
+ return BadAlloc;
+ leds = xkb->indicators;
leds->phys_indicators = rep->realIndicators;
- if (rep->length>0) {
- register int left;
- if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
- return BadAlloc;
- if (nread_rtrn)
- *nread_rtrn= (int)rep->length*4;
- if (rep->which) {
- register int i,bit;
- left= (int)rep->which;
- for (i=0,bit=1;(i<XkbNumIndicators)&&(left);i++,bit<<=1) {
- if (left&bit) {
- xkbIndicatorMapWireDesc *wire;
- wire= (xkbIndicatorMapWireDesc *)
- _XkbGetReadBufferPtr(&buf,
- SIZEOF(xkbIndicatorMapWireDesc));
- if (wire==NULL) {
- _XkbFreeReadBuffer(&buf);
- return BadAlloc;
- }
- leds->maps[i].flags= wire->flags;
- leds->maps[i].which_groups= wire->whichGroups;
- leds->maps[i].groups= wire->groups;
- leds->maps[i].which_mods= wire->whichMods;
- leds->maps[i].mods.mask= wire->mods;
- leds->maps[i].mods.real_mods= wire->realMods;
- leds->maps[i].mods.vmods= wire->virtualMods;
- leds->maps[i].ctrls= wire->ctrls;
- left&= ~bit;
- }
- }
- }
- left= _XkbFreeReadBuffer(&buf);
+ if (rep->length > 0) {
+ register int left;
+
+ if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4))
+ return BadAlloc;
+ if (nread_rtrn)
+ *nread_rtrn = (int) rep->length * 4;
+ if (rep->which) {
+ register int i, bit;
+
+ left = (int) rep->which;
+ for (i = 0, bit = 1; (i < XkbNumIndicators) && (left);
+ i++, bit <<= 1) {
+ if (left & bit) {
+ xkbIndicatorMapWireDesc *wire;
+
+ wire = (xkbIndicatorMapWireDesc *)
+ _XkbGetReadBufferPtr(&buf,
+ SIZEOF(xkbIndicatorMapWireDesc));
+ if (wire == NULL) {
+ _XkbFreeReadBuffer(&buf);
+ return BadAlloc;
+ }
+ leds->maps[i].flags = wire->flags;
+ leds->maps[i].which_groups = wire->whichGroups;
+ leds->maps[i].groups = wire->groups;
+ leds->maps[i].which_mods = wire->whichMods;
+ leds->maps[i].mods.mask = wire->mods;
+ leds->maps[i].mods.real_mods = wire->realMods;
+ leds->maps[i].mods.vmods = wire->virtualMods;
+ leds->maps[i].ctrls = wire->ctrls;
+ left &= ~bit;
+ }
+ }
+ }
+ left = _XkbFreeReadBuffer(&buf);
}
return Success;
}
Bool
-XkbGetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+XkbGetIndicatorMap(Display *dpy, unsigned long which, XkbDescPtr xkb)
{
- register xkbGetIndicatorMapReq * req;
- xkbGetIndicatorMapReply rep;
- XkbInfoPtr xkbi;
- Status status;
+ register xkbGetIndicatorMapReq *req;
+ xkbGetIndicatorMapReply rep;
+ XkbInfoPtr xkbi;
+ Status status;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return BadAccess;
- if ((!which)||(!xkb))
- return BadValue;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return BadAccess;
+ if ((!which) || (!xkb))
+ return BadValue;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
if (!xkb->indicators) {
- xkb->indicators = _XkbTypedCalloc(1,XkbIndicatorRec);
- if (!xkb->indicators) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadAlloc;
- }
+ xkb->indicators = _XkbTypedCalloc(1, XkbIndicatorRec);
+ if (!xkb->indicators) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
}
GetReq(kbGetIndicatorMap, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbGetIndicatorMap;
req->deviceSpec = xkb->device_spec;
- req->which = (CARD32)which;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadValue;
+ req->which = (CARD32) which;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadValue;
}
- status= _XkbReadGetIndicatorMapReply(dpy,&rep,xkb,NULL);
+ status = _XkbReadGetIndicatorMapReply(dpy, &rep, xkb, NULL);
UnlockDisplay(dpy);
SyncHandle();
return status;
}
Bool
-XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+XkbSetIndicatorMap(Display *dpy, unsigned long which, XkbDescPtr xkb)
{
- register xkbSetIndicatorMapReq *req;
- register int i,bit;
+ register xkbSetIndicatorMapReq *req;
+ register int i, bit;
int nMaps;
xkbIndicatorMapWireDesc *wire;
XkbInfoPtr xkbi;
if ((dpy->flags & XlibDisplayNoXkb) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
- if ((!xkb)||(!which)||(!xkb->indicators))
- return False;
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
+ if ((!xkb) || (!which) || (!xkb->indicators))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetIndicatorMap, req);
req->reqType = xkbi->codes->major_opcode;
req->xkbReqType = X_kbSetIndicatorMap;
req->deviceSpec = xkb->device_spec;
- req->which = (CARD32)which;
- for (i=nMaps=0,bit=1;i<32;i++,bit<<=1) {
- if (which&bit)
- nMaps++;
+ req->which = (CARD32) which;
+ for (i = nMaps = 0, bit = 1; i < 32; i++, bit <<= 1) {
+ if (which & bit)
+ nMaps++;
}
- req->length+= (nMaps*sizeof(XkbIndicatorMapRec))/4;
- BufAlloc(xkbIndicatorMapWireDesc *,wire,
- (nMaps*SIZEOF(xkbIndicatorMapWireDesc)));
- for (i=0,bit=1;i<32;i++,bit<<=1) {
- if (which&bit) {
- wire->flags= xkb->indicators->maps[i].flags;
- wire->whichGroups= xkb->indicators->maps[i].which_groups;
- wire->groups= xkb->indicators->maps[i].groups;
- wire->whichMods= xkb->indicators->maps[i].which_mods;
- wire->mods= xkb->indicators->maps[i].mods.real_mods;
- wire->virtualMods= xkb->indicators->maps[i].mods.vmods;
- wire->ctrls= xkb->indicators->maps[i].ctrls;
- wire++;
- }
+ req->length += (nMaps * sizeof(XkbIndicatorMapRec)) / 4;
+ BufAlloc(xkbIndicatorMapWireDesc *, wire,
+ (nMaps * SIZEOF(xkbIndicatorMapWireDesc)));
+ for (i = 0, bit = 1; i < 32; i++, bit <<= 1) {
+ if (which & bit) {
+ wire->flags = xkb->indicators->maps[i].flags;
+ wire->whichGroups = xkb->indicators->maps[i].which_groups;
+ wire->groups = xkb->indicators->maps[i].groups;
+ wire->whichMods = xkb->indicators->maps[i].which_mods;
+ wire->mods = xkb->indicators->maps[i].mods.real_mods;
+ wire->virtualMods = xkb->indicators->maps[i].mods.vmods;
+ wire->ctrls = xkb->indicators->maps[i].ctrls;
+ wire++;
+ }
}
UnlockDisplay(dpy);
SyncHandle();
@@ -193,23 +197,23 @@ XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
}
Bool
-XkbGetNamedDeviceIndicator( Display * dpy,
- unsigned device,
- unsigned class,
- unsigned id,
- Atom name,
- int * pNdxRtrn,
- Bool * pStateRtrn,
- XkbIndicatorMapPtr pMapRtrn,
- Bool * pRealRtrn)
+XkbGetNamedDeviceIndicator(Display *dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ int *pNdxRtrn,
+ Bool *pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool *pRealRtrn)
{
register xkbGetNamedIndicatorReq *req;
- xkbGetNamedIndicatorReply rep;
+ xkbGetNamedIndicatorReply rep;
XkbInfoPtr xkbi;
- if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ if ((dpy->flags & XlibDisplayNoXkb) || (name == None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbGetNamedIndicator, req);
@@ -218,66 +222,66 @@ XkbGetNamedDeviceIndicator( Display * dpy,
req->deviceSpec = device;
req->ledClass = class;
req->ledID = id;
- req->indicator = (CARD32)name;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
+ req->indicator = (CARD32) name;
+ if (!_XReply(dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
}
UnlockDisplay(dpy);
SyncHandle();
- if ((!rep.found)||(!rep.supported))
- return False;
- if (pNdxRtrn!=NULL)
- *pNdxRtrn= rep.ndx;
- if (pStateRtrn!=NULL)
- *pStateRtrn= rep.on;
- if (pMapRtrn!=NULL) {
- pMapRtrn->flags= rep.flags;
- pMapRtrn->which_groups= rep.whichGroups;
- pMapRtrn->groups= rep.groups;
- pMapRtrn->which_mods= rep.whichMods;
- pMapRtrn->mods.mask= rep.mods;
- pMapRtrn->mods.real_mods= rep.realMods;
- pMapRtrn->mods.vmods= rep.virtualMods;
- pMapRtrn->ctrls= rep.ctrls;
+ if ((!rep.found) || (!rep.supported))
+ return False;
+ if (pNdxRtrn != NULL)
+ *pNdxRtrn = rep.ndx;
+ if (pStateRtrn != NULL)
+ *pStateRtrn = rep.on;
+ if (pMapRtrn != NULL) {
+ pMapRtrn->flags = rep.flags;
+ pMapRtrn->which_groups = rep.whichGroups;
+ pMapRtrn->groups = rep.groups;
+ pMapRtrn->which_mods = rep.whichMods;
+ pMapRtrn->mods.mask = rep.mods;
+ pMapRtrn->mods.real_mods = rep.realMods;
+ pMapRtrn->mods.vmods = rep.virtualMods;
+ pMapRtrn->ctrls = rep.ctrls;
}
- if (pRealRtrn!=NULL)
- *pRealRtrn= rep.realIndicator;
+ if (pRealRtrn != NULL)
+ *pRealRtrn = rep.realIndicator;
return True;
}
Bool
-XkbGetNamedIndicator( Display * dpy,
- Atom name,
- int * pNdxRtrn,
- Bool * pStateRtrn,
- XkbIndicatorMapPtr pMapRtrn,
- Bool * pRealRtrn)
+XkbGetNamedIndicator(Display *dpy,
+ Atom name,
+ int *pNdxRtrn,
+ Bool *pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool *pRealRtrn)
{
- return XkbGetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
- XkbDfltXIClass,XkbDfltXIId,
- name,pNdxRtrn,pStateRtrn,
- pMapRtrn,pRealRtrn);
+ return XkbGetNamedDeviceIndicator(dpy, XkbUseCoreKbd,
+ XkbDfltXIClass, XkbDfltXIId,
+ name, pNdxRtrn, pStateRtrn,
+ pMapRtrn, pRealRtrn);
}
Bool
-XkbSetNamedDeviceIndicator( Display * dpy,
- unsigned device,
- unsigned class,
- unsigned id,
- Atom name,
- Bool changeState,
- Bool state,
- Bool createNewMap,
- XkbIndicatorMapPtr pMap)
+XkbSetNamedDeviceIndicator(Display *dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
{
- register xkbSetNamedIndicatorReq *req;
+ register xkbSetNamedIndicatorReq *req;
XkbInfoPtr xkbi;
- if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
- (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
- return False;
+ if ((dpy->flags & XlibDisplayNoXkb) || (name == None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
+ return False;
LockDisplay(dpy);
xkbi = dpy->xkb_info;
GetReq(kbSetNamedIndicator, req);
@@ -286,32 +290,33 @@ XkbSetNamedDeviceIndicator( Display * dpy,
req->deviceSpec = device;
req->ledClass = class;
req->ledID = id;
- req->indicator= (CARD32)name;
- req->setState= changeState;
+ req->indicator = (CARD32) name;
+ req->setState = changeState;
if (req->setState)
- req->on= state;
- else req->on= False;
- if (pMap!=NULL) {
- req->setMap= True;
- req->createMap= createNewMap;
- req->flags= pMap->flags;
- req->whichGroups= pMap->which_groups;
- req->groups= pMap->groups;
- req->whichMods= pMap->which_mods;
- req->realMods= pMap->mods.real_mods;
- req->virtualMods= pMap->mods.vmods;
- req->ctrls= pMap->ctrls;
+ req->on = state;
+ else
+ req->on = False;
+ if (pMap != NULL) {
+ req->setMap = True;
+ req->createMap = createNewMap;
+ req->flags = pMap->flags;
+ req->whichGroups = pMap->which_groups;
+ req->groups = pMap->groups;
+ req->whichMods = pMap->which_mods;
+ req->realMods = pMap->mods.real_mods;
+ req->virtualMods = pMap->mods.vmods;
+ req->ctrls = pMap->ctrls;
}
else {
- req->setMap= False;
- req->createMap= False;
- req->flags= 0;
- req->whichGroups= 0;
- req->groups= 0;
- req->whichMods= 0;
- req->realMods= 0;
- req->virtualMods= 0;
- req->ctrls= 0;
+ req->setMap = False;
+ req->createMap = False;
+ req->flags = 0;
+ req->whichGroups = 0;
+ req->groups = 0;
+ req->whichMods = 0;
+ req->realMods = 0;
+ req->virtualMods = 0;
+ req->ctrls = 0;
}
UnlockDisplay(dpy);
SyncHandle();
@@ -319,15 +324,15 @@ XkbSetNamedDeviceIndicator( Display * dpy,
}
Bool
-XkbSetNamedIndicator( Display * dpy,
- Atom name,
- Bool changeState,
- Bool state,
- Bool createNewMap,
- XkbIndicatorMapPtr pMap)
+XkbSetNamedIndicator(Display *dpy,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
{
- return XkbSetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
- XkbDfltXIClass,XkbDfltXIId,
- name,changeState,state,
- createNewMap,pMap);
+ return XkbSetNamedDeviceIndicator(dpy, XkbUseCoreKbd,
+ XkbDfltXIClass, XkbDfltXIId,
+ name, changeState, state,
+ createNewMap, pMap);
}
diff --git a/nx-X11/lib/X11/XKBlibint.h b/nx-X11/lib/X11/XKBlibint.h
index 34cdf9aaf..dad48b703 100644
--- a/nx-X11/lib/X11/XKBlibint.h
+++ b/nx-X11/lib/X11/XKBlibint.h
@@ -25,216 +25,210 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
#ifndef _XKBLIBINT_H_
-#define _XKBLIBINT_H_
+#define _XKBLIBINT_H_
#include <nx-X11/Xutil.h>
#include <nx-X11/XKBlib.h>
-#define XkbMapPending (1<<0)
-#define XkbXlibNewKeyboard (1<<1)
+#define XkbMapPending (1<<0)
+#define XkbXlibNewKeyboard (1<<1)
-typedef int (*XkbKSToMBFunc)(
- XPointer /* priv */,
- KeySym /* sym */,
- char * /* buf */,
- int /* len */,
- int * /* extra_rtrn */
+typedef int (*XkbKSToMBFunc)(
+ XPointer /* priv */,
+ KeySym /* sym */,
+ char * /* buf */,
+ int /* len */,
+ int * /* extra_rtrn */
);
-typedef KeySym (*XkbMBToKSFunc)(
- XPointer /* priv */,
- char * /* buf */,
- int /* len */,
- Status * /* status */
+typedef KeySym (*XkbMBToKSFunc)(
+ XPointer /* priv */,
+ char * /* buf */,
+ int /* len */,
+ Status * /* status */
);
-typedef KeySym (*XkbToUpperFunc)(
- KeySym /* sym */
+typedef KeySym (*XkbToUpperFunc)(
+ KeySym /* sym */
);
typedef struct _XkbConverters {
- XkbKSToMBFunc KSToMB;
- XPointer KSToMBPriv;
- XkbMBToKSFunc MBToKS;
- XPointer MBToKSPriv;
- XkbToUpperFunc KSToUpper;
+ XkbKSToMBFunc KSToMB;
+ XPointer KSToMBPriv;
+ XkbMBToKSFunc MBToKS;
+ XPointer MBToKSPriv;
+ XkbToUpperFunc KSToUpper;
} XkbConverters;
-extern XkbInternAtomFunc _XkbInternAtomFunc;
-extern XkbGetAtomNameFunc _XkbGetAtomNameFunc;
+extern XkbInternAtomFunc _XkbInternAtomFunc;
+extern XkbGetAtomNameFunc _XkbGetAtomNameFunc;
typedef struct _XkbInfoRec {
- unsigned flags;
- unsigned xlib_ctrls;
- XExtCodes *codes;
- int srv_major;
- int srv_minor;
- unsigned selected_events;
- unsigned short selected_nkn_details;
- unsigned short selected_map_details;
- XkbDescRec *desc;
- XkbMapChangesRec changes;
- Atom composeLED;
- XkbConverters cvt;
- XkbConverters latin1cvt;
+ unsigned flags;
+ unsigned xlib_ctrls;
+ XExtCodes *codes;
+ int srv_major;
+ int srv_minor;
+ unsigned selected_events;
+ unsigned short selected_nkn_details;
+ unsigned short selected_map_details;
+ XkbDescRec *desc;
+ XkbMapChangesRec changes;
+ Atom composeLED;
+ XkbConverters cvt;
+ XkbConverters latin1cvt;
} XkbInfoRec, *XkbInfoPtr;
-#define _XkbUnavailable(d) \
- (((d)->flags&XlibDisplayNoXkb) ||\
- ((!(d)->xkb_info || (!(d)->xkb_info->desc)) && !_XkbLoadDpy(d)))
-
-#define _XkbCheckPendingRefresh(d,xi) {\
- if ((xi)->flags&XkbXlibNewKeyboard)\
- _XkbReloadDpy((d));\
- else if ((xi)->flags&XkbMapPending) {\
- if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) {\
- LockDisplay((d));\
- (xi)->changes.changed= 0;\
- UnlockDisplay((d));\
- }\
- }\
+#define _XkbUnavailable(d) \
+ (((d)->flags&XlibDisplayNoXkb) || \
+ ((!(d)->xkb_info || (!(d)->xkb_info->desc)) && !_XkbLoadDpy(d)))
+
+#define _XkbCheckPendingRefresh(d,xi) { \
+ if ((xi)->flags&XkbXlibNewKeyboard) \
+ _XkbReloadDpy((d)); \
+ else if ((xi)->flags&XkbMapPending) { \
+ if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) { \
+ LockDisplay((d)); \
+ (xi)->changes.changed= 0; \
+ UnlockDisplay((d)); \
+ } \
+ } \
}
-#define _XkbNeedModmap(i) ((!(i)->desc->map)||(!(i)->desc->map->modmap))
+#define _XkbNeedModmap(i) ((!(i)->desc->map)||(!(i)->desc->map->modmap))
- /*
- * mask of the events that the "invisible" XKB support in Xlib needs
- */
+ /*
+ * mask of the events that the "invisible" XKB support in Xlib needs
+ */
#define XKB_XLIB_MAP_MASK (XkbAllClientInfoMask)
- /*
- * Handy helper macros
- */
-#define XKB_INSURE_SIZE(f,t,nNum,oNum) {\
- if ((f)==NULL) \
- (f)=(t *)Xmalloc(sizeof(t)*(nNum));\
- else if ((nNum)<(oNum))\
- (f)=(t *)Xrealloc((f),sizeof(t)*(nNum));\
- }
+ /*
+ * Handy helper macros
+ */
typedef struct _XkbReadBuffer {
- int error;
- int size;
- char *start;
- char *data;
-} XkbReadBufferRec,*XkbReadBufferPtr;
-
-#define _XkbAlloc(s) Xmalloc((s))
-#define _XkbCalloc(n,s) Xcalloc((n),(s))
-#define _XkbRealloc(o,s) Xrealloc((o),(s))
-#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
-#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
-#define _XkbTypedRealloc(o,n,t) \
- ((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
-#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
-#define _XkbFree(p) Xfree(p)
+ int error;
+ int size;
+ char *start;
+ char *data;
+} XkbReadBufferRec, *XkbReadBufferPtr;
+
+#define _XkbAlloc(s) Xmalloc((s))
+#define _XkbCalloc(n,s) Xcalloc((n),(s))
+#define _XkbRealloc(o,s) Xrealloc((o),(s))
+#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
+#define _XkbTypedRealloc(o,n,t) \
+ ((o) ? (t *)Xrealloc((o), (n)*sizeof(t)) : _XkbTypedCalloc(n,t))
+#define _XkbClearElems(a,f,l,t) bzero(&(a)[f], ((l)-(f)+1) * sizeof(t))
+#define _XkbFree(p) Xfree(p)
_XFUNCPROTOBEGIN
-extern void _XkbReloadDpy(
- Display * /* dpy */
+extern void _XkbReloadDpy(
+ Display * /* dpy */
);
extern KeySym _XKeycodeToKeysym(
- Display* /* display */,
+ Display * /* display */,
#if NeedWidePrototypes
- unsigned int /* keycode */,
+ unsigned int /* keycode */,
#else
- KeyCode /* keycode */,
+ KeyCode /* keycode */,
#endif
- int /* index */
+ int /* index */
);
extern KeyCode _XKeysymToKeycode(
- Display* /* display */,
- KeySym /* keysym */
+ Display * /* display */,
+ KeySym /* keysym */
);
extern KeySym _XLookupKeysym(
- XKeyEvent* /* key_event */,
- int /* index */
+ XKeyEvent * /* key_event */,
+ int /* index */
);
extern int _XRefreshKeyboardMapping(
- XMappingEvent* /* event_map */
+ XMappingEvent * /* event_map */
);
-extern unsigned _XKeysymToModifiers(
- Display * /* dpy */,
- KeySym /* ks */
+extern unsigned _XKeysymToModifiers(
+ Display * /* dpy */,
+ KeySym /* ks */
);
extern int _XTranslateKey(
- register Display * /* dpy */,
- KeyCode /* keycode */,
+ register Display * /* dpy */,
+ KeyCode /* keycode */,
register unsigned int /* modifiers */,
- unsigned int * /* modifiers_return */,
- KeySym * /* keysym_return */
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
);
-extern int _XTranslateKeySym(
- Display * /* dpy */,
- register KeySym /* symbol */,
- unsigned int /* modifiers */,
- char * /* buffer */,
- int /* nbytes */
+extern int _XTranslateKeySym(
+ Display * /* dpy */,
+ register KeySym /* symbol */,
+ unsigned int /* modifiers */,
+ char * /* buffer */,
+ int /* nbytes */
);
-extern int _XLookupString(
- register XKeyEvent * /* event */,
- char * /* buffer */,
- int /* nbytes */,
- KeySym * /* keysym */,
- XComposeStatus * /* status */
+extern int _XLookupString(
+ register XKeyEvent * /* event */,
+ char * /* buffer */,
+ int /* nbytes */,
+ KeySym * /* keysym */,
+ XComposeStatus * /* status */
);
extern void _XkbNoteCoreMapChanges(
- XkbMapChangesRec * /* old */,
- XMappingEvent * /* new */,
- unsigned int /* wanted */
+ XkbMapChangesRec * /* old */,
+ XMappingEvent * /* new */,
+ unsigned int /* wanted */
);
-extern int _XkbInitReadBuffer(
- Display * /* dpy */,
- XkbReadBufferPtr /* buf */,
- int /* size */
+extern int _XkbInitReadBuffer(
+ Display * /* dpy */,
+ XkbReadBufferPtr /* buf */,
+ int /* size */
);
extern int _XkbSkipReadBufferData(
- XkbReadBufferPtr /* from */,
- int /* size */
+ XkbReadBufferPtr /* from */,
+ int /* size */
);
extern int _XkbCopyFromReadBuffer(
- XkbReadBufferPtr /* from */,
- char * /* to */,
- int /* size */
+ XkbReadBufferPtr /* from */,
+ char * /* to */,
+ int /* size */
);
-#if defined(LONG64)
-extern int _XkbReadCopyData32(
- int * /* from */,
- long * /* to */,
- int /* num_words */
+#ifdef LONG64
+extern int _XkbReadCopyData32(
+ int * /* from */,
+ long * /* to */,
+ int /* num_words */
);
-extern int _XkbWriteCopyData32(
- unsigned long * /* from */,
- CARD32 * /* to */,
- int /* num_words */
+extern int _XkbWriteCopyData32(
+ unsigned long * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
);
extern int _XkbReadBufferCopy32(
- XkbReadBufferPtr /* from */,
- long * /* to */,
- int /* size */
+ XkbReadBufferPtr /* from */,
+ long * /* to */,
+ int /* size */
);
#else
-#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
-#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
-#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f,(char *)t,(s)*4)
+#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t), (char *)(f), (s)*4)
+#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t), (char *)(f), (s)*4)
+#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f, (char *)t, (s)*4)
#endif
#ifndef NO_DEC_BINARY_COMPATIBILITY
@@ -243,97 +237,97 @@ extern int _XkbReadBufferCopy32(
#ifdef XKB_FORCE_INT_KEYSYM
extern int _XkbReadCopyKeySyms(
- int * /* from */,
- KeySym * /* to */,
- int /* num_words */
+ int * /* from */,
+ KeySym * /* to */,
+ int /* num_words */
);
-extern int _XkbWriteCopyKeySyms(
- KeySym * /* from */,
- CARD32 * /* to */,
- int /* num_words */
+extern int _XkbWriteCopyKeySyms(
+ KeySym * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
);
extern int _XkbReadBufferCopyKeySyms(
- XkbReadBufferPtr /* from */,
+ XkbReadBufferPtr /* from */,
#ifndef NO_DEC_BUG_FIX
- KeySym * /* to */,
+ KeySym * /* to */,
#else
- long * /* to */,
+ long * /* to */,
#endif
- int /* size */
+ int /* size */
);
#else
-#define _XkbReadCopyKeySyms(f,t,n) _XkbReadCopyData32(f,t,n)
-#define _XkbWriteCopyKeySyms(f,t,n) _XkbWriteCopyData32(f,t,n)
-#define _XkbReadBufferCopyKeySyms(f,t,s) _XkbReadBufferCopy32(f,t,s)
+#define _XkbReadCopyKeySyms(f,t,n) _XkbReadCopyData32(f,t,n)
+#define _XkbWriteCopyKeySyms(f,t,n) _XkbWriteCopyData32(f,t,n)
+#define _XkbReadBufferCopyKeySyms(f,t,s) _XkbReadBufferCopy32(f,t,s)
#endif
extern char *_XkbPeekAtReadBuffer(
- XkbReadBufferPtr /* from */,
- int /* size */
+ XkbReadBufferPtr /* from */,
+ int /* size */
);
extern char *_XkbGetReadBufferPtr(
- XkbReadBufferPtr /* from */,
- int /* size */
+ XkbReadBufferPtr /* from */,
+ int /* size */
);
-#define _XkbGetTypedRdBufPtr(b,n,t) ((t *)_XkbGetReadBufferPtr(b,(n)*SIZEOF(t)))
+#define _XkbGetTypedRdBufPtr(b,n,t) ((t *)_XkbGetReadBufferPtr(b,(n)*SIZEOF(t)))
extern int _XkbFreeReadBuffer(
- XkbReadBufferPtr /* buf */
+ XkbReadBufferPtr /* buf */
);
extern Bool
_XkbGetReadBufferCountedString(
- XkbReadBufferPtr /* buf */,
- char ** /* rtrn */
+ XkbReadBufferPtr /* buf */,
+ char ** /* rtrn */
);
-extern char *_XkbGetCharset(
+extern char *_XkbGetCharset(
void
);
-extern int _XkbGetConverters(
+extern int _XkbGetConverters(
const char * /* encoding_name */,
XkbConverters * /* cvt_rtrn */
);
-#ifdef NEED_MAP_READERS
+#ifdef NEED_MAP_READERS
-extern Status _XkbReadGetMapReply(
- Display * /* dpy */,
- xkbGetMapReply * /* rep */,
- XkbDescRec * /* xkb */,
- int * /* nread_rtrn */
+extern Status _XkbReadGetMapReply(
+ Display * /* dpy */,
+ xkbGetMapReply * /* rep */,
+ XkbDescRec * /* xkb */,
+ int * /* nread_rtrn */
);
-extern Status _XkbReadGetCompatMapReply(
- Display * /* dpy */,
- xkbGetCompatMapReply * /* rep */,
- XkbDescPtr /* xkb */,
- int * /* nread_rtrn */
+extern Status _XkbReadGetCompatMapReply(
+ Display * /* dpy */,
+ xkbGetCompatMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
);
-extern Status _XkbReadGetIndicatorMapReply(
- Display * /* dpy */,
- xkbGetIndicatorMapReply * /* rep */,
- XkbDescPtr /* xkb */,
- int * /* nread_rtrn */
+extern Status _XkbReadGetIndicatorMapReply(
+ Display * /* dpy */,
+ xkbGetIndicatorMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
);
-extern Status _XkbReadGetNamesReply(
- Display * /* dpy */,
- xkbGetNamesReply * /* rep */,
- XkbDescPtr /* xkb */,
- int * /* nread_rtrn */
+extern Status _XkbReadGetNamesReply(
+ Display * /* dpy */,
+ xkbGetNamesReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
);
-extern Status _XkbReadGetGeometryReply(
- Display * /* dpy */,
- xkbGetGeometryReply * /* rep */,
- XkbDescPtr /* xkb */,
- int * /* nread_rtrn */
+extern Status _XkbReadGetGeometryReply(
+ Display * /* dpy */,
+ xkbGetGeometryReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
);
#endif
diff --git a/nx-X11/lib/X11/XKeysymDB b/nx-X11/lib/X11/XKeysymDB
deleted file mode 100644
index cdd639955..000000000
--- a/nx-X11/lib/X11/XKeysymDB
+++ /dev/null
@@ -1,382 +0,0 @@
-! Copyright 1993 Massachusetts Institute of Technology
-!
-! 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 M.I.T. not be used in advertising or
-! publicity pertaining to distribution of the software without specific,
-! written prior permission. M.I.T. makes no representations about the
-! suitability of this software for any purpose. It is provided "as is"
-! without express or implied warranty.
-!
-
-hpmute_acute :100000A8
-hpmute_grave :100000A9
-hpmute_asciicircum :100000AA
-hpmute_diaeresis :100000AB
-hpmute_asciitilde :100000AC
-hplira :100000AF
-hpguilder :100000BE
-hpYdiaeresis :100000EE
-hpIO :100000EE
-hplongminus :100000F6
-hpblock :100000FC
-apLineDel :1000FF00
-apCharDel :1000FF01
-apCopy :1000FF02
-apCut :1000FF03
-apPaste :1000FF04
-apMove :1000FF05
-apGrow :1000FF06
-apCmd :1000FF07
-apShell :1000FF08
-apLeftBar :1000FF09
-apRightBar :1000FF0A
-apLeftBox :1000FF0B
-apRightBox :1000FF0C
-apUpBox :1000FF0D
-apDownBox :1000FF0E
-apPop :1000FF0F
-apRead :1000FF10
-apEdit :1000FF11
-apSave :1000FF12
-apExit :1000FF13
-apRepeat :1000FF14
-hpModelock1 :1000FF48
-hpModelock2 :1000FF49
-hpReset :1000FF6C
-hpSystem :1000FF6D
-hpUser :1000FF6E
-hpClearLine :1000FF6F
-hpInsertLine :1000FF70
-hpDeleteLine :1000FF71
-hpInsertChar :1000FF72
-hpDeleteChar :1000FF73
-hpBackTab :1000FF74
-hpKP_BackTab :1000FF75
-apKP_parenleft :1000FFA8
-apKP_parenright :1000FFA9
-
-I2ND_FUNC_L :10004001
-I2ND_FUNC_R :10004002
-IREMOVE :10004003
-IREPEAT :10004004
-IA1 :10004101
-IA2 :10004102
-IA3 :10004103
-IA4 :10004104
-IA5 :10004105
-IA6 :10004106
-IA7 :10004107
-IA8 :10004108
-IA9 :10004109
-IA10 :1000410A
-IA11 :1000410B
-IA12 :1000410C
-IA13 :1000410D
-IA14 :1000410E
-IA15 :1000410F
-IB1 :10004201
-IB2 :10004202
-IB3 :10004203
-IB4 :10004204
-IB5 :10004205
-IB6 :10004206
-IB7 :10004207
-IB8 :10004208
-IB9 :10004209
-IB10 :1000420A
-IB11 :1000420B
-IB12 :1000420C
-IB13 :1000420D
-IB14 :1000420E
-IB15 :1000420F
-IB16 :10004210
-
-DRemove :1000FF00
-Dring_accent :1000FEB0
-Dcircumflex_accent :1000FE5E
-Dcedilla_accent :1000FE2C
-Dacute_accent :1000FE27
-Dgrave_accent :1000FE60
-Dtilde :1000FE7E
-Ddiaeresis :1000FE22
-
-osfCopy :1004FF02
-osfCut :1004FF03
-osfPaste :1004FF04
-osfBackTab :1004FF07
-osfBackSpace :1004FF08
-osfClear :1004FF0B
-osfEscape :1004FF1B
-osfAddMode :1004FF31
-osfPrimaryPaste :1004FF32
-osfQuickPaste :1004FF33
-osfPageLeft :1004FF40
-osfPageUp :1004FF41
-osfPageDown :1004FF42
-osfPageRight :1004FF43
-osfActivate :1004FF44
-osfMenuBar :1004FF45
-osfLeft :1004FF51
-osfUp :1004FF52
-osfRight :1004FF53
-osfDown :1004FF54
-osfPrior :1004FF55
-osfNext :1004FF56
-osfEndLine :1004FF57
-osfBeginLine :1004FF58
-osfEndData :1004FF59
-osfBeginData :1004FF5A
-osfPrevMenu :1004FF5B
-osfNextMenu :1004FF5C
-osfPrevField :1004FF5D
-osfNextField :1004FF5E
-osfSelect :1004FF60
-osfInsert :1004FF63
-osfUndo :1004FF65
-osfMenu :1004FF67
-osfCancel :1004FF69
-osfHelp :1004FF6A
-osfSelectAll :1004FF71
-osfDeselectAll :1004FF72
-osfReselect :1004FF73
-osfExtend :1004FF74
-osfRestore :1004FF78
-osfSwitchDirection :1004FF7E
-osfPriorMinor :1004FFF5
-osfNextMinor :1004FFF6
-osfRightLine :1004FFF7
-osfLeftLine :1004FFF8
-osfDelete :1004FFFF
-
-SunFA_Grave :1005FF00
-SunFA_Circum :1005FF01
-SunFA_Tilde :1005FF02
-SunFA_Acute :1005FF03
-SunFA_Diaeresis :1005FF04
-SunFA_Cedilla :1005FF05
-SunF36 :1005FF10
-SunF37 :1005FF11
-SunSys_Req :1005FF60
-SunProps :1005FF70
-SunFront :1005FF71
-SunCopy :1005FF72
-SunOpen :1005FF73
-SunPaste :1005FF74
-SunCut :1005FF75
-SunPowerSwitch :1005FF76
-SunAudioLowerVolume :1005FF77
-SunAudioMute :1005FF78
-SunAudioRaiseVolume :1005FF79
-SunVideoDegauss :1005FF7A
-SunVideoLowerBrightness :1005FF7B
-SunVideoRaiseBrightness :1005FF7C
-SunPowerSwitchShift :1005FF7D
-
-SunCompose :FF20
-SunPageUp :FF55
-SunPageDown :FF56
-SunPrint_Screen :FF61
-SunUndo :FF65
-SunAgain :FF66
-SunFind :FF68
-SunStop :FF69
-SunAltGraph :FF7E
-
-WYSetup :1006FF00
-
-ncdSetup :1006FF00
-
-XeroxPointerButton1 :10070001
-XeroxPointerButton2 :10070002
-XeroxPointerButton3 :10070003
-XeroxPointerButton4 :10070004
-XeroxPointerButton5 :10070005
-
-! The definitions here should match <X11/XF86keysym.h>
-XF86ModeLock :1008FF01
-XF86MonBrightnessUp :1008FF02
-XF86MonBrightnessDown :1008FF03
-XF86KbdLightOnOff :1008FF04
-XF86KbdBrightnessUp :1008FF05
-XF86KbdBrightnessDown :1008FF06
-XF86Standby :1008FF10
-XF86AudioLowerVolume :1008FF11
-XF86AudioMute :1008FF12
-XF86AudioRaiseVolume :1008FF13
-XF86AudioPlay :1008FF14
-XF86AudioStop :1008FF15
-XF86AudioPrev :1008FF16
-XF86AudioNext :1008FF17
-XF86HomePage :1008FF18
-XF86Mail :1008FF19
-XF86Start :1008FF1A
-XF86Search :1008FF1B
-XF86AudioRecord :1008FF1C
-XF86Calculator :1008FF1D
-XF86Memo :1008FF1E
-XF86ToDoList :1008FF1F
-XF86Calendar :1008FF20
-XF86PowerDown :1008FF21
-XF86ContrastAdjust :1008FF22
-XF86RockerUp :1008FF23
-XF86RockerDown :1008FF24
-XF86RockerEnter :1008FF25
-XF86Back :1008FF26
-XF86Forward :1008FF27
-XF86Stop :1008FF28
-XF86Refresh :1008FF29
-XF86PowerOff :1008FF2A
-XF86WakeUp :1008FF2B
-XF86Eject :1008FF2C
-XF86ScreenSaver :1008FF2D
-XF86WWW :1008FF2E
-XF86Sleep :1008FF2F
-XF86Favorites :1008FF30
-XF86AudioPause :1008FF31
-XF86AudioMedia :1008FF32
-XF86MyComputer :1008FF33
-XF86VendorHome :1008FF34
-XF86LightBulb :1008FF35
-XF86Shop :1008FF36
-XF86History :1008FF37
-XF86OpenURL :1008FF38
-XF86AddFavorite :1008FF39
-XF86HotLinks :1008FF3A
-XF86BrightnessAdjust :1008FF3B
-XF86Finance :1008FF3C
-XF86Community :1008FF3D
-XF86AudioRewind :1008FF3E
-XF86BackForward :1008FF3F
-XF86Launch0 :1008FF40
-XF86Launch1 :1008FF41
-XF86Launch2 :1008FF42
-XF86Launch3 :1008FF43
-XF86Launch4 :1008FF44
-XF86Launch5 :1008FF45
-XF86Launch6 :1008FF46
-XF86Launch7 :1008FF47
-XF86Launch8 :1008FF48
-XF86Launch9 :1008FF49
-XF86LaunchA :1008FF4A
-XF86LaunchB :1008FF4B
-XF86LaunchC :1008FF4C
-XF86LaunchD :1008FF4D
-XF86LaunchE :1008FF4E
-XF86LaunchF :1008FF4F
-XF86ApplicationLeft :1008FF50
-XF86ApplicationRight :1008FF51
-XF86Book :1008FF52
-XF86CD :1008FF53
-XF86Calculater :1008FF54
-XF86Clear :1008FF55
-XF86Close :1008FF56
-XF86Copy :1008FF57
-XF86Cut :1008FF58
-XF86Display :1008FF59
-XF86DOS :1008FF5A
-XF86Documents :1008FF5B
-XF86Excel :1008FF5C
-XF86Explorer :1008FF5D
-XF86Game :1008FF5E
-XF86Go :1008FF5F
-XF86iTouch :1008FF60
-XF86LogOff :1008FF61
-XF86Market :1008FF62
-XF86Meeting :1008FF63
-XF86MenuKB :1008FF65
-XF86MenuPB :1008FF66
-XF86MySites :1008FF67
-XF86New :1008FF68
-XF86News :1008FF69
-XF86OfficeHome :1008FF6A
-XF86Open :1008FF6B
-XF86Option :1008FF6C
-XF86Paste :1008FF6D
-XF86Phone :1008FF6E
-XF86Q :1008FF70
-XF86Reply :1008FF72
-XF86Reload :1008FF73
-XF86RotateWindows :1008FF74
-XF86RotationPB :1008FF75
-XF86RotationKB :1008FF76
-XF86Save :1008FF77
-XF86ScrollUp :1008FF78
-XF86ScrollDown :1008FF79
-XF86ScrollClick :1008FF7A
-XF86Send :1008FF7B
-XF86Spell :1008FF7C
-XF86SplitScreen :1008FF7D
-XF86Support :1008FF7E
-XF86TaskPane :1008FF7F
-XF86Terminal :1008FF80
-XF86Tools :1008FF81
-XF86Travel :1008FF82
-XF86UserPB :1008FF84
-XF86User1KB :1008FF85
-XF86User2KB :1008FF86
-XF86Video :1008FF87
-XF86WheelButton :1008FF88
-XF86Word :1008FF89
-XF86Xfer :1008FF8A
-XF86ZoomIn :1008FF8B
-XF86ZoomOut :1008FF8C
-XF86Away :1008FF8D
-XF86Messenger :1008FF8E
-XF86WebCam :1008FF8F
-XF86MailForward :1008FF90
-XF86Pictures :1008FF91
-XF86Music :1008FF92
-XF86Battery :1008FF93
-XF86Bluetooth :1008FF94
-XF86WLAN :1008FF95
-XF86UWB :1008FF96
-XF86AudioForward :1008FF97
-XF86AudioRepeat :1008FF98
-XF86AudioRandomPlay :1008FF99
-XF86Subtitle :1008FF9A
-XF86AudioCycleTrack :1008FF9B
-XF86CycleAngle :1008FF9C
-XF86FrameBack :1008FF9D
-XF86FrameForward :1008FF9E
-XF86Time :1008FF9F
-XF86Select :1008FFA0
-XF86View :1008FFA1
-XF86TopMenu :1008FFA2
-XF86Red :1008FFA3
-XF86Green :1008FFA4
-XF86Yellow :1008FFA5
-XF86Blue :1008FFA6
-XF86Suspend :1008FFA7
-XF86Hibernate :1008FFA8
-XF86TouchpadToggle :1008FFA9
-XF86TouchpadOn :1008FFB0
-XF86TouchpadOff :1008FFB1
-
-! XFree86 special action keys
-XF86_Switch_VT_1 :1008FE01
-XF86_Switch_VT_2 :1008FE02
-XF86_Switch_VT_3 :1008FE03
-XF86_Switch_VT_4 :1008FE04
-XF86_Switch_VT_5 :1008FE05
-XF86_Switch_VT_6 :1008FE06
-XF86_Switch_VT_7 :1008FE07
-XF86_Switch_VT_8 :1008FE08
-XF86_Switch_VT_9 :1008FE09
-XF86_Switch_VT_10 :1008FE0A
-XF86_Switch_VT_11 :1008FE0B
-XF86_Switch_VT_12 :1008FE0C
-XF86_Ungrab :1008FE20
-XF86_ClearGrab :1008FE21
-XF86_Next_VMode :1008FE22
-XF86_Prev_VMode :1008FE23
-
-usldead_acute :100000A8
-usldead_grave :100000A9
-usldead_diaeresis :100000AB
-usldead_asciicircum :100000AA
-usldead_asciitilde :100000AC
-usldead_cedilla :1000FE2C
-usldead_ring :1000FEB0
diff --git a/nx-X11/lib/X11/XYZ.c b/nx-X11/lib/X11/XYZ.c
index 1245622b7..826565773 100644
--- a/nx-X11/lib/X11/XYZ.c
+++ b/nx-X11/lib/X11/XYZ.c
@@ -120,13 +120,13 @@ CIEXYZ_ParseString(
* RETURNS
*/
{
- int n;
+ size_t n;
char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure);
}
- n = (int)(pchar - spec);
+ n = (size_t)(pchar - spec);
/*
* Check for proper prefix.
diff --git a/nx-X11/lib/X11/Xcms.h b/nx-X11/lib/X11/Xcms.h
index 7f7c1553a..3b0410533 100644
--- a/nx-X11/lib/X11/Xcms.h
+++ b/nx-X11/lib/X11/Xcms.h
@@ -32,6 +32,14 @@
#include <nx-X11/Xlib.h>
+/* The Xcms structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
/*
* XCMS Status Values
*/
@@ -799,6 +807,10 @@ extern Visual *XcmsVisualOfCCC (
XcmsCCC /* ccc */
);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
_XFUNCPROTOEND
#endif /* !defined(_X11_XCMS_H_) && !defined(_XCMS_H_) */
diff --git a/nx-X11/lib/X11/XimTrInt.h b/nx-X11/lib/X11/XimTrInt.h
index b7e4439d2..bceab9886 100644
--- a/nx-X11/lib/X11/XimTrInt.h
+++ b/nx-X11/lib/X11/XimTrInt.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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"),
@@ -73,7 +73,7 @@ extern Bool _XimXConf(
char *address
);
-#if defined(TCPCONN) || defined(UNIXCONN) || defined(DNETCONN) || defined(STREAMSCONN)
+#if defined(TCPCONN) || defined(UNIXCONN)
extern Bool _XimTransConf(
Xim im,
diff --git a/nx-X11/lib/X11/XimTrX.h b/nx-X11/lib/X11/XimTrX.h
index 1c24fe368..198d5fa5f 100644
--- a/nx-X11/lib/X11/XimTrX.h
+++ b/nx-X11/lib/X11/XimTrX.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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/nx-X11/lib/X11/XimTrans.h b/nx-X11/lib/X11/XimTrans.h
index 987b5ee33..8c3aa829a 100644
--- a/nx-X11/lib/X11/XimTrans.h
+++ b/nx-X11/lib/X11/XimTrans.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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/nx-X11/lib/X11/Ximint.h b/nx-X11/lib/X11/Ximint.h
index f39053f84..9550c6851 100644
--- a/nx-X11/lib/X11/Ximint.h
+++ b/nx-X11/lib/X11/Ximint.h
@@ -36,9 +36,6 @@ PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <nx-X11/Xutil.h>
-#define Public /**/
-#define Private static
-
typedef struct _Xim *Xim;
typedef struct _Xic *Xic;
@@ -982,7 +979,7 @@ extern Bool _XimEncodeSavedICATTRIBUTE(
);
#endif
-extern Public Bool
+extern Bool
_XimRegisterDispatcher(
Xim im,
Bool (*callback)(
@@ -990,7 +987,7 @@ _XimRegisterDispatcher(
),
XPointer call_data);
-extern Public Bool
+extern Bool
_XimRespSyncReply(
Xic ic,
BITMASK16 mode);
diff --git a/nx-X11/lib/X11/XimintP.h b/nx-X11/lib/X11/XimintP.h
index 89b7c214f..14a7e6d5a 100644
--- a/nx-X11/lib/X11/XimintP.h
+++ b/nx-X11/lib/X11/XimintP.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1991, 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1991, 1992 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"),
@@ -161,6 +161,8 @@ typedef struct _XimProtoPrivateRec {
#define DELAYBINDABLE (1L << 3)
#define RECONNECTABLE (1L << 4)
#endif /* XIM_CONNECTABLE */
+#define FABRICATED (1L << 5)
+#define NEED_SYNC_REPLY (1L << 6)
/*
* macro for the flag of XIMPrivateRec
@@ -199,6 +201,20 @@ typedef struct _XimProtoPrivateRec {
(((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE))
#endif /* XIM_CONNECTABLE */
+#define IS_FABRICATED(im) \
+ (((Xim)im)->private.proto.flag & FABRICATED)
+#define MARK_FABRICATED(im) \
+ (((Xim)im)->private.proto.flag |= FABRICATED)
+#define UNMARK_FABRICATED(im) \
+ (((Xim)im)->private.proto.flag &= ~FABRICATED)
+
+#define IS_NEED_SYNC_REPLY(im) \
+ (((Xim)im)->private.proto.flag & NEED_SYNC_REPLY)
+#define MARK_NEED_SYNC_REPLY(im) \
+ (((Xim)im)->private.proto.flag |= NEED_SYNC_REPLY)
+#define UNMARK_NEED_SYNC_REPLY(im) \
+ (((Xim)im)->private.proto.flag &= ~NEED_SYNC_REPLY)
+
/*
* bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec
*/
@@ -259,9 +275,6 @@ typedef struct _XicProtoPrivateRec {
* bit mask for the flag of XICPrivateRec
*/
#define IC_CONNECTED (1L)
-#define FABLICATED (1L << 1)
-#define NEED_SYNC_REPLY (1L << 2)
-#define FOCUSED (1L << 3)
/*
* macro for the flag of XICPrivateRec
@@ -273,27 +286,6 @@ typedef struct _XicProtoPrivateRec {
#define UNMARK_IC_CONNECTED(ic) \
(((Xic)ic)->private.proto.flag &= ~IC_CONNECTED)
-#define IS_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag & FABLICATED)
-#define MARK_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag |= FABLICATED)
-#define UNMARK_FABLICATED(ic) \
- (((Xic)ic)->private.proto.flag &= ~FABLICATED)
-
-#define IS_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY)
-#define MARK_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY)
-#define UNMARK_NEED_SYNC_REPLY(ic) \
- (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)
-
-#define IS_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag & FOCUSED)
-#define MARK_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag |= FOCUSED)
-#define UNMARK_FOCUSED(ic) \
- (((Xic)ic)->private.proto.flag &= ~FOCUSED)
-
/*
* macro for the filter_event_mask of XICPrivateRec
*/
diff --git a/nx-X11/lib/X11/Xintatom.h b/nx-X11/lib/X11/Xintatom.h
index f4057798d..b2d307bab 100644
--- a/nx-X11/lib/X11/Xintatom.h
+++ b/nx-X11/lib/X11/Xintatom.h
@@ -2,6 +2,7 @@
#ifndef _XINTATOM_H_
#define _XINTATOM_H_ 1
+#include <nx-X11/Xlib.h>
#include <nx-X11/Xfuncproto.h>
/* IntAtom.c */
diff --git a/nx-X11/lib/X11/Xintconn.h b/nx-X11/lib/X11/Xintconn.h
index 54200ed9f..675f684ac 100644
--- a/nx-X11/lib/X11/Xintconn.h
+++ b/nx-X11/lib/X11/Xintconn.h
@@ -3,6 +3,7 @@
#define _XINTCONN_H_ 1
#include <nx-X11/Xfuncproto.h>
+#include <nx-X11/Xlib.h>
_XFUNCPROTOBEGIN
diff --git a/nx-X11/lib/X11/XlcDL.c b/nx-X11/lib/X11/XlcDL.c
index 879bc51eb..bc71900a0 100644
--- a/nx-X11/lib/X11/XlcDL.c
+++ b/nx-X11/lib/X11/XlcDL.c
@@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted.
*/
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2000 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"),
@@ -86,16 +86,6 @@ Sun Microsystems, Inc. or its licensors is granted.
#include "XlcPublic.h"
#include "XlcPubI.h"
-#if defined(_LP64) && defined(__sparcv9)
-# define _MACH64_NAME "sparcv9"
-#else
-# undef _MACH64_NAME
-#endif /* defined(_LP64) && defined(__sparcv9) */
-
-#ifdef _MACH64_NAME
-# define _MACH64_NAME_LEN (sizeof (_MACH64_NAME) - 1)
-#endif
-
#define XI18N_DLREL 2
#define iscomment(ch) ((ch) == '\0' || (ch) == '#')
@@ -195,16 +185,10 @@ resolve_object(char *path, const char *lc_name)
if (lc_len == 0) { /* True only for the 1st time */
lc_len = OBJECT_INIT_LEN;
- xi18n_objects_list = (XI18NObjectsList)
- Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
+ xi18n_objects_list = Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
if (!xi18n_objects_list) return;
}
-/*
-1266793
-Limit the length of path to prevent stack buffer corruption.
- sprintf(filename, "%s/%s", path, "XI18N_OBJS");
-*/
- sprintf(filename, "%.*s/%s", BUFSIZ - 12, path, "XI18N_OBJS");
+ snprintf(filename, sizeof(filename), "%s/%s", path, "XI18N_OBJS");
fp = fopen(filename, "r");
if (fp == (FILE *)NULL){
return;
@@ -222,11 +206,13 @@ Limit the length of path to prevent stack buffer corruption.
}
if (lc_count == lc_len) {
- lc_len += OBJECT_INC_LEN;
- xi18n_objects_list = (XI18NObjectsList)
- Xrealloc(xi18n_objects_list,
- sizeof(XI18NObjectsListRec) * lc_len);
- if (!xi18n_objects_list) return;
+ int new_len = lc_len + OBJECT_INC_LEN;
+ XI18NObjectsListRec *tmp = Xrealloc(xi18n_objects_list,
+ sizeof(XI18NObjectsListRec) * new_len);
+ if (tmp == NULL)
+ goto done;
+ xi18n_objects_list = tmp;
+ lc_len = new_len;
}
n = parse_line(p, args, 6);
@@ -254,6 +240,7 @@ Limit the length of path to prevent stack buffer corruption.
lc_count++;
}
}
+ done:
fclose(fp);
}
@@ -262,6 +249,7 @@ __lc_path(const char *dl_name, const char *lc_dir)
{
char *path;
size_t len;
+ char *slash_p;
/*
* reject this for possible security issue
@@ -269,35 +257,6 @@ __lc_path(const char *dl_name, const char *lc_dir)
if (strstr (dl_name, "../"))
return NULL;
-#if defined (_LP64) && defined (_MACH64_NAME)
- len = (lc_dir ? strlen(lc_dir) : 0 ) +
- (dl_name ? strlen(dl_name) : 0) + _MACH64_NAME_LEN + 10;
- path = Xmalloc(len + 1);
-
- if (strchr(dl_name, '/') != NULL) {
- char *tmp = strdup(dl_name);
- char *dl_dir, *dl_file;
- char *slash_p;
- slash_p = strchr(tmp, '/');
- *slash_p = '\0';
- dl_dir = tmp;
- dl_file = ++slash_p;
-
- slash_p = strrchr(lc_dir, '/');
- *slash_p = '\0';
- strcpy(path, lc_dir); strcat(path, "/");
- strcat(path, dl_dir); strcat(path, "/");
- strcat(path, _MACH64_NAME); strcat(path, "/");
- strcat(path, dl_file); strcat(path, ".so.2");
-
- *slash_p = '/';
- Xfree(tmp);
- } else {
- strcpy(path, lc_dir); strcat(path, "/");
- strcat(path, _MACH64_NAME); strcat(path, "/");
- strcat(path, dl_name); strcat(path, ".so.2");
- }
-#else
len = (lc_dir ? strlen(lc_dir) : 0 ) +
(dl_name ? strlen(dl_name) : 0) + 10;
#if defined POSTLOCALELIBDIR
@@ -306,23 +265,21 @@ __lc_path(const char *dl_name, const char *lc_dir)
path = Xmalloc(len + 1);
if (strchr(dl_name, '/') != NULL) {
- char *slash_p;
slash_p = strrchr(lc_dir, '/');
*slash_p = '\0';
- strcpy(path, lc_dir); strcat(path, "/");
+ } else
+ slash_p = NULL;
+
#if defined POSTLOCALELIBDIR
- strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
+ snprintf(path, len + 1, "%s/%s/%s.so.2",
+ lc_dir, POSTLOCALELIBDIR, dl_name);
+#else
+ snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name);
#endif
- strcat(path, dl_name); strcat(path, ".so.2");
+
+ if (slash_p != NULL)
*slash_p = '/';
- } else {
- strcpy(path, lc_dir); strcat(path, "/");
-#if defined POSTLOCALELIBDIR
- strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
-#endif
- strcat(path, dl_name); strcat(path, ".so.2");
- }
-#endif
+
return path;
}
@@ -423,9 +380,9 @@ _XlcDynamicLoad(const char *lc_name)
if (lc_name == NULL) return (XLCd)NULL;
- if (_XlcLocaleDirName(lc_dir, BUFSIZE, (char *)lc_name) == (char *)NULL)
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL)
return (XLCd)NULL;
- if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, (char *)lc_name) == (char*)NULL)
+ if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, lc_name) == NULL)
return (XLCd)NULL;
resolve_object(lc_dir, lc_name);
@@ -552,7 +509,7 @@ _XDynamicUnRegisterIMInstantiateCallback(
XPointer client_data)
{
char lc_dir[BUFSIZE];
- char *lc_name;
+ const char *lc_name;
dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL;
Bool ret_flag = False;
int count;
diff --git a/nx-X11/lib/X11/XlcPubI.h b/nx-X11/lib/X11/XlcPubI.h
index f41e3442a..c454c7ddd 100644
--- a/nx-X11/lib/X11/XlcPubI.h
+++ b/nx-X11/lib/X11/XlcPubI.h
@@ -207,13 +207,13 @@ extern int _XlcResolveI18NPath(
extern char *_XlcLocaleLibDirName(
char* /* dir_name */,
size_t, /* dir_len */
- char* /* lc_name */
+ const char* /* lc_name */
);
extern char *_XlcLocaleDirName(
char* /* dir_name */,
size_t, /* dir_len */
- char* /* lc_name */
+ const char* /* lc_name */
);
extern XPointer _XlcCreateLocaleDataBase(
@@ -232,12 +232,6 @@ extern void _XlcGetLocaleDataBase(
int* /* count */
);
-#ifdef X_LOCALE
-extern char *
-_Xsetlocale(
- int category,
- _Xconst char *name);
-#else
#if defined(__APPLE__) || defined(__DARWIN__)
extern char *
_Xsetlocale(
@@ -247,7 +241,6 @@ _Xsetlocale(
extern char *_XlcMapOSLocaleName(
char *osname,
char *siname);
-#endif
extern int
_Xmbstoutf8(
diff --git a/nx-X11/lib/X11/XlcSL.c b/nx-X11/lib/X11/XlcSL.c
index 526f677fb..b8b3967d9 100644
--- a/nx-X11/lib/X11/XlcSL.c
+++ b/nx-X11/lib/X11/XlcSL.c
@@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted.
*/
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2000 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"),
@@ -71,8 +71,7 @@ extern XIM _XDefaultOpenIM(
);
Bool
-_XInitDefaultIM(lcd)
-XLCd lcd;
+_XInitDefaultIM(XLCd lcd)
{
if(lcd == (XLCd)NULL)
return False;
@@ -88,8 +87,7 @@ extern XOM _XDefaultOpenOM(
);
Bool
-_XInitDefaultOM(lcd)
- XLCd lcd;
+_XInitDefaultOM(XLCd lcd)
{
lcd->methods->open_om = _XDefaultOpenOM;
return True;
diff --git a/nx-X11/lib/X11/Xlcint.h b/nx-X11/lib/X11/Xlcint.h
index 7b10d8fd7..5a6205a1f 100644
--- a/nx-X11/lib/X11/Xlcint.h
+++ b/nx-X11/lib/X11/Xlcint.h
@@ -932,21 +932,6 @@ extern XLCd _XlcUtf8Loader(
const char* name
);
-/* The old EUC locale loader. */
-extern XLCd _XlcEucLoader(
- const char* name
-);
-
-/* The old SJIS locale loader. */
-extern XLCd _XlcSjisLoader(
- const char* name
-);
-
-/* The old ISO-2022-JP locale loader. */
-extern XLCd _XlcJisLoader(
- const char* name
-);
-
extern XLCd _XlcDynamicLoad(
const char* name
);
diff --git a/nx-X11/lib/X11/Xlib.h b/nx-X11/lib/X11/Xlib.h
index e537c7522..1ac1ef181 100644
--- a/nx-X11/lib/X11/Xlib.h
+++ b/nx-X11/lib/X11/Xlib.h
@@ -59,29 +59,25 @@ typedef unsigned long wchar_t;
#endif
#endif
-#if defined(ISC) && defined(USE_XMBTOWC)
-#define wctomb(a,b) _Xwctomb(a,b)
-#define mblen(a,b) _Xmblen(a,b)
-#ifndef USE_XWCHAR_STRING
-#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
-#endif
-#endif
extern int
_Xmblen(
-#ifdef ISC
- char const *str,
- size_t len
-#else
char *str,
int len
-#endif
);
/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
November 2000. Its presence is indicated through the following macro. */
#define X_HAVE_UTF8_STRING 1
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
typedef char *XPointer;
#define Bool int
@@ -93,39 +89,39 @@ typedef char *XPointer;
#define QueuedAfterReading 1
#define QueuedAfterFlush 2
-#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
+#define ConnectionNumber(dpy) (((_XPrivDisplay)(dpy))->fd)
#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
-#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
+#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
#define AllPlanes ((unsigned long)~0L)
-#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
+#define QLength(dpy) (((_XPrivDisplay)(dpy))->qlen)
#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
-#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
-#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
-#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
-#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
-#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
-#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
+#define ScreenCount(dpy) (((_XPrivDisplay)(dpy))->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)(dpy))->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)(dpy))->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)(dpy))->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)(dpy))->release)
+#define DisplayString(dpy) (((_XPrivDisplay)(dpy))->display_name)
#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
-#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
-#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
-#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
-#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
-#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
-#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
+#define BitmapUnit(dpy) (((_XPrivDisplay)(dpy))->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)(dpy))->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)(dpy))->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)(dpy))->byte_order)
+#define NextRequest(dpy) (((_XPrivDisplay)(dpy))->request + 1)
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)(dpy))->last_request_read)
/* macros for screen oriented applications (toolkit) */
-#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)(dpy))->screens[scr])
#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
#define DisplayOfScreen(s) ((s)->display)
#define RootWindowOfScreen(s) ((s)->root)
@@ -1014,7 +1010,7 @@ typedef union _XEvent {
} XEvent;
#endif
-#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
+#define XAllocID(dpy) ((*((_XPrivDisplay)(dpy))->resource_alloc)((dpy)))
/*
* per character font metric information.
@@ -1688,6 +1684,7 @@ extern XHostAddress *XListHosts(
int* /* nhosts_return */,
Bool* /* state_return */
);
+_X_DEPRECATED
extern KeySym XKeycodeToKeysym(
Display* /* display */,
#if NeedWidePrototypes
@@ -4012,13 +4009,8 @@ extern void XSetAuthorization(
extern int _Xmbtowc(
wchar_t * /* wstr */,
-#ifdef ISC
- char const * /* str */,
- size_t /* len */
-#else
char * /* str */,
int /* len */
-#endif
);
extern int _Xwctomb(
@@ -4036,6 +4028,10 @@ extern void XFreeEventData(
XGenericEventCookie* /* cookie*/
);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
_XFUNCPROTOEND
#endif /* #if !defined(_X11_XLIB_H_) && !defined(_XLIB_H_) */
diff --git a/nx-X11/lib/X11/XlibInt.c b/nx-X11/lib/X11/XlibInt.c
index 7ca1d0d01..d3c85a343 100644
--- a/nx-X11/lib/X11/XlibInt.c
+++ b/nx-X11/lib/X11/XlibInt.c
@@ -608,7 +608,7 @@ Bool _XPollfdCacheInit(
#ifdef USE_POLL
struct pollfd *pfp;
- pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ pfp = Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
if (!pfp)
return False;
pfp[0].fd = dpy->fd;
@@ -901,7 +901,7 @@ void _XSeqSyncFunction(
static int
_XPrivSyncFunction (Display *dpy)
{
-#if XTHREADS
+#ifdef XTHREADS
assert(!dpy->lock_fns);
#endif
assert(dpy->synchandler == _XPrivSyncFunction);
@@ -2477,10 +2477,10 @@ _XRegisterInternalConnection(
#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG)
fprintf(stderr, "_XRegisterInternalConnection: Got called.\n");
#endif
- new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ new_conni = Xmalloc(sizeof(struct _XConnectionInfo));
if (!new_conni)
return 0;
- new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ new_conni->watch_data = Xmalloc(dpy->watcher_count * sizeof(XPointer));
if (!new_conni->watch_data) {
Xfree(new_conni);
return 0;
@@ -2537,8 +2537,7 @@ _XUnregisterInternalConnection(
watch=watch->next, wd++) {
(*watch->fn) (dpy, watch->client_data, fd, False, wd);
}
- if (info_list->watch_data)
- Xfree (info_list->watch_data);
+ Xfree (info_list->watch_data);
Xfree (info_list);
break;
}
@@ -2573,7 +2572,7 @@ XInternalConnectionNumbers(
count = 0;
for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
count++;
- fd_list = (int*) Xmalloc (count * sizeof(int));
+ fd_list = Xmalloc (count * sizeof(int));
if (!fd_list) {
UnlockDisplay(dpy);
return 0;
@@ -2666,17 +2665,17 @@ XAddConnectionWatch(
/* allocate new watch data */
for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
- wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
- (dpy->watcher_count + 1) *
- sizeof(XPointer));
+ wd_array = Xrealloc(info_list->watch_data,
+ (dpy->watcher_count + 1) * sizeof(XPointer));
if (!wd_array) {
UnlockDisplay(dpy);
return 0;
}
+ info_list->watch_data = wd_array;
wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
}
- new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ new_watcher = Xmalloc(sizeof(struct _XConnWatchInfo));
if (!new_watcher) {
UnlockDisplay(dpy);
return 0;
@@ -2839,10 +2838,10 @@ _XFreeEventCookies(Display *dpy)
head = (struct stored_event**)&dpy->cookiejar;
DL_FOREACH_SAFE(*head, e, tmp) {
- XFree(e->ev.data);
- XFree(e);
if (dpy->cookiejar == e)
dpy->cookiejar = NULL;
+ XFree(e->ev.data);
+ XFree(e);
}
}
@@ -2935,8 +2934,7 @@ void _XEnq(
/* If dpy->qfree is non-NULL do this, else malloc a new one. */
dpy->qfree = qelt->next;
}
- else if ((qelt =
- (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ else if ((qelt = Xmalloc(sizeof(_XQEvent))) == NULL) {
/* Malloc call failed! */
ESET(ENOMEM);
#ifdef NX_TRANS_SOCKET
@@ -2951,7 +2949,9 @@ void _XEnq(
type = event->u.u.type & 0177;
extension = ((xGenericEvent*)event)->extension;
- /* If an extension has registerd a generic_event_vec handler, then
+
+ qelt->event.type = type;
+ /* If an extension has registered a generic_event_vec handler, then
* it can handle event cookies. Otherwise, proceed with the normal
* event handlers.
*
@@ -3496,7 +3496,7 @@ int _XDefaultIOError(
#else
exit(1);
#endif /* #ifdef NX_TRANS_SOCKET */
- return(0); /* dummy - function should never return */
+ /*NOTREACHED*/
}
@@ -3518,16 +3518,17 @@ static int _XPrintDefaultError(
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->request_code);
if (event->request_code < 128) {
- sprintf(number, "%d", event->request_code);
+ snprintf(number, sizeof(number), "%d", event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
} else {
for (ext = dpy->ext_procs;
ext && (ext->codes.major_opcode != event->request_code);
ext = ext->next)
;
- if (ext)
- strcpy(buffer, ext->name);
- else
+ if (ext) {
+ strncpy(buffer, ext->name, BUFSIZ);
+ buffer[BUFSIZ - 1] = '\0';
+ } else
buffer[0] = '\0';
}
(void) fprintf(fp, " (%s)\n", buffer);
@@ -3537,7 +3538,7 @@ static int _XPrintDefaultError(
fputs(" ", fp);
(void) fprintf(fp, mesg, event->minor_code);
if (ext) {
- sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ snprintf(mesg, sizeof(mesg), "%s.%d", ext->name, event->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
(void) fprintf(fp, " (%s)", buffer);
}
@@ -3560,8 +3561,8 @@ static int _XPrintDefaultError(
bext = ext;
}
if (bext)
- sprintf(buffer, "%s.%d", bext->name,
- event->error_code - bext->codes.first_error);
+ snprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
else
strcpy(buffer, "Value");
XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
@@ -3745,7 +3746,7 @@ _XIOError (
#else
exit (1);
#endif
- return 0;
+ /*NOTREACHED*/
}
@@ -3761,8 +3762,9 @@ char *_XAllocScratch(
unsigned long nbytes)
{
if (nbytes > dpy->scratch_length) {
- if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
- if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ Xfree (dpy->scratch_buffer);
+ dpy->scratch_buffer = Xmalloc(nbytes);
+ if (dpy->scratch_buffer)
dpy->scratch_length = nbytes;
else dpy->scratch_length = 0;
}
@@ -3790,8 +3792,8 @@ void _XFreeTemp(
char *buf,
unsigned long nbytes)
{
- if (dpy->scratch_buffer)
- Xfree(dpy->scratch_buffer);
+
+ Xfree(dpy->scratch_buffer);
dpy->scratch_buffer = buf;
dpy->scratch_length = nbytes;
}
@@ -3848,7 +3850,7 @@ void _Xbcopy(b1, b2, length)
#ifdef DataRoutineIsProcedure
void Data(
Display *dpy,
- char *data,
+ _Xconst char *data,
long len)
{
if (dpy->bufptr + (len) <= dpy->bufmax) {
@@ -3865,7 +3867,7 @@ void Data(
int
_XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len)
{
register int *buf;
@@ -3978,6 +3980,14 @@ void *_XGetRequest(Display *dpy, CARD8 type, size_t len)
if (dpy->bufptr + len > dpy->bufmax)
_XFlush(dpy);
+ /* Request still too large, so do not allow it to overflow. */
+ if (dpy->bufptr + len > dpy->bufmax) {
+ fprintf(stderr,
+ "Xlib: request %d length %zd would exceed buffer size.\n",
+ type, len);
+ /* Changes failure condition from overflow to NULL dereference. */
+ return NULL;
+ }
if (len % 4)
fprintf(stderr,
diff --git a/nx-X11/lib/X11/Xlibint.h b/nx-X11/lib/X11/Xlibint.h
index 69561f401..056b4d8f9 100644
--- a/nx-X11/lib/X11/Xlibint.h
+++ b/nx-X11/lib/X11/Xlibint.h
@@ -67,6 +67,14 @@ from The Open Group.
#include <nx-X11/Xproto.h> /* to declare xEvent */
#include <nx-X11/XlibConf.h> /* for configured options like XTHREADS */
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
#ifdef NX_TRANS_SOCKET
#include <nx/NXvars.h>
@@ -80,14 +88,6 @@ from The Open Group.
#define _XFlush _XFlushIt
#endif
-/*
- * If your BytesReadable correctly detects broken connections, then
- * you should NOT define XCONN_CHECK_FREQ.
- */
-#ifndef XCONN_CHECK_FREQ
-#define XCONN_CHECK_FREQ 256
-#endif
-
struct _XGC
{
XExtData *ext_data; /* hook for extension to hang data */
@@ -235,10 +235,6 @@ struct _XDisplay
#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
-/*
- * define the following if you want the Data macro to be a procedure instead
- */
-
#ifndef _XEVENT_
/*
* _QEvent datatype for use in input queueing.
@@ -367,7 +363,7 @@ extern LockInfoPtr _Xglobal_lock;
* define MALLOC_0_RETURNS_NULL. This is necessary because some
* Xlib code expects malloc(0) to return a valid pointer to storage.
*/
-#ifdef MALLOC_0_RETURNS_NULL
+#if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)
# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
@@ -437,6 +433,28 @@ extern LockInfoPtr _Xglobal_lock;
* X Protocol packetizing macros.
*/
+/* Leftover from CRAY support - was defined empty on all non-Cray systems */
+#define WORD64ALIGN
+
+/**
+ * Return a len-sized request buffer for the request type. This function may
+ * flush the output queue.
+ *
+ * @param dpy The display connection
+ * @param type The request type
+ * @param len Length of the request in bytes
+ *
+ * @returns A pointer to the request buffer with a few default values
+ * initialized.
+ */
+extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
+
+/* GetReqSized is the same as GetReq but allows the caller to specify the
+ * size in bytes. 'sz' must be a multiple of 4! */
+
+#define GetReqSized(name, sz, req) \
+ req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)
+
/*
* GetReq - Get the next available X request packet in the buffer and
* return it.
@@ -446,50 +464,14 @@ extern LockInfoPtr _Xglobal_lock;
*
*/
-#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetReq(name, req) \
- if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = (SIZEOF(x##name##Req))>>2;\
- dpy->bufptr += SIZEOF(x##name##Req);\
- dpy->request++
-
-#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
-#define GetReq(name, req) \
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = (SIZEOF(x/**/name/**/Req))>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req);\
- dpy->request++
-#endif
+ GetReqSized(name, SIZEOF(x##name##Req), req)
/* GetReqExtra is the same as GetReq, but allocates "n" additional
bytes after the request. "n" must be a multiple of 4! */
-#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetReqExtra(name, n, req) \
- if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = (SIZEOF(x##name##Req) + n)>>2;\
- dpy->bufptr += SIZEOF(x##name##Req) + n;\
- dpy->request++
-#else
-#define GetReqExtra(name, n, req) \
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
- dpy->request++
-#endif
-
+ GetReqSized(name, SIZEOF(x##name##Req) + n, req)
/*
* GetResReq is for those requests that have a resource ID
@@ -497,51 +479,16 @@ extern LockInfoPtr _Xglobal_lock;
* "rid" is the name of the resource.
*/
-#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetResReq(name, rid, req) \
- if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = 2;\
- req->id = (rid);\
- dpy->bufptr += SIZEOF(xResourceReq);\
- dpy->request++
-#else
-#define GetResReq(name, rid, req) \
- if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = 2;\
- req->id = (rid);\
- dpy->bufptr += SIZEOF(xResourceReq);\
- dpy->request++
-#endif
+ req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
+ req->id = (rid)
/*
* GetEmptyReq is for those requests that have no arguments
* at all.
*/
-#if !defined(UNIXCPP) || defined(ANSICPP)
-#define GetEmptyReq(name, req) \
- if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = 1;\
- dpy->bufptr += SIZEOF(xReq);\
- dpy->request++
-#else
#define GetEmptyReq(name, req) \
- if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = 1;\
- dpy->bufptr += SIZEOF(xReq);\
- dpy->request++
-#endif
+ req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))
/*
* MakeBigReq sets the CARD16 "req->length" to 0 and inserts a new CARD32
@@ -582,6 +529,7 @@ extern LockInfoPtr _Xglobal_lock;
* Do not use SetReqLen if "req" does not already have data after the
* xReq header. req->length must already be >= 2.
*/
+#ifndef __clang_analyzer__
#define SetReqLen(req,n,badlen) \
if ((req->length + n) > (unsigned)65535) { \
if (dpy->bigreq_size) { \
@@ -592,6 +540,10 @@ extern LockInfoPtr _Xglobal_lock;
} \
} else \
req->length += n
+#else
+#define SetReqLen(req,n,badlen) \
+ req->length += n
+#endif
#define SyncHandle() \
if (dpy->synchandler) (*dpy->synchandler)(dpy)
@@ -604,7 +556,7 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
* 32 bit word alignment. Transmit if the buffer fills.
*
* "dpy" is a pointer to a Display.
- * "data" is a pinter to a data buffer.
+ * "data" is a pointer to a data buffer.
* "len" is the length of the data buffer.
*/
#ifndef DataRoutineIsProcedure
@@ -636,17 +588,17 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
if (dpy->bufptr + (n) > dpy->bufmax) \
_XFlush (dpy); \
ptr = (type) dpy->bufptr; \
- (void)ptr; \
+ memset(ptr, '\0', n); \
dpy->bufptr += (n);
-#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#ifdef LONG64
-#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
extern int _XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len
);
extern void _XRead32(
@@ -655,7 +607,7 @@ extern void _XRead32(
long len
);
#else
-#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#endif
@@ -726,7 +678,6 @@ extern void _XRead32(
}
-
/* srcvar must be a variable for large architecture version */
#define OneDataCard32(dpy,dstaddr,srcvar) \
{ *(CARD32 *)(dstaddr) = (srcvar); }
@@ -784,7 +735,7 @@ typedef int (*FreeModmapType) (
*/
typedef struct _XFreeFuncs {
FreeFuncType atoms; /* _XFreeAtomTable */
- FreeModmapType modifiermap; /* XFreeModifierMap */
+ FreeModmapType modifiermap; /* XFreeModifiermap */
FreeFuncType key_bindings; /* _XFreeKeyBindings */
FreeFuncType context_db; /* _XFreeContextDB */
FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */
@@ -905,7 +856,7 @@ extern int _XError(
);
extern int _XIOError(
Display* /* dpy */
-);
+) _X_NORETURN;
extern int (*_XIOErrorFunction)(
Display* /* dpy */
);
@@ -1405,6 +1356,10 @@ extern void xlocaledir(
int buf_len
);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
_XFUNCPROTOEND
#endif /* !defined(_X11_XLIBINT_H_) && !defined(_XLIBINT_H_) */
diff --git a/nx-X11/lib/X11/Xlocale.h b/nx-X11/lib/X11/Xlocale.h
index da5746d28..4ac9bac30 100644
--- a/nx-X11/lib/X11/Xlocale.h
+++ b/nx-X11/lib/X11/Xlocale.h
@@ -33,28 +33,6 @@ from The Open Group.
#include <nx-X11/Xfuncproto.h>
#include <nx-X11/Xosdefs.h>
-#ifndef X_LOCALE
#include <locale.h>
-#else
-
-#define LC_ALL 0
-#define LC_COLLATE 1
-#define LC_CTYPE 2
-#define LC_MONETARY 3
-#define LC_NUMERIC 4
-#define LC_TIME 5
-
-_XFUNCPROTOBEGIN
-extern char *_Xsetlocale(
- int /* category */,
- _Xconst char* /* name */
-);
-_XFUNCPROTOEND
-
-#define setlocale _Xsetlocale
-
-#include <stddef.h>
-
-#endif /* X_LOCALE */
#endif /* !defined(_X11_XLOCALE_H_) && !defined(_XLOCALE_H_) */
diff --git a/nx-X11/lib/X11/Xprivate.h b/nx-X11/lib/X11/Xprivate.h
index ebe51c1ed..2dd62ce7d 100644
--- a/nx-X11/lib/X11/Xprivate.h
+++ b/nx-X11/lib/X11/Xprivate.h
@@ -8,10 +8,12 @@
#ifndef XPRIVATE_H
#define XPRIVATE_H
-extern void _XIDHandler(Display *dpy);
-extern void _XSeqSyncFunction(Display *dpy);
-extern void _XSetPrivSyncFunction(Display *dpy);
-extern void _XSetSeqSyncFunction(Display *dpy);
+#include <nx-X11/Xlib.h>
+
+extern _X_HIDDEN void _XIDHandler(Display *dpy);
+extern _X_HIDDEN void _XSeqSyncFunction(Display *dpy);
+extern _X_HIDDEN void _XSetPrivSyncFunction(Display *dpy);
+extern _X_HIDDEN void _XSetSeqSyncFunction(Display *dpy);
#ifdef XTHREADS
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
diff --git a/nx-X11/lib/X11/Xregion.h b/nx-X11/lib/X11/Xregion.h
index 1c36db144..4f55af82f 100644
--- a/nx-X11/lib/X11/Xregion.h
+++ b/nx-X11/lib/X11/Xregion.h
@@ -113,10 +113,11 @@ typedef struct _XRegion {
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
- (firstrect) = (BOX *) Xrealloc \
- ((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
- if ((firstrect) == 0)\
+ BoxPtr tmpRect = Xrealloc ((firstrect), \
+ (2 * (sizeof(BOX)) * ((reg)->size))); \
+ if (tmpRect == NULL) \
return(0);\
+ (firstrect) = tmpRect; \
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
diff --git a/nx-X11/lib/X11/Xresinternal.h b/nx-X11/lib/X11/Xresinternal.h
index c2f355fe6..c740102b6 100644
--- a/nx-X11/lib/X11/Xresinternal.h
+++ b/nx-X11/lib/X11/Xresinternal.h
@@ -2,6 +2,8 @@
#ifndef _XRESINTERNAL_H_
#define _XRESINTERNAL_H_
+#include <nx-X11/Xlib.h>
+#include <nx-X11/Xresource.h>
#include <inttypes.h>
/* type defines */
diff --git a/nx-X11/lib/X11/Xrm.c b/nx-X11/lib/X11/Xrm.c
index 818e72906..3b90346d8 100644
--- a/nx-X11/lib/X11/Xrm.c
+++ b/nx-X11/lib/X11/Xrm.c
@@ -60,8 +60,9 @@ from The Open Group.
#ifdef XTHREADS
#include "locking.h"
#endif
-#include "XrmI.h"
#include <nx-X11/Xos.h>
+#include <sys/stat.h>
+#include <limits.h>
#include "Xresinternal.h"
#include "Xresource.h"
@@ -348,7 +349,7 @@ void XrmSetDatabase(
XrmDatabase database)
{
LockDisplay(display);
- /* destroy database if set up imlicitely by XGetDefault() */
+ /* destroy database if set up implicitly by XGetDefault() */
if (display->db && (display->flags & XlibDisplayDfltRMDB)) {
XrmDestroyDatabase(display->db);
display->flags &= ~XlibDisplayDfltRMDB;
@@ -494,7 +495,7 @@ static XrmDatabase NewDatabase(void)
{
register XrmDatabase db;
- db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec));
+ db = Xmalloc(sizeof(XrmHashBucketRec));
if (db) {
_XCreateMutex(&db->linfo);
db->table = (NTable)NULL;
@@ -507,7 +508,7 @@ static XrmDatabase NewDatabase(void)
}
/* move all values from ftable to ttable, and free ftable's buckets.
- * ttable is quaranteed empty to start with.
+ * ttable is guaranteed empty to start with.
*/
static void MoveValues(
LTable ftable,
@@ -530,7 +531,7 @@ static void MoveValues(
fentry->next = tentry;
}
}
- Xfree((char *)ftable->buckets);
+ Xfree(ftable->buckets);
}
/* move all tables from ftable to ttable, and free ftable.
@@ -557,7 +558,7 @@ static void MoveTables(
fentry->next = tentry;
}
}
- Xfree((char *)ftable);
+ Xfree(ftable);
}
/* grow the table, based on current number of entries */
@@ -581,23 +582,21 @@ static void GrowTable(
ltable = (LTable)table;
/* cons up a copy to make MoveValues look symmetric */
otable = *ltable;
- ltable->buckets = (VEntry *)Xmalloc(i * sizeof(VEntry));
+ ltable->buckets = Xcalloc(i, sizeof(VEntry));
if (!ltable->buckets) {
ltable->buckets = otable.buckets;
return;
}
ltable->table.mask = i - 1;
- bzero((char *)ltable->buckets, i * sizeof(VEntry));
MoveValues(&otable, ltable);
} else {
register NTable ntable;
- ntable = (NTable)Xmalloc(sizeof(NTableRec) + i * sizeof(NTable));
+ ntable = Xcalloc(1, sizeof(NTableRec) + (i * sizeof(NTable)));
if (!ntable)
return;
*ntable = *table;
ntable->mask = i - 1;
- bzero((char *)NodeBuckets(ntable), i * sizeof(NTable));
*prev = ntable;
MoveTables(table, ntable);
}
@@ -650,7 +649,7 @@ static void MergeValues(
fentry = *prev;
*prev = tentry->next;
/* free the overridden entry */
- Xfree((char *)tentry);
+ Xfree(tentry);
/* get next tentry */
tentry = *prev;
} else {
@@ -659,7 +658,7 @@ static void MergeValues(
tentry = fentry; /* use as a temp var */
fentry = fentry->next;
/* free the overpowered entry */
- Xfree((char *)tentry);
+ Xfree(tentry);
/* get next tentry */
tentry = *prev;
}
@@ -677,8 +676,8 @@ static void MergeValues(
}
}
}
- Xfree((char *)ftable->buckets);
- Xfree((char *)ftable);
+ Xfree(ftable->buckets);
+ Xfree(ftable);
/* resize if necessary, now that we're all done */
GROW(pprev);
}
@@ -752,7 +751,7 @@ static void MergeTables(
}
}
}
- Xfree((char *)ftable);
+ Xfree(ftable);
/* resize if necessary, now that we're all done */
GROW(pprev);
}
@@ -802,7 +801,7 @@ void XrmCombineDatabase(
(from->methods->destroy)(from->mbstate);
_XUnlockMutex(&from->linfo);
_XFreeMutex(&from->linfo);
- Xfree((char *)from);
+ Xfree(from);
_XUnlockMutex(&(*into)->linfo);
}
}
@@ -829,7 +828,7 @@ static void PutEntry(
NTable *nprev, *firstpprev;
#define NEWTABLE(q,i) \
- table = (NTable)Xmalloc(sizeof(LTableRec)); \
+ table = Xmalloc(sizeof(LTableRec)); \
if (!table) \
return; \
table->name = q; \
@@ -842,8 +841,10 @@ static void PutEntry(
nprev = NodeBuckets(table); \
} else { \
table->leaf = 1; \
- if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \
+ if (!(nprev = Xmalloc(sizeof(VEntry *)))) {\
+ Xfree(table); \
return; \
+ } \
((LTable)table)->buckets = (VEntry *)nprev; \
} \
*nprev = (NTable)NULL; \
@@ -928,7 +929,7 @@ static void PutEntry(
}
/* splice out and free old entry */
*vprev = entry->next;
- Xfree((char *)entry);
+ Xfree(entry);
(*pprev)->entries--;
}
/* this is where to insert */
@@ -954,9 +955,8 @@ static void PutEntry(
prev = nprev;
}
/* now allocate the value entry */
- entry = (VEntry)Xmalloc(((type == XrmQString) ?
- sizeof(VEntryRec) : sizeof(DEntryRec)) +
- value->size);
+ entry = Xmalloc(((type == XrmQString) ?
+ sizeof(VEntryRec) : sizeof(DEntryRec)) + value->size);
if (!entry)
return;
entry->name = q = *quarks;
@@ -986,13 +986,12 @@ static void PutEntry(
if (resourceQuarks) {
unsigned char *prevQuarks = resourceQuarks;
- resourceQuarks = (unsigned char *)Xrealloc((char *)resourceQuarks,
- size);
+ resourceQuarks = Xrealloc(resourceQuarks, size);
if (!resourceQuarks) {
Xfree(prevQuarks);
}
} else
- resourceQuarks = (unsigned char *)Xmalloc(size);
+ resourceQuarks = Xmalloc(size);
if (resourceQuarks) {
bzero((char *)&resourceQuarks[oldsize], size - oldsize);
maxResourceQuark = (size << 3) - 1;
@@ -1092,7 +1091,7 @@ static void GetIncludeFile(
static void GetDatabase(
XrmDatabase db,
- _Xconst register char *str,
+ _Xconst char *str,
_Xconst char *filename,
Bool doall,
int depth)
@@ -1137,11 +1136,11 @@ static void GetDatabase(
str_len = strlen (str);
if (DEF_BUFF_SIZE > str_len) lhs = lhs_s;
- else if ((lhs = (char*) Xmalloc (str_len)) == NULL)
+ else if ((lhs = Xmalloc (str_len)) == NULL)
return;
alloc_chars = DEF_BUFF_SIZE < str_len ? str_len : DEF_BUFF_SIZE;
- if ((rhs = (char*) Xmalloc (alloc_chars)) == NULL) {
+ if ((rhs = Xmalloc (alloc_chars)) == NULL) {
if (lhs != lhs_s) Xfree (lhs);
return;
}
@@ -1595,12 +1594,14 @@ ReadInFile(_Xconst char *filename)
* result that the number of bytes actually read with be <=
* to the size returned by fstat.
*/
- GetSizeOfFile(fd, size);
-
- /* There might have been a problem trying to stat a file */
- if (size == -1) {
- close (fd);
- return (char *)NULL;
+ {
+ struct stat status_buffer;
+ if ( ((fstat(fd, &status_buffer)) == -1 ) ||
+ (status_buffer.st_size >= INT_MAX) ) {
+ close (fd);
+ return (char *)NULL;
+ } else
+ size = (int) status_buffer.st_size;
}
if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
@@ -2604,11 +2605,11 @@ static void DestroyLTable(
for (i = table->table.mask; i >= 0; i--, buckets++) {
for (next = *buckets; (entry = next); ) {
next = entry->next;
- Xfree((char *)entry);
+ Xfree(entry);
}
}
- Xfree((char *)table->buckets);
- Xfree((char *)table);
+ Xfree(table->buckets);
+ Xfree(table);
}
/* destroy all contained tables, plus table itself */
@@ -2629,7 +2630,7 @@ static void DestroyNTable(
DestroyNTable(entry);
}
}
- Xfree((char *)table);
+ Xfree(table);
}
const char *
@@ -2660,6 +2661,6 @@ void XrmDestroyDatabase(
_XUnlockMutex(&db->linfo);
_XFreeMutex(&db->linfo);
(*db->methods->destroy)(db->mbstate);
- Xfree((char *)db);
+ Xfree(db);
}
}
diff --git a/nx-X11/lib/X11/XrmI.h b/nx-X11/lib/X11/XrmI.h
deleted file mode 100644
index 63ed257ed..000000000
--- a/nx-X11/lib/X11/XrmI.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-
-Copyright 1990, 1998 The Open Group
-
-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.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-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 OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-*/
-
-
-/*
- * Macros to abstract out reading the file, and getting its size.
- *
- * You may need to redefine these for various other operating systems.
- */
-
-#include <nx-X11/Xos.h>
-#include <sys/stat.h>
-#include <limits.h>
-
-#define GetSizeOfFile(fd,size) \
-{ \
- struct stat status_buffer; \
- if ( ((fstat((fd), &status_buffer)) == -1 ) || \
- (status_buffer.st_size >= INT_MAX) ) \
- size = -1; \
- else \
- size = status_buffer.st_size; \
-}
diff --git a/nx-X11/lib/X11/Xutil.h b/nx-X11/lib/X11/Xutil.h
index 2b90005d7..48fa23cf5 100644
--- a/nx-X11/lib/X11/Xutil.h
+++ b/nx-X11/lib/X11/Xutil.h
@@ -50,10 +50,18 @@ SOFTWARE.
#define _X11_XUTIL_H_
#define _XUTIL_H_
-/* You must include <nx-X11/Xlib.h> before including this file */
+/* You must include <X11/Xlib.h> before including this file */
#include <nx-X11/Xlib.h>
#include <nx-X11/keysym.h>
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
/*
* Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
* value (x, y, width, height) was found in the parsed string.
@@ -251,7 +259,7 @@ typedef struct _XComposeStatus {
#define IsModifierKey(keysym) \
((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
|| (((KeySym)(keysym) >= XK_ISO_Lock) && \
- ((KeySym)(keysym) <= XK_ISO_Last_Group_Lock)) \
+ ((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \
|| ((KeySym)(keysym) == XK_Mode_switch) \
|| ((KeySym)(keysym) == XK_Num_Lock))
#else
@@ -822,6 +830,10 @@ extern int XXorRegion(
Region /* dr_return */
);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
_XFUNCPROTOEND
#endif /* !defined(_X11_XUTIL_H_) && !defined(_XUTIL_H_) */
diff --git a/nx-X11/lib/X11/cmsCmap.c b/nx-X11/lib/X11/cmsCmap.c
index 00816ce03..c5401c05d 100644
--- a/nx-X11/lib/X11/cmsCmap.c
+++ b/nx-X11/lib/X11/cmsCmap.c
@@ -191,7 +191,7 @@ CmapRecForColormap(
SyncHandle();
} while (async_state.error_count > 0 && ++j < nVisualsMatched);
- Xfree((char *)visualList);
+ Xfree(visualList);
/*
* if successful
@@ -250,8 +250,7 @@ _XcmsAddCmapRec(
{
XcmsCmapRec *pNew;
- if ((pNew = (XcmsCmapRec *) Xcalloc(1, (unsigned) sizeof(XcmsCmapRec)))
- == NULL) {
+ if ((pNew = Xcalloc(1, sizeof(XcmsCmapRec))) == NULL) {
return((XcmsCmapRec *)NULL);
}
@@ -301,7 +300,7 @@ _XcmsCopyCmapRecAndFree(
pRec_copy =_XcmsAddCmapRec(dpy, copy_cmap, pRec_src->windowID,
pRec_src->visual);
if (pRec_copy != NULL && pRec_src->ccc) {
- pRec_copy->ccc = (XcmsCCC)Xcalloc(1, (unsigned) sizeof(XcmsCCCRec));
+ pRec_copy->ccc = Xcalloc(1, sizeof(XcmsCCCRec));
memcpy((char *)pRec_copy->ccc, (char *)pRec_src->ccc,
sizeof(XcmsCCCRec));
}
@@ -353,7 +352,7 @@ _XcmsDeleteCmapRec(
XcmsFreeCCC(pRec->ccc);
}
*pPrevPtr = pRec->pNext;
- Xfree((char *)pRec);
+ Xfree(pRec);
}
}
@@ -388,7 +387,7 @@ _XcmsFreeClientCmaps(
XcmsFreeCCC(pRecFree->ccc);
}
/* Now free the XcmsCmapRec structure */
- Xfree((char *)pRecFree);
+ Xfree(pRecFree);
}
dpy->cms.clientCmaps = (XPointer)NULL;
}
diff --git a/nx-X11/lib/X11/cmsColNm.c b/nx-X11/lib/X11/cmsColNm.c
index 5f9724822..e43a829f2 100644
--- a/nx-X11/lib/X11/cmsColNm.c
+++ b/nx-X11/lib/X11/cmsColNm.c
@@ -54,7 +54,7 @@ static Status LoadColornameDB(void);
* #define declarations local to this package.
*/
#ifndef XCMSDB
-#define XCMSDB "/usr/lib/X11/Xcms.txt"
+#define XCMSDB XCMSDIR "/Xcms.txt"
#endif
#ifndef isgraph
@@ -126,13 +126,13 @@ _XcmsColorSpaceOfString(
*/
{
XcmsColorSpace **papColorSpaces;
- int n;
+ size_t n;
char *pchar;
if ((pchar = strchr(color_string, ':')) == NULL) {
return(XcmsFailure);
}
- n = (int)(pchar - color_string);
+ n = (size_t)(pchar - color_string);
if (ccc == NULL) {
return(NULL);
@@ -198,7 +198,7 @@ _XcmsParseColorString(
XcmsColorSpace *pColorSpace;
char string_buf[64];
char *string_lowered;
- int len;
+ size_t len;
int res;
if (ccc == NULL) {
@@ -209,7 +209,7 @@ _XcmsParseColorString(
* While copying color_string to string_lowered, convert to lowercase
*/
if ((len = strlen(color_string)) >= sizeof(string_buf)) {
- string_lowered = (char *) Xmalloc(len+1);
+ string_lowered = Xmalloc(len+1);
} else {
string_lowered = string_buf;
}
@@ -255,7 +255,7 @@ FirstCmp(const void *p1, const void *p2)
*
*/
{
- return(strcmp(((XcmsPair *)p1)->first, ((XcmsPair *)p2)->first));
+ return(strcmp(((const XcmsPair *)p1)->first, ((const XcmsPair *)p2)->first));
}
@@ -418,7 +418,7 @@ _XcmsLookupColorName(
Retry:
if ((len = strlen(tmpName)) > 63) {
- name_lowered = (char *) Xmalloc(len+1);
+ name_lowered = Xmalloc(len+1);
} else {
name_lowered = name_lowered_64;
}
@@ -571,7 +571,7 @@ stringSectionSize(
return(XcmsFailure);
}
- while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ while((fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
break;
}
@@ -666,7 +666,7 @@ ReadColornameDB(
* Process lines between START_TOKEN to END_TOKEN
*/
- while ((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ while ((fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
/*
* Found END_TOKEN so break out of for loop
@@ -760,8 +760,8 @@ LoadColornameDB(void)
}
rewind(stream);
- strings = (char *) Xmalloc(size);
- pairs = (XcmsPair *)Xcalloc(nEntries, sizeof(XcmsPair));
+ strings = Xmalloc(size);
+ pairs = Xcalloc(nEntries, sizeof(XcmsPair));
ReadColornameDB(stream, pairs, strings);
(void) fclose(stream);
diff --git a/nx-X11/lib/X11/cmsInt.c b/nx-X11/lib/X11/cmsInt.c
index b7c321472..f4aef04ff 100644
--- a/nx-X11/lib/X11/cmsInt.c
+++ b/nx-X11/lib/X11/cmsInt.c
@@ -82,7 +82,7 @@ _XcmsCopyPointerArray(
for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
n++; /* add 1 to include the NULL pointer */
- if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ if ((newArray = Xmalloc(n * sizeof(XPointer)))) {
memcpy((char *)newArray, (char *)pap,
(unsigned)(n * sizeof(XPointer)));
}
@@ -141,7 +141,7 @@ _XcmsPushPointerArray(
/* add 2: 1 for the new pointer and another for the NULL pointer */
n += 2;
- if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ if ((newArray = Xmalloc(n * sizeof(XPointer)))) {
memcpy((char *)(newArray+1),(char *)pap,
(unsigned)((n-1) * sizeof(XPointer)));
*newArray = p;
@@ -183,8 +183,7 @@ _XcmsInitDefaultCCCs(
* Create an array of XcmsCCC structures, one for each screen.
* They serve as the screen's default CCC.
*/
- if (!(ccc = (XcmsCCC)
- Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
+ if (!(ccc = Xcalloc((unsigned)nScrn, sizeof(XcmsCCCRec)))) {
return(0);
}
dpy->cms.defaultCCCs = (XPointer)ccc;
@@ -322,8 +321,8 @@ _XcmsInitScrnInfo(
* for the latter (see XcmsCreateCCC). The ones created
* here are referenced by the default CCC.
*/
- if (!(defaultccc->pPerScrnInfo = (XcmsPerScrnInfo *)
- Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ if (!(defaultccc->pPerScrnInfo =
+ Xcalloc(1, sizeof(XcmsPerScrnInfo)))) {
return(0);
}
defaultccc->pPerScrnInfo->state = XcmsInitNone;
diff --git a/nx-X11/lib/X11/cmsMath.c b/nx-X11/lib/X11/cmsMath.c
index 70b067587..487eb3f9c 100644
--- a/nx-X11/lib/X11/cmsMath.c
+++ b/nx-X11/lib/X11/cmsMath.c
@@ -35,6 +35,10 @@ in this Software without prior written authorization from The Open Group.
#include "Xlibint.h"
#include "Xcmsint.h"
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
#include <float.h>
#ifndef DBL_EPSILON
#define DBL_EPSILON 1e-6
diff --git a/nx-X11/lib/X11/cmsProp.c b/nx-X11/lib/X11/cmsProp.c
index 0e8f8a2ba..a7aa5b5c5 100644
--- a/nx-X11/lib/X11/cmsProp.c
+++ b/nx-X11/lib/X11/cmsProp.c
@@ -125,20 +125,23 @@ _XcmsGetProperty(
unsigned long nitems_ret, after_ret;
#endif
Atom atom_ret;
+ int xgwp_ret;
- while (XGetWindowProperty (pDpy, w, property, 0, len, False,
- XA_INTEGER, &atom_ret, &format_ret,
- &nitems_ret, &after_ret,
- (unsigned char **)&prop_ret)) {
- if (after_ret > 0) {
+ while (True) {
+ xgwp_ret = XGetWindowProperty (pDpy, w, property, 0, len, False,
+ XA_INTEGER, &atom_ret, &format_ret,
+ &nitems_ret, &after_ret,
+ (unsigned char **)&prop_ret);
+ if (xgwp_ret == Success && after_ret > 0) {
len += nitems_ret * (format_ret >> 3);
XFree (prop_ret);
} else {
break;
}
}
- if (format_ret == 0 || nitems_ret == 0) {
- /* the property does not exist or is of an unexpected type */
+ if (xgwp_ret != Success || format_ret == 0 || nitems_ret == 0) {
+ /* the property does not exist or is of an unexpected type or
+ getting window property failed */
return(XcmsFailure);
}
diff --git a/nx-X11/lib/X11/cmsTrig.c b/nx-X11/lib/X11/cmsTrig.c
index a917b78db..b23033aa8 100644
--- a/nx-X11/lib/X11/cmsTrig.c
+++ b/nx-X11/lib/X11/cmsTrig.c
@@ -375,21 +375,10 @@ static double _XcmsPolynomial(
{
auto double rtn_value;
-#if 0
- auto double curr_coeff;
- if (order <= 0) {
- rtn_value = *coeffs;
- } else {
- curr_coeff = *coeffs; /* Bug in Unisoft's compiler. Does not */
- coeffs++; /* generate good code for *coeffs++ */
- rtn_value = curr_coeff + x * _XcmsPolynomial (--order, coeffs, x);
- }
-#else /* ++jrb -- removed tail recursion */
coeffs += order;
rtn_value = *coeffs--;
while(order-- > 0)
rtn_value = *coeffs-- + (x * rtn_value);
-#endif
return(rtn_value);
}
diff --git a/nx-X11/lib/X11/globals.c b/nx-X11/lib/X11/globals.c
index d1cab6ba5..efae2f8bb 100644
--- a/nx-X11/lib/X11/globals.c
+++ b/nx-X11/lib/X11/globals.c
@@ -53,15 +53,9 @@ from The Open Group.
/*
* If we need to define extra variables for each global
*/
-#if !defined(UNIXCPP) || defined(ANSICPP)
#define ZEROINIT(t,var,val) SetZero(t,var,val); \
SetZero (long, _libX_##var##Flag, 0); \
SetZero (void *, _libX_##var##Ptr, NULL)
-#else /* else pcc concatenation */
-#define ZEROINIT(t,var,val) SetZero(t,var,val); \
- SetZero (long, _libX_/**/var/**/Flag, 0); \
- SetZero (void *, _libX_/**/var/**/Ptr, NULL)
-#endif /* concat ANSI C vs. pcc */
#else /* else not USL_SHAREDLIB */
/*
@@ -87,127 +81,6 @@ ZEROINIT (int, _Xdebug, 0);
ZEROINIT (Display *, _XHeadOfDisplayList, NULL);
-
-#if 0
-#ifdef STREAMSCONN
-
-
-/* The following are how the Xstream connections are used: */
-/* 1) Local connections over pseudo-tty ports. */
-/* 2) SVR4 local connections using named streams or SVR3.2 */
-/* local connections using streams. */
-/* 3) SVR4 stream pipe code. This code is proprietary and */
-/* the actual code is not included in the XC distribution. */
-/* 4) remote connections using tcp */
-/* 5) remote connections using StarLan */
-
-/*
- * descriptor block for streams connections
- */
-
-#include "Xstreams.h"
-
-char _XsTypeOfStream[100] = { 0 };
-
-extern int write();
-extern int close();
-#ifdef SVR4
-extern int _XsSetupSpStream();
-extern int _XsSetupNamedStream();
-#endif
-extern int _XsSetupLocalStream();
-extern int _XsConnectLocalClient();
-extern int _XsCallLocalServer();
-extern int _XsReadLocalStream();
-extern int _XsErrorCall();
-extern int _XsWriteLocalStream();
-extern int _XsCloseLocalStream();
-extern int _XsSetupTliStream();
-extern int _XsConnectTliClient();
-extern int _XsCallTliServer();
-extern int _XsReadTliStream();
-extern int _XsWriteTliStream();
-extern int _XsCloseTliStream();
-
-
-Xstream _XsStream[] = {
-
- {
- /* local connections using pseudo-ttys */
-
- _XsSetupLocalStream,
- _XsConnectLocalClient,
- _XsCallLocalServer,
- _XsReadLocalStream,
- _XsErrorCall,
- write,
- close,
- NULL
- },
- {
-#ifdef SVR4
- /* local connections using named streams */
-
- _XsSetupNamedStream,
-#else
- /* local connections using streams */
- _XsSetupLocalStream,
-#endif
- _XsConnectLocalClient,
- _XsCallLocalServer,
- _XsReadLocalStream,
- _XsErrorCall,
- write,
- close,
- NULL
- },
- /* Enhanced Application Compatibility Support */
- {
-#ifdef SVR4
- /* SVR4 stream pipe code */
- _XsSetupSpStream,
-#else
- _XsSetupLocalStream,
-#endif
- _XsConnectLocalClient,
- _XsCallLocalServer,
- _XsReadLocalStream,
- _XsErrorCall,
- write,
- close,
- NULL
- },
- /* End Enhanced Application Compatibility Support */
-
- {
- /* remote connections using tcp */
- _XsSetupTliStream,
- _XsConnectTliClient,
- _XsCallTliServer,
- _XsReadLocalStream,
- _XsErrorCall,
- write,
- close,
- NULL
- },
- {
- /* remote connections using StarLan */
- _XsSetupTliStream,
- _XsConnectTliClient,
- _XsCallTliServer,
- _XsReadLocalStream,
- _XsErrorCall,
- write,
- close,
- NULL
- }
-};
-
-
-#endif /* STREAMSCONN */
-#endif
-
-
#ifdef XTEST1
/*
* Stuff for input synthesis extension:
diff --git a/nx-X11/lib/X11/imCallbk.c b/nx-X11/lib/X11/imCallbk.c
index 866b27c64..4e091d8ef 100644
--- a/nx-X11/lib/X11/imCallbk.c
+++ b/nx-X11/lib/X11/imCallbk.c
@@ -39,10 +39,6 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
#include "XlcPubI.h"
-#ifdef X_LOCALE
-#define mblen(a,b) _Xmblen(a,b)
-extern int _Xmblen ();
-#endif
#define sz_CARD8 1
#define sz_INT8 1
@@ -92,17 +88,17 @@ typedef XimCbStatus (*XimCb)(
(im->private.proto.read((im),(XPointer)(buf),(buf_len),&(len)))
#define _XimFlushData(im) im->private.proto.flush((im))
-Private XimCbStatus _XimGeometryCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimStrConversionCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimPreeditStartCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimPreeditDoneCallback(Xim, Xic, char*, int);
-Private void _free_memory_for_text(XIMText*);
-Private XimCbStatus _XimPreeditDrawCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimPreeditCaretCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimStatusStartCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimStatusDoneCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimStatusDrawCallback(Xim, Xic, char*, int);
-Private XimCbStatus _XimPreeditStateNotifyCallback(Xim, Xic, char *, int);
+static XimCbStatus _XimGeometryCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimStrConversionCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimPreeditStartCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimPreeditDoneCallback(Xim, Xic, char*, int);
+static void _free_memory_for_text(XIMText*);
+static XimCbStatus _XimPreeditDrawCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimPreeditCaretCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimStatusStartCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimStatusDoneCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimStatusDrawCallback(Xim, Xic, char*, int);
+static XimCbStatus _XimPreeditStateNotifyCallback(Xim, Xic, char *, int);
#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
#define RConst /**/
@@ -138,13 +134,13 @@ static RConst XimCb callback_table[] = {
};
-Private Bool
+static Bool
_XimIsReadyForProcess(Xic ic)
{
return(!ic->private.proto.waitCallback); /* check HM */
}
-Private void
+static void
_XimProcessPendingCallbacks(Xic ic)
{
XimPendingCallback pcbq;
@@ -161,7 +157,7 @@ _XimProcessPendingCallbacks(Xic ic)
}
}
-Private void
+static void
_XimPutCbIntoQueue(Xic ic, XimPendingCallback call_data)
{
XimPendingCallback pcbq = ic->private.proto.pend_cb_que;
@@ -182,7 +178,7 @@ _XimPutCbIntoQueue(Xic ic, XimPendingCallback call_data)
}
}
-Public Bool
+Bool
_XimCbDispatch(Xim xim,
INT16 len,
XPointer data,
@@ -230,9 +226,9 @@ _XimCbDispatch(Xim xim,
/* queue the protocol
*/
XimPendingCallback pcb;
- char *proto_buf = (proto_len > 0) ? (char*)Xmalloc(proto_len) : NULL;
+ char *proto_buf = (proto_len > 0) ? Xmalloc(proto_len) : NULL;
- pcb = (XimPendingCallback)Xmalloc(sizeof(XimPendingCallbackRec));
+ pcb = Xmalloc(sizeof(XimPendingCallbackRec));
if (pcb && (proto_len <= 0 || proto_buf)) {
if (proto_len > 0)
memcpy(proto_buf, proto, proto_len);
@@ -247,6 +243,8 @@ _XimCbDispatch(Xim xim,
/* status = XimCbQueued; */
} else {
/* status = XimCbError; */
+ Xfree(pcb);
+ Xfree(proto_buf);
}
}
else {
@@ -259,7 +257,7 @@ _XimCbDispatch(Xim xim,
return True;
}
-Private XimCbStatus
+static XimCbStatus
_XimGeometryCallback(Xim im,
Xic ic,
char* proto,
@@ -282,7 +280,7 @@ _XimGeometryCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimStrConversionCallback(Xim im,
Xic ic,
char* proto,
@@ -337,7 +335,7 @@ _XimStrConversionCallback(Xim im,
2 + length_in_bytes +
XIM_PAD(2 + length_in_bytes) +
2 + 2 + sz_CARD32 * cbrec.text->length;
- buf = (CARD8*)Xmalloc(buf_len);
+ buf = Xmalloc(buf_len);
}
_XimSetHeader((XPointer)buf, XIM_STR_CONVERSION_REPLY, 0, &buf_len);
buf_len -= XIM_HEADER_SIZE; /* added by _XimSetHeader (HACK) */
@@ -365,7 +363,7 @@ _XimStrConversionCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimPreeditStartCallback(Xim im,
Xic ic,
char* proto,
@@ -414,7 +412,7 @@ _XimPreeditStartCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimPreeditDoneCallback(Xim im,
Xic ic,
char* proto,
@@ -437,7 +435,7 @@ _XimPreeditDoneCallback(Xim im,
return XimCbSuccess;
}
-Private void
+static void
_read_text_from_packet(Xim im,
char* buf,
XIMText** text_ptr)
@@ -459,12 +457,12 @@ _read_text_from_packet(Xim im,
return;
}
- *text_ptr = text = (XIMText*)Xmalloc(sizeof(XIMText));
+ *text_ptr = text = Xmalloc(sizeof(XIMText));
if (text == (XIMText*)NULL) return;
tmp_len = (int)*(CARD16*)buf;
buf += sz_CARD16;
- if ((tmp_buf = (char*)Xmalloc(tmp_len + 1))) {
+ if ((tmp_buf = Xmalloc(tmp_len + 1))) {
memcpy(tmp_buf, buf, tmp_len);
tmp_buf[tmp_len] = '\0';
@@ -475,11 +473,10 @@ _read_text_from_packet(Xim im,
if (s != XLookupNone) {
#ifndef NO_DEC_I18N_FIX
/* Allow for NULL-terminated */
- if ((text->string.multi_byte =
- (char*)Xmalloc(text->length *
+ if ((text->string.multi_byte = Xmalloc(text->length *
XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1))) {
#else
- if (text->string.multi_byte = (char*)Xmalloc(text->length+1)) {
+ if (text->string.multi_byte = Xmalloc(text->length+1)) {
#endif
int tmp;
#ifndef NO_DEC_I18N_FIX
@@ -528,7 +525,7 @@ _read_text_from_packet(Xim im,
i = (int)*(CARD16*)buf; buf += sz_CARD16;
buf += sz_CARD16; /* skip `unused' */
- text->feedback = (XIMFeedback*)Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
+ text->feedback = Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
j = 0;
while (i > 0) {
text->feedback[j] = (XIMFeedback)*(CARD32*)buf;
@@ -552,19 +549,17 @@ _read_text_from_packet(Xim im,
}
}
-Private void
+static void
_free_memory_for_text(XIMText* text)
{
if (text) {
- if (text->string.multi_byte)
- Xfree(text->string.multi_byte);
- if (text->feedback)
- Xfree(text->feedback);
+ Xfree(text->string.multi_byte);
+ Xfree(text->feedback);
Xfree(text);
}
}
-Private XimCbStatus
+static XimCbStatus
_XimPreeditDrawCallback(Xim im,
Xic ic,
char* proto,
@@ -595,7 +590,7 @@ _XimPreeditDrawCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimPreeditCaretCallback(Xim im,
Xic ic,
char* proto,
@@ -647,7 +642,7 @@ _XimPreeditCaretCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimStatusStartCallback(Xim im,
Xic ic,
char* proto,
@@ -670,7 +665,7 @@ _XimStatusStartCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimStatusDoneCallback(Xim im,
Xic ic,
char* proto,
@@ -693,7 +688,7 @@ _XimStatusDoneCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimStatusDrawCallback(Xim im,
Xic ic,
char* proto,
@@ -728,7 +723,7 @@ _XimStatusDrawCallback(Xim im,
return XimCbSuccess;
}
-Private XimCbStatus
+static XimCbStatus
_XimPreeditStateNotifyCallback( Xim im, Xic ic, char* proto, int len )
{
XICCallback *cb = &ic->core.preedit_attr.state_notify_callback;
diff --git a/nx-X11/lib/X11/imDefFlt.c b/nx-X11/lib/X11/imDefFlt.c
index 9717aa2c3..b6473e176 100644
--- a/nx-X11/lib/X11/imDefFlt.c
+++ b/nx-X11/lib/X11/imDefFlt.c
@@ -35,7 +35,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Private long
+static long
_XimTriggerCheck(
Xim im,
XKeyEvent *ev,
@@ -66,7 +66,7 @@ _XimTriggerCheck(
return -1;
}
-Private long
+static long
_XimTriggerOnCheck(
Xim im,
XKeyEvent *ev)
@@ -75,7 +75,7 @@ _XimTriggerOnCheck(
&im->private.proto.im_onkeylist[1]);
}
-Private long
+static long
_XimTriggerOffCheck(
Xim im,
XKeyEvent *ev)
@@ -84,7 +84,7 @@ _XimTriggerOffCheck(
&im->private.proto.im_offkeylist[1]);
}
-Private Bool
+static Bool
_XimOnKeysCheck(
Xic ic,
XKeyEvent *ev)
@@ -103,7 +103,7 @@ _XimOnKeysCheck(
return False;
}
-Private Bool
+static Bool
_XimOffKeysCheck(
Xic ic,
XKeyEvent *ev)
@@ -122,31 +122,29 @@ _XimOffKeysCheck(
return False;
}
-Private void
+static void
_XimPendingFilter(
Xic ic)
{
Xim im = (Xim)ic->core.im;
- if (IS_NEED_SYNC_REPLY(ic)) {
+ if (IS_NEED_SYNC_REPLY(im)) {
(void)_XimProcSyncReply(im, ic);
- UNMARK_NEED_SYNC_REPLY(ic);
+ UNMARK_NEED_SYNC_REPLY(im);
}
return;
}
-Private Bool
+static Bool
_XimProtoKeypressFilter(
Xic ic,
XKeyEvent *ev)
{
-#ifdef XIM_CONNECTABLE
Xim im = (Xim)ic->core.im;
-#endif
- if (IS_FABLICATED(ic)) {
+ if (IS_FABRICATED(im)) {
_XimPendingFilter(ic);
- UNMARK_FABLICATED(ic);
+ UNMARK_FABRICATED(im);
return NOTFILTERD;
}
@@ -188,7 +186,7 @@ _XimProtoKeypressFilter(
return NOTFILTERD;
}
-Private Bool
+static Bool
_XimFilterKeypress(
Display *d,
Window w,
@@ -198,18 +196,16 @@ _XimFilterKeypress(
return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
}
-Private Bool
+static Bool
_XimProtoKeyreleaseFilter(
Xic ic,
XKeyEvent *ev)
{
-#ifdef XIM_CONNECTABLE
Xim im = (Xim)ic->core.im;
-#endif
- if (IS_FABLICATED(ic)) {
+ if (IS_FABRICATED(im)) {
_XimPendingFilter(ic);
- UNMARK_FABLICATED(ic);
+ UNMARK_FABRICATED(im);
return NOTFILTERD;
}
@@ -251,7 +247,7 @@ _XimProtoKeyreleaseFilter(
return NOTFILTERD;
}
-Private Bool
+static Bool
_XimFilterKeyrelease(
Display *d,
Window w,
@@ -261,7 +257,7 @@ _XimFilterKeyrelease(
return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
}
-Private void
+static void
_XimRegisterKeyPressFilter(
Xic ic)
{
@@ -278,7 +274,7 @@ _XimRegisterKeyPressFilter(
return;
}
-Private void
+static void
_XimRegisterKeyReleaseFilter(
Xic ic)
{
@@ -295,7 +291,7 @@ _XimRegisterKeyReleaseFilter(
return;
}
-Private void
+static void
_XimUnregisterKeyPressFilter(
Xic ic)
{
@@ -311,7 +307,7 @@ _XimUnregisterKeyPressFilter(
return;
}
-Private void
+static void
_XimUnregisterKeyReleaseFilter(
Xic ic)
{
@@ -327,7 +323,7 @@ _XimUnregisterKeyReleaseFilter(
return;
}
-Public void
+void
_XimRegisterFilter(
Xic ic)
{
@@ -337,7 +333,7 @@ _XimRegisterFilter(
return;
}
-Public void
+void
_XimUnregisterFilter(
Xic ic)
{
@@ -346,7 +342,7 @@ _XimUnregisterFilter(
return;
}
-Public void
+void
_XimReregisterFilter(
Xic ic)
{
@@ -358,7 +354,7 @@ _XimReregisterFilter(
return;
}
-Private Bool
+static Bool
_XimFilterServerDestroy(
Display *d,
Window w,
@@ -380,7 +376,7 @@ _XimFilterServerDestroy(
return True;
}
-Public void
+void
_XimRegisterServerFilter(
Xim im)
{
@@ -399,7 +395,7 @@ _XimRegisterServerFilter(
return;
}
-Public void
+void
_XimUnregisterServerFilter(
Xim im)
{
diff --git a/nx-X11/lib/X11/imDefIc.c b/nx-X11/lib/X11/imDefIc.c
index ba720b56c..3cf46827a 100644
--- a/nx-X11/lib/X11/imDefIc.c
+++ b/nx-X11/lib/X11/imDefIc.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1991, 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1991, 1992 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"),
@@ -56,7 +56,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Private Bool
+static Bool
_XimCreateICCheck(
Xim im,
INT16 len,
@@ -81,7 +81,7 @@ _XimCreateICCheck(
}
#ifdef XIM_CONNECTABLE
-Public Bool
+Bool
_XimReCreateIC(ic)
Xic ic;
{
@@ -108,7 +108,7 @@ _XimReCreateIC(ic)
XPointer preply;
int ret_code;
- if (!(save_ic = (Xic)Xmalloc(sizeof(XicRec))))
+ if (!(save_ic = Xmalloc(sizeof(XicRec))))
return False;
memcpy((char *)save_ic, (char *)ic, sizeof(XicRec));
@@ -120,7 +120,7 @@ _XimReCreateIC(ic)
num = im->core.ic_num_resources;
buf_size = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ if (!(res = Xmalloc(buf_size)))
goto ErrorOnReCreateIC;
(void)memcpy((char *)res, (char *)im->core.ic_resources, buf_size);
ic->private.proto.ic_resources = res;
@@ -128,7 +128,7 @@ _XimReCreateIC(ic)
num = im->private.proto.ic_num_inner_resources;
buf_size = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ if (!(res = Xmalloc(buf_size)))
goto ErrorOnReCreateIC;
(void)memcpy((char *)res,
(char *)im->private.proto.ic_inner_resources, buf_size);
@@ -164,13 +164,13 @@ _XimReCreateIC(ic)
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
goto ErrorOnReCreateIC;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
goto ErrorOnReCreateIC;
}
@@ -203,7 +203,7 @@ _XimReCreateIC(ic)
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimCreateICCheck, 0);
if (ret_code != XIM_TRUE) {
@@ -244,7 +244,7 @@ ErrorOnReCreateIC:
return False;
}
-Private char *
+static char *
_XimDelayModeGetICValues(ic, arg)
Xic ic;
XIMArg *arg;
@@ -259,7 +259,7 @@ _XimDelayModeGetICValues(ic, arg)
}
#endif /* XIM_CONNECTABLE */
-Private Bool
+static Bool
_XimGetICValuesCheck(
Xim im,
INT16 len,
@@ -288,7 +288,7 @@ _XimGetICValuesCheck(
return False;
}
-Private char *
+static char *
_XimProtoGetICValues(
XIC xic,
XIMArg *arg)
@@ -351,7 +351,7 @@ _XimProtoGetICValues(
+ sizeof(INT16)
+ XIM_PAD(2 + buf_size);
- if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ if (!(buf = Xmalloc(buf_size)))
return arg->name;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -385,7 +385,7 @@ _XimProtoGetICValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimGetICValuesCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -424,7 +424,7 @@ _XimProtoGetICValues(
}
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimCheckNestQuarkList(quark_list, num_quark, quark, separator)
XrmQuark *quark_list;
int num_quark;
@@ -444,7 +444,7 @@ _XimCheckNestQuarkList(quark_list, num_quark, quark, separator)
return False;
}
-Private Bool
+static Bool
_XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
XrmQuark **quark_list;
int idx;
@@ -465,7 +465,7 @@ _XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
quark, separator)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
+ if (!(tmp = Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
*quark_list = q_list;
*num_quark = n_quark;
return False;
@@ -485,7 +485,7 @@ _XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
return True;
}
-Private Bool
+static Bool
_XimCheckICQuarkList(quark_list, num_quark, quark, idx)
XrmQuark *quark_list;
int num_quark;
@@ -503,7 +503,7 @@ _XimCheckICQuarkList(quark_list, num_quark, quark, idx)
return False;
}
-Private Bool
+static Bool
_XimSaveICValues(ic, arg)
Xic ic;
XIMArg *arg;
@@ -535,7 +535,7 @@ _XimSaveICValues(ic, arg)
for (pp = (XIMArg *)p->value, nn = 0;
pp && pp->name; pp++, nn++);
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + nn + 2))))) {
ic->private.proto.saved_icvalues = quark_list;
ic->private.proto.num_saved_icvalues = num_quark;
@@ -562,7 +562,7 @@ _XimSaveICValues(ic, arg)
if (_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + 1))))) {
ic->private.proto.saved_icvalues = quark_list;
ic->private.proto.num_saved_icvalues = num_quark;
@@ -589,7 +589,7 @@ _XimSaveICValues(ic, arg)
}
}
- if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ if (!(quark_list = Xmalloc(sizeof(XrmQuark) * n))) {
return False;
}
@@ -610,7 +610,7 @@ _XimSaveICValues(ic, arg)
return True;
}
-Private char *
+static char *
_XimDelayModeSetICValues(ic, arg)
Xic ic;
XIMArg *arg;
@@ -628,7 +628,7 @@ _XimDelayModeSetICValues(ic, arg)
}
#endif /* XIM_CONNECTABLE */
-Private Bool
+static Bool
_XimSetICValuesCheck(
Xim im,
INT16 len,
@@ -657,7 +657,7 @@ _XimSetICValuesCheck(
return False;
}
-Private char *
+static char *
_XimProtoSetICValues(
XIC xic,
XIMArg *arg)
@@ -731,13 +731,13 @@ _XimProtoSetICValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return tmp_name;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return tmp_name;
}
@@ -781,7 +781,7 @@ _XimProtoSetICValues(
preply = reply;
} else if (ret_code == XIM_OVERFLOW) {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSetICValuesCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -807,7 +807,7 @@ _XimProtoSetICValues(
return name;
}
-Private Bool
+static Bool
_XimDestroyICCheck(
Xim im,
INT16 len,
@@ -837,7 +837,7 @@ _XimDestroyICCheck(
return ret;
}
-Private void
+static void
_XimProtoICFree(
Xic ic)
{
@@ -884,7 +884,7 @@ _XimProtoICFree(
return;
}
-Private void
+static void
_XimProtoDestroyIC(
XIC xic)
{
@@ -915,7 +915,7 @@ _XimProtoDestroyIC(
_XimDestroyICCheck, (XPointer)ic);
if (ret_code == XIM_OVERFLOW) {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
(void)_XimRead(im, &len, preply, buf_size,
_XimDestroyICCheck, (XPointer)ic);
Xfree(preply);
@@ -927,7 +927,7 @@ _XimProtoDestroyIC(
return;
}
-Private void
+static void
_XimProtoSetFocus(
XIC xic)
{
@@ -968,13 +968,11 @@ _XimProtoSetFocus(
(void)_XimWrite(im, len, (XPointer)buf);
_XimFlush(im);
- MARK_FOCUSED(ic);
-
_XimRegisterFilter(ic);
return;
}
-Private void
+static void
_XimProtoUnsetFocus(
XIC xic)
{
@@ -1015,13 +1013,11 @@ _XimProtoUnsetFocus(
(void)_XimWrite(im, len, (XPointer)buf);
_XimFlush(im);
- UNMARK_FOCUSED(ic);
-
_XimUnregisterFilter(ic);
return;
}
-Private Bool
+static Bool
_XimResetICCheck(
Xim im,
INT16 len,
@@ -1050,7 +1046,7 @@ _XimResetICCheck(
return False;
}
-Private char *
+static char *
_XimProtoReset(
XIC xic,
char * (*retfunc) (Xim im, Xic ic, XPointer buf) )
@@ -1092,7 +1088,7 @@ _XimProtoReset(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimResetICCheck, (XPointer)ic);
if (ret_code != XIM_TRUE) {
@@ -1121,7 +1117,7 @@ _XimProtoReset(
return commit;
}
-Private char *
+static char *
_XimCommitedMbString(
Xim im,
Xic ic,
@@ -1143,7 +1139,7 @@ _XimCommitedMbString(
if ( len == 0 )
return( NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1171,14 +1167,14 @@ Error_On_Reset:
return new_commit;
}
-Private char *
+static char *
_XimProtoMbReset(
XIC xic)
{
return _XimProtoReset(xic, _XimCommitedMbString);
}
-Private wchar_t *
+static wchar_t *
_XimCommitedWcString(
Xim im,
Xic ic,
@@ -1200,7 +1196,7 @@ _XimCommitedWcString(
if ( len == 0 )
return( (wchar_t *)NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1229,7 +1225,7 @@ Error_On_Reset:
return new_commit;
}
-Private wchar_t *
+static wchar_t *
_XimProtoWcReset(
XIC xic)
{
@@ -1237,7 +1233,7 @@ _XimProtoWcReset(
(char * (*) (Xim, Xic, XPointer)) _XimCommitedWcString);
}
-Private char *
+static char *
_XimCommitedUtf8String(
Xim im,
Xic ic,
@@ -1259,7 +1255,7 @@ _XimCommitedUtf8String(
if ( len == 0 )
return( NULL );
- if (!(commit = (char *)Xmalloc(len + 1)))
+ if (!(commit = Xmalloc(len + 1)))
goto Error_On_Reset;
str = commit;
@@ -1287,14 +1283,14 @@ Error_On_Reset:
return new_commit;
}
-Private char *
+static char *
_XimProtoUtf8Reset(
XIC xic)
{
return _XimProtoReset(xic, _XimCommitedUtf8String);
}
-Private XICMethodsRec ic_methods = {
+static XICMethodsRec ic_methods = {
_XimProtoDestroyIC, /* destroy */
_XimProtoSetFocus, /* set_focus */
_XimProtoUnsetFocus, /* unset_focus */
@@ -1308,7 +1304,7 @@ Private XICMethodsRec ic_methods = {
_XimProtoUtf8LookupString /* utf8_lookup_string */
};
-Private Bool
+static Bool
_XimGetInputStyle(
XIMArg *arg,
XIMStyle *input_style)
@@ -1325,7 +1321,7 @@ _XimGetInputStyle(
}
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimDelayModeCreateIC(
Xic ic,
XIMArg *values,
@@ -1360,7 +1356,7 @@ _XimDelayModeCreateIC(
return True;
}
-Public Bool
+Bool
_XimReconnectModeCreateIC(ic)
Xic ic;
{
@@ -1372,7 +1368,7 @@ _XimReconnectModeCreateIC(ic)
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
+ if (!(res = Xmalloc(len)))
return False;
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
ic->private.proto.ic_resources = res;
@@ -1386,7 +1382,7 @@ _XimReconnectModeCreateIC(ic)
}
#endif /* XIM_CONNECTABLE */
-Public XIC
+XIC
_XimProtoCreateIC(
XIM xim,
XIMArg *arg)
@@ -1425,18 +1421,17 @@ _XimProtoCreateIC(
if (!(_XimGetInputStyle(arg, &input_style)))
return (XIC)NULL;
- if ((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL)
+ if ((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL)
return (XIC)NULL;
- bzero((char *)ic, sizeof(XicRec));
ic->methods = &ic_methods;
ic->core.im = (XIM)im;
ic->core.input_style = input_style;
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
- return (XIC)NULL;
+ if (!(res = Xmalloc(len)))
+ goto ErrorOnCreatingIC;
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
ic->private.proto.ic_resources = res;
ic->private.proto.ic_num_resources = num;
@@ -1463,8 +1458,8 @@ _XimProtoCreateIC(
num = im->private.proto.ic_num_inner_resources;
len = sizeof(XIMResource) * num;
- if (!(res = (XIMResourceList)Xmalloc(len)))
- return (XIC)NULL;
+ if (!(res = Xmalloc(len)))
+ goto ErrorOnCreatingIC;
(void)memcpy((char *)res,
(char *)im->private.proto.ic_inner_resources, len);
ic->private.proto.ic_inner_resources = res;
@@ -1497,13 +1492,13 @@ _XimProtoCreateIC(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
goto ErrorOnCreatingIC;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
goto ErrorOnCreatingIC;
}
@@ -1543,7 +1538,7 @@ _XimProtoCreateIC(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimCreateICCheck, 0);
if (ret_code != XIM_TRUE) {
@@ -1573,10 +1568,9 @@ _XimProtoCreateIC(
ErrorOnCreatingIC:
_XimUnregisterFilter(ic);
- if (ic->private.proto.ic_resources)
- Xfree(ic->private.proto.ic_resources);
- if (ic->private.proto.ic_inner_resources)
- Xfree(ic->private.proto.ic_inner_resources);
+
+ Xfree(ic->private.proto.ic_resources);
+ Xfree(ic->private.proto.ic_inner_resources);
Xfree(ic);
return (XIC)NULL;
}
diff --git a/nx-X11/lib/X11/imDefIm.c b/nx-X11/lib/X11/imDefIm.c
index f29f44436..2a1ccb4ec 100644
--- a/nx-X11/lib/X11/imDefIm.c
+++ b/nx-X11/lib/X11/imDefIm.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1990, 1991, 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1990, 1991, 1992 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"),
@@ -63,7 +63,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
-Public int
+int
_XimCheckDataSize(
XPointer buf,
int len)
@@ -75,7 +75,7 @@ _XimCheckDataSize(
return buf_s[1];
}
-Public void
+void
_XimSetHeader(
XPointer buf,
CARD8 major_opcode,
@@ -93,7 +93,7 @@ _XimSetHeader(
return;
}
-Public char
+char
_XimGetMyEndian(void)
{
CARD16 test_card = 1;
@@ -104,7 +104,7 @@ _XimGetMyEndian(void)
return BIGENDIAN;
}
-Private Bool
+static Bool
_XimCheckServerName(
Xim im,
char *str)
@@ -142,7 +142,7 @@ _XimCheckServerName(
return True;
}
-Private char *
+static char *
_XimCheckLocaleName(
Xim im,
char *address,
@@ -182,7 +182,7 @@ _XimCheckLocaleName(
return (char *)NULL;
}
-Private Bool
+static Bool
_XimCheckTransport(
char *address,
int address_len,
@@ -226,7 +226,7 @@ _XimCheckTransport(
return True;
}
-Private Bool
+static Bool
_CheckSNEvent(
Display *display,
XEvent *xevent,
@@ -240,7 +240,7 @@ _CheckSNEvent(
return False;
}
-Private Bool
+static Bool
_XimGetSelectionNotify(
Display *display,
Window window,
@@ -269,7 +269,7 @@ _XimGetSelectionNotify(
return True;
}
-Private Bool
+static Bool
_XimPreConnectionIM(
Xim im,
Atom selection)
@@ -387,7 +387,7 @@ Error:
return False;
}
-Private Bool
+static Bool
_XimPreConnect(
Xim im)
{
@@ -434,7 +434,7 @@ _XimPreConnect(
return True;
}
-Private Bool
+static Bool
_XimGetAuthProtocolNames(
Xim im,
CARD16 *buf,
@@ -452,7 +452,7 @@ _XimGetAuthProtocolNames(
return True;
}
-Private Bool
+static Bool
_XimSetAuthReplyData(
Xim im,
XPointer buf,
@@ -465,7 +465,7 @@ _XimSetAuthReplyData(
return True;
}
-Private Bool
+static Bool
_XimSetAuthNextData(
Xim im,
XPointer buf,
@@ -478,7 +478,7 @@ _XimSetAuthNextData(
return True;
}
-Private Bool
+static Bool
_XimSetAuthRequiredData(
Xim im,
XPointer buf,
@@ -491,7 +491,7 @@ _XimSetAuthRequiredData(
return True;
}
-Private Bool
+static Bool
_XimCheckAuthSetupData(
Xim im,
XPointer buf)
@@ -502,7 +502,7 @@ _XimCheckAuthSetupData(
return True;
}
-Private Bool
+static Bool
_XimCheckAuthNextData(
Xim im,
XPointer buf)
@@ -517,7 +517,7 @@ _XimCheckAuthNextData(
#define GOOD_AUTH 1
#define BAD_AUTH 0
-Private int
+static int
_XimClientAuthCheck(
Xim im,
XPointer buf)
@@ -528,7 +528,7 @@ _XimClientAuthCheck(
return NO_MORE_AUTH;
}
-Private void
+static void
_XimAuthNG(
Xim im)
{
@@ -542,7 +542,7 @@ _XimAuthNG(
return;
}
-Private Bool
+static Bool
_XimAllRecv(
Xim im,
INT16 len,
@@ -555,7 +555,7 @@ _XimAllRecv(
#define CLIENT_WAIT1 1
#define CLIENT_WAIT2 2
-Private Bool
+static Bool
_XimConnection(
Xim im)
{
@@ -616,7 +616,7 @@ _XimConnection(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size, _XimAllRecv, 0);
if(ret_code != XIM_TRUE) {
Xfree(preply);
@@ -716,7 +716,7 @@ _XimConnection(
return True;
}
-Private Bool
+static Bool
_XimDisconnectCheck(
Xim im,
INT16 len,
@@ -735,7 +735,7 @@ _XimDisconnectCheck(
return False;
}
-Private Bool
+static Bool
_XimDisconnect(
Xim im)
{
@@ -759,7 +759,7 @@ _XimDisconnect(
if(ret_code == XIM_OVERFLOW) {
if(len > 0) {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimDisconnectCheck, 0);
Xfree(preply);
@@ -775,7 +775,7 @@ _XimDisconnect(
return True;
}
-Private Bool
+static Bool
_XimOpenCheck(
Xim im,
INT16 len,
@@ -794,7 +794,7 @@ _XimOpenCheck(
return False;
}
-Private Bool
+static Bool
_XimOpen(
Xim im)
{
@@ -831,7 +831,7 @@ _XimOpen(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimOpenCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -890,7 +890,7 @@ _XimOpen(
return True;
}
-Private Bool
+static Bool
_XimCloseCheck(
Xim im,
INT16 len,
@@ -914,7 +914,7 @@ _XimCloseCheck(
return False;
}
-Private Bool
+static Bool
_XimClose(
Xim im)
{
@@ -950,7 +950,7 @@ _XimClose(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size, _XimCloseCheck, 0);
if(ret_code != XIM_TRUE) {
Xfree(preply);
@@ -972,7 +972,7 @@ _XimClose(
return True;
}
-Public void
+void
_XimProtoIMFree(
Xim im)
{
@@ -1090,7 +1090,7 @@ _XimProtoIMFree(
return;
}
-Private Status
+static Status
_XimProtoCloseIM(
XIM xim)
{
@@ -1105,10 +1105,10 @@ _XimProtoCloseIM(
next = ic->core.next;
#ifdef XIM_CONNECTABLE
if (!(!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im))) {
- Xfree ((char *) ic);
+ Xfree (ic);
}
#else
- Xfree ((char *) ic);
+ Xfree (ic);
#endif /* XIM_CONNECTABLE */
ic = next;
}
@@ -1138,7 +1138,7 @@ _XimProtoCloseIM(
}
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimCheckIMQuarkList(
XrmQuark *quark_list,
int num_quark,
@@ -1154,7 +1154,7 @@ _XimCheckIMQuarkList(
return False;
}
-Private Bool
+static Bool
_XimSaveIMValues(
Xim im,
XIMArg *arg)
@@ -1173,7 +1173,7 @@ _XimSaveIMValues(
if (_XimCheckIMQuarkList(quark_list, num_quark, quark)) {
continue;
}
- if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ if (!(tmp = Xrealloc(quark_list,
(sizeof(XrmQuark) * (num_quark + 1))))) {
im->private.proto.saved_imvalues = quark_list;
im->private.proto.num_saved_imvalues = num_quark;
@@ -1190,7 +1190,7 @@ _XimSaveIMValues(
for (p = arg, n = 0; p && p->name; p++, n++);
- if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ if (!(quark_list = Xmalloc(sizeof(XrmQuark) * n))) {
return False;
}
@@ -1203,7 +1203,7 @@ _XimSaveIMValues(
return True;
}
-Private char *
+static char *
_XimDelayModeSetIMValues(
Xim im,
XIMArg *arg)
@@ -1221,7 +1221,7 @@ _XimDelayModeSetIMValues(
}
#endif /* XIM_CONNECTABLE */
-Private Bool
+static Bool
_XimSetIMValuesCheck(
Xim im,
INT16 len,
@@ -1245,7 +1245,7 @@ _XimSetIMValuesCheck(
return False;
}
-Private char *
+static char *
_XimProtoSetIMValues(
XIM xim,
XIMArg *arg)
@@ -1311,13 +1311,13 @@ _XimProtoSetIMValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return arg->name;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return arg->name;
}
@@ -1353,7 +1353,7 @@ _XimProtoSetIMValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimSetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1377,7 +1377,7 @@ _XimProtoSetIMValues(
}
#ifdef XIM_CONNECTABLE
-Private char *
+static char *
_XimDelayModeGetIMValues(
Xim im,
XIMArg *arg)
@@ -1390,7 +1390,7 @@ _XimDelayModeGetIMValues(
}
#endif /* XIM_CONNECTABLE */
-Private Bool
+static Bool
_XimGetIMValuesCheck(
Xim im,
INT16 len,
@@ -1414,7 +1414,7 @@ _XimGetIMValuesCheck(
return False;
}
-Private char *
+static char *
_XimProtoGetIMValues(
XIM xim,
XIMArg *arg)
@@ -1462,7 +1462,7 @@ _XimProtoGetIMValues(
+ sizeof(INT16)
+ XIM_PAD(buf_size);
- if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ if (!(buf = Xmalloc(buf_size)))
return arg->name;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -1494,7 +1494,7 @@ _XimProtoGetIMValues(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimGetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1526,7 +1526,7 @@ _XimProtoGetIMValues(
return makeid_name;
}
-Private XIMMethodsRec im_methods = {
+static XIMMethodsRec im_methods = {
_XimProtoCloseIM, /* close */
_XimProtoSetIMValues, /* set_values */
_XimProtoGetIMValues, /* get_values */
@@ -1536,7 +1536,7 @@ Private XIMMethodsRec im_methods = {
_Ximctstoutf8 /* ctstoutf8 */
};
-Private Bool
+static Bool
_XimSetEncodingByName(
Xim im,
char **buf,
@@ -1556,7 +1556,7 @@ _XimSetEncodingByName(
encoding_len = strlen(encoding);
compound_len = strlen("COMPOUND_TEXT");
*len = encoding_len + sizeof(BYTE) + compound_len + sizeof(BYTE);
- if (!(ret = (BYTE *)Xmalloc(*len))) {
+ if (!(ret = Xmalloc(*len))) {
return False;
}
*buf = (char *)ret;
@@ -1569,7 +1569,7 @@ _XimSetEncodingByName(
return True;
}
-Private Bool
+static Bool
_XimSetEncodingByDetail(
Xim im,
char **buf,
@@ -1580,7 +1580,7 @@ _XimSetEncodingByDetail(
return True;
}
-Private Bool
+static Bool
_XimGetEncoding(
Xim im,
CARD16 *buf,
@@ -1669,7 +1669,7 @@ _XimGetEncoding(
return True;
}
-Private Bool
+static Bool
_XimEncodingNegoCheck(
Xim im,
INT16 len,
@@ -1693,7 +1693,7 @@ _XimEncodingNegoCheck(
return False;
}
-Private Bool
+static Bool
_XimEncodingNegotiation(
Xim im)
{
@@ -1713,11 +1713,8 @@ _XimEncodingNegotiation(
if (!(_XimSetEncodingByName(im, &name_ptr, &name_len)))
return False;
- if (!(_XimSetEncodingByDetail(im, &detail_ptr, &detail_len))) {
- if (name_ptr)
- Xfree(name_ptr);
- return False;
- }
+ if (!(_XimSetEncodingByDetail(im, &detail_ptr, &detail_len)))
+ goto free_name_ptr;
len = sizeof(CARD16)
+ sizeof(INT16)
@@ -1727,13 +1724,9 @@ _XimEncodingNegotiation(
+ sizeof(CARD16)
+ detail_len;
- if (!(buf = (CARD8 *)Xmalloc(XIM_HEADER_SIZE + len))) {
- if (name_ptr)
- Xfree(name_ptr);
- if (detail_ptr)
- Xfree(detail_ptr);
- return False;
- }
+ if (!(buf = Xmalloc(XIM_HEADER_SIZE + len)))
+ goto free_detail_ptr;
+
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
buf_s[0] = im->private.proto.imid;
@@ -1750,7 +1743,7 @@ _XimEncodingNegotiation(
_XimSetHeader((XPointer)buf, XIM_ENCODING_NEGOTIATION, 0, &len);
if (!(_XimWrite(im, len, (XPointer)buf))) {
Xfree(buf);
- return False;
+ goto free_detail_ptr;
}
_XimFlush(im);
Xfree(buf);
@@ -1764,43 +1757,47 @@ _XimEncodingNegotiation(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimEncodingNegoCheck, 0);
- if(ret_code != XIM_TRUE) {
- Xfree(preply);
- return False;
- }
+ if(ret_code != XIM_TRUE)
+ goto free_preply;
}
} else
- return False;
+ goto free_detail_ptr;
buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
if (*((CARD8 *)preply) == XIM_ERROR) {
_XimProcError(im, 0, (XPointer)&buf_s[3]);
- if(reply != preply)
- Xfree(preply);
- return False;
+ goto free_preply;
}
if (!(_XimGetEncoding(im, &buf_s[1], name_ptr, name_len,
- detail_ptr, detail_len))) {
- if(reply != preply)
- Xfree(preply);
- return False;
- }
- if (name_ptr)
- Xfree(name_ptr);
- if (detail_ptr)
- Xfree(detail_ptr);
+ detail_ptr, detail_len)))
+ goto free_preply;
+
+ Xfree(name_ptr);
+ Xfree(detail_ptr);
if(reply != preply)
Xfree(preply);
return True;
+
+free_preply:
+ if (reply != preply)
+ Xfree(preply);
+
+free_detail_ptr:
+ Xfree(detail_ptr);
+
+free_name_ptr:
+ Xfree(name_ptr);
+
+ return False;
}
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimSendSavedIMValues(
Xim im)
{
@@ -1845,13 +1842,13 @@ _XimSendSavedIMValues(
buf_size += ret_len;
if (buf == tmp_buf) {
- if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ if (!(tmp = Xmalloc(buf_size + data_len))) {
return False;
}
memcpy(tmp, buf, buf_size);
buf = tmp;
} else {
- if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ if (!(tmp = Xrealloc(buf, (buf_size + data_len)))) {
Xfree(buf);
return False;
}
@@ -1886,7 +1883,7 @@ _XimSendSavedIMValues(
preply = reply;
} else {
buf_size = (int)len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimSetIMValuesCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -1910,7 +1907,7 @@ _XimSendSavedIMValues(
return True;
}
-Private void
+static void
_XimDelayModeIMFree(
Xim im)
{
@@ -1933,13 +1930,13 @@ _XimDelayModeIMFree(
return;
}
-Public Bool
+Bool
_XimConnectServer(
Xim im)
{
Xim save_im;
- if (!(save_im = (Xim)Xmalloc(sizeof(XimRec))))
+ if (!(save_im = Xmalloc(sizeof(XimRec))))
return False;
memcpy((char *)save_im, (char *)im, sizeof(XimRec));
@@ -1957,7 +1954,7 @@ _XimConnectServer(
return False;
}
-Public Bool
+Bool
_XimDelayModeSetAttr(
Xim im)
{
@@ -1989,7 +1986,7 @@ _XimDelayModeSetAttr(
return True;
}
-Private Bool
+static Bool
_XimReconnectModeSetAttr(
Xim im)
{
@@ -2016,7 +2013,7 @@ _XimReconnectModeSetAttr(
}
#endif /* XIM_CONNECTABLE */
-Public Bool
+Bool
_XimProtoOpenIM(
Xim im)
{
diff --git a/nx-X11/lib/X11/imDefLkup.c b/nx-X11/lib/X11/imDefLkup.c
index d1c3a6567..af39008bc 100644
--- a/nx-X11/lib/X11/imDefLkup.c
+++ b/nx-X11/lib/X11/imDefLkup.c
@@ -34,7 +34,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Public Xic
+Xic
_XimICOfXICID(
Xim im,
XICID icid)
@@ -48,7 +48,7 @@ _XimICOfXICID(
return (Xic)0;
}
-Private void
+static void
_XimProcIMSetEventMask(
Xim im,
XPointer buf)
@@ -60,7 +60,7 @@ _XimProcIMSetEventMask(
return;
}
-Private void
+static void
_XimProcICSetEventMask(
Xic ic,
XPointer buf)
@@ -73,7 +73,7 @@ _XimProcICSetEventMask(
return;
}
-Public Bool
+Bool
_XimSetEventMaskCallback(
Xim xim,
INT16 len,
@@ -98,7 +98,7 @@ _XimSetEventMaskCallback(
return False;
}
-Private Bool
+static Bool
_XimSyncCheck(
Xim im,
INT16 len,
@@ -127,7 +127,7 @@ _XimSyncCheck(
return False;
}
-Public Bool
+Bool
_XimSync(
Xim im,
Xic ic)
@@ -162,7 +162,7 @@ _XimSync(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSyncCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -185,7 +185,7 @@ _XimSync(
return True;
}
-Public Bool
+Bool
_XimProcSyncReply(
Xim im,
Xic ic)
@@ -208,22 +208,18 @@ _XimProcSyncReply(
return True;
}
-Public Bool
+Bool
_XimRespSyncReply(
Xic ic,
BITMASK16 mode)
{
- if (mode & XimSYNCHRONUS) /* SYNC Request */ {
- if (IS_FOCUSED(ic))
- MARK_NEED_SYNC_REPLY(ic);
- else
- _XimProcSyncReply((Xim)ic->core.im, ic);
- }
+ if (mode & XimSYNCHRONUS) /* SYNC Request */
+ MARK_NEED_SYNC_REPLY(ic->core.im);
return True;
}
-Public Bool
+Bool
_XimSyncCallback(
Xim xim,
INT16 len,
@@ -244,7 +240,7 @@ _XimSyncCallback(
return False;
}
-Private INT16
+static INT16
_XimSetEventToWire(
XEvent *ev,
xEvent *event)
@@ -256,7 +252,7 @@ _XimSetEventToWire(
return sz_xEvent;
}
-Private Bool
+static Bool
_XimForwardEventCore(
Xic ic,
XEvent *ev,
@@ -273,6 +269,8 @@ _XimForwardEventCore(
int ret_code;
INT16 len;
+ bzero(buf32, sizeof(buf32)); /* valgrind noticed uninitialized memory use! */
+
if (!(len = _XimSetEventToWire(ev, (xEvent *)&buf_s[4])))
return False; /* X event */
@@ -304,7 +302,7 @@ _XimForwardEventCore(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimSyncCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -328,7 +326,7 @@ _XimForwardEventCore(
return True;
}
-Public Bool
+Bool
_XimForwardEvent(
Xic ic,
XEvent *ev,
@@ -342,7 +340,7 @@ _XimForwardEvent(
return _XimForwardEventCore(ic, ev, sync);
}
-Private void
+static void
_XimProcEvent(
Display *d,
Xic ic,
@@ -356,11 +354,11 @@ _XimProcEvent(
ev->xany.serial |= serial << 16;
ev->xany.send_event = False;
ev->xany.display = d;
- MARK_FABLICATED(ic);
+ MARK_FABRICATED(ic->core.im);
return;
}
-Private Bool
+static Bool
_XimForwardEventRecv(
Xim im,
Xic ic,
@@ -379,7 +377,7 @@ _XimForwardEventRecv(
return True;
}
-Public Bool
+Bool
_XimForwardEventCallback(
Xim xim,
INT16 len,
@@ -400,7 +398,7 @@ _XimForwardEventCallback(
return False;
}
-Private Bool
+static Bool
_XimRegisterTriggerkey(
Xim im,
XPointer buf)
@@ -419,7 +417,7 @@ _XimRegisterTriggerkey(
len = buf_l[0]; /* length of on-keys */
len += sizeof(INT32); /* sizeof length of on-keys */
- if (!(key = (CARD32 *)Xmalloc(len))) {
+ if (!(key = Xmalloc(len))) {
_XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -436,7 +434,7 @@ _XimRegisterTriggerkey(
len = buf_l[0]; /* length of off-keys */
len += sizeof(INT32); /* sizeof length of off-keys */
- if (!(key = (CARD32 *)Xmalloc(len))) {
+ if (!(key = Xmalloc(len))) {
_XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -447,7 +445,7 @@ _XimRegisterTriggerkey(
return True;
}
-Public Bool
+Bool
_XimRegisterTriggerKeysCallback(
Xim xim,
INT16 len,
@@ -461,7 +459,7 @@ _XimRegisterTriggerKeysCallback(
return True;
}
-Public EVENTMASK
+EVENTMASK
_XimGetWindowEventmask(
Xic ic)
{
@@ -474,7 +472,7 @@ _XimGetWindowEventmask(
}
-Private Bool
+static Bool
_XimTriggerNotifyCheck(
Xim im,
INT16 len,
@@ -503,7 +501,7 @@ _XimTriggerNotifyCheck(
return False;
}
-Public Bool
+Bool
_XimTriggerNotify(
Xim im,
Xic ic,
@@ -548,7 +546,7 @@ _XimTriggerNotify(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(len);
+ preply = Xmalloc(len);
ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
_XimTriggerNotifyCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -571,7 +569,7 @@ _XimTriggerNotify(
return True;
}
-Private Bool
+static Bool
_XimRegCommitInfo(
Xic ic,
char *string,
@@ -581,7 +579,7 @@ _XimRegCommitInfo(
{
XimCommitInfo info;
- if (!(info = (XimCommitInfo)Xmalloc(sizeof(XimCommitInfoRec))))
+ if (!(info = Xmalloc(sizeof(XimCommitInfoRec))))
return False;
info->string = string;
info->string_len = string_len;
@@ -592,7 +590,7 @@ _XimRegCommitInfo(
return True;
}
-Private void
+static void
_XimUnregCommitInfo(
Xic ic)
{
@@ -601,16 +599,15 @@ _XimUnregCommitInfo(
if (!(info = ic->private.proto.commit_info))
return;
- if (info->string)
- Xfree(info->string);
- if (info->keysym)
- Xfree(info->keysym);
+
+ Xfree(info->string);
+ Xfree(info->keysym);
ic->private.proto.commit_info = info->next;
Xfree(info);
return;
}
-Public void
+void
_XimFreeCommitInfo(
Xic ic)
{
@@ -619,7 +616,7 @@ _XimFreeCommitInfo(
return;
}
-Private Bool
+static Bool
_XimProcKeySym(
Xic ic,
CARD32 sym,
@@ -628,7 +625,7 @@ _XimProcKeySym(
{
Xim im = (Xim)ic->core.im;
- if (!(*xim_keysym = (KeySym *)Xmalloc(sizeof(KeySym)))) {
+ if (!(*xim_keysym = Xmalloc(sizeof(KeySym)))) {
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -639,7 +636,7 @@ _XimProcKeySym(
return True;
}
-Private Bool
+static Bool
_XimProcCommit(
Xic ic,
BYTE *buf,
@@ -650,7 +647,7 @@ _XimProcCommit(
Xim im = (Xim)ic->core.im;
char *string;
- if (!(string = (char *)Xmalloc(len + 1))) {
+ if (!(string = Xmalloc(len + 1))) {
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
@@ -663,7 +660,7 @@ _XimProcCommit(
return True;
}
-Private Bool
+static Bool
_XimCommitRecv(
Xim im,
Xic ic,
@@ -691,22 +688,26 @@ _XimCommitRecv(
return False;
if (!(_XimProcCommit(ic, (BYTE *)&buf_s[5],
- (int)buf_s[4], &string, &string_len)))
+ (int)buf_s[4], &string, &string_len))) {
+ Xfree(keysym);
return False;
+ }
}
if (!(_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len))) {
- if (string)
- Xfree(string);
- if (keysym)
- Xfree(keysym);
+ Xfree(string);
+ Xfree(keysym);
_XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
return False;
}
(void)_XimRespSyncReply(ic, flag);
- MARK_FABLICATED(ic);
+ if (ic->private.proto.registed_filter_event
+ & (KEYPRESS_MASK | KEYRELEASE_MASK))
+ MARK_FABRICATED(im);
+
+ bzero(&ev, sizeof(ev)); /* uninitialized : found when running kterm under valgrind */
ev.type = KeyPress;
ev.send_event = False;
@@ -715,12 +716,21 @@ _XimCommitRecv(
ev.keycode = 0;
ev.state = 0;
+ ev.time = 0L;
+ ev.serial = LastKnownRequestProcessed(im->core.display);
+ /* FIXME :
+ I wish there were COMMENTs (!) about the data passed around.
+ */
+#if 0
+ fprintf(stderr,"%s,%d: putback k press FIXED ev.time=0 ev.serial=%lu\n", __FILE__, __LINE__, ev.serial);
+#endif
+
XPutBackEvent(im->core.display, (XEvent *)&ev);
return True;
}
-Public Bool
+Bool
_XimCommitCallback(
Xim xim,
INT16 len,
@@ -741,7 +751,7 @@ _XimCommitCallback(
return False;
}
-Public void
+void
_XimProcError(
Xim im,
Xic ic,
@@ -750,7 +760,7 @@ _XimProcError(
return;
}
-Public Bool
+Bool
_XimErrorCallback(
Xim xim,
INT16 len,
@@ -779,7 +789,7 @@ _XimErrorCallback(
return True;
}
-Public Bool
+Bool
_XimError(
Xim im,
Xic ic,
@@ -823,7 +833,7 @@ _XimError(
return True;
}
-Private int
+static int
_Ximctsconvert(
XlcConv conv,
char *from,
@@ -889,7 +899,7 @@ _Ximctsconvert(
return to_cnvlen;
}
-Public int
+int
_Ximctstombs(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
@@ -897,7 +907,7 @@ _Ximctstombs(XIM xim, char *from, int from_len,
from, from_len, to, to_len, state);
}
-Public int
+int
_Ximctstowcs(
XIM xim,
char *from,
@@ -965,7 +975,7 @@ _Ximctstowcs(
return to_cnvlen;
}
-Public int
+int
_Ximctstoutf8(
XIM xim,
char *from,
@@ -978,7 +988,7 @@ _Ximctstoutf8(
from, from_len, to, to_len, state);
}
-Public int
+int
_XimProtoMbLookupString(
XIC xic,
XKeyEvent *ev,
@@ -1041,7 +1051,7 @@ _XimProtoMbLookupString(
return ret;
}
-Public int
+int
_XimProtoWcLookupString(
XIC xic,
XKeyEvent *ev,
@@ -1104,7 +1114,7 @@ _XimProtoWcLookupString(
return ret;
}
-Public int
+int
_XimProtoUtf8LookupString(
XIC xic,
XKeyEvent *ev,
diff --git a/nx-X11/lib/X11/imDispch.c b/nx-X11/lib/X11/imDispch.c
index cd4870671..862a9b651 100644
--- a/nx-X11/lib/X11/imDispch.c
+++ b/nx-X11/lib/X11/imDispch.c
@@ -36,7 +36,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
-Public Bool
+Bool
_XimRegProtoIntrCallback(
Xim im,
CARD16 major_code,
@@ -49,7 +49,7 @@ _XimRegProtoIntrCallback(
{
XimProtoIntrRec *rec;
- if (!(rec = (XimProtoIntrRec *)Xmalloc(sizeof(XimProtoIntrRec))))
+ if (!(rec = Xmalloc(sizeof(XimProtoIntrRec))))
return False;
rec->func = proc;
rec->major_code = major_code;
@@ -60,7 +60,7 @@ _XimRegProtoIntrCallback(
return True;
}
-Public void
+void
_XimFreeProtoIntrCallback(Xim im)
{
register XimProtoIntrRec *rec, *next;
@@ -74,7 +74,7 @@ _XimFreeProtoIntrCallback(Xim im)
return;
}
-Private Bool
+static Bool
_XimTransportIntr(
Xim im,
INT16 len,
@@ -95,7 +95,7 @@ _XimTransportIntr(
return False;
}
-Public Bool
+Bool
_XimDispatchInit(Xim im)
{
if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im))
diff --git a/nx-X11/lib/X11/imExten.c b/nx-X11/lib/X11/imExten.c
index 3ffe7f891..532b18d3b 100644
--- a/nx-X11/lib/X11/imExten.c
+++ b/nx-X11/lib/X11/imExten.c
@@ -55,7 +55,7 @@ typedef struct _XIM_QueryExtRec {
int idx;
} XIM_QueryExtRec;
-Private XIM_QueryExtRec extensions[] = {
+static XIM_QueryExtRec extensions[] = {
{False, "XIM_EXT_SET_EVENT_MASK", 0, 0, 0,
XIM_EXT_SET_EVENT_MASK_IDX},
#ifdef EXT_FORWARD
@@ -68,7 +68,7 @@ Private XIM_QueryExtRec extensions[] = {
{False, NULL, 0, 0, 0, 0} /* dummy */
};
-Private int
+static int
_XimIsSupportExt(
int idx)
{
@@ -86,7 +86,7 @@ _XimIsSupportExt(
return -1;
}
-Private Bool
+static Bool
_XimProcExtSetEventMask(
Xim im,
Xic ic,
@@ -113,7 +113,7 @@ _XimProcExtSetEventMask(
return True;
}
-Private Bool
+static Bool
_XimExtSetEventMaskCallback(
Xim xim,
INT16 len,
@@ -135,7 +135,7 @@ _XimExtSetEventMaskCallback(
}
#ifdef EXT_FORWARD
-Private Bool
+static Bool
_XimProcExtForwardKeyEvent(
Xim im,
Xic ic,
@@ -159,12 +159,12 @@ _XimProcExtForwardKeyEvent(
XPutBackEvent(im->core.display, &ev);
_XimRespSyncReply(ic, buf_s[0]);
- MARK_FABLICATED(ic);
+ MARK_FABRICATED(im);
return True;
}
-Private Bool
+static Bool
_XimExtForwardKeyEventCallback(
Xim xim,
INT16 len,
@@ -185,7 +185,7 @@ _XimExtForwardKeyEventCallback(
return False;
}
-Private Bool
+static Bool
_XimExtForwardKeyEventCheck(
Xim im,
INT16 len,
@@ -213,7 +213,7 @@ _XimExtForwardKeyEventCheck(
return False;
}
-Public Bool
+Bool
_XimExtForwardKeyEvent(
Xic ic,
XKeyEvent *ev,
@@ -271,7 +271,7 @@ _XimExtForwardKeyEvent(
preply = reply;
} else {
buf_sizex = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, preply, buf_size,
_XimExtForwardKeyEventCheck, (XPointer)ic);
if(ret_code != XIM_TRUE) {
@@ -295,7 +295,7 @@ _XimExtForwardKeyEvent(
}
#endif /* EXT_FORWARD */
-Private int
+static int
_XimCheckExtensionListSize(void)
{
register int i;
@@ -312,7 +312,7 @@ _XimCheckExtensionListSize(void)
return total;
}
-Private void
+static void
_XimSetExtensionList(
CARD8 *buf)
{
@@ -330,7 +330,7 @@ _XimSetExtensionList(
return;
}
-Private unsigned int
+static unsigned int
_XimCountNumberOfExtension(
INT16 total,
CARD8 *ext)
@@ -352,7 +352,7 @@ _XimCountNumberOfExtension(
return n;
}
-Private Bool
+static Bool
_XimParseExtensionList(
Xim im,
CARD16 *data)
@@ -367,7 +367,7 @@ _XimParseExtensionList(
if (!(n = _XimCountNumberOfExtension(data[0], (CARD8 *)&data[1])))
return True;
- buf = (CARD8 *)&data[1];;
+ buf = (CARD8 *)&data[1];
for (i = 0; i < n; i++) {
len = *((INT16 *)(&buf[2]));
for (j = 0; j < num; j++) {
@@ -388,7 +388,7 @@ _XimParseExtensionList(
return True;
}
-Private Bool
+static Bool
_XimQueryExtensionCheck(
Xim im,
INT16 len,
@@ -412,7 +412,7 @@ _XimQueryExtensionCheck(
return False;
}
-Public Bool
+Bool
_XimExtension(
Xim im)
{
@@ -436,7 +436,7 @@ _XimExtension(
+ len
+ XIM_PAD(len);
- if (!(buf = (CARD8 *)Xmalloc(buf_len)))
+ if (!(buf = Xmalloc(buf_len)))
return False;
buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
@@ -465,7 +465,7 @@ _XimExtension(
preply = reply;
} else {
buf_size = len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimRead(im, &len, reply, buf_size,
_XimQueryExtensionCheck, 0);
if(ret_code != XIM_TRUE) {
@@ -518,7 +518,7 @@ _XimExtension(
/* length of XPoint attribute */
#define XIM_Xpoint_length 12
-Private Bool
+static Bool
_XimExtMove(
Xim im,
Xic ic,
@@ -551,7 +551,7 @@ _XimExtMove(
return True;
}
-Public BITMASK32
+BITMASK32
_XimExtenArgCheck(
XIMArg *arg)
{
@@ -561,7 +561,7 @@ _XimExtenArgCheck(
return flag;
}
-Public Bool
+Bool
_XimExtenMove(
Xim im,
Xic ic,
diff --git a/nx-X11/lib/X11/imImSw.c b/nx-X11/lib/X11/imImSw.c
index acad4b8af..28b1725a6 100644
--- a/nx-X11/lib/X11/imImSw.c
+++ b/nx-X11/lib/X11/imImSw.c
@@ -40,7 +40,7 @@ THIS SOFTWARE.
#include "Ximint.h"
#include "XimImSw.h"
-Private Bool
+static Bool
_XimCheckIfDefault(
Xim im)
{
diff --git a/nx-X11/lib/X11/imInsClbk.c b/nx-X11/lib/X11/imInsClbk.c
index cb1905c01..3ae6b1bd7 100644
--- a/nx-X11/lib/X11/imInsClbk.c
+++ b/nx-X11/lib/X11/imInsClbk.c
@@ -52,11 +52,11 @@ typedef struct _XimInstCallback {
} XimInstCallbackRec, *XimInstCallback;
-Private XimInstCallback callback_list = NULL;
-Private Bool lock = False;
+static XimInstCallback callback_list = NULL;
+static Bool lock = False;
-Private void
+static void
MakeLocale( XLCd lcd, char locale[] )
{
char *language, *territory, *codeset;
@@ -76,7 +76,7 @@ MakeLocale( XLCd lcd, char locale[] )
}
-Private Bool
+static Bool
_XimFilterPropertyNotify(
Display *display,
Window window,
@@ -150,7 +150,7 @@ _XimFilterPropertyNotify(
}
-Public Bool
+Bool
_XimRegisterIMInstantiateCallback(
XLCd lcd,
Display *display,
@@ -168,7 +168,7 @@ _XimRegisterIMInstantiateCallback(
if( lock )
return( False );
- icb = (XimInstCallback)Xmalloc(sizeof(XimInstCallbackRec));
+ icb = Xmalloc(sizeof(XimInstCallbackRec));
if( !icb )
return( False );
icb->call = icb->destroy = False;
@@ -213,7 +213,7 @@ _XimRegisterIMInstantiateCallback(
}
-Public Bool
+Bool
_XimUnRegisterIMInstantiateCallback(
XLCd lcd,
Display *display,
@@ -267,7 +267,7 @@ _XimUnRegisterIMInstantiateCallback(
}
-Public void
+void
_XimResetIMInstantiateCallback(Xim xim)
{
char locale[XIM_MAXLCNAMELEN];
diff --git a/nx-X11/lib/X11/imInt.c b/nx-X11/lib/X11/imInt.c
index c78ffc68d..05e04dac8 100644
--- a/nx-X11/lib/X11/imInt.c
+++ b/nx-X11/lib/X11/imInt.c
@@ -37,10 +37,10 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
#include "XimImSw.h"
-Private Xim *_XimCurrentIMlist = (Xim *)NULL;
-Private int _XimCurrentIMcount = 0;
+static Xim *_XimCurrentIMlist = (Xim *)NULL;
+static int _XimCurrentIMcount = 0;
-Private Bool
+static Bool
_XimSetIMStructureList(
Xim im)
{
@@ -48,7 +48,7 @@ _XimSetIMStructureList(
Xim *xim;
if(!(_XimCurrentIMlist)) {
- if(!(_XimCurrentIMlist = (Xim *)Xmalloc(sizeof(Xim))))
+ if(!(_XimCurrentIMlist = Xmalloc(sizeof(Xim))))
return False;
_XimCurrentIMlist[0] = im;
_XimCurrentIMcount = 1;
@@ -61,7 +61,7 @@ _XimSetIMStructureList(
}
}
if(i >= _XimCurrentIMcount) {
- if(!(xim = (Xim *)Xrealloc(_XimCurrentIMlist,
+ if(!(xim = Xrealloc(_XimCurrentIMlist,
((i + 1) * sizeof(Xim)))))
return False;
_XimCurrentIMlist = xim;
@@ -72,7 +72,7 @@ _XimSetIMStructureList(
return True;
}
-Public void
+void
_XimDestroyIMStructureList(Xim im)
{
register int i;
@@ -86,7 +86,7 @@ _XimDestroyIMStructureList(Xim im)
return;
}
-Public void
+void
_XimServerDestroy(Xim im_2_destroy)
{
register int i;
@@ -120,7 +120,7 @@ _XimServerDestroy(Xim im_2_destroy)
}
#ifdef XIM_CONNECTABLE
-Public void
+void
_XimServerReconectableDestroy(void)
{
register int i;
@@ -147,7 +147,7 @@ _XimServerReconectableDestroy(void)
}
#endif /* XIM_CONNECTABLE */
-Private const char *
+static const char *
_XimStrstr(
register const char *src,
register const char *dest)
@@ -163,7 +163,7 @@ _XimStrstr(
return NULL;
}
-Private char *
+static char *
_XimMakeImName(
XLCd lcd)
{
@@ -193,7 +193,7 @@ _XimMakeImName(
return ret;
}
-Public XIM
+XIM
_XimOpenIM(
XLCd lcd,
Display *dpy,
@@ -204,9 +204,8 @@ _XimOpenIM(
Xim im;
register int i;
- if (!(im = (Xim)Xmalloc(sizeof(XimRec))))
+ if (!(im = Xcalloc(1, sizeof(XimRec))))
return (XIM)NULL;
- bzero(im, sizeof(XimRec));
im->core.lcd = lcd;
im->core.ic_chain = (XIC)NULL;
@@ -215,14 +214,12 @@ _XimOpenIM(
im->core.res_name = NULL;
im->core.res_class = NULL;
if((res_name != NULL) && (*res_name != '\0')){
- if(!(im->core.res_name = (char *)Xmalloc(strlen(res_name)+1)))
+ if(!(im->core.res_name = strdup(res_name)))
goto Error1;
- strcpy(im->core.res_name,res_name);
}
if((res_class != NULL) && (*res_class != '\0')){
- if(!(im->core.res_class = (char *)Xmalloc(strlen(res_class)+1)))
+ if(!(im->core.res_class = strdup(res_class)))
goto Error2;
- strcpy(im->core.res_class,res_class);
}
if(!(im->core.im_name = _XimMakeImName(lcd)))
goto Error3;
@@ -242,19 +239,16 @@ Error4 :
Xfree(im);
return NULL;
Error3 :
- if(im->core.im_name)
- Xfree(im->core.im_name);
+ Xfree(im->core.im_name);
Error2:
- if(im->core.res_class)
- Xfree(im->core.res_class);
+ Xfree(im->core.res_class);
Error1:
- if(im->core.res_name)
- Xfree(im->core.res_name);
+ Xfree(im->core.res_name);
Xfree(im);
return NULL;
}
-Public Bool
+Bool
_XInitIM(XLCd lcd)
{
if(lcd == (XLCd)NULL)
diff --git a/nx-X11/lib/X11/imKStoUCS.c b/nx-X11/lib/X11/imKStoUCS.c
index 5cfce420d..640b3516a 100644
--- a/nx-X11/lib/X11/imKStoUCS.c
+++ b/nx-X11/lib/X11/imKStoUCS.c
@@ -143,7 +143,7 @@ static unsigned short const keysym_to_unicode_aa1_afe[] = {
0x2105, 0x0000, 0x0000, 0x2012, 0x2039, 0x2024, 0x203a, 0x0000, /* 0x0ab8-0x0abf */
0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, /* 0x0ac0-0x0ac7 */
0x0000, 0x2122, 0x2120, 0x0000, 0x25c1, 0x25b7, 0x25cb, 0x25ad, /* 0x0ac8-0x0acf */
- 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x2030, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
0x0000, 0x271d, 0x0000, 0x220e, 0x25c2, 0x2023, 0x25cf, 0x25ac, /* 0x0ad8-0x0adf */
0x25e6, 0x25ab, 0x25ae, 0x25b5, 0x25bf, 0x2606, 0x2022, 0x25aa, /* 0x0ae0-0x0ae7 */
0x25b4, 0x25be, 0x261a, 0x261b, 0x2663, 0x2666, 0x2665, 0x0000, /* 0x0ae8-0x0aef */
diff --git a/nx-X11/lib/X11/imLcFlt.c b/nx-X11/lib/X11/imLcFlt.c
index e812fdd0d..50f4c252a 100644
--- a/nx-X11/lib/X11/imLcFlt.c
+++ b/nx-X11/lib/X11/imLcFlt.c
@@ -43,21 +43,22 @@ _XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
Xic ic = (Xic)client_data;
KeySym keysym;
static char buf[256];
+ static unsigned prevcode = 0, prevstate = 0;
+ unsigned currstate;
DefTree *b = ic->private.local.base.tree;
DTIndex t;
+ Bool braille = False, anymodifier = False;
if(ev->xkey.keycode == 0)
return (False);
XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
- if(IsModifierKey(keysym))
- return (False);
-
if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) {
if(ev->type == KeyPress) {
ic->private.local.brl_pressed |=
1<<(keysym-XK_braille_dot_1);
+ return(True);
} else {
if(!ic->private.local.brl_committing
|| ev->xkey.time - ic->private.local.brl_release_start > 300) {
@@ -65,51 +66,92 @@ _XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
ic->private.local.brl_release_start = ev->xkey.time;
}
ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1));
- if(!ic->private.local.brl_pressed) {
- if(ic->private.local.brl_committing) {
- ic->private.local.brl_committed =
- ic->private.local.brl_committing;
- ic->private.local.composed = 0;
- ev->type = KeyPress;
- ev->xkey.keycode = 0;
- _XPutBackEvent(d, ev);
- }
+ if(!ic->private.local.brl_pressed && ic->private.local.brl_committing) {
+ /* Commited a braille pattern, let it go through compose tree */
+ keysym = XK_braille_blank | ic->private.local.brl_committing;
+ ev->type = KeyPress;
+ braille = True;
+ } else {
+ return(True);
}
}
- return(True);
}
- if( (ev->type != KeyPress)
- || (((Xim)ic->core.im)->private.local.top == 0 ) )
- return(False);
+ if(((Xim)ic->core.im)->private.local.top == 0 )
+ goto emit_braille;
+
+ currstate = ev->xkey.state;
+ if(ev->type == KeyPress) {
+ prevcode = ev->xkey.keycode;
+ prevstate = currstate;
+
+ if(IsModifierKey(keysym))
+ return(False);
+ prevcode = 0;
+ } else {
+ if(prevcode != ev->xkey.keycode)
+ return False;
+
+ /* For lookup, we use the state at the time when the key was pressed, */
+ /* because this state was not affected by the modifier that is mapped */
+ /* to the key. */
+ ev->xkey.state = prevstate;
+ XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
+ }
for(t = ic->private.local.context; t; t = b[t].next) {
+ if(IsModifierKey(b[t].keysym))
+ anymodifier = True;
if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) &&
(keysym == b[t].keysym))
break;
}
+ /* Restore the state */
+ ev->xkey.state = currstate;
+
if(t) { /* Matched */
if(b[t].succession) { /* Intermediate */
ic->private.local.context = b[t].succession;
- return(True);
+ return (ev->type == KeyPress);
} else { /* Terminate (reached to leaf) */
ic->private.local.composed = t;
ic->private.local.brl_committed = 0;
/* return back to client KeyPressEvent keycode == 0 */
ev->xkey.keycode = 0;
+ ev->xkey.type = KeyPress;
XPutBackEvent(d, ev);
+ if(prevcode){
+ /* For modifier key releases, restore the event, as we do not */
+ /* filter it. */
+ ev->xkey.type = KeyRelease;
+ ev->xkey.keycode = prevcode;
+ }
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
- return(True);
+ return (ev->type == KeyPress);
}
} else { /* Unmatched */
- if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) {
- return(False);
+ /* Unmatched modifier key releases abort matching only in the case that */
+ /* there was any modifier that would have matched */
+ if((ic->private.local.context == ((Xim)ic->core.im)->private.local.top) ||
+ (ev->type == KeyRelease && !anymodifier)) {
+ goto emit_braille;
}
/* Error (Sequence Unmatch occured) */
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return (ev->type == KeyPress);
+ }
+
+emit_braille:
+ if(braille) {
+ /* Braille pattern is not in compose tree, emit alone */
+ ic->private.local.brl_committed = ic->private.local.brl_committing;
+ ic->private.local.composed = 0;
+ ev->xkey.keycode = 0;
+ _XPutBackEvent(d, ev);
return(True);
}
+ return(False);
}
diff --git a/nx-X11/lib/X11/imLcGIc.c b/nx-X11/lib/X11/imLcGIc.c
index 26930c426..003b3897a 100644
--- a/nx-X11/lib/X11/imLcGIc.c
+++ b/nx-X11/lib/X11/imLcGIc.c
@@ -33,7 +33,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Public char *
+char *
_XimLocalGetICValues(XIC xic, XIMArg *values)
{
Xic ic = (Xic)xic;
diff --git a/nx-X11/lib/X11/imLcIc.c b/nx-X11/lib/X11/imLcIc.c
index 66ff3e913..7ab9050c1 100644
--- a/nx-X11/lib/X11/imLcIc.c
+++ b/nx-X11/lib/X11/imLcIc.c
@@ -36,7 +36,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Private void
+static void
_XimLocalUnSetFocus(
XIC xic)
{
@@ -49,7 +49,7 @@ _XimLocalUnSetFocus(
return;
}
-Private void
+static void
_XimLocalDestroyIC(
XIC xic)
{
@@ -68,7 +68,7 @@ _XimLocalDestroyIC(
return;
}
-Private void
+static void
_XimLocalSetFocus(
XIC xic)
{
@@ -90,7 +90,7 @@ _XimLocalSetFocus(
return;
}
-Private void
+static void
_XimLocalReset(
XIC xic)
{
@@ -102,7 +102,7 @@ _XimLocalReset(
ic->private.local.brl_committed = 0;
}
-Private char *
+static char *
_XimLocalMbReset(
XIC xic)
{
@@ -110,7 +110,7 @@ _XimLocalMbReset(
return (char *)NULL;
}
-Private wchar_t *
+static wchar_t *
_XimLocalWcReset(
XIC xic)
{
@@ -118,7 +118,7 @@ _XimLocalWcReset(
return (wchar_t *)NULL;
}
-Private XICMethodsRec Local_ic_methods = {
+static XICMethodsRec Local_ic_methods = {
_XimLocalDestroyIC, /* destroy */
_XimLocalSetFocus, /* set_focus */
_XimLocalUnSetFocus, /* unset_focus */
@@ -132,7 +132,7 @@ Private XICMethodsRec Local_ic_methods = {
_XimLocalUtf8LookupString /* utf8_lookup_string */
};
-Public XIC
+XIC
_XimLocalCreateIC(
XIM im,
XIMArg *values)
@@ -143,10 +143,9 @@ _XimLocalCreateIC(
unsigned int num;
int len;
- if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ if((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL) {
return ((XIC)NULL);
}
- bzero((char *)ic, sizeof(XicRec));
ic->methods = &Local_ic_methods;
ic->core.im = im;
@@ -159,7 +158,7 @@ _XimLocalCreateIC(
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ if((res = Xmalloc(len)) == (XIMResourceList)NULL) {
goto Set_Error;
}
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
@@ -180,7 +179,7 @@ _XimLocalCreateIC(
values, XIM_CREATEIC, True)) {
goto Set_Error;
}
- ic_values.filter_events = KeyPressMask;
+ ic_values.filter_events = KeyPressMask | KeyReleaseMask;
_XimSetCurrentICValues(ic, &ic_values);
if(_XimSetICDefaults(ic, (XPointer)&ic_values,
XIM_SETICDEFAULTS, res, num) == False) {
diff --git a/nx-X11/lib/X11/imLcIm.c b/nx-X11/lib/X11/imLcIm.c
index 81645e5bd..817fb2147 100644
--- a/nx-X11/lib/X11/imLcIm.c
+++ b/nx-X11/lib/X11/imLcIm.c
@@ -36,9 +36,7 @@ THIS SOFTWARE.
#include <config.h>
#endif
#include <stdio.h>
-/*
-#include <nx-X11/Xlib.h>
-*/
+
#include <nx-X11/Xmd.h>
#include <nx-X11/Xatom.h>
#include <nx-X11/Xos.h>
@@ -88,14 +86,14 @@ struct _XimCacheStruct {
/* char encoding[1] */
};
-Private struct _XimCacheStruct* _XimCache_mmap = NULL;
-Private DefTreeBase _XimCachedDefaultTreeBase;
-Private int _XimCachedDefaultTreeRefcount = 0;
+static struct _XimCacheStruct* _XimCache_mmap = NULL;
+static DefTreeBase _XimCachedDefaultTreeBase;
+static int _XimCachedDefaultTreeRefcount = 0;
#endif
-Public Bool
+Bool
_XimCheckIfLocalProcessing(Xim im)
{
FILE *fp;
@@ -119,7 +117,7 @@ _XimCheckIfLocalProcessing(Xim im)
return(False);
}
-Private void
+static void
XimFreeDefaultTree(
DefTreeBase *b)
{
@@ -133,58 +131,51 @@ XimFreeDefaultTree(
}
#endif
Xfree (b->tree);
- if (b->mb) Xfree (b->mb);
- if (b->wc) Xfree (b->wc);
- if (b->utf8) Xfree (b->utf8);
b->tree = NULL;
+ Xfree (b->mb);
b->mb = NULL;
+ Xfree (b->wc);
b->wc = NULL;
+ Xfree (b->utf8);
b->utf8 = NULL;
+
b->treeused = b->treesize = 0;
b->mbused = b->mbsize = 0;
b->wcused = b->wcsize = 0;
b->utf8used = b->utf8size = 0;
}
-Public void
+void
_XimLocalIMFree(
Xim im)
{
XimFreeDefaultTree(&im->private.local.base);
im->private.local.top = 0;
- if(im->core.im_resources) {
- Xfree(im->core.im_resources);
- im->core.im_resources = NULL;
- }
- if(im->core.ic_resources) {
- Xfree(im->core.ic_resources);
- im->core.ic_resources = NULL;
- }
- if(im->core.im_values_list) {
- Xfree(im->core.im_values_list);
- im->core.im_values_list = NULL;
- }
- if(im->core.ic_values_list) {
- Xfree(im->core.ic_values_list);
- im->core.ic_values_list = NULL;
- }
- if(im->core.styles) {
- Xfree(im->core.styles);
- im->core.styles = NULL;
- }
- if(im->core.res_name) {
- Xfree(im->core.res_name);
- im->core.res_name = NULL;
- }
- if(im->core.res_class) {
- Xfree(im->core.res_class);
- im->core.res_class = NULL;
- }
- if(im->core.im_name) {
- Xfree(im->core.im_name);
- im->core.im_name = NULL;
- }
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+
if (im->private.local.ctom_conv) {
_XlcCloseConverter(im->private.local.ctom_conv);
im->private.local.ctom_conv = NULL;
@@ -220,7 +211,7 @@ _XimLocalIMFree(
return;
}
-Private Status
+static Status
_XimLocalCloseIM(
XIM xim)
{
@@ -233,7 +224,7 @@ _XimLocalCloseIM(
while (ic) {
(*ic->methods->destroy) (ic);
next = ic->core.next;
- Xfree ((char *) ic);
+ Xfree (ic);
ic = next;
}
_XimLocalIMFree(im);
@@ -241,7 +232,7 @@ _XimLocalCloseIM(
return(True);
}
-Public char *
+char *
_XimLocalGetIMValues(
XIM xim,
XIMArg *values)
@@ -254,7 +245,7 @@ _XimLocalGetIMValues(
im->core.im_resources, im->core.im_num_resources));
}
-Public char *
+char *
_XimLocalSetIMValues(
XIM xim,
XIMArg *values)
@@ -273,7 +264,7 @@ _XimLocalSetIMValues(
#ifdef COMPOSECACHE
-Private Bool
+static Bool
_XimReadCachedDefaultTree(
int fd_cache,
const char *name,
@@ -324,7 +315,7 @@ _XimReadCachedDefaultTree(
return True;
}
-Private unsigned int strToHash (
+static unsigned int strToHash (
const char *name)
{
unsigned int hash = 0;
@@ -336,7 +327,7 @@ Private unsigned int strToHash (
/* Returns read-only fd of cache file, -1 if none.
* Sets *res to cache filename if safe. Sets *size to file size of cache. */
-Private int _XimCachedFileName (
+static int _XimCachedFileName (
const char *dir, const char *name,
const char *intname, const char *encoding,
uid_t uid, int isglobal, char **res, off_t *size)
@@ -421,7 +412,7 @@ Private int _XimCachedFileName (
}
-Private Bool _XimLoadCache (
+static Bool _XimLoadCache (
int fd,
const char *name,
const char *encoding,
@@ -441,7 +432,7 @@ Private Bool _XimLoadCache (
}
-Private void
+static void
_XimWriteCachedDefaultTree(
const char *name,
const char *encoding,
@@ -456,7 +447,7 @@ _XimWriteCachedDefaultTree(
+ XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT;
DefTreeBase *b = &im->private.local.base;
- if (! b->tree && ! (b->tree = Xmalloc (sizeof(DefTree))) )
+ if (! b->tree && ! (b->tree = Xcalloc (1, sizeof(DefTree))) )
return;
if (! b->mb && ! (b->mb = Xmalloc (1)) )
return;
@@ -466,13 +457,11 @@ _XimWriteCachedDefaultTree(
return;
/* First entry is always unused */
- memset (b->tree, 0, sizeof(DefTree));
b->mb[0] = 0;
b->wc[0] = 0;
b->utf8[0] = 0;
- m = Xmalloc (msize);
- memset (m, 0, msize);
+ m = Xcalloc (1, msize);
m->id = XIM_CACHE_MAGIC;
m->version = XIM_CACHE_VERSION;
m->top = im->private.local.top;
@@ -491,10 +480,13 @@ _XimWriteCachedDefaultTree(
/* This STILL might be racy on NFS */
if ( (fd = _XOpenFileMode (cachename, O_WRONLY | O_CREAT | O_EXCL,
- 0600)) < 0)
+ 0600)) < 0) {
+ Xfree(m);
return;
+ }
if (! (fp = fdopen (fd, "wb")) ) {
close (fd);
+ Xfree(m);
return;
}
fwrite (m, msize, 1, fp);
@@ -513,7 +505,7 @@ _XimWriteCachedDefaultTree(
#endif
-Private void
+static void
_XimCreateDefaultTree(
Xim im)
{
@@ -575,19 +567,15 @@ _XimCreateDefaultTree(
encoding, 0, 1, &cachename, &size);
if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
- if (tmpcachedir)
- Xfree (tmpcachedir);
- if (tmpname)
- Xfree (tmpname);
- if (cachename)
- Xfree (cachename);
+ Xfree (tmpcachedir);
+ Xfree (tmpname);
+ Xfree (cachename);
close (cachefd);
return;
}
close (cachefd);
}
- if (cachename)
- Xfree (cachename);
+ Xfree (cachename);
cachename = NULL;
}
@@ -602,12 +590,9 @@ _XimCreateDefaultTree(
euid, 0, &cachename, &size);
if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
- if (tmpcachedir)
- Xfree (tmpcachedir);
- if (tmpname)
- Xfree (tmpname);
- if (cachename)
- Xfree (cachename);
+ Xfree (tmpcachedir);
+ Xfree (tmpname);
+ Xfree (cachename);
close (cachefd);
return;
}
@@ -617,12 +602,9 @@ _XimCreateDefaultTree(
#endif
if (! (fp = _XFopenFile (name, "r"))) {
- if (tmpcachedir)
- Xfree (tmpcachedir);
- if (tmpname)
- Xfree (tmpname);
- if (cachename)
- Xfree (cachename);
+ Xfree (tmpcachedir);
+ Xfree (tmpname);
+ Xfree (cachename);
return;
}
_XimParseStringFile(fp, im);
@@ -635,15 +617,12 @@ _XimCreateDefaultTree(
}
#endif
- if (tmpcachedir)
- Xfree (tmpcachedir);
- if (tmpname)
- Xfree (tmpname);
- if (cachename)
- Xfree (cachename);
+ Xfree (tmpcachedir);
+ Xfree (tmpname);
+ Xfree (cachename);
}
-Private XIMMethodsRec Xim_im_local_methods = {
+static XIMMethodsRec Xim_im_local_methods = {
_XimLocalCloseIM, /* close */
_XimLocalSetIMValues, /* set_values */
_XimLocalGetIMValues, /* get_values */
@@ -653,7 +632,7 @@ Private XIMMethodsRec Xim_im_local_methods = {
_XimLcctstoutf8 /* ctstoutf8 */
};
-Public Bool
+Bool
_XimLocalOpenIM(
Xim im)
{
diff --git a/nx-X11/lib/X11/imLcLkup.c b/nx-X11/lib/X11/imLcLkup.c
index fa65ed077..878b8e350 100644
--- a/nx-X11/lib/X11/imLcLkup.c
+++ b/nx-X11/lib/X11/imLcLkup.c
@@ -43,7 +43,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "XlcPubI.h"
#include "Ximint.h"
-Public int
+int
_XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
KeySym *keysym, Status *status)
{
@@ -67,12 +67,21 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
if(status) *status = XBufferOverflow;
return(ret);
}
- if(keysym) {
- *keysym = XK_braille_blank | pattern;
- if(status) *status = XLookupBoth;
- } else
- if(status) *status = XLookupChars;
- memcpy(buffer, mb, ret);
+ if(keysym) *keysym = XK_braille_blank | pattern;
+ if(ret > 0) {
+ if (keysym) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ memcpy(buffer, mb, ret);
+ } else {
+ if(keysym) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
} else { /* Composed Event */
ret = strlen(&mb[b[ic->private.local.composed].mb]);
if(ret > bytes) {
@@ -117,7 +126,7 @@ _XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
return (ret);
}
-Public int
+int
_XimLocalWcLookupString(XIC xic, XKeyEvent *ev, wchar_t *buffer, int wlen,
KeySym *keysym, Status *status)
{
@@ -189,7 +198,7 @@ _XimLocalWcLookupString(XIC xic, XKeyEvent *ev, wchar_t *buffer, int wlen,
return (ret);
}
-Public int
+int
_XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
KeySym *keysym, Status *status)
{
@@ -213,6 +222,11 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
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;
+ } else
+ if(status) *status = XLookupChars;
} else { /* Composed Event */
ret = strlen(&utf8[b[ic->private.local.composed].utf8]);
if(ret > bytes) {
@@ -257,7 +271,7 @@ _XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
return (ret);
}
-Private int
+static int
_XimLcctsconvert(
XlcConv conv,
char *from,
@@ -323,7 +337,7 @@ _XimLcctsconvert(
return to_cnvlen;
}
-Public int
+int
_XimLcctstombs(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
@@ -331,7 +345,7 @@ _XimLcctstombs(XIM xim, char *from, int from_len,
from, from_len, to, to_len, state);
}
-Public int
+int
_XimLcctstowcs(XIM xim, char *from, int from_len,
wchar_t *to, int to_len, Status *state)
{
@@ -394,7 +408,7 @@ _XimLcctstowcs(XIM xim, char *from, int from_len,
return to_cnvlen;
}
-Public int
+int
_XimLcctstoutf8(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
diff --git a/nx-X11/lib/X11/imLcPrs.c b/nx-X11/lib/X11/imLcPrs.c
index ad65da694..fa992e5d3 100644
--- a/nx-X11/lib/X11/imLcPrs.c
+++ b/nx-X11/lib/X11/imLcPrs.c
@@ -68,8 +68,9 @@ static void parsestringfile(FILE *fp, Xim im, int depth);
* COMMENT ::= "#" {<any character except null or newline>}
* LHS ::= EVENT { EVENT }
* EVENT ::= [MODIFIER_LIST] "<" keysym ">"
- * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None"
- * MODIFIER ::= ["~"] modifier_name
+ * MODIFIER_LIST ::= (["!"] {MODIFIER} ) | "None"
+ * MODIFIER ::= ["~"] MODIFIER_NAME
+ * MODIFIER_NAME ::= ("Ctrl"|"Lock"|"Caps"|"Shift"|"Alt"|"Meta")
* RHS ::= ( STRING | keysym | STRING keysym )
* STRING ::= '"' { CHAR } '"'
* CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR
@@ -495,10 +496,10 @@ parseline(
token = nexttoken(fp, tokenbuf, &lastch);
if (token != KEY && token != STRING)
goto error;
- if ((filename = TransFileName(im, tokenbuf)) == NULL)
- goto error;
if (++depth > 100)
goto error;
+ if ((filename = TransFileName(im, tokenbuf)) == NULL)
+ goto error;
infp = _XFopenFile(filename, "r");
Xfree(filename);
if (infp == NULL)
@@ -574,9 +575,12 @@ parseline(
if (token == STRING) {
l = strlen(tokenbuf) + 1;
while (b->mbused + l > b->mbsize) {
- b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
- if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ DTCharIndex newsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ char *newmb = Xrealloc (b->mb, newsize);
+ if (newmb == NULL)
goto error;
+ b->mb = newmb;
+ b->mbsize = newsize;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l;
@@ -604,9 +608,12 @@ parseline(
l = get_mb_string(im, local_mb_buf, rhs_keysym);
while (b->mbused + l + 1 > b->mbsize) {
- b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
- if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
+ DTCharIndex newsize = b->mbsize ? b->mbsize * 1.5 : 1024;
+ char *newmb = Xrealloc (b->mb, newsize);
+ if (newmb == NULL)
goto error;
+ b->mb = newmb;
+ b->mbsize = newsize;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l + 1;
@@ -621,9 +628,12 @@ parseline(
local_wc_buf[l] = (wchar_t)'\0';
}
while (b->wcused + l + 1 > b->wcsize) {
- b->wcsize = b->wcsize ? b->wcsize * 1.5 : 512;
- if (! (b->wc = Xrealloc (b->wc, sizeof(wchar_t) * b->wcsize)) )
+ DTCharIndex newsize = b->wcsize ? b->wcsize * 1.5 : 512;
+ wchar_t *newwc = Xrealloc (b->wc, sizeof(wchar_t) * newsize);
+ if (newwc == NULL)
goto error;
+ b->wc = newwc;
+ b->wcsize = newsize;
}
rhs_string_wc = &b->wc[b->wcused];
b->wcused += l + 1;
@@ -634,9 +644,12 @@ parseline(
local_utf8_buf[l] = '\0';
}
while (b->utf8used + l + 1 > b->utf8size) {
- b->utf8size = b->utf8size ? b->utf8size * 1.5 : 1024;
- if (! (b->utf8 = Xrealloc (b->utf8, b->utf8size)) )
+ DTCharIndex newsize = b->utf8size ? b->utf8size * 1.5 : 1024;
+ char *newutf8 = Xrealloc (b->utf8, newsize);
+ if (newutf8 == NULL)
goto error;
+ b->utf8 = newutf8;
+ b->utf8size = newsize;
}
rhs_string_utf8 = &b->utf8[b->utf8used];
b->utf8used += l + 1;
@@ -657,9 +670,12 @@ parseline(
while (b->treeused >= b->treesize) {
DefTree *old = b->tree;
int oldsize = b->treesize;
- b->treesize = b->treesize ? b->treesize * 1.5 : 256;
- if (! (b->tree = Xrealloc (b->tree, sizeof(DefTree) * b->treesize)) )
+ int newsize = b->treesize ? b->treesize * 1.5 : 256;
+ DefTree *new = Xrealloc (b->tree, sizeof(DefTree) * newsize);
+ if (new == NULL)
goto error;
+ b->tree = new;
+ b->treesize = newsize;
if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
top = (DTIndex *) (((char *) top) + (((char *)b->tree)-(char *)old));
}
diff --git a/nx-X11/lib/X11/imLcSIc.c b/nx-X11/lib/X11/imLcSIc.c
index 8f656f670..944bd8abd 100644
--- a/nx-X11/lib/X11/imLcSIc.c
+++ b/nx-X11/lib/X11/imLcSIc.c
@@ -37,7 +37,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Public char *
+char *
_XimLocalSetICValues(XIC xic, XIMArg *values)
{
XimDefICValues ic_values;
diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c
index 7f79765e1..373217173 100644
--- a/nx-X11/lib/X11/imRm.c
+++ b/nx-X11/lib/X11/imRm.c
@@ -58,7 +58,7 @@ typedef struct _XimValueOffsetInfo {
} XimValueOffsetInfoRec, *XimValueOffsetInfo;
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimCheckBool(str)
char *str;
{
@@ -69,14 +69,16 @@ _XimCheckBool(str)
return False;
}
-Public void
+void
_XimSetProtoResource(im)
Xim im;
{
char res_name_buf[256];
char* res_name;
+ size_t res_name_len;
char res_class_buf[256];
char* res_class;
+ size_t res_class_len;
char* str_type;
XrmValue value;
XIMStyle preedit_style = 0;
@@ -90,17 +92,31 @@ _XimSetProtoResource(im)
if (!im->core.rdb)
return;
- if (strlen (im->core.res_name) < 200) res_name = res_name_buf;
- else res_name = Xmalloc (strlen (im->core.res_name) + 50);
- if (strlen (im->core.res_class) < 200) res_class = res_class_buf;
- else res_class = Xmalloc (strlen (im->core.res_class) + 50);
+ res_name_len = strlen (im->core.res_name);
+ if (res_name_len < 200) {
+ res_name = res_name_buf;
+ res_name_len = sizeof(res_name_buf);
+ }
+ else {
+ res_name_len += 50;
+ res_name = Xmalloc (res_name_len);
+ }
+ res_class_len = strlen (im->core.res_class);
+ if (res_class_len < 200) {
+ res_class = res_class_buf;
+ res_class_len = sizeof(res_class_buf);
+ }
+ else {
+ res_class_len += 50;
+ res_class = Xmalloc (res_class_len);
+ }
/* pretend malloc always works */
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"useAuth");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"UseAuth");
@@ -111,11 +127,11 @@ _XimSetProtoResource(im)
}
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"delaybinding");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"Delaybinding");
@@ -126,11 +142,11 @@ _XimSetProtoResource(im)
}
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"reconnect");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"Reconnect");
@@ -147,11 +163,11 @@ _XimSetProtoResource(im)
return;
}
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"preeditDefaultStyle");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"PreeditDefaultStyle");
@@ -170,11 +186,11 @@ _XimSetProtoResource(im)
if(!preedit_style)
preedit_style = XIMPreeditNothing;
- (void) sprintf (res_name, "%s%s%s",
+ (void) snprintf (res_name, res_name_len, "%s%s%s",
im->core.res_name != NULL ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot,
"statusDefaultStyle");
- (void) sprintf (res_class, "%s%s%s",
+ (void) snprintf (res_class, res_class_len, "%s%s%s",
im->core.res_class != NULL ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot,
"StatusDefaultStyle");
@@ -191,7 +207,7 @@ _XimSetProtoResource(im)
if(!status_style)
status_style = XIMStatusNothing;
- if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
+ if(!(imstyles = Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
if (res_name != res_name_buf) Xfree (res_name);
if (res_class != res_class_buf) Xfree (res_class);
return;
@@ -344,7 +360,7 @@ static XIMStyle const supported_local_styles[] = {
0 /* dummy */
};
-Private Bool
+static Bool
_XimDefaultStyles(
XimValueOffsetInfo info,
XPointer top,
@@ -360,10 +376,9 @@ _XimDefaultStyles(
n = XIMNumber(supported_local_styles) - 1;
len = sizeof(XIMStyles) + sizeof(XIMStyle) * n;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xcalloc(1, len))) {
return False;
}
- bzero(tmp, len);
styles = (XIMStyles *)tmp;
if (n > 0) {
@@ -380,7 +395,7 @@ _XimDefaultStyles(
return True;
}
-Private Bool
+static Bool
_XimDefaultIMValues(
XimValueOffsetInfo info,
XPointer top,
@@ -396,10 +411,9 @@ _XimDefaultIMValues(
n = XIMNumber(supported_local_im_values_list);
len = sizeof(XIMValuesList) + sizeof(char **) * n;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xcalloc(1, len))) {
return False;
}
- bzero(tmp, len);
values_list = (XIMValuesList *)tmp;
if (n > 0) {
@@ -417,7 +431,7 @@ _XimDefaultIMValues(
return True;
}
-Private Bool
+static Bool
_XimDefaultICValues(
XimValueOffsetInfo info,
XPointer top,
@@ -433,10 +447,9 @@ _XimDefaultICValues(
n = XIMNumber(supported_local_ic_values_list);
len = sizeof(XIMValuesList) + sizeof(char **) * n;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xcalloc(1, len))) {
return False;
}
- bzero(tmp, len);
values_list = (XIMValuesList *)tmp;
if (n > 0) {
@@ -454,7 +467,7 @@ _XimDefaultICValues(
return True;
}
-Private Bool
+static Bool
_XimDefaultVisiblePos(
XimValueOffsetInfo info,
XPointer top,
@@ -468,7 +481,7 @@ _XimDefaultVisiblePos(
return True;
}
-Private Bool
+static Bool
_XimDefaultFocusWindow(
XimValueOffsetInfo info,
XPointer top,
@@ -487,7 +500,7 @@ _XimDefaultFocusWindow(
return True;
}
-Private Bool
+static Bool
_XimDefaultResName(
XimValueOffsetInfo info,
XPointer top,
@@ -507,7 +520,7 @@ _XimDefaultResName(
return True;
}
-Private Bool
+static Bool
_XimDefaultResClass(
XimValueOffsetInfo info,
XPointer top,
@@ -527,7 +540,7 @@ _XimDefaultResClass(
return True;
}
-Private Bool
+static Bool
_XimDefaultDestroyCB(
XimValueOffsetInfo info,
XPointer top,
@@ -543,7 +556,7 @@ _XimDefaultDestroyCB(
return True;
}
-Private Bool
+static Bool
_XimDefaultResetState(
XimValueOffsetInfo info,
XPointer top,
@@ -557,7 +570,7 @@ _XimDefaultResetState(
return True;
}
-Private Bool
+static Bool
_XimDefaultHotKeyState(
XimValueOffsetInfo info,
XPointer top,
@@ -571,7 +584,7 @@ _XimDefaultHotKeyState(
return True;
}
-Private Bool
+static Bool
_XimDefaultArea(
XimValueOffsetInfo info,
XPointer top,
@@ -607,7 +620,7 @@ _XimDefaultArea(
return True;
}
-Private Bool
+static Bool
_XimDefaultColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -632,7 +645,7 @@ _XimDefaultColormap(
return True;
}
-Private Bool
+static Bool
_XimDefaultStdColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -646,7 +659,7 @@ _XimDefaultStdColormap(
return True;
}
-Private Bool
+static Bool
_XimDefaultFg(
XimValueOffsetInfo info,
XPointer top,
@@ -664,7 +677,7 @@ _XimDefaultFg(
return True;
}
-Private Bool
+static Bool
_XimDefaultBg(
XimValueOffsetInfo info,
XPointer top,
@@ -682,7 +695,7 @@ _XimDefaultBg(
return True;
}
-Private Bool
+static Bool
_XimDefaultBgPixmap(
XimValueOffsetInfo info,
XPointer top,
@@ -696,7 +709,7 @@ _XimDefaultBgPixmap(
return True;
}
-Private Bool
+static Bool
_XimDefaultFontSet(
XimValueOffsetInfo info,
XPointer top,
@@ -710,7 +723,7 @@ _XimDefaultFontSet(
return True;
}
-Private Bool
+static Bool
_XimDefaultLineSpace(
XimValueOffsetInfo info,
XPointer top,
@@ -739,7 +752,7 @@ _XimDefaultLineSpace(
return True;
}
-Private Bool
+static Bool
_XimDefaultCursor(
XimValueOffsetInfo info,
XPointer top,
@@ -753,7 +766,7 @@ _XimDefaultCursor(
return True;
}
-Private Bool
+static Bool
_XimDefaultPreeditState(
XimValueOffsetInfo info,
XPointer top,
@@ -767,7 +780,7 @@ _XimDefaultPreeditState(
return True;
}
-Private Bool
+static Bool
_XimDefaultNest(
XimValueOffsetInfo info,
XPointer top,
@@ -777,7 +790,7 @@ _XimDefaultNest(
return True;
}
-Private Bool
+static Bool
_XimEncodeCallback(
XimValueOffsetInfo info,
XPointer top,
@@ -790,25 +803,21 @@ _XimEncodeCallback(
return True;
}
-Private Bool
+static Bool
_XimEncodeString(
XimValueOffsetInfo info,
XPointer top,
XPointer val)
{
- int len;
char *string;
char **out;
if(val == (XPointer)NULL) {
return False;
}
- len = strlen((char *)val);
- if(!(string = (char *)Xmalloc(len + 1))) {
+ if (!(string = strdup((char *)val))) {
return False;
}
- (void)strcpy(string, (char *)val);
- string[len] = '\0';
out = (char **)((char *)top + info->offset);
if(*out) {
@@ -818,7 +827,7 @@ _XimEncodeString(
return True;
}
-Private Bool
+static Bool
_XimEncodeStyle(
XimValueOffsetInfo info,
XPointer top,
@@ -831,7 +840,7 @@ _XimEncodeStyle(
return True;
}
-Private Bool
+static Bool
_XimEncodeWindow(
XimValueOffsetInfo info,
XPointer top,
@@ -844,7 +853,7 @@ _XimEncodeWindow(
return True;
}
-Private Bool
+static Bool
_XimEncodeStringConv(
XimValueOffsetInfo info,
XPointer top,
@@ -856,7 +865,7 @@ _XimEncodeStringConv(
return True;
}
-Private Bool
+static Bool
_XimEncodeResetState(
XimValueOffsetInfo info,
XPointer top,
@@ -869,7 +878,7 @@ _XimEncodeResetState(
return True;
}
-Private Bool
+static Bool
_XimEncodeHotKey(
XimValueOffsetInfo info,
XPointer top,
@@ -893,7 +902,7 @@ _XimEncodeHotKey(
}
len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xmalloc(len))) {
return False;
}
@@ -912,7 +921,7 @@ _XimEncodeHotKey(
return True;
}
-Private Bool
+static Bool
_XimEncodeHotKetState(
XimValueOffsetInfo info,
XPointer top,
@@ -925,7 +934,7 @@ _XimEncodeHotKetState(
return True;
}
-Private Bool
+static Bool
_XimEncodeRectangle(
XimValueOffsetInfo info,
XPointer top,
@@ -938,7 +947,7 @@ _XimEncodeRectangle(
return True;
}
-Private Bool
+static Bool
_XimEncodeSpot(
XimValueOffsetInfo info,
XPointer top,
@@ -951,7 +960,7 @@ _XimEncodeSpot(
return True;
}
-Private Bool
+static Bool
_XimEncodeColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -964,7 +973,7 @@ _XimEncodeColormap(
return True;
}
-Private Bool
+static Bool
_XimEncodeStdColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -977,7 +986,7 @@ _XimEncodeStdColormap(
return True;
}
-Private Bool
+static Bool
_XimEncodeLong(
XimValueOffsetInfo info,
XPointer top,
@@ -990,7 +999,7 @@ _XimEncodeLong(
return True;
}
-Private Bool
+static Bool
_XimEncodeBgPixmap(
XimValueOffsetInfo info,
XPointer top,
@@ -1003,7 +1012,7 @@ _XimEncodeBgPixmap(
return True;
}
-Private Bool
+static Bool
_XimEncodeFontSet(
XimValueOffsetInfo info,
XPointer top,
@@ -1016,7 +1025,7 @@ _XimEncodeFontSet(
return True;
}
-Private Bool
+static Bool
_XimEncodeLineSpace(
XimValueOffsetInfo info,
XPointer top,
@@ -1029,7 +1038,7 @@ _XimEncodeLineSpace(
return True;
}
-Private Bool
+static Bool
_XimEncodeCursor(
XimValueOffsetInfo info,
XPointer top,
@@ -1042,7 +1051,7 @@ _XimEncodeCursor(
return True;
}
-Private Bool
+static Bool
_XimEncodePreeditState(
XimValueOffsetInfo info,
XPointer top,
@@ -1055,7 +1064,7 @@ _XimEncodePreeditState(
return True;
}
-Private Bool
+static Bool
_XimEncodeNest(
XimValueOffsetInfo info,
XPointer top,
@@ -1064,7 +1073,7 @@ _XimEncodeNest(
return True;
}
-Private Bool
+static Bool
_XimDecodeStyles(
XimValueOffsetInfo info,
XPointer top,
@@ -1085,10 +1094,9 @@ _XimDecodeStyles(
num = styles->count_styles;
len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xcalloc(1, len))) {
return False;
}
- bzero(tmp, len);
out = (XIMStyles *)tmp;
if(num >0) {
@@ -1103,7 +1111,7 @@ _XimDecodeStyles(
return True;
}
-Private Bool
+static Bool
_XimDecodeValues(
XimValueOffsetInfo info,
XPointer top,
@@ -1124,10 +1132,9 @@ _XimDecodeValues(
num = values_list->count_values;
len = sizeof(XIMValuesList) + sizeof(char **) * num;
- if(!(tmp = (char *)Xmalloc(len))) {
+ if(!(tmp = Xcalloc(1, len))) {
return False;
}
- bzero(tmp, len);
out = (XIMValuesList *)tmp;
if(num) {
@@ -1142,7 +1149,7 @@ _XimDecodeValues(
return True;
}
-Private Bool
+static Bool
_XimDecodeCallback(
XimValueOffsetInfo info,
XPointer top,
@@ -1152,7 +1159,7 @@ _XimDecodeCallback(
XIMCallback *callback;
in = (XIMCallback *)((char *)top + info->offset);
- if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) {
+ if(!(callback = Xmalloc(sizeof(XIMCallback)))) {
return False;
}
callback->client_data = in->client_data;
@@ -1162,32 +1169,29 @@ _XimDecodeCallback(
return True;
}
-Private Bool
+static Bool
_XimDecodeString(
XimValueOffsetInfo info,
XPointer top,
XPointer val)
{
- int len = 0;
char *in;
char *string;
in = *((char **)((char *)top + info->offset));
- if(in != (char *)NULL) {
- len = strlen(in);
+ if (in != NULL) {
+ string = strdup(in);
+ } else {
+ string = Xcalloc(1, 1); /* strdup("") */
}
- if(!(string = (char *)Xmalloc(len + 1))) {
+ if (string == NULL) {
return False;
}
- if(in != (char *)NULL) {
- (void)strcpy(string, in);
- }
- string[len] = '\0';
*((char **)val) = string;
return True;
}
-Private Bool
+static Bool
_XimDecodeBool(
XimValueOffsetInfo info,
XPointer top,
@@ -1200,7 +1204,7 @@ _XimDecodeBool(
return True;
}
-Private Bool
+static Bool
_XimDecodeStyle(
XimValueOffsetInfo info,
XPointer top,
@@ -1213,7 +1217,7 @@ _XimDecodeStyle(
return True;
}
-Private Bool
+static Bool
_XimDecodeWindow(
XimValueOffsetInfo info,
XPointer top,
@@ -1226,7 +1230,7 @@ _XimDecodeWindow(
return True;
}
-Private Bool
+static Bool
_XimDecodeStringConv(
XimValueOffsetInfo info,
XPointer top,
@@ -1238,7 +1242,7 @@ _XimDecodeStringConv(
return True;
}
-Private Bool
+static Bool
_XimDecodeResetState(
XimValueOffsetInfo info,
XPointer top,
@@ -1251,7 +1255,7 @@ _XimDecodeResetState(
return True;
}
-Private Bool
+static Bool
_XimDecodeHotKey(
XimValueOffsetInfo info,
XPointer top,
@@ -1268,7 +1272,7 @@ _XimDecodeHotKey(
in = *((XIMHotKeyTriggers **)((char *)top + info->offset));
num = in->num_hot_key;
len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
- if(!(tmp = (XPointer)Xmalloc(len))) {
+ if(!(tmp = Xmalloc(len))) {
return False;
}
@@ -1285,7 +1289,7 @@ _XimDecodeHotKey(
return True;
}
-Private Bool
+static Bool
_XimDecodeHotKetState(
XimValueOffsetInfo info,
XPointer top,
@@ -1298,7 +1302,7 @@ _XimDecodeHotKetState(
return True;
}
-Private Bool
+static Bool
_XimDecodeRectangle(
XimValueOffsetInfo info,
XPointer top,
@@ -1308,7 +1312,7 @@ _XimDecodeRectangle(
XRectangle *rect;
in = (XRectangle *)((char *)top + info->offset);
- if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) {
+ if(!(rect = Xmalloc(sizeof(XRectangle)))) {
return False;
}
*rect = *in;
@@ -1316,7 +1320,7 @@ _XimDecodeRectangle(
return True;
}
-Private Bool
+static Bool
_XimDecodeSpot(
XimValueOffsetInfo info,
XPointer top,
@@ -1326,7 +1330,7 @@ _XimDecodeSpot(
XPoint *spot;
in = (XPoint *)((char *)top + info->offset);
- if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) {
+ if(!(spot = Xmalloc(sizeof(XPoint)))) {
return False;
}
*spot = *in;
@@ -1334,7 +1338,7 @@ _XimDecodeSpot(
return True;
}
-Private Bool
+static Bool
_XimDecodeColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -1347,7 +1351,7 @@ _XimDecodeColormap(
return True;
}
-Private Bool
+static Bool
_XimDecodeStdColormap(
XimValueOffsetInfo info,
XPointer top,
@@ -1360,7 +1364,7 @@ _XimDecodeStdColormap(
return True;
}
-Private Bool
+static Bool
_XimDecodeLong(
XimValueOffsetInfo info,
XPointer top,
@@ -1373,7 +1377,7 @@ _XimDecodeLong(
return True;
}
-Private Bool
+static Bool
_XimDecodeBgPixmap(
XimValueOffsetInfo info,
XPointer top,
@@ -1386,7 +1390,7 @@ _XimDecodeBgPixmap(
return True;
}
-Private Bool
+static Bool
_XimDecodeFontSet(
XimValueOffsetInfo info,
XPointer top,
@@ -1399,7 +1403,7 @@ _XimDecodeFontSet(
return True;
}
-Private Bool
+static Bool
_XimDecodeLineSpace(
XimValueOffsetInfo info,
XPointer top,
@@ -1412,7 +1416,7 @@ _XimDecodeLineSpace(
return True;
}
-Private Bool
+static Bool
_XimDecodeCursor(
XimValueOffsetInfo info,
XPointer top,
@@ -1425,7 +1429,7 @@ _XimDecodeCursor(
return True;
}
-Private Bool
+static Bool
_XimDecodePreeditState(
XimValueOffsetInfo info,
XPointer top,
@@ -1438,7 +1442,7 @@ _XimDecodePreeditState(
return True;
}
-Private Bool
+static Bool
_XimDecodeNest(
XimValueOffsetInfo info,
XPointer top,
@@ -2130,7 +2134,7 @@ static const XimICMode ic_mode[] = {
static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])];
static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])];
-Private Bool
+static Bool
_XimSetResourceList(
XIMResourceList *res_list,
unsigned int *list_num,
@@ -2143,10 +2147,9 @@ _XimSetResourceList(
XIMResourceList res;
len = sizeof(XIMResource) * num_resource;
- if(!(res = (XIMResourceList)Xmalloc(len))) {
+ if(!(res = Xcalloc(1, len))) {
return False;
}
- bzero((char *)res, len);
for(i = 0; i < num_resource; i++, id++) {
res[i] = resource[i];
@@ -2159,7 +2162,7 @@ _XimSetResourceList(
return True;
}
-Public Bool
+Bool
_XimSetIMResourceList(
XIMResourceList *res_list,
unsigned int *list_num)
@@ -2168,7 +2171,7 @@ _XimSetIMResourceList(
im_resources, XIMNumber(im_resources), 100);
}
-Public Bool
+Bool
_XimSetICResourceList(
XIMResourceList *res_list,
unsigned int *list_num)
@@ -2177,7 +2180,7 @@ _XimSetICResourceList(
ic_resources, XIMNumber(ic_resources), 200);
}
-Public Bool
+Bool
_XimSetInnerIMResourceList(
XIMResourceList *res_list,
unsigned int *list_num)
@@ -2186,7 +2189,7 @@ _XimSetInnerIMResourceList(
im_inner_resources, XIMNumber(im_inner_resources), 100);
}
-Public Bool
+Bool
_XimSetInnerICResourceList(
XIMResourceList *res_list,
unsigned int *list_num)
@@ -2195,7 +2198,7 @@ _XimSetInnerICResourceList(
ic_inner_resources, XIMNumber(ic_inner_resources), 200);
}
-Private XIMResourceList
+static XIMResourceList
_XimGetResourceListRecByMode(
XIMResourceList res_list,
unsigned int list_num,
@@ -2211,7 +2214,7 @@ _XimGetResourceListRecByMode(
return (XIMResourceList)NULL;
}
-Public Bool
+Bool
_XimCheckCreateICValues(
XIMResourceList res_list,
unsigned int list_num)
@@ -2222,7 +2225,7 @@ _XimCheckCreateICValues(
return False;
}
-Public XIMResourceList
+XIMResourceList
_XimGetResourceListRecByQuark(
XIMResourceList res_list,
unsigned int list_num,
@@ -2238,7 +2241,7 @@ _XimGetResourceListRecByQuark(
return (XIMResourceList)NULL;
}
-Public XIMResourceList
+XIMResourceList
_XimGetResourceListRec(
XIMResourceList res_list,
unsigned int list_num,
@@ -2249,7 +2252,7 @@ _XimGetResourceListRec(
return _XimGetResourceListRecByQuark(res_list, list_num, quark);
}
-Public char *
+char *
_XimSetIMValueData(
Xim im,
XPointer top,
@@ -2263,23 +2266,23 @@ _XimSetIMValueData(
for(p = values; p->name != NULL; p++) {
if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
- return p->value;
+ return p->name;
}
check = _XimCheckIMMode(res, XIM_SETIMVALUES);
if(check == XIM_CHECK_INVALID) {
continue;
} else if (check == XIM_CHECK_ERROR) {
- return p->value;
+ return p->name;
}
if(!_XimEncodeLocalIMAttr(res, top, p->value)) {
- return p->value;
+ return p->name;
}
}
return NULL;
}
-Public char *
+char *
_XimGetIMValueData(
Xim im,
XPointer top,
@@ -2293,23 +2296,23 @@ _XimGetIMValueData(
for(p = values; p->name != NULL; p++) {
if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
- return p->value;
+ return p->name;
}
check = _XimCheckIMMode(res, XIM_GETIMVALUES);
if(check == XIM_CHECK_INVALID) {
continue;
} else if (check == XIM_CHECK_ERROR) {
- return p->value;
+ return p->name;
}
if(!_XimDecodeLocalIMAttr(res, top, p->value)) {
- return p->value;
+ return p->name;
}
}
return NULL;
}
-Public void
+void
_XimSetIMMode(
XIMResourceList res_list,
unsigned int list_num)
@@ -2328,7 +2331,7 @@ _XimSetIMMode(
return;
}
-Private int
+static int
_XimCheckSetIMDefaultsMode(
XIMResourceList res)
{
@@ -2338,7 +2341,7 @@ _XimCheckSetIMDefaultsMode(
return XIM_CHECK_INVALID;
}
-Private int
+static int
_XimCheckSetIMValuesMode(
XIMResourceList res)
{
@@ -2348,7 +2351,7 @@ _XimCheckSetIMValuesMode(
return XIM_CHECK_INVALID;
}
-Private int
+static int
_XimCheckGetIMValuesMode(
XIMResourceList res)
{
@@ -2358,7 +2361,7 @@ Private int
return XIM_CHECK_INVALID;
}
-Public int
+int
_XimCheckIMMode(
XIMResourceList res,
unsigned long mode)
@@ -2377,7 +2380,7 @@ Public int
}
}
-Public void
+void
_XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
{
XIMResourceList res;
@@ -2413,13 +2416,13 @@ _XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
list_num, ic_mode_quark[i]))) {
continue;
}
- res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
- | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
+ res->mode = ( (*(const unsigned short *)((const char *)&ic_mode[i] + pre_offset))
+ | (*(const unsigned short *)((const char *)&ic_mode[i] + sts_offset)));
}
return;
}
-Private int
+static int
_XimCheckSetICDefaultsMode(
XIMResourceList res,
unsigned long mode)
@@ -2462,7 +2465,7 @@ _XimCheckSetICDefaultsMode(
return XIM_CHECK_VALID;
}
-Private int
+static int
_XimCheckCreateICMode(
XIMResourceList res,
unsigned long mode)
@@ -2515,7 +2518,7 @@ _XimCheckCreateICMode(
return XIM_CHECK_VALID;
}
-Private int
+static int
_XimCheckSetICValuesMode(
XIMResourceList res,
unsigned long mode)
@@ -2556,7 +2559,7 @@ _XimCheckSetICValuesMode(
return XIM_CHECK_VALID;
}
-Private int
+static int
_XimCheckGetICValuesMode(
XIMResourceList res,
unsigned long mode)
@@ -2591,7 +2594,7 @@ _XimCheckGetICValuesMode(
return XIM_CHECK_VALID;
}
-Public int
+int
_XimCheckICMode(
XIMResourceList res,
unsigned long mode)
@@ -2609,7 +2612,7 @@ Public int
}
}
-Public Bool
+Bool
_XimSetLocalIMDefaults(
Xim im,
XPointer top,
@@ -2648,7 +2651,7 @@ _XimSetLocalIMDefaults(
return True;
}
-Public Bool
+Bool
_XimSetICDefaults(
Xic ic,
XPointer top,
@@ -2713,7 +2716,7 @@ _XimSetICDefaults(
return True;
}
-Private Bool
+static Bool
_XimEncodeAttr(
XimValueOffsetInfo info,
unsigned int num,
@@ -2734,7 +2737,7 @@ _XimEncodeAttr(
return False;
}
-Public Bool
+Bool
_XimEncodeLocalIMAttr(
XIMResourceList res,
XPointer top,
@@ -2744,7 +2747,7 @@ _XimEncodeLocalIMAttr(
res, top, val);
}
-Public Bool
+Bool
_XimEncodeLocalICAttr(
Xic ic,
XIMResourceList res,
@@ -2769,7 +2772,7 @@ _XimEncodeLocalICAttr(
return _XimEncodeAttr(info, num, res, top, arg->value);
}
-Private Bool
+static Bool
_XimEncodeLocalTopValue(
Xic ic,
XIMResourceList res,
@@ -2805,7 +2808,7 @@ _XimEncodeLocalTopValue(
return True;
}
-Private Bool
+static Bool
_XimEncodeLocalPreeditValue(
Xic ic,
XIMResourceList res,
@@ -2821,11 +2824,13 @@ _XimEncodeLocalPreeditValue(
ic->core.focus_window, &colormap_ret,
&count, (Atom)p->value)))
return False;
+
+ Xfree(colormap_ret);
}
return True;
}
-Private Bool
+static Bool
_XimEncodeLocalStatusValue(
Xic ic,
XIMResourceList res,
@@ -2841,11 +2846,13 @@ _XimEncodeLocalStatusValue(
ic->core.focus_window, &colormap_ret,
&count, (Atom)p->value)))
return False;
+
+ Xfree(colormap_ret);
}
return True;
}
-Public char *
+char *
_XimSetICValueData(
Xic ic,
XPointer top,
@@ -2894,13 +2901,13 @@ _XimSetICValueData(
if(mode & XIM_PREEDIT_ATTR) {
if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p))
- return False;
+ return p->name;
} else if(mode & XIM_STATUS_ATTR) {
if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p))
- return False;
+ return p->name;
} else {
if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag))
- return False;
+ return p->name;
}
if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) {
return p->name;
@@ -2910,7 +2917,7 @@ _XimSetICValueData(
return NULL;
}
-Private Bool
+static Bool
_XimCheckInputStyle(
XIMStyles *styles,
XIMStyle style)
@@ -2926,7 +2933,7 @@ _XimCheckInputStyle(
return False;
}
-Public Bool
+Bool
_XimCheckLocalInputStyle(
Xic ic,
XPointer top,
@@ -2957,7 +2964,7 @@ _XimCheckLocalInputStyle(
return False;
}
-Private Bool
+static Bool
_XimDecodeAttr(
XimValueOffsetInfo info,
unsigned int num,
@@ -2978,7 +2985,7 @@ _XimDecodeAttr(
return False;
}
-Public Bool
+Bool
_XimDecodeLocalIMAttr(
XIMResourceList res,
XPointer top,
@@ -2988,7 +2995,7 @@ _XimDecodeLocalIMAttr(
res, top, val);
}
-Public Bool
+Bool
_XimDecodeLocalICAttr(
XIMResourceList res,
XPointer top,
@@ -3012,7 +3019,7 @@ _XimDecodeLocalICAttr(
return _XimDecodeAttr(info, num, res, top, val);
}
-Public char *
+char *
_XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list,
unsigned int list_num, XIMArg *values, unsigned long mode)
{
@@ -3061,7 +3068,7 @@ _XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list,
return NULL;
}
-Public void
+void
_XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values)
{
bzero((char *)im_values, sizeof(XimDefIMValues));
@@ -3075,7 +3082,7 @@ _XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values)
im_values->visible_position = im->core.visible_position;
}
-Public void
+void
_XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values)
{
im->core.styles = im_values->styles;
@@ -3087,7 +3094,7 @@ _XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values)
im->core.visible_position = im_values->visible_position;
}
-Public void
+void
_XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values)
{
bzero((char *)ic_values, sizeof(XimDefICValues));
@@ -3110,7 +3117,7 @@ _XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values)
ic_values->status_attr = ic->core.status_attr;
}
-Public void
+void
_XimSetCurrentICValues(
Xic ic,
XimDefICValues *ic_values)
@@ -3134,7 +3141,7 @@ _XimSetCurrentICValues(
ic->core.status_attr = ic_values->status_attr;
}
-Private void
+static void
_XimInitialIMOffsetInfo(void)
{
unsigned int n = XIMNumber(im_attr_info);
@@ -3145,7 +3152,7 @@ _XimInitialIMOffsetInfo(void)
}
}
-Private void
+static void
_XimInitialICOffsetInfo(void)
{
unsigned int n;
@@ -3167,7 +3174,7 @@ _XimInitialICOffsetInfo(void)
}
}
-Private void
+static void
_XimInitialIMMode(void)
{
unsigned int n = XIMNumber(im_mode);
@@ -3178,7 +3185,7 @@ _XimInitialIMMode(void)
}
}
-Private void
+static void
_XimInitialICMode(void)
{
unsigned int n = XIMNumber(ic_mode);
@@ -3189,7 +3196,7 @@ _XimInitialICMode(void)
}
}
-Public void
+void
_XimInitialResourceInfo(void)
{
static Bool init_flag = False;
diff --git a/nx-X11/lib/X11/imRmAttr.c b/nx-X11/lib/X11/imRmAttr.c
index b6d1e1293..9d4e46258 100644
--- a/nx-X11/lib/X11/imRmAttr.c
+++ b/nx-X11/lib/X11/imRmAttr.c
@@ -34,7 +34,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
-Private XIMResourceList
+static XIMResourceList
_XimGetNestedListSeparator(
XIMResourceList res_list, /* LISTofIMATTR or IMATTR */
unsigned int res_num)
@@ -42,7 +42,7 @@ _XimGetNestedListSeparator(
return _XimGetResourceListRec(res_list, res_num, XNSeparatorofNestedList);
}
-Private Bool
+static Bool
_XimCheckInnerIMAttributes(
Xim im,
XIMArg *arg,
@@ -64,7 +64,7 @@ _XimCheckInnerIMAttributes(
return True;
}
-Public char *
+char *
_XimMakeIMAttrIDList(
Xim im,
XIMResourceList res_list,
@@ -102,7 +102,7 @@ _XimMakeIMAttrIDList(
return (char *)NULL;
}
-Private Bool
+static Bool
_XimCheckInnerICAttributes(
Xic ic,
XIMArg *arg,
@@ -124,7 +124,7 @@ _XimCheckInnerICAttributes(
return True;
}
-Public char *
+char *
_XimMakeICAttrIDList(
Xic ic,
XIMResourceList res_list,
@@ -177,6 +177,8 @@ _XimMakeICAttrIDList(
else *len += new_len;
return name;
}
+ *len += new_len;
+ buf = (CARD16 *)((char *)buf + new_len);
} else if (res->xrm_name == sts_quark) {
if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
(XIMArg *)p->value, buf, &new_len,
@@ -185,9 +187,10 @@ _XimMakeICAttrIDList(
else *len += new_len;
return name;
}
+ *len += new_len;
+ buf = (CARD16 *)((char *)buf + new_len);
}
- *len += new_len;
- buf = (CARD16 *)((char *)buf + new_len);
+
if (!(res = _XimGetNestedListSeparator(res_list, res_num))) {
p++;
if (p) {
@@ -206,7 +209,7 @@ _XimMakeICAttrIDList(
return (char *)NULL;
}
-Private Bool
+static Bool
_XimAttributeToValue(
Xic ic,
XIMResourceList res,
@@ -235,7 +238,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(str = (char *)Xmalloc(data_len + 1)))
+ if (!(str = Xmalloc(data_len + 1)))
return False;
(void)memcpy(str, (char *)data, data_len);
@@ -259,7 +262,7 @@ _XimAttributeToValue(
return False;
alloc_len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
- if (!(p = (char *)Xmalloc(alloc_len)))
+ if (!(p = Xmalloc(alloc_len)))
return False;
rep = (XIMStyles *)p;
@@ -281,7 +284,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(rep = (XRectangle *)Xmalloc(sizeof(XRectangle))))
+ if (!(rep = Xmalloc(sizeof(XRectangle))))
return False;
rep->x = data[0];
@@ -299,7 +302,7 @@ _XimAttributeToValue(
if (!(value))
return False;
- if (!(rep = (XPoint *)Xmalloc(sizeof(XPoint))))
+ if (!(rep = Xmalloc(sizeof(XPoint))))
return False;
rep->x = data[0];
@@ -313,7 +316,7 @@ _XimAttributeToValue(
INT16 len = data[0];
char *base_name;
XFontSet rep = (XFontSet)NULL;
- char **missing_list;
+ char **missing_list = NULL;
int missing_count;
char *def_string;
@@ -322,7 +325,7 @@ _XimAttributeToValue(
if (!ic)
return False;
- if (!(base_name = (char *)Xmalloc(len + 1)))
+ if (!(base_name = Xmalloc(len + 1)))
return False;
(void)strncpy(base_name, (char *)&data[1], (int)len);
@@ -347,6 +350,7 @@ _XimAttributeToValue(
}
Xfree(base_name);
+ Xfree(missing_list);
*((XFontSet *)value) = rep;
break;
}
@@ -366,7 +370,7 @@ _XimAttributeToValue(
alloc_len = sizeof(XIMHotKeyTriggers)
+ sizeof(XIMHotKeyTrigger) * num;
- if (!(p = (char *)Xmalloc(alloc_len)))
+ if (!(p = Xmalloc(alloc_len)))
return False;
rep = (XIMHotKeyTriggers *)p;
@@ -395,7 +399,7 @@ _XimAttributeToValue(
return True;
}
-Private Bool
+static Bool
_XimDecodeInnerIMATTRIBUTE(
Xim im,
XIMArg *arg)
@@ -411,7 +415,7 @@ _XimDecodeInnerIMATTRIBUTE(
return _XimDecodeLocalIMAttr(res, (XPointer)&im_values, arg->value);
}
-Public char *
+char *
_XimDecodeIMATTRIBUTE(
Xim im,
XIMResourceList res_list,
@@ -464,7 +468,7 @@ _XimDecodeIMATTRIBUTE(
return (char *)NULL;
}
-Private Bool
+static Bool
_XimDecodeInnerICATTRIBUTE(
Xic ic,
XIMArg *arg,
@@ -484,7 +488,7 @@ _XimDecodeInnerICATTRIBUTE(
return True;
}
-Public char *
+char *
_XimDecodeICATTRIBUTE(
Xic ic,
XIMResourceList res_list,
@@ -560,7 +564,7 @@ _XimDecodeICATTRIBUTE(
return (char *)NULL;
}
-Private Bool
+static Bool
_XimValueToAttribute(
XIMResourceList res,
XPointer buf,
@@ -768,7 +772,7 @@ _XimValueToAttribute(
return True;
}
-Private Bool
+static Bool
_XimSetInnerIMAttributes(
Xim im,
XPointer top,
@@ -791,7 +795,7 @@ _XimSetInnerIMAttributes(
return _XimEncodeLocalIMAttr(res, top, arg->value);
}
-Public char *
+char *
_XimEncodeIMATTRIBUTE(
Xim im,
XIMResourceList res_list,
@@ -855,7 +859,7 @@ _XimEncodeIMATTRIBUTE(
}
#ifdef XIM_CONNECTABLE
-Public Bool
+Bool
_XimEncodeSavedIMATTRIBUTE(
Xim im,
XIMResourceList res_list,
@@ -918,7 +922,7 @@ _XimEncodeSavedIMATTRIBUTE(
}
#endif /* XIM_CONNECTABLE */
-Private Bool
+static Bool
_XimEncodeTopValue(
Xic ic,
XIMResourceList res,
@@ -941,7 +945,7 @@ _XimEncodeTopValue(
return True;
}
-Private Bool
+static Bool
_XimEncodePreeditValue(
Xic ic,
XIMResourceList res,
@@ -956,6 +960,7 @@ _XimEncodePreeditValue(
&count, (Atom)p->value)))
return False;
+ XFree(colormap_ret);
} else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
int list_ret;
XFontStruct **struct_list;
@@ -967,8 +972,7 @@ _XimEncodePreeditValue(
if (!p->value)
return False;
- if (ic->private.proto.preedit_font)
- Xfree(ic->private.proto.preedit_font);
+ Xfree(ic->private.proto.preedit_font);
list_ret = XFontsOfFontSet((XFontSet)p->value,
&struct_list, &name_list);
@@ -992,14 +996,14 @@ _XimEncodePreeditValue(
return True;
}
-Private Bool
+static Bool
_XimEncodeStatusValue(
Xic ic,
XIMResourceList res,
XIMArg *p)
{
if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
- XStandardColormap *colormap_ret;
+ XStandardColormap *colormap_ret = NULL;
int count;
if (!(XGetRGBColormaps(ic->core.im->core.display,
@@ -1007,6 +1011,7 @@ _XimEncodeStatusValue(
&count, (Atom)p->value)))
return False;
+ XFree(colormap_ret);
} else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
int list_ret;
XFontStruct **struct_list;
@@ -1018,8 +1023,7 @@ _XimEncodeStatusValue(
if (!p->value)
return False;
- if (ic->private.proto.status_font)
- Xfree(ic->private.proto.status_font);
+ Xfree(ic->private.proto.status_font);
list_ret = XFontsOfFontSet((XFontSet)p->value,
&struct_list, &name_list);
@@ -1043,7 +1047,7 @@ _XimEncodeStatusValue(
return True;
}
-Private Bool
+static Bool
_XimSetInnerICAttributes(
Xic ic,
XPointer top,
@@ -1066,7 +1070,7 @@ _XimSetInnerICAttributes(
return _XimEncodeLocalICAttr(ic, res, top, arg, mode);
}
-Public char *
+char *
_XimEncodeICATTRIBUTE(
Xic ic,
XIMResourceList res_list,
@@ -1178,7 +1182,7 @@ _XimEncodeICATTRIBUTE(
}
#ifdef XIM_CONNECTABLE
-Private Bool
+static Bool
_XimEncodeSavedPreeditValue(
Xic ic,
XIMResourceList res,
@@ -1220,7 +1224,7 @@ _XimEncodeSavedPreeditValue(
return True;
}
-Private Bool
+static Bool
_XimEncodeSavedStatusValue(
Xic ic,
XIMResourceList res,
@@ -1237,8 +1241,7 @@ _XimEncodeSavedStatusValue(
if (!value)
return False;
- if (ic->private.proto.status_font)
- Xfree(ic->private.proto.status_font);
+ Xfree(ic->private.proto.status_font);
list_ret = XFontsOfFontSet((XFontSet)value,
&struct_list, &name_list);
@@ -1262,7 +1265,7 @@ _XimEncodeSavedStatusValue(
return True;
}
-Public Bool
+Bool
_XimEncodeSavedICATTRIBUTE(
Xic ic,
XIMResourceList res_list,
@@ -1373,7 +1376,7 @@ _XimEncodeSavedICATTRIBUTE(
}
#endif /* XIM_CONNECTABLE */
-Private unsigned int
+static unsigned int
_XimCountNumberOfAttr(
INT16 total,
CARD16 *attr,
@@ -1381,7 +1384,7 @@ _XimCountNumberOfAttr(
{
unsigned int n;
INT16 len;
- INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ INT16 min_len = sizeof(CARD16) /* sizeof attribute ID */
+ sizeof(CARD16) /* sizeof type of value */
+ sizeof(INT16); /* sizeof length of attribute */
@@ -1398,14 +1401,13 @@ _XimCountNumberOfAttr(
return n;
}
-Public Bool
+Bool
_XimGetAttributeID(
Xim im,
CARD16 *buf)
{
unsigned int n;
XIMResourceList res;
- int res_len;
char *names;
int names_len;
XPointer tmp;
@@ -1414,7 +1416,7 @@ _XimGetAttributeID(
int values_len;
register int i;
INT16 len;
- INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ INT16 min_len = sizeof(CARD16) /* sizeof attribute ID */
+ sizeof(CARD16) /* sizeof type of value */
+ sizeof(INT16); /* sizeof length of attr */
/*
@@ -1423,16 +1425,15 @@ _XimGetAttributeID(
if (!(n = _XimCountNumberOfAttr(buf[0], &buf[1], &names_len)))
return False;
- res_len = sizeof(XIMResource) * n;
- if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ if (!(res = Xcalloc(n, sizeof(XIMResource))))
return False;
- bzero((char *)res, res_len);
values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
- if (!(tmp = (XPointer)Xmalloc(values_len)))
+ if (!(tmp = Xcalloc(1, values_len))) {
+ Xfree(res);
return False;
- bzero(tmp, values_len);
+ }
values_list = (XIMValuesList *)tmp;
values = (char **)((char *)tmp + sizeof(XIMValuesList));
@@ -1456,10 +1457,9 @@ _XimGetAttributeID(
}
_XIMCompileResourceList(res, n);
- if (im->core.im_resources)
- Xfree(im->core.im_resources);
- if (im->core.im_values_list)
- Xfree(im->core.im_values_list);
+ Xfree(im->core.im_resources);
+ Xfree(im->core.im_values_list);
+
im->core.im_resources = res;
im->core.im_num_resources = n;
im->core.im_values_list = values_list;
@@ -1470,16 +1470,15 @@ _XimGetAttributeID(
if (!(n = _XimCountNumberOfAttr(buf[0], &buf[2], &names_len)))
return False;
- res_len = sizeof(XIMResource) * n;
- if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ if (!(res = Xcalloc(n, sizeof(XIMResource))))
return False;
- bzero((char *)res, res_len);
values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
- if (!(tmp = (XPointer)Xmalloc(values_len)))
+ if (!(tmp = Xcalloc(1, values_len))) {
+ Xfree(res);
return False;
- bzero(tmp, values_len);
+ }
values_list = (XIMValuesList *)tmp;
values = (char **)((char *)tmp + sizeof(XIMValuesList));
@@ -1503,10 +1502,10 @@ _XimGetAttributeID(
}
_XIMCompileResourceList(res, n);
- if (im->core.ic_resources)
- Xfree(im->core.ic_resources);
- if (im->core.ic_values_list)
- Xfree(im->core.ic_values_list);
+
+ Xfree(im->core.ic_resources);
+ Xfree(im->core.ic_values_list);
+
im->core.ic_resources = res;
im->core.ic_num_resources = n;
im->core.ic_values_list = values_list;
diff --git a/nx-X11/lib/X11/imThaiFlt.c b/nx-X11/lib/X11/imThaiFlt.c
index 5f67373d1..401bd9a08 100644
--- a/nx-X11/lib/X11/imThaiFlt.c
+++ b/nx-X11/lib/X11/imThaiFlt.c
@@ -81,7 +81,7 @@ SOFTWARE.
/* character classification table */
#define TACTIS_CHARS 256
-Private
+static
char const tactis_chtype[TACTIS_CHARS] = {
CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 0 - 7 */
CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 8 - 15 */
@@ -127,7 +127,7 @@ char const tactis_chtype[TACTIS_CHARS] = {
#define CH_CLASSES 17 /* 17 classes of chars */
-Private
+static
char const write_rules_lookup[CH_CLASSES][CH_CLASSES] = {
/* Table 0: writing/outputing rules */
/* row: leading char, column: following char */
@@ -151,7 +151,7 @@ char const write_rules_lookup[CH_CLASSES][CH_CLASSES] = {
,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, CP, NC, NC, NC, NC}/*AV3*/
};
-Private
+static
char const wtt_isc1_lookup[CH_CLASSES][CH_CLASSES] = {
/* Table 1: WTT default input sequence check rules */
/* row: leading char, column: following char */
@@ -175,7 +175,7 @@ char const wtt_isc1_lookup[CH_CLASSES][CH_CLASSES] = {
,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
};
-Private
+static
char const wtt_isc2_lookup[CH_CLASSES][CH_CLASSES] = {
/* Table 2: WTT strict input sequence check rules */
/* row: leading char, column: following char */
@@ -199,7 +199,7 @@ char const wtt_isc2_lookup[CH_CLASSES][CH_CLASSES] = {
,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
};
-Private
+static
char const thaicat_isc_lookup[CH_CLASSES][CH_CLASSES] = {
/* Table 3: Thaicat input sequence check rules */
/* row: leading char, column: following char */
@@ -225,7 +225,7 @@ char const thaicat_isc_lookup[CH_CLASSES][CH_CLASSES] = {
/* returns classification of a char */
-Private int
+static int
THAI_chtype (unsigned char ch)
{
return tactis_chtype[ch];
@@ -233,7 +233,7 @@ THAI_chtype (unsigned char ch)
#ifdef UNUSED
/* returns the display level */
-Private int
+static int
THAI_chlevel (unsigned char ch)
{
int chlevel;
@@ -274,7 +274,7 @@ THAI_chlevel (unsigned char ch)
/* return True if char is non-spacing */
-Private Bool
+static Bool
THAI_isdead (unsigned char ch)
{
return ((tactis_chtype[ch] == CTRL) || (tactis_chtype[ch] == BV1) ||
@@ -287,7 +287,7 @@ THAI_isdead (unsigned char ch)
/* return True if char is consonant */
-Private Bool
+static Bool
THAI_iscons (unsigned char ch)
{
return (tactis_chtype[ch] == CONS);
@@ -295,7 +295,7 @@ THAI_iscons (unsigned char ch)
/* return True if char is vowel */
-Private Bool
+static Bool
THAI_isvowel (unsigned char ch)
{
return ((tactis_chtype[ch] == LV) || (tactis_chtype[ch] == FV1) ||
@@ -307,14 +307,14 @@ THAI_isvowel (unsigned char ch)
/* return True if char is tonemark */
-Private Bool
+static Bool
THAI_istone (unsigned char ch)
{
return (tactis_chtype[ch] == TONE);
}
#endif
-Private Bool
+static Bool
THAI_iscomposible (
unsigned char follow_ch,
unsigned char lead_ch)
@@ -324,7 +324,7 @@ THAI_iscomposible (
== CP);
}
-Private Bool
+static Bool
THAI_isaccepted (
unsigned char follow_ch,
unsigned char lead_ch,
@@ -355,7 +355,7 @@ THAI_isaccepted (
}
#ifdef UNUSED
-Private void
+static void
THAI_apply_write_rules(
unsigned char *instr,
unsigned char *outstr,
@@ -401,7 +401,7 @@ Output parameters:
}
}
-Private int
+static int
THAI_find_chtype (
unsigned char *instr,
int chtype)
@@ -430,7 +430,7 @@ Output parameters:
}
-Private int
+static int
THAI_apply_scm(
unsigned char *instr,
unsigned char *outstr,
@@ -466,33 +466,33 @@ THAI_apply_scm(
/* The following functions are copied from XKeyBind.c */
-Private void ComputeMaskFromKeytrans();
-Private int IsCancelComposeKey(KeySym *symbol, XKeyEvent *event);
-Private void SetLed(Display *dpy, int num, int state);
-Private CARD8 FindKeyCode();
+static void ComputeMaskFromKeytrans();
+static int IsCancelComposeKey(KeySym *symbol, XKeyEvent *event);
+static void SetLed(Display *dpy, int num, int state);
+static CARD8 FindKeyCode();
/* The following functions are specific to this module */
-Private int XThaiTranslateKey();
-Private int XThaiTranslateKeySym();
+static int XThaiTranslateKey();
+static int XThaiTranslateKeySym();
-Private KeySym HexIMNormalKey(
+static KeySym HexIMNormalKey(
XicThaiPart *thai_part,
KeySym symbol,
XKeyEvent *event);
-Private KeySym HexIMFirstComposeKey(
+static KeySym HexIMFirstComposeKey(
XicThaiPart *thai_part,
KeySym symbol,
XKeyEvent *event);
-Private KeySym HexIMSecondComposeKey(
+static KeySym HexIMSecondComposeKey(
XicThaiPart *thai_part,
KeySym symbol
XKeyEvent *event);
-Private KeySym HexIMComposeSequence(KeySym ks1, KeySym ks2);
-Private void InitIscMode(Xic ic);
-Private Bool ThaiComposeConvert(
+static KeySym HexIMComposeSequence(KeySym ks1, KeySym ks2);
+static void InitIscMode(Xic ic);
+static Bool ThaiComposeConvert(
Display *dpy,
KeySym insym,
KeySym *outsym, KeySym *lower, KeySym *upper);
@@ -530,7 +530,7 @@ Private Bool ThaiComposeConvert(
#define IC_DeletePreviousChar(ic) \
(IC_RealDeletePreviousChar(ic))
-Private unsigned char
+static unsigned char
IC_RealGetPreviousChar(Xic ic, unsigned short pos)
{
XICCallback* cb = &ic->core.string_conversion_callback;
@@ -597,7 +597,7 @@ IC_RealGetPreviousChar(Xic ic, unsigned short pos)
}
}
-Private unsigned char
+static unsigned char
IC_RealDeletePreviousChar(Xic ic)
{
XICCallback* cb = &ic->core.string_conversion_callback;
@@ -701,8 +701,8 @@ typedef KeySym (*StateProc)(
* State handler to implement the Thai hex input method.
*/
-Private int const nstate_handlers = 3;
-Private StateProc state_handler[] = {
+static int const nstate_handlers = 3;
+static StateProc state_handler[] = {
HexIMNormalKey,
HexIMFirstComposeKey,
HexIMSecondComposeKey
@@ -718,7 +718,7 @@ struct _XMapThaiKey {
KeySym to;
};
-Private struct _XMapThaiKey const ThaiComposeTable[] = {
+static struct _XMapThaiKey const ThaiComposeTable[] = {
{ /* 0xa4 */ XK_currency, /* 0xa5 */ XK_yen },
{ /* 0xa2 */ XK_cent, /* 0xa3 */ XK_sterling },
{ /* 0xe6 */ XK_ae, /* 0xef */ XK_idiaeresis },
@@ -742,7 +742,7 @@ struct _XKeytrans {
/* Convert keysym to 'Thai Compose' keysym */
/* The current implementation use latin-1 keysyms */
-Private Bool
+static Bool
ThaiComposeConvert(
Display *dpy,
KeySym insym,
@@ -762,7 +762,7 @@ ThaiComposeConvert(
return False;
}
-Private int
+static int
XThaiTranslateKey(
register Display *dpy,
KeyCode keycode,
@@ -847,7 +847,7 @@ XThaiTranslateKey(
* Should be changed to TACTIS keysyms when they are defined by the
* standard.
*/
-Private int
+static int
XThaiTranslateKeySym(
Display *dpy,
register KeySym symbol,
@@ -956,7 +956,7 @@ XThaiTranslateKeySym(
/*
* given a KeySym, returns the first keycode containing it, if any.
*/
-Private CARD8
+static CARD8
FindKeyCode(
register Display *dpy,
register KeySym code)
@@ -980,7 +980,7 @@ FindKeyCode(
* what modifier it is bound to, if any. Sets the AnyModifier bit if it
* can't map some keysym to a modifier.
*/
-Private void
+static void
ComputeMaskFromKeytrans(
Display *dpy,
register struct _XKeytrans *p)
@@ -1020,7 +1020,7 @@ ComputeMaskFromKeytrans(
#define FIRST_COMPOSE_KEY_STATE 1
#define SECOND_COMPOSE_KEY_STATE 2
-Private
+static
KeySym HexIMNormalKey(
XicThaiPart *thai_part,
KeySym symbol,
@@ -1036,7 +1036,7 @@ KeySym HexIMNormalKey(
}
-Private
+static
KeySym HexIMFirstComposeKey(
XicThaiPart *thai_part,
KeySym symbol,
@@ -1059,7 +1059,7 @@ KeySym HexIMFirstComposeKey(
return NoSymbol;
}
-Private
+static
KeySym HexIMSecondComposeKey(
XicThaiPart *thai_part,
KeySym symbol,
@@ -1094,7 +1094,7 @@ KeySym HexIMSecondComposeKey(
* The current implementation of this routine returns ISO Latin Keysyms.
*/
-Private
+static
KeySym HexIMComposeSequence(KeySym ks1, KeySym ks2)
{
int hi_digit;
@@ -1131,7 +1131,7 @@ int tactis_code;
* 2) whether cancelling key event should be processed or ignored
*/
-Private
+static
int IsCancelComposeKey(
KeySym *symbol,
XKeyEvent *event)
@@ -1163,7 +1163,7 @@ int IsCancelComposeKey(
* set specified keyboard LED on or off
*/
-Private
+static
void SetLed(
Display *dpy,
int num,
@@ -1180,7 +1180,7 @@ void SetLed(
/*
* Initialize ISC mode from im modifier
*/
-Private void InitIscMode(Xic ic)
+static void InitIscMode(Xic ic)
{
Xim im;
char *im_modifier_name;
@@ -1213,7 +1213,7 @@ Private void InitIscMode(Xic ic)
/*
* Helper functions for _XimThaiFilter()
*/
-Private Bool
+static Bool
ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
{
DefTreeBase *b = &ic->private.local.base;
@@ -1228,7 +1228,7 @@ ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
return True;
}
-Private Bool
+static Bool
ThaiFltReorderInput(Xic ic, unsigned char previous_char, unsigned char new_char)
{
DefTreeBase *b = &ic->private.local.base;
@@ -1242,7 +1242,7 @@ ThaiFltReorderInput(Xic ic, unsigned char previous_char, unsigned char new_char)
return True;
}
-Private Bool
+static Bool
ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
{
DefTreeBase *b = &ic->private.local.base;
@@ -1258,19 +1258,26 @@ ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
return True;
}
-Private unsigned
+static unsigned
NumLockMask(Display *d)
{
int i;
- XModifierKeymap *map = XGetModifierMapping (d);
+ XModifierKeymap *map;
KeyCode numlock_keycode = XKeysymToKeycode (d, XK_Num_Lock);
if (numlock_keycode == NoSymbol)
return 0;
+ map = XGetModifierMapping (d);
+ if (!map)
+ return 0;
+
for (i = 0; i < 8; i++) {
- if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
+ if (map->modifiermap[map->max_keypermod * i] == numlock_keycode) {
+ XFreeModifiermap(map);
return 1 << i;
+ }
}
+ XFreeModifiermap(map);
return 0;
}
diff --git a/nx-X11/lib/X11/imThaiIc.c b/nx-X11/lib/X11/imThaiIc.c
index 72e99ba75..b559145d0 100644
--- a/nx-X11/lib/X11/imThaiIc.c
+++ b/nx-X11/lib/X11/imThaiIc.c
@@ -42,7 +42,7 @@ THIS SOFTWARE.
#include "Xlcint.h"
#include "Ximint.h"
-Private void
+static void
_XimThaiUnSetFocus(
XIC xic)
{
@@ -55,7 +55,7 @@ _XimThaiUnSetFocus(
return;
}
-Private void
+static void
_XimThaiDestroyIC(
XIC xic)
{
@@ -65,23 +65,25 @@ _XimThaiDestroyIC(
if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
_XimThaiUnSetFocus(xic);
}
- if(ic->private.local.ic_resources) {
- Xfree(ic->private.local.ic_resources);
- ic->private.local.ic_resources = NULL;
- }
- if (b->tree) Xfree (b->tree);
- if (b->mb) Xfree (b->mb);
- if (b->wc) Xfree (b->wc);
- if (b->utf8) Xfree (b->utf8);
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+
+ Xfree (b->tree);
b->tree = NULL;
+
+ Xfree (b->mb);
b->mb = NULL;
+
+ Xfree (b->wc);
b->wc = NULL;
+
+ Xfree (b->utf8);
b->utf8 = NULL;
return;
}
-Private void
+static void
_XimThaiSetFocus(
XIC xic)
{
@@ -102,7 +104,7 @@ _XimThaiSetFocus(
return;
}
-Private void
+static void
_XimThaiReset(
XIC xic)
{
@@ -115,7 +117,7 @@ _XimThaiReset(
b->utf8[b->tree[ic->private.local.composed].utf8] = '\0';
}
-Private char *
+static char *
_XimThaiMbReset(
XIC xic)
{
@@ -123,7 +125,7 @@ _XimThaiMbReset(
return (char *)NULL;
}
-Private wchar_t *
+static wchar_t *
_XimThaiWcReset(
XIC xic)
{
@@ -131,7 +133,7 @@ _XimThaiWcReset(
return (wchar_t *)NULL;
}
-Private XICMethodsRec Thai_ic_methods = {
+static XICMethodsRec Thai_ic_methods = {
_XimThaiDestroyIC, /* destroy */
_XimThaiSetFocus, /* set_focus */
_XimThaiUnSetFocus, /* unset_focus */
@@ -157,22 +159,21 @@ _XimThaiCreateIC(
int len;
DefTree *tree;
- if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ if((ic = Xcalloc(1, sizeof(XicRec))) == (Xic)NULL) {
return ((XIC)NULL);
}
- bzero((char *)ic, sizeof(XicRec));
ic->methods = &Thai_ic_methods;
ic->core.im = im;
ic->core.filter_events = KeyPressMask;
- if (! (ic->private.local.base.tree = tree = (DefTree *)Xmalloc(sizeof(DefTree)*3)) )
+ if (! (ic->private.local.base.tree = tree = Xmalloc(sizeof(DefTree)*3)) )
goto Set_Error;
- if (! (ic->private.local.base.mb = (char *)Xmalloc(21)) )
+ if (! (ic->private.local.base.mb = Xmalloc(21)) )
goto Set_Error;
- if (! (ic->private.local.base.wc = (wchar_t*)Xmalloc(sizeof(wchar_t)*21)) )
+ if (! (ic->private.local.base.wc = Xmalloc(sizeof(wchar_t)*21)) )
goto Set_Error;
- if (! (ic->private.local.base.utf8 = (char *)Xmalloc(21)) )
+ if (! (ic->private.local.base.utf8 = Xmalloc(21)) )
goto Set_Error;
ic->private.local.context = 1;
tree[1].mb = 1;
@@ -189,7 +190,7 @@ _XimThaiCreateIC(
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
- if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ if((res = Xmalloc(len)) == (XIMResourceList)NULL) {
goto Set_Error;
}
(void)memcpy((char *)res, (char *)im->core.ic_resources, len);
diff --git a/nx-X11/lib/X11/imThaiIm.c b/nx-X11/lib/X11/imThaiIm.c
index 73de70748..c17723aca 100644
--- a/nx-X11/lib/X11/imThaiIm.c
+++ b/nx-X11/lib/X11/imThaiIm.c
@@ -46,7 +46,7 @@ THIS SOFTWARE.
#include "XlcPubI.h"
#include "Ximint.h"
-Private XIMMethodsRec Xim_im_thai_methods = {
+static XIMMethodsRec Xim_im_thai_methods = {
_XimThaiCloseIM, /* close */
_XimLocalSetIMValues, /* set_values */
_XimLocalGetIMValues, /* get_values */
@@ -76,7 +76,7 @@ _XimCheckIfThaiProcessing(Xim im)
return(False);
}
-Public Bool
+Bool
_XimThaiOpenIM(Xim im)
{
XLCd lcd = im->core.lcd;
@@ -145,7 +145,7 @@ Open_Error :
return(False);
}
-Public void
+void
_XimThaiIMFree(Xim im)
{
if(im->core.im_resources) {
@@ -215,7 +215,7 @@ _XimThaiIMFree(Xim im)
return;
}
-Public Status
+Status
_XimThaiCloseIM(XIM xim)
{
Xim im = (Xim)xim;
@@ -227,7 +227,7 @@ _XimThaiCloseIM(XIM xim)
while (ic) {
(*ic->methods->destroy) (ic);
next = ic->core.next;
- Xfree ((char *) ic);
+ Xfree (ic);
ic = next;
}
_XimThaiIMFree(im);
diff --git a/nx-X11/lib/X11/imTrX.c b/nx-X11/lib/X11/imTrX.c
index 2b5455f1b..148b7fc90 100644
--- a/nx-X11/lib/X11/imTrX.c
+++ b/nx-X11/lib/X11/imTrX.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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"),
@@ -60,7 +60,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "XimTrInt.h"
#include "XimTrX.h"
-Private Bool
+static Bool
_XimXRegisterDispatcher(
Xim im,
Bool (*callback)(
@@ -71,7 +71,7 @@ _XimXRegisterDispatcher(
XIntrCallbackPtr rec;
XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
- if (!(rec = (XIntrCallbackPtr)Xmalloc(sizeof(XIntrCallbackRec))))
+ if (!(rec = Xmalloc(sizeof(XIntrCallbackRec))))
return False;
rec->func = callback;
@@ -81,7 +81,7 @@ _XimXRegisterDispatcher(
return True;
}
-Private void
+static void
_XimXFreeIntrCallback(
Xim im)
{
@@ -96,7 +96,7 @@ _XimXFreeIntrCallback(
return;
}
-Private Bool
+static Bool
_XimXCallDispatcher(Xim im, INT16 len, XPointer data)
{
register XIntrCallbackRec *rec;
@@ -109,7 +109,7 @@ _XimXCallDispatcher(Xim im, INT16 len, XPointer data)
return False;
}
-Private Bool
+static Bool
_XimXFilterWaitEvent(
Display *d,
Window w,
@@ -137,7 +137,7 @@ _XimXFilterWaitEvent(
return ret;
}
-Private Bool
+static Bool
_CheckConnect(
Display *display,
XEvent *event,
@@ -153,7 +153,7 @@ _CheckConnect(
return False;
}
-Private Bool
+static Bool
_XimXConnect(Xim im)
{
XEvent event;
@@ -224,7 +224,7 @@ _XimXConnect(Xim im)
return True;
}
-Private Bool
+static Bool
_XimXShutdown(Xim im)
{
XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
@@ -244,7 +244,7 @@ _XimXShutdown(Xim im)
return True;
}
-Private char *
+static char *
_NewAtom(
char *atomName)
{
@@ -255,7 +255,7 @@ _NewAtom(
return atomName;
}
-Private Bool
+static Bool
_XimXWrite(Xim im, INT16 len, XPointer data)
{
Atom atom;
@@ -316,7 +316,7 @@ _XimXWrite(Xim im, INT16 len, XPointer data)
return True;
}
-Private Bool
+static Bool
_XimXGetReadData(
Xim im,
char *buf,
@@ -377,14 +377,19 @@ _XimXGetReadData(
*ret_len = (int)nitems;
if (bytes_after_ret > 0) {
XFree(prop_ret);
- XGetWindowProperty(im->core.display,
- spec->lib_connect_wid, prop, 0L,
- ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
- &type_ret, &format_ret, &nitems, &bytes_after_ret,
- &prop_ret);
- XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
- XA_STRING, 8, PropModePrepend, &prop_ret[length],
- (nitems - length));
+ if (XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4),
+ True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems,
+ &bytes_after_ret,
+ &prop_ret) == Success) {
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[length],
+ (nitems - length));
+ } else {
+ return False;
+ }
}
} else {
(void)memcpy(buf, prop_ret, buf_len);
@@ -393,10 +398,14 @@ _XimXGetReadData(
if (bytes_after_ret > 0) {
XFree(prop_ret);
- XGetWindowProperty(im->core.display,
- spec->lib_connect_wid, prop, 0L,
- ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
- &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ if (XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4),
+ True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems,
+ &bytes_after_ret, &prop_ret) != Success) {
+ return False;
+ }
}
XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len);
@@ -431,7 +440,7 @@ _XimXGetReadData(
return True;
}
-Private Bool
+static Bool
_CheckCMEvent(
Display *display,
XEvent *event,
@@ -452,7 +461,7 @@ _CheckCMEvent(
return False;
}
-Private Bool
+static Bool
_XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len)
{
XEvent *ev;
@@ -475,21 +484,20 @@ _XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len)
return True;
}
-Private void
+static void
_XimXFlush(Xim im)
{
XFlush(im->core.display);
return;
}
-Public Bool
+Bool
_XimXConf(Xim im, char *address)
{
XSpecRec *spec;
- if (!(spec = (XSpecRec *)Xmalloc(sizeof(XSpecRec))))
+ if (!(spec = Xcalloc(1, sizeof(XSpecRec))))
return False;
- bzero(spec, sizeof(XSpecRec));
spec->improtocolid = XInternAtom(im->core.display, _XIM_PROTOCOL, False);
spec->imconnectid = XInternAtom(im->core.display, _XIM_XCONNECT, False);
diff --git a/nx-X11/lib/X11/imTrans.c b/nx-X11/lib/X11/imTrans.c
index 0fdc8cd9a..7f936cff6 100644
--- a/nx-X11/lib/X11/imTrans.c
+++ b/nx-X11/lib/X11/imTrans.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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"),
@@ -72,7 +72,7 @@ PERFORMANCE OF THIS SOFTWARE.
#endif
-Private Bool
+static Bool
_XimTransConnect(
Xim im)
{
@@ -122,7 +122,7 @@ _XimTransConnect(
}
-Private Bool
+static Bool
_XimTransShutdown(
Xim im)
{
@@ -142,7 +142,7 @@ _XimTransShutdown(
-Public Bool
+Bool
_XimTransRegisterDispatcher(
Xim im,
Bool (*callback)(
@@ -153,7 +153,7 @@ _XimTransRegisterDispatcher(
TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
TransIntrCallbackPtr rec;
- if (!(rec = (TransIntrCallbackPtr)Xmalloc(sizeof(TransIntrCallbackRec))))
+ if (!(rec = Xmalloc(sizeof(TransIntrCallbackRec))))
return False;
rec->func = callback;
@@ -164,7 +164,7 @@ _XimTransRegisterDispatcher(
}
-Public void
+void
_XimFreeTransIntrCallback(
Xim im)
{
@@ -180,7 +180,7 @@ _XimFreeTransIntrCallback(
}
-Public Bool
+Bool
_XimTransCallDispatcher(Xim im, INT16 len, XPointer data)
{
TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
@@ -194,7 +194,7 @@ _XimTransCallDispatcher(Xim im, INT16 len, XPointer data)
}
-Public Bool
+Bool
_XimTransFilterWaitEvent(
Display *d,
Window w,
@@ -209,7 +209,7 @@ _XimTransFilterWaitEvent(
}
-Public void
+void
_XimTransInternalConnection(
Display *d,
int fd,
@@ -222,12 +222,20 @@ _XimTransInternalConnection(
if (spec->is_putback)
return;
+
+ bzero(&ev, sizeof(ev)); /* FIXME: other fields may be accessed, too. */
kev = (XKeyEvent *)&ev;
kev->type = KeyPress;
kev->send_event = False;
kev->display = im->core.display;
kev->window = spec->window;
kev->keycode = 0;
+ kev->time = 0L;
+ kev->serial = LastKnownRequestProcessed(im->core.display);
+#if 0
+ fprintf(stderr,"%s,%d: putback FIXED kev->time=0 kev->serial=%lu\n", __FILE__, __LINE__, kev->serial);
+#endif
+
XPutBackEvent(im->core.display, &ev);
XFlush(im->core.display);
spec->is_putback = True;
@@ -235,7 +243,7 @@ _XimTransInternalConnection(
}
-Public Bool
+Bool
_XimTransWrite(Xim im, INT16 len, XPointer data)
{
TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
@@ -252,7 +260,7 @@ _XimTransWrite(Xim im, INT16 len, XPointer data)
}
-Public Bool
+Bool
_XimTransRead(
Xim im,
XPointer recv_buf,
@@ -273,7 +281,7 @@ _XimTransRead(
}
-Public void
+void
_XimTransFlush(
Xim im)
{
@@ -282,7 +290,7 @@ _XimTransFlush(
-Public Bool
+Bool
_XimTransConf(
Xim im,
char *address)
@@ -290,17 +298,14 @@ _XimTransConf(
char *paddr;
TransSpecRec *spec;
- if (!(paddr = (char *)Xmalloc(strlen(address) + 1)))
+ if (!(paddr = strdup(address)))
return False;
- if (!(spec = (TransSpecRec *) Xmalloc(sizeof(TransSpecRec)))) {
+ if (!(spec = Xcalloc(1, sizeof(TransSpecRec)))) {
Xfree(paddr);
return False;
}
- bzero(spec, sizeof(TransSpecRec));
-
- (void)strcpy(paddr, address);
spec->address = paddr;
im->private.proto.spec = (XPointer)spec;
diff --git a/nx-X11/lib/X11/imTransR.c b/nx-X11/lib/X11/imTransR.c
index e536bbc9b..50b549e71 100644
--- a/nx-X11/lib/X11/imTransR.c
+++ b/nx-X11/lib/X11/imTransR.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 1992 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"),
@@ -57,7 +57,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "XimTrInt.h"
#include "Ximint.h"
-Public TransportSW _XimTransportRec[] = {
+TransportSW _XimTransportRec[] = {
{ "X", _XimXConf }, /* 1st entry must be X.
This will be a fallback */
#ifdef TCPCONN
@@ -66,34 +66,28 @@ Public TransportSW _XimTransportRec[] = {
#if defined(UNIXCONN) || defined(LOCALCONN)
{ "local", _XimTransConf }, /* use X transport lib */
#endif /* UNIXCONN */
-#ifdef DNETCONN
- { "dnet", _XimTransConf }, /* use X transport lib */
-#endif /* DNETCONN */
-#ifdef STREAMSCONN
- { "streams", _XimTransConf }, /* use X transport lib */
-#endif /* STREAMSCONN */
{ (char *)NULL, (Bool (*)(Xim, char *))NULL },
};
-Public Bool
+Bool
_XimConnect(Xim im)
{
return im->private.proto.connect(im);
}
-Public Bool
+Bool
_XimShutdown(Xim im)
{
return im->private.proto.shutdown(im);
}
-Public Bool
+Bool
_XimWrite(Xim im, INT16 len, XPointer data)
{
return im->private.proto.write(im, len, data);
}
-Private int
+static int
_CheckProtocolData(
Xim im,
char *recv_buf)
@@ -104,7 +98,7 @@ _CheckProtocolData(
return data_len;
}
-Private int
+static int
_XimReadData(
Xim im,
INT16 *len,
@@ -144,7 +138,7 @@ _XimReadData(
data_len -= i;
if (data_len) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, &hold_buf[i], data_len);
@@ -179,7 +173,7 @@ _XimReadData(
}
if (packet_size > buf_size) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, buf, data_len);
@@ -206,7 +200,7 @@ _XimReadData(
data_len -= i;
if (data_len) {
- if (!(tmp = (char *)Xmalloc(data_len))) {
+ if (!(tmp = Xmalloc(data_len))) {
return XIM_FALSE;
}
memcpy(tmp, &buf[i], data_len);
@@ -221,7 +215,7 @@ _XimReadData(
return XIM_TRUE;
}
-Private Bool
+static Bool
_XimCallDispatcher(
Xim im,
INT16 len,
@@ -230,7 +224,7 @@ _XimCallDispatcher(
return im->private.proto.call_dispatcher(im, len, data);
}
-Public int
+int
_XimRead(Xim im, INT16 *len, XPointer buf, int buf_size,
Bool (*predicate)(Xim, INT16, XPointer, XPointer), XPointer arg)
{
@@ -252,7 +246,7 @@ _XimRead(Xim im, INT16 *len, XPointer buf, int buf_size,
return True;
}
-Public Bool
+Bool
_XimRegisterDispatcher(
Xim im,
Bool (*callback)(
@@ -263,14 +257,14 @@ _XimRegisterDispatcher(
return im->private.proto.register_dispatcher(im, callback, call_data);
}
-Public void
+void
_XimFlush(Xim im)
{
im->private.proto.flush(im);
return;
}
-Public Bool
+Bool
_XimFilterWaitEvent(Xim im)
{
INT16 read_len;
@@ -289,7 +283,7 @@ _XimFilterWaitEvent(Xim im)
preply = reply;
} else {
buf_size = (int)read_len;
- preply = (XPointer)Xmalloc(buf_size);
+ preply = Xmalloc(buf_size);
ret_code = _XimReadData(im, &read_len, preply, buf_size);
if(ret_code != XIM_TRUE) {
if (preply != reply)
diff --git a/nx-X11/lib/X11/lcCT.c b/nx-X11/lib/X11/lcCT.c
index d7fbb74cb..6e3f21e92 100644
--- a/nx-X11/lib/X11/lcCT.c
+++ b/nx-X11/lib/X11/lcCT.c
@@ -478,7 +478,7 @@ _XlcAddCT(
/* Allocate a CTinfo record. */
length = strlen(ct_sequence);
- ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec) + length+1);
+ ct_info = Xmalloc(sizeof(CTInfoRec) + length+1);
if (ct_info == NULL)
return charset;
@@ -514,7 +514,7 @@ _XlcAddCT(
Xfree(ct_info);
return charset;
}
- p = (char *) Xmalloc(n+1);
+ p = Xmalloc(n+1);
if (p == NULL) {
Xfree(ct_info);
return charset;
@@ -970,7 +970,7 @@ cstoct(
/* The CompoundText specification says that the only
control characters allowed are 0x09, 0x0a, 0x1b, 0x9b.
Therefore here we eliminate other control characters. */
- unsigned char ch = *((unsigned char *) csptr) & 0x7f;
+ unsigned char ch = *((const unsigned char *) csptr) & 0x7f;
if (!((ch >= min_ch && ch <= max_ch)
|| (side == XlcGL
&& (ch == 0x00 || ch == 0x09 || ch == 0x0a))
@@ -1020,7 +1020,7 @@ cstoct(
#endif
) {
while (csstr_len > 0 && ct_len > 0) {
- unsigned char ch = * (unsigned char *) csptr;
+ unsigned char ch = * (const unsigned char *) csptr;
int char_size = (ch < 0xc0 ? 1 :
ch < 0xe0 ? 2 :
ch < 0xf0 ? 3 :
@@ -1093,9 +1093,9 @@ strtocs(
dst = (char *) *to;
length = min(*from_left, *to_left);
- side = *((unsigned char *) src) & 0x80;
+ side = *((const unsigned char *) src) & 0x80;
- while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
+ while (side == (*((const unsigned char *) src) & 0x80) && length-- > 0)
*dst++ = *src++;
*from_left -= src - (const char *) *from;
@@ -1140,7 +1140,7 @@ cstostr(
str_len = *to_left;
while (csstr_len > 0 && str_len > 0) {
- ch = *((unsigned char *) csptr++);
+ ch = *((const unsigned char *) csptr++);
csstr_len--;
/* Citing ICCCM: "STRING as a type specifies the ISO Latin-1 character
set plus the control characters TAB and NEWLINE." */
@@ -1169,7 +1169,7 @@ create_conv(
{
XlcConv conv;
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + sizeof(StateRec));
+ conv = Xmalloc(sizeof(XlcConvRec) + sizeof(StateRec));
if (conv == NULL)
return (XlcConv) NULL;
@@ -1187,7 +1187,7 @@ close_converter(
XlcConv conv)
{
/* conv->state is allocated together with conv, free both at once. */
- Xfree((char *) conv);
+ Xfree(conv);
}
diff --git a/nx-X11/lib/X11/lcCharSet.c b/nx-X11/lib/X11/lcCharSet.c
index 0fa39d869..0adf0adfc 100644
--- a/nx-X11/lib/X11/lcCharSet.c
+++ b/nx-X11/lib/X11/lcCharSet.c
@@ -92,7 +92,7 @@ _XlcAddCharSet(
if (_XlcGetCharSet(charset->name))
return False;
- list = (XlcCharSetList) Xmalloc(sizeof(XlcCharSetListRec));
+ list = Xmalloc(sizeof(XlcCharSetListRec));
if (list == NULL)
return False;
@@ -176,18 +176,17 @@ _XlcCreateDefaultCharSet(
const char *colon;
char *tmp;
- charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec));
+ charset = Xcalloc(1, sizeof(XlcCharSetRec));
if (charset == NULL)
return (XlcCharSet) NULL;
- bzero((char *) charset, sizeof(XlcCharSetRec));
name_len = strlen(name);
ct_sequence_len = strlen(ct_sequence);
/* Fill in name and xrm_name. */
- tmp = (char *) Xmalloc(name_len + 1 + ct_sequence_len + 1);
+ tmp = Xmalloc(name_len + 1 + ct_sequence_len + 1);
if (tmp == NULL) {
- Xfree((char *) charset);
+ Xfree(charset);
return (XlcCharSet) NULL;
}
memcpy(tmp, name, name_len+1);
@@ -197,10 +196,10 @@ _XlcCreateDefaultCharSet(
/* Fill in encoding_name and xrm_encoding_name. */
if ((colon = strchr(charset->name, ':')) != NULL) {
unsigned int length = colon - charset->name;
- char *encoding_tmp = (char *) Xmalloc(length + 1);
+ char *encoding_tmp = Xmalloc(length + 1);
if (encoding_tmp == NULL) {
Xfree((char *) charset->name);
- Xfree((char *) charset);
+ Xfree(charset);
return (XlcCharSet) NULL;
}
memcpy(encoding_tmp, charset->name, length);
diff --git a/nx-X11/lib/X11/lcConv.c b/nx-X11/lib/X11/lcConv.c
index 9797e7ed3..7d9a4738c 100644
--- a/nx-X11/lib/X11/lcConv.c
+++ b/nx-X11/lib/X11/lcConv.c
@@ -101,7 +101,7 @@ _XlcSetConverter(
}
}
- list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec));
+ list = Xmalloc(sizeof(XlcConverterListRec));
if (list == NULL)
return False;
@@ -199,10 +199,10 @@ close_indirect_converter(
if (conv->to_conv)
close_converter(conv->to_conv);
- Xfree((char *) conv);
+ Xfree(conv);
}
- Xfree((char *) lc_conv);
+ Xfree(lc_conv);
}
static void
@@ -250,13 +250,13 @@ open_indirect_converter(
to_type == QChar)
return (XlcConv) NULL;
- lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ lc_conv = Xmalloc(sizeof(XlcConvRec));
if (lc_conv == NULL)
return (XlcConv) NULL;
lc_conv->methods = &conv_methods;
- lc_conv->state = (XPointer) Xcalloc(1, sizeof(ConvRec));
+ lc_conv->state = Xcalloc(1, sizeof(ConvRec));
if (lc_conv->state == NULL)
goto err;
diff --git a/nx-X11/lib/X11/lcDB.c b/nx-X11/lib/X11/lcDB.c
index 1353acfe3..1111ec955 100644
--- a/nx-X11/lib/X11/lcDB.c
+++ b/nx-X11/lib/X11/lcDB.c
@@ -165,7 +165,7 @@ init_parse_info (void)
int size;
if (!allocated) {
bzero(&parse_info, sizeof(DBParseInfo));
- parse_info.buf = (char *)Xmalloc(BUFSIZE);
+ parse_info.buf = Xmalloc(BUFSIZE);
parse_info.bufMaxSize = BUFSIZE;
allocated = 1;
return;
@@ -196,7 +196,7 @@ clear_parse_info (void)
if (*parse_info.value) {
Xfree(*parse_info.value);
}
- Xfree((char *)parse_info.value);
+ Xfree(parse_info.value);
}
ptr = parse_info.buf;
size = parse_info.bufMaxSize;
@@ -210,11 +210,12 @@ realloc_parse_info(
int len)
{
char *p;
+ int newsize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
- parse_info.bufMaxSize = BUFSIZE * ((parse_info.bufsize + len)/BUFSIZE + 1);
- p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
+ p = Xrealloc(parse_info.buf, newsize);
if (p == NULL)
return False;
+ parse_info.bufMaxSize = newsize;
parse_info.buf = p;
return True;
@@ -247,9 +248,9 @@ realloc_line(
char *str = line->str;
if (str != NULL) {
- str = (char *)Xrealloc(str, size);
+ str = Xrealloc(str, size);
} else {
- str = (char *)Xmalloc(size);
+ str = Xmalloc(size);
}
if (str == NULL) {
/* malloc error */
@@ -485,7 +486,7 @@ append_value_list (void)
}
if (value_list == (char **)NULL) {
- value_list = (char **)Xmalloc(sizeof(char *) * 2);
+ value_list = Xmalloc(sizeof(char *) * 2);
*value_list = NULL;
} else {
char **prev_list = value_list;
@@ -501,11 +502,11 @@ append_value_list (void)
value = *value_list;
if (value == NULL) {
- value = (char *)Xmalloc(value_len + len + 1);
+ value = Xmalloc(value_len + len + 1);
} else {
char *prev_value = value;
- value = (char *)Xrealloc(value, value_len + len + 1);
+ value = Xrealloc(value, value_len + len + 1);
if (value == NULL) {
Xfree(prev_value);
}
@@ -591,26 +592,23 @@ store_to_database(
goto err;
}
- new = (Database)Xmalloc(sizeof(DatabaseRec));
+ new = Xcalloc(1, sizeof(DatabaseRec));
if (new == (Database)NULL) {
goto err;
}
- bzero(new, sizeof(DatabaseRec));
- new->category = (char *)Xmalloc(strlen(parse_info.category) + 1);
+ new->category = strdup(parse_info.category);
if (new->category == NULL) {
goto err;
}
- strcpy(new->category, parse_info.category);
if (! construct_name(name, sizeof(name))) {
goto err;
}
- new->name = (char *)Xmalloc(strlen(name) + 1);
+ new->name = strdup(name);
if (new->name == NULL) {
goto err;
}
- strcpy(new->name, name);
new->next = *db;
new->value = parse_info.value;
new->value_num = parse_info.value_num;
@@ -944,10 +942,9 @@ f_default(
case S_NULL:
if (parse_info.category != NULL)
goto err;
- p = (char *)Xmalloc(strlen(wordp) + 1);
+ p = strdup(wordp);
if (p == NULL)
goto err;
- strcpy(p, wordp);
parse_info.category = p;
parse_info.pre_state = S_CATEGORY;
break;
@@ -961,10 +958,9 @@ f_default(
break;
}
}
- p = (char *)Xmalloc(strlen(wordp) + 1);
+ p = strdup(wordp);
if (p == NULL)
goto err;
- strcpy(p, wordp);
if (parse_info.name[parse_info.nest_depth] != NULL) {
Xfree(parse_info.name[parse_info.nest_depth]);
}
@@ -1037,10 +1033,10 @@ DestroyDatabase(
if (*p->value != NULL) {
Xfree(*p->value);
}
- Xfree((char *)p->value);
+ Xfree(p->value);
}
db = p->next;
- Xfree((char *)p);
+ Xfree(p);
p = db;
}
}
@@ -1253,7 +1249,7 @@ _XlcDestroyLocaleDataBase(
if (p->lc_db == lc_db) {
if ((-- p->ref_count) < 1) {
if (p->lc_db != (XlcDatabase)NULL) {
- Xfree((char *)p->lc_db);
+ Xfree(p->lc_db);
}
DestroyDatabase(p->database);
if (prev == (XlcDatabaseList)NULL) {
@@ -1309,17 +1305,16 @@ _XlcCreateLocaleDataBase(
return (XPointer)NULL;
}
n = CountDatabase(database);
- lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1));
+ lc_db = Xcalloc(n + 1, sizeof(XlcDatabaseRec));
if (lc_db == (XlcDatabase)NULL)
goto err;
- bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1));
for (p = database, i = 0; p && i < n; p = p->next, ++i) {
lc_db[i].category_q = XrmStringToQuark(p->category);
lc_db[i].name_q = XrmStringToQuark(p->name);
lc_db[i].db = p;
}
- new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec));
+ new = Xmalloc(sizeof(XlcDatabaseListRec));
if (new == (XlcDatabaseList)NULL) {
goto err;
}
@@ -1336,7 +1331,7 @@ _XlcCreateLocaleDataBase(
err:
DestroyDatabase(database);
if (lc_db != (XlcDatabase)NULL) {
- Xfree((char *)lc_db);
+ Xfree(lc_db);
}
Xfree (name);
return (XPointer)NULL;
diff --git a/nx-X11/lib/X11/lcDefConv.c b/nx-X11/lib/X11/lcDefConv.c
index 5860a79a5..51ad2f8e7 100644
--- a/nx-X11/lib/X11/lcDefConv.c
+++ b/nx-X11/lib/X11/lcDefConv.c
@@ -149,14 +149,16 @@ def_mbstowcs(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
- wchar_t *dst = (wchar_t *) * to;
+ const char *src;
+ wchar_t *dst = (wchar_t *) *to;
State state = (State) conv->state;
int unconv = 0;
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
+
while (*from_left && *to_left) {
(*from_left)--;
if (state->MBtoWC (state, src++, dst)) {
@@ -181,7 +183,7 @@ def_wcstombs(
XPointer *args,
int num_args)
{
- const wchar_t *src = (const wchar_t *) * from;
+ const wchar_t *src;
char *dst = (char *) *to;
State state = (State) conv->state;
char ch[MB_LEN_MAX];
@@ -190,6 +192,8 @@ def_wcstombs(
if (from == NULL || *from == NULL)
return 0;
+ src = (const wchar_t *) *from;
+
while (*from_left && *to_left) {
(*from_left)--;
if (state->WCtoMB (state, *src++, ch)) {
@@ -214,7 +218,7 @@ mbstostr(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
+ const char *src;
char *dst = (char *) *to;
CodeSet codeset;
State state = (State) conv->state;
@@ -224,6 +228,8 @@ mbstostr(
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
+
while (*from_left && *to_left) {
ch = *src++;
(*from_left)--;
@@ -251,7 +257,7 @@ wcstostr(
XPointer *args,
int num_args)
{
- const wchar_t *src = (const wchar_t *) *from;
+ const wchar_t *src;
char *dst = (char *) *to;
CodeSet codeset;
State state = (State) conv->state;
@@ -261,6 +267,8 @@ wcstostr(
if (from == NULL || *from == NULL)
return 0;
+ src = (const wchar_t *) *from;
+
while (*from_left && *to_left) {
(*from_left)--;
if (state->WCtoMB (state, *src++, ch)) {
@@ -290,7 +298,7 @@ mbstocs(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
+ const char *src;
char *dst = (char *) *to;
int length;
State state = (State) conv->state;
@@ -300,6 +308,7 @@ mbstocs(
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
length = min(*from_left, *to_left);
cur_side = *src & GR;
@@ -336,7 +345,7 @@ wcstocs(
XPointer *args,
int num_args)
{
- const wchar_t *src = (const wchar_t *) * from;
+ const wchar_t *src;
char *dst = (char *) *to;
State state = (State) conv->state;
char cur_side = 0, ch[MB_LEN_MAX];
@@ -346,6 +355,8 @@ wcstocs(
if (from == NULL || *from == NULL)
return 0;
+ src = (const wchar_t *) *from;
+
while (*from_left) {
if ((found = state->WCtoMB (state, *src, ch)))
break;
@@ -398,7 +409,7 @@ cstombs(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
+ const char *src;
char *dst = (char *) *to;
CodeSet codeset;
XlcCharSet charset;
@@ -410,6 +421,8 @@ cstombs(
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
+
if (num_args > 0) {
charset = (XlcCharSet) args[0];
if (charset == NULL)
@@ -467,8 +480,8 @@ cstowcs(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
- wchar_t *dst = (wchar_t *) * to;
+ const char *src;
+ wchar_t *dst = (wchar_t *) *to;
CodeSet codeset;
XlcCharSet charset;
State state = (State) conv->state;
@@ -479,6 +492,8 @@ cstowcs(
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
+
if (num_args > 0) {
charset = (XlcCharSet) args[0];
if (charset == NULL)
@@ -539,13 +554,14 @@ strtombs(
XPointer *args,
int num_args)
{
- const char *src = (const char *) *from;
+ const char *src;
char *dst = (char *) *to;
int length;
if (from == NULL || *from == NULL)
return 0;
+ src = (const char *) *from;
length = min(*from_left, *to_left);
while (length) {
*dst++ = *src++;
@@ -563,10 +579,9 @@ static void
close_converter(
XlcConv conv)
{
- if (conv->state)
- Xfree((char *) conv->state);
- Xfree((char *) conv);
+ Xfree(conv->state);
+ Xfree(conv);
}
static XlcConv
@@ -577,11 +592,11 @@ create_conv(
XlcConv conv;
State state;
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ conv = Xcalloc(1, sizeof(XlcConvRec));
if (conv == NULL)
return (XlcConv) NULL;
- state = (State) Xmalloc(sizeof(StateRec));
+ state = Xmalloc(sizeof(StateRec));
if (state == NULL) {
close_converter(conv);
return (XlcConv) NULL;
diff --git a/nx-X11/lib/X11/lcDynamic.c b/nx-X11/lib/X11/lcDynamic.c
index f6df94cbb..3821bfff1 100644
--- a/nx-X11/lib/X11/lcDynamic.c
+++ b/nx-X11/lib/X11/lcDynamic.c
@@ -65,8 +65,8 @@ _XlcDynamicLoader(
XLCd lcd;
void *nlshandler;
- sprintf(libpath,"%s/%s/%s",
- XLOCALEDIR,name,LCLIBNAME);
+ snprintf(libpath, sizeof(libpath), "%s/%s/%s",
+ XLOCALEDIR, name, LCLIBNAME);
nlshandler = dlopen(libpath,LAZY);
_XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods");
lcd = _XlcCreateLC(name,_XlcGenericMethods);
diff --git a/nx-X11/lib/X11/lcEuc.c b/nx-X11/lib/X11/lcEuc.c
deleted file mode 100644
index 442e3090f..000000000
--- a/nx-X11/lib/X11/lcEuc.c
+++ /dev/null
@@ -1,1537 +0,0 @@
-/******************************************************************
-
- Copyright 1992, 1993 by FUJITSU LIMITED
- Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
-
-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 FUJITSU LIMITED and
-Fujitsu Open Systems Solutions, Inc. not be used in advertising or
-publicity pertaining to distribution of the software without specific,
-written prior permission.
-FUJITSU LIMITED and Fujitsu Open Systems Solutions, Inc. makes no
-representations about the suitability of this software for any purpose.
-It is provided "as is" without express or implied warranty.
-
-FUJITSU LIMITED AND FUJITSU OPEN SYSTEMS SOLUTIONS, INC. DISCLAIMS ALL
-WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU OPEN SYSTEMS
-SOLUTIONS, INC. AND FUJITSU LIMITED 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.
-
- Authors: Shigeru Yamada (yamada@ossi.com)
- Jeffrey Bloomfield (jeffb@ossi.com)
- Yoshiyuki Segawa (segawa@ossi.com)
-
-*****************************************************************/
-
-/*
- * An EUC locale.
- * Supports: all locales with codeset eucJP, eucKR, eucCN, eucTW.
- * How: Provides converters for euc*.
- * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
- */
-
-#ifdef X_LOCALE
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XlcGeneric.h"
-
-#include <ctype.h>
-#ifdef WIN32
-#define isascii __isascii
-#endif
-
-#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
-#define CS1 codesets[1] /* Codeset 1 - Kanji */
-#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
-#define CS3 codesets[3] /* Codeset 3 - User defined */
-
-#define SS2 0x8e /* Single-shift char: CS2 */
-#define SS3 0x8f /* Single-shift char: CS3 */
-
-#define ASCII_CODESET 0
-#define KANJI_CODESET 1
-#define KANA_CODESET 2
-#define USERDEF_CODESET 3
-#define MAX_CODESETS
-
-#define GR 0x80 /* begins right-side (non-ascii) region */
-#define GL 0x7f /* ends left-side (ascii) region */
-
-#define isleftside(c) (((c) & GR) ? 0 : 1)
-#define isrightside(c) (!isleftside(c))
-
-#define BIT8OFF(c) ((c) & GL)
-#define BIT8ON(c) ((c) | GR)
-
-typedef unsigned char Uchar;
-typedef unsigned long Ulong;
-typedef unsigned int Uint;
-
-static CodeSet GetCodeSetFromCharSet (XLCd lcd, XlcCharSet charset);
-static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
-
-#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
- BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
- BIT8OFF(c) != 0x1b)
-
-/*
- * Notes:
- * 1. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
- * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
- * 2. Using direct converters (e.g. mbstowcs()) decreases conversion
- * times by 20-40% (depends on specific converter used).
- */
-
-static int
-euc_mbstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
-
- Uchar ch;
- int chr_len = 0;
- int sshift = False;
- int shift_mult = 0;
- Uint chrcode;
-
- Uint wc_encode = 0;
- Uint wc_tmp = 0;
-
- int cs0flg = False;
- int cs1flg = False;
- int length = 0;
- int unconv_num = 0;
-
- Bool new_char;
-
- const char *inbufptr = *from;
- wchar_t *outbufptr = (wchar_t *) *to;
-
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
- for (new_char = True; *from_left > 0 && *to_left > 0;) {
-
- ch = *inbufptr++;
-
- if (isleftside(ch)) { /* CS0 */
- if (ASCII_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- if( cs0flg == True) {
- new_char = True;
- cs0flg = False;
- }
- length = CS0->length;
- *outbufptr++ = (wchar_t)ch;
- (*from_left)--;
- (*to_left)--;
- continue;
- }
- else if (ch == SS2) { /* CS2 */
- if (KANA_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- if (sshift == True || cs1flg == True) {
- cs1flg = False;
- unconv_num++;
- continue;
- }
- length = CS2->length;
- wc_encode = CS2->wc_encoding;
- chrcode = 0;
- sshift = True;
- cs0flg = True;
- (*from_left)--;
- continue;
- }
- else if (ch == SS3) { /* CS3 */
- if (USERDEF_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- if (sshift == True || cs1flg == True) {
- cs1flg = False;
- unconv_num++;
- continue;
- }
- length = CS3->length;
- if (*from_left < 1 )
- unconv_num++;
- wc_encode = CS3->wc_encoding;
- chrcode = 0;
- sshift = True;
- cs0flg = True;
- (*from_left)--;
- continue;
-
- } else { /* CS1 */
- if (KANJI_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- if (sshift == False) {
- length = CS1->length;
- if (*from_left < 1)
- unconv_num++;
- wc_encode = CS1->wc_encoding;
- }
- chrcode = BIT8OFF(ch);
- cs0flg = True;
- cs1flg = True;
- (*from_left)--;
- }
-
- if (new_char) { /* begin new character */
- chr_len = length;
- shift_mult = length - 1;
- new_char = False;
- }
-
- chrcode <<= (wc_shift * shift_mult);
- shift_mult--;
- wc_tmp |= chrcode;
-
- if (--chr_len == 0) {
- wc_tmp |= wc_encode;
- *outbufptr++ = wc_tmp;
- (*to_left)--;
-
- new_char = True;
- sshift = False;
- cs0flg = False;
- cs1flg = False;
- wc_tmp = (Uint)0;
- }
-
- } /* end for */
-
- *to = (XPointer)outbufptr;
-
- if (cs0flg == True || cs1flg == True) /* error check on last char */
- unconv_num++;
-
- return unconv_num;
-}
-
-
-static int
-euc_wcstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const wchar_t *inbufptr = (const wchar_t *) *from;
- XPointer outbufptr = *to;
- wchar_t wch;
- int length;
- Uchar tmp;
- int unconv_num = 0;
-
- XLCd lcd = (XLCd)conv->state;
- CodeSet codeset;
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
- for (; *from_left > 0 && *to_left > 0; (*from_left)-- ) {
-
- wch = *inbufptr++;
-
- if (!(codeset = wc_codeset(lcd, wch))) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
-
- length = codeset->length;
- wch ^= (wchar_t)codeset->wc_encoding;
-
- if (codeset->parse_info) { /* put out SS2 or SS3 */
- if (*to_left < length + 1) {
- unconv_num++;
- break;
- }
- *outbufptr++ = *codeset->parse_info->encoding;
- (*to_left)--;
- } else {
- if (*to_left < length) {
- unconv_num++;
- break;
- }
- }
-
- do {
- length--;
- tmp = (wch>>(wchar_t)(length * wc_shift));
-
- if (codeset->side == XlcGR)
- tmp = BIT8ON(tmp);
-
- *outbufptr++ = (Uchar)tmp;
- (*to_left)--;
- } while (length);
- }
-
- *to = (XPointer)outbufptr;
-
- return unconv_num;
-}
-
-
-static int
-euc_mbtocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- XlcCharSet charset;
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
- int length;
- int unconv_num = 0;
- int min_ch = 0;
- const char *src = *from;
- char *dst = *to;
-
- if (isleftside(*src)) { /* 7-bit (CS0) */
- if (ASCII_CODESET >= codeset_num)
- return -1;
- charset = *CS0->charset_list;
- }
- else if ((Uchar)*src == SS2) { /* half-kana (CS2) */
- if (KANA_CODESET >= codeset_num)
- return -1;
- charset = *CS2->charset_list;
- src++;
- (*from_left)--;
- }
- else if ((Uchar)*src == SS3) { /* user-def */
- if (USERDEF_CODESET >= codeset_num)
- return -1;
- charset = *CS3->charset_list;
- src++;
- (*from_left)--;
- }
- else { /* Kanji (CS1) */
- if (KANJI_CODESET >= codeset_num)
- return -1;
- charset = *CS1->charset_list;
- }
-
- if(*from_left < charset->char_size || *to_left < charset->char_size)
- return -1;
-
- min_ch = 0x20;
- if (charset->set_size == 94)
- if (charset->char_size > 1 || charset->side == XlcGR)
- min_ch = 0x21;
-
- length = charset->char_size;
- do {
- if(BADCHAR(min_ch, *src)) {
- unconv_num++;
- src++;
- break;
- }
- switch (charset->side) {
- case XlcGL:
- *dst++ = BIT8OFF(*src++);
- break;
- case XlcGR:
- *dst++ = BIT8ON(*src++);
- break;
- default:
- *dst++ = *src++;
- break;
- }
- } while (--length);
-
- *to = dst;
- *from = (XPointer) src;
- *from_left -= charset->char_size;
- *to_left -= charset->char_size - length;
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-
-static int
-euc_mbstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const char *tmp_from;
- char *tmp_to;
- int tmp_from_left, tmp_to_left;
- XlcCharSet charset, tmp_charset;
- XPointer tmp_args[1];
- int unconv_num = 0, ret;
-
-/* Determine the charset of the segment and convert one characater: */
-
- tmp_args[0] = (XPointer) &charset; /* charset from euc_mbtocs() */
- while
- ((ret = euc_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
- unconv_num += ret;
- if ( ret < 0 )
- return ret;
-
- tmp_from = *from;
- tmp_from_left = *from_left;
- tmp_to_left = *to_left;
- tmp_to = *to;
-
-/* Convert remainder of the segment: */
-
- tmp_args[0] = (XPointer) &tmp_charset;
- while( (ret = euc_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
- (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
-
- if (ret > 0) {
- unconv_num += ret;
- continue;
- }
-
- if (tmp_charset != charset) /* quit on end of segment */
- break;
-
- *from = (XPointer) tmp_from;
- *from_left = tmp_from_left;
- *to = (XPointer) tmp_to;
- *to_left = tmp_to_left;
- }
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-
-static int
-euc_wcstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- const wchar_t *wcptr = (const wchar_t *) *from;
- char *bufptr = (char *) *to;
- wchar_t wch;
- char *tmpptr;
- int length;
- CodeSet codeset;
- Ulong wc_encoding;
- int wcstr_len = *from_left, buf_len = *to_left;
-
- if (!(codeset = wc_codeset(lcd, *wcptr)))
- return -1;
-
- wc_encoding = codeset->wc_encoding;
-
- if (wcstr_len < buf_len / codeset->length)
- buf_len = wcstr_len * codeset->length;
-
- for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
- wch = *wcptr;
-
- if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
- break;
-
- length = codeset->length;
-
- buf_len -= length;
- bufptr += length;
- tmpptr = bufptr - 1;
-
- while (length--) {
- *tmpptr-- = codeset->length == 1 && codeset->side == XlcGR ?
- BIT8ON(wch) : BIT8OFF(wch);
- wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
- }
- }
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = *codeset->charset_list;
-
- *from_left -= wcptr - (wchar_t *) *from;
- *from = (XPointer) wcptr;
-
- *to_left -= bufptr - *to;
- *to = bufptr;
-
- return 0;
-}
-
-
-static int
-euc_cstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- const char *csptr = *from;
- char *bufptr = *to;
- int csstr_len = *from_left;
- int buf_len = *to_left;
- int length;
- CodeSet codeset;
- int cvt_length;
-
- if (num_args < 1)
- return -1;
-
- if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
- return -1;
-
- cvt_length = 0;
- csstr_len /= codeset->length;
- buf_len /= codeset->length;
-
- if (codeset->parse_info)
- csstr_len *= 2;
-
- if (csstr_len < buf_len)
- buf_len = csstr_len;
-
- cvt_length += buf_len * codeset->length;
-
- if (bufptr) {
- while (buf_len--) {
- if (codeset->parse_info) /* put out SS2 or SS3 */
- *bufptr++ = *codeset->parse_info->encoding;
-
- length = codeset->length;
- while (length--)
- *bufptr++ = codeset->side == XlcGR ?
- BIT8ON(*csptr++) : BIT8OFF(*csptr++);
- }
- }
-
- *from_left -= csptr - *from;
- *from = (XPointer) csptr;
- if (bufptr)
- *to += cvt_length;
- *to_left -= cvt_length;
-
- return 0;
-}
-
-
-static int
-euc_cstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- const char *csptr = *from;
- wchar_t *bufptr = (wchar_t *) *to;
- wchar_t *toptr = (wchar_t *) *to;
- int csstr_len = *from_left;
- int buf_len = *to_left;
- wchar_t wch;
- int length;
- Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
- CodeSet codeset;
-
- if (num_args < 1)
- return -1;
-
- if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
- return -1;
-
- csstr_len /= codeset->length;
- if (csstr_len < buf_len)
- buf_len = csstr_len;
- *to_left -= buf_len;
-
- if (bufptr) {
-
- toptr += buf_len;
- *to = (XPointer) toptr;
-
- while (buf_len--) {
-
- wch = (wchar_t) BIT8OFF(*csptr);
- csptr++;
-
- length = codeset->length - 1;
- while (length--) {
- wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
- csptr++;
- }
- *bufptr++ = wch | codeset->wc_encoding;
- }
- }
- *from_left -= csptr - *from;
- *from = (XPointer) csptr;
-
- return 0;
-}
-
-
-static CodeSet
-wc_codeset(
- XLCd lcd,
- wchar_t wch)
-{
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- int end = XLC_GENERIC(lcd, codeset_num);
- Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
-
- for (; --end >= 0; codesets++)
- if ( widech == (*codesets)->wc_encoding )
- return *codesets;
-
- return NULL;
-}
-
-
-static CodeSet
-GetCodeSetFromCharSet(
- XLCd lcd,
- XlcCharSet charset)
-{
- CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
- XlcCharSet *charset_list;
- int codeset_num, num_charsets;
-
- codeset_num = XLC_GENERIC(lcd, codeset_num);
-
- for ( ; codeset_num-- > 0; codeset++) {
- num_charsets = (*codeset)->num_charsets;
- charset_list = (*codeset)->charset_list;
-
- for ( ; num_charsets-- > 0; charset_list++)
- if (*charset_list == charset)
- return *codeset;
- }
-
- return (CodeSet) NULL;
-}
-
-
-static XlcConv
-create_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
- if (conv == NULL)
- return (XlcConv) NULL;
-
- conv->methods = methods;
- conv->state = (XPointer) lcd;
- return conv;
-}
-
-
-/*
- * Stripped down Direct CT converters for EUC
- *
- */
-
-typedef struct _CTDataRec {
- int side;
- int length;
- char *name;
- Ulong wc_encoding;
- char sshift;
- char *ct_encoding;
- int ct_encoding_len;
- int set_size;
- Uchar min_ch;
- Uchar ct_type;
-} CTDataRec, *CTData;
-
-typedef struct _StateRec {
- CTData GL_charset;
- CTData GR_charset;
- CTData charset;
-} StateRec, *State;
-
-#define CT_STD 0
-#define CT_NSTD 1
-#define CT_DIR 2
-#define CT_EXT0 3
-#define CT_EXT1 4
-#define CT_EXT2 5
-#define CT_VER 6
-
-static CTDataRec ctdata[] =
-{
- { XlcGL, 1, "ISO8859-1:GL", 0, 0, "\033(B" , 3, 0, 0, CT_STD },
- { XlcGR, 1, "ISO8859-1:GR", 0, 0, "\033-A" , 3, 0, 0, CT_STD },
- { XlcGL, 1, "JISX0201.1976-0:GL", 0, 0, "\033(J" , 3, 0, 0, CT_STD },
- { XlcGR, 1, "JISX0201.1976-0:GR", 0, 0, "\033)I" , 3, 0, 0, CT_STD },
- { XlcGL, 2, "JISX0208.1983-0:GL", 0, 0, "\033$(B" , 4, 0, 0, CT_STD },
- { XlcGR, 2, "JISX0208.1983-0:GR", 0, 0, "\033$)B" , 4, 0, 0, CT_STD },
- { XlcGL, 2, "JISX0212.1990-0:GL", 0, 0, "\033$(D" , 4, 0, 0, CT_STD },
- { XlcGR, 2, "JISX0212.1990-0:GR", 0, 0, "\033$)D" , 4, 0, 0, CT_STD },
- { XlcUnknown, 0, "Ignore-Ext-Status?", 0, 0, "\033#" , 2, 0, 0, CT_VER },
- { XlcUnknown, 0, "NonStd-?-OctetChar", 0, 0, "\033%/0" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 1, "NonStd-1-OctetChar", 0, 0, "\033%/1" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 2, "NonStd-2-OctetChar", 0, 0, "\033%/2" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 3, "NonStd-3-OctetChar", 0, 0, "\033%/3" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 4, "NonStd-4-OctetChar", 0, 0, "\033%/4" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 0, "Extension-2" , 0, 0, "\033%/" , 3, 0, 0, CT_EXT2 },
- { XlcUnknown, 0, "Extension-0" , 0, 0, "\033" , 1, 0, 0, CT_EXT0 },
- { XlcUnknown, 0, "Begin-L-to-R-Text", 0, 0, "\2331]" , 3, 0, 0, CT_DIR },
- { XlcUnknown, 0, "Begin-R-to-L-Text", 0, 0, "\2332]" , 3, 0, 0, CT_DIR },
- { XlcUnknown, 0, "End-Of-String", 0, 0, "\233]" , 2, 0, 0, CT_DIR },
- { XlcUnknown, 0, "Extension-1" , 0, 0, "\233" , 1, 0, 0, CT_EXT1 },
-};
-
-/* Note on above table: euc_ctstombs() and euc_ctstowcs() parser depends on
- * certain table entries occuring in decreasing string length--
- * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
- * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
- */
-
-static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
-static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
-
-#define Ascii 0
-#define Kanji 1
-#define Kana 2
-#define Userdef 3
-
-/*
- * initCTptr(): Set ctdptr[] to point at ctdata[], indexed by codeset_num.
- */
-static void
-initCTptr(
- XLCd lcd)
-{
- int num_codesets = XLC_GENERIC(lcd, codeset_num);
- int num_charsets;
- int i, j;
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- CodeSet codeset;
- XlcCharSet charset;
- CTData ctdp = ctdata;
-
- ctdptr[Ascii] = &ctdata[0]; /* failsafe */
-
- for (i = 0; i < num_codesets; i++) {
-
- codeset = codesets[i];
- num_charsets = codeset->num_charsets;
-
- for (j = 0; j < num_charsets; j++) {
-
- charset = codeset->charset_list[j];
-
- for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
-
- if (! strcmp(ctdp->name, charset->name)) {
-
- ctdptr[codeset->cs_num] = ctdp;
-
- ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
-
- ctdptr[codeset->cs_num]->set_size =
- charset->set_size;
-
- ctdptr[codeset->cs_num]->min_ch =
- charset->set_size == 94 &&
- (ctdptr[codeset->cs_num]->length > 1 ||
- ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
-
- if (codeset->parse_info) {
- ctdptr[codeset->cs_num]->sshift =
- *codeset->parse_info->encoding;
- }
-
- break;
- }
- }
- }
-}
-
-
-#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
-#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
-
-static int
-euc_ctstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
- const char *inbufptr = *from;
- const char *inbuf_base;
- wchar_t *outbufptr = (wchar_t *) *to;
- wchar_t *outbuf_base = outbufptr;
- int clen, length;
- int unconv_num = 0;
- unsigned int ct_seglen = 0;
- Uchar ct_type = 0;
- int shift_mult;
- wchar_t wc_tmp;
- wchar_t wch;
- Ulong wc_encoding;
- CTData ctdp = ctdata;
- CTData GL_ctdp = ctdp; /* GL ctdp save */
- CTData GR_ctdp = ctdp; /* GR ctdp save */
- Bool save_outbuf = True;
- /* If outbufptr is NULL, doen't save output, but just counts
- a length to hold the output */
- if (outbufptr == NULL) save_outbuf = False;
-
- for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
- {
- ct_type = CT_STD;
- /* change GL/GR charset */
- if(ctdp->side == XlcGR && isleftside(*inbufptr)){
- /* select GL side */
- ctdp = GL_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
- /* select GR side */
- ctdp = GR_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }
- if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
- for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
-
- if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
- {
- inbufptr += ctdp->ct_encoding_len;
- (*from_left) -= ctdp->ct_encoding_len;
- if (ctdp->length) {
- length = ctdp->length;
- if( *from_left < length ) {
- *to = (XPointer)outbufptr;
- *to_left -= outbufptr - outbuf_base;
- return( unconv_num + *from_left );
- }
- }
- ct_type = ctdp->ct_type;
- if(ctdp->side == XlcGL){
- GL_ctdp = ctdp; /* save GL ctdp */
- }else{
- GR_ctdp = ctdp; /* save GR ctdp */
- }
- break;
- }
- }
- if (ctdp > ctd_endp) /* failed to match CT sequence */
- unconv_num++;
- }
-
-/* The following code insures that non-standard encodings, direction, extension,
- * and version strings are ignored; subject to change in future.
- */
- switch (ct_type) {
- case CT_STD:
- break;
- case CT_EXT2:
- inbufptr++;
- (*from_left)--;
- case CT_NSTD:
- ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
- inbufptr += ct_seglen;
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT0:
- inbuf_base = inbufptr;
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- *(from_left) -= ct_seglen;
- continue;
- case CT_EXT1:
- inbuf_base = inbufptr;
- SKIP_P(inbufptr);
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- *(from_left) -= ct_seglen;
- continue;
- case CT_DIR:
- continue;
- case CT_VER:
- inbufptr += 2;
- *(from_left) -= 2;
- continue;
- }
-
- wc_encoding = (ctdp == ctdptr[Kana] && isleftside(*inbufptr)) ?
- ctdptr[Ascii]->wc_encoding: ctdp->wc_encoding;
-
- shift_mult = length - 1;
- wch = (wchar_t)0;
- clen = length;
-
- do {
- wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
- wch |= wc_tmp;
- shift_mult--;
- } while (--clen);
-
- if (save_outbuf == True)
- *outbufptr++ = wch | wc_encoding;
- if (--*to_left == 0 && *from_left != length) {
- *to = (XPointer)outbufptr;
- unconv_num = *from_left;
- return unconv_num;
- }
- }
-
- *to = (XPointer)outbufptr;
-
- return unconv_num;
-
-}
-
-
-#define byte1 (length == codeset->length - 1)
-#define byte2 (byte1 == 0)
-#define kanji (codeset->cs_num == 1)
-#define kana (codeset->cs_num == 2)
-#define userdef (codeset->cs_num == 3)
-
-static int
-euc_wcstocts(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- int ct_len = *to_left;
- const wchar_t *inbufptr = (const wchar_t *) *from;
- char *ctptr = *to;
- XPointer ct_base = ctptr;
- wchar_t wch;
- int length;
- int unconv_num = 0;
- Uchar tmp;
- Uchar t1 = 0;
- int num_conv;
-
- StateRec ct_state;
- XLCd lcd = (XLCd)conv->state;
- CTData charset;
- CodeSet codeset;
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
-/* Initial State: */
- ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
- ct_state.GR_charset = NULL;
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (; *from_left > 0 ; (*from_left)-- ) {
-
- wch = *inbufptr++;
-
- if (!(codeset = wc_codeset(lcd, wch))) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
-
- charset = ctdptr[codeset->cs_num];
-
- length = codeset->length;
- wch ^= (wchar_t)codeset->wc_encoding;
-
- if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
- (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
-
- ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
-
- if (ct_len < 0) {
- unconv_num++;
- break;
- }
-
- if (ctptr) {
- strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
- ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
- }
- }
-
- if (charset->side == XlcGR) {
- ct_state.GR_charset = charset;
- ct_state.GL_charset = NULL;
- } else if (charset->side == XlcGL) {
- ct_state.GL_charset = charset;
- ct_state.GR_charset = NULL;
- }
-
- do {
-
- length--;
- tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
-
- if (kana) {
- if (BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
- *ctptr++ = (char)BIT8ON(tmp);
- }
-
- else if (byte1 && (kanji || userdef))
- t1 = tmp;
-
- else if (byte2 && (kanji || userdef)) {
- if (BADCHAR(charset->min_ch, (char)t1) ||
- BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
- if (charset->side == XlcGR) {
- *ctptr++ = (char)BIT8ON(t1);
- *ctptr++ = (char)BIT8ON(tmp);
- } else {
- *ctptr++ = (char)BIT8OFF(t1);
- *ctptr++ = (char)BIT8OFF(tmp);
- }
- }
-
- else {
- if (BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
- *ctptr++ = (char)tmp;
- }
-
-
- } while (length);
-
- } /* end for */
-
- *to = (XPointer)ctptr;
-
- if ((num_conv = (int)(ctptr - ct_base)) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-}
-#undef byte1
-#undef byte2
-#undef kana
-#undef kanji
-#undef userdef
-
-
-#define byte1 (ctdp->length == clen)
-#define kana (ctdp == ctdptr[Kana] && isrightside(*inbufptr))
-/* #define kanji (ctdp == ctdptr[Kanji]) */
-#define kanji (strstr(ctdp->name, "JISX0208"))
-#define userdef (ctdp == ctdptr[Userdef])
-
-static int
-euc_ctstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- char *inbufptr = *from;
- XPointer outbufptr = *to;
- const char *inbuf_base;
- XPointer outbuf_base = outbufptr;
- int clen, length;
- int unconv_num = 0;
- unsigned int ct_seglen = 0;
- Uchar ct_type = 0;
- CTData ctdp = &ctdata[0]; /* default */
- CTData GL_ctdp = ctdp; /* GL ctdp save */
- CTData GR_ctdp = ctdp; /* GR ctdp save */
- Bool save_outbuf = True;
- /* If outbufptr is NULL, doen't save output, but just counts
- a length to hold the output */
- if (outbufptr == NULL) save_outbuf = False;
-
- for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
- {
- ct_type = CT_STD;
- /* change GL/GR charset */
- if(ctdp->side == XlcGR && isleftside(*inbufptr)){
- /* select GL side */
- ctdp = GL_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
- /* select GR side */
- ctdp = GR_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }
- if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
-
- for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
-
- if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
- {
- inbufptr += ctdp->ct_encoding_len;
- (*from_left) -= ctdp->ct_encoding_len;
- if (ctdp->length) {
- length = ctdp->length;
- if( *from_left < length ) {
- *to = (XPointer)outbufptr;
- *to_left -= outbufptr - outbuf_base;
- return( unconv_num + *from_left );
- }
- }
- ct_type = ctdp->ct_type;
- if(ctdp->side == XlcGL){
- GL_ctdp = ctdp; /* save GL ctdp */
- }else{
- GR_ctdp = ctdp; /* save GR ctdp */
- }
- break;
- }
- }
- if (ctdp > ctd_endp) /* failed to match CT sequence */
- unconv_num++;
- }
-
-/* The following code insures that non-standard encodings, direction, extension,
- * and version strings are ignored; subject to change in future.
- */
- switch (ct_type) {
- case CT_STD:
- break;
- case CT_EXT2:
- inbufptr++;
- (*from_left)--;
- case CT_NSTD:
- ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
- inbufptr += ct_seglen;
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT0:
- inbuf_base = inbufptr;
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- *(from_left) -= ct_seglen;
- continue;
- case CT_EXT1:
- inbuf_base = inbufptr;
- SKIP_P(inbufptr);
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- *(from_left) -= ct_seglen;
- continue;
- case CT_DIR:
- continue;
- case CT_VER:
- inbufptr += 2;
- *(from_left) -= 2;
- continue;
- }
-
- clen = length;
- do {
-
- if (byte1) {
- if (kanji) {
- /* FIXME: assignment of read-only location */
- *inbufptr = BIT8ON(*inbufptr);
- *(inbufptr+1) = BIT8ON(*(inbufptr+1));
- }
- else if (kana || userdef) {
- if (save_outbuf == True) {
- *outbufptr++ = ctdp->sshift;
- }
- (*to_left)--;
- }
- }
- if (save_outbuf == True) {
- *outbufptr++ = *inbufptr;
- }
- (*to_left)--;
- inbufptr++;
-
- if (*to_left == 0 && *from_left != length) {
- *to = (XPointer)outbufptr;
- unconv_num = *from_left;
- return unconv_num;
- }
- } while (--clen);
- }
-
- *to = outbufptr;
-
- return unconv_num;
-
-}
-#undef byte1
-#undef kana
-#undef kanji
-#undef userdef
-
-
-static int
-euc_mbstocts(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- int ct_len = *to_left;
- int cs_num;
- int clen, length = 0;
- int unconv_num = 0;
- int num_conv;
- const char *inbufptr = *from;
- char *ctptr = *to;
- XPointer ct_base = ctptr;
-
- StateRec ct_state;
- CTData charset;
- XLCd lcd = (XLCd) conv->state;
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
-
-/* Initial State: */
- ct_state.GL_charset = NULL;
- ct_state.GR_charset = NULL;
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (;*from_left > 0; (*from_left) -= length) {
-
- if (isleftside(*inbufptr)) { /* 7-bit (CS0) */
- if (ASCII_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Ascii;
- charset = ctdptr[Ascii];
- }
- else if ((Uchar)*inbufptr == SS2) { /* Kana */
- if (KANA_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Kana;
- charset = ctdptr[Kana];
- inbufptr++;
- (*from_left)--;
- }
- else if ((Uchar)*inbufptr == SS3) { /* Userdef */
- if (USERDEF_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Userdef;
- charset = ctdptr[Userdef];
- inbufptr++;
- (*from_left)--;
- }
- else {
- if (KANJI_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Kanji;
- charset = ctdptr[Kanji];
- }
-
- length = charset->length;
-
- if (BADCHAR(charset->min_ch, *inbufptr))
- continue;
-
- if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
- (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
-
- ct_len -= ctdptr[cs_num]->ct_encoding_len;
- if (ct_len < 0) {
- unconv_num++;
- break;
- }
-
- if (ctptr) {
- strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
- ctptr += ctdptr[cs_num]->ct_encoding_len;
- }
- }
-
- if (charset->side == XlcGR) {
- ct_state.GR_charset = charset;
- ct_state.GL_charset = NULL;
- } else if (charset->side == XlcGL) {
- ct_state.GL_charset = charset;
- ct_state.GR_charset = NULL;
- }
-
- clen = length;
-
- do {
- *ctptr++ = charset == ct_state.GR_charset ?
- BIT8ON(*inbufptr++) : BIT8OFF(*inbufptr++);
- } while (--clen);
- }
-
- *to = (XPointer)ctptr;
-
- if ((num_conv = (int)(ctptr - ct_base)) > 0)
- (*to_left) -= num_conv;
- return unconv_num;
-
-}
-
-
-static void
-close_converter(
- XlcConv conv)
-{
- Xfree((char *) conv);
-}
-
-enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
- CTSTOWCS, CTSTOMBS, WCSTOCTS, MBSTOCTS };
-
-static XlcConvMethodsRec conv_methods[] = {
- {close_converter, euc_mbstocs, NULL },
- {close_converter, euc_wcstocs, NULL },
- {close_converter, euc_mbtocs, NULL },
- {close_converter, euc_cstombs, NULL },
- {close_converter, euc_cstowcs, NULL },
- {close_converter, euc_mbstowcs, NULL },
- {close_converter, euc_wcstombs, NULL },
- {close_converter, euc_ctstowcs, NULL },
- {close_converter, euc_ctstombs, NULL },
- {close_converter, euc_wcstocts, NULL },
- {close_converter, euc_mbstocts, NULL },
-};
-
-
-static XlcConv
-open_mbstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOCS]);
-}
-
-static XlcConv
-open_wcstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOCS]);
-}
-
-static XlcConv
-open_mbtocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBTOCS]);
-}
-
-static XlcConv
-open_cstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CSTOMBS]);
-}
-
-static XlcConv
-open_cstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CSTOWCS]);
-}
-
-static XlcConv
-open_mbstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
-}
-
-static XlcConv
-open_wcstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
-}
-
-static XlcConv
-open_ctstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
-}
-
-static XlcConv
-open_ctstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
-}
-
-static XlcConv
-open_wcstocts(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
-}
-
-static XlcConv
-open_mbstocts(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
-}
-
-XLCd
-_XlcEucLoader(
- const char *name)
-{
- XLCd lcd;
-
- lcd = _XlcCreateLC(name, _XlcGenericMethods);
- if (lcd == NULL)
- return lcd;
-
- if (!XLC_PUBLIC_PART(lcd)->codeset ||
- (_XlcNCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "euc", 3))) {
- _XlcDestroyLC(lcd);
- return (XLCd) NULL;
- }
-
- initCTptr(lcd);
-
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
-
-#ifndef FORCE_INDIRECT_CONVERTER
- _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
- _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
-#endif
-
- _XlcAddUtf8Converters(lcd);
-
- return lcd;
-}
-
-#else
-typedef int dummy;
-#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcFile.c b/nx-X11/lib/X11/lcFile.c
index 8c2e7c062..eeb6ce312 100644
--- a/nx-X11/lib/X11/lcFile.c
+++ b/nx-X11/lib/X11/lcFile.c
@@ -401,10 +401,7 @@ resolve_name(
from = args[1], to = args[0]; /* right to left */
}
if (! strcmp(from, lc_name)) {
- name = Xmalloc(strlen(to) + 1);
- if (name != NULL) {
- strcpy(name, to);
- }
+ name = strdup(to);
break;
}
}
@@ -489,9 +486,11 @@ _XlcFileName(
for (i = 0; i < n; ++i) {
char buf[PATH_MAX], *name;
+ if (args[i] == NULL)
+ continue;
+
name = NULL;
- if ((5 + (args[i] ? strlen (args[i]) : 0) + strlen(cat)) < PATH_MAX) {
- sprintf(buf, "%s/%s.dir", args[i], cat);
+ if (snprintf(buf, PATH_MAX, "%s/%s.dir", args[i], cat) < PATH_MAX) {
name = resolve_name(siname, buf, RtoL);
}
if (name == NULL) {
@@ -501,13 +500,13 @@ _XlcFileName(
/* supposed to be absolute path name */
file_name = name;
} else {
- file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
- (name ? strlen (name) : 0));
- if (file_name != NULL)
- sprintf(file_name, "%s/%s", args[i], name);
+ if (snprintf(buf, PATH_MAX, "%s/%s", args[i], name) < PATH_MAX)
+ file_name = strdup(buf);
+ else
+ file_name = NULL;
Xfree(name);
}
- if (isreadable(file_name)) {
+ if (file_name && isreadable(file_name)) {
break;
}
Xfree(file_name);
@@ -538,9 +537,11 @@ _XlcResolveLocaleName(
xlocaledir (dir, PATH_MAX);
n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
for (i = 0; i < n; ++i) {
- if ((2 + (args[i] ? strlen (args[i]) : 0) +
- strlen (locale_alias)) < PATH_MAX) {
- sprintf (buf, "%s/%s", args[i], locale_alias);
+ if (args[i] == NULL)
+ continue;
+
+ if (snprintf (buf, PATH_MAX, "%s/%s", args[i], locale_alias)
+ < PATH_MAX) {
name = resolve_name (lc_name, buf, LtoR);
if (!name) {
if (!nlc_name)
@@ -553,12 +554,11 @@ _XlcResolveLocaleName(
break;
}
}
- if (nlc_name) Xfree(nlc_name);
+ Xfree(nlc_name);
if (name == NULL) {
/* vendor locale name == Xlocale name, no expansion of alias */
- pub->siname = Xmalloc (strlen (lc_name) + 1);
- strcpy (pub->siname, lc_name);
+ pub->siname = strdup (lc_name);
} else {
pub->siname = name;
}
@@ -615,14 +615,14 @@ _XlcResolveI18NPath(char *buf, int buf_len)
}
char *
-_XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
+_XlcLocaleDirName(char *dir_name, size_t dir_len, const char *lc_name)
{
- char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char dir[PATH_MAX], buf[PATH_MAX];
int i, n;
char *args[NUM_LOCALEDIR];
static char locale_alias[] = LOCALE_ALIAS;
- char *target_name = (char*)0;
- char *target_dir = (char*)0;
+ char *target_name = NULL;
+ char *target_dir = NULL;
char *nlc_name = NULL;
static char* last_dir_name = 0;
static size_t last_dir_len = 0;
@@ -635,94 +635,72 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
}
xlocaledir (dir, PATH_MAX);
- n = _XlcParsePath(dir, args, 256);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
for (i = 0; i < n; ++i) {
+ char *name = NULL;
+
+ if (args[i] == NULL)
+ continue;
- if ((2 + (args[i] ? strlen(args[i]) : 0) +
- strlen(locale_alias)) < PATH_MAX) {
- sprintf (buf, "%s/%s", args[i], locale_alias);
- name = resolve_name(lc_name, buf, LtoR);
+ if (snprintf (buf, PATH_MAX, "%s/%s", args[i], locale_alias)
+ < PATH_MAX) {
+ name = resolve_name(lc_name, buf, LtoR);
if (!name) {
if (!nlc_name)
nlc_name = normalize_lcname(lc_name);
if (nlc_name)
name = resolve_name (nlc_name, buf, LtoR);
}
- }
-
- /* If name is not an alias, use lc_name for locale.dir search */
- if (name == NULL)
- name = lc_name;
+ }
- /* look at locale.dir */
+ /* look at locale.dir */
- target_dir = args[i];
- if (!target_dir) {
- /* something wrong */
- if (name != lc_name)
- Xfree(name);
- continue;
- }
- if ((1 + (target_dir ? strlen (target_dir) : 0) +
- strlen("locale.dir")) < PATH_MAX) {
- sprintf(buf, "%s/locale.dir", target_dir);
- target_name = resolve_name(name, buf, RtoL);
- }
- if (name != lc_name)
- Xfree(name);
- if (target_name != NULL) {
- char *p = 0;
- if ((p = strstr(target_name, "/XLC_LOCALE"))) {
- *p = '\0';
- break;
- }
- Xfree(target_name);
- target_name = NULL;
- }
+ target_dir = args[i];
+ if (snprintf(buf, PATH_MAX, "%s/locale.dir", target_dir) < PATH_MAX) {
+ /* If name is not an alias, use lc_name for locale.dir search */
+ target_name = resolve_name(name ? name : lc_name, buf, RtoL);
+ }
+ Xfree(name);
name = NULL;
+ if (target_name != NULL) {
+ char *p = 0;
+ if ((p = strstr(target_name, "/XLC_LOCALE"))) {
+ *p = '\0';
+ break;
+ }
+ Xfree(target_name);
+ target_name = NULL;
+ }
}
- if (nlc_name) Xfree(nlc_name);
+ Xfree(nlc_name);
- if (target_name == NULL) {
- /* vendor locale name == Xlocale name, no expansion of alias */
- target_dir = args[0];
- target_name = lc_name;
- }
- /* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
- strncpy(dir_name, target_dir, dir_len - 1);
- if (strlen(target_dir) >= dir_len - 1) {
- dir_name[dir_len - 1] = '\0';
- } else {
- strcat(dir_name, "/");
- strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
- if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
- dir_name[dir_len - 1] = '\0';
- }
- if (target_name != lc_name)
- Xfree(target_name);
+ if (target_name == NULL)
+ /* vendor locale name == Xlocale name, no expansion of alias */
+ snprintf(dir_name, dir_len, "%s/%s", args[0], lc_name);
+ else
+ snprintf(dir_name, dir_len, "%s/%s", target_dir, target_name);
+
+ Xfree(target_name);
+ Xfree (last_dir_name);
+ Xfree (last_lc_name);
- if (last_dir_name != 0)
- Xfree (last_dir_name);
- if (last_lc_name != 0)
- Xfree (last_lc_name);
last_dir_len = strlen (dir_name) + 1;
last_dir_name = Xmalloc (last_dir_len);
strcpy (last_dir_name, dir_name);
- last_lc_name = Xmalloc (strlen (lc_name) + 1);
- strcpy (last_lc_name, lc_name);
+ last_lc_name = strdup (lc_name);
return dir_name;
}
char *
-_XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
+_XlcLocaleLibDirName(char *dir_name, size_t dir_len, const char *lc_name)
{
- char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char dir[PATH_MAX], buf[PATH_MAX];
int i, n;
char *args[NUM_LOCALEDIR];
static char locale_alias[] = LOCALE_ALIAS;
- char *target_name = (char*)0;
- char *target_dir = (char*)0;
+ char *target_name = NULL;
+ char *target_dir = NULL;
char *nlc_name = NULL;
static char* last_dir_name = 0;
static size_t last_dir_len = 0;
@@ -735,12 +713,15 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
}
xlocalelibdir (dir, PATH_MAX);
- n = _XlcParsePath(dir, args, 256);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
for (i = 0; i < n; ++i) {
+ char *name = NULL;
- if ((2 + (args[i] ? strlen(args[i]) : 0) +
- strlen(locale_alias)) < PATH_MAX) {
- sprintf (buf, "%s/%s", args[i], locale_alias);
+ if (args[i] == NULL)
+ continue;
+
+ if (snprintf (buf, PATH_MAX, "%s/%s", args[i], locale_alias)
+ < PATH_MAX) {
name = resolve_name(lc_name, buf, LtoR);
if (!name) {
if (!nlc_name)
@@ -750,26 +731,15 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
}
}
- /* If name is not an alias, use lc_name for locale.dir search */
- if (name == NULL)
- name = lc_name;
-
/* look at locale.dir */
target_dir = args[i];
- if (!target_dir) {
- /* something wrong */
- if (name != lc_name)
- Xfree(name);
- continue;
+ if (snprintf(buf, PATH_MAX, "%s/locale.dir", target_dir) < PATH_MAX) {
+ /* If name is not an alias, use lc_name for locale.dir search */
+ target_name = resolve_name(name ? name : lc_name, buf, RtoL);
}
- if ((1 + (target_dir ? strlen (target_dir) : 0) +
- strlen("locale.dir")) < PATH_MAX) {
- sprintf(buf, "%s/locale.dir", target_dir);
- target_name = resolve_name(name, buf, RtoL);
- }
- if (name != lc_name)
- Xfree(name);
+ Xfree(name);
+ name = NULL;
if (target_name != NULL) {
char *p = 0;
if ((p = strstr(target_name, "/XLC_LOCALE"))) {
@@ -779,37 +749,22 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
Xfree(target_name);
target_name = NULL;
}
- name = NULL;
}
- if (nlc_name) Xfree(nlc_name);
+ Xfree(nlc_name);
- if (target_name == NULL) {
+ if (target_name == NULL)
/* vendor locale name == Xlocale name, no expansion of alias */
- target_dir = args[0];
- target_name = lc_name;
- }
- /* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
- strncpy(dir_name, target_dir, dir_len - 1);
- if (strlen(target_dir) >= dir_len - 1) {
- dir_name[dir_len - 1] = '\0';
- } else {
- strcat(dir_name, "/");
- strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
- if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
- dir_name[dir_len - 1] = '\0';
- }
- if (target_name != lc_name)
- Xfree(target_name);
+ snprintf(dir_name, dir_len, "%s/%s", args[0], lc_name);
+ else
+ snprintf(dir_name, dir_len, "%s/%s", target_dir, target_name);
+ Xfree(target_name);
+ Xfree (last_dir_name);
+ Xfree (last_lc_name);
- if (last_dir_name != 0)
- Xfree (last_dir_name);
- if (last_lc_name != 0)
- Xfree (last_lc_name);
last_dir_len = strlen (dir_name) + 1;
last_dir_name = Xmalloc (last_dir_len);
strcpy (last_dir_name, dir_name);
- last_lc_name = Xmalloc (strlen (lc_name) + 1);
- strcpy (last_lc_name, lc_name);
+ last_lc_name = strdup (lc_name);
return dir_name;
}
diff --git a/nx-X11/lib/X11/lcGenConv.c b/nx-X11/lib/X11/lcGenConv.c
index 074a8d726..eede76807 100644
--- a/nx-X11/lib/X11/lcGenConv.c
+++ b/nx-X11/lib/X11/lcGenConv.c
@@ -342,7 +342,7 @@ byteM_parse_codeset(
continue;
for (j = 0; j < codeset->length; j++) {
- ch = *((unsigned char *)(inbufptr + j));
+ ch = *((const unsigned char *)(inbufptr + j));
byteM_rec = byteM[j];
byteinfo = byteM_rec.byteinfo;
@@ -753,7 +753,7 @@ mbstowcs_org(
CodeSet codeset = NULL;
- const char *inbufptr = *from;
+ const char *inbufptr;
wchar_t *outbufptr = (wchar_t *) *to;
int from_size = *from_left;
@@ -764,8 +764,7 @@ mbstowcs_org(
return( 0 );
}
- if (*from_left > *to_left)
- *from_left = *to_left;
+ inbufptr = *from;
while (*from_left && *to_left) {
@@ -921,9 +920,6 @@ wcstombs_org(
int defstr_len = strlen(default_string);
- if (*from_left > *to_left)
- *from_left = *to_left;
-
while (*from_left && *to_left) {
wc = *inbufptr++;
@@ -1080,9 +1076,6 @@ wcstocts(
int from_size = *from_left;
char *ext_seg_len = NULL;
- if (*from_left > *to_left)
- *from_left = *to_left;
-
while (*from_left && *to_left) {
wc = *inbufptr++;
@@ -1232,8 +1225,7 @@ stdc_wcstocts(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -1261,7 +1253,7 @@ ctstowcs(
CodeSet codeset = NULL;
XlcCharSet charset_tmp;
- const char *inbufptr = *from;
+ const char *inbufptr;
wchar_t *outbufptr = (wchar_t *) *to;
int from_size = *from_left;
@@ -1271,9 +1263,7 @@ ctstowcs(
_XlcResetConverter(conv);
return( 0 );
}
-
- if (*from_left > *to_left)
- *from_left = *to_left;
+ inbufptr = *from;
while (*from_left && *to_left) {
@@ -1449,7 +1439,7 @@ cstowcs(
CodeSet codeset = NULL;
XlcCharSet charset, charset_tmp;
- const char *inbufptr = *from;
+ const char *inbufptr;
wchar_t *outbufptr = (wchar_t *) *to;
int from_size = *from_left;
@@ -1457,6 +1447,8 @@ cstowcs(
return( 0 );
}
+ inbufptr = *from;
+
charset = (XlcCharSet) args[0];
while (*from_left && *to_left) {
@@ -1555,8 +1547,7 @@ stdc_ctstowcs(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -1591,8 +1582,7 @@ stdc_cstowcs(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -1627,8 +1617,7 @@ mbstocts(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -1655,7 +1644,7 @@ mbstostr(
CodeSet codeset = NULL;
- const char *inbufptr = *from;
+ const char *inbufptr;
char *outbufptr = *to;
int from_size = *from_left;
@@ -1666,8 +1655,7 @@ mbstostr(
return( 0 );
}
- if (*from_left > *to_left)
- *from_left = *to_left;
+ inbufptr = *from;
while (*from_left && *to_left) {
@@ -1773,7 +1761,7 @@ mbtocs(
CodeSet codeset = NULL;
XlcCharSet charset = NULL;
- const char *inbufptr = *from;
+ const char *inbufptr;
char *outbufptr = *to;
int from_size = *from_left;
@@ -1784,8 +1772,7 @@ mbtocs(
return( 0 );
}
- if (*from_left > *to_left)
- *from_left = *to_left;
+ inbufptr = *from;
while (*from_left && *to_left) {
@@ -1872,7 +1859,7 @@ output:
return -1;
}
- /* nomal end */
+ /* normal end */
*from = (XPointer) inbufptr;
*to = (XPointer) outbufptr;
@@ -1959,10 +1946,6 @@ wcstostr(
const char *default_string = XLC_PUBLIC(lcd, default_string);
int defstr_len = strlen(default_string);
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
while (*from_left && *to_left) {
wc = *inbufptr++;
@@ -2084,8 +2067,7 @@ stdc_wcstostr(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -2117,9 +2099,6 @@ wctocs(
char *outbufptr = *to;
int from_size = *from_left;
- if (*from_left > *to_left)
- *from_left = *to_left;
-
if (*from_left && *to_left) {
wc = *inbufptr++;
@@ -2171,7 +2150,7 @@ end:
return -1;
}
- /* nomal end */
+ /* normal end */
*from = (XPointer) inbufptr;
*to = (XPointer) outbufptr;
@@ -2225,7 +2204,7 @@ end:
return -1;
}
- /* nomal end */
+ /* normal end */
*from = (XPointer) src;
*from_left = src_left;
@@ -2362,8 +2341,7 @@ ctstombs(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -2398,8 +2376,7 @@ cstombs(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -2430,9 +2407,6 @@ strtombs(
char *outbufptr = *to;
int from_size = *from_left;
- if (*from_left > *to_left)
- *from_left = *to_left;
-
while (*from_left && *to_left) {
ch = *inbufptr++;
@@ -2540,9 +2514,6 @@ strtowcs(
wchar_t *outbufptr = (wchar_t *)*to;
int from_size = *from_left;
- if (*from_left > *to_left)
- *from_left = *to_left;
-
while (*from_left && *to_left) {
ch = *inbufptr++;
@@ -2613,8 +2584,7 @@ stdc_strtowcs(
goto ret;
ret:
- if (buf)
- Xfree((char *)buf);
+ Xfree(buf);
return (unconv_num1 + unconv_num2);
}
@@ -2627,15 +2597,9 @@ static void
close_converter(
XlcConv conv)
{
- if (conv->state) {
- Xfree((char *) conv->state);
- }
-
- if (conv->methods) {
- Xfree((char *) conv->methods);
- }
-
- Xfree((char *) conv);
+ Xfree(conv->state);
+ Xfree(conv->methods);
+ Xfree(conv);
}
/* -------------------------------------------------------------------------- */
@@ -2650,20 +2614,19 @@ create_conv(
XlcConv conv;
State state;
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ conv = Xcalloc(1, sizeof(XlcConvRec));
if (conv == NULL)
return (XlcConv) NULL;
- conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
+ conv->methods = Xmalloc(sizeof(XlcConvMethodsRec));
if (conv->methods == NULL)
goto err;
*conv->methods = *methods;
conv->methods->reset = init_state;
- conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ conv->state = Xcalloc(1, sizeof(StateRec));
if (conv->state == NULL)
goto err;
- bzero((char *) conv->state, sizeof(StateRec));
state = (State) conv->state;
state->lcd = lcd;
diff --git a/nx-X11/lib/X11/lcGeneric.c b/nx-X11/lib/X11/lcGeneric.c
index 69ea97db8..1c78a95c6 100644
--- a/nx-X11/lib/X11/lcGeneric.c
+++ b/nx-X11/lib/X11/lcGeneric.c
@@ -60,17 +60,15 @@ create(
XLCd lcd;
XLCdPublicMethods new;
- lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ lcd = Xcalloc(1, sizeof(XLCdRec));
if (lcd == NULL)
return (XLCd) NULL;
- bzero((char *) lcd, sizeof(XLCdRec));
- lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdGenericRec));
+ lcd->core = Xcalloc(1, sizeof(XLCdGenericRec));
if (lcd->core == NULL)
goto err;
- bzero((char *) lcd->core, sizeof(XLCdGenericRec));
- new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ new = Xmalloc(sizeof(XLCdPublicMethodsRec));
if (new == NULL)
goto err;
memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
@@ -158,10 +156,10 @@ add_charset(
int num;
if ((num = codeset->num_charsets))
- new_list = (XlcCharSet *) Xrealloc(codeset->charset_list,
+ new_list = Xrealloc(codeset->charset_list,
(num + 1) * sizeof(XlcCharSet));
else
- new_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet));
+ new_list = Xmalloc(sizeof(XlcCharSet));
if (new_list == NULL)
return False;
@@ -180,16 +178,15 @@ add_codeset(
CodeSet new, *new_list;
int num;
- new = (CodeSet) Xmalloc(sizeof(CodeSetRec));
+ new = Xcalloc(1, sizeof(CodeSetRec));
if (new == NULL)
return NULL;
- bzero((char *) new, sizeof(CodeSetRec));
if ((num = gen->codeset_num))
- new_list = (CodeSet *) Xrealloc(gen->codeset_list,
+ new_list = Xrealloc(gen->codeset_list,
(num + 1) * sizeof(CodeSet));
else
- new_list = (CodeSet *) Xmalloc(sizeof(CodeSet));
+ new_list = Xmalloc(sizeof(CodeSet));
if (new_list == NULL)
goto err;
@@ -218,28 +215,25 @@ add_parse_list(
unsigned char ch;
int num;
- str = (char *) Xmalloc(strlen(encoding) + 1);
+ str = strdup(encoding);
if (str == NULL)
return False;
- strcpy(str, encoding);
- new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec));
+ new = Xcalloc(1, sizeof(ParseInfoRec));
if (new == NULL)
goto err;
- bzero((char *) new, sizeof(ParseInfoRec));
if (gen->mb_parse_table == NULL) {
- gen->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */
+ gen->mb_parse_table = Xcalloc(1, 256); /* 2^8 */
if (gen->mb_parse_table == NULL)
goto err;
- bzero((char *) gen->mb_parse_table, 256);
}
if ((num = gen->mb_parse_list_num))
- new_list = (ParseInfo *) Xrealloc(gen->mb_parse_list,
+ new_list = Xrealloc(gen->mb_parse_list,
(num + 2) * sizeof(ParseInfo));
else {
- new_list = (ParseInfo *) Xmalloc(2 * sizeof(ParseInfo));
+ new_list = Xmalloc(2 * sizeof(ParseInfo));
}
if (new_list == NULL)
@@ -265,8 +259,8 @@ add_parse_list(
err:
Xfree(str);
- if (new)
- Xfree(new);
+
+ Xfree(new);
return False;
}
@@ -279,12 +273,10 @@ free_charset(
ParseInfo *parse_info;
int num;
- if (gen->mb_parse_table)
- Xfree(gen->mb_parse_table);
+ Xfree(gen->mb_parse_table);
if ((num = gen->mb_parse_list_num) > 0) {
for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) {
- if ((*parse_info)->encoding)
- Xfree((*parse_info)->encoding);
+ Xfree((*parse_info)->encoding);
Xfree(*parse_info);
}
Xfree(gen->mb_parse_list);
@@ -357,7 +349,7 @@ _XlcParse_scopemaps(
const char *str_sc;
num = count_scopemap(str);
- scope = (FontScope) Xmalloc(num * sizeof(FontScopeRec));
+ scope = Xmalloc(num * sizeof(FontScopeRec));
if (scope == NULL)
return NULL;
@@ -428,23 +420,23 @@ read_charset_define(
char name[BUFSIZ];
XlcCharSet charsetd;
char **value;
- int num, new;
+ int num, new = 0;
XlcSide side = XlcUnknown;
char *tmp;
for (i=0; ; i++) { /* loop start */
charsetd = 0;
- sprintf(csd, "csd%d", i);
+ snprintf(csd, sizeof(csd), "csd%d", i);
/* charset_name */
- sprintf(name, "%s.%s", csd, "charset_name");
+ snprintf(name, sizeof(name), "%s.%s", csd, "charset_name");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
_XlcDbg_printValue(name,value,num);
if (num > 0) {
/* hackers will get truncated -- C'est la vie */
strncpy(cset_name,value[0], sizeof cset_name - 1);
cset_name[(sizeof cset_name) - 1] = '\0';
- sprintf(name, "%s.%s", csd , "side");
+ snprintf(name, sizeof(name), "%s.%s", csd , "side");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -468,30 +460,29 @@ read_charset_define(
break;
}
if (new) {
- tmp = (char *)Xmalloc(strlen(cset_name)+1);
+ tmp = strdup(cset_name);
if (tmp == NULL)
return;
- strcpy(tmp,cset_name);
charsetd->name = tmp;
}
/* side */
charsetd->side = side ;
/* length */
- sprintf(name, "%s.%s", csd, "length");
+ snprintf(name, sizeof(name), "%s.%s", csd, "length");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
charsetd->char_size = atoi(value[0]);
}
/* gc_number */
- sprintf(name, "%s.%s", csd, "gc_number");
+ snprintf(name, sizeof(name), "%s.%s", csd, "gc_number");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
charsetd->set_size = atoi(value[0]);
}
/* string_encoding */
- sprintf(name, "%s.%s", csd, "string_encoding");
+ snprintf(name, sizeof(name), "%s.%s", csd, "string_encoding");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -502,7 +493,7 @@ read_charset_define(
}
}
/* sequence */
- sprintf(name, "%s.%s", csd, "sequence");
+ snprintf(name, sizeof(name), "%s.%s", csd, "sequence");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -511,14 +502,14 @@ read_charset_define(
Xfree(charsetd->ct_sequence);
}
*/
- tmp = (char *)Xmalloc(strlen(value[0])+1);
+ tmp = Xmalloc(strlen(value[0])+1);
if (tmp == NULL)
return;
charsetd->ct_sequence = tmp;
string_to_encoding(value[0],tmp);
}
/* encoding_name */
- sprintf(name, "%s.%s", csd, "encoding_name");
+ snprintf(name, sizeof(name), "%s.%s", csd, "encoding_name");
_XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -527,8 +518,7 @@ read_charset_define(
Xfree(charsetd->encoding_name);
}
*/
- tmp = (char *)Xmalloc(strlen(value[0])+1);
- strcpy(tmp,value[0]);
+ tmp = strdup(value[0]);
charsetd->encoding_name = tmp;
charsetd->xrm_encoding_name = XrmStringToQuark(tmp);
}
@@ -544,10 +534,10 @@ add_conversion(
int num;
if ((num = gen->segment_conv_num) > 0) {
- new_list = (SegConv) Xrealloc(gen->segment_conv,
+ new_list = Xrealloc(gen->segment_conv,
(num + 1) * sizeof(SegConvRec));
} else {
- new_list = (SegConv) Xmalloc(sizeof(SegConvRec));
+ new_list = Xmalloc(sizeof(SegConvRec));
}
if (new_list == NULL)
@@ -573,10 +563,10 @@ read_segmentconversion(
SegConv conversion;
for (i=0 ; ; i++) { /* loop start */
conversion = 0;
- sprintf(conv, "conv%d", i);
+ snprintf(conv, sizeof(conv), "conv%d", i);
/* length */
- sprintf(name, "%s.%s", conv, "length");
+ snprintf(name, sizeof(name), "%s.%s", conv, "length");
_XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
if (num > 0) {
if (conversion == NULL &&
@@ -593,33 +583,31 @@ read_segmentconversion(
conversion->length = atoi(value[0]);
/* source_encoding */
- sprintf(name, "%s.%s", conv, "source_encoding");
+ snprintf(name, sizeof(name), "%s.%s", conv, "source_encoding");
_XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
if (num > 0) {
char *tmp;
_XlcDbg_printValue(name,value,num);
- tmp = (char *)Xmalloc(strlen(value[0])+1);
+ tmp = strdup(value[0]);
if (tmp == NULL)
return;
- strcpy(tmp,value[0]);
conversion->source_encoding = tmp;
conversion->source = srch_charset_define(tmp,&new);
}
/* destination_encoding */
- sprintf(name, "%s.%s", conv, "destination_encoding");
+ snprintf(name, sizeof(name), "%s.%s", conv, "destination_encoding");
_XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
if (num > 0) {
char *tmp;
_XlcDbg_printValue(name,value,num);
- tmp = (char *)Xmalloc(strlen(value[0])+1);
+ tmp = strdup(value[0]);
if (tmp == NULL)
return;
- strcpy(tmp,value[0]);
conversion->destination_encoding = tmp;
conversion->dest = srch_charset_define(tmp,&new);
}
/* range */
- sprintf(name, "%s.%s", conv, "range");
+ snprintf(name, sizeof(name), "%s.%s", conv, "range");
_XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -627,7 +615,7 @@ read_segmentconversion(
&(conversion->range.start), &(conversion->range.end));
}
/* conversion */
- sprintf(name, "%s.%s", conv, "conversion");
+ snprintf(name, sizeof(name), "%s.%s", conv, "conversion");
_XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -645,18 +633,19 @@ create_ctextseg(
ExtdSegment ret;
char* ptr;
char* cset_name = NULL;
+ size_t cset_len;
int i,new;
FontScope scope;
- ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec));
+ ret = Xmalloc(sizeof(ExtdSegmentRec));
if (ret == NULL)
return NULL;
- ret->name = (char *)Xmalloc(strlen(value[0]) + 1);
+ ret->name = strdup(value[0]);
if (ret->name == NULL) {
Xfree (ret);
return NULL;
}
- strcpy(ret->name,value[0]);
- cset_name = (char*) Xmalloc (strlen(ret->name) + 1);
+ cset_len = strlen(ret->name) + 1;
+ cset_name = Xmalloc (cset_len);
if (cset_name == NULL) {
Xfree (ret->name);
Xfree (ret);
@@ -668,16 +657,16 @@ create_ctextseg(
ptr++;
if (!_XlcNCompareISOLatin1(ptr, "GL", 2)) {
ret->side = XlcGL;
- sprintf(cset_name,"%s:%s",ret->name,"GL");
+ snprintf(cset_name, cset_len, "%s:%s", ret->name, "GL");
} else {
ret->side = XlcGR;
- sprintf(cset_name,"%s:%s",ret->name,"GR");
+ snprintf(cset_name, cset_len, "%s:%s", ret->name, "GR");
}
} else {
ret->side = XlcGLGR;
strcpy(cset_name,ret->name);
}
- ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec));
+ ret->area = Xmalloc((num - 1)*sizeof(FontScopeRec));
if (ret->area == NULL) {
Xfree (cset_name);
Xfree (ret->name);
@@ -742,10 +731,10 @@ load_generic(
char cs[16];
char name[BUFSIZ];
- sprintf(cs, "cs%d", i);
+ snprintf(cs, sizeof(cs), "cs%d", i);
/***** codeset.side *****/
- sprintf(name, "%s.%s", cs , "side");
+ snprintf(name, sizeof(name), "%s.%s", cs , "side");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
char *tmp;
@@ -772,7 +761,7 @@ load_generic(
}
/***** codeset.length *****/
- sprintf(name, "%s.%s", cs , "length");
+ snprintf(name, sizeof(name), "%s.%s", cs , "length");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
@@ -783,7 +772,7 @@ load_generic(
}
/***** codeset.mb_encoding *****/
- sprintf(name, "%s.%s", cs, "mb_encoding");
+ snprintf(name, sizeof(name), "%s.%s", cs, "mb_encoding");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
static struct {
@@ -819,7 +808,7 @@ load_generic(
}
/***** codeset.wc_encoding *****/
- sprintf(name, "%s.%s", cs, "wc_encoding");
+ snprintf(name, sizeof(name), "%s.%s", cs, "wc_encoding");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
@@ -830,7 +819,7 @@ load_generic(
}
/***** codeset.ct_encoding *****/
- sprintf(name, "%s.%s", cs, "ct_encoding");
+ snprintf(name, sizeof(name), "%s.%s", cs, "ct_encoding");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
char *encoding;
@@ -872,7 +861,7 @@ load_generic(
unsigned long start,end;
ByteInfo tmpb;
- sprintf(name,"%s.%s%d",cs,"byte",M);
+ snprintf(name, sizeof(name),"%s.%s%d",cs,"byte",M);
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (M == 1) {
@@ -880,8 +869,7 @@ load_generic(
codeset->byteM = NULL;
break ;
}
- codeset->byteM =
- (ByteInfoListRec *)Xmalloc(
+ codeset->byteM = Xmalloc(
(codeset->length)*sizeof(ByteInfoListRec));
if (codeset->byteM == NULL) {
goto err;
@@ -893,7 +881,7 @@ load_generic(
(codeset->byteM)[M-1].M = M;
(codeset->byteM)[M-1].byteinfo_num = num;
(codeset->byteM)[M-1].byteinfo =
- (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec));
+ Xmalloc(num * sizeof(ByteInfoRec));
for (ii = 0 ; ii < num ; ii++) {
tmpb = (codeset->byteM)[M-1].byteinfo ;
/* default 0x00 - 0xff */
@@ -907,7 +895,7 @@ load_generic(
/***** codeset.mb_conversion *****/
- sprintf(name, "%s.%s", cs, "mb_conversion");
+ snprintf(name, sizeof(name), "%s.%s", cs, "mb_conversion");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -919,7 +907,7 @@ load_generic(
/* [\x%x,\x%x]->\x%x,... */
}
/***** codeset.ct_conversion *****/
- sprintf(name, "%s.%s", cs, "ct_conversion");
+ snprintf(name, sizeof(name), "%s.%s", cs, "ct_conversion");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
@@ -931,14 +919,14 @@ load_generic(
/* [\x%x,\x%x]->\x%x,... */
}
/***** codeset.ct_conversion_file *****/
- sprintf(name, "%s.%s", cs, "ct_conversion_file");
+ snprintf(name, sizeof(name), "%s.%s", cs, "ct_conversion_file");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
/* [\x%x,\x%x]->\x%x,... */
}
/***** codeset.ct_extended_segment *****/
- sprintf(name, "%s.%s", cs, "ct_extended_segment");
+ snprintf(name, sizeof(name), "%s.%s", cs, "ct_extended_segment");
_XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
if (num > 0) {
_XlcDbg_printValue(name,value,num);
diff --git a/nx-X11/lib/X11/lcInit.c b/nx-X11/lib/X11/lcInit.c
index ee66b8c92..e3092f77d 100644
--- a/nx-X11/lib/X11/lcInit.c
+++ b/nx-X11/lib/X11/lcInit.c
@@ -37,7 +37,7 @@ Sun Microsystems, Inc. or its licensors is granted.
*/
/*
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2000 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"),
@@ -106,11 +106,6 @@ Sun Microsystems, Inc. or its licensors is granted.
#define USE_GENERIC_LOADER
#define USE_DEFAULT_LOADER
#define USE_UTF8_LOADER
-#ifdef X_LOCALE
-# define USE_EUC_LOADER
-# define USE_SJIS_LOADER
-# define USE_JIS_LOADER
-#endif
#endif
/*
@@ -138,18 +133,6 @@ _XlcInitLoader(void)
_XlcAddLoader(_XlcUtf8Loader, XlcHead);
#endif
-#ifdef USE_EUC_LOADER
- _XlcAddLoader(_XlcEucLoader, XlcHead);
-#endif
-
-#ifdef USE_SJIS_LOADER
- _XlcAddLoader(_XlcSjisLoader, XlcHead);
-#endif
-
-#ifdef USE_JIS_LOADER
- _XlcAddLoader(_XlcJisLoader, XlcHead);
-#endif
-
#ifdef USE_DYNAMIC_LOADER
_XlcAddLoader(_XlcDynamicLoader, XlcHead);
#endif
@@ -177,18 +160,6 @@ _XlcDeInitLoader(void)
_XlcRemoveLoader(_XlcUtf8Loader);
#endif
-#ifdef USE_EUC_LOADER
- _XlcRemoveLoader(_XlcEucLoader);
-#endif
-
-#ifdef USE_SJIS_LOADER
- _XlcRemoveLoader(_XlcSjisLoader);
-#endif
-
-#ifdef USE_JIS_LOADER
- _XlcRemoveLoader(_XlcJisLoader);
-#endif
-
#ifdef USE_DYNAMIC_LOADER
_XlcRemoveLoader(_XlcDynamicLoader);
#endif
diff --git a/nx-X11/lib/X11/lcJis.c b/nx-X11/lib/X11/lcJis.c
deleted file mode 100644
index 594e6363c..000000000
--- a/nx-X11/lib/X11/lcJis.c
+++ /dev/null
@@ -1,945 +0,0 @@
-/*
- * Copyright 1992, 1993 by TOSHIBA Corp.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, 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 TOSHIBA not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. TOSHIBA make no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * TOSHIBA 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.
- *
- * Author: Katsuhisa Yano TOSHIBA Corp.
- * mopi@osa.ilab.toshiba.co.jp
- */
-
-/*
- * A Japanese JIS locale.
- * Supports: all locales with codeset JIS7.
- * How: Provides converters for JIS.
- * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
- */
-
-#ifdef X_LOCALE
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XlcGeneric.h"
-#include <stdio.h>
-
-#if !defined(X_LOCALE)
-#define STDCVT
-#endif
-
-typedef struct _StateRec {
- XLCd lcd;
- XlcCharSet charset;
- XlcCharSet GL_charset;
- XlcCharSet GR_charset;
-} StateRec, *State;
-
-static void
-init_state(
- XlcConv conv)
-{
- State state = (State) conv->state;
- XLCdGenericPart *gen = XLC_GENERIC_PART(state->lcd);
- CodeSet codeset;
-
- codeset = gen->initial_state_GL;
- if (codeset && codeset->charset_list)
- state->GL_charset = *codeset->charset_list;
- codeset = gen->initial_state_GR;
- if (codeset && codeset->charset_list)
- state->GR_charset = *codeset->charset_list;
-
- if (state->GL_charset == NULL)
- if ((codeset = *gen->codeset_list) != NULL)
- state->GL_charset = *codeset->charset_list;
-}
-
-static int
-compare(
- const char *src,
- const char *encoding,
- int length)
-{
- const char *start = src;
-
- while (length-- > 0) {
- if (*src++ != *encoding++)
- return 0;
- if (*encoding == '\0')
- return src - start;
- }
-
- return 0;
-}
-
-static int
-mbtocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- State state = (State) conv->state;
- XLCd lcd = state->lcd;
- const char *src;
- char *dst;
- unsigned char *mb_parse_table;
- ParseInfo *parse_list, parse_info;
- XlcCharSet charset;
- int length, number, encoding_len = 0;
- int i;
-
- src = *((const char **) from);
- dst = *((char **) to);
-
- mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
- if (mb_parse_table != NULL) {
- number = mb_parse_table[(unsigned char) *src];
- if (number > 0) {
- parse_list = XLC_GENERIC(lcd, mb_parse_list) + number - 1;
- for ( ; (parse_info = *parse_list) != NULL; parse_list++) {
- encoding_len = compare(src, parse_info->encoding, *from_left);
- if (encoding_len > 0) {
- switch (parse_info->type) {
- case E_SS:
- src += encoding_len;
- charset = *parse_info->codeset->charset_list;
- goto found;
- case E_LSL:
- case E_LSR:
- src += encoding_len;
- charset = *parse_info->codeset->charset_list;
- if (parse_info->type == E_LSL)
- state->GL_charset = charset;
- else
- state->GR_charset = charset;
- length = 0;
- goto end;
- case E_GL:
- charset = state->GL_charset;
- goto found;
- case E_GR:
- charset = state->GR_charset;
- goto found;
- default:
- break;
- }
- }
- }
- }
- }
-
- if ((*src & 0x80) && state->GR_charset)
- charset = state->GR_charset;
- else
- charset = state->GL_charset;
-
-found:
- if (charset == NULL ||
- (num_args == 2 && (XlcCharSet) args[1] != charset))
- return -1;
-
- length = charset->char_size;
- if (length > *from_left - encoding_len)
- return -1;
-
- if (dst) {
- if (length > *to_left)
- return -1;
- if (charset->side == XlcGL) {
- for (i = 0; i < length; i++)
- *dst++ = *src++ & 0x7f;
- } else if (charset->side == XlcGR) {
- for (i = 0; i < length; i++)
- *dst++ = *src++ | 0x80;
- } else {
- for (i = 0; i < length; i++)
- *dst++ = *src++;
- }
- *to = (XPointer) dst;
- *to_left -= length;
- }
-end:
- *from = (XPointer) src;
- *from_left -= encoding_len + length;
- state->charset = charset;
- if (num_args == 1)
- *((XlcCharSet *) args[0]) = charset;
-
- return 0;
-}
-
-static int
-mbstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XlcCharSet charset = NULL;
- XPointer tmp_args[2], save_from = *from;
- int ret, unconv_num = 0, tmp_num = 1;
-
- tmp_args[0] = (XPointer) &charset;
-
- while (*from_left > 0 && *to_left > 0) {
- ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, tmp_num);
- if (ret < 0)
- break;
- unconv_num += ret;
- if (tmp_num == 1 && charset) {
- tmp_args[1] = (XPointer) charset;
- tmp_num = 2;
- }
- }
-
- if (save_from == *from)
- return -1;
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-static CodeSet
-wc_parse_codeset(
- XLCd lcd,
- const wchar_t *wcstr)
-{
- CodeSet *codeset;
- unsigned long wc_encoding;
- int num;
-
- wc_encoding = *wcstr & XLC_GENERIC(lcd, wc_encode_mask);
- num = XLC_GENERIC(lcd, codeset_num);
- codeset = XLC_GENERIC(lcd, codeset_list);
- while (num-- > 0) {
- if (wc_encoding == (*codeset)->wc_encoding)
- return *codeset;
- codeset++;
- }
-
- return NULL;
-}
-
-static int
-wcstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- State state = (State) conv->state;
- XLCd lcd = state->lcd;
- const wchar_t *wcptr;
- char *bufptr;
- wchar_t wch;
- char *tmpptr;
- int length;
- CodeSet codeset;
- unsigned long wc_encoding;
- int wcstr_len, buf_len;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- wcptr = *((const wchar_t **) from);
- bufptr = *((char **) to);
- wcstr_len = *from_left;
- buf_len = *to_left;
-
- codeset = wc_parse_codeset(lcd, wcptr);
- if (codeset == NULL)
- return -1;
- wc_encoding = codeset->wc_encoding;
-
- if (wcstr_len < buf_len / codeset->length)
- buf_len = wcstr_len * codeset->length;
-
- for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
- wch = *wcptr;
- if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
- break;
- length = codeset->length;
- buf_len -= length;
- bufptr += length;
-
- tmpptr = bufptr - 1;
- if ((*codeset->charset_list)->side == XlcGL) {
- while (length--) {
- *tmpptr-- = (unsigned char) (wch & 0x7f);
- wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
- }
- } else if ((*codeset->charset_list)->side == XlcGR) {
- while (length--) {
- *tmpptr-- = (unsigned char) (wch | 0x80);
- wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
- }
- } else {
- while (length--) {
- *tmpptr-- = (unsigned char) wch;
- wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
- }
- }
- }
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = *codeset->charset_list;
-
- *from_left -= wcptr - *((wchar_t **) from);
- *from = (XPointer) wcptr;
-
- *to_left -= bufptr - *((char **) to);
- *to = bufptr;
-
- return 0;
-}
-
-static CodeSet
-GetCodeSetFromCharSet(
- XLCd lcd,
- XlcCharSet charset)
-{
- CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
- XlcCharSet *charset_list;
- int codeset_num, num_charsets;
-
- codeset_num = XLC_GENERIC(lcd, codeset_num);
-
- for ( ; codeset_num-- > 0; codeset++) {
- num_charsets = (*codeset)->num_charsets;
- charset_list = (*codeset)->charset_list;
-
- for ( ; num_charsets-- > 0; charset_list++)
- if (*charset_list == charset)
- return *codeset;
- }
-
- return (CodeSet) NULL;
-}
-
-static int
-cstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- State state = (State) conv->state;
- const char *csptr;
- char *bufptr;
- int csstr_len;
- int buf_len;
- int num, encoding_len = 0;
- CodeSet codeset;
- XlcCharSet charset;
- EncodingType type;
- int cvt_length;
-
- csptr = *((const char **) from);
- bufptr = *((char **) to);
- csstr_len = *from_left;
- buf_len = *to_left;
-
- if (num_args < 1)
- return -1;
-
- charset = (XlcCharSet) args[0];
-
- codeset = GetCodeSetFromCharSet(state->lcd, charset);
- if (codeset == NULL)
- return -1;
-
- cvt_length = 0;
- if (codeset->parse_info) {
- switch (type = codeset->parse_info->type) {
- case E_SS:
- encoding_len = strlen(codeset->parse_info->encoding);
- break;
- case E_LSL:
- case E_LSR:
- if (type == E_LSL) {
- if (charset == state->GL_charset)
- break;
- } else {
- if (charset == state->GR_charset)
- break;
- }
- encoding_len = strlen(codeset->parse_info->encoding);
- if (encoding_len > buf_len)
- return -1;
- cvt_length += encoding_len;
- if (bufptr) {
- strcpy(bufptr, codeset->parse_info->encoding);
- bufptr += encoding_len;
- }
- buf_len -= encoding_len;
- encoding_len = 0;
- if (type == E_LSL)
- state->GL_charset = charset;
- else
- state->GR_charset = charset;
- break;
- default:
- break;
- }
- }
-
- csstr_len /= codeset->length;
- buf_len /= codeset->length + encoding_len;
- if (csstr_len < buf_len)
- buf_len = csstr_len;
-
- cvt_length += buf_len * (encoding_len + codeset->length);
- if (bufptr) {
- while (buf_len--) {
- if (encoding_len) {
- strcpy(bufptr, codeset->parse_info->encoding);
- bufptr += encoding_len;
- }
- num = codeset->length;
- if (codeset->side == XlcGL) {
- while (num--)
- *bufptr++ = *csptr++ & 0x7f;
- } else if (codeset->side == XlcGR) {
- while (num--)
- *bufptr++ = *csptr++ | 0x80;
- } else {
- while (num--)
- *bufptr++ = *csptr++;
- }
- }
- }
-
- *from_left -= csptr - *((char **) from);
- *from = (XPointer) csptr;
-
- if (bufptr)
- *to = (XPointer) bufptr;
- *to_left -= cvt_length;
-
- return 0;
-}
-
-static int
-cstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- State state = (State) conv->state;
- XLCd lcd = state->lcd;
- const char *csptr;
- wchar_t *bufptr;
- int csstr_len;
- int buf_len;
- wchar_t wch;
- unsigned long code_mask, wc_encoding;
- int num, length, wc_shift_bits;
- CodeSet codeset;
-
- csptr = *((const char **) from);
- bufptr = *((wchar_t **) to);
- csstr_len = *from_left;
- buf_len = *to_left;
-
- if (num_args < 1)
- return -1;
-
- codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]);
- if (codeset == NULL)
- return -1;
-
- length = codeset->length;
- csstr_len /= length;
- if (csstr_len < buf_len)
- buf_len = csstr_len;
-
- code_mask = ~XLC_GENERIC(lcd, wc_encode_mask);
- wc_encoding = codeset->wc_encoding;
- wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
-
- *to_left -= buf_len;
-
- if (bufptr) {
- while (buf_len--) {
- wch = (wchar_t) (*csptr++ & 0x7f);
- num = length - 1;
- while (num--)
- wch = (wch << wc_shift_bits) | (*csptr++ & 0x7f);
-
- *bufptr++ = (wch & code_mask) | wc_encoding;
- }
- }
-
- *from_left -= csptr - *((char **) from);
- *from = (XPointer) csptr;
-
- if (bufptr)
- *to = (XPointer) bufptr;
-
- return 0;
-}
-
-
-static void
-close_converter(
- XlcConv conv)
-{
- if (conv->state) {
- Xfree((char *) conv->state);
- }
-
- Xfree((char *) conv);
-}
-
-static XlcConv
-create_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
- State state;
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
- if (conv == NULL)
- return (XlcConv) NULL;
-
- conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
- if (conv->methods == NULL)
- goto err;
- *conv->methods = *methods;
- if (XLC_PUBLIC(lcd, is_state_depend))
- conv->methods->reset = init_state;
-
- conv->state = (XPointer) Xmalloc(sizeof(StateRec));
- if (conv->state == NULL)
- goto err;
- bzero((char *) conv->state, sizeof(StateRec));
-
- state = (State) conv->state;
- state->lcd = lcd;
- init_state(conv);
-
- return conv;
-
-err:
- close_converter(conv);
-
- return (XlcConv) NULL;
-}
-
-static XlcConvMethodsRec mbstocs_methods = {
- close_converter,
- mbstocs,
- NULL
-};
-
-static XlcConv
-open_mbstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &mbstocs_methods);
-}
-
-static XlcConvMethodsRec wcstocs_methods = {
- close_converter,
- wcstocs,
- NULL
-};
-
-static XlcConv
-open_wcstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &wcstocs_methods);
-}
-
-static XlcConvMethodsRec mbtocs_methods = {
- close_converter,
- mbtocs,
- NULL
-};
-
-static XlcConv
-open_mbtocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &mbtocs_methods);
-}
-
-static XlcConvMethodsRec cstombs_methods = {
- close_converter,
- cstombs,
- NULL
-};
-
-static XlcConv
-open_cstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &cstombs_methods);
-}
-
-static XlcConvMethodsRec cstowcs_methods = {
- close_converter,
- cstowcs,
- NULL
-};
-
-static XlcConv
-open_cstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &cstowcs_methods);
-}
-
-#ifdef STDCVT
-static int
-stdc_mbstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const char *src = *((const char **) from);
- wchar_t *dst = *((wchar_t **) to);
- int src_left = *from_left;
- int dst_left = *to_left;
- int length;
-
- while (src_left > 0 && dst_left > 0) {
- length = mbtowc(dst, src, src_left);
- if (length < 0)
- break;
-
- src += length;
- src_left -= length;
- if (dst)
- dst++;
- dst_left--;
-
- if (length == 0) {
- src++;
- src_left--;
- break;
- }
- }
-
- if (*from_left == src_left)
- return -1;
-
- *from = (XPointer) src;
- if (dst)
- *to = (XPointer) dst;
- *from_left = src_left;
- *to_left = dst_left;
-
- return 0;
-}
-
-static int
-stdc_wcstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const wchar_t *src = *((const wchar_t **) from);
- char *dst = *((char **) to);
- int src_left = *from_left;
- int dst_left = *to_left;
- int length;
-
- while (src_left > 0 && dst_left > 0) {
- length = wctomb(dst, *src); /* XXX */
- if (length < 0 || dst_left < length)
- break;
-
- src++;
- src_left--;
- dst += length;
- dst_left -= length;
-
- if (length == 0) {
- dst++;
- dst_left--;
- break;
- }
- }
-
- if (*from_left == src_left)
- return -1;
-
- *from = (XPointer) src;
- *to = (XPointer) dst;
- *from_left = src_left;
- *to_left = dst_left;
-
- return 0;
-}
-
-static int
-stdc_wcstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const wchar_t *src = *((const wchar_t **) from);
- wchar_t wch;
- XlcCharSet charset = NULL;
- XPointer tmp_args[2], tmp_from, save_from = *from;
- char tmp[32];
- int length, ret, src_left = *from_left;
- int unconv_num = 0, tmp_num = 1;
-
- tmp_args[0] = (XPointer) &charset;
-
- while (src_left > 0 && *to_left > 0) {
- if (wch = *src) {
- length = wctomb(tmp, wch);
- } else {
- length = 1;
- *tmp = '\0';
- }
-
- if (length < 0)
- break;
-
- tmp_from = (XPointer) tmp;
- ret = mbtocs(conv, &tmp_from, &length, to, to_left, tmp_args, tmp_num);
- if (ret < 0)
- break;
- unconv_num += ret;
- if (tmp_num == 1 && charset) {
- tmp_args[1] = (XPointer) charset;
- tmp_num = 2;
- }
-
- src++;
- src_left--;
- }
-
- if (save_from == (XPointer) src)
- return -1;
-
- *from = (XPointer) src;
- *from_left = src_left;
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-#define DefineLocalBuf char local_buf[BUFSIZ]
-#define AllocLocalBuf(length) (length > BUFSIZ ? (char*) Xmalloc(length) : local_buf)
-#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
-
-static int
-stdc_cstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = ((State) conv->state)->lcd;
- DefineLocalBuf;
- XPointer buf, save_buf;
- int length, left, ret;
-
- left = length = *to_left * XLC_PUBLIC(lcd, mb_cur_max);
- buf = save_buf = (XPointer) AllocLocalBuf(length);
- if (buf == NULL)
- return -1;
-
- ret = cstombs(conv, from, from_left, &buf, &left, args, num_args);
- if (ret < 0)
- goto err;
-
- buf = save_buf;
- length -= left;
- if (stdc_mbstowcs(conv, &buf, &length, to, to_left, args, num_args) < 0)
- ret = -1;
-
-err:
- FreeLocalBuf(save_buf);
-
- return ret;
-}
-
-static XlcConvMethodsRec stdc_mbstowcs_methods = {
- close_converter,
- stdc_mbstowcs,
- NULL
-};
-
-static XlcConv
-open_stdc_mbstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &stdc_mbstowcs_methods);
-}
-
-static XlcConvMethodsRec stdc_wcstombs_methods = {
- close_converter,
- stdc_wcstombs,
- NULL
-};
-
-static XlcConv
-open_stdc_wcstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &stdc_wcstombs_methods);
-}
-
-static XlcConvMethodsRec stdc_wcstocs_methods = {
- close_converter,
- stdc_wcstocs,
- NULL
-};
-
-static XlcConv
-open_stdc_wcstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &stdc_wcstocs_methods);
-}
-
-static XlcConvMethodsRec stdc_cstowcs_methods = {
- close_converter,
- stdc_cstowcs,
- NULL
-};
-
-static XlcConv
-open_stdc_cstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &stdc_cstowcs_methods);
-}
-#endif /* STDCVT */
-
-XLCd
-_XlcJisLoader(
- const char *name)
-{
- XLCd lcd;
-#ifdef STDCVT
- XLCdGenericPart *gen;
-#endif
-
- lcd = _XlcCreateLC(name, _XlcGenericMethods);
- if (lcd == NULL)
- return lcd;
-
- if (!XLC_PUBLIC_PART(lcd)->codeset ||
- (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "JIS7"))) {
- _XlcDestroyLC(lcd);
- return (XLCd) NULL;
- }
-
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
-
-#ifdef STDCVT
- gen = XLC_GENERIC_PART(lcd);
-
- if (gen->use_stdc_env == True) {
- _XlcSetConverter(lcd,XlcNMultiByte,lcd,XlcNWideChar,open_stdc_mbstowcs);
- _XlcSetConverter(lcd,XlcNWideChar,lcd,XlcNMultiByte,open_stdc_wcstombs);
- }
- if (gen->force_convert_to_mb == True) {
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet,open_stdc_wcstocs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar,open_stdc_cstowcs);
- } else {
-#endif
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
-#ifdef STDCVT
- }
-#endif
-
- _XlcAddUtf8Converters(lcd);
-
- return lcd;
-}
-
-#else
-typedef int dummy;
-#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcPrTxt.c b/nx-X11/lib/X11/lcPrTxt.c
index b86fb7f5e..e62e94e80 100644
--- a/nx-X11/lib/X11/lcPrTxt.c
+++ b/nx-X11/lib/X11/lcPrTxt.c
@@ -40,11 +40,11 @@ alloc_list(
if (is_wide_char) {
wchar_t **wstr_list;
- wstr_list = (wchar_t **) Xmalloc(count * sizeof(wchar_t *));
+ wstr_list = Xmalloc(count * sizeof(wchar_t *));
if (wstr_list == NULL)
return (XPointer *) NULL;
- *wstr_list = (wchar_t *) Xmalloc(nitems * sizeof(wchar_t));
+ *wstr_list = Xmalloc(nitems * sizeof(wchar_t));
if (*wstr_list == NULL) {
Xfree(wstr_list);
return (XPointer *) NULL;
@@ -54,11 +54,11 @@ alloc_list(
} else {
char **str_list;
- str_list = (char **) Xmalloc(count * sizeof(char *));
+ str_list = Xmalloc(count * sizeof(char *));
if (str_list == NULL)
return (XPointer *) NULL;
- *str_list = (char *) Xmalloc(nitems);
+ *str_list = Xmalloc(nitems);
if (*str_list == NULL) {
Xfree(str_list);
return (XPointer *) NULL;
@@ -149,14 +149,14 @@ _XTextPropertyToTextList(
return XConverterNotFound;
if (is_wide_char) {
- buf_len = (text_prop->nitems + 1) * sizeof(wchar_t);;
+ buf_len = (text_prop->nitems + 1) * sizeof(wchar_t);
} else {
if (strcmp(to_type, XlcNUtf8String) == 0)
buf_len = text_prop->nitems * 6 + 1;
else
buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
}
- buf = (XPointer) Xmalloc(buf_len);
+ buf = Xmalloc(buf_len);
if (buf == NULL)
return XNoMemory;
to = buf;
@@ -283,8 +283,7 @@ _XwcFreeStringList(
wchar_t **list)
{
if (list) {
- if (*list)
- Xfree(*list);
+ Xfree(*list);
Xfree(list);
}
}
diff --git a/nx-X11/lib/X11/lcPubWrap.c b/nx-X11/lib/X11/lcPubWrap.c
index 2a5ac08d8..3119918c6 100644
--- a/nx-X11/lib/X11/lcPubWrap.c
+++ b/nx-X11/lib/X11/lcPubWrap.c
@@ -78,10 +78,9 @@ _XlcCreateLC(
return (XLCd) NULL;
if (lcd->core->name == NULL) {
- lcd->core->name = (char*) Xmalloc(strlen(name) + 1);
+ lcd->core->name = strdup(name);
if (lcd->core->name == NULL)
goto err;
- strcpy(lcd->core->name, name);
}
if (lcd->methods == NULL)
diff --git a/nx-X11/lib/X11/lcPublic.c b/nx-X11/lib/X11/lcPublic.c
index 2c02f5fba..98a7435fd 100644
--- a/nx-X11/lib/X11/lcPublic.c
+++ b/nx-X11/lib/X11/lcPublic.c
@@ -80,17 +80,15 @@ create(
XLCd lcd;
XLCdPublicMethods new;
- lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ lcd = Xcalloc(1, sizeof(XLCdRec));
if (lcd == NULL)
return (XLCd) NULL;
- bzero((char *) lcd, sizeof(XLCdRec));
- lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec));
+ lcd->core = Xcalloc(1, sizeof(XLCdPublicRec));
if (lcd->core == NULL)
goto err;
- bzero((char *) lcd->core, sizeof(XLCdPublicRec));
- new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ new = Xmalloc(sizeof(XLCdPublicMethodsRec));
if (new == NULL)
goto err;
memcpy(new,methods,sizeof(XLCdPublicMethodsRec));
@@ -108,7 +106,8 @@ load_public(
XLCd lcd)
{
XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
- char **values, *str;
+ char **values;
+ const char *str;
int num;
if(_XlcCreateLocaleDataBase(lcd) == NULL)
@@ -130,10 +129,9 @@ load_public(
_XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
str = (num > 0) ? values[0] : "STRING";
- pub->encoding_name = (char*) Xmalloc(strlen(str) + 1);
+ pub->encoding_name = strdup(str);
if (pub->encoding_name == NULL)
return False;
- strcpy(pub->encoding_name, str);
return True;
}
@@ -256,16 +254,14 @@ static void
destroy_core(
XLCd lcd)
{
- if (lcd->core) {
- if (lcd->core->name)
+ if (lcd) {
+ if (lcd->core) {
Xfree(lcd->core->name);
- Xfree(lcd->core);
+ Xfree(lcd->core);
+ }
+ Xfree(lcd->methods);
+ Xfree(lcd);
}
-
- if (lcd->methods)
- Xfree(lcd->methods);
-
- Xfree(lcd);
}
static void
@@ -276,10 +272,8 @@ destroy(
_XlcDestroyLocaleDataBase(lcd);
- if (pub->siname)
- Xfree(pub->siname);
- if (pub->encoding_name)
- Xfree(pub->encoding_name);
+ Xfree(pub->siname);
+ Xfree(pub->encoding_name);
destroy_core(lcd);
}
diff --git a/nx-X11/lib/X11/lcRM.c b/nx-X11/lib/X11/lcRM.c
index 9f72504ee..bdc20f21d 100644
--- a/nx-X11/lib/X11/lcRM.c
+++ b/nx-X11/lib/X11/lcRM.c
@@ -85,7 +85,7 @@ ub_destroy(
XPointer state)
{
_XCloseLC(((UbState) state)->lcd);
- Xfree((char *) state);
+ Xfree(state);
}
static const XrmMethodsRec ub_methods = {
@@ -177,7 +177,7 @@ mb_destroy(
{
_XlcCloseConverter(((MbState) state)->conv);
_XCloseLC(((MbState) state)->lcd);
- Xfree((char *) state);
+ Xfree(state);
}
static const XrmMethodsRec mb_methods = {
@@ -197,7 +197,7 @@ _XrmDefaultInitParseInfo(
{
if (XLC_PUBLIC(lcd, mb_cur_max) == 1) {
/* Unibyte case. */
- UbState state = (UbState) Xmalloc(sizeof(UbStateRec));
+ UbState state = Xmalloc(sizeof(UbStateRec));
if (state == NULL)
return (XrmMethods) NULL;
@@ -207,14 +207,14 @@ _XrmDefaultInitParseInfo(
return &ub_methods;
} else {
/* Multibyte case. */
- MbState state = (MbState) Xmalloc(sizeof(MbStateRec));
+ MbState state = Xmalloc(sizeof(MbStateRec));
if (state == NULL)
return (XrmMethods) NULL;
state->lcd = lcd;
state->conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
if (state->conv == NULL) {
- Xfree((char *) state);
+ Xfree(state);
return (XrmMethods) NULL;
}
diff --git a/nx-X11/lib/X11/lcSjis.c b/nx-X11/lib/X11/lcSjis.c
deleted file mode 100644
index 74dd033ec..000000000
--- a/nx-X11/lib/X11/lcSjis.c
+++ /dev/null
@@ -1,1612 +0,0 @@
-/****************************************************************
-
- Copyright 1992, 1993 by FUJITSU LIMITED
- Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
- Copyright 1994 by Sony Corporation
-
-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 FUJITSU LIMITED,
-Fujitsu Open Systems Solutions, Inc. and Sony Corporation not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-FUJITSU LIMITED, Fujitsu Open Systems Solutions, Inc. and
-Sony Corporation make no representations about the suitability of
-this software for any purpose. It is provided "as is" without
-express or implied warranty.
-
-FUJITSU LIMITED, FUJITSU OPEN SYSTEMS SOLUTIONS, INC. AND SONY
-CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL FUJITSU OPEN SYSTEMS SOLUTIONS, INC., FUJITSU LIMITED
-AND SONY CORPORATION 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.
-
- Authors: Jeffrey Bloomfield (jeffb@ossi.com)
- Shigeru Yamada (yamada@ossi.com)
- Yoshiyuki Segawa (segawa@ossi.com)
- Modifier:Makoto Wakamatsu Sony Corporation
- makoto@sm.sony.co.jp
-
-*****************************************************************/
-
-/*
- * A Japanese SJIS locale.
- * Supports: all locales with codeset SJIS.
- * How: Provides converters for SJIS.
- * Platforms: Only those defining X_LOCALE (only Lynx, Linux-libc5, OS/2).
- */
-
-#ifdef X_LOCALE
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "XlcGeneric.h"
-
-#include <ctype.h>
-#ifdef WIN32
-#define isascii __isascii
-#endif
-
-#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
-#define CS1 codesets[1] /* Codeset 1 - Kanji */
-#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
-#define CS3 codesets[3] /* Codeset 3 - User defined */
-
-#define ascii (codeset->cs_num == 0)
-#define kanji (codeset->cs_num == 1)
-#define kana (codeset->cs_num == 2)
-#define userdef (codeset->cs_num == 3)
-
-#define ASCII_CODESET 0
-#define KANJI_CODESET 1
-#define KANA_CODESET 2
-#define USERDEF_CODESET 3
-#define MAX_CODESETS 4
-
-#define GR 0x80 /* begins right-side (non-ascii) region */
-#define GL 0x7f /* ends left-side (ascii) region */
-
-#define isleftside(c) (((c) & GR) ? 0 : 1)
-#define isrightside(c) (!isleftside(c))
-
-typedef unsigned char Uchar;
-typedef unsigned long Ulong;
-typedef unsigned int Uint;
-
-/* Acceptable range for 2nd byte of SJIS multibyte char */
-#define VALID_MULTIBYTE(c) \
- ((0x40<=((Uchar)c) && ((Uchar)c)<=0x7e) \
- || (0x80<=((Uchar)c) && ((Uchar)c)<=0xfc))
-
-#ifndef iskanji
-#define iskanji(c) ((0x81<=((Uchar)c) && ((Uchar)c)<=0x9f) \
- || (0xe0<=((Uchar)c) && ((Uchar)c)<=0xef))
-#endif /* !iskanji */
-
-#ifndef iskana
-#define iskana(c) (0xa1<=((Uchar)c) && ((Uchar)c)<=0xdf)
-#endif /* !iskana */
-
-#define isuserdef(c) (0xf0<=((Uchar)c) && ((Uchar)c)<=0xfc)
-
-#define BIT8OFF(c) ((c) & GL)
-#define BIT8ON(c) ((c) | GR)
-
-
-static void jis_to_sjis (Uchar *p1, Uchar *p2);
-static void sjis_to_jis (Uchar *p1, Uchar *p2);
-static CodeSet wc_codeset (XLCd lcd, wchar_t wch);
-
-
-/*
- * Notes:
- * 1. 16-bit widechar format is limited to 14 data bits. Since the 2nd byte
- * of SJIS multibyte chars are in the ranges of 0x40 - 7E and 0x80 - 0xFC,
- * SJIS cannot map directly into 16 bit widechar format within the confines
- * of a single codeset. Therefore, for SJIS widechar conversion, SJIS Kanji
- * is mapped into the JIS codeset. (The algorithms used in jis_to_sjis()
- * and sjis_to_jis() are from Ken Lunde (lunde@mv.us.adobe.com) and are in
- * the public domain.)
- * 2. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
- * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
- * 3. Using direct converters (e.g. mbstowcs()) decreases conversion
- * times by 20-40% (depends on specific converter used).
- */
-
-
-static int
-sjis_mbstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
-
- XLCd lcd = (XLCd)conv->state;
-
- int chr_len = 0;
- int shift_mult = 0;
- Uint chrcode = 0;
-
- Uchar ch, ch2;
- Uint wc_encode = 0;
- Uint wc_tmp = 0;
-
- Bool new_char;
-
- int firstbyte;
- int length = 0;
- int num_conv;
- int unconv_num = 0;
-
- const char *inbufptr = *from;
- wchar_t *outbufptr = (wchar_t *) *to;
- wchar_t *outbuf_base = outbufptr;
-
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (new_char = True, firstbyte = True; *from_left > 0; (*from_left)--) {
-
- ch = *inbufptr++;
-
- if (firstbyte) {
- if (ASCII_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- if (isascii(ch)) {
- length = CS0->length;
- *outbufptr++ = (wchar_t)ch;
- continue;
- }
- else if (iskanji(ch)) {
- if (KANJI_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- firstbyte = False;
- length = CS1->length;
- if (*from_left < length || *to_left < length)
- return -1;
- wc_encode = CS1->wc_encoding;
- ch2 = *inbufptr;
- sjis_to_jis(&ch, &ch2);
- chrcode = ch;
- }
- else if (iskana(ch)) {
- if (KANA_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- length = CS2->length;
- wc_encode = CS2->wc_encoding;
- chrcode = BIT8OFF(ch);
- }
- else if (isuserdef(ch)) {
- if (USERDEF_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- firstbyte = False;
- length = CS3->length;
- if (*from_left < length || *to_left < length)
- return -1;
- wc_encode = CS3->wc_encoding;
- ch2 = *inbufptr;
- sjis_to_jis(&ch, &ch2);
- chrcode = ch;
- }
- else /* unknown */ {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- } else { /* 2nd byte of multibyte char */
- if (!VALID_MULTIBYTE((Uchar) *(inbufptr-1))) {
- unconv_num++;
- firstbyte = True;
- }
- chrcode = ch2;
- }
-
- if (new_char) {
- chr_len = length;
- shift_mult = length - 1;
- new_char = False;
- }
-
- chrcode <<= (wc_shift * shift_mult);
- shift_mult--;
- wc_tmp |= chrcode;
- if (--chr_len == 0) {
- wc_tmp |= wc_encode;
- *outbufptr++ = wc_tmp;
-
- firstbyte = True;
- new_char = True;
- wc_tmp = (Uint)0;
- }
-
- } /* end for */
-
- *to = (XPointer)outbufptr;
-
- if ((num_conv = outbufptr - outbuf_base) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-}
-
-
-#define byte1 (length == codeset->length - 1)
-#define byte2 (byte1 == 0)
-
-static int
-sjis_wcstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const wchar_t *inbufptr = (const wchar_t *) *from;
- XPointer outbufptr = *to;
- XPointer outbuf_base = outbufptr;
- wchar_t wch;
- int length;
- Uchar tmp;
- Uchar t1, t2;
- int num_conv;
- int unconv_num = 0;
-
- XLCd lcd = (XLCd)conv->state;
- CodeSet codeset;
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (; *from_left > 0 ; (*from_left)-- ) {
-
- wch = *inbufptr++;
-
- if (!(codeset = wc_codeset(lcd, wch))) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
-
- length = codeset->length;
- wch ^= (wchar_t)codeset->wc_encoding;
-
- do {
- length--;
- tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
-
- if (kana)
- tmp = BIT8ON(tmp);
-
- else if (byte1 && (kanji || userdef)) {
- t1 = BIT8OFF(tmp);
- continue;
- }
-
- else if (byte2 && (kanji || userdef)) {
- t2 = BIT8OFF(tmp);
- jis_to_sjis(&t1, &t2);
- *outbufptr++ = (char)t1;
- tmp = t2;
- }
-
- *outbufptr++ = (char)tmp;
- } while (length);
-
- } /* end for */
-
- *to = (XPointer)outbufptr;
-
- if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-}
-#undef byte1
-#undef byte2
-
-/*
- * sjis<->jis conversion for widechar kanji (See Note at top of file)
- */
-static void
-sjis_to_jis(
- Uchar *p1,
- Uchar *p2)
-{
- Uchar c1 = *p1;
- Uchar c2 = *p2;
- Uchar adjust = c2 < 0x9f;
- Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0;
- Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e;
-
- *p1 = ((c1 - rowOffset) << 1) - adjust;
- *p2 -= cellOffset;
-}
-
-static void
-jis_to_sjis(
- Uchar *p1,
- Uchar *p2)
-{
- Uchar c1 = *p1;
- Uchar c2 = *p2;
- Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0;
- Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e;
-
- *p1 = ((Uchar)(c1 + 1) >> 1) + rowOffset;
- *p2 = c2 + cellOffset;
-}
-
-static CodeSet
-wc_codeset(
- XLCd lcd,
- wchar_t wch)
-{
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
-#if !defined(__sony_news) || defined(SVR4)
- int end = XLC_GENERIC(lcd, codeset_num);
- Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
-
- for (; --end >= 0; codesets++)
- if ( widech == (*codesets)->wc_encoding )
- return *codesets;
-
- return NULL;
-#else
- if( iskanji(wch >> 8) )
- return( codesets[1] );
- if( iskana(wch & 0xff) )
- return( codesets[2] );
- return( codesets[0] );
-#endif
-}
-
-
-static int
-sjis_mbtocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- XlcCharSet charset = NULL;
- int char_size = 0;
- int unconv_num = 0;
- const char *src = *from;
- char *dst = *to;
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
-
- if (iskanji(*src)) {
- if (KANJI_CODESET >= codeset_num)
- return -1;
- charset = *CS1->charset_list;
- char_size = charset->char_size;
-
- if (*from_left >= char_size && *to_left >= char_size) {
- *dst++ = *src++;
- *dst++ = *src++;
- if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
- unconv_num++;
- sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
- } else
- return -1;
- }
- else if (isuserdef(*src)) {
- if (USERDEF_CODESET >= codeset_num)
- return -1;
- charset = *CS3->charset_list;
- char_size = charset->char_size;
-
- if (*from_left >= char_size && *to_left >= char_size) {
- *dst++ = *src++;
- *dst++ = *src++;
- if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
- unconv_num++;
- sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
- } else
- return -1;
- }
- else if (isascii(*src)) {
- if (ASCII_CODESET >= codeset_num)
- return -1;
- charset = *CS0->charset_list;
- char_size = charset->char_size;
-
- if (*from_left >= char_size && *to_left >= char_size)
- *dst++ = *src++;
- else
- return -1;
- }
- else if (iskana(*src)) {
- if (KANA_CODESET >= codeset_num)
- return -1;
- charset = *CS2->charset_list;
- char_size = charset->char_size;
-
- if (*from_left >= char_size && *to_left >= char_size)
- *dst++ = *src++;
- else
- return -1;
- }
- else /* unknown */
- return -1;
-
- *from_left -= char_size;
- *to_left -= char_size;
-
- *to = (XPointer) dst;
- *from = (XPointer) src;
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-
-static int
-sjis_mbstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const char *tmp_from;
- char *tmp_to;
- int tmp_from_left, tmp_to_left;
- XlcCharSet charset, tmp_charset;
- XPointer tmp_args[1];
- int unconv_num = 0, ret;
-
-/* Determine the charset of the segment and convert one character: */
-
- tmp_args[0] = (XPointer) &charset; /* charset from sjis_mbtocs() */
- while
- ((ret = sjis_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
- unconv_num += ret;
- if ( ret < 0 )
- return ret;
-
- tmp_from = *from;
- tmp_from_left = *from_left;
- tmp_to_left = *to_left;
- tmp_to = *to;
-
-/* Convert remainder of the segment: */
-
- tmp_args[0] = (XPointer) &tmp_charset;
- while( (ret = sjis_mbtocs(conv, (XPointer *) &tmp_from, &tmp_from_left,
- (XPointer *) &tmp_to, &tmp_to_left, tmp_args, 1)) >= 0 ) {
-
- if (ret > 0) {
- unconv_num += ret;
- continue;
- }
-
- if (tmp_charset != charset) /* quit on end of segment */
- break;
-
- *from = (XPointer) tmp_from;
- *from_left = tmp_from_left;
- *to = (XPointer) tmp_to;
- *to_left = tmp_to_left;
- }
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = charset;
-
- return unconv_num;
-}
-
-static int
-sjis_wcstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd) conv->state;
- const wchar_t *wcptr = *((const wchar_t **)from);
- char *bufptr = *((char **) to);
- wchar_t wch;
- char *tmpptr;
- int length;
- CodeSet codeset;
- Ulong wc_encoding;
- int buf_len = *to_left;
- int wcstr_len = *from_left;
-
- if (!(codeset = wc_codeset(lcd, *wcptr)))
- return -1;
-
- if (wcstr_len < buf_len / codeset->length)
- buf_len = wcstr_len * codeset->length;
-
-#if !defined(__sony_news) || defined(SVR4)
- wc_encoding = codeset->wc_encoding;
-
- for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
- wch = *wcptr;
-
- if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
- break;
-
- length = codeset->length;
-
- buf_len -= length;
- bufptr += length;
- tmpptr = bufptr - 1;
-
- while (length--) {
- *tmpptr-- = kana ? BIT8ON(wch) : BIT8OFF(wch);
- wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
- }
- }
-#else
- length = codeset->length;
- for( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len-- ) {
- wch = *wcptr;
- if( codeset != wc_codeset( lcd, wch ) )
- break;
-
- buf_len -= length;
- if( length == 2 ) {
- unsigned short code;
-
- code = sjis2jis( wch & 0xffff );
- *bufptr++ = code >> 8;
- *bufptr++ = code & 0xff;
- }
- else
- *bufptr++ = wch & 0xff;
- }
-#endif
-
- if (num_args > 0)
- *((XlcCharSet *) args[0]) = *codeset->charset_list;
-
- *from_left -= wcptr - (wchar_t *) *from;
- *from = (XPointer) wcptr;
-
- *to_left -= bufptr - *to;
- *to = bufptr;
-
- return 0;
-}
-
-static CodeSet
-GetCodeSetFromCharSet(
- XLCd lcd,
- XlcCharSet charset)
-{
- CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
- XlcCharSet *charset_list;
- int codeset_num, num_charsets;
-
- codeset_num = XLC_GENERIC(lcd, codeset_num);
-
- for ( ; codeset_num-- > 0; codeset++) {
- num_charsets = (*codeset)->num_charsets;
- charset_list = (*codeset)->charset_list;
-
- for ( ; num_charsets-- > 0; charset_list++)
- if (*charset_list == charset)
- return *codeset;
- }
-
- return (CodeSet) NULL;
-}
-
-
-static int
-sjis_cstombs(
- XlcConv conv,
- char **from,
- int *from_left,
- char **to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd) conv->state;
- const char *csptr = *from;
- char *bufptr = *to;
- int csstr_len = *from_left;
- int buf_len = *to_left;
- int length;
- CodeSet codeset;
- int cvt_length = 0;
-
- if (num_args < 1)
- return -1;
-
- if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
- return -1;
-
- csstr_len /= codeset->length;
- buf_len /= codeset->length;
- if (csstr_len < buf_len)
- buf_len = csstr_len;
-
- cvt_length += buf_len * codeset->length;
-
- if (bufptr) {
- while (buf_len--) {
- length = codeset->length;
- while (length--)
- *bufptr++ = codeset->length == 1 && codeset->side == XlcGR ?
- BIT8ON(*csptr++) : BIT8OFF(*csptr++);
-
- if (codeset->length == 2)
- jis_to_sjis((Uchar *)(bufptr-2), (Uchar *)(bufptr-1));
- }
- }
-
- *from_left -= csptr - *from;
- *from = (XPointer) csptr;
-
- if (bufptr)
- *to += cvt_length;
- *to_left -= cvt_length;
-
-
- return 0;
-}
-
-static int
-sjis_cstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd) conv->state;
- const char *csptr = (const char *) *from;
- wchar_t *bufptr = (wchar_t *) *to;
- wchar_t *toptr = (wchar_t *) *to;
- int csstr_len = *from_left;
- int buf_len = *to_left;
- wchar_t wch;
- int length;
- Ulong wc_shift_bits = (int)XLC_GENERIC(lcd, wc_shift_bits);
- CodeSet codeset;
-
- if (num_args < 1)
- return -1;
-
- if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
- return -1;
-
- csstr_len /= codeset->length;
- if (csstr_len < buf_len)
- buf_len = csstr_len;
-
- *to_left -= buf_len;
-
- if (bufptr) {
-
- toptr += buf_len;
- *to = (XPointer) toptr;
-
- while (buf_len--) {
- wch = (wchar_t) BIT8OFF(*csptr);
- csptr++;
-
- length = codeset->length - 1;
- while (length--) {
- wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
- csptr++;
- }
- *bufptr++ = wch | codeset->wc_encoding;
- }
- }
-
- *from_left -= csptr - *from;
- *from = (XPointer) csptr;
-
- return 0;
-}
-
-
-/*
- * Stripped down Direct CT converters for SJIS
- *
- */
-
-#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
- BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
- BIT8OFF(c) != 0x1b)
-
-typedef struct _CTDataRec {
- int side;
- int length;
- char *name;
- Ulong wc_encoding;
- char *ct_encoding;
- int ct_encoding_len;
- int set_size;
- Uchar min_ch;
- Uchar ct_type;
-} CTDataRec, *CTData;
-
-typedef struct _StateRec {
- CTData GL_charset;
- CTData GR_charset;
- CTData charset;
-} StateRec, *State;
-
-#define CT_STD 0
-#define CT_NSTD 1
-#define CT_DIR 2
-#define CT_EXT0 3
-#define CT_EXT1 4
-#define CT_EXT2 5
-#define CT_VER 6
-
-static CTDataRec ctdata[] =
-{
- { XlcGL, 1, "ISO8859-1:GL", 0, "\033(B" , 3, 0, 0, CT_STD },
- { XlcGR, 1, "ISO8859-1:GR", 0, "\033-A" , 3, 0, 0, CT_STD },
- { XlcGL, 1, "JISX0201.1976-0:GL", 0, "\033(J" , 3, 0, 0, CT_STD },
- { XlcGR, 1, "JISX0201.1976-0:GR", 0, "\033)I" , 3, 0, 0, CT_STD },
- { XlcGL, 2, "JISX0208.1983-0:GL", 0, "\033$(B" , 4, 0, 0, CT_STD },
- { XlcGR, 2, "JISX0208.1983-0:GR", 0, "\033$)B" , 4, 0, 0, CT_STD },
- { XlcGL, 2, "JISX0212.1990-0:GL", 0, "\033$(D" , 4, 0, 0, CT_STD },
- { XlcGR, 2, "JISX0212.1990-0:GR", 0, "\033$)D" , 4, 0, 0, CT_STD },
- { XlcUnknown, 0, "Ignore-Ext-Status?", 0, "\033#" , 2, 0, 0, CT_VER },
- { XlcUnknown, 0, "NonStd-?-OctetChar", 0, "\033%/0" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 1, "NonStd-1-OctetChar", 0, "\033%/1" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 2, "NonStd-2-OctetChar", 0, "\033%/2" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 3, "NonStd-3-OctetChar", 0, "\033%/3" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 4, "NonStd-4-OctetChar", 0, "\033%/4" , 4, 0, 0, CT_NSTD },
- { XlcUnknown, 0, "Extension-2" , 0, "\033%/" , 3, 0, 0, CT_EXT2 },
- { XlcUnknown, 0, "Extension-0" , 0, "\033" , 1, 0, 0, CT_EXT0 },
- { XlcUnknown, 0, "Begin-L-to-R-Text", 0, "\2331]" , 3, 0, 0, CT_DIR },
- { XlcUnknown, 0, "Begin-R-to-L-Text", 0, "\2332]" , 3, 0, 0, CT_DIR },
- { XlcUnknown, 0, "End-Of-String", 0, "\233]" , 2, 0, 0, CT_DIR },
- { XlcUnknown, 0, "Extension-1" , 0, "\233" , 1, 0, 0, CT_EXT1 },
-};
-
-/* Note on above table: sjis_ctstombs() and sjis_ctstowcs() parser depends on
- * certain table entries occuring in decreasing string length--
- * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
- * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
- */
-
-static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
-static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
-
-#define Ascii 0
-#define Kanji 1
-#define Kana 2
-#define Userdef 3
-
-/*
- * initCTptr(): Set ctptr[] to point at ctdata[], indexed by codeset_num.
- */
-static void
-initCTptr(
- XLCd lcd)
-{
- int num_codesets = XLC_GENERIC(lcd, codeset_num);
- int num_charsets;
- int i, j;
- CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
- CodeSet codeset;
- XlcCharSet charset;
- CTData ctdp = ctdata;
-
- ctdptr[Ascii] = &ctdata[0]; /* failsafe */
-
- for (i = 0; i < num_codesets; i++) {
-
- codeset = codesets[i];
- num_charsets = codeset->num_charsets;
-
- for (j = 0; j < num_charsets; j++) {
-
- charset = codeset->charset_list[j];
-
- for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
-
- if (! strcmp(ctdp->name, charset->name)) {
-
- ctdptr[codeset->cs_num] = ctdp;
-
- ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
-
- ctdptr[codeset->cs_num]->set_size =
- charset->set_size;
-
- ctdptr[codeset->cs_num]->min_ch =
- charset->set_size == 94 &&
- (ctdptr[codeset->cs_num]->length > 1 ||
- ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
-
- break;
- }
- }
- }
-}
-
-
-static int
-sjis_mbstocts(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- int ct_len = *to_left;
- int cs_num;
- int clen;
- int unconv_num = 0;
- int num_conv;
- const char *inbufptr = *from;
- char *ctptr = *to;
- XPointer ct_base = ctptr;
-
- StateRec ct_state;
- CTData charset = NULL;
- XLCd lcd = (XLCd) conv->state;
- int codeset_num = XLC_GENERIC(lcd, codeset_num);
-
-/* Initial State: */
-
- ct_state.GL_charset = ctdptr[Ascii];
- ct_state.GR_charset = NULL;
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (;*from_left > 0; (*from_left) -= charset->length) {
-
- if (iskanji(*inbufptr)) {
- if (KANJI_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Kanji;
- charset = ctdptr[Kanji];
- if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
- unconv_num++;
- }
- else if (isuserdef(*inbufptr)) {
- if (USERDEF_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Userdef;
- charset = ctdptr[Userdef];
- if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
- unconv_num++;
- }
- else if (isascii(*inbufptr)) {
- if (ASCII_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Ascii;
- charset = ctdptr[Ascii];
- }
- else if (iskana(*inbufptr)) {
- if (KANA_CODESET >= codeset_num) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
- cs_num = Kana;
- charset = ctdptr[Kana];
- }
- else { /* unknown */
- unconv_num++;
- (*from_left)--;
- continue;
- }
-
- if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
- (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
-
- ct_len -= ctdptr[cs_num]->ct_encoding_len;
- if (ct_len < 0) {
- unconv_num++;
- break;
- }
-
- if (ctptr) {
- strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
- ctptr += ctdptr[cs_num]->ct_encoding_len;
- }
- }
-
- clen = charset->length;
- do {
- *ctptr++ = *inbufptr++;
- } while (--clen);
-
- if (charset->length >= 2) {
- sjis_to_jis((Uchar *)(ctptr-2), (Uchar *)(ctptr-1));
- if (BADCHAR(charset->min_ch, *(ctptr-2)) ||
- BADCHAR(charset->min_ch, *(ctptr-1))) {
- unconv_num++;
- continue;
- }
- }
- else
- if (BADCHAR(charset->min_ch, *(ctptr-1))) {
- unconv_num++;
- continue;
- }
-
- if (charset->side == XlcGR)
- ct_state.GR_charset = charset;
- else if (charset->side == XlcGL)
- ct_state.GL_charset = charset;
-
- if (charset->side == XlcGR) {
- clen = charset->length;
- do {
- (*(Uchar *)(ctptr-clen)) = BIT8ON(*(Uchar *)(ctptr-clen));
- } while (--clen);
- }
- }
-
- *to = (XPointer)ctptr;
-
- if ((num_conv = (int)(ctptr - ct_base)) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-
-}
-
-
-#define byte1 (length == codeset->length - 1)
-#define byte2 (byte1 == 0)
-
-static int
-sjis_wcstocts(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- int ct_len = *to_left;
- const wchar_t *inbufptr = (const wchar_t *) *from;
- char *ctptr = *to;
- XPointer ct_base = ctptr;
- wchar_t wch;
- int length;
- Uchar tmp;
- Uchar t1 = 0;
- int num_conv;
-
- StateRec ct_state;
- XLCd lcd = (XLCd)conv->state;
- CTData charset;
- CodeSet codeset;
- int unconv_num = 0;
- Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
-
-/* Initial State: */
- ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
- ct_state.GR_charset = NULL;
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (; *from_left > 0 ; (*from_left)-- ) {
-
- wch = *inbufptr++;
-
- if (!(codeset = wc_codeset(lcd, wch))) {
- unconv_num++;
- (*from_left)--;
- continue;
- }
-
- charset = ctdptr[codeset->cs_num];
-
- length = codeset->length;
- wch ^= (wchar_t)codeset->wc_encoding;
-
- if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
- (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
-
- ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
- if (ct_len < 0) {
- unconv_num++;
- break;
- }
-
- if (ctptr) {
- strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
- ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
- }
-
- }
-
- if (charset->side == XlcGR)
- ct_state.GR_charset = charset;
- else if (charset->side == XlcGL)
- ct_state.GL_charset = charset;
-
- do {
- length--;
- tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
-
- if (kana) {
- if (BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
- *ctptr++ = (char)BIT8ON(tmp);
- }
-
- else if (byte1 && (kanji || userdef)) {
- t1 = tmp;
- }
-
- else if (byte2 && (kanji || userdef)) {
- if (BADCHAR(charset->min_ch, (char)t1) ||
- BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
-
- *ctptr++ = (char)BIT8OFF(t1);
- *ctptr++ = (char)BIT8OFF(tmp);
- }
-
- else {
- if (BADCHAR(charset->min_ch, (char)tmp)) {
- unconv_num++;
- break;
- }
- *ctptr++ = (char)tmp;
- }
- } while (length);
-
- } /* end for */
-
- *to = (XPointer)ctptr;
-
- if ((num_conv = (int)(ctptr - ct_base)) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-}
-#undef byte1
-#undef byte2
-
-#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
-#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
-
-static int
-sjis_ctstombs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const char *inbufptr = *from;
- XPointer outbufptr = *to;
- const char *inbuf_base;
- XPointer outbuf_base = outbufptr;
- int clen, length;
- int unconv_num = 0;
- int num_conv;
- unsigned int ct_seglen = 0;
- Uchar ct_type;
- CTData ctdp = ctdata; /* default */
- CTData GL_ctdp = ctdp; /* GL ctdp save */
- CTData GR_ctdp = ctdp; /* GR ctdp save */
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length)
- {
- ct_type = CT_STD;
- /* change GL/GR charset */
- if(ctdp->side == XlcGR && isleftside(*inbufptr)){
- /* select GL side */
- ctdp = GL_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
- /* select GR side */
- ctdp = GR_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }
- if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
-
- for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
-
- if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
- {
- inbufptr += ctdp->ct_encoding_len;
- (*from_left) -= ctdp->ct_encoding_len;
- if( ctdp->length ) {
- length = ctdp->length;
- if( *from_left < length ) {
- *to = (XPointer)outbufptr;
- *to_left -= outbufptr - outbuf_base;
- return( unconv_num + *from_left );
- }
- }
- ct_type = ctdp->ct_type;
- if(ctdp->side == XlcGL){
- GL_ctdp = ctdp; /* save GL ctdp */
- }else{
- GR_ctdp = ctdp; /* save GR ctdp */
- }
- break;
- }
- }
- if (ctdp > ctd_endp) /* failed to match CT sequence */
- unconv_num++;
- }
-
-/* The following code insures that non-standard encodings, direction, extension,
- * and version strings are ignored; subject to change in future.
- */
- switch (ct_type) {
- case CT_STD:
- break;
- case CT_EXT2:
- inbufptr++;
- (*from_left)--;
- case CT_NSTD:
- ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
- inbufptr += ct_seglen;
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT0:
- inbuf_base = inbufptr;
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT1:
- inbuf_base = inbufptr;
- SKIP_P(inbufptr);
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- (*from_left) -= ct_seglen;
- continue;
- case CT_DIR:
- continue;
- case CT_VER:
- inbufptr += 2;
- (*from_left) -= 2;
- continue;
- }
-
- if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
- clen = length;
- } else {
- clen = 1;
- *from_left += length - clen;
- }
- do {
- Uchar mask = (length == 2) ? GL : -1;
- *outbufptr++ = *inbufptr++ & mask;
- } while (--clen);
-
- if (length >= 2)
- jis_to_sjis((Uchar *)(outbufptr-2), (Uchar *)(outbufptr-1));
- }
-
- *to = (XPointer)outbufptr;
-
- if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
- (*to_left) -= num_conv;
-
- return unconv_num;
-}
-
-
-static int
-sjis_ctstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XLCd lcd = (XLCd)conv->state;
- Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
- const char *inbufptr = *from;
- const char *inbuf_base;
- wchar_t *outbufptr = (wchar_t *) *to;
- wchar_t *outbuf_base = outbufptr;
- int clen, length;
- int num_conv;
- int unconv_num = 0;
- unsigned int ct_seglen = 0;
- Uchar ct_type = 0;
- int shift_mult;
- wchar_t wc_tmp;
- wchar_t wch;
- Ulong wc_encoding;
- CTData ctdp = ctdata;
- CTData GL_ctdp = ctdp; /* GL ctdp save */
- CTData GR_ctdp = ctdp; /* GR ctdp save */
-
- if (*from_left > *to_left)
- *from_left = *to_left;
-
- for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length )
- {
- ct_type = CT_STD;
- /* change GL/GR charset */
- if(ctdp->side == XlcGR && isleftside(*inbufptr)){
- /* select GL side */
- ctdp = GL_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }else if(ctdp->side == XlcGL && isrightside(*inbufptr)){
- /* select GR side */
- ctdp = GR_ctdp;
- length = ctdp->length;
- ct_type = ctdp->ct_type;
- }
- if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
- for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
-
- if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
- {
- inbufptr += ctdp->ct_encoding_len;
- (*from_left) -= ctdp->ct_encoding_len;
- if( ctdp->length ) {
- length = ctdp->length;
- if( *from_left < length ) {
- *to = (XPointer)outbufptr;
- *to_left -= outbufptr - outbuf_base;
- return( unconv_num + *from_left );
- }
- }
- ct_type = ctdp->ct_type;
- if(ctdp->side == XlcGL){
- GL_ctdp = ctdp; /* save GL ctdp */
- }else{
- GR_ctdp = ctdp; /* save GR ctdp */
- }
- break;
- }
- }
- if (ctdp > ctd_endp) /* failed to match CT sequence */
- unconv_num++;
- }
-
-/* The following block of code insures that non-standard encodings, direction,
- * extension, and version strings are ignored; subject to change in future.
- */
- switch (ct_type) {
- case CT_STD:
- break;
- case CT_EXT2:
- inbufptr++;
- (*from_left)--;
- case CT_NSTD:
- ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
- inbufptr += ct_seglen;
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT0:
- inbuf_base = inbufptr;
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- (*from_left) -= ct_seglen;
- continue;
- case CT_EXT1:
- inbuf_base = inbufptr;
- SKIP_P(inbufptr);
- SKIP_I(inbufptr);
- inbufptr++;
- ct_seglen = (unsigned)(inbufptr - inbuf_base);
- (*from_left) -= ct_seglen;
- continue;
- case CT_DIR:
- continue;
- case CT_VER:
- inbufptr += 2;
- (*from_left) -= 2;
- continue;
- }
-#if !defined(__sony_news) || defined(SVR4)
- if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
- clen = length;
- wc_encoding = ctdp->wc_encoding;
- } else {
- clen = 1;
- *from_left += length - clen;
- wc_encoding = ctdptr[Ascii]->wc_encoding;
- }
- shift_mult = clen - 1;
- wch = (wchar_t)0;
-
- do {
- wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
- wch |= wc_tmp;
- shift_mult--;
- } while (--clen);
- *outbufptr++ = wch | wc_encoding;
-#else
- if( length == 1 )
- *outbufptr++ = (unsigned char)*inbufptr++;
- else if( length == 2 ) {
- unsigned short code;
- code = (*inbufptr << 8) | *(inbufptr+1);
- *outbufptr++ = jis2sjis( code );
- inbufptr += 2;
- }
-#endif
- }
- *to = (XPointer)outbufptr;
-
- if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
- (*to_left) -= num_conv ;
-
- return unconv_num;
-
-}
-#undef BADCHAR
-
-static void
-close_converter(
- XlcConv conv)
-{
- Xfree((char *) conv);
-}
-
-
-static XlcConv
-create_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
- if (conv == NULL)
- return (XlcConv) NULL;
-
- conv->methods = methods;
- conv->state = (XPointer) lcd;
- return conv;
-}
-
-
-enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
- WCSTOCTS, MBSTOCTS, CTSTOMBS, CTSTOWCS };
-
-static XlcConvMethodsRec conv_methods[] = {
- {close_converter, sjis_mbstocs, NULL },
- {close_converter, sjis_wcstocs, NULL },
- {close_converter, sjis_mbtocs, NULL },
- {close_converter, sjis_cstombs, NULL },
- {close_converter, sjis_cstowcs, NULL },
- {close_converter, sjis_mbstowcs, NULL },
- {close_converter, sjis_wcstombs, NULL },
- {close_converter, sjis_wcstocts, NULL },
- {close_converter, sjis_mbstocts, NULL },
- {close_converter, sjis_ctstombs, NULL },
- {close_converter, sjis_ctstowcs, NULL },
-};
-
-
-static XlcConv
-open_mbstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOCS]);
-}
-
-static XlcConv
-open_wcstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOCS]);
-}
-
-static XlcConv
-open_mbtocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBTOCS]);
-}
-
-static XlcConv
-open_cstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CSTOMBS]);
-}
-
-static XlcConv
-open_cstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CSTOWCS]);
-}
-
-static XlcConv
-open_mbstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
-}
-
-static XlcConv
-open_wcstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
-}
-
-static XlcConv
-open_wcstocts(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
-}
-
-static XlcConv
-open_mbstocts(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
-}
-
-static XlcConv
-open_ctstombs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
-}
-
-static XlcConv
-open_ctstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
-}
-
-XLCd
-_XlcSjisLoader(
- const char *name)
-{
- XLCd lcd;
-
- lcd = _XlcCreateLC(name, _XlcGenericMethods);
- if (lcd == NULL)
- return lcd;
-
- if (!XLC_PUBLIC_PART(lcd)->codeset ||
- (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "SJIS"))) {
- _XlcDestroyLC(lcd);
- return (XLCd) NULL;
- }
-
- initCTptr(lcd);
-
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
-
-#ifndef FORCE_INDIRECT_CONVERTER
- _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
- _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
-#endif
-
- _XlcAddUtf8Converters(lcd);
-
- return lcd;
-}
-
-#else
-typedef int dummy;
-#endif /* X_LOCALE */
diff --git a/nx-X11/lib/X11/lcStd.c b/nx-X11/lib/X11/lcStd.c
index 87f6b60b3..9d452bcae 100644
--- a/nx-X11/lib/X11/lcStd.c
+++ b/nx-X11/lib/X11/lcStd.c
@@ -199,13 +199,8 @@ _Xlcwcstombs(
int
_Xmbtowc(
wchar_t *wstr,
-#ifdef ISC
- char const *str,
- size_t len
-#else
char *str,
int len
-#endif
)
{
return _Xlcmbtowc((XLCd) NULL, wstr, str, len);
@@ -213,13 +208,8 @@ _Xmbtowc(
int
_Xmblen(
-#ifdef ISC
- char const *str,
- size_t len
-#else
char *str,
int len
-#endif
)
{
return _Xmbtowc((wchar_t *) NULL, str, len);
diff --git a/nx-X11/lib/X11/lcTxtPr.c b/nx-X11/lib/X11/lcTxtPr.c
index e980f0168..cf25e3d0e 100644
--- a/nx-X11/lib/X11/lcTxtPr.c
+++ b/nx-X11/lib/X11/lcTxtPr.c
@@ -89,7 +89,7 @@ _XTextListToTextProperty(
is_wide_char = True;
buf_len = get_buf_size(is_wide_char, list, count);
- if ((buf = (char *) Xmalloc(buf_len)) == NULL)
+ if ((buf = Xmalloc(buf_len)) == NULL)
return XNoMemory;
switch (style) {
@@ -194,7 +194,7 @@ retry:
done:
if (nitems <= 0)
nitems = 1;
- value = (char *) Xmalloc(nitems);
+ value = Xmalloc(nitems);
if (value == NULL) {
Xfree(buf);
return XNoMemory;
diff --git a/nx-X11/lib/X11/lcUTF8.c b/nx-X11/lib/X11/lcUTF8.c
index 3e934b713..38201573e 100644
--- a/nx-X11/lib/X11/lcUTF8.c
+++ b/nx-X11/lib/X11/lcUTF8.c
@@ -86,7 +86,7 @@ create_conv(
{
XlcConv conv;
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ conv = Xmalloc(sizeof(XlcConvRec));
if (conv == (XlcConv) NULL)
return (XlcConv) NULL;
@@ -100,7 +100,7 @@ static void
close_converter(
XlcConv conv)
{
- Xfree((char *) conv);
+ Xfree(conv);
}
/* Replacement character for invalid multibyte sequence or wide character. */
@@ -498,7 +498,7 @@ create_tocs_conv(
if (charset_num > all_charsets_count-1)
charset_num = all_charsets_count-1;
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)
+ conv = Xmalloc(sizeof(XlcConvRec)
+ (charset_num + 1) * sizeof(Utf8Conv));
if (conv == (XlcConv) NULL)
return (XlcConv) NULL;
@@ -539,7 +539,7 @@ close_tocs_converter(
XlcConv conv)
{
/* conv->state is allocated together with conv, free both at once. */
- Xfree((char *) conv);
+ Xfree(conv);
}
/*
@@ -961,7 +961,7 @@ create_ucstocs_conv(
lazy_init_all_charsets();
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
+ conv = Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
if (conv == (XlcConv) NULL)
return (XlcConv) NULL;
preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
@@ -1015,7 +1015,7 @@ ucstocs1(
XPointer *args,
int num_args)
{
- ucs4_t const *src = (ucs4_t const *) *from;
+ ucs4_t const *src;
unsigned char *dst = (unsigned char *) *to;
int unconv_num = 0;
Utf8Conv *preferred_charsets = (Utf8Conv *) conv->state;
@@ -1027,6 +1027,8 @@ ucstocs1(
if (from == NULL || *from == NULL)
return 0;
+ src = (ucs4_t const *) *from;
+
count = charset_wctocs_exactly(preferred_charsets, &chosen_charset,
&chosen_side, conv, dst, *src, *to_left);
if (count < 1) {
@@ -1731,10 +1733,10 @@ create_tofontcs_conv(
lazy_init_all_charsets();
for (i = 0, num = 0;; i++) {
- sprintf(buf, "fs%d.charset.name", i);
+ snprintf(buf, sizeof(buf), "fs%d.charset.name", i);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1) {
- sprintf(buf, "fs%d.charset", i);
+ snprintf(buf, sizeof(buf), "fs%d.charset", i);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
break;
@@ -1742,17 +1744,17 @@ create_tofontcs_conv(
num += count;
}
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
+ conv = Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
if (conv == (XlcConv) NULL)
return (XlcConv) NULL;
preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
/* Loop through all fontsets mentioned in the locale. */
for (i = 0, num = 0;; i++) {
- sprintf(buf, "fs%d.charset.name", i);
+ snprintf(buf, sizeof(buf), "fs%d.charset.name", i);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1) {
- sprintf(buf, "fs%d.charset", i);
+ snprintf(buf, sizeof(buf), "fs%d.charset", i);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
break;
diff --git a/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
index 1caa28a21..993979aeb 100644
--- a/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
+++ b/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
@@ -65,7 +65,7 @@ int main (int argc, char *argv[])
if (argc > 3) {
filename = argv[3];
} else {
- char* s = (char*) malloc(strlen(c_charsetname)+strlen(".h")+1);
+ char* s = malloc(strlen(c_charsetname)+strlen(".h")+1);
strcpy(s,c_charsetname); strcat(s,".h");
filename = s;
}
@@ -361,11 +361,11 @@ int main (int argc, char *argv[])
if (tables[t].usecount > 1) {
char* s;
if (p == tables[t].minline >> 5) {
- s = (char*) malloc(5+1);
+ s = malloc(5+1);
sprintf(s, "%02x_%d", p, ++i);
} else {
p = tables[t].minline >> 5;
- s = (char*) malloc(2+1);
+ s = malloc(2+1);
sprintf(s, "%02x", p);
}
tables[t].suffix = s;
diff --git a/nx-X11/lib/X11/lcUniConv/big5hkscs.h b/nx-X11/lib/X11/lcUniConv/big5hkscs.h
index 29eab938f..721d1228e 100644
--- a/nx-X11/lib/X11/lcUniConv/big5hkscs.h
+++ b/nx-X11/lib/X11/lcUniConv/big5hkscs.h
@@ -6249,3 +6249,4 @@ big5hkscs_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
}
return RET_TOOSMALL;
}
+
diff --git a/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
index 6934789cf..f70fe5e11 100644
--- a/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
+++ b/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
@@ -70,9 +70,9 @@ static void read_table (Encoding* enc)
{
int row, col, i, i1, i2, c, j;
- enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*));
+ enc->charset2uni = malloc(enc->rows*sizeof(int*));
for (row = 0; row < enc->rows; row++)
- enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int));
+ enc->charset2uni[row] = malloc(enc->cols*sizeof(int));
for (row = 0; row < enc->rows; row++)
for (col = 0; col < enc->cols; col++)
@@ -136,7 +136,7 @@ static void find_charset2uni_pages (Encoding* enc)
{
int row, col;
- enc->charsetpage = (int*) malloc((enc->rows+1)*sizeof(int));
+ enc->charsetpage = malloc((enc->rows+1)*sizeof(int));
for (row = 0; row <= enc->rows; row++)
enc->charsetpage[row] = 0;
@@ -157,7 +157,7 @@ static void find_charset2uni_blocks (Encoding* enc)
{
int n, row, lastrow;
- enc->charsetblocks = (Block*) malloc(enc->rows*sizeof(Block));
+ enc->charsetblocks = malloc(enc->rows*sizeof(Block));
n = 0;
for (row = 0; row < enc->rows; row++)
@@ -266,7 +266,7 @@ static void invert (Encoding* enc)
{
int row, col, j;
- enc->uni2charset = (int*) malloc(0x10000*sizeof(int));
+ enc->uni2charset = malloc(0x10000*sizeof(int));
for (j = 0; j < 0x10000; j++)
enc->uni2charset[j] = 0;
@@ -764,9 +764,9 @@ static void read_table_ksc5601 (Encoding* enc)
{
int row, col, i, i1, i2, c, j;
- enc->charset2uni = (int**) malloc(enc->rows*sizeof(int*));
+ enc->charset2uni = malloc(enc->rows*sizeof(int*));
for (row = 0; row < enc->rows; row++)
- enc->charset2uni[row] = (int*) malloc(enc->cols*sizeof(int));
+ enc->charset2uni[row] = malloc(enc->cols*sizeof(int));
for (row = 0; row < enc->rows; row++)
for (col = 0; col < enc->cols; col++)
diff --git a/nx-X11/lib/X11/lcWrap.c b/nx-X11/lib/X11/lcWrap.c
index 47581f8f8..067c501ba 100644
--- a/nx-X11/lib/X11/lcWrap.c
+++ b/nx-X11/lib/X11/lcWrap.c
@@ -77,20 +77,19 @@ XSetLocaleModifiers(
{
XLCd lcd = _XlcCurrentLC();
char *user_mods;
+ char *mapped_mods;
if (!lcd)
return (char *) NULL;
if (!modifiers)
return lcd->core->modifiers;
user_mods = getenv("XMODIFIERS");
- modifiers = (*lcd->methods->map_modifiers) (lcd,
- user_mods, (char *)modifiers);
- if (modifiers) {
- if (lcd->core->modifiers)
- Xfree(lcd->core->modifiers);
- lcd->core->modifiers = (char *)modifiers;
+ mapped_mods = (*lcd->methods->map_modifiers) (lcd, user_mods, modifiers);
+ if (mapped_mods) {
+ Xfree(lcd->core->modifiers);
+ lcd->core->modifiers = mapped_mods;
}
- return (char *)modifiers;
+ return mapped_mods;
}
Bool
@@ -218,7 +217,7 @@ _XlcAddLoader(
_XlcRemoveLoader(proc); /* remove old loader, if exist */
- loader = (XlcLoaderList) Xmalloc(sizeof(XlcLoaderListRec));
+ loader = Xmalloc(sizeof(XlcLoaderListRec));
if (loader == NULL)
return False;
@@ -293,7 +292,7 @@ _XOpenLC(
for (loader = loader_list; loader; loader = loader->next) {
lcd = (*loader->proc)(name);
if (lcd) {
- cur = (XLCdList) Xmalloc (sizeof(XLCdListRec));
+ cur = Xmalloc (sizeof(XLCdListRec));
if (cur) {
cur->lcd = lcd;
cur->ref_count = 1;
@@ -565,7 +564,7 @@ _XlcVaToArgList(
{
XlcArgList args;
- *args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count);
+ *args_ret = args = Xmalloc(sizeof(XlcArg) * count);
if (args == (XlcArgList) NULL)
return;
diff --git a/nx-X11/lib/X11/locking.c b/nx-X11/lib/X11/locking.c
index 4f9a40fbd..9f4fe0677 100644
--- a/nx-X11/lib/X11/locking.c
+++ b/nx-X11/lib/X11/locking.c
@@ -82,7 +82,7 @@ _Xthread_waiter(void)
struct _xthread_waiter *me;
if (!(me = TlsGetValue(_X_TlsIndex))) {
- me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter));
+ me = xmalloc(sizeof(struct _xthread_waiter));
me->sem = CreateSemaphore(NULL, 0, 1, NULL);
me->next = NULL;
TlsSetValue(_X_TlsIndex, me);
@@ -249,7 +249,7 @@ static struct _XCVList *_XCreateCVL(
dpy->lock->free_cvls = cvl->next;
dpy->lock->num_free_cvls--;
} else {
- cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList));
+ cvl = Xmalloc(sizeof(struct _XCVList));
if (!cvl)
return NULL;
cvl->cv = xcondition_malloc();
@@ -312,8 +312,8 @@ static void _XPopReader(
dpy->lock->num_free_cvls++;
} else {
xcondition_clear(front->cv);
- Xfree((char *)front->cv);
- Xfree((char *)front);
+ Xfree(front->cv);
+ Xfree(front);
}
}
@@ -419,14 +419,14 @@ static void _XFreeDisplayLock(
while ((cvl = dpy->lock->free_cvls)) {
dpy->lock->free_cvls = cvl->next;
xcondition_clear(cvl->cv);
- Xfree((char *)cvl->cv);
- Xfree((char *)cvl);
+ Xfree(cvl->cv);
+ Xfree(cvl);
}
- Xfree((char *)dpy->lock);
+ Xfree(dpy->lock);
dpy->lock = NULL;
}
if (dpy->lock_fns != NULL) {
- Xfree((char *)dpy->lock_fns);
+ Xfree(dpy->lock_fns);
dpy->lock_fns = NULL;
}
}
@@ -486,6 +486,8 @@ static void _XInternalLockDisplay(
static void _XUserLockDisplay(
register Display* dpy)
{
+ _XDisplayLockWait(dpy);
+
if (++dpy->lock->locking_level == 1) {
dpy->lock->lock_wait = _XDisplayLockWait;
dpy->lock->locking_thread = xthread_self();
@@ -510,10 +512,10 @@ void _XUserUnlockDisplay(
static int _XInitDisplayLock(
Display *dpy)
{
- dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs));
+ dpy->lock_fns = Xmalloc(sizeof(struct _XLockPtrs));
if (dpy->lock_fns == NULL)
return -1;
- dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo));
+ dpy->lock = Xmalloc(sizeof(struct _XLockInfo));
if (dpy->lock == NULL) {
_XFreeDisplayLock(dpy);
return -1;
diff --git a/nx-X11/lib/X11/locking.h b/nx-X11/lib/X11/locking.h
index 7126e61d8..277c9afc8 100644
--- a/nx-X11/lib/X11/locking.h
+++ b/nx-X11/lib/X11/locking.h
@@ -1,4 +1,4 @@
-/*
+/*
Copyright 1992, 1998 The Open Group
@@ -36,6 +36,8 @@ in this Software without prior written authorization from The Open Group.
#define xmalloc(s) Xmalloc(s)
#define xfree(s) Xfree(s)
+#include <nx-X11/Xlib.h>
+#include <nx-X11/Xlibint.h>
#include <nx-X11/Xthreads.h>
struct _XCVList {
diff --git a/nx-X11/lib/X11/mbWMProps.c b/nx-X11/lib/X11/mbWMProps.c
index 123d379fc..9fb57faca 100644
--- a/nx-X11/lib/X11/mbWMProps.c
+++ b/nx-X11/lib/X11/mbWMProps.c
@@ -61,9 +61,9 @@ XmbSetWMProperties (
XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
sizeHints, wmHints, classHints);
if (wprop)
- Xfree((char *)wname.value);
+ Xfree(wname.value);
if (iprop)
- Xfree((char *)iname.value);
+ Xfree(iname.value);
/* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
}
diff --git a/nx-X11/lib/X11/mbWrap.c b/nx-X11/lib/X11/mbWrap.c
index 19f01f656..766b8da01 100644
--- a/nx-X11/lib/X11/mbWrap.c
+++ b/nx-X11/lib/X11/mbWrap.c
@@ -101,7 +101,7 @@ XmbDrawString(
int text_len)
{
(void)(*font_set->methods->mb_draw_string) (dpy, d, font_set, gc, x, y,
- (char *)text, text_len);
+ text, text_len);
}
@@ -117,7 +117,7 @@ XmbDrawImageString(
int text_len)
{
(*font_set->methods->mb_draw_image_string) (dpy, d, font_set, gc, x, y,
- (char *)text, text_len);
+ text, text_len);
}
int
@@ -126,8 +126,7 @@ XmbTextEscapement(
_Xconst char *text,
int text_len)
{
- return (*font_set->methods->mb_escapement) (font_set,
- (char *)text, text_len);
+ return (*font_set->methods->mb_escapement) (font_set, text, text_len);
}
int
@@ -138,8 +137,7 @@ XmbTextExtents(
XRectangle *overall_ink_extents,
XRectangle *overall_logical_extents)
{
- return (*font_set->methods->mb_extents) (font_set,
- (char *)text, text_len,
+ return (*font_set->methods->mb_extents) (font_set, text, text_len,
overall_ink_extents,
overall_logical_extents);
}
@@ -157,7 +155,7 @@ XmbTextPerCharExtents(
XRectangle *max_logical_extents)
{
return (*font_set->methods->mb_extents_per_char)
- (font_set, (char *)text, text_len,
+ (font_set, text, text_len,
ink_extents_buffer, logical_extents_buffer,
buffer_size, num_chars, max_ink_extents, max_logical_extents);
}
diff --git a/nx-X11/lib/X11/omGeneric.c b/nx-X11/lib/X11/omGeneric.c
index 32a066a75..68eec01c0 100644
--- a/nx-X11/lib/X11/omGeneric.c
+++ b/nx-X11/lib/X11/omGeneric.c
@@ -65,32 +65,6 @@
#define CHARSET_ENCODING_FIELD 14
#define XLFD_MAX_LEN 255
-#if 0
-extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement(),
- _Xutf8DefaultTextEscapement();
-extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents(),
- _Xutf8DefaultTextExtents();
-extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents(),
- _Xutf8DefaultTextPerCharExtents();
-extern int _XmbDefaultDrawString(), _XwcDefaultDrawString(),
- _Xutf8DefaultDrawString();
-extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString(),
- _Xutf8DefaultDrawImageString();
-
-extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement(),
- _Xutf8GenericTextEscapement();
-extern int _XmbGenericTextExtents(), _XwcGenericTextExtents(),
- _Xutf8GenericTextExtents();
-extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents(),
- _Xutf8GenericTextPerCharExtents();
-extern int _XmbGenericDrawString(), _XwcGenericDrawString(),
- _Xutf8GenericDrawString();
-extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString(),
- _Xutf8GenericDrawImageString();
-
-extern void _XlcDbg_printValue (const char *str, char **value, int num);
-#endif
-
/* For VW/UDC start */
static FontData
@@ -101,11 +75,10 @@ init_fontdata(
FontData fd;
int i;
- fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count);
+ fd = Xcalloc(font_data_count, sizeof(FontDataRec));
if(fd == (FontData) NULL)
return False;
- memset(fd, 0x00, sizeof(FontData) * font_data_count);
for(i = 0 ; i < font_data_count ; i++)
fd[i] = font_data[i];
@@ -126,11 +99,10 @@ init_vrotate(
if(type == VROTATE_NONE)
return (VRotate)NULL;
- vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count);
+ vrotate = Xcalloc(font_data_count, sizeof(VRotateRec));
if(vrotate == (VRotate) NULL)
return False;
- memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count);
for(i = 0 ; i < font_data_count ; i++) {
vrotate[i].charset_name = font_data[i].name;
vrotate[i].side = font_data[i].side;
@@ -155,10 +127,9 @@ init_fontset(
count = XOM_GENERIC(oc->core.om)->data_num;
data = XOM_GENERIC(oc->core.om)->data;
- font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count);
+ font_set = Xcalloc(count, sizeof(FontSetRec));
if (font_set == NULL)
return False;
- memset((char *) font_set, 0x00, sizeof(FontSetRec) * count);
gen = XOC_GENERIC(oc);
gen->font_set_num = count;
@@ -196,16 +167,12 @@ init_fontset(
return True;
err:
- if(font_set->font_data)
- Xfree(font_set->font_data);
- if(font_set->substitute)
- Xfree(font_set->substitute);
- if(font_set->vmap)
- Xfree(font_set->vmap);
- if(font_set->vrotate)
- Xfree(font_set->vrotate);
- if(font_set)
- Xfree(font_set);
+
+ Xfree(font_set->font_data);
+ Xfree(font_set->substitute);
+ Xfree(font_set->vmap);
+ Xfree(font_set->vrotate);
+ Xfree(font_set);
gen->font_set = (FontSet) NULL;
gen->font_set_num = 0;
return False;
@@ -463,15 +430,15 @@ init_core_part(
if (count == 0)
return False;
- font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count);
+ font_struct_list = Xmalloc(sizeof(XFontStruct *) * count);
if (font_struct_list == NULL)
return False;
- font_name_list = (char **) Xmalloc(sizeof(char *) * count);
+ font_name_list = Xmalloc(sizeof(char *) * count);
if (font_name_list == NULL)
goto err;
- font_name_buf = (char *) Xmalloc(length);
+ font_name_buf = Xmalloc(length);
if (font_name_buf == NULL)
goto err;
@@ -504,8 +471,8 @@ init_core_part(
return True;
err:
- if (font_name_list)
- Xfree(font_name_list);
+
+ Xfree(font_name_list);
Xfree(font_struct_list);
return False;
@@ -523,9 +490,7 @@ get_font_name(
if (list == NULL)
return NULL;
- name = (char *) Xmalloc(strlen(*list) + 1);
- if (name)
- strcpy(name, *list);
+ name = strdup(*list);
XFreeFontNames(list);
@@ -549,10 +514,9 @@ get_rotate_fontname(
|| len > XLFD_MAX_LEN)
return NULL;
- pattern = (char *)Xmalloc(len + 1);
+ pattern = strdup(font_name);
if(!pattern)
return NULL;
- strcpy(pattern, font_name);
memset(fields, 0, sizeof(char *) * 14);
ptr = pattern;
@@ -575,7 +539,7 @@ get_rotate_fontname(
}
if(field_num < CHARSET_ENCODING_FIELD)
- return NULL;
+ goto free_pattern;
/* Pixel Size field : fields[6] */
for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) {
@@ -584,13 +548,12 @@ get_rotate_fontname(
strcpy(pattern, font_name);
return(pattern);
}
- if(pattern)
- Xfree(pattern);
- return NULL;
+ goto free_pattern;
}
}
pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]);
- sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
+ snprintf(str_pixel, sizeof(str_pixel),
+ "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
fields[6] = str_pixel;
/* Point Size field : fields[7] */
@@ -605,11 +568,11 @@ get_rotate_fontname(
/* Max XLFD length is 255 */
if (len > XLFD_MAX_LEN)
- return NULL;
+ goto free_pattern;
- rotate_font_ptr = (char *)Xmalloc(len + 1);
+ rotate_font_ptr = Xmalloc(len + 1);
if(!rotate_font_ptr)
- return NULL;
+ goto free_pattern;
rotate_font_ptr[0] = '\0';
@@ -619,8 +582,8 @@ get_rotate_fontname(
strcat(rotate_font_ptr, fields[field_num]);
}
- if(pattern)
- Xfree(pattern);
+free_pattern:
+ Xfree(pattern);
return rotate_font_ptr;
}
@@ -646,36 +609,6 @@ is_match_charset(
return False;
}
-#if 0
-static char *
-get_font_name_from_list(
- XOC oc,
- char *pattern,
- FontData font_data)
-{
- char **list, *name = (char *)NULL, *fname;
- int count = 0, i;
-
- list = XListFonts(oc->core.om->core.display, pattern, MAXFONTS, &count);
- if (list == NULL)
- return NULL;
-
- for (i = 0; i < count; i++) {
- fname = list[i];
- if(is_match_charset(font_data, fname) == True) {
- name = (char *) Xmalloc(strlen(fname) + 1);
- if (name)
- strcpy(name, fname);
- break;
- }
- }
-
- XFreeFontNames(list);
-
- return name;
-}
-#endif
-
static int
parse_all_name(
XOC oc,
@@ -687,11 +620,10 @@ parse_all_name(
if(is_match_charset(font_data, pattern) != True)
return False;
- font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ font_data->xlfd_name = strdup(pattern);
if(font_data->xlfd_name == NULL)
return (-1);
- strcpy(font_data->xlfd_name, pattern);
return True;
#else /* OLDCODE */
Display *dpy = oc->core.om->core.display;
@@ -725,11 +657,10 @@ parse_all_name(
}
}
- font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ font_data->xlfd_name = strdup(pattern);
if(font_data->xlfd_name == NULL)
return (-1);
- strcpy(font_data->xlfd_name, pattern);
return True;
#endif /* OLDCODE */
}
@@ -841,7 +772,7 @@ parse_omit_name(
return True;
/* This may mot be needed anymore as XListFonts() takes care of this */
- while (num_fields < 12) {
+ if (num_fields < 12) {
if ((last - buf) > (XLFD_MAX_LEN - 2))
return -1;
*last = '*';
@@ -948,12 +879,9 @@ parse_fontdata(
* -- jjw/pma (HP)
*/
if (font_data_return) {
- font_data_return->xlfd_name = (char *)Xmalloc
- (strlen(font_data->xlfd_name) + 1);
+ font_data_return->xlfd_name = strdup(font_data->xlfd_name);
if (!font_data_return->xlfd_name) return -1;
- strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
-
font_data_return->side = font_data->side;
}
#ifdef FONTDEBUG
@@ -998,11 +926,9 @@ parse_fontdata(
#ifdef FONTDEBUG
fprintf(stderr,"XLFD name: %s\n",font_data->xlfd_name);
#endif
- font_data_return->xlfd_name = (char *)Xmalloc
- (strlen(font_data->xlfd_name) + 1);
+ font_data_return->xlfd_name = strdup(font_data->xlfd_name);
if (!font_data_return->xlfd_name) return -1;
- strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
font_data_return->side = font_data->side;
}
@@ -1111,11 +1037,10 @@ parse_vw(
Xfree(vrotate);
if(sub_num > 0) {
- vrotate = font_set->vrotate = (VRotate)Xmalloc
- (sizeof(VRotateRec) * sub_num);
+ vrotate = font_set->vrotate = Xcalloc(sub_num,
+ sizeof(VRotateRec));
if(font_set->vrotate == (VRotate)NULL)
return (-1);
- memset(font_set->vrotate, 0x00, sizeof(VRotateRec) * sub_num);
for(i = 0 ; i < sub_num ; i++) {
vrotate[i].charset_name = font_set->substitute[i].name;
@@ -1177,7 +1102,7 @@ parse_fontname(
* a "missing_charset" will be reported to the client
* for this CharSet.
*/
- font_data_return. xlfd_name = NULL;
+ font_data_return.xlfd_name = NULL;
font_data_return.side = XlcUnknown;
ret = parse_fontdata(oc, font_set, font_set->font_data,
@@ -1194,11 +1119,10 @@ parse_fontname(
* be matched. It returns the required information in
* font_data_return.
*/
- font_set->font_name = (char *)Xmalloc
- (strlen(font_data_return.xlfd_name) + 1);
+ font_set->font_name = strdup(font_data_return.xlfd_name);
if(font_set->font_name == (char *) NULL)
goto err;
- strcpy(font_set->font_name, font_data_return.xlfd_name);
+
font_set->side = font_data_return.side;
Xfree (font_data_return.xlfd_name);
@@ -1225,11 +1149,10 @@ parse_fontname(
break;
}
}
- font_set->font_name = (char *)Xmalloc
- (strlen(font_set->substitute[i].xlfd_name) + 1);
+ font_set->font_name = strdup(font_set->substitute[i].xlfd_name);
if(font_set->font_name == (char *) NULL)
goto err;
- strcpy(font_set->font_name,font_set->substitute[i].xlfd_name);
+
font_set->side = font_set->substitute[i].side;
if(parse_vw(oc, font_set, name_list, count) == -1)
goto err;
@@ -1239,11 +1162,10 @@ parse_fontname(
}
}
- base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ base_name = strdup(oc->core.base_name_list);
if (base_name == NULL)
goto err;
- strcpy(base_name, oc->core.base_name_list);
oc->core.base_name_list = base_name;
XFreeStringList(name_list);
@@ -1304,12 +1226,12 @@ set_missing_list(
return True;
}
- charset_list = (char **) Xmalloc(sizeof(char *) * count);
+ charset_list = Xmalloc(sizeof(char *) * count);
if (charset_list == NULL) {
return False;
}
- charset_buf = (char *) Xmalloc(length);
+ charset_buf = Xmalloc(length);
if (charset_buf == NULL) {
Xfree(charset_list);
return False;
@@ -1502,24 +1424,15 @@ destroy_oc(
*/
/* For VW/UDC end */
- if (oc->core.base_name_list)
- Xfree(oc->core.base_name_list);
-
- if (oc->core.font_info.font_name_list)
- XFreeStringList(oc->core.font_info.font_name_list);
-
- if (oc->core.font_info.font_struct_list) {
- Xfree(oc->core.font_info.font_struct_list);
- }
-
- if (oc->core.missing_list.charset_list)
- XFreeStringList(oc->core.missing_list.charset_list);
+ Xfree(oc->core.base_name_list);
+ XFreeStringList(oc->core.font_info.font_name_list);
+ Xfree(oc->core.font_info.font_struct_list);
+ XFreeStringList(oc->core.missing_list.charset_list);
#ifdef notdef
- if (oc->core.res_name)
- Xfree(oc->core.res_name);
- if (oc->core.res_class)
- Xfree(oc->core.res_class);
+
+ Xfree(oc->core.res_name);
+ Xfree(oc->core.res_class);
#endif
Xfree(oc);
@@ -1656,10 +1569,9 @@ create_oc(
XOCMethodsList methods_list = oc_methods_list;
int count;
- oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ oc = Xcalloc(1, sizeof(XOCGenericRec));
if (oc == NULL)
return (XOC) NULL;
- bzero((char *) oc, sizeof(XOCGenericRec));
oc->core.om = om;
@@ -1844,26 +1756,23 @@ create_om(
{
XOM om;
- om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ om = Xcalloc(1, sizeof(XOMGenericRec));
if (om == NULL)
return (XOM) NULL;
- bzero((char *) om, sizeof(XOMGenericRec));
om->methods = &methods;
om->core.lcd = lcd;
om->core.display = dpy;
om->core.rdb = rdb;
if (res_name) {
- om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1);
+ om->core.res_name = strdup(res_name);
if (om->core.res_name == NULL)
goto err;
- strcpy(om->core.res_name, res_name);
}
if (res_class) {
- om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1);
+ om->core.res_class = strdup(res_class);
if (om->core.res_class == NULL)
goto err;
- strcpy(om->core.res_class, res_class);
}
if (om_resources[0].xrm_name == NULLQUARK)
@@ -1889,9 +1798,9 @@ add_data(
int num;
if ((num = gen->data_num))
- new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec));
+ new = Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec));
else
- new = (OMData) Xmalloc(sizeof(OMDataRec));
+ new = Xmalloc(sizeof(OMDataRec));
if (new == NULL)
return NULL;
@@ -1914,14 +1823,13 @@ read_EncodingInfo(
{
FontData font_data,ret;
char *buf, *bufptr,*scp;
- int len;
- font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ int len, i;
+ font_data = Xcalloc(count, sizeof(FontDataRec));
if (font_data == NULL)
return NULL;
- bzero((char *) font_data, sizeof(FontDataRec) * count);
ret = font_data;
- for ( ; count-- > 0; font_data++) {
+ for (i = 0; i < count; i++, font_data++) {
/*
strcpy(buf, *value++);
*/
@@ -1931,9 +1839,12 @@ read_EncodingInfo(
bufptr++ ;
} else
len = strlen(buf);
- font_data->name = (char *) Xmalloc(len + 1);
- if (font_data->name == NULL)
+ font_data->name = Xmalloc(len + 1);
+ if (font_data->name == NULL) {
+ free_fontdataOM(ret, i + 1);
+ Xfree(ret);
return NULL;
+ }
strncpy(font_data->name, buf,len);
font_data->name[len] = 0;
if (bufptr && _XlcCompareISOLatin1(bufptr, "GL") == 0)
@@ -1980,7 +1891,7 @@ static void read_vw(
char **value, buf[BUFSIZ];
int count;
- sprintf(buf, "fs%d.font.vertical_map", num);
+ snprintf(buf, sizeof(buf), "fs%d.font.vertical_map", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
_XlcDbg_printValue(buf,value,count);
@@ -1988,7 +1899,7 @@ static void read_vw(
font_set->vmap = read_EncodingInfo(count,value);
}
- sprintf(buf, "fs%d.font.vertical_rotate", num);
+ snprintf(buf, sizeof(buf), "fs%d.font.vertical_rotate", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
_XlcDbg_printValue(buf,value,count);
@@ -2017,19 +1928,18 @@ init_om(
_XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count);
if (count > 0) {
- gen->object_name = (char *) Xmalloc(strlen(*value) + 1);
+ gen->object_name = strdup(*value);
if (gen->object_name == NULL)
return False;
- strcpy(gen->object_name, *value);
}
for (num = 0; ; num++) {
- sprintf(buf, "fs%d.charset.name", num);
+ snprintf(buf, sizeof(buf), "fs%d.charset.name", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if( count < 1){
- sprintf(buf, "fs%d.charset", num);
+ snprintf(buf, sizeof(buf), "fs%d.charset", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
break;
@@ -2039,7 +1949,7 @@ init_om(
if (data == NULL)
return False;
- charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count);
+ charset_list = Xmalloc(sizeof(XlcCharSet) * count);
if (charset_list == NULL)
return False;
data->charset_list = charset_list;
@@ -2048,12 +1958,12 @@ init_om(
while (count-- > 0){
*charset_list++ = _XlcGetCharSet(*value++);
}
- sprintf(buf, "fs%d.charset.udc_area", num);
+ snprintf(buf, sizeof(buf), "fs%d.charset.udc_area", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if( count > 0){
UDCArea udc;
int i,flag = 0;
- udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec));
+ udc = Xmalloc(count * sizeof(UDCAreaRec));
if (udc == NULL)
return False;
for(i=0;i<count;i++){
@@ -2072,10 +1982,10 @@ init_om(
}
}
- sprintf(buf, "fs%d.font.primary", num);
+ snprintf(buf, sizeof(buf), "fs%d.font.primary", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1){
- sprintf(buf, "fs%d.font", num);
+ snprintf(buf, sizeof(buf), "fs%d.font", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1)
return False;
@@ -2088,7 +1998,7 @@ init_om(
data->font_data = font_data;
data->font_data_count = count;
- sprintf(buf, "fs%d.font.substitute", num);
+ snprintf(buf, sizeof(buf), "fs%d.font.substitute", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count > 0){
font_data = read_EncodingInfo(count,value);
@@ -2097,7 +2007,7 @@ init_om(
data->substitute = font_data;
data->substitute_num = count;
} else {
- sprintf(buf, "fs%d.font", num);
+ snprintf(buf, sizeof(buf), "fs%d.font", num);
_XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
if (count < 1) {
data->substitute = NULL;
@@ -2113,30 +2023,32 @@ init_om(
}
/* required charset list */
- required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num);
+ required_list = Xmalloc(sizeof(char *) * gen->data_num);
if (required_list == NULL)
return False;
- bufptr = (char *) Xmalloc(length);
- if (bufptr == NULL) {
- Xfree(required_list);
- return False;
- }
-
om->core.required_charset.charset_list = required_list;
om->core.required_charset.charset_count = gen->data_num;
count = gen->data_num;
data = gen->data;
- for ( ; count-- > 0; data++) {
- strcpy(bufptr, data->font_data->name);
- *required_list++ = bufptr;
- bufptr += strlen(bufptr) + 1;
+ if (count > 0) {
+ bufptr = Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ for ( ; count-- > 0; data++) {
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+ }
}
/* orientation list */
- orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2);
+ orientation = Xmalloc(sizeof(XOrientation) * 2);
if (orientation == NULL)
return False;
diff --git a/nx-X11/lib/X11/omImText.c b/nx-X11/lib/X11/omImText.c
index 1bc08bc25..9cfb5497d 100644
--- a/nx-X11/lib/X11/omImText.c
+++ b/nx-X11/lib/X11/omImText.c
@@ -29,10 +29,6 @@
#include "Xlibint.h"
#include "XomGeneric.h"
-#if 0
-extern int _XomGenericTextExtents(), _XomGenericDrawString();
-#endif
-
#define GET_VALUE_MASK (GCFunction | GCForeground | GCBackground | GCFillStyle)
#define SET_VALUE_MASK (GCFunction | GCForeground | GCFillStyle)
diff --git a/nx-X11/lib/X11/omXChar.c b/nx-X11/lib/X11/omXChar.c
index 85d2f15b7..c9bbb8e88 100644
--- a/nx-X11/lib/X11/omXChar.c
+++ b/nx-X11/lib/X11/omXChar.c
@@ -317,7 +317,7 @@ _XomConvert(
XlcCharSet charset;
int length, cs_left, ret;
FontSet font_set;
-
+
cs = *to;
cs_left = *to_left;
lc_args[0] = (XPointer) &charset;
@@ -335,20 +335,18 @@ _XomConvert(
length = *to_left - cs_left;
- {
- if (font_set->side != charset->side) {
- if (font_set->side == XlcGL)
- shift_to_gl(*to, length);
- else if (font_set->side == XlcGR)
- shift_to_gr(*to, length);
- }
-
- if (font_set->is_xchar2b)
- length >>= 1;
- *to = cs;
- *to_left -= length;
+ if (font_set->side != charset->side) {
+ if (font_set->side == XlcGL)
+ shift_to_gl(*to, length);
+ else if (font_set->side == XlcGR)
+ shift_to_gr(*to, length);
}
+ if (font_set->is_xchar2b)
+ length >>= 1;
+ *to = cs;
+ *to_left -= length;
+
*((XFontStruct **) args[0]) = font_set->font;
*((Bool *) args[1]) = font_set->is_xchar2b;
if(num_args >= 3){
diff --git a/nx-X11/lib/X11/os2Stubs.c b/nx-X11/lib/X11/os2Stubs.c
index d01b85b46..5ffc4824c 100644
--- a/nx-X11/lib/X11/os2Stubs.c
+++ b/nx-X11/lib/X11/os2Stubs.c
@@ -3,26 +3,26 @@
* <marineau@genie.uottawa.ca>
* <Holger.Veit@gmd.de>
*
- * 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
+ * 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 or substantial portions of the Software.
- *
+ *
* 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
- * HOLGER VEIT 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
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HOLGER VEIT 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.
- *
- * Except as contained in this notice, the name of Sebastien Marineau or Holger Veit
- * shall not be used in advertising or otherwise to promote the sale, use or other
+ *
+ * Except as contained in this notice, the name of Sebastien Marineau or Holger Veit
+ * shall not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization from Holger Veit or
* Sebastien Marineau.
*
@@ -66,7 +66,7 @@ char *__XOS2RedirRoot(char *fname)
return fname;
root = (char*)getenv("X11ROOT");
- if (root==0 ||
+ if (root==0 ||
(fname[1]==':' && isalpha(fname[0])) ||
(strlen(fname)+strlen(root)+2) > 300)
return fname;
@@ -131,7 +131,7 @@ BOOL any_ready;
int np,ns, i,ready_handles,n;
APIRET rc;
-sd.have_read=FALSE; sd.have_write=FALSE;
+sd.have_read=FALSE; sd.have_write=FALSE;
sd.socket_nread=0; sd.socket_nwrite=0; sd.socket_ntotal=0;
sd.max_fds=31; ready_handles=0; any_ready=FALSE;
sd.pipe_ntotal=0; sd.pipe_have_write=FALSE;
@@ -149,7 +149,7 @@ if(FirstTime){
}
/* Call these a first time to set the semaphore */
rc = DosCreateEventSem(NULL, &hPipeSem, DC_SEM_SHARED, FALSE);
- if(rc) {
+ if(rc) {
fprintf(stderr, "Could not create event semaphore, rc=%d\n",rc);
return(-1);
}
@@ -238,7 +238,7 @@ if(FirstTime){
ready_handles+=np;
any_ready = TRUE;
}
- else if (np == -1) {
+ else if (np == -1) {
return(-1); }
}
@@ -249,7 +249,7 @@ if(FirstTime){
}
else if (ns == -1) {return(-1);}
- if (i%8 == 0) {
+ if (i%8 == 0) {
now_millis = os2_get_sys_millis();
if((now_millis-start_millis) > timeout_ms) timeout_ms = 0;
}
@@ -349,7 +349,7 @@ fd_set *readfds,*writefds;
int j,n;
memcpy(sd->tcp_select_copy,sd->tcp_select_mask,
sd->socket_ntotal*sizeof(int));
-
+
e = os2_tcp_select(sd->tcp_select_copy,sd->socket_nread,
sd->socket_nwrite, 0, 0);
@@ -370,7 +370,7 @@ fd_set *readfds,*writefds;
n ++;
}
errno = 0;
-
+
return n;
}
if(e<0){
@@ -393,7 +393,7 @@ PIPESEMSTATE pipeSemState[128];
APIRET rc;
e = 0;
rc = DosResetEventSem(hPipeSem,&ulPostCount);
- rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
+ rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
sizeof(pipeSemState));
if(rc) fprintf(stderr,"SELECT: rc from QueryNPipeSem: %d\n",rc);
i=0;
diff --git a/nx-X11/lib/X11/pathmax.h b/nx-X11/lib/X11/pathmax.h
index ffec295e0..86e65fadf 100644
--- a/nx-X11/lib/X11/pathmax.h
+++ b/nx-X11/lib/X11/pathmax.h
@@ -79,4 +79,3 @@ SOFTWARE.
#endif
#endif
#endif
-
diff --git a/nx-X11/lib/X11/udcInf.c b/nx-X11/lib/X11/udcInf.c
deleted file mode 100644
index afe398cc7..000000000
--- a/nx-X11/lib/X11/udcInf.c
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
-Copyright 1996, 1998 The Open Group
-
-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.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-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 OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-*/
-/*
- * Copyright 1995 by FUJITSU LIMITED
- * This is source code modified by FUJITSU LIMITED under the Joint
- * Development Agreement for the CDE/Motif PST.
- *
- * Modifier: Takanori Tateno FUJITSU LIMITED
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <locale.h>
-#include <Xlib.h>
-#include <Xlibint.h>
-#include <Xlcint.h>
-#include <XlcPubI.h>
-#include <XlcGeneric.h>
-#include <XomGeneric.h>
-
-/*
- external symbols
-*/
-extern FontData read_EncodingInfo();
-extern int _xudc_get_codeset();
-
-extern int _xudc_utyderror ;
-extern int _xudc_utyerror ;
-
-extern unsigned long _xudc_utyerrno ;
-
-#define _XUDC_ERROR -1
-
-
-/*
- UDC structure define
-*/
-typedef struct __XUDCGlyphRegion {
- unsigned long start;
- unsigned long end;
-} _XUDCGlyphRegion ;
-
-/*
- * "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu.
- */
-static unsigned char getbyte(code,i)
-unsigned long code;
-int i;
-{
- unsigned long byteL;
- unsigned char byte;
- byteL = code >> (8*(3-i));
- byte = (unsigned char)(0x000000ff & byteL);
- return(byte);
-}
-/*
- get codeset which described by charset_str and locale.
- for examples ...
- locale : ja_JP
- charset_str : JISX0208.1983-0
-*/
-
-_xudc_get_codeset(locale,charset_str,codeset,num_codeset)
-char *locale;
-char *charset_str;
-int **codeset;
-int *num_codeset;
-{
- XLCdRec lcdrec;
- XLCd lcd;
- XLCdPublicRec xlcdp;
- XPointer rdb;
- int num = 0,count,num_ret=0,i,*ret;
- char **value,buf[128],*ptr;
-
-
- _xudc_utyderror = 0;
- _xudc_utyerror = 0;
-
- if((locale == NULL) || (charset_str == NULL)){
- _xudc_utyerror = 5;
- _xudc_utyderror = 1;
- _xudc_utyerrno = 0x04 ;
- return(_XUDC_ERROR);
- }
- if(codeset == NULL){
- _xudc_utyerror = 5;
- _xudc_utyderror = 2;
- _xudc_utyerrno = 0x04 ;
- return(_XUDC_ERROR);
- }
-
- /* create XLCd */
- xlcdp.pub.siname = locale;
- lcdrec.core = (XLCdCore)&xlcdp;
- lcd = &lcdrec;
- /* create X RDB (X NLS DB) */
- rdb = _XlcCreateLocaleDataBase(lcd);
- if(rdb == NULL){
- _xudc_utyerror = 1;
- _xudc_utyerrno = 0x15 ;
- return(_XUDC_ERROR);
- }
-
- for(num=0;;num++){
- /* XLC_FONTSET */
- sprintf(buf, "fs%d.font.primary", num);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count < 1){
- break ;
- }
- for(i=0;i<count;i++){
- if (strlen(value[i]) >= sizeof(buf))
- continue;
- strcpy(buf,value[i]);
- ptr = (char *)strchr(buf,(int)':');
- *ptr = 0;
- if(!_XlcCompareISOLatin1(charset_str,buf)){
- num_ret += 1;
- if(num_ret == 1){
- ret = (int *)Xmalloc(sizeof(int));
- } else {
- int *prev_ret = ret;
-
- ret =
- (int *)Xrealloc(ret,num_ret*sizeof(int));
- if (ret == NULL){
- Xfree(prev_ret);
- }
- }
- if(ret == NULL){
- _xudc_utyerrno = 0x03 ;
- return(_XUDC_ERROR);
- }
- ret[num_ret-1]=num;
- break ;
- }
- }
- }
- if(num_ret == 0){
- *num_codeset = 0;
- *codeset = NULL;
- return (0xff);
- }
-
- *num_codeset = num_ret;
- *codeset = ret;
- return 0;
-}
-
-static Bool gi_to_vgi(gi,vgi,scope)
-unsigned long gi,*vgi;
-FontScope scope;
-{
- if(scope->shift_direction == (unsigned long)'+'){
- gi -= scope->shift;
- } else {
- gi += scope->shift;
- }
- if(gi >= scope->start && gi <= scope->end){
- *vgi = gi;
- return(True);
- }
- return(False);
-}
-
-static void shift_area(udc,scope)
-_XUDCGlyphRegion *udc;
-FontScope scope;
-{
- if(scope->shift_direction == (unsigned long)'+'){
- udc->start += scope->shift;
- udc->end += scope->shift;
- } else {
- udc->start -= scope->shift;
- udc->end -= scope->shift;
- }
-}
-
-/*
- get UDC area with glyph index.
- for examples ...
- locale : ja_JP
- charset_str : JISX0208.1983-0
-*/
-_XUDCGetUDCGIArea(locale,codeset,charset_str,gr,num_gr)
-char *locale;
-int codeset;
-char *charset_str;
-_XUDCGlyphRegion **gr;
-int *num_gr;
-{
- XLCdRec lcdrec;
- XLCd lcd;
- XLCdPublicRec xlcdp;
- XPointer rdb;
- _XUDCGlyphRegion *udc;
- int num = 0,count,num_ret=0;
- int i,j,k;
- char **value,buf[128],ptr;
- FontData font_data;
-
-
- _xudc_utyderror = 0;
- _xudc_utyerror = 0;
- _xudc_utyerrno = 0x00 ;
-
- if((locale == NULL) || (charset_str == NULL)){
- _xudc_utyerror = 5;
- _xudc_utyderror = 1;
- _xudc_utyerrno = 0x04;
- _xudc_utyerrno |= (0x0b<<8) ;
- return(_XUDC_ERROR);
- }
- if(gr == NULL){
- _xudc_utyerror = 5;
- _xudc_utyderror = 1;
- _xudc_utyerrno = 0x04;
- _xudc_utyerrno |= (0x0b<<8) ;
- return(_XUDC_ERROR);
- }
- if(num_gr == NULL){
- _xudc_utyerror = 5;
- _xudc_utyderror = 2;
- _xudc_utyerrno = 0x04;
- _xudc_utyerrno |= (0x0b<<8) ;
- return(_XUDC_ERROR);
- }
-
- /* create XLCd */
- xlcdp.pub.siname = locale;
- lcdrec.core = (XLCdCore)&xlcdp;
- lcd = &lcdrec;
- /* create X RDB (X NLS DB) */
- rdb = _XlcCreateLocaleDataBase(lcd);
- if(rdb == NULL){
- _xudc_utyerror = 1;
- _xudc_utyerrno = 0x15 ;
- _xudc_utyerrno |= (0x0b<<8) ;
- return(_XUDC_ERROR);
- }
- udc = NULL;
-
- /* XLC_FONTSET */
- sprintf(buf, "fs%d.charset.udc_area", codeset-1);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- udc = (_XUDCGlyphRegion *)Xmalloc(count * sizeof(_XUDCGlyphRegion));
- if(udc == NULL){
- _xudc_utyerrno = 0x03 ;
- _xudc_utyerrno |= (0x0b<<8) ;
- return(_XUDC_ERROR);
- }
- for(i=0;i<count;i++){
- sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end));
- }
- }
-
- *num_gr = count;
-
- sprintf(buf, "fs%d.font.primary", codeset-1);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- font_data = read_EncodingInfo(count,value);
- for(i=0;i<count;i++){
- if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
- for(j=0;j<(*num_gr);j++){
- for(k=0;k<font_data[i].scopes_num;k++){
- if(udc[j].start == font_data[i].scopes[k].start
- && font_data[i].scopes[k].shift){
- shift_area(&udc[j],&(font_data[i].scopes[k]));
- }
- }
- }
- }
- }
- }
-
- *gr = udc;
- return 0;
-}
-
-/*
- * Code convert wo tomonau UDC area no kakutoku
- * GetUDCCPArea() / glyph_to_code()
- *
- */
-
-static int
-_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,gi,vgi,charsetname,size)
-XLCd lcd;
-char *locale;
-char *charset_str;
-int codeset;
-unsigned long gi;
-unsigned long *vgi;
-char *charsetname;
-int size;
-{
- _XUDCGlyphRegion *udc;
- int num = 0,count,num_ret=0;
- int i,j,k;
- char **value,buf[128],ptr;
- FontData font_data;
-
-
- sprintf(buf, "fs%d.charset.name", codeset-1);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- strcpy(charsetname,value[0]);
- }
- if (count >= size)
- return False;
- sprintf(buf, "fs%d.font.primary", codeset-1);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- font_data = read_EncodingInfo(count,value);
- for(i=0;i<count;i++){
- if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
- for(k=0;k<font_data[i].scopes_num;k++){
- if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
- return(True);
- }
- }
- }
- }
- }
-/*
- free_fontdata(font_data);
-*/
- *vgi = gi;
- return(True);
-}
-
-Bool non_standard(lcd,charset)
-XLCd lcd;
-XlcCharSet charset;
-{
- char buf[256];
- int count,i;
- char **value;
- if(charset->ct_sequence == NULL){
- return(False);
- }
- for(i=0;;i++){
- sprintf(buf, "csd%d.charset_name", i);
- _XlcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count);
- if(count > 0){
- if(!_XlcNCompareISOLatin1(value[0],
- charset->name,strlen(value[0])) ){
- return(True);
- }
- } else {
- return(False);
- }
- }
-}
-
-static Bool
-make_none_standard(from,charset,src,size)
-char *from;
-XlcCharSet charset;
-char *src;
-int size;
-{
- int name_len,seq_len,rest_len,i;
- name_len = 2 + strlen(charset->encoding_name) + 1;
- seq_len = strlen(charset->ct_sequence);
- rest_len = strlen(charset->encoding_name) + 1 + strlen(src);
- if (name_len + seq_len + strlen(src) >= size || rest_len >= 0x4000)
- return False;
- strcpy(from,charset->ct_sequence);
- from[seq_len] = (rest_len >> 7) + 128;
- from[seq_len+1] = (rest_len & 0x7f) + 128;
- strcpy(&from[seq_len + 2],charset->encoding_name);
- from[seq_len+name_len-1] = 0x02; /* STX */
- strcpy(&from[seq_len + name_len],src);
- return True;
-}
-int
-_xudc_glyph_to_code(locale,charset_str,codeset,glyph_index,codepoint)
-char *locale;
-char *charset_str;
-int codeset;
-unsigned long glyph_index;
-unsigned long *codepoint;
-{
- XLCd lcd;
- unsigned char *from; int from_left;
- unsigned char *to ; int to_left = 10;
- unsigned char *dst;
- unsigned char byte;
- unsigned long from32[25];
- unsigned long to32[25];
- int i,j;
- char charsetname[256],src[10];
- XlcConv conv;
- XlcCharSet charset;
- XPointer args[2];
-
- from = (unsigned char *)from32;
- to = (unsigned char *)to32;
- dst = (unsigned char *)to32;
-
- memset(dst,0,25);
-
- lcd = (XLCd)_XlcGenericLoader(locale);
-
- if (!_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,
- glyph_index,&glyph_index,charsetname,sizeof(charsetname)))
- return(_XUDC_ERROR);
-
- for(i=0,j=0;i<4;i++){
- byte = getbyte(glyph_index,i);
- if(byte){
- src[j] = byte;
- j ++;
- }
- }
- src[j] = 0;
-
-
- /* get charset */
-/*
- sprintf(tmp,"%s%s",charset_str,":GL");
- charset_name = strdup(tmp);
-*/
- charset = _XlcGetCharSet(charsetname);
- if(charset == NULL){
- _xudc_utyerrno = 0x16 ;
- return(_XUDC_ERROR);
- }
- /* make ct */
- if( non_standard(lcd,charset)) {
- if (!make_none_standard(from,charset,src,sizeof(from32)))
- return(_XUDC_ERROR);
- } else if(charset->ct_sequence){
- if (strlen(charset->ct_sequence) + strlen(src) >= sizeof(from32))
- return(_XUDC_ERROR);
- sprintf((char *)from,"%s%s",charset->ct_sequence,src);
- } else {
- sprintf((char *)from,"%s\0",src);
- }
- /* compound text -> multi byte */
- conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
- from_left = strlen((char *)from);
- _XlcConvert(conv,(XPointer *)&from,&from_left,
- (XPointer *)&to, &to_left,args,0);
- _XlcCloseConverter(conv);
- _XlcDestroyLC(lcd);
-
- *codepoint = 0;
- for(i=0;dst[i];i++){
- *codepoint = ((*codepoint << 8) | dst[i]) ;
- }
- return(0);
-}
-
-typedef struct __XUDCCodeRegion {
- unsigned long start,end;
-} _XUDCCodeRegion ;
-
-int
-_XUDCGetUDCCPArea(locale,codeset,charset_str,cr,num_cr)
-char *locale;
-int codeset;
-char *charset_str;
-_XUDCCodeRegion **cr;
-int *num_cr;
-{
- int i,num_gr,ret;
- _XUDCGlyphRegion *gr;
- _XUDCCodeRegion *crr;
-
- _xudc_utyerror = 0;
- _xudc_utyderror = 0;
-
- if(cr == NULL){
- _xudc_utyerror = 5;
- _xudc_utyderror = 1;
- _xudc_utyerrno = 0x04 ;
- _xudc_utyerrno |= (0x0a<<8) ;
- return(_XUDC_ERROR);
- }
- if(num_cr == NULL){
- _xudc_utyerror = 5;
- _xudc_utyderror = 2;
- _xudc_utyerrno = 0x04 ;
- _xudc_utyerrno |= (0x0a<<8) ;
- return(_XUDC_ERROR);
- }
-
- ret = _XUDCGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr);
- if(ret == _XUDC_ERROR){
- _xudc_utyerrno &= 0xff ;
- _xudc_utyerrno |= (0x0a<<8) ;
- return(ret);
- }
-
- crr = (_XUDCCodeRegion *)Xmalloc(num_gr*sizeof(_XUDCCodeRegion));
- if(crr == NULL){
- Xfree(gr);
- _xudc_utyerrno = 0x03 ;
- _xudc_utyerrno |= (0x0a<<8) ;
- return(_XUDC_ERROR);
- }
-
- for(i=0;i<num_gr;i++){
- ret = _xudc_glyph_to_code(locale,charset_str,codeset,
- gr[i].start, &(crr[i].start));
- if(ret == _XUDC_ERROR){
- _xudc_utyerrno |= (0x0a<<8) ;
- Xfree(gr);
- Xfree(crr);
- return(ret);
- }
- ret = _xudc_glyph_to_code(locale,charset_str,codeset,
- gr[i].end, &(crr[i].end));
- if(ret == _XUDC_ERROR){
- _xudc_utyerrno |= (0x0a<<8) ;
- Xfree(gr);
- Xfree(crr);
- return(ret);
- }
- }
- Xfree(gr);
- *cr = crr;
- *num_cr = num_gr;
- return(0);
-}
-
-/*
- * code_to_glyph()
- *
- */
-typedef struct __XUDCGIInf {
- char *charset_str;
- unsigned long glyph_index;
-} _XUDCGIInf ;
-
-/*
- *
- *
- */
-static Bool vgi_to_gi(gi,vgi,scope)
-unsigned long *gi,vgi;
-FontScope scope;
-{
- if(vgi >= scope->start && vgi <= scope->end){
- if(scope->shift_direction == (unsigned long)'+'){
- *gi = vgi + scope->shift;
- } else {
- *gi = vgi - scope->shift;
- }
- return(True);
- }
- return(False);
-}
-/*
- *
- *
- */
-static Bool
-_xudc_vgi_to_gi(lcd,locale,vglyph,glyph,charset,charsetname,size)
-XLCd lcd;
-char *locale;
-unsigned long vglyph;
-unsigned long *glyph;
-XlcCharSet charset;
-char *charsetname;
-int size;
-{
- int num = 0,count,num_ret=0;
- int i,j,k;
- char **value,buf[128],ptr;
- FontData font_data;
- CodeSet cs;
-
-
- for(i=0;;i++){
- sprintf(buf, "fs%d.charset.name",i);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- if(!_XlcNCompareISOLatin1(charset->name,value[0],
- strlen(charset->name))){
- break;
- }
- } else {
- _xudc_utyerrno = 0x17 ;
- return(False);
- }
- }
-/*
- sprintf(buf, "fs%d.charset.name", codeset-1);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- strcpy(charsetname,value[0]);
- }
-*/
- sprintf(buf, "fs%d.font.primary", i);
- _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
- if(count > 0){
- font_data = read_EncodingInfo(count,value);
- for(i=0;i<count;i++){
- for(k=0;k<font_data[i].scopes_num;k++){
- if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
- if (strlen(font_data[i].name) >= size)
- return(False);
- strcpy(charsetname,font_data[i].name);
- return(True);
- }
- }
- }
- }
- *glyph = vglyph;
- return(True);
-}
-int
-_xudc_code_to_glyph(locale,codepoint,gi,num_gi)
-char *locale;
-unsigned long codepoint;
-_XUDCGIInf **gi;
-int *num_gi;
-{
- XLCd lcd;
- unsigned char *from; int from_left;
- unsigned char *to ; int to_left = 10;
- unsigned char *dst;
- unsigned char byte;
- unsigned int from32[25];
- unsigned int to32[25];
- int i,j;
- char charsetname[256],src[10];
- XlcConv conv;
- XlcCharSet charset;
- XPointer args[2];
- unsigned long glyph,vglyph;
-
- from = (unsigned char *)from32;
- to = (unsigned char *)to32;
- dst = (unsigned char *)to32;
- memset(dst,0,25);
-
- lcd = (XLCd)_XlcGenericLoader(locale);
-
- for(i=0,j=0;i<4;i++){
- byte = getbyte(codepoint,i);
- if(byte){
- src[j] = byte;
- j ++;
- }
- }
- src[j] = 0;
- sprintf((char *)from,"%s\0",src);
- /* multi byte -> vgi */
- conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
- from_left = strlen((char *)from);
- args[0] = (XPointer) &charset;
- _XlcConvert(conv,(XPointer *)&from,&from_left,
- (XPointer *)&to, &to_left,args,1);
-
- /* vgi -> gi */
- vglyph = 0;
- for(i=0;dst[i];i++){
- vglyph = ((vglyph << 8) | dst[i]) ;
- }
- if(_xudc_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname,
- sizeof(charsetname))==False){
- _XlcCloseConverter(conv);
- _XlcDestroyLC(lcd);
- *num_gi = 0;
- return(0);
- }
-
- _XlcCloseConverter(conv);
- _XlcDestroyLC(lcd);
-
- *gi = (_XUDCGIInf *)Xmalloc(sizeof(_XUDCGIInf));
- (*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
- strcpy((*gi)->charset_str,charsetname);
- (*gi)->glyph_index = glyph;
- if(*gi == NULL){
- _xudc_utyerrno = 0x03 ;
- return(_XUDC_ERROR);
- }
- *num_gi = 1;
- return(0);
-}
-
diff --git a/nx-X11/lib/X11/utf8WMProps.c b/nx-X11/lib/X11/utf8WMProps.c
index 2ac3e390b..09d643377 100644
--- a/nx-X11/lib/X11/utf8WMProps.c
+++ b/nx-X11/lib/X11/utf8WMProps.c
@@ -83,9 +83,9 @@ Xutf8SetWMProperties (
XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
sizeHints, wmHints, classHints);
if (wprop)
- Xfree((char *)wname.value);
+ Xfree(wname.value);
if (iprop)
- Xfree((char *)iname.value);
+ Xfree(iname.value);
/* Note: The WM_LOCALE_NAME property is set by XSetWMProperties. */
}
diff --git a/nx-X11/lib/X11/utf8Wrap.c b/nx-X11/lib/X11/utf8Wrap.c
index 82967b0b1..24cb4494c 100644
--- a/nx-X11/lib/X11/utf8Wrap.c
+++ b/nx-X11/lib/X11/utf8Wrap.c
@@ -123,7 +123,7 @@ Xutf8DrawString(
int text_len)
{
(void)(*font_set->methods->utf8_draw_string) (dpy, d, font_set, gc, x, y,
- (char *)text, text_len);
+ text, text_len);
}
@@ -139,7 +139,7 @@ Xutf8DrawImageString(
int text_len)
{
(*font_set->methods->utf8_draw_image_string) (dpy, d, font_set, gc, x, y,
- (char *)text, text_len);
+ text, text_len);
}
int
@@ -148,8 +148,7 @@ Xutf8TextEscapement(
_Xconst char *text,
int text_len)
{
- return (*font_set->methods->utf8_escapement) (font_set,
- (char *)text, text_len);
+ return (*font_set->methods->utf8_escapement) (font_set, text, text_len);
}
int
@@ -160,8 +159,7 @@ Xutf8TextExtents(
XRectangle *overall_ink_extents,
XRectangle *overall_logical_extents)
{
- return (*font_set->methods->utf8_extents) (font_set,
- (char *)text, text_len,
+ return (*font_set->methods->utf8_extents) (font_set, text, text_len,
overall_ink_extents,
overall_logical_extents);
}
@@ -179,7 +177,7 @@ Xutf8TextPerCharExtents(
XRectangle *max_logical_extents)
{
return (*font_set->methods->utf8_extents_per_char)
- (font_set, (char *)text, text_len,
+ (font_set, text, text_len,
ink_extents_buffer, logical_extents_buffer,
buffer_size, num_chars, max_ink_extents, max_logical_extents);
}
diff --git a/nx-X11/lib/X11/utlist.h b/nx-X11/lib/X11/utlist.h
index 0ce06f2b5..215c2c62e 100644
--- a/nx-X11/lib/X11/utlist.h
+++ b/nx-X11/lib/X11/utlist.h
@@ -113,3 +113,4 @@ do {
for(el=head,tmp=el->next;el;el=tmp,tmp=(el) ? (el->next) : NULL)
#endif /* UTLIST_H */
+
diff --git a/nx-X11/lib/X11/uvY.c b/nx-X11/lib/X11/uvY.c
index 60603a950..19e6c5232 100644
--- a/nx-X11/lib/X11/uvY.c
+++ b/nx-X11/lib/X11/uvY.c
@@ -135,13 +135,13 @@ CIEuvY_ParseString(
* 0 if failed, non-zero otherwise.
*/
{
- int n;
+ size_t n;
char *pchar;
if ((pchar = strchr(spec, ':')) == NULL) {
return(XcmsFailure);
}
- n = (int)(pchar - spec);
+ n = (size_t)(pchar - spec);
/*
* Check for proper prefix.
@@ -243,7 +243,7 @@ XcmsCIEuvYToCIEXYZ(
{
XcmsCIEXYZ XYZ_return;
XcmsColor whitePt;
- int i;
+ unsigned int i;
XcmsColor *pColor = pColors_in_out;
XcmsFloat div, x, y, z, Y;
@@ -358,7 +358,7 @@ XcmsCIEXYZToCIEuvY(
{
XcmsCIEuvY uvY_return;
XcmsColor whitePt;
- int i;
+ unsigned int i;
XcmsColor *pColor = pColors_in_out;
XcmsFloat div;
diff --git a/nx-X11/lib/X11/xlibi18n/lc/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/Imakefile
index a4eaeeb6f..16f7aceb3 100644
--- a/nx-X11/lib/X11/xlibi18n/lc/Imakefile
+++ b/nx-X11/lib/X11/xlibi18n/lc/Imakefile
@@ -2,7 +2,7 @@ XCOMM $XConsortium: Imakefile,v 1.27 94/04/07 15:01:48 rws Exp $
#define IHaveSubdirs
#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)"
-SUBDIRS = gen def Utf8 xlocale
+SUBDIRS = gen def Utf8
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
diff --git a/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile b/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile
deleted file mode 100644
index 5ead4b763..000000000
--- a/nx-X11/lib/X11/xlibi18n/lc/xlocale/Imakefile
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#include "../../Xi18nLib.conf"
-
- EXTRA_INCLUDES = -I../../..
- XI18NLIBNAME = xlocale
- SRCS = lcEuc.c lcSjis.c lcJis.c
- OBJS = ${SRCS:.c=.o}
- REQUIREDLIBS = SharedXlibi18nReqs
-
-LinkSourceFile(lcEuc.c, ../../..)
-LinkSourceFile(lcSjis.c, ../../..)
-LinkSourceFile(lcJis.c, ../../..)
-
-Xi18nLibraryTarget(xlocale)
diff --git a/nx-X11/lib/X11/xyY.c b/nx-X11/lib/X11/xyY.c
index 67959b048..e85b8d249 100644
--- a/nx-X11/lib/X11/xyY.c
+++ b/nx-X11/lib/X11/xyY.c
@@ -253,7 +253,7 @@ XcmsCIExyYToCIEXYZ(
XcmsCIEXYZ XYZ_return;
XcmsFloat div; /* temporary storage in case divisor is zero */
XcmsFloat u, v, x, y, z; /* temporary storage */
- register int i;
+ unsigned int i;
/*
* Check arguments
@@ -359,7 +359,7 @@ XcmsCIEXYZToCIExyY(
XcmsColor *pColor = pColors_in_out;
XcmsCIExyY xyY_return;
XcmsFloat div; /* temporary storage in case divisor is zero */
- register int i;
+ unsigned int i;
/*
* Check arguments
diff --git a/nx-X11/programs/Xserver/Xext/xf86bigfont.c b/nx-X11/programs/Xserver/Xext/xf86bigfont.c
index 253706ad2..67a09f77b 100644
--- a/nx-X11/programs/Xserver/Xext/xf86bigfont.c
+++ b/nx-X11/programs/Xserver/Xext/xf86bigfont.c
@@ -74,7 +74,7 @@
#include "protocol-versions.h"
#define _XF86BIGFONT_SERVER_
-#include <nx-X11/extensions/xf86bigfstr.h>
+#include <nx-X11/extensions/xf86bigfproto.h>
static void XF86BigfontResetProc(
ExtensionEntry * /* extEntry */
diff --git a/nx-X11/programs/Xserver/mi/miinitext.c b/nx-X11/programs/Xserver/mi/miinitext.c
index 22f48ffd8..b48ed8a1c 100644
--- a/nx-X11/programs/Xserver/mi/miinitext.c
+++ b/nx-X11/programs/Xserver/mi/miinitext.c
@@ -172,7 +172,7 @@ typedef void (*InitExtension)(void);
#include <nx-X11/extensions/panoramiXproto.h>
#endif
#ifdef XF86BIGFONT
-#include <nx-X11/extensions/xf86bigfstr.h>
+#include <nx-X11/extensions/xf86bigfproto.h>
#endif
#ifdef RES
#include <nx-X11/extensions/XResproto.h>