From bfb19bed915a30b5542fe8fee4e91151f25ec3b9 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 9 Jul 2010 14:19:56 +0000 Subject: git update 9/7/2010 --- libX11/src/Makefile.am | 8 +- libX11/src/StrKeysym.c | 327 +++++++++++++------------ libX11/src/XKeysymDB | 380 ----------------------------- libX11/src/util/makekeys.c | 593 ++++++++++++++++++++++++--------------------- 4 files changed, 491 insertions(+), 817 deletions(-) delete mode 100644 libX11/src/XKeysymDB (limited to 'libX11/src') diff --git a/libX11/src/Makefile.am b/libX11/src/Makefile.am index 3864bfaaa..455650c58 100644 --- a/libX11/src/Makefile.am +++ b/libX11/src/Makefile.am @@ -341,7 +341,7 @@ libX11_la_SOURCES+=UIThrStubs.c endif x11datadir = @X11_DATADIR@ -x11data_DATA = XKeysymDB XErrorDB +x11data_DATA = XErrorDB EXTRA_DIST = \ $(x11data_DATA) \ @@ -414,10 +414,10 @@ endif MAKE_LINT_LIB # Building ks_tables.h requires the makekeys utility # -KEYSYMDEF=@KEYSYMDEF@ +KEYSYMDEFS=@KEYSYMDEFS@ -ks_tables.h: $(KEYSYMDEF) $(top_builddir)/src/util/makekeys$(EXEEXT) - $(top_builddir)/src/util/makekeys < $(KEYSYMDEF) > ks_tables_h +ks_tables.h: $(KEYSYMDEFS) $(top_builddir)/src/util/makekeys$(EXEEXT) + $(top_builddir)/src/util/makekeys $(KEYSYMDEFS) > ks_tables_h mv ks_tables_h $@ $(top_builddir)/src/util/makekeys$(EXEEXT): force diff --git a/libX11/src/StrKeysym.c b/libX11/src/StrKeysym.c index fb507458f..8fb384505 100644 --- a/libX11/src/StrKeysym.c +++ b/libX11/src/StrKeysym.c @@ -1,156 +1,171 @@ -/* - -Copyright 1985, 1987, 1990, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include "Xlibint.h" -#include -#include -#include "Xresinternal.h" - -#define NEEDKTABLE -#include "ks_tables.h" -#include "Key.h" - -#ifndef KEYSYMDB -#ifndef XKEYSYMDB -#define KEYSYMDB "/usr/lib/X11/XKeysymDB" -#else -#define KEYSYMDB XKEYSYMDB -#endif -#endif - -static Bool initialized; -static XrmDatabase keysymdb; -static XrmQuark Qkeysym[2]; - -XrmDatabase -_XInitKeysymDB(void) -{ - if (!initialized) - { - const char *dbname; - - XrmInitialize(); - /* use and name of this env var is not part of the standard */ - /* implementation-dependent feature */ - dbname = getenv("XKEYSYMDB"); - if (!dbname) - dbname = KEYSYMDB; - keysymdb = XrmGetFileDatabase(dbname); - if (keysymdb) - Qkeysym[0] = XrmStringToQuark("Keysym"); - initialized = True; - } - return keysymdb; -} - -KeySym -XStringToKeysym(_Xconst char *s) -{ - register int i, n; - int h; - register Signature sig = 0; - register const char *p = s; - register int c; - register int idx; - const unsigned char *entry; - unsigned char sig1, sig2; - KeySym val; - - while ((c = *p++)) - sig = (sig << 1) + c; - i = sig % KTABLESIZE; - h = i + 1; - sig1 = (sig >> 8) & 0xff; - sig2 = sig & 0xff; - n = KMAXHASH; - while ((idx = hashString[i])) - { - entry = &_XkeyTable[idx]; - if ((entry[0] == sig1) && (entry[1] == sig2) && - !strcmp(s, (char *)entry + 6)) - { - val = (entry[2] << 24) | (entry[3] << 16) | - (entry[4] << 8) | entry[5]; - if (!val) - val = XK_VoidSymbol; - return val; - } - if (!--n) - break; - i += h; - if (i >= KTABLESIZE) - i -= KTABLESIZE; - } - - if (!initialized) - (void)_XInitKeysymDB(); - if (keysymdb) - { - XrmValue result; - XrmRepresentation from_type; - char c; - XrmQuark names[2]; - - names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False); - names[1] = NULLQUARK; - (void)XrmQGetResource(keysymdb, names, Qkeysym, &from_type, &result); - if (result.addr && (result.size > 1)) - { - val = 0; - for (i = 0; i < result.size - 1; i++) - { - c = ((char *)result.addr)[i]; - if ('0' <= c && c <= '9') val = (val<<4)+c-'0'; - else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10; - else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10; - else return NoSymbol; - } - return val; - } - } - - if (*s == 'U') { - val = 0; - for (p = &s[1]; *p; p++) { - c = *p; - if ('0' <= c && c <= '9') val = (val<<4)+c-'0'; - else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10; - else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10; - else return NoSymbol; - if (val > 0x10ffff) - return NoSymbol; - } - if (val < 0x20 || (val > 0x7e && val < 0xa0)) - return NoSymbol; - if (val < 0x100) - return val; - return val | 0x01000000; - } - return NoSymbol; -} +/* + +Copyright 1985, 1987, 1990, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall not be +used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization from The Open Group. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "Xlibint.h" +#include +#include +#include "Xresinternal.h" + +#define NEEDKTABLE +#include "ks_tables.h" +#include "Key.h" + +#ifndef KEYSYMDB +#ifndef XKEYSYMDB +#define KEYSYMDB "/usr/lib/X11/XKeysymDB" +#else +#define KEYSYMDB XKEYSYMDB +#endif +#endif + +static Bool initialized; +static XrmDatabase keysymdb; +static XrmQuark Qkeysym[2]; + +XrmDatabase +_XInitKeysymDB(void) +{ + if (!initialized) + { + const char *dbname; + + XrmInitialize(); + /* use and name of this env var is not part of the standard */ + /* implementation-dependent feature */ + dbname = getenv("XKEYSYMDB"); + if (!dbname) + dbname = KEYSYMDB; + keysymdb = XrmGetFileDatabase(dbname); + if (keysymdb) + Qkeysym[0] = XrmStringToQuark("Keysym"); + initialized = True; + } + return keysymdb; +} + +KeySym +XStringToKeysym(_Xconst char *s) +{ + register int i, n; + int h; + register Signature sig = 0; + register const char *p = s; + register int c; + register int idx; + const unsigned char *entry; + unsigned char sig1, sig2; + KeySym val; + + while ((c = *p++)) + sig = (sig << 1) + c; + i = sig % KTABLESIZE; + h = i + 1; + sig1 = (sig >> 8) & 0xff; + sig2 = sig & 0xff; + n = KMAXHASH; + while ((idx = hashString[i])) + { + entry = &_XkeyTable[idx]; + if ((entry[0] == sig1) && (entry[1] == sig2) && + !strcmp(s, (char *)entry + 6)) + { + val = (entry[2] << 24) | (entry[3] << 16) | + (entry[4] << 8) | entry[5]; + if (!val) + val = XK_VoidSymbol; + return val; + } + if (!--n) + break; + i += h; + if (i >= KTABLESIZE) + i -= KTABLESIZE; + } + + if (!initialized) + (void)_XInitKeysymDB(); + if (keysymdb) + { + XrmValue result; + XrmRepresentation from_type; + char c; + XrmQuark names[2]; + + names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False); + names[1] = NULLQUARK; + (void)XrmQGetResource(keysymdb, names, Qkeysym, &from_type, &result); + if (result.addr && (result.size > 1)) + { + val = 0; + for (i = 0; i < result.size - 1; i++) + { + c = ((char *)result.addr)[i]; + if ('0' <= c && c <= '9') val = (val<<4)+c-'0'; + else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10; + else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10; + else return NoSymbol; + } + return val; + } + } + + if (*s == 'U') { + val = 0; + for (p = &s[1]; *p; p++) { + c = *p; + if ('0' <= c && c <= '9') val = (val<<4)+c-'0'; + else if ('a' <= c && c <= 'f') val = (val<<4)+c-'a'+10; + else if ('A' <= c && c <= 'F') val = (val<<4)+c-'A'+10; + else return NoSymbol; + if (val > 0x10ffff) + return NoSymbol; + } + if (val < 0x20 || (val > 0x7e && val < 0xa0)) + return NoSymbol; + if (val < 0x100) + return val; + return val | 0x01000000; + } + + /* Stupid inconsistency between the headers and XKeysymDB: the former has + * no separating underscore, while some XF86* syms in the latter did. + * As a last ditch effort, try without. */ + if (strncmp(s, "XF86_", 5) == 0) { + KeySym ret; + char *tmp = strdup(s); + if (!tmp) + return NoSymbol; + memmove(&tmp[4], &tmp[5], strlen(s) - 5 + 1); + ret = XStringToKeysym(tmp); + free(tmp); + return ret; + } + + return NoSymbol; +} diff --git a/libX11/src/XKeysymDB b/libX11/src/XKeysymDB deleted file mode 100644 index 45d892971..000000000 --- a/libX11/src/XKeysymDB +++ /dev/null @@ -1,380 +0,0 @@ -! Copyright 1993 Massachusetts Institute of Technology -! -! Permission to use, copy, modify, distribute, and sell this software and -! its documentation for any purpose is hereby granted without fee, provided -! that the above copyright notice appear in all copies and that both that -! copyright notice and this permission notice appear in supporting -! documentation, and that the name of M.I.T. not be used in advertising or -! publicity pertaining to distribution of the software without specific, -! written prior permission. M.I.T. makes no representations about the -! suitability of this software for any purpose. It is provided "as is" -! without express or implied warranty. -! - -hpmute_acute :100000A8 -hpmute_grave :100000A9 -hpmute_asciicircum :100000AA -hpmute_diaeresis :100000AB -hpmute_asciitilde :100000AC -hplira :100000AF -hpguilder :100000BE -hpYdiaeresis :100000EE -hpIO :100000EE -hplongminus :100000F6 -hpblock :100000FC -apLineDel :1000FF00 -apCharDel :1000FF01 -apCopy :1000FF02 -apCut :1000FF03 -apPaste :1000FF04 -apMove :1000FF05 -apGrow :1000FF06 -apCmd :1000FF07 -apShell :1000FF08 -apLeftBar :1000FF09 -apRightBar :1000FF0A -apLeftBox :1000FF0B -apRightBox :1000FF0C -apUpBox :1000FF0D -apDownBox :1000FF0E -apPop :1000FF0F -apRead :1000FF10 -apEdit :1000FF11 -apSave :1000FF12 -apExit :1000FF13 -apRepeat :1000FF14 -hpModelock1 :1000FF48 -hpModelock2 :1000FF49 -hpReset :1000FF6C -hpSystem :1000FF6D -hpUser :1000FF6E -hpClearLine :1000FF6F -hpInsertLine :1000FF70 -hpDeleteLine :1000FF71 -hpInsertChar :1000FF72 -hpDeleteChar :1000FF73 -hpBackTab :1000FF74 -hpKP_BackTab :1000FF75 -apKP_parenleft :1000FFA8 -apKP_parenright :1000FFA9 - -I2ND_FUNC_L :10004001 -I2ND_FUNC_R :10004002 -IREMOVE :10004003 -IREPEAT :10004004 -IA1 :10004101 -IA2 :10004102 -IA3 :10004103 -IA4 :10004104 -IA5 :10004105 -IA6 :10004106 -IA7 :10004107 -IA8 :10004108 -IA9 :10004109 -IA10 :1000410A -IA11 :1000410B -IA12 :1000410C -IA13 :1000410D -IA14 :1000410E -IA15 :1000410F -IB1 :10004201 -IB2 :10004202 -IB3 :10004203 -IB4 :10004204 -IB5 :10004205 -IB6 :10004206 -IB7 :10004207 -IB8 :10004208 -IB9 :10004209 -IB10 :1000420A -IB11 :1000420B -IB12 :1000420C -IB13 :1000420D -IB14 :1000420E -IB15 :1000420F -IB16 :10004210 - -DRemove :1000FF00 -Dring_accent :1000FEB0 -Dcircumflex_accent :1000FE5E -Dcedilla_accent :1000FE2C -Dacute_accent :1000FE27 -Dgrave_accent :1000FE60 -Dtilde :1000FE7E -Ddiaeresis :1000FE22 - -osfCopy :1004FF02 -osfCut :1004FF03 -osfPaste :1004FF04 -osfBackTab :1004FF07 -osfBackSpace :1004FF08 -osfClear :1004FF0B -osfEscape :1004FF1B -osfAddMode :1004FF31 -osfPrimaryPaste :1004FF32 -osfQuickPaste :1004FF33 -osfPageLeft :1004FF40 -osfPageUp :1004FF41 -osfPageDown :1004FF42 -osfPageRight :1004FF43 -osfActivate :1004FF44 -osfMenuBar :1004FF45 -osfLeft :1004FF51 -osfUp :1004FF52 -osfRight :1004FF53 -osfDown :1004FF54 -osfPrior :1004FF55 -osfNext :1004FF56 -osfEndLine :1004FF57 -osfBeginLine :1004FF58 -osfEndData :1004FF59 -osfBeginData :1004FF5A -osfPrevMenu :1004FF5B -osfNextMenu :1004FF5C -osfPrevField :1004FF5D -osfNextField :1004FF5E -osfSelect :1004FF60 -osfInsert :1004FF63 -osfUndo :1004FF65 -osfMenu :1004FF67 -osfCancel :1004FF69 -osfHelp :1004FF6A -osfSelectAll :1004FF71 -osfDeselectAll :1004FF72 -osfReselect :1004FF73 -osfExtend :1004FF74 -osfRestore :1004FF78 -osfSwitchDirection :1004FF7E -osfPriorMinor :1004FFF5 -osfNextMinor :1004FFF6 -osfRightLine :1004FFF7 -osfLeftLine :1004FFF8 -osfDelete :1004FFFF - -SunFA_Grave :1005FF00 -SunFA_Circum :1005FF01 -SunFA_Tilde :1005FF02 -SunFA_Acute :1005FF03 -SunFA_Diaeresis :1005FF04 -SunFA_Cedilla :1005FF05 -SunF36 :1005FF10 -SunF37 :1005FF11 -SunSys_Req :1005FF60 -SunProps :1005FF70 -SunFront :1005FF71 -SunCopy :1005FF72 -SunOpen :1005FF73 -SunPaste :1005FF74 -SunCut :1005FF75 -SunPowerSwitch :1005FF76 -SunAudioLowerVolume :1005FF77 -SunAudioMute :1005FF78 -SunAudioRaiseVolume :1005FF79 -SunVideoDegauss :1005FF7A -SunVideoLowerBrightness :1005FF7B -SunVideoRaiseBrightness :1005FF7C -SunPowerSwitchShift :1005FF7D - -SunCompose :FF20 -SunPageUp :FF55 -SunPageDown :FF56 -SunPrint_Screen :FF61 -SunUndo :FF65 -SunAgain :FF66 -SunFind :FF68 -SunStop :FF69 -SunAltGraph :FF7E - -WYSetup :1006FF00 - -ncdSetup :1006FF00 - -XeroxPointerButton1 :10070001 -XeroxPointerButton2 :10070002 -XeroxPointerButton3 :10070003 -XeroxPointerButton4 :10070004 -XeroxPointerButton5 :10070005 - -! The definitions here should match -XF86ModeLock :1008FF01 -XF86MonBrightnessUp :1008FF02 -XF86MonBrightnessDown :1008FF03 -XF86KbdLightOnOff :1008FF04 -XF86KbdBrightnessUp :1008FF05 -XF86KbdBrightnessDown :1008FF06 -XF86Standby :1008FF10 -XF86AudioLowerVolume :1008FF11 -XF86AudioMute :1008FF12 -XF86AudioRaiseVolume :1008FF13 -XF86AudioPlay :1008FF14 -XF86AudioStop :1008FF15 -XF86AudioPrev :1008FF16 -XF86AudioNext :1008FF17 -XF86HomePage :1008FF18 -XF86Mail :1008FF19 -XF86Start :1008FF1A -XF86Search :1008FF1B -XF86AudioRecord :1008FF1C -XF86Calculator :1008FF1D -XF86Memo :1008FF1E -XF86ToDoList :1008FF1F -XF86Calendar :1008FF20 -XF86PowerDown :1008FF21 -XF86ContrastAdjust :1008FF22 -XF86RockerUp :1008FF23 -XF86RockerDown :1008FF24 -XF86RockerEnter :1008FF25 -XF86Back :1008FF26 -XF86Forward :1008FF27 -XF86Stop :1008FF28 -XF86Refresh :1008FF29 -XF86PowerOff :1008FF2A -XF86WakeUp :1008FF2B -XF86Eject :1008FF2C -XF86ScreenSaver :1008FF2D -XF86WWW :1008FF2E -XF86Sleep :1008FF2F -XF86Favorites :1008FF30 -XF86AudioPause :1008FF31 -XF86AudioMedia :1008FF32 -XF86MyComputer :1008FF33 -XF86VendorHome :1008FF34 -XF86LightBulb :1008FF35 -XF86Shop :1008FF36 -XF86History :1008FF37 -XF86OpenURL :1008FF38 -XF86AddFavorite :1008FF39 -XF86HotLinks :1008FF3A -XF86BrightnessAdjust :1008FF3B -XF86Finance :1008FF3C -XF86Community :1008FF3D -XF86AudioRewind :1008FF3E -XF86BackForward :1008FF3F -XF86Launch0 :1008FF40 -XF86Launch1 :1008FF41 -XF86Launch2 :1008FF42 -XF86Launch3 :1008FF43 -XF86Launch4 :1008FF44 -XF86Launch5 :1008FF45 -XF86Launch6 :1008FF46 -XF86Launch7 :1008FF47 -XF86Launch8 :1008FF48 -XF86Launch9 :1008FF49 -XF86LaunchA :1008FF4A -XF86LaunchB :1008FF4B -XF86LaunchC :1008FF4C -XF86LaunchD :1008FF4D -XF86LaunchE :1008FF4E -XF86LaunchF :1008FF4F -XF86ApplicationLeft :1008FF50 -XF86ApplicationRight :1008FF51 -XF86Book :1008FF52 -XF86CD :1008FF53 -XF86Calculater :1008FF54 -XF86Clear :1008FF55 -XF86Close :1008FF56 -XF86Copy :1008FF57 -XF86Cut :1008FF58 -XF86Display :1008FF59 -XF86DOS :1008FF5A -XF86Documents :1008FF5B -XF86Excel :1008FF5C -XF86Explorer :1008FF5D -XF86Game :1008FF5E -XF86Go :1008FF5F -XF86iTouch :1008FF60 -XF86LogOff :1008FF61 -XF86Market :1008FF62 -XF86Meeting :1008FF63 -XF86MenuKB :1008FF65 -XF86MenuPB :1008FF66 -XF86MySites :1008FF67 -XF86New :1008FF68 -XF86News :1008FF69 -XF86OfficeHome :1008FF6A -XF86Open :1008FF6B -XF86Option :1008FF6C -XF86Paste :1008FF6D -XF86Phone :1008FF6E -XF86Q :1008FF70 -XF86Reply :1008FF72 -XF86Reload :1008FF73 -XF86RotateWindows :1008FF74 -XF86RotationPB :1008FF75 -XF86RotationKB :1008FF76 -XF86Save :1008FF77 -XF86ScrollUp :1008FF78 -XF86ScrollDown :1008FF79 -XF86ScrollClick :1008FF7A -XF86Send :1008FF7B -XF86Spell :1008FF7C -XF86SplitScreen :1008FF7D -XF86Support :1008FF7E -XF86TaskPane :1008FF7F -XF86Terminal :1008FF80 -XF86Tools :1008FF81 -XF86Travel :1008FF82 -XF86UserPB :1008FF84 -XF86User1KB :1008FF85 -XF86User2KB :1008FF86 -XF86Video :1008FF87 -XF86WheelButton :1008FF88 -XF86Word :1008FF89 -XF86Xfer :1008FF8A -XF86ZoomIn :1008FF8B -XF86ZoomOut :1008FF8C -XF86Away :1008FF8D -XF86Messenger :1008FF8E -XF86WebCam :1008FF8F -XF86MailForward :1008FF90 -XF86Pictures :1008FF91 -XF86Music :1008FF92 -XF86Battery :1008FF93 -XF86Bluetooth :1008FF94 -XF86WLAN :1008FF95 -XF86UWB :1008FF96 -XF86AudioForward :1008FF97 -XF86AudioRepeat :1008FF98 -XF86AudioRandomPlay :1008FF99 -XF86Subtitle :1008FF9A -XF86AudioCycleTrack :1008FF9B -XF86CycleAngle :1008FF9C -XF86FrameBack :1008FF9D -XF86FrameForward :1008FF9E -XF86Time :1008FF9F -XF86Select :1008FFA0 -XF86View :1008FFA1 -XF86TopMenu :1008FFA2 -XF86Red :1008FFA3 -XF86Green :1008FFA4 -XF86Yellow :1008FFA5 -XF86Blue :1008FFA6 -XF86Suspend :1008FFA7 -XF86Hibernate :1008FFA8 -XF86TouchpadToggle :1008FFA9 - -! XFree86 special action keys -XF86_Switch_VT_1 :1008FE01 -XF86_Switch_VT_2 :1008FE02 -XF86_Switch_VT_3 :1008FE03 -XF86_Switch_VT_4 :1008FE04 -XF86_Switch_VT_5 :1008FE05 -XF86_Switch_VT_6 :1008FE06 -XF86_Switch_VT_7 :1008FE07 -XF86_Switch_VT_8 :1008FE08 -XF86_Switch_VT_9 :1008FE09 -XF86_Switch_VT_10 :1008FE0A -XF86_Switch_VT_11 :1008FE0B -XF86_Switch_VT_12 :1008FE0C -XF86_Ungrab :1008FE20 -XF86_ClearGrab :1008FE21 -XF86_Next_VMode :1008FE22 -XF86_Prev_VMode :1008FE23 - -usldead_acute :100000A8 -usldead_grave :100000A9 -usldead_diaeresis :100000AB -usldead_asciicircum :100000AA -usldead_asciitilde :100000AC -usldead_cedilla :1000FE2C -usldead_ring :1000FEB0 diff --git a/libX11/src/util/makekeys.c b/libX11/src/util/makekeys.c index 1c27e6b21..85ce75268 100644 --- a/libX11/src/util/makekeys.c +++ b/libX11/src/util/makekeys.c @@ -1,277 +1,316 @@ -/* - -Copyright 1990, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/* Constructs hash tables for XStringToKeysym and XKeysymToString. */ - -#include -#include -#include -#include -#include - -typedef unsigned long Signature; - -#define KTNUM 4000 - -static struct info { - char *name; - KeySym val; -} info[KTNUM]; - -#define MIN_REHASH 15 -#define MATCHES 10 - -static char tab[KTNUM]; -static unsigned short offsets[KTNUM]; -static unsigned short indexes[KTNUM]; -static KeySym values[KTNUM]; -static char buf[1024]; - -int -main(int argc, char *argv[]) -{ - int ksnum = 0; - int max_rehash; - Signature sig; - register int i, j, k, z; - register char *name; - register char c; - int first; - int best_max_rehash; - int best_z = 0; - int num_found; - KeySym val; - char key[128]; - char alias[128]; - - - while (fgets(buf, sizeof(buf), stdin)) { - i = sscanf(buf, "#define XK_%127s 0x%lx", key, &info[ksnum].val); - if (i != 2) { - i = sscanf(buf, "#define XK_%127s XK_%127s", key, alias); - if (i != 2) - continue; - for (i = ksnum - 1; i >= 0; i--) { - if (strcmp(info[i].name, alias) == 0) { - info[ksnum].val = info[i].val; - break; - } - } - if (i < 0) { /* Didn't find a match */ - fprintf(stderr, - "can't find matching definition %s for keysym %s\n", - alias, key); - continue; - } - } - if (info[ksnum].val == XK_VoidSymbol) - info[ksnum].val = 0; - if (info[ksnum].val > 0x1fffffff) { - fprintf(stderr, - "ignoring illegal keysym (%s), remove it from .h file!\n", - key); - continue; - } - name = strdup(key); - if (!name) { - fprintf(stderr, "makekeys: out of memory!\n"); - exit(1); - } - info[ksnum].name = name; - ksnum++; - if (ksnum == KTNUM) { - fprintf(stderr, "makekeys: too many keysyms!\n"); - exit(1); - } - } - - printf("/* This file is generated from keysymdef.h. */\n"); - printf("/* Do not edit. */\n"); - printf("\n"); - - best_max_rehash = ksnum; - num_found = 0; - for (z = ksnum; z < KTNUM; z++) { - max_rehash = 0; - for (name = tab, i = z; --i >= 0;) - *name++ = 0; - for (i = 0; i < ksnum; i++) { - name = info[i].name; - sig = 0; - while ((c = *name++)) - sig = (sig << 1) + c; - first = j = sig % z; - for (k = 0; tab[j]; k++) { - j += first + 1; - if (j >= z) - j -= z; - if (j == first) - goto next1; - } - tab[j] = 1; - if (k > max_rehash) - max_rehash = k; - } - if (max_rehash < MIN_REHASH) { - if (max_rehash < best_max_rehash) { - best_max_rehash = max_rehash; - best_z = z; - } - num_found++; - if (num_found >= MATCHES) - break; - } -next1: ; - } - - z = best_z; - if (z == 0) { - fprintf(stderr, "makekeys: failed to find small enough hash!\n" - "Try increasing KTNUM in makekeys.c\n"); - exit(1); - } - printf("#ifdef NEEDKTABLE\n"); - printf("const unsigned char _XkeyTable[] = {\n"); - printf("0,\n"); - k = 1; - for (i = 0; i < ksnum; i++) { - name = info[i].name; - sig = 0; - while ((c = *name++)) - sig = (sig << 1) + c; - first = j = sig % z; - while (offsets[j]) { - j += first + 1; - if (j >= z) - j -= z; - } - offsets[j] = k; - indexes[i] = k; - val = info[i].val; - printf("0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ", - (sig >> 8) & 0xff, sig & 0xff, - (val >> 24) & 0xff, (val >> 16) & 0xff, - (val >> 8) & 0xff, val & 0xff); - for (name = info[i].name, k += 7; (c = *name++); k++) - printf("'%c',", c); - printf((i == (ksnum-1)) ? "0\n" : "0,\n"); - } - printf("};\n"); - printf("\n"); - printf("#define KTABLESIZE %d\n", z); - printf("#define KMAXHASH %d\n", best_max_rehash + 1); - printf("\n"); - printf("static const unsigned short hashString[KTABLESIZE] = {\n"); - for (i = 0; i < z;) { - printf("0x%.4x", offsets[i]); - i++; - if (i == z) - break; - printf((i & 7) ? ", " : ",\n"); - } - printf("\n"); - printf("};\n"); - printf("#endif /* NEEDKTABLE */\n"); - - best_max_rehash = ksnum; - num_found = 0; - for (z = ksnum; z < KTNUM; z++) { - max_rehash = 0; - for (name = tab, i = z; --i >= 0;) - *name++ = 0; - for (i = 0; i < ksnum; i++) { - val = info[i].val; - first = j = val % z; - for (k = 0; tab[j]; k++) { - if (values[j] == val) - goto skip1; - j += first + 1; - if (j >= z) - j -= z; - if (j == first) - goto next2; - } - tab[j] = 1; - values[j] = val; - if (k > max_rehash) - max_rehash = k; -skip1: ; - } - if (max_rehash < MIN_REHASH) { - if (max_rehash < best_max_rehash) { - best_max_rehash = max_rehash; - best_z = z; - } - num_found++; - if (num_found >= MATCHES) - break; - } -next2: ; - } - - z = best_z; - if (z == 0) { - fprintf(stderr, "makekeys: failed to find small enough hash!\n" - "Try increasing KTNUM in makekeys.c\n"); - exit(1); - } - for (i = z; --i >= 0;) - offsets[i] = 0; - for (i = 0; i < ksnum; i++) { - val = info[i].val; - first = j = val % z; - while (offsets[j]) { - if (values[j] == val) - goto skip2; - j += first + 1; - if (j >= z) - j -= z; - } - offsets[j] = indexes[i] + 2; - values[j] = val; -skip2: ; - } - printf("\n"); - printf("#ifdef NEEDVTABLE\n"); - printf("#define VTABLESIZE %d\n", z); - printf("#define VMAXHASH %d\n", best_max_rehash + 1); - printf("\n"); - printf("static const unsigned short hashKeysym[VTABLESIZE] = {\n"); - for (i = 0; i < z;) { - printf("0x%.4x", offsets[i]); - i++; - if (i == z) - break; - printf((i & 7) ? ", " : ",\n"); - } - printf("\n"); - printf("};\n"); - printf("#endif /* NEEDVTABLE */\n"); - - exit(0); -} +/* + +Copyright 1990, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ + +/* Constructs hash tables for XStringToKeysym and XKeysymToString. */ + +#include +#include +#include +#include +#include + +typedef unsigned long Signature; + +#define KTNUM 4000 + +static struct info { + char *name; + KeySym val; +} info[KTNUM]; + +#define MIN_REHASH 15 +#define MATCHES 10 + +static char tab[KTNUM]; +static unsigned short offsets[KTNUM]; +static unsigned short indexes[KTNUM]; +static KeySym values[KTNUM]; +static char buf[1024]; +static int ksnum = 0; + +static int +parse_line(const char *buf, char *key, KeySym *val, char *prefix) +{ + int i; + char alias[128]; + char *tmp, *tmpa; + + /* See if we can catch a straight XK_foo 0x1234-style definition first; + * the trickery around tmp is to account for prefices. */ + i = sscanf(buf, "#define %127s 0x%lx", key, val); + if (i == 2 && (tmp = strstr(key, "XK_"))) { + memcpy(prefix, key, tmp - key); + prefix[tmp - key] = '\0'; + tmp += 3; + memmove(key, tmp, strlen(tmp) + 1); + return 1; + } + + /* Now try to catch alias (XK_foo XK_bar) definitions, and resolve them + * immediately: if the target is in the form XF86XK_foo, we need to + * canonicalise this to XF86foo before we do the lookup. */ + i = sscanf(buf, "#define %127s %127s", key, alias); + if (i == 2 && (tmp = strstr(key, "XK_")) && (tmpa = strstr(alias, "XK_"))) { + memcpy(prefix, key, tmp - key); + prefix[tmp - key] = '\0'; + tmp += 3; + memmove(key, tmp, strlen(tmp) + 1); + memmove(tmpa, tmpa + 3, strlen(tmpa + 3) + 1); + + for (i = ksnum - 1; i >= 0; i--) { + if (strcmp(info[i].name, alias) == 0) { + *val = info[i].val; + return 1; + } + } + + fprintf(stderr, "can't find matching definition %s for keysym %s%s\n", + alias, prefix, key); + } + + return 0; +} + +int +main(int argc, char *argv[]) +{ + int max_rehash; + Signature sig; + int i, j, k, l, z; + FILE *fptr; + char *name; + char c; + int first; + int best_max_rehash; + int best_z = 0; + int num_found; + KeySym val; + char key[128], prefix[128]; + + for (l = 1; l < argc; l++) { + fptr = fopen(argv[l], "r"); + if (!fptr) { + fprintf(stderr, "couldn't open %s\n", argv[l]); + continue; + } + + while (fgets(buf, sizeof(buf), fptr)) { + if (!parse_line(buf, key, &val, prefix)) + continue; + + if (val == XK_VoidSymbol) + val = 0; + if (val > 0x1fffffff) { + fprintf(stderr, "ignoring illegal keysym (%s, %lx)\n", key, + val); + continue; + } + + name = malloc(strlen(prefix) + strlen(key) + 1); + if (!name) { + fprintf(stderr, "makekeys: out of memory!\n"); + exit(1); + } + sprintf(name, "%s%s", prefix, key); + info[ksnum].name = name; + info[ksnum].val = val; + ksnum++; + if (ksnum == KTNUM) { + fprintf(stderr, "makekeys: too many keysyms!\n"); + exit(1); + } + } + + fclose(fptr); + } + + printf("/* This file is generated from keysymdef.h. */\n"); + printf("/* Do not edit. */\n"); + printf("\n"); + + best_max_rehash = ksnum; + num_found = 0; + for (z = ksnum; z < KTNUM; z++) { + max_rehash = 0; + for (name = tab, i = z; --i >= 0;) + *name++ = 0; + for (i = 0; i < ksnum; i++) { + name = info[i].name; + sig = 0; + while ((c = *name++)) + sig = (sig << 1) + c; + first = j = sig % z; + for (k = 0; tab[j]; k++) { + j += first + 1; + if (j >= z) + j -= z; + if (j == first) + goto next1; + } + tab[j] = 1; + if (k > max_rehash) + max_rehash = k; + } + if (max_rehash < MIN_REHASH) { + if (max_rehash < best_max_rehash) { + best_max_rehash = max_rehash; + best_z = z; + } + num_found++; + if (num_found >= MATCHES) + break; + } +next1: ; + } + + z = best_z; + if (z == 0) { + fprintf(stderr, "makekeys: failed to find small enough hash!\n" + "Try increasing KTNUM in makekeys.c\n"); + exit(1); + } + printf("#ifdef NEEDKTABLE\n"); + printf("const unsigned char _XkeyTable[] = {\n"); + printf("0,\n"); + k = 1; + for (i = 0; i < ksnum; i++) { + name = info[i].name; + sig = 0; + while ((c = *name++)) + sig = (sig << 1) + c; + first = j = sig % z; + while (offsets[j]) { + j += first + 1; + if (j >= z) + j -= z; + } + offsets[j] = k; + indexes[i] = k; + val = info[i].val; + printf("0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, 0x%.2lx, ", + (sig >> 8) & 0xff, sig & 0xff, + (val >> 24) & 0xff, (val >> 16) & 0xff, + (val >> 8) & 0xff, val & 0xff); + for (name = info[i].name, k += 7; (c = *name++); k++) + printf("'%c',", c); + printf((i == (ksnum-1)) ? "0\n" : "0,\n"); + } + printf("};\n"); + printf("\n"); + printf("#define KTABLESIZE %d\n", z); + printf("#define KMAXHASH %d\n", best_max_rehash + 1); + printf("\n"); + printf("static const unsigned short hashString[KTABLESIZE] = {\n"); + for (i = 0; i < z;) { + printf("0x%.4x", offsets[i]); + i++; + if (i == z) + break; + printf((i & 7) ? ", " : ",\n"); + } + printf("\n"); + printf("};\n"); + printf("#endif /* NEEDKTABLE */\n"); + + best_max_rehash = ksnum; + num_found = 0; + for (z = ksnum; z < KTNUM; z++) { + max_rehash = 0; + for (name = tab, i = z; --i >= 0;) + *name++ = 0; + for (i = 0; i < ksnum; i++) { + val = info[i].val; + first = j = val % z; + for (k = 0; tab[j]; k++) { + if (values[j] == val) + goto skip1; + j += first + 1; + if (j >= z) + j -= z; + if (j == first) + goto next2; + } + tab[j] = 1; + values[j] = val; + if (k > max_rehash) + max_rehash = k; +skip1: ; + } + if (max_rehash < MIN_REHASH) { + if (max_rehash < best_max_rehash) { + best_max_rehash = max_rehash; + best_z = z; + } + num_found++; + if (num_found >= MATCHES) + break; + } +next2: ; + } + + z = best_z; + if (z == 0) { + fprintf(stderr, "makekeys: failed to find small enough hash!\n" + "Try increasing KTNUM in makekeys.c\n"); + exit(1); + } + for (i = z; --i >= 0;) + offsets[i] = 0; + for (i = 0; i < ksnum; i++) { + val = info[i].val; + first = j = val % z; + while (offsets[j]) { + if (values[j] == val) + goto skip2; + j += first + 1; + if (j >= z) + j -= z; + } + offsets[j] = indexes[i] + 2; + values[j] = val; +skip2: ; + } + printf("\n"); + printf("#ifdef NEEDVTABLE\n"); + printf("#define VTABLESIZE %d\n", z); + printf("#define VMAXHASH %d\n", best_max_rehash + 1); + printf("\n"); + printf("static const unsigned short hashKeysym[VTABLESIZE] = {\n"); + for (i = 0; i < z;) { + printf("0x%.4x", offsets[i]); + i++; + if (i == z) + break; + printf((i & 7) ? ", " : ",\n"); + } + printf("\n"); + printf("};\n"); + printf("#endif /* NEEDVTABLE */\n"); + + exit(0); +} -- cgit v1.2.3