tdevdraw: map X11 dead_diaresis to double quote - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e4122a42b922fd1047a4b5beee6fdc0ce623f873
 (DIR) parent 33cdf63251a23d71906cb482bce4ca02ce6d94c0
 (HTM) Author: Caio Oliveira <cmarcelo@gmail.com>
       Date:   Sun, 21 Oct 2012 12:12:00 -0400
       
       devdraw: map X11 dead_diaresis to double quote
       
       R=rsc
       CC=plan9port.codebot
       http://codereview.appspot.com/6690049
       
       Diffstat:
         M CONTRIBUTORS                        |       1 +
         M src/cmd/devdraw/x11-keysym2ucs.c    |      81 ++++++++++++++++---------------
       
       2 files changed, 43 insertions(+), 39 deletions(-)
       ---
 (DIR) diff --git a/CONTRIBUTORS b/CONTRIBUTORS
       t@@ -11,6 +11,7 @@ Anthony Martin <ality@pbrane.org>
        Anthony Sorace <a@9srv.net>
        Arvindh Rajesh Tamilmani <art@a-30.net>
        Benjamin Huntsman <BHuntsman@mail2.cu-portland.edu>
       +Caio Oliveira <cmarcelo@gmail.com>
        Christopher Brannon <chris@the-brannons.com>
        David du Colombier <0intro@gmail.com>
        David Jeannot <djeannot24@gmail.com>
 (DIR) diff --git a/src/cmd/devdraw/x11-keysym2ucs.c b/src/cmd/devdraw/x11-keysym2ucs.c
       t@@ -826,49 +826,52 @@ static struct codepair {
        VISIBLE
        long _p9keysym2ucs(KeySym keysym)
        {
       -    int min = 0;
       -    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
       -    int mid;
       +        int min = 0;
       +        int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
       +        int mid;
        
       -    switch(keysym){
       -    case 0xfe53: /*dead tilde*/
       -        keysym = 0x007e; /*asciitilde*/
       -        break;
       -    case 0xfe52: /*dead_circumflex*/
       -        keysym = 0x005e; /*asciicircum*/
       -        break;
       -    case 0xfe51: /*dead_acute*/
       -        keysym = 0x0027; /*apostrophe*/
       -        break;
       -    case 0xfe50: /*dead_grave*/
       -        keysym = 0x0060; /*grave*/
       -        break;
       -    default:
       -        break;
       -    }
       +        switch(keysym){
       +        case 0xfe53: /*dead tilde*/
       +                keysym = 0x007e; /*asciitilde*/
       +                break;
       +        case 0xfe52: /*dead_circumflex*/
       +                keysym = 0x005e; /*asciicircum*/
       +                break;
       +        case 0xfe51: /*dead_acute*/
       +                keysym = 0x0027; /*apostrophe*/
       +                break;
       +        case 0xfe50: /*dead_grave*/
       +                keysym = 0x0060; /*grave*/
       +                break;
       +        case 0xfe57: /*dead_diaresis*/
       +                keysym = 0x0022; /*quotedbl*/
       +                break;
       +        default:
       +                break;
       +        }
        
       -    /* first check for Latin-1 characters (1:1 mapping) */
       -    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
       -        (keysym >= 0x00a0 && keysym <= 0x00ff))
       -        return keysym;
       +        /* first check for Latin-1 characters (1:1 mapping) */
       +        if ((keysym >= 0x0020 && keysym <= 0x007e) ||
       +            (keysym >= 0x00a0 && keysym <= 0x00ff))
       +                return keysym;
        
       -    /* also check for directly encoded 24-bit UCS characters */
       -    if ((keysym & 0xff000000) == 0x01000000)
       -        return keysym & 0x00ffffff;
       +        /* also check for directly encoded 24-bit UCS characters */
       +        if ((keysym & 0xff000000) == 0x01000000)
       +                return keysym & 0x00ffffff;
        
       -    /* binary search in table */
       -    while (max >= min) {
       -        mid = (min + max) / 2;
       -        if (keysymtab[mid].keysym < keysym)
       -            min = mid + 1;
       -        else if (keysymtab[mid].keysym > keysym)
       -            max = mid - 1;
       -        else {
       -            /* found it */
       -            return keysymtab[mid].ucs;
       +        /* binary search in table */
       +        while (max >= min) {
       +                mid = (min + max) / 2;
       +                if (keysymtab[mid].keysym < keysym)
       +                        min = mid + 1;
       +                else if (keysymtab[mid].keysym > keysym)
       +                        max = mid - 1;
       +                else {
       +                        /* found it */
       +                        return keysymtab[mid].ucs;
       +                }
                }
       -    }
        
       -    /* no matching Unicode value found */
       -    return -1;
       +        /* no matching Unicode value found */
       +        return -1;
        }