aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r--nx-X11/lib/X11/Imakefile33
-rw-r--r--nx-X11/lib/X11/XDefaultIMIF.c457
-rw-r--r--nx-X11/lib/X11/XDefaultOMIF.c1122
-rw-r--r--nx-X11/lib/X11/XlcDL.c559
-rw-r--r--nx-X11/lib/X11/XlcSL.c94
-rw-r--r--nx-X11/lib/X11/lcDynamic.c78
-rw-r--r--nx-X11/lib/X11/lcUTF8.c3
-rw-r--r--nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c535
-rw-r--r--nx-X11/lib/X11/lcUniConv/ascii.h25
-rw-r--r--nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c1071
10 files changed, 3 insertions, 3974 deletions
diff --git a/nx-X11/lib/X11/Imakefile b/nx-X11/lib/X11/Imakefile
index 061f2e33e..055cbec33 100644
--- a/nx-X11/lib/X11/Imakefile
+++ b/nx-X11/lib/X11/Imakefile
@@ -209,11 +209,11 @@ XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSOR
AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o
AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c
SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */
+ OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(EXTRAOBJS)
LINTLIBS =
-EXTRASTATICSRC = $(STATICLCSRCS)
-
-EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC)
+EXTRASRCS = $(STATICLCSRCS)
+EXTRAOBJS = $(STATICLCOBJS)
SRCS1 = \
Context.c \
@@ -891,13 +891,6 @@ OBJS3 = \
xim_trans.o \
$(XKBOBJS) $(LCOBJS)
-SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c
-
-SHAREDI18NSTATICSRCS = \
- XDefaultIMIF.c XDefaultOMIF.c
-
-STATICLCDEPSYMSRCS =
-
STATICI18NSTATICSRCS = \
imCallbk.c \
imDefFlt.c \
@@ -958,17 +951,8 @@ LCSRCS = \
lcUTF8.c
STATICLCSRCS = \
- $(STATICLCDEPSYMSRCS) \
$(STATICI18NSTATICSRCS)
-SHAREDLCSRCS = \
- $(SHAREDLCDEPSYMSRCS) \
- $(SHAREDI18NSTATICSRCS)
-
-SHAREDLCDEPOBJS = XlcDL.o XlcSL.o
-SHAREDI18NSTATICOBJS = \
- XDefaultIMIF.o XDefaultOMIF.o
-STATICLCDEPOBJS =
STATICI18NSTATICOBJS = \
imCallbk.o \
imDefFlt.o \
@@ -1029,19 +1013,8 @@ LCOBJS = \
lcUTF8.o
STATICLCOBJS = \
- $(STATICLCDEPOBJS) \
$(STATICI18NSTATICOBJS)
-SHAREDLCOBJS = \
- $(SHAREDLCDEPOBJS) \
- $(SHAREDI18NSTATICOBJS)
-
-OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
-
-EXTRAUNSHAREDOBJS = $(STATICLCOBJS)
-
-EXTRASHAREDOBJS = $(STATICLCOBJS)
-
#include <Library.tmpl>
SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES))
diff --git a/nx-X11/lib/X11/XDefaultIMIF.c b/nx-X11/lib/X11/XDefaultIMIF.c
deleted file mode 100644
index 7c32ce296..000000000
--- a/nx-X11/lib/X11/XDefaultIMIF.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
-Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
-
-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 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
-EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
-
-
-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.
-
-
-X Window System is a trademark of The Open Group
-
-OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
-logo, LBX, X Window System, and Xinerama are trademarks of the Open
-Group. All other trademarks and registered trademarks mentioned herein
-are the property of their respective owners. No right, title or
-interest in or to any trademark, service mark, logo or trade name of
-Sun Microsystems, Inc. or its licensors is granted.
-
-*/
-/*
- * 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"),
- * 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 (including the next
- * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include "Xlibint.h"
-#include "Xlcint.h"
-#include "XlcGeneric.h"
-
-#ifndef MAXINT
-#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
-#endif /* !MAXINT */
-
-typedef struct _StaticXIM *StaticXIM;
-
-typedef struct _XIMStaticXIMRec {
- /* for CT => MB,WC converter */
- XlcConv ctom_conv;
- XlcConv ctow_conv;
-} XIMStaticXIMRec;
-
-typedef enum {
- CREATE_IC = 1,
- SET_ICVAL = 2,
- GET_ICVAL = 3
-} XICOp_t;
-
-typedef struct _StaticXIM {
- XIMMethods methods;
- XIMCoreRec core;
- XIMStaticXIMRec *private;
-} StaticXIMRec;
-
-static Status _CloseIM(
- XIM
-);
-
-static char *_SetIMValues(
- XIM, XIMArg *
-);
-
-static char *_GetIMValues(
- XIM, XIMArg*
-);
-
-static XIC _CreateIC(
- XIM, XIMArg*
-);
-
-static _Xconst XIMMethodsRec local_im_methods = {
- _CloseIM, /* close */
- _SetIMValues, /* set_values */
- _GetIMValues, /* get_values */
- _CreateIC, /* create_ic */
- NULL, /* ctstombs */
- NULL /* ctstowcs */
-};
-
-static void _DestroyIC(
- XIC
-);
-static void _SetFocus(
- XIC
-);
-static void _UnsetFocus(
- XIC
-);
-static char* _SetICValues(
- XIC, XIMArg *
-);
-static char* _GetICValues(
- XIC, XIMArg *
-);
-static char *_MbReset(
- XIC
-);
-static wchar_t *_WcReset(
- XIC
-);
-static int _MbLookupString(
- XIC, XKeyEvent *, char *, int, KeySym *, Status *
-);
-static int _WcLookupString(
- XIC, XKeyEvent *, wchar_t *, int, KeySym *, Status *
-);
-
-static _Xconst XICMethodsRec local_ic_methods = {
- _DestroyIC, /* destroy */
- _SetFocus, /* set_focus */
- _UnsetFocus, /* unset_focus */
- _SetICValues, /* set_values */
- _GetICValues, /* get_values */
- _MbReset, /* mb_reset */
- _WcReset, /* wc_reset */
- NULL, /* utf8_reset */ /* ??? */
- _MbLookupString, /* mb_lookup_string */
- _WcLookupString, /* wc_lookup_string */
- NULL /* utf8_lookup_string */ /* ??? */
-};
-
-XIM
-_XDefaultOpenIM(
- XLCd lcd,
- Display *dpy,
- XrmDatabase rdb,
- char *res_name,
- char *res_class)
-{
- StaticXIM im;
- int i;
- char *mod;
- char buf[BUFSIZ];
-
- if ((im = Xcalloc(1, sizeof(StaticXIMRec))) == NULL)
- return NULL;
-
- if ((im->private = Xcalloc(1, sizeof(XIMStaticXIMRec))) == NULL)
- goto Error;
-
- 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;
- if ((lcd->core->modifiers) && (*lcd->core->modifiers)) {
-#define MODIFIER "@im="
- mod = strstr(lcd->core->modifiers, MODIFIER);
- if (mod) {
- mod += strlen(MODIFIER);
- while (*mod && *mod != '@' && i < BUFSIZ - 1) {
- buf[i++] = *mod++;
- }
- buf[i] = '\0';
- }
- }
-#undef MODIFIER
- if ((im->core.im_name = strdup(buf)) == NULL)
- goto Error;
-
- im->methods = (XIMMethods)&local_im_methods;
- im->core.lcd = lcd;
- im->core.ic_chain = (XIC)NULL;
- im->core.display = dpy;
- im->core.rdb = rdb;
- im->core.res_name = NULL;
- im->core.res_class = NULL;
-
- if ((res_name != NULL) && (*res_name != '\0')){
- im->core.res_name = strdup(res_name);
- }
- if ((res_class != NULL) && (*res_class != '\0')){
- im->core.res_class = strdup(res_class);
- }
-
- return (XIM)im;
-
- Error:
- _CloseIM((XIM)im);
- Xfree(im);
- return(NULL);
-}
-
-static Status
-_CloseIM(XIM xim)
-{
- StaticXIM im = (StaticXIM)xim;
-
- 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);
- XFree(im->core.res_name);
- XFree(im->core.res_class);
- return 1;
-}
-
-static char *
-_SetIMValues(
- XIM xim,
- XIMArg *arg)
-{
- return(arg->name); /* evil */
-}
-
-static char *
-_GetIMValues(
- XIM xim,
- XIMArg *values)
-{
- XIMArg *p;
- XIMStyles *styles;
-
- for (p = values; p->name != NULL; p++) {
- if (strcmp(p->name, XNQueryInputStyle) == 0) {
- styles = Xmalloc(sizeof(XIMStyles));
- *(XIMStyles **)p->value = styles;
- styles->count_styles = 1;
- styles->supported_styles =
- Xmalloc(styles->count_styles * sizeof(XIMStyle));
- styles->supported_styles[0] = (XIMPreeditNone | XIMStatusNone);
- } else {
- break;
- }
- }
- return (p->name);
-}
-
-static char*
-_SetICValueData(XIC ic, XIMArg *values, XICOp_t mode)
-{
- XIMArg *p;
- char *return_name = NULL;
-
- for (p = values; p != NULL && p->name != NULL; p++) {
- if(strcmp(p->name, XNInputStyle) == 0) {
- if (mode == CREATE_IC)
- ic->core.input_style = (XIMStyle)p->value;
- } else if (strcmp(p->name, XNClientWindow) == 0) {
- ic->core.client_window = (Window)p->value ;
- } else if (strcmp(p->name, XNFocusWindow) == 0) {
- ic->core.focus_window = (Window)p->value ;
- } else if (strcmp(p->name, XNPreeditAttributes) == 0
- || strcmp(p->name, XNStatusAttributes) == 0) {
- return_name = _SetICValueData(ic, (XIMArg*)p->value, mode);
- if (return_name) break;
- } else {
- return_name = p->name;
- break;
- }
- }
- return(return_name);
-}
-
-static char*
-_GetICValueData(XIC ic, XIMArg *values, XICOp_t mode)
-{
- XIMArg *p;
- char *return_name = NULL;
-
- for (p = values; p->name != NULL; p++) {
- if(strcmp(p->name, XNInputStyle) == 0) {
- *((XIMStyle *)(p->value)) = ic->core.input_style;
- } else if (strcmp(p->name, XNClientWindow) == 0) {
- *((Window *)(p->value)) = ic->core.client_window;
- } else if (strcmp(p->name, XNFocusWindow) == 0) {
- *((Window *)(p->value)) = ic->core.focus_window;
- } else if (strcmp(p->name, XNFilterEvents) == 0) {
- *((unsigned long *)(p->value))= ic->core.filter_events;
- } else if (strcmp(p->name, XNPreeditAttributes) == 0
- || strcmp(p->name, XNStatusAttributes) == 0) {
- return_name = _GetICValueData(ic, (XIMArg*)p->value, mode);
- if (return_name) break;
- } else {
- return_name = p->name;
- break;
- }
- }
- return(return_name);
-}
-
-static XIC
-_CreateIC(XIM im, XIMArg *arg)
-{
- XIC ic;
-
- if ((ic = Xcalloc(1, sizeof(XICRec))) == (XIC)NULL) {
- return ((XIC)NULL);
- }
-
- ic->methods = (XICMethods)&local_ic_methods;
- ic->core.im = im;
- ic->core.filter_events = KeyPressMask;
-
- if (_SetICValueData(ic, arg, CREATE_IC) != NULL)
- goto err_return;
- if (!(ic->core.input_style))
- goto err_return;
-
- return (XIC)ic;
-err_return:
- XFree(ic);
- return ((XIC)NULL);
-}
-
-static void
-_DestroyIC(XIC ic)
-{
-/*BugId4255571. This Xfree() should be removed because XDestroyIC() still need ic after invoking _DestroyIC() and there is a XFree(ic) at the end of XDestroyIC() already.
- if(ic)
- XFree(ic); */
-}
-
-static void
-_SetFocus(XIC ic)
-{
-}
-
-static void
-_UnsetFocus(XIC ic)
-{
-}
-
-static char*
-_SetICValues(XIC ic, XIMArg *args)
-{
- char *ret = NULL;
- if (!ic) {
- return (args->name);
- }
- ret = _SetICValueData(ic, args, SET_ICVAL);
- return(ret);
-}
-
-static char*
-_GetICValues(XIC ic, XIMArg *args)
-{
- char *ret = NULL;
- if (!ic) {
- return (args->name);
- }
- ret = _GetICValueData(ic, args, GET_ICVAL);
- return(ret);
-}
-
-static char *
-_MbReset(XIC xic)
-{
- return(NULL);
-}
-
-static wchar_t *
-_WcReset(XIC xic)
-{
- return(NULL);
-}
-
-static int
-_MbLookupString(
- XIC xic,
- XKeyEvent *ev,
- char * buffer,
- int bytes,
- KeySym *keysym,
- Status *status)
-{
- XComposeStatus NotSupportedYet ;
- int length;
-
- length = XLookupString(ev, buffer, bytes, keysym, &NotSupportedYet);
-
- if (keysym && *keysym == NoSymbol){
- *status = XLookupNone;
- } else if (length > 0) {
- *status = XLookupBoth;
- } else {
- *status = XLookupKeySym;
- }
- return(length);
-}
-
-static int
-_WcLookupString(
- XIC xic,
- XKeyEvent *ev,
- wchar_t * buffer,
- int wlen,
- KeySym *keysym,
- Status *status)
-{
- XComposeStatus NotSupportedYet ;
- int length;
- /* In single-byte, mb_len = wc_len */
- char *mb_buf = Xmalloc(wlen);
-
- length = XLookupString(ev, mb_buf, wlen, keysym, &NotSupportedYet);
-
- if (keysym && *keysym == NoSymbol){
- *status = XLookupNone;
- } else if (length > 0) {
- *status = XLookupBoth;
- } else {
- *status = XLookupKeySym;
- }
- mbstowcs(buffer, mb_buf, length);
- XFree(mb_buf);
- return(length);
-}
diff --git a/nx-X11/lib/X11/XDefaultOMIF.c b/nx-X11/lib/X11/XDefaultOMIF.c
deleted file mode 100644
index e61344d31..000000000
--- a/nx-X11/lib/X11/XDefaultOMIF.c
+++ /dev/null
@@ -1,1122 +0,0 @@
-/*
-Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
-
-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 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
-EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
-
-
-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.
-
-
-X Window System is a trademark of The Open Group
-
-OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
-logo, LBX, X Window System, and Xinerama are trademarks of the Open
-Group. All other trademarks and registered trademarks mentioned herein
-are the property of their respective owners. No right, title or
-interest in or to any trademark, service mark, logo or trade name of
-Sun Microsystems, Inc. or its licensors is granted.
-
-*/
-/*
- * 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"),
- * 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 (including the next
- * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "Xlcint.h"
-#include "XlcPublic.h"
-#include <nx-X11/Xos.h>
-#include <nx-X11/Xatom.h>
-#include <stdio.h>
-
-#define MAXFONTS 100
-
-#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
-#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
-
-#define DefineLocalBuf char local_buf[BUFSIZ]
-#define AllocLocalBuf(length) (length > BUFSIZ ? Xmalloc(length) : local_buf)
-#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
-
-typedef struct _FontDataRec {
- char *name;
-} FontDataRec, *FontData;
-
-typedef struct _OMDataRec {
- int font_data_count;
- FontData font_data;
-} OMDataRec, *OMData;
-
-typedef struct _XOMGenericPart {
- OMData data;
-} XOMGenericPart;
-
-typedef struct _XOMGenericRec {
- XOMMethods methods;
- XOMCoreRec core;
- XOMGenericPart gen;
-} XOMGenericRec, *XOMGeneric;
-
-typedef struct _FontSetRec {
- int id;
- int font_data_count;
- FontData font_data;
- char *font_name;
- XFontStruct *info;
- XFontStruct *font;
-} FontSetRec, *FontSet;
-
-typedef struct _XOCGenericPart {
- XlcConv wcs_to_cs;
- FontSet font_set;
-} XOCGenericPart;
-
-typedef struct _XOCGenericRec {
- XOCMethods methods;
- XOCCoreRec core;
- XOCGenericPart gen;
-} XOCGenericRec, *XOCGeneric;
-
-static Bool
-init_fontset(
- XOC oc)
-{
- XOCGenericPart *gen;
- FontSet font_set;
- OMData data;
-
- data = XOM_GENERIC(oc->core.om)->data;
-
- font_set = Xcalloc(1, sizeof(FontSetRec));
- if (font_set == NULL)
- return False;
-
- gen = XOC_GENERIC(oc);
- gen->font_set = font_set;
-
- font_set->font_data_count = data->font_data_count;
- font_set->font_data = data->font_data;
-
- return True;
-}
-
-static char *
-get_prop_name(
- Display *dpy,
- XFontStruct *fs)
-{
- unsigned long fp;
-
- if (XGetFontProperty(fs, XA_FONT, &fp))
- return XGetAtomName(dpy, fp);
-
- return (char *) NULL;
-}
-
-static FontData
-check_charset(
- FontSet font_set,
- char *font_name)
-{
- FontData font_data;
- char *last;
- int count;
- ssize_t length, name_len;
-
- name_len = strlen(font_name);
- last = font_name + name_len;
-
- count = font_set->font_data_count;
- font_data = font_set->font_data;
-
- for ( ; count-- > 0; font_data++) {
- length = strlen(font_data->name);
-
- if (length > name_len)
- return(NULL);
-
- if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
- return font_data;
- }
- return (FontData) NULL;
-}
-
-static Bool
-load_font(
- XOC oc)
-{
- Display *dpy = oc->core.om->core.display;
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set = gen->font_set;
-
- if (font_set->font_name == NULL)
- return False;
-
- if (font_set->font == NULL) {
- font_set->font = XLoadQueryFont(dpy, font_set->font_name);
- if (font_set->font == NULL)
- return False;
- }
- return True;
-}
-
-static void
-set_fontset_extents(
- XOC oc)
-{
- XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
- XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
- XFontStruct **font_list, *font;
- XCharStruct overall;
- int logical_ascent, logical_descent;
-
- font_list = oc->core.font_info.font_struct_list;
- font = *font_list++;
- overall = font->max_bounds;
- overall.lbearing = font->min_bounds.lbearing;
- logical_ascent = font->ascent;
- logical_descent = font->descent;
-
- ink->x = overall.lbearing;
- ink->y = -(overall.ascent);
- ink->width = overall.rbearing - overall.lbearing;
- ink->height = overall.ascent + overall.descent;
-
- logical->x = 0;
- logical->y = -(logical_ascent);
- logical->width = overall.width;
- logical->height = logical_ascent + logical_descent;
-}
-
-static Bool
-init_core_part(
- XOC oc)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- XFontStruct **font_struct_list;
- char **font_name_list, *font_name_buf;
-
- font_set = gen->font_set;
-
- if (font_set->font_name == NULL)
- return False;
-
- font_struct_list = Xmalloc(sizeof(XFontStruct *));
- if (font_struct_list == NULL)
- return False;
-
- font_name_list = Xmalloc(sizeof(char *));
- if (font_name_list == NULL)
- goto err;
-
- font_name_buf = strdup(font_set->font_name);
- if (font_name_buf == NULL)
- goto err;
-
- oc->core.font_info.num_font = 1;
- oc->core.font_info.font_name_list = font_name_list;
- oc->core.font_info.font_struct_list = font_struct_list;
-
- 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:
-
- Xfree(font_name_list);
- Xfree(font_struct_list);
-
- return False;
-}
-
-static char *
-get_font_name(
- XOC oc,
- char *pattern)
-{
- char **list, *name;
- int count;
- XFontStruct *fs;
- Display *dpy = oc->core.om->core.display;
-
- list = XListFonts(dpy, pattern, 1, &count);
- if (list != NULL) {
- name = strdup(*list);
-
- XFreeFontNames(list);
- } else {
- fs = XLoadQueryFont(dpy, pattern);
- if (fs == NULL) return NULL;
-
- name = get_prop_name(dpy, fs);
- XFreeFont(dpy, fs);
- }
- return name;
-}
-
-static int
-parse_fontname(
- XOC oc)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- FontData font_data;
- char *pattern, *last, buf[BUFSIZ];
- int font_data_count, found_num = 0;
- ssize_t length;
- int count, num_fields;
- char *base_name, *font_name, **name_list, **cur_name_list;
- char *charset_p = NULL;
- Bool append_charset;
- /*
- append_charset flag should be set to True when the XLFD fontname
- doesn't contain a chaset part.
- */
-
- name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
- if (name_list == NULL)
- return -1;
- cur_name_list = name_list;
-
- while (count-- > 0) {
- pattern = *cur_name_list++;
- if (pattern == NULL || *pattern == '\0')
- continue;
-
- append_charset = False;
-
- if (strchr(pattern, '*') == NULL &&
- (font_name = get_font_name(oc, pattern))) {
-
- font_set = gen->font_set;
-
- font_data = check_charset(font_set, font_name);
- if (font_data == NULL) {
- Display *dpy = oc->core.om->core.display;
- char **fn_list = NULL, *prop_fname = NULL;
- int list_num;
- XFontStruct *fs_list;
- if ((fn_list = XListFontsWithInfo(dpy, font_name,
- MAXFONTS,
- &list_num, &fs_list))
- && (prop_fname = get_prop_name(dpy, fs_list))
- && (font_data = check_charset(font_set, prop_fname))) {
- if (fn_list) {
- XFreeFontInfo(fn_list, fs_list, list_num);
- fn_list = NULL;
- }
- font_name = prop_fname;
- }
- }
- if (font_data == NULL)
- continue;
-
- font_set->font_name = strdup(font_name);
- Xfree(font_name);
- if (font_set->font_name == NULL) {
- goto err;
- }
- found_num++;
- goto found;
- }
-
- strncpy(buf, pattern, BUFSIZ);
- buf[BUFSIZ-1] = '\0';
- length = strlen(buf);
- last = buf + length - 1;
-
- for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
- if (*base_name == '-') num_fields++;
- if (strchr(pattern, '*') == NULL) {
- if (num_fields == 12) {
- append_charset = True;
- *++last = '-';
- last++;
- } else
- continue;
- } else {
- if (num_fields == 13 || num_fields == 14) {
- /*
- * There are 14 fields in an XLFD name -- make certain the
- * charset (& encoding) is placed in the correct field.
- */
- append_charset = True;
- last = strrchr (buf, '-');
- if (num_fields == 14) {
- *last = '\0';
- last = strrchr (buf, '-');
- }
- last++;
- } else if (*last == '*') {
- append_charset = True;
- if (length > 3 && *(last-3) == '-' && *(last-2) == '*'
- && *(last-1) == '-') {
- last -= 2;
- }
- *++last = '-';
- last++;
- } else {
- last = strrchr (buf, '-');
- charset_p = last;
- charset_p = strrchr (buf, '-');
- while (*(--charset_p) != '-');
- charset_p++;
- }
- }
-
- font_set = gen->font_set;
-
- font_data = font_set->font_data;
- font_data_count = font_set->font_data_count;
- for ( ; font_data_count-- > 0; font_data++) {
- if (append_charset)
- {
- strncpy(last, font_data->name, BUFSIZ - length);
- buf[BUFSIZ-1] = '\0';
- }
- else {
- if (_XlcCompareISOLatin1(charset_p,
- font_data->name)) {
- continue;
- }
- }
- if ((font_set->font_name = get_font_name(oc, buf)))
- break;
- }
- if (font_set->font_name != NULL) {
- found_num++;
- goto found;
- }
- }
- found:
- base_name = strdup(oc->core.base_name_list);
- if (base_name == NULL)
- goto err;
-
- oc->core.base_name_list = base_name;
-
- XFreeStringList(name_list);
-
- return found_num;
-err:
- XFreeStringList(name_list);
-
- return -1;
-}
-
-static Bool
-set_missing_list(
- XOC oc)
-{
- XOCGenericPart *gen = XOC_GENERIC(oc);
- FontSet font_set;
- char **charset_list, *charset_buf;
-
- font_set = gen->font_set;
-
- if (font_set->info == NULL || font_set->font == NULL)
- return True;
-
- charset_list = Xmalloc(sizeof(char *));
- if (charset_list == NULL)
- return False;
-
- charset_buf = strdup(font_set->font_data->name);
- if (charset_buf == NULL) {
- Xfree(charset_list);
- return False;
- }
-
- oc->core.missing_list.charset_list = charset_list;
-
- *charset_list = charset_buf;
-
- return True;
-}
-
-static Bool
-create_fontset(
- XOC oc)
-{
- int found_num;
-
- if (init_fontset(oc) == False)
- return False;
-
- found_num = parse_fontname(oc);
- if (found_num <= 0) {
- if (found_num == 0)
- set_missing_list(oc);
- return False;
- }
-
- if (load_font(oc) == False)
- return False;
-
- if (init_core_part(oc) == False)
- return False;
-
- if (set_missing_list(oc) == False)
- return False;
-
- return True;
-}
-
-static void
-destroy_oc(
- XOC oc)
-{
- Display *dpy = oc->core.om->core.display;
- XOCGenericPart *gen = XOC_GENERIC(oc);
- XFontStruct **font_list, *font;
-
-
- 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)) {
- if (font->fid)
- XFreeFont(dpy, font);
- else
- XFreeFontInfo(NULL, font, 1);
- }
- Xfree(oc->core.font_info.font_struct_list);
- }
-
-
- XFreeStringList(oc->core.missing_list.charset_list);
-
-#ifdef notdef
- Xfree(oc->core.res_name);
- Xfree(oc->core.res_class);
-#endif
-
- Xfree(oc);
-}
-
-static char *
-set_oc_values(
- XOC oc,
- XlcArgList args,
- int num_args)
-{
- if (oc->core.resources == NULL)
- return NULL;
-
- return _XlcSetValues((XPointer) oc, oc->core.resources,
- oc->core.num_resources, args, num_args, XlcSetMask);
-}
-
-static char *
-get_oc_values(
- XOC oc,
- XlcArgList args,
- int num_args)
-{
- if (oc->core.resources == NULL)
- return NULL;
-
- return _XlcGetValues((XPointer) oc, oc->core.resources,
- oc->core.num_resources, args, num_args, XlcGetMask);
-}
-
-static Bool
-wcs_to_mbs(
- XOC oc,
- char *to,
- _Xconst wchar_t *from,
- int length)
-{
- XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
- XLCd lcd;
- int ret, to_left = length;
-
- if (conv == NULL) {
- lcd = oc->core.om->core.lcd;
- conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
- if (conv == NULL)
- return False;
- XOC_GENERIC(oc)->wcs_to_cs = conv;
- } else
- _XlcResetConverter(conv);
-
- ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
- &to_left, NULL, 0);
- if (ret != 0 || length > 0)
- return False;
-
- return True;
-}
-
-static int
-_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
-{
- return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
-}
-
-static int
-_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret = 0;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- ret = _XmbDefaultTextEscapement(oc, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-static int
-_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- int direction, logical_ascent, logical_descent;
- XCharStruct overall;
-
- XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
- &logical_ascent, &logical_descent, &overall);
-
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(logical_ascent);
- overall_logical->width = overall.width;
- overall_logical->height = logical_ascent + logical_descent;
- }
-
- return overall.width;
-}
-
-static int
-_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *overall_ink, XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret = 0;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-static Status
-_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- XFontStruct *font = *oc->core.font_info.font_struct_list;
- XCharStruct *def, *cs, overall;
- Bool first = True;
-
- if (buf_size < length)
- return 0;
-
- bzero((char *) &overall, sizeof(XCharStruct));
- *num_chars = 0;
-
- CI_GET_DEFAULT_INFO_1D(font, def)
-
- while (length-- > 0) {
- CI_GET_CHAR_INFO_1D(font, *text, def, cs)
- text++;
- if (cs == NULL)
- continue;
-
- ink_buf->x = overall.width + cs->lbearing;
- ink_buf->y = -(cs->ascent);
- ink_buf->width = cs->rbearing - cs->lbearing;
- ink_buf->height = cs->ascent + cs->descent;
- ink_buf++;
-
- logical_buf->x = overall.width;
- logical_buf->y = -(font->ascent);
- logical_buf->width = cs->width;
- logical_buf->height = font->ascent + font->descent;
- logical_buf++;
-
- if (first) {
- overall = *cs;
- first = False;
- } else {
- overall.ascent = max(overall.ascent, cs->ascent);
- overall.descent = max(overall.descent, cs->descent);
- overall.lbearing = min(overall.lbearing, overall.width +
- cs->lbearing);
- overall.rbearing = max(overall.rbearing, overall.width +
- cs->rbearing);
- overall.width += cs->width;
- }
- (*num_chars)++;
- }
-
- if (overall_ink) {
- overall_ink->x = overall.lbearing;
- overall_ink->y = -(overall.ascent);
- overall_ink->width = overall.rbearing - overall.lbearing;
- overall_ink->height = overall.ascent + overall.descent;
- }
-
- if (overall_logical) {
- overall_logical->x = 0;
- overall_logical->y = -(font->ascent);
- overall_logical->width = overall.width;
- overall_logical->height = font->ascent + font->descent;
- }
-
- return 1;
-}
-
-static Status
-_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
- XRectangle *ink_buf, XRectangle *logical_buf,
- int buf_size, int *num_chars,
- XRectangle *overall_ink,
- XRectangle *overall_logical)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- Status ret = 0;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
- buf_size, num_chars, overall_ink,
- overall_logical);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-static int
-_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst char *text, int length)
-{
- XFontStruct *font = *oc->core.font_info.font_struct_list;
-
- XSetFont(dpy, gc, font->fid);
- XDrawString(dpy, d, gc, x, y, text, length);
-
- return XTextWidth(font, text, length);
-}
-
-static int
-_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
- _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
- int ret = 0;
-
- if (buf == NULL)
- return 0;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-
- return ret;
-}
-
-static void
-_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst char *text, int length)
-{
- XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
- XDrawImageString(dpy, d, gc, x, y, text, length);
-}
-
-static void
-_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
- int y, _Xconst wchar_t *text, int length)
-{
- DefineLocalBuf;
- char *buf = AllocLocalBuf(length);
-
- if (buf == NULL)
- return;
-
- if (wcs_to_mbs(oc, buf, text, length) == False)
- goto err;
-
- _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
-
-err:
- FreeLocalBuf(buf);
-}
-
-static _Xconst XOCMethodsRec oc_default_methods = {
- destroy_oc,
- set_oc_values,
- get_oc_values,
- _XmbDefaultTextEscapement,
- _XmbDefaultTextExtents,
- _XmbDefaultTextPerCharExtents,
- _XmbDefaultDrawString,
- _XmbDefaultDrawImageString,
- _XwcDefaultTextEscapement,
- _XwcDefaultTextExtents,
- _XwcDefaultTextPerCharExtents,
- _XwcDefaultDrawString,
- _XwcDefaultDrawImageString
-};
-
-static XlcResource oc_resources[] = {
- { XNBaseFontName, NULLQUARK, sizeof(char *),
- XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
- { XNOMAutomatic, NULLQUARK, sizeof(Bool),
- XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
- { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
- XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
- { XNDefaultString, NULLQUARK, sizeof(char *),
- XOffsetOf(XOCRec, core.default_string), XlcGetMask },
- { XNOrientation, NULLQUARK, sizeof(XOrientation),
- XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask },
- { XNResourceName, NULLQUARK, sizeof(char *),
- XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
- { XNResourceClass, NULLQUARK, sizeof(char *),
- XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
- { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
- XOffsetOf(XOCRec, core.font_info), XlcGetMask }
-};
-
-static XOC
-create_oc(
- XOM om,
- XlcArgList args,
- int num_args)
-{
- XOC oc;
-
- oc = Xcalloc(1, sizeof(XOCGenericRec));
- if (oc == NULL)
- return (XOC) NULL;
-
- oc->core.om = om;
-
- if (oc_resources[0].xrm_name == NULLQUARK)
- _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
-
- if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
- args, num_args, XlcCreateMask | XlcDefaultMask))
- goto err;
-
- if (oc->core.base_name_list == NULL)
- goto err;
-
- oc->core.resources = oc_resources;
- oc->core.num_resources = XlcNumber(oc_resources);
-
- if (create_fontset(oc) == False)
- goto err;
-
- oc->methods = (XOCMethods)&oc_default_methods;
-
- return oc;
-
-err:
- destroy_oc(oc);
-
- return (XOC) NULL;
-}
-
-static Status
-close_om(
- XOM om)
-{
- XOMGenericPart *gen = XOM_GENERIC(om);
- OMData data;
- FontData font_data;
- int count;
-
- if ((data = gen->data)) {
- if (data->font_data) {
- for (font_data = data->font_data, count = data->font_data_count;
- count-- > 0 ; font_data++) {
- Xfree(font_data->name);
- }
- Xfree(data->font_data);
- }
- Xfree(gen->data);
- }
-
-
- 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);
-
- Xfree(om->core.orientation_list.orientation);
- Xfree(om);
-
- return 1;
-}
-
-static char *
-set_om_values(
- XOM om,
- XlcArgList args,
- int num_args)
-{
- if (om->core.resources == NULL)
- return NULL;
-
- return _XlcSetValues((XPointer) om, om->core.resources,
- om->core.num_resources, args, num_args, XlcSetMask);
-}
-
-static char *
-get_om_values(
- XOM om,
- XlcArgList args,
- int num_args)
-{
- if (om->core.resources == NULL)
- return NULL;
-
- return _XlcGetValues((XPointer) om, om->core.resources,
- om->core.num_resources, args, num_args, XlcGetMask);
-}
-
-static _Xconst XOMMethodsRec methods = {
- close_om,
- set_om_values,
- get_om_values,
- create_oc
-};
-
-static XlcResource om_resources[] = {
- { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
- XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
- { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
- XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
- { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
- XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
- { XNContextualDrawing, NULLQUARK, sizeof(Bool),
- XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
-};
-
-static OMData
-add_data(
- XOM om)
-{
- XOMGenericPart *gen = XOM_GENERIC(om);
- OMData new;
-
- new = Xcalloc(1, sizeof(OMDataRec));
-
- if (new == NULL)
- return NULL;
-
- gen->data = new;
-
- return new;
-}
-
-static _Xconst char *supported_charset_list[] = {
- "ISO8859-1",
- "adobe-fontspecific",
- "SUNOLCURSOR-1",
- "SUNOLGLYPH-1"
-};
-
-static Bool
-init_om(
- XOM om)
-{
- XOMGenericPart *gen = XOM_GENERIC(om);
- OMData data;
- FontData font_data;
- char **required_list;
- XOrientation *orientation;
- char *bufptr;
- int i, count;
-
- count = XlcNumber(supported_charset_list);
-
- data = add_data(om);
- if (data == NULL)
- return False;
-
- font_data = Xcalloc(count, sizeof(FontDataRec));
- if (font_data == NULL)
- return False;
- data->font_data = font_data;
- data->font_data_count = count;
-
- for (i = 0; i < count; i++, font_data++) {
- font_data->name = strdup(supported_charset_list[i]);
- if (font_data->name == NULL)
- return False;
- }
-
- /* required charset list */
- required_list = Xmalloc(sizeof(char *));
- if (required_list == NULL)
- return False;
-
- bufptr = strdup(data->font_data->name);
- if (bufptr == NULL) {
- Xfree(required_list);
- return False;
- }
-
- om->core.required_charset.charset_list = required_list;
- om->core.required_charset.charset_count = 1; /* always 1 */
-
- data = gen->data;
-
- *required_list = bufptr;
-
- /* orientation list */
- orientation = Xmalloc(sizeof(XOrientation));
- if (orientation == NULL)
- return False;
-
- *orientation = XOMOrientation_LTR_TTB;
- om->core.orientation_list.orientation = orientation;
- om->core.orientation_list.num_orientation = 1;
-
- /* directional dependent drawing */
- om->core.directional_dependent = False;
-
- /* contexual drawing */
- om->core.contextual_drawing = False;
-
- /* context dependent */
- om->core.context_dependent = False;
-
- return True;
-}
-
-XOM
-_XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
- _Xconst char *res_name, _Xconst char *res_class)
-{
- XOM om;
-
- om = Xcalloc(1, sizeof(XOMGenericRec));
- if (om == NULL)
- return (XOM) NULL;
-
- om->methods = (XOMMethods)&methods;
- om->core.lcd = lcd;
- om->core.display = dpy;
- om->core.rdb = rdb;
- if (res_name) {
- om->core.res_name = strdup(res_name);
- if (om->core.res_name == NULL)
- goto err;
- }
- if (res_class) {
- om->core.res_class = strdup(res_class);
- if (om->core.res_class == NULL)
- goto err;
- }
-
- if (om_resources[0].xrm_name == NULLQUARK)
- _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
-
- om->core.resources = om_resources;
- om->core.num_resources = XlcNumber(om_resources);
-
- if (init_om(om) == False)
- goto err;
-
- return om;
-err:
- close_om(om);
-
- return (XOM) NULL;
-}
diff --git a/nx-X11/lib/X11/XlcDL.c b/nx-X11/lib/X11/XlcDL.c
deleted file mode 100644
index 032bcf51c..000000000
--- a/nx-X11/lib/X11/XlcDL.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
-Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
-
-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 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
-EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
-
-
-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.
-
-
-X Window System is a trademark of The Open Group
-
-OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
-logo, LBX, X Window System, and Xinerama are trademarks of the Open
-Group. All other trademarks and registered trademarks mentioned herein
-are the property of their respective owners. No right, title or
-interest in or to any trademark, service mark, logo or trade name of
-Sun Microsystems, Inc. or its licensors is granted.
-
-*/
-/*
- * 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"),
- * 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 (including the next
- * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
- */
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#else
-# define HAVE_DLFCN_H
-#endif
-
-#include <stdio.h>
-
-#ifdef HAVE_DL_H
-#include <dl.h>
-#endif
-
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <ctype.h>
-
-#include "Xlibint.h"
-#include "XlcPublic.h"
-#include "XlcPubI.h"
-
-#define XI18N_DLREL 2
-
-#define iscomment(ch) ((ch) == '\0' || (ch) == '#')
-
-typedef enum {
- XLC_OBJECT,
- XIM_OBJECT,
- XOM_OBJECT
-} XI18NDLType;
-
-typedef struct {
- XI18NDLType type;
- int locale_name_len;
- char *locale_name;
- char *dl_name;
- char *open;
- char *im_register;
- char *im_unregister;
- int dl_release;
- unsigned int refcount;
- void *dl_module;
-} XI18NObjectsListRec, *XI18NObjectsList;
-
-#define OBJECT_INIT_LEN 8
-#define OBJECT_INC_LEN 4
-static int lc_len = 0;
-static XI18NObjectsListRec *xi18n_objects_list = NULL;
-static int lc_count = 0;
-
-static int
-parse_line(char *line, char **argv, int argsize)
-{
- int argc = 0;
- char *p = line;
-
- while (argc < argsize) {
- while (isspace(*p)) {
- ++p;
- }
- if (iscomment(*p)){
- break;
- }
- argv[argc++] = p;
- while (!isspace(*p)) {
- ++p;
- }
- if (iscomment(*p)) {
- break;
- }
- *p++ = '\0';
- }
- return argc;
-}
-
-static char *
-strdup_with_underscore(const char *symbol)
-{
- char *result;
-
- if ((result = malloc(strlen(symbol) + 2)) == NULL)
- return NULL;
- result[0] = '_';
- strcpy(result + 1, symbol);
- return result;
-}
-
-static void *
-try_both_dlsym (void *handle, char *name)
-{
- void *ret;
-
- ret = dlsym (handle, name);
- if (!ret)
- {
- name = strdup_with_underscore (name);
- if (name)
- {
- ret = dlsym (handle, name);
- free (name);
- }
- }
- return ret;
-}
-
-static void
-resolve_object(char *path, const char *lc_name)
-{
- char filename[BUFSIZ];
- FILE *fp;
- char buf[BUFSIZ];
-
- if (lc_len == 0) { /* True only for the 1st time */
- lc_len = OBJECT_INIT_LEN;
- xi18n_objects_list = Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
- if (!xi18n_objects_list) return;
- }
- snprintf(filename, sizeof(filename), "%s/%s", path, "XI18N_OBJS");
- fp = fopen(filename, "r");
- if (fp == (FILE *)NULL){
- return;
- }
-
- while (fgets(buf, BUFSIZ, fp) != NULL){
- char *p = buf;
- int n;
- char *args[6];
- while (isspace(*p)){
- ++p;
- }
- if (iscomment(*p)){
- continue;
- }
-
- if (lc_count == lc_len) {
- 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);
-
- if (n == 3 || n == 5) {
- if (!strcmp(args[0], "XLC")){
- xi18n_objects_list[lc_count].type = XLC_OBJECT;
- } else if (!strcmp(args[0], "XOM")){
- xi18n_objects_list[lc_count].type = XOM_OBJECT;
- } else if (!strcmp(args[0], "XIM")){
- xi18n_objects_list[lc_count].type = XIM_OBJECT;
- }
- xi18n_objects_list[lc_count].dl_name = strdup(args[1]);
- xi18n_objects_list[lc_count].open = strdup(args[2]);
- xi18n_objects_list[lc_count].dl_release = XI18N_DLREL;
- xi18n_objects_list[lc_count].locale_name = strdup(lc_name);
- xi18n_objects_list[lc_count].refcount = 0;
- xi18n_objects_list[lc_count].dl_module = (void*)NULL;
- if (n == 5) {
- xi18n_objects_list[lc_count].im_register = strdup(args[3]);
- xi18n_objects_list[lc_count].im_unregister = strdup(args[4]);
- } else {
- xi18n_objects_list[lc_count].im_register = NULL;
- xi18n_objects_list[lc_count].im_unregister = NULL;
- }
- lc_count++;
- }
- }
- done:
- fclose(fp);
-}
-
-static char*
-__lc_path(const char *dl_name, const char *lc_dir)
-{
- char *path;
- size_t len;
- char *slash_p;
-
- /*
- * reject this for possible security issue
- */
- if (strstr (dl_name, "../"))
- return NULL;
-
- len = (lc_dir ? strlen(lc_dir) : 0 ) +
- (dl_name ? strlen(dl_name) : 0) + 10;
-#if defined POSTLOCALELIBDIR
- len += (strlen(POSTLOCALELIBDIR) + 1);
-#endif
- path = Xmalloc(len + 1);
-
- if (strchr(dl_name, '/') != NULL) {
- slash_p = strrchr(lc_dir, '/');
- *slash_p = '\0';
- } else
- slash_p = NULL;
-
-#if defined POSTLOCALELIBDIR
- 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
-
- if (slash_p != NULL)
- *slash_p = '/';
-
- return path;
-}
-
-/* We reference count dlopen() and dlclose() of modules; unfortunately,
- * since XCloseIM, XCloseOM, XlcClose aren't wrapped, but directly
- * call the close method of the object, we leak a reference count every
- * time we open then close a module. Fixing this would require
- * either creating proxy objects or hooks for close_im/close_om
- * in XLCd
- */
-static Bool
-open_object(
- XI18NObjectsList object,
- char *lc_dir)
-{
- char *path;
-
- if (object->refcount == 0) {
- path = __lc_path(object->dl_name, lc_dir);
- if (!path)
- return False;
- object->dl_module = dlopen(path, RTLD_LAZY);
- Xfree(path);
-
- if (!object->dl_module)
- return False;
- }
-
- object->refcount++;
- return True;
-}
-
-static void *
-fetch_symbol(
- XI18NObjectsList object,
- char *symbol)
-{
- void *result = NULL;
-
- if (symbol == NULL)
- return NULL;
-
- result = try_both_dlsym(object->dl_module, symbol);
-
- return result;
-}
-
-static void
-close_object(XI18NObjectsList object)
-{
- object->refcount--;
- if (object->refcount == 0)
- {
- dlclose(object->dl_module);
- object->dl_module = NULL;
- }
-}
-
-
-typedef XLCd (*dynamicLoadProc)(const char *);
-
-XLCd
-_XlcDynamicLoad(const char *lc_name)
-{
- XLCd lcd = (XLCd)NULL;
- dynamicLoadProc lc_loader = (dynamicLoadProc)NULL;
- int count;
- XI18NObjectsList objects_list;
- char lc_dir[BUFSIZE], lc_lib_dir[BUFSIZE];
-
- if (lc_name == NULL) return (XLCd)NULL;
-
- if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL)
- return (XLCd)NULL;
- if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, lc_name) == NULL)
- return (XLCd)NULL;
-
- resolve_object(lc_dir, lc_name);
- resolve_object(lc_lib_dir, lc_name);
-
- objects_list = xi18n_objects_list;
- count = lc_count;
- for (; count-- > 0; objects_list++) {
- if (objects_list->type != XLC_OBJECT ||
- strcmp(objects_list->locale_name, lc_name)) continue;
- if (!open_object (objects_list, lc_dir) && \
- !open_object (objects_list, lc_lib_dir))
- continue;
-
- lc_loader = (dynamicLoadProc)fetch_symbol (objects_list, objects_list->open);
- if (!lc_loader) continue;
- lcd = (*lc_loader)(lc_name);
- if (lcd != (XLCd)NULL) {
- break;
- }
-
- close_object (objects_list);
- }
- return (XLCd)lcd;
-}
-
-
-typedef XIM (*dynamicOpenProcp)(XLCd, Display *, XrmDatabase, char *, char *);
-
-static XIM
-_XDynamicOpenIM(XLCd lcd, Display *display, XrmDatabase rdb,
- char *res_name, char *res_class)
-{
- XIM im = (XIM)NULL;
- char lc_dir[BUFSIZE];
- char *lc_name;
- dynamicOpenProcp im_openIM = (dynamicOpenProcp)NULL;
- int count;
- XI18NObjectsList objects_list = xi18n_objects_list;
-
- lc_name = lcd->core->name;
-
- if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XIM)0;
-
- count = lc_count;
- for (; count-- > 0; objects_list++) {
- if (objects_list->type != XIM_OBJECT ||
- strcmp(objects_list->locale_name, lc_name)) continue;
-
- if (!open_object (objects_list, lc_dir))
- continue;
-
- im_openIM = (dynamicOpenProcp)fetch_symbol(objects_list, objects_list->open);
- if (!im_openIM) continue;
- im = (*im_openIM)(lcd, display, rdb, res_name, res_class);
- if (im != (XIM)NULL) {
- break;
- }
-
- close_object (objects_list);
- }
- return (XIM)im;
-}
-
-typedef Bool (*dynamicRegisterCBProcp)(
- XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer);
-
-static Bool
-_XDynamicRegisterIMInstantiateCallback(
- XLCd lcd,
- Display *display,
- XrmDatabase rdb,
- char *res_name,
- char *res_class,
- XIDProc callback,
- XPointer client_data)
-{
- char lc_dir[BUFSIZE];
- char *lc_name;
- dynamicRegisterCBProcp im_registerIM = (dynamicRegisterCBProcp)NULL;
- Bool ret_flag = False;
- int count;
- XI18NObjectsList objects_list = xi18n_objects_list;
-
- lc_name = lcd->core->name;
-
- if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False;
-
- count = lc_count;
- for (; count-- > 0; objects_list++) {
- if (objects_list->type != XIM_OBJECT ||
- strcmp(objects_list->locale_name, lc_name)) continue;
-
- if (!open_object (objects_list, lc_dir))
- continue;
- im_registerIM = (dynamicRegisterCBProcp)fetch_symbol(objects_list,
- objects_list->im_register);
- if (!im_registerIM) continue;
- ret_flag = (*im_registerIM)(lcd, display, rdb,
- res_name, res_class,
- callback, client_data);
- if (ret_flag) break;
-
- close_object (objects_list);
- }
- return (Bool)ret_flag;
-}
-
-typedef Bool (*dynamicUnregisterProcp)(
- XLCd, Display *, XrmDatabase, char *, char *, XIDProc, XPointer);
-
-static Bool
-_XDynamicUnRegisterIMInstantiateCallback(
- XLCd lcd,
- Display *display,
- XrmDatabase rdb,
- char *res_name,
- char *res_class,
- XIDProc callback,
- XPointer client_data)
-{
- char lc_dir[BUFSIZE];
- const char *lc_name;
- dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL;
- Bool ret_flag = False;
- int count;
- XI18NObjectsList objects_list = xi18n_objects_list;
-
- lc_name = lcd->core->name;
- if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL) return False;
-
- count = lc_count;
- for (; count-- > 0; objects_list++) {
- if (objects_list->type != XIM_OBJECT ||
- strcmp(objects_list->locale_name, lc_name)) continue;
-
- if (!objects_list->refcount) /* Must already be opened */
- continue;
-
- im_unregisterIM = (dynamicUnregisterProcp)fetch_symbol(objects_list,
- objects_list->im_unregister);
-
- if (!im_unregisterIM) continue;
- ret_flag = (*im_unregisterIM)(lcd, display, rdb,
- res_name, res_class,
- callback, client_data);
- if (ret_flag) {
- close_object (objects_list); /* opened in RegisterIMInstantiateCallback */
- break;
- }
- }
- return (Bool)ret_flag;
-}
-
-Bool
-_XInitDynamicIM(XLCd lcd)
-{
- if(lcd == (XLCd)NULL)
- return False;
- lcd->methods->open_im = _XDynamicOpenIM;
- lcd->methods->register_callback = _XDynamicRegisterIMInstantiateCallback;
- lcd->methods->unregister_callback = _XDynamicUnRegisterIMInstantiateCallback;
- return True;
-}
-
-
-typedef XOM (*dynamicIOpenProcp)(
- XLCd, Display *, XrmDatabase, _Xconst char *, _Xconst char *);
-
-static XOM
-_XDynamicOpenOM(XLCd lcd, Display *display, XrmDatabase rdb,
- _Xconst char *res_name, _Xconst char *res_class)
-{
- XOM om = (XOM)NULL;
- int count;
- char lc_dir[BUFSIZE];
- char *lc_name;
- dynamicIOpenProcp om_openOM = (dynamicIOpenProcp)NULL;
- XI18NObjectsList objects_list = xi18n_objects_list;
-
- lc_name = lcd->core->name;
-
- if (_XlcLocaleLibDirName(lc_dir, BUFSIZE, lc_name) == NULL) return (XOM)0;
-
- count = lc_count;
- for (; count-- > 0; objects_list++) {
- if (objects_list->type != XOM_OBJECT ||
- strcmp(objects_list->locale_name, lc_name)) continue;
- if (!open_object (objects_list, lc_dir))
- continue;
-
- om_openOM = (dynamicIOpenProcp)fetch_symbol(objects_list, objects_list->open);
- if (!om_openOM) continue;
- om = (*om_openOM)(lcd, display, rdb, res_name, res_class);
- if (om != (XOM)NULL) {
- break;
- }
- close_object(objects_list);
- }
- return (XOM)om;
-}
-
-Bool
-_XInitDynamicOM(XLCd lcd)
-{
- if(lcd == (XLCd)NULL)
- return False;
-
- lcd->methods->open_om = _XDynamicOpenOM;
-
- return True;
-}
diff --git a/nx-X11/lib/X11/XlcSL.c b/nx-X11/lib/X11/XlcSL.c
deleted file mode 100644
index b8b3967d9..000000000
--- a/nx-X11/lib/X11/XlcSL.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
-
-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 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
-EVEN IF ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
-
-
-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.
-
-
-X Window System is a trademark of The Open Group
-
-OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
-logo, LBX, X Window System, and Xinerama are trademarks of the Open
-Group. All other trademarks and registered trademarks mentioned herein
-are the property of their respective owners. No right, title or
-interest in or to any trademark, service mark, logo or trade name of
-Sun Microsystems, Inc. or its licensors is granted.
-
-*/
-/*
- * 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"),
- * 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 (including the next
- * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "Xlcint.h"
-
-extern XIM _XDefaultOpenIM(
- XLCd, Display *, XrmDatabase, char *, char *
- );
-
-Bool
-_XInitDefaultIM(XLCd lcd)
-{
- if(lcd == (XLCd)NULL)
- return False;
-
- lcd->methods->open_im = _XDefaultOpenIM;
- lcd->methods->register_callback = NULL;
- lcd->methods->unregister_callback = NULL;
- return True;
-}
-
-extern XOM _XDefaultOpenOM(
- XLCd, Display*, XrmDatabase, _Xconst char*, _Xconst char*
- );
-
-Bool
-_XInitDefaultOM(XLCd lcd)
-{
- lcd->methods->open_om = _XDefaultOpenOM;
- return True;
-}
diff --git a/nx-X11/lib/X11/lcDynamic.c b/nx-X11/lib/X11/lcDynamic.c
deleted file mode 100644
index 3821bfff1..000000000
--- a/nx-X11/lib/X11/lcDynamic.c
+++ /dev/null
@@ -1,78 +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
- *
- */
-
-/*
- * A dynamically loaded locale.
- * Supports: All locale names.
- * How: Loads $(XLOCALEDIR)/xi18n.so and forwards the request to that library.
- * Platforms: Only those defining USE_DYNAMIC_LOADER (none known).
- */
-
-#ifdef USE_DYNAMIC_LOADER
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <dlfcn.h>
-
-#include "Xlibint.h"
-#include "Xlcint.h"
-
-#ifndef XLOCALEDIR
-#define XLOCALEDIR "/usr/lib/X11/locale"
-#endif
-
-#define LCLIBNAME "xi18n.so"
-
-XLCd
-_XlcDynamicLoader(
- const char *name)
-{
- char libpath[1024];
- XLCdMethods _XlcGenericMethods;
- XLCd lcd;
- void *nlshandler;
-
- snprintf(libpath, sizeof(libpath), "%s/%s/%s",
- XLOCALEDIR, name, LCLIBNAME);
- nlshandler = dlopen(libpath,LAZY);
- _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods");
- lcd = _XlcCreateLC(name,_XlcGenericMethods);
-
- return lcd;
-}
-#else
-typedef int dummy;
-#endif /* USE_DYNAMIC_LOADER */
diff --git a/nx-X11/lib/X11/lcUTF8.c b/nx-X11/lib/X11/lcUTF8.c
index 38201573e..5899338f1 100644
--- a/nx-X11/lib/X11/lcUTF8.c
+++ b/nx-X11/lib/X11/lcUTF8.c
@@ -163,9 +163,6 @@ typedef struct _Utf8ConvRec {
#include "lcUniConv/utf8.h"
#include "lcUniConv/ucs2be.h"
-#ifdef notused
-#include "lcUniConv/ascii.h"
-#endif
#include "lcUniConv/iso8859_1.h"
#include "lcUniConv/iso8859_2.h"
#include "lcUniConv/iso8859_3.h"
diff --git a/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
deleted file mode 100644
index 993979aeb..000000000
--- a/nx-X11/lib/X11/lcUniConv/8bit_tab_to_h.c
+++ /dev/null
@@ -1,535 +0,0 @@
-
-/*
- * Generates an 8-bit character set table from a .TXT table as found on
- * ftp.unicode.org or from a table containing the 256 Unicode values as
- * hexadecimal integers.
- * Examples:
- *
- * ./8bit_tab_to_h ISO-8859-1 iso8859_1 < tab8859_1
- * ./8bit_tab_to_h ISO-8859-2 iso8859_2 < tab8859_2
- * ./8bit_tab_to_h ISO-8859-3 iso8859_3 < tab8859_3
- * ./8bit_tab_to_h ISO-8859-4 iso8859_4 < tab8859_4
- * ./8bit_tab_to_h ISO-8859-5 iso8859_5 < tab8859_5
- * ./8bit_tab_to_h ISO-8859-6 iso8859_6 < tab8859_6
- * ./8bit_tab_to_h ISO-8859-7 iso8859_7 < tab8859_7
- * ./8bit_tab_to_h ISO-8859-8 iso8859_8 < tab8859_8
- * ./8bit_tab_to_h ISO-8859-9 iso8859_9 < tab8859_9
- * ./8bit_tab_to_h ISO-8859-10 iso8859_10 < tab8859_10
- * ./8bit_tab_to_h ISO-8859-14 iso8859_14 < tab8859_14
- * ./8bit_tab_to_h ISO-8859-15 iso8859_15 < tab8859_15
- * ./8bit_tab_to_h JISX0201.1976-0 jisx0201 < jis0201
- * ./8bit_tab_to_h TIS620-0 tis620 < tabtis620
- * ./8bit_tab_to_h KOI8-R koi8_r < tabkoi8_r
- * ./8bit_tab_to_h KOI8-U koi8_u < tabkoi8_u
- * ./8bit_tab_to_h ARMSCII-8 armscii_8 < tabarmscii_8
- * ./8bit_tab_to_h CP1133 cp1133 < tabibm_cp1133
- * ./8bit_tab_to_h MULELAO-1 mulelao < tabmulelao_1
- * ./8bit_tab_to_h VISCII1.1-1 viscii1 < tabviscii
- * ./8bit_tab_to_h TCVN-5712 tcvn < tabtcvn
- * ./8bit_tab_to_h GEORGIAN-ACADEMY georgian_ac < tabgeorgian_academy
- * ./8bit_tab_to_h GEORGIAN-PS georgian_ps < tabgeorgian_ps
- *
- * ./8bit_tab_to_h ISO-8859-1 iso8859_1 < 8859-1.TXT
- * ./8bit_tab_to_h ISO-8859-2 iso8859_2 < 8859-2.TXT
- * ./8bit_tab_to_h ISO-8859-3 iso8859_3 < 8859-3.TXT
- * ./8bit_tab_to_h ISO-8859-4 iso8859_4 < 8859-4.TXT
- * ./8bit_tab_to_h ISO-8859-5 iso8859_5 < 8859-5.TXT
- * ./8bit_tab_to_h ISO-8859-6 iso8859_6 < 8859-6.TXT
- * ./8bit_tab_to_h ISO-8859-7 iso8859_7 < 8859-7.TXT
- * ./8bit_tab_to_h ISO-8859-8 iso8859_8 < 8859-8.TXT
- * ./8bit_tab_to_h ISO-8859-9 iso8859_9 < 8859-9.TXT
- * ./8bit_tab_to_h ISO-8859-10 iso8859_10 < 8859-10.TXT
- * ./8bit_tab_to_h ISO-8859-14 iso8859_14 < 8859-14.TXT
- * ./8bit_tab_to_h ISO-8859-15 iso8859_15 < 8859-15.TXT
- * ./8bit_tab_to_h JISX0201.1976-0 jisx0201 < JIS0201.TXT
- * ./8bit_tab_to_h KOI8-R koi8_r < KOI8-R.TXT
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-
-int main (int argc, char *argv[])
-{
- const char* charsetname;
- const char* c_charsetname;
- const char* filename;
- const char* directory;
- int charset2uni[0x100];
-
- if (argc != 3 && argc != 4 && argc != 5)
- exit(1);
- charsetname = argv[1];
- c_charsetname = argv[2];
- if (argc > 3) {
- filename = argv[3];
- } else {
- char* s = malloc(strlen(c_charsetname)+strlen(".h")+1);
- strcpy(s,c_charsetname); strcat(s,".h");
- filename = s;
- }
- directory = (argc > 4 ? argv[4] : "");
-
- fprintf(stderr, "Creating %s%s\n", directory, filename);
-
- {
- int i, c;
- c = getc(stdin);
- ungetc(c,stdin);
- if (c == '#') {
- /* Read a unicode.org style .TXT file. */
- for (i = 0; i < 0x100; i++)
- charset2uni[i] = 0xfffd;
- for (;;) {
- c = getc(stdin);
- if (c == EOF)
- break;
- if (c == '\n' || c == ' ' || c == '\t')
- continue;
- if (c == '#') {
- do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
- continue;
- }
- ungetc(c,stdin);
- if (scanf("0x%x", &i) != 1 || !(i >= 0 && i < 0x100))
- exit(1);
- do { c = getc(stdin); } while (c == ' ' || c == '\t');
- if (c != EOF)
- ungetc(c,stdin);
- if (c == '\n' || c == '#')
- continue;
- if (scanf("0x%x", &charset2uni[i]) != 1)
- exit(1);
- }
- } else {
- /* Read a table of hexadecimal Unicode values. */
- for (i = 0; i < 0x100; i++) {
- if (scanf("%x", &charset2uni[i]) != 1)
- exit(1);
- if (charset2uni[i] < 0 || charset2uni[i] == 0xffff)
- charset2uni[i] = 0xfffd;
- }
- if (scanf("%x", &i) != EOF)
- exit(1);
- }
- }
-
- /* Write the output file. */
- {
- FILE* f;
-
- {
- char* fname = malloc(strlen(directory)+strlen(filename)+1);
- strcpy(fname,directory); strcat(fname,filename);
- f = fopen(fname,"w");
- if (f == NULL)
- exit(1);
- }
-
- fprintf(f, "\n");
- fprintf(f, "/*\n");
- fprintf(f, " * %s\n", charsetname);
- fprintf(f, " */\n");
- fprintf(f, "\n");
-
- {
- int i, i1, i2, i3;
- int line[16];
- int tableno;
- struct { int minline; int maxline; } tables[16];
- bool some_invalid;
- bool final_ret_reached;
-
- for (i1 = 0; i1 < 16; i1++) {
- bool all_invalid = true;
- bool all_identity = true;
- for (i2 = 0; i2 < 16; i2++) {
- i = 16*i1+i2;
- if (charset2uni[i] != 0xfffd)
- all_invalid = false;
- if (charset2uni[i] != i)
- all_identity = false;
- }
- if (all_invalid)
- line[i1] = -2;
- else if (all_identity)
- line[i1] = -1;
- else
- line[i1] = 0;
- }
- tableno = 0;
- for (i1 = 0; i1 < 16; i1++) {
- if (line[i1] >= 0) {
- if (i1 > 0 && tableno > 0 && line[i1-1] == tableno-1) {
- line[i1] = tableno-1;
- tables[tableno-1].maxline = i1;
- } else {
- tableno++;
- line[i1] = tableno-1;
- tables[tableno-1].minline = tables[tableno-1].maxline = i1;
- }
- }
- }
- some_invalid = false;
- for (i = 0; i < 0x100; i++)
- if (charset2uni[i] == 0xfffd)
- some_invalid = true;
- if (tableno > 0) {
- int t;
- for (t = 0; t < tableno; t++) {
- fprintf(f, "static const unsigned short %s_2uni", c_charsetname);
- if (tableno > 1)
- fprintf(f, "_%d", t+1);
- fprintf(f, "[%d] = {\n", 16*(tables[t].maxline-tables[t].minline+1));
- for (i1 = tables[t].minline; i1 <= tables[t].maxline; i1++) {
- fprintf(f, " /* 0x%02x */\n", 16*i1);
- for (i2 = 0; i2 < 2; i2++) {
- fprintf(f, " ");
- for (i3 = 0; i3 < 8; i3++) {
- i = 16*i1+8*i2+i3;
- fprintf(f, " 0x%04x,", charset2uni[i]);
- }
- fprintf(f, "\n");
- }
- }
- fprintf(f, "};\n");
- }
- fprintf(f, "\n");
- }
- final_ret_reached = false;
- fprintf(f, "static int\n%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", c_charsetname);
- fprintf(f, "{\n");
- fprintf(f, " unsigned char c = *s;\n");
- if (some_invalid) {
- for (i1 = 0; i1 < 16;) {
- int t = line[i1];
- const char* indent;
- for (i2 = i1; i2 < 16 && line[i2] == t; i2++);
- indent = (i1 == 0 && i2 == 16 ? " " : " ");
- if (i1 == 0) {
- if (i2 == 16) {
- } else {
- fprintf(f, " if (c < 0x%02x) {\n", 16*i2);
- }
- } else {
- if (i2 == 16) {
- fprintf(f, " else {\n");
- } else {
- fprintf(f, " else if (c < 0x%02x) {\n", 16*i2);
- }
- }
- if (t == -2) {
- final_ret_reached = true;
- } else if (t == -1) {
- fprintf(f, "%s*pwc = (ucs4_t) c;\n", indent);
- fprintf(f, "%sreturn 1;\n", indent);
- } else {
- fprintf(f, "%s", indent);
- some_invalid = false;
- for (i = 16*i1; i < 16*i2; i++)
- if (charset2uni[i] == 0xfffd)
- some_invalid = true;
- if (some_invalid)
- fprintf(f, "unsigned short wc = ");
- else
- fprintf(f, "*pwc = (ucs4_t) ");
- fprintf(f, "%s_2uni", c_charsetname);
- if (tableno > 1)
- fprintf(f, "_%d", t+1);
- fprintf(f, "[c");
- if (tables[t].minline > 0)
- fprintf(f, "-0x%02x", 16*tables[t].minline);
- fprintf(f, "];\n");
- if (some_invalid) {
- fprintf(f, "%sif (wc != 0xfffd) {\n", indent);
- fprintf(f, "%s *pwc = (ucs4_t) wc;\n", indent);
- fprintf(f, "%s return 1;\n", indent);
- fprintf(f, "%s}\n", indent);
- final_ret_reached = true;
- } else {
- fprintf(f, "%sreturn 1;\n", indent);
- }
- }
- if (!(i1 == 0 && i2 == 16))
- fprintf(f, " }\n");
- i1 = i2;
- }
- if (final_ret_reached)
- fprintf(f, " return RET_ILSEQ;\n");
- } else {
- for (i1 = 0; i1 < 16;) {
- int t = line[i1];
- for (i2 = i1; i2 < 16 && line[i2] == t; i2++);
- if (i1 == 0) {
- if (i2 == 16) {
- fprintf(f, " ");
- } else {
- fprintf(f, " if (c < 0x%02x)\n ", 16*i2);
- }
- } else {
- if (i2 == 16) {
- fprintf(f, " else\n ");
- } else {
- fprintf(f, " else if (c < 0x%02x)\n ", 16*i2);
- }
- }
- if (t == -1)
- fprintf(f, "*pwc = (ucs4_t) c;\n");
- else {
- fprintf(f, "*pwc = (ucs4_t) %s_2uni", c_charsetname);
- if (tableno > 1)
- fprintf(f, "_%d", t+1);
- fprintf(f, "[c");
- if (tables[t].minline > 0)
- fprintf(f, "-0x%02x", 16*tables[t].minline);
- fprintf(f, "];\n");
- }
- i1 = i2;
- }
- fprintf(f, " return 1;\n");
- }
- fprintf(f, "}\n");
-
- }
-
- fprintf(f, "\n");
-
- {
- int uni2charset[0x10000];
- bool pages[0x100];
- int line[0x2000];
- int tableno;
- struct { int minline; int maxline; int usecount; const char* suffix; } tables[0x2000];
- bool need_c;
- bool fix_0000;
- int i, j, p, j1, j2, t;
-
- for (j = 0; j < 0x10000; j++)
- uni2charset[j] = 0;
- for (p = 0; p < 0x100; p++)
- pages[p] = false;
- for (i = 0; i < 0x100; i++) {
- j = charset2uni[i];
- if (j != 0xfffd) {
- uni2charset[j] = i;
- pages[j>>8] = true;
- }
- }
- for (j1 = 0; j1 < 0x2000; j1++) {
- bool all_invalid = true;
- bool all_identity = true;
- for (j2 = 0; j2 < 8; j2++) {
- j = 8*j1+j2;
- if (uni2charset[j] != 0)
- all_invalid = false;
- if (uni2charset[j] != j)
- all_identity = false;
- }
- if (all_invalid)
- line[j1] = -2;
- else if (all_identity)
- line[j1] = -1;
- else
- line[j1] = 0;
- }
- tableno = 0;
- for (j1 = 0; j1 < 0x2000; j1++) {
- if (line[j1] >= 0) {
- if (tableno > 0
- && ((j1 > 0 && line[j1-1] == tableno-1)
- || ((tables[tableno-1].maxline >> 5) == (j1 >> 5)
- && j1 - tables[tableno-1].maxline <= 8))) {
- line[j1] = tableno-1;
- tables[tableno-1].maxline = j1;
- } else {
- tableno++;
- line[j1] = tableno-1;
- tables[tableno-1].minline = tables[tableno-1].maxline = j1;
- }
- }
- }
- for (t = 0; t < tableno; t++) {
- tables[t].usecount = 0;
- j1 = 8*tables[t].minline;
- j2 = 8*(tables[t].maxline+1);
- for (j = j1; j < j2; j++)
- if (uni2charset[j] != 0)
- tables[t].usecount++;
- }
- for (t = 0, p = -1, i = 0; t < tableno; t++) {
- if (tables[t].usecount > 1) {
- char* s;
- if (p == tables[t].minline >> 5) {
- s = malloc(5+1);
- sprintf(s, "%02x_%d", p, ++i);
- } else {
- p = tables[t].minline >> 5;
- s = malloc(2+1);
- sprintf(s, "%02x", p);
- }
- tables[t].suffix = s;
- } else
- tables[t].suffix = NULL;
- }
- {
- p = -1;
- for (t = 0; t < tableno; t++)
- if (tables[t].usecount > 1) {
- p = 0;
- fprintf(f, "static const unsigned char %s_page%s[%d] = {\n", c_charsetname, tables[t].suffix, 8*(tables[t].maxline-tables[t].minline+1));
- for (j1 = tables[t].minline; j1 <= tables[t].maxline; j1++) {
- if ((j1 % 0x20) == 0 && j1 > tables[t].minline)
- fprintf(f, " /* 0x%04x */\n", 8*j1);
- fprintf(f, " ");
- for (j2 = 0; j2 < 8; j2++) {
- j = 8*j1+j2;
- fprintf(f, " 0x%02x,", uni2charset[j]);
- }
- fprintf(f, " /* 0x%02x-0x%02x */\n", 8*(j1 % 0x20), 8*(j1 % 0x20)+7);
- }
- fprintf(f, "};\n");
- }
- if (p >= 0)
- fprintf(f, "\n");
- }
- need_c = false;
- for (j1 = 0; j1 < 0x2000;) {
- t = line[j1];
- for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
- if (t >= 0)
- j2 = tables[t].maxline+1;
- if (!(t == -2 || (t == -1 && j1 == 0)))
- need_c = true;
- j1 = j2;
- }
- fix_0000 = false;
- fprintf(f, "static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", c_charsetname);
- fprintf(f, "{\n");
- if (need_c)
- fprintf(f, " unsigned char c = 0;\n");
- for (j1 = 0; j1 < 0x2000;) {
- t = line[j1];
- for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
- if (t >= 0) {
- if (j1 != tables[t].minline) abort();
- if (j2 > tables[t].maxline+1) abort();
- j2 = tables[t].maxline+1;
- }
- if (t == -2) {
- } else {
- if (j1 == 0)
- fprintf(f, " ");
- else
- fprintf(f, " else ");
- if (t >= 0 && tables[t].usecount == 0) abort();
- if (t >= 0 && tables[t].usecount == 1) {
- if (j2 != j1+1) abort();
- for (j = 8*j1; j < 8*j2; j++)
- if (uni2charset[j] != 0) {
- fprintf(f, "if (wc == 0x%04x)\n c = 0x%02x;\n", j, uni2charset[j]);
- break;
- }
- } else {
- if (j1 == 0) {
- fprintf(f, "if (wc < 0x%04x)", 8*j2);
- } else {
- fprintf(f, "if (wc >= 0x%04x && wc < 0x%04x)", 8*j1, 8*j2);
- }
- if (t == -1) {
- if (j1 == 0)
- /* If wc == 0, the function must return 1, not -1. */
- fprintf(f, " {\n *r = wc;\n return 1;\n }\n");
- else
- fprintf(f, "\n c = wc;\n");
- } else {
- fprintf(f, "\n c = %s_page%s[wc", c_charsetname, tables[t].suffix);
- if (tables[t].minline > 0)
- fprintf(f, "-0x%04x", 8*j1);
- fprintf(f, "];\n");
- if (j1 == 0 && uni2charset[0] == 0)
- /* If wc == 0, the function must return 1, not -1. */
- fix_0000 = true;
- }
- }
- }
- j1 = j2;
- }
- if (need_c) {
- if (fix_0000)
- fprintf(f, " if (c != 0 || wc == 0) {\n");
- else
- fprintf(f, " if (c != 0) {\n");
- fprintf(f, " *r = c;\n");
- fprintf(f, " return 1;\n");
- fprintf(f, " }\n");
- }
- fprintf(f, " return RET_ILSEQ;\n");
- fprintf(f, "}\n");
-
- }
-
- if (ferror(f) || fclose(f))
- exit(1);
- }
-
-#if 0
-
- int i1, i2, i3, i1_min, i1_max, j1, j2;
-
- i1_min = 16;
- i1_max = -1;
- for (i1 = 0; i1 < 16; i1++)
- for (i2 = 0; i2 < 16; i2++)
- if (charset2uni[16*i1+i2] != 0xfffd) {
- if (i1_min > i1) i1_min = i1;
- if (i1_max < i1) i1_max = i1;
- }
- printf("static const unsigned short %s_2uni[%d] = {\n",
- name, 16*(i1_max-i1_min+1));
- for (i1 = i1_min; i1 <= i1_max; i1++) {
- printf(" /""* 0x%02x *""/\n", 16*i1);
- for (i2 = 0; i2 < 2; i2++) {
- printf(" ");
- for (i3 = 0; i3 < 8; i3++) {
- if (i3 > 0) printf(" ");
- printf("0x%04x,", charset2uni[16*i1+8*i2+i3]);
- }
- printf("\n");
- }
- }
- printf("};\n");
- printf("\n");
-
- for (p = 0; p < 0x100; p++)
- pages[p] = 0;
- for (i = 0; i < 0x100; i++)
- if (charset2uni[i] != 0xfffd)
- pages[charset2uni[i]>>8] = 1;
- for (p = 0; p < 0x100; p++)
- if (pages[p]) {
- int j1_min = 32;
- int j1_max = -1;
- for (j1 = 0; j1 < 32; j1++)
- for (j2 = 0; j2 < 8; j2++)
- if (uni2charset[256*p+8*j1+j2] != 0) {
- if (j1_min > j1) j1_min = j1;
- if (j1_max < j1) j1_max = j1;
- }
- printf("static const unsigned char %s_page%02x[%d] = {\n",
- name, p, 8*(j1_max-j1_min+1));
- for (j1 = j1_min; j1 <= j1_max; j1++) {
- printf(" ");
- for (j2 = 0; j2 < 8; j2++)
- printf("0x%02x, ", uni2charset[256*p+8*j1+j2]);
- printf("/""* 0x%02x-0x%02x *""/\n", 8*j1, 8*j1+7);
- }
- printf("};\n");
- }
- printf("\n");
-
-}
-#endif
-
- exit(0);
-}
diff --git a/nx-X11/lib/X11/lcUniConv/ascii.h b/nx-X11/lib/X11/lcUniConv/ascii.h
deleted file mode 100644
index e32cf417e..000000000
--- a/nx-X11/lib/X11/lcUniConv/ascii.h
+++ /dev/null
@@ -1,25 +0,0 @@
-
-/*
- * ASCII
- */
-
-static int
-ascii_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
-{
- unsigned char c = *s;
- if (c < 0x80) {
- *pwc = (ucs4_t) c;
- return 1;
- }
- return RET_ILSEQ;
-}
-
-static int
-ascii_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
-{
- if (wc < 0x0080) {
- *r = wc;
- return 1;
- }
- return RET_ILSEQ;
-}
diff --git a/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c b/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
deleted file mode 100644
index f70fe5e11..000000000
--- a/nx-X11/lib/X11/lcUniConv/cjk_tab_to_h.c
+++ /dev/null
@@ -1,1071 +0,0 @@
-
-/*
- * Generates a CJK character set table from a .TXT table as found on
- * ftp.unicode.org or in the X nls directory.
- * Examples:
- *
- * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < gb2312
- * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < jis0208
- * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < ksc5601
- *
- * ./cjk_tab_to_h GB2312.1980-0 gb2312 > gb2312.h < GB2312.TXT
- * ./cjk_tab_to_h JISX0208.1983-0 jisx0208 > jisx0208.h < JIS0208.TXT
- * ./cjk_tab_to_h JISX0212.1990-0 jisx0212 > jisx0212.h < JIS0212.TXT
- * ./cjk_tab_to_h KSC5601.1987-0 ksc5601 > ksc5601.h < KSC5601.TXT
- * ./cjk_tab_to_h KSX1001.1992-0 ksc5601 > ksc5601.h < KSX1001.TXT
- *
- * ./cjk_tab_to_h BIG5 big5 > big5.h < BIG5.TXT
- *
- * ./cjk_tab_to_h JOHAB johab > johab.h < JOHAB.TXT
- *
- * ./cjk_tab_to_h BIG5HKSCS-0 big5hkscs >big5hkscs.h < BIG5HKSCS.TXT
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-
-typedef struct {
- int start;
- int end;
-} Block;
-
-typedef struct {
- int rows; /* number of possible values for the 1st byte */
- int cols; /* number of possible values for the 2nd byte */
- int (*row_byte) (int row); /* returns the 1st byte value for a given row */
- int (*col_byte) (int col); /* returns the 2nd byte value for a given col */
- int (*byte_row) (int byte); /* converts a 1st byte value to a row, else -1 */
- int (*byte_col) (int byte); /* converts a 2nd byte value to a col, else -1 */
- const char* check_row_expr; /* format string for 1st byte value checking */
- const char* check_col_expr; /* format string for 2nd byte value checking */
- const char* byte_row_expr; /* format string for 1st byte value to row */
- const char* byte_col_expr; /* format string for 2nd byte value to col */
- int** charset2uni; /* charset2uni[0..rows-1][0..cols-1] is valid */
- /* You'll understand the terms "row" and "col" when you buy Ken Lunde's book.
- Once a row is fixed, choosing a "col" is the same as choosing a "cell". */
- int* charsetpage; /* charsetpage[0..rows]: how large is a page for a row */
- int ncharsetblocks;
- Block* charsetblocks; /* blocks[0..nblocks-1] */
- int* uni2charset; /* uni2charset[0x0000..0xffff] */
-} Encoding;
-
-/*
- * Outputs the file title.
- */
-static void output_title (const char *charsetname)
-{
- printf("\n");
- printf("/*\n");
- printf(" * %s\n", charsetname);
- printf(" */\n");
- printf("\n");
-}
-
-/*
- * Reads the charset2uni table from standard input.
- */
-static void read_table (Encoding* enc)
-{
- int row, col, i, i1, i2, c, j;
-
- enc->charset2uni = malloc(enc->rows*sizeof(int*));
- for (row = 0; row < enc->rows; row++)
- enc->charset2uni[row] = malloc(enc->cols*sizeof(int));
-
- for (row = 0; row < enc->rows; row++)
- for (col = 0; col < enc->cols; col++)
- enc->charset2uni[row][col] = 0xfffd;
-
- c = getc(stdin);
- ungetc(c,stdin);
- if (c == '#') {
- /* Read a unicode.org style .TXT file. */
- for (;;) {
- c = getc(stdin);
- if (c == EOF)
- break;
- if (c == '\n' || c == ' ' || c == '\t')
- continue;
- if (c == '#') {
- do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
- continue;
- }
- ungetc(c,stdin);
- if (scanf("0x%x", &j) != 1)
- exit(1);
- i1 = j >> 8;
- i2 = j & 0xff;
- row = enc->byte_row(i1);
- col = enc->byte_col(i2);
- if (row < 0 || col < 0) {
- fprintf(stderr, "lost entry for %02x %02x\n", i1, i2);
- exit(1);
- }
- if (scanf(" 0x%x", &enc->charset2uni[row][col]) != 1)
- exit(1);
- }
- } else {
- /* Read a table of hexadecimal Unicode values. */
- for (i1 = 32; i1 < 132; i1++)
- for (i2 = 32; i2 < 132; i2++) {
- i = scanf("%x", &j);
- if (i == EOF)
- goto read_done;
- if (i != 1)
- exit(1);
- if (j < 0 || j == 0xffff)
- j = 0xfffd;
- if (j != 0xfffd) {
- if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) {
- fprintf(stderr, "lost entry at %02x %02x\n", i1, i2);
- exit (1);
- }
- enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j;
- }
- }
- read_done: ;
- }
-}
-
-/*
- * Computes the charsetpage[0..rows] array.
- */
-static void find_charset2uni_pages (Encoding* enc)
-{
- int row, col;
-
- enc->charsetpage = malloc((enc->rows+1)*sizeof(int));
-
- for (row = 0; row <= enc->rows; row++)
- enc->charsetpage[row] = 0;
-
- for (row = 0; row < enc->rows; row++) {
- int used = 0;
- for (col = 0; col < enc->cols; col++)
- if (enc->charset2uni[row][col] != 0xfffd)
- used = col+1;
- enc->charsetpage[row] = used;
- }
-}
-
-/*
- * Fills in nblocks and blocks.
- */
-static void find_charset2uni_blocks (Encoding* enc)
-{
- int n, row, lastrow;
-
- enc->charsetblocks = malloc(enc->rows*sizeof(Block));
-
- n = 0;
- for (row = 0; row < enc->rows; row++)
- if (enc->charsetpage[row] > 0 && (row == 0 || enc->charsetpage[row-1] == 0)) {
- for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++);
- enc->charsetblocks[n].start = row * enc->cols;
- enc->charsetblocks[n].end = lastrow * enc->cols + enc->charsetpage[lastrow];
- n++;
- }
- enc->ncharsetblocks = n;
-}
-
-/*
- * Outputs the charset to unicode table and function.
- */
-static void output_charset2uni (const char* name, Encoding* enc)
-{
- int row, col, lastrow, col_max, i, i1_min, i1_max;
-
- find_charset2uni_pages(enc);
-
- find_charset2uni_blocks(enc);
-
- for (row = 0; row < enc->rows; row++)
- if (enc->charsetpage[row] > 0) {
- if (row == 0 || enc->charsetpage[row-1] == 0) {
- /* Start a new block. */
- for (lastrow = row; enc->charsetpage[lastrow+1] > 0; lastrow++);
- printf("static const unsigned short %s_2uni_page%02x[%d] = {\n",
- name, enc->row_byte(row),
- (lastrow-row) * enc->cols + enc->charsetpage[lastrow]);
- }
- printf(" /""* 0x%02x *""/\n ", enc->row_byte(row));
- col_max = (enc->charsetpage[row+1] > 0 ? enc->cols : enc->charsetpage[row]);
- for (col = 0; col < col_max; col++) {
- printf(" 0x%04x,", enc->charset2uni[row][col]);
- if ((col % 8) == 7 && (col+1 < col_max)) printf("\n ");
- }
- printf("\n");
- if (enc->charsetpage[row+1] == 0) {
- /* End a block. */
- printf("};\n");
- }
- }
- printf("\n");
-
- printf("static int\n");
- printf("%s_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)\n", name);
- printf("{\n");
- printf(" unsigned char c1 = s[0];\n");
- printf(" if (");
- for (i = 0; i < enc->ncharsetblocks; i++) {
- i1_min = enc->row_byte(enc->charsetblocks[i].start / enc->cols);
- i1_max = enc->row_byte((enc->charsetblocks[i].end-1) / enc->cols);
- if (i > 0)
- printf(" || ");
- if (i1_min == i1_max)
- printf("(c1 == 0x%02x)", i1_min);
- else
- printf("(c1 >= 0x%02x && c1 <= 0x%02x)", i1_min, i1_max);
- }
- printf(") {\n");
- printf(" if (n >= 2) {\n");
- printf(" unsigned char c2 = s[1];\n");
- printf(" if (");
- printf(enc->check_col_expr, "c2");
- printf(") {\n");
- printf(" unsigned int i = %d * (", enc->cols);
- printf(enc->byte_row_expr, "c1");
- printf(") + (");
- printf(enc->byte_col_expr, "c2");
- printf(");\n");
- printf(" unsigned short wc = 0xfffd;\n");
- for (i = 0; i < enc->ncharsetblocks; i++) {
- printf(" ");
- if (i > 0)
- printf("} else ");
- if (i < enc->ncharsetblocks-1)
- printf("if (i < %d) ", enc->charsetblocks[i+1].start);
- printf("{\n");
- printf(" if (i < %d)\n", enc->charsetblocks[i].end);
- printf(" wc = %s_2uni_page%02x[i", name, enc->row_byte(enc->charsetblocks[i].start / enc->cols));
- if (enc->charsetblocks[i].start > 0)
- printf("-%d", enc->charsetblocks[i].start);
- printf("];\n");
- }
- printf(" }\n");
- printf(" if (wc != 0xfffd) {\n");
- printf(" *pwc = (ucs4_t) wc;\n");
- printf(" return 2;\n");
- printf(" }\n");
- printf(" }\n");
- printf(" return RET_ILSEQ;\n");
- printf(" }\n");
- printf(" return RET_TOOFEW(0);\n");
- printf(" }\n");
- printf(" return RET_ILSEQ;\n");
- printf("}\n");
- printf("\n");
-}
-
-/*
- * Computes the uni2charset[0x0000..0xffff] array.
- */
-static void invert (Encoding* enc)
-{
- int row, col, j;
-
- enc->uni2charset = malloc(0x10000*sizeof(int));
-
- for (j = 0; j < 0x10000; j++)
- enc->uni2charset[j] = 0;
-
- for (row = 0; row < enc->rows; row++)
- for (col = 0; col < enc->cols; col++) {
- j = enc->charset2uni[row][col];
- if (j != 0xfffd)
- enc->uni2charset[j] = 0x100 * enc->row_byte(row) + enc->col_byte(col);
- }
-}
-
-/*
- * Outputs the unicode to charset table and function, using a linear array.
- * (Suitable if the table is dense.)
- */
-static void output_uni2charset_dense (const char* name, Encoding* enc)
-{
- /* Like in 8bit_tab_to_h.c */
- bool pages[0x100];
- int line[0x2000];
- int tableno;
- struct { int minline; int maxline; int usecount; } tables[0x2000];
- bool first;
- int row, col, j, p, j1, j2, t;
-
- for (p = 0; p < 0x100; p++)
- pages[p] = false;
- for (row = 0; row < enc->rows; row++)
- for (col = 0; col < enc->cols; col++) {
- j = enc->charset2uni[row][col];
- if (j != 0xfffd)
- pages[j>>8] = true;
- }
- for (j1 = 0; j1 < 0x2000; j1++) {
- bool all_invalid = true;
- for (j2 = 0; j2 < 8; j2++) {
- j = 8*j1+j2;
- if (enc->uni2charset[j] != 0)
- all_invalid = false;
- }
- if (all_invalid)
- line[j1] = -1;
- else
- line[j1] = 0;
- }
- tableno = 0;
- for (j1 = 0; j1 < 0x2000; j1++) {
- if (line[j1] >= 0) {
- if (tableno > 0
- && ((j1 > 0 && line[j1-1] == tableno-1)
- || ((tables[tableno-1].maxline >> 5) == (j1 >> 5)
- && j1 - tables[tableno-1].maxline <= 8))) {
- line[j1] = tableno-1;
- tables[tableno-1].maxline = j1;
- } else {
- tableno++;
- line[j1] = tableno-1;
- tables[tableno-1].minline = tables[tableno-1].maxline = j1;
- }
- }
- }
- for (t = 0; t < tableno; t++) {
- tables[t].usecount = 0;
- j1 = 8*tables[t].minline;
- j2 = 8*(tables[t].maxline+1);
- for (j = j1; j < j2; j++)
- if (enc->uni2charset[j] != 0)
- tables[t].usecount++;
- }
- {
- p = -1;
- for (t = 0; t < tableno; t++)
- if (tables[t].usecount > 1) {
- p = tables[t].minline >> 5;
- printf("static const unsigned short %s_page%02x[%d] = {\n", name, p, 8*(tables[t].maxline-tables[t].minline+1));
- for (j1 = tables[t].minline; j1 <= tables[t].maxline; j1++) {
- if ((j1 % 0x20) == 0 && j1 > tables[t].minline)
- printf(" /* 0x%04x */\n", 8*j1);
- printf(" ");
- for (j2 = 0; j2 < 8; j2++) {
- j = 8*j1+j2;
- printf(" 0x%04x,", enc->uni2charset[j]);
- }
- printf(" /*0x%02x-0x%02x*/\n", 8*(j1 % 0x20), 8*(j1 % 0x20)+7);
- }
- printf("};\n");
- }
- if (p >= 0)
- printf("\n");
- }
- printf("static int\n%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
- printf("{\n");
- printf(" if (n >= 2) {\n");
- printf(" unsigned short c = 0;\n");
- first = true;
- for (j1 = 0; j1 < 0x2000;) {
- t = line[j1];
- for (j2 = j1; j2 < 0x2000 && line[j2] == t; j2++);
- if (t >= 0) {
- if (j1 != tables[t].minline) abort();
- if (j2 > tables[t].maxline+1) abort();
- j2 = tables[t].maxline+1;
- if (first)
- printf(" ");
- else
- printf(" else ");
- first = false;
- if (tables[t].usecount == 0) abort();
- if (tables[t].usecount == 1) {
- if (j2 != j1+1) abort();
- for (j = 8*j1; j < 8*j2; j++)
- if (enc->uni2charset[j] != 0) {
- printf("if (wc == 0x%04x)\n c = 0x%02x;\n", j, enc->uni2charset[j]);
- break;
- }
- } else {
- if (j1 == 0) {
- printf("if (wc < 0x%04x)", 8*j2);
- } else {
- printf("if (wc >= 0x%04x && wc < 0x%04x)", 8*j1, 8*j2);
- }
- printf("\n c = %s_page%02x[wc", name, j1 >> 5);
- if (tables[t].minline > 0)
- printf("-0x%04x", 8*j1);
- printf("];\n");
- }
- }
- j1 = j2;
- }
- printf(" if (c != 0) {\n");
- printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n");
- printf(" return 2;\n");
- printf(" }\n");
- printf(" return RET_ILSEQ;\n");
- printf(" }\n");
- printf(" return RET_TOOSMALL;\n");
- printf("}\n");
-}
-
-/*
- * Outputs the unicode to charset table and function, using a packed array.
- * (Suitable if the table is sparse.)
- */
-static void output_uni2charset_sparse (const char* name, Encoding* enc)
-{
- bool pages[0x100];
- Block pageblocks[0x100]; int npageblocks;
- int indx2charset[0x10000];
- int summary_indx[0x1000];
- int summary_used[0x1000];
- int i, row, col, j, p, j1, j2, indx;
-
- /* Fill pages[0x100]. */
- for (p = 0; p < 0x100; p++)
- pages[p] = false;
- for (row = 0; row < enc->rows; row++)
- for (col = 0; col < enc->cols; col++) {
- j = enc->charset2uni[row][col];
- if (j != 0xfffd)
- pages[j>>8] = true;
- }
-
-#if 0
- for (p = 0; p < 0x100; p++)
- if (pages[p]) {
- printf("static const unsigned short %s_page%02x[256] = {\n", name, p);
- for (j1 = 0; j1 < 32; j1++) {
- printf(" ");
- for (j2 = 0; j2 < 8; j2++)
- printf("0x%04x, ", enc->uni2charset[256*p+8*j1+j2]);
- printf("/""*0x%02x-0x%02x*""/\n", 8*j1, 8*j1+7);
- }
- printf("};\n");
- }
- printf("\n");
-#endif
-
- /* Fill summary_indx[] and summary_used[]. */
- indx = 0;
- for (j1 = 0; j1 < 0x1000; j1++) {
- summary_indx[j1] = indx;
- summary_used[j1] = 0;
- for (j2 = 0; j2 < 16; j2++) {
- j = 16*j1+j2;
- if (enc->uni2charset[j] != 0) {
- indx2charset[indx++] = enc->uni2charset[j];
- summary_used[j1] |= (1 << j2);
- }
- }
- }
-
- /* Fill npageblocks and pageblocks[]. */
- npageblocks = 0;
- for (p = 0; p < 0x100; ) {
- if (pages[p] && (p == 0 || !pages[p-1])) {
- pageblocks[npageblocks].start = 16*p;
- do p++; while (p < 0x100 && pages[p]);
- j1 = 16*p;
- while (summary_used[j1-1] == 0) j1--;
- pageblocks[npageblocks].end = j1;
- npageblocks++;
- } else
- p++;
- }
-
- printf("static const unsigned short %s_2charset[%d] = {\n", name, indx);
- for (i = 0; i < indx; ) {
- if ((i % 8) == 0) printf(" ");
- printf(" 0x%04x,", indx2charset[i]);
- i++;
- if ((i % 8) == 0 || i == indx) printf("\n");
- }
- printf("};\n");
- printf("\n");
- for (i = 0; i < npageblocks; i++) {
- printf("static const Summary16 %s_uni2indx_page%02x[%d] = {\n", name,
- pageblocks[i].start/16, pageblocks[i].end-pageblocks[i].start);
- for (j1 = pageblocks[i].start; j1 < pageblocks[i].end; ) {
- if (((16*j1) % 0x100) == 0) printf(" /""* 0x%04x *""/\n", 16*j1);
- if ((j1 % 4) == 0) printf(" ");
- printf(" { %4d, 0x%04x },", summary_indx[j1], summary_used[j1]);
- j1++;
- if ((j1 % 4) == 0 || j1 == pageblocks[i].end) printf("\n");
- }
- printf("};\n");
- }
- printf("\n");
-
- printf("static int\n");
- printf("%s_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)\n", name);
- printf("{\n");
- printf(" if (n >= 2) {\n");
- printf(" const Summary16 *summary = NULL;\n");
- for (i = 0; i < npageblocks; i++) {
- printf(" ");
- if (i > 0)
- printf("else ");
- printf("if (wc >= 0x%04x && wc < 0x%04x)\n",
- 16*pageblocks[i].start, 16*pageblocks[i].end);
- printf(" summary = &%s_uni2indx_page%02x[(wc>>4)", name,
- pageblocks[i].start/16);
- if (pageblocks[i].start > 0)
- printf("-0x%03x", pageblocks[i].start);
- printf("];\n");
- }
- printf(" if (summary) {\n");
- printf(" unsigned short used = summary->used;\n");
- printf(" unsigned int i = wc & 0x0f;\n");
- printf(" if (used & ((unsigned short) 1 << i)) {\n");
- printf(" unsigned short c;\n");
- printf(" /* Keep in `used' only the bits 0..i-1. */\n");
- printf(" used &= ((unsigned short) 1 << i) - 1;\n");
- printf(" /* Add `summary->indx' and the number of bits set in `used'. */\n");
- printf(" used = (used & 0x5555) + ((used & 0xaaaa) >> 1);\n");
- printf(" used = (used & 0x3333) + ((used & 0xcccc) >> 2);\n");
- printf(" used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);\n");
- printf(" used = (used & 0x00ff) + (used >> 8);\n");
- printf(" c = %s_2charset[summary->indx + used];\n", name);
- printf(" r[0] = (c >> 8); r[1] = (c & 0xff);\n");
- printf(" return 2;\n");
- printf(" }\n");
- printf(" }\n");
- printf(" return RET_ILSEQ;\n");
- printf(" }\n");
- printf(" return RET_TOOSMALL;\n");
- printf("}\n");
-}
-
-/* ISO-2022/EUC specifics */
-
-static int row_byte_normal (int row) { return 0x21+row; }
-static int col_byte_normal (int col) { return 0x21+col; }
-static int byte_row_normal (int byte) { return byte-0x21; }
-static int byte_col_normal (int byte) { return byte-0x21; }
-
-static void do_normal (const char* name)
-{
- Encoding enc;
-
- enc.rows = 94;
- enc.cols = 94;
- enc.row_byte = row_byte_normal;
- enc.col_byte = col_byte_normal;
- enc.byte_row = byte_row_normal;
- enc.byte_col = byte_col_normal;
- enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.byte_row_expr = "%1$s - 0x21";
- enc.byte_col_expr = "%1$s - 0x21";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* Note: On first sight, the jisx0212_2charset[] table seems to be in order,
- starting from the charset=0x3021/uni=0x4e02 pair. But it's only mostly in
- order. There are 75 out-of-order values, scattered all throughout the table.
- */
-
-static void do_normal_only_charset2uni (const char* name)
-{
- Encoding enc;
-
- enc.rows = 94;
- enc.cols = 94;
- enc.row_byte = row_byte_normal;
- enc.col_byte = col_byte_normal;
- enc.byte_row = byte_row_normal;
- enc.byte_col = byte_col_normal;
- enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.byte_row_expr = "%1$s - 0x21";
- enc.byte_col_expr = "%1$s - 0x21";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
-}
-
-/* CNS 11643 specifics - trick to put two tables into one */
-
-static int row_byte_cns11643 (int row) {
- return 0x100 * (row / 94) + (row % 94) + 0x21;
-}
-static int byte_row_cns11643 (int byte) {
- return (byte >= 0x100 && byte < 0x200 ? byte-0x121 :
- byte >= 0x200 && byte < 0x300 ? byte-0x221+94 :
- byte >= 0x300 && byte < 0x400 ? byte-0x321+2*94 :
- -1);
-}
-
-static void do_cns11643_only_uni2charset (const char* name)
-{
- Encoding enc;
- int j, x;
-
- enc.rows = 3*94;
- enc.cols = 94;
- enc.row_byte = row_byte_cns11643;
- enc.col_byte = col_byte_normal;
- enc.byte_row = byte_row_cns11643;
- enc.byte_col = byte_col_normal;
- enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.byte_row_expr = "%1$s - 0x21";
- enc.byte_col_expr = "%1$s - 0x21";
-
- read_table(&enc);
- invert(&enc);
- /* Move the 2 plane bits into the unused bits 15 and 7. */
- for (j = 0; j < 0x10000; j++) {
- x = enc.uni2charset[j];
- if (x != 0) {
- if (x & 0x8080) abort();
- switch (x >> 16) {
- case 0: /* plane 1 */ x = (x & 0xffff) | 0x0000; break;
- case 1: /* plane 2 */ x = (x & 0xffff) | 0x0080; break;
- case 2: /* plane 3 */ x = (x & 0xffff) | 0x8000; break;
- default: abort();
- }
- enc.uni2charset[j] = x;
- }
- }
- output_uni2charset_sparse(name,&enc);
-}
-
-/* GBK specifics */
-
-static int row_byte_gbk1 (int row) {
- return 0x81+row;
-}
-static int col_byte_gbk1 (int col) {
- return (col >= 0x3f ? 0x41 : 0x40) + col;
-}
-static int byte_row_gbk1 (int byte) {
- if (byte >= 0x81 && byte < 0xff)
- return byte-0x81;
- else
- return -1;
-}
-static int byte_col_gbk1 (int byte) {
- if (byte >= 0x40 && byte < 0x7f)
- return byte-0x40;
- else if (byte >= 0x80 && byte < 0xff)
- return byte-0x41;
- else
- return -1;
-}
-
-static void do_gbk1 (const char* name)
-{
- Encoding enc;
-
- enc.rows = 126;
- enc.cols = 190;
- enc.row_byte = row_byte_gbk1;
- enc.col_byte = col_byte_gbk1;
- enc.byte_row = byte_row_gbk1;
- enc.byte_col = byte_col_gbk1;
- enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0x81";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_dense(name,&enc);
-}
-
-static void do_gbk1_only_charset2uni (const char* name)
-{
- Encoding enc;
-
- enc.rows = 126;
- enc.cols = 190;
- enc.row_byte = row_byte_gbk1;
- enc.col_byte = col_byte_gbk1;
- enc.byte_row = byte_row_gbk1;
- enc.byte_col = byte_col_gbk1;
- enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0x81";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
-}
-
-static int row_byte_gbk2 (int row) {
- return 0x81+row;
-}
-static int col_byte_gbk2 (int col) {
- return (col >= 0x3f ? 0x41 : 0x40) + col;
-}
-static int byte_row_gbk2 (int byte) {
- if (byte >= 0x81 && byte < 0xff)
- return byte-0x81;
- else
- return -1;
-}
-static int byte_col_gbk2 (int byte) {
- if (byte >= 0x40 && byte < 0x7f)
- return byte-0x40;
- else if (byte >= 0x80 && byte < 0xa1)
- return byte-0x41;
- else
- return -1;
-}
-
-static void do_gbk2_only_charset2uni (const char* name)
-{
- Encoding enc;
-
- enc.rows = 126;
- enc.cols = 96;
- enc.row_byte = row_byte_gbk2;
- enc.col_byte = col_byte_gbk2;
- enc.byte_row = byte_row_gbk2;
- enc.byte_col = byte_col_gbk2;
- enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xa1)";
- enc.byte_row_expr = "%1$s - 0x81";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
-}
-
-static void do_gbk1_only_uni2charset (const char* name)
-{
- Encoding enc;
-
- enc.rows = 126;
- enc.cols = 190;
- enc.row_byte = row_byte_gbk1;
- enc.col_byte = col_byte_gbk1;
- enc.byte_row = byte_row_gbk1;
- enc.byte_col = byte_col_gbk1;
- enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0x81";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
-
- read_table(&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* KSC 5601 specifics */
-
-/*
- * Reads the charset2uni table from standard input.
- */
-static void read_table_ksc5601 (Encoding* enc)
-{
- int row, col, i, i1, i2, c, j;
-
- enc->charset2uni = malloc(enc->rows*sizeof(int*));
- for (row = 0; row < enc->rows; row++)
- enc->charset2uni[row] = malloc(enc->cols*sizeof(int));
-
- for (row = 0; row < enc->rows; row++)
- for (col = 0; col < enc->cols; col++)
- enc->charset2uni[row][col] = 0xfffd;
-
- c = getc(stdin);
- ungetc(c,stdin);
- if (c == '#') {
- /* Read a unicode.org style .TXT file. */
- for (;;) {
- c = getc(stdin);
- if (c == EOF)
- break;
- if (c == '\n' || c == ' ' || c == '\t')
- continue;
- if (c == '#') {
- do { c = getc(stdin); } while (!(c == EOF || c == '\n'));
- continue;
- }
- ungetc(c,stdin);
- if (scanf("0x%x", &j) != 1)
- exit(1);
- i1 = j >> 8;
- i2 = j & 0xff;
- if (scanf(" 0x%x", &j) != 1)
- exit(1);
- /* Take only the range covered by KS C 5601.1987-0 = KS C 5601.1989-0
- = KS X 1001.1992, ignore the rest. */
- if (!(i1 >= 128+33 && i1 < 128+127 && i2 >= 128+33 && i2 < 128+127))
- continue; /* KSC5601 specific */
- i1 &= 0x7f; /* KSC5601 specific */
- i2 &= 0x7f; /* KSC5601 specific */
- row = enc->byte_row(i1);
- col = enc->byte_col(i2);
- if (row < 0 || col < 0) {
- fprintf(stderr, "lost entry for %02x %02x\n", i1, i2);
- exit(1);
- }
- enc->charset2uni[row][col] = j;
- }
- } else {
- /* Read a table of hexadecimal Unicode values. */
- for (i1 = 33; i1 < 127; i1++)
- for (i2 = 33; i2 < 127; i2++) {
- i = scanf("%x", &j);
- if (i == EOF)
- goto read_done;
- if (i != 1)
- exit(1);
- if (j < 0 || j == 0xffff)
- j = 0xfffd;
- if (j != 0xfffd) {
- if (enc->byte_row(i1) < 0 || enc->byte_col(i2) < 0) {
- fprintf(stderr, "lost entry at %02x %02x\n", i1, i2);
- exit (1);
- }
- enc->charset2uni[enc->byte_row(i1)][enc->byte_col(i2)] = j;
- }
- }
- read_done: ;
- }
-}
-
-static void do_ksc5601 (const char* name)
-{
- Encoding enc;
-
- enc.rows = 94;
- enc.cols = 94;
- enc.row_byte = row_byte_normal;
- enc.col_byte = col_byte_normal;
- enc.byte_row = byte_row_normal;
- enc.byte_col = byte_col_normal;
- enc.check_row_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.check_col_expr = "%1$s >= 0x21 && %1$s < 0x7f";
- enc.byte_row_expr = "%1$s - 0x21";
- enc.byte_col_expr = "%1$s - 0x21";
-
- read_table_ksc5601(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* Big5 specifics */
-
-static int row_byte_big5 (int row) {
- return 0xa1+row;
-}
-static int col_byte_big5 (int col) {
- return (col >= 0x3f ? 0x62 : 0x40) + col;
-}
-static int byte_row_big5 (int byte) {
- if (byte >= 0xa1 && byte < 0xff)
- return byte-0xa1;
- else
- return -1;
-}
-static int byte_col_big5 (int byte) {
- if (byte >= 0x40 && byte < 0x7f)
- return byte-0x40;
- else if (byte >= 0xa1 && byte < 0xff)
- return byte-0x62;
- else
- return -1;
-}
-
-static void do_big5 (const char* name)
-{
- Encoding enc;
-
- enc.rows = 94;
- enc.cols = 157;
- enc.row_byte = row_byte_big5;
- enc.col_byte = col_byte_big5;
- enc.byte_row = byte_row_big5;
- enc.byte_col = byte_col_big5;
- enc.check_row_expr = "%1$s >= 0xa1 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0xa1 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0xa1";
- enc.byte_col_expr = "%1$s - (%1$s >= 0xa1 ? 0x62 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* Big5-HKSCS specifics */
-
-static int row_byte_big5hkscs (int row) {
- return 0x81+row;
-}
-static int col_byte_big5hkscs (int col) {
- return (col >= 0x3f ? 0x62 : 0x40) + col;
-}
-static int byte_row_big5hkscs (int byte) {
- if (byte >= 0x81 && byte < 0xff)
- return byte-0x81;
- else
- return -1;
-}
-static int byte_col_big5hkscs (int byte) {
- if (byte >= 0x40 && byte < 0x7f)
- return byte-0x40;
- else if (byte >= 0xa1 && byte < 0xff)
- return byte-0x62;
- else
- return -1;
-}
-
-static void do_big5hkscs (const char* name)
-{
- Encoding enc;
-
- enc.rows = 126;
- enc.cols = 157;
- enc.row_byte = row_byte_big5hkscs;
- enc.col_byte = col_byte_big5hkscs;
- enc.byte_row = byte_row_big5hkscs;
- enc.byte_col = byte_col_big5hkscs;
- enc.check_row_expr = "%1$s >= 0x81 && %1$s < 0xff";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0xa1 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0x81";
- enc.byte_col_expr = "%1$s - (%1$s >= 0xa1 ? 0x62 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* Johab Hangul specifics */
-
-static int row_byte_johab_hangul (int row) {
- return 0x84+row;
-}
-static int col_byte_johab_hangul (int col) {
- return (col >= 0x3e ? 0x43 : 0x41) + col;
-}
-static int byte_row_johab_hangul (int byte) {
- if (byte >= 0x84 && byte < 0xd4)
- return byte-0x84;
- else
- return -1;
-}
-static int byte_col_johab_hangul (int byte) {
- if (byte >= 0x41 && byte < 0x7f)
- return byte-0x41;
- else if (byte >= 0x81 && byte < 0xff)
- return byte-0x43;
- else
- return -1;
-}
-
-static void do_johab_hangul (const char* name)
-{
- Encoding enc;
-
- enc.rows = 80;
- enc.cols = 188;
- enc.row_byte = row_byte_johab_hangul;
- enc.col_byte = col_byte_johab_hangul;
- enc.byte_row = byte_row_johab_hangul;
- enc.byte_col = byte_col_johab_hangul;
- enc.check_row_expr = "%1$s >= 0x84 && %1$s < 0xd4";
- enc.check_col_expr = "(%1$s >= 0x41 && %1$s < 0x7f) || (%1$s >= 0x81 && %1$s < 0xff)";
- enc.byte_row_expr = "%1$s - 0x84";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x81 ? 0x43 : 0x41)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_dense(name,&enc);
-}
-
-/* SJIS specifics */
-
-static int row_byte_sjis (int row) {
- return (row >= 0x1f ? 0xc1 : 0x81) + row;
-}
-static int col_byte_sjis (int col) {
- return (col >= 0x3f ? 0x41 : 0x40) + col;
-}
-static int byte_row_sjis (int byte) {
- if (byte >= 0x81 && byte < 0xa0)
- return byte-0x81;
- else if (byte >= 0xe0)
- return byte-0xc1;
- else
- return -1;
-}
-static int byte_col_sjis (int byte) {
- if (byte >= 0x40 && byte < 0x7f)
- return byte-0x40;
- else if (byte >= 0x80 && byte < 0xfd)
- return byte-0x41;
- else
- return -1;
-}
-
-static void do_sjis (const char* name)
-{
- Encoding enc;
-
- enc.rows = 94;
- enc.cols = 188;
- enc.row_byte = row_byte_sjis;
- enc.col_byte = col_byte_sjis;
- enc.byte_row = byte_row_sjis;
- enc.byte_col = byte_col_sjis;
- enc.check_row_expr = "(%1$s >= 0x81 && %1$s < 0xa0) || (%1$s >= 0xe0)";
- enc.check_col_expr = "(%1$s >= 0x40 && %1$s < 0x7f) || (%1$s >= 0x80 && %1$s < 0xfd)";
- enc.byte_row_expr = "%1$s - (%1$s >= 0xe0 ? 0xc1 : 0x81)";
- enc.byte_col_expr = "%1$s - (%1$s >= 0x80 ? 0x41 : 0x40)";
-
- read_table(&enc);
- output_charset2uni(name,&enc);
- invert(&enc); output_uni2charset_sparse(name,&enc);
-}
-
-/* Main program */
-
-int main (int argc, char *argv[])
-{
- const char* charsetname;
- const char* name;
-
- if (argc != 3)
- exit(1);
- charsetname = argv[1];
- name = argv[2];
-
- output_title(charsetname);
-
- if (!strcmp(name,"gb2312") || !strcmp(name,"gb12345ext")
- || !strcmp(name,"jisx0208") || !strcmp(name,"jisx0212"))
- do_normal(name);
- else if (!strcmp(name,"cns11643_1") || !strcmp(name,"cns11643_2")
- || !strcmp(name,"cns11643_3"))
- do_normal_only_charset2uni(name);
- else if (!strcmp(name,"cns11643_inv"))
- do_cns11643_only_uni2charset(name);
- else if (!strcmp(name,"gbkext1"))
- do_gbk1_only_charset2uni(name);
- else if (!strcmp(name,"gbkext2"))
- do_gbk2_only_charset2uni(name);
- else if (!strcmp(name,"gbkext_inv"))
- do_gbk1_only_uni2charset(name);
- else if (!strcmp(name,"cp936ext"))
- do_gbk1(name);
- else if (!strcmp(name,"ksc5601"))
- do_ksc5601(name);
- else if (!strcmp(name,"big5") || !strcmp(name,"cp950ext"))
- do_big5(name);
- else if (!strcmp(name,"big5hkscs"))
- do_big5hkscs(name);
- else if (!strcmp(name,"johab_hangul"))
- do_johab_hangul(name);
- else if (!strcmp(name,"cp932ext"))
- do_sjis(name);
- else
- exit(1);
-
- return 0;
-}