Revision: 6183
Author: nogu.dev
Date: Sun Feb 28 14:55:40 2010
Log: * qt4/immodule/candidatewindow.cpp
* qt4/immodule/plugin.cpp
* qt4/immodule/qhelpermanager.cpp
* qt4/immodule/qtextutil.h
* qt4/immodule/quiminputcontext.cpp
* qt4/immodule/quiminputcontext_compose.cpp
* qt4/immodule/quiminputcontext_compose.h
  - Expand tabs to spaces.
http://code.google.com/p/uim/source/detail?r=6183

Modified:
 /trunk/qt4/immodule/candidatewindow.cpp
 /trunk/qt4/immodule/plugin.cpp
 /trunk/qt4/immodule/qhelpermanager.cpp
 /trunk/qt4/immodule/qtextutil.h
 /trunk/qt4/immodule/quiminputcontext.cpp
 /trunk/qt4/immodule/quiminputcontext_compose.cpp
 /trunk/qt4/immodule/quiminputcontext_compose.h

=======================================
--- /trunk/qt4/immodule/candidatewindow.cpp     Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/candidatewindow.cpp     Sun Feb 28 14:55:40 2010
@@ -153,8 +153,8 @@
     // clear stored candidate datas
     for ( int i = 0; i < stores.size(); i++ )
     {
-       if ( stores[ i ] )
-           uim_candidate_free( stores[ i ] );
+        if ( stores[ i ] )
+            uim_candidate_free( stores[ i ] );
     }
     stores.clear();
 }
@@ -204,8 +204,8 @@
     // setup dummy candidate
     for ( int i = 0; i < nrCandidates; i++ )
     {
-       uim_candidate d = NULL;
-       stores.append( d );
+        uim_candidate d = NULL;
+        stores.append( d );
     }

     if ( !subWin )
@@ -226,12 +226,12 @@
     start = page * displayLimit;

     if ( displayLimit && ( nrCandidates - start ) > displayLimit )
-       pageNr = displayLimit;
+        pageNr = displayLimit;
     else
-       pageNr = nrCandidates - start;
+        pageNr = nrCandidates - start;

     for ( i = 0; i < pageNr; i++ )
-       stores[ start + i ] = candidates[ i ];
+        stores[ start + i ] = candidates[ i ];
 }
 #endif /* UIM_QT_USE_NEW_PAGE_HANDLING */

=======================================
--- /trunk/qt4/immodule/plugin.cpp      Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/plugin.cpp      Sun Feb 28 14:55:40 2010
@@ -76,7 +76,7 @@

 #if UIM_QT_LIST_SUBIM_AS_QTIM
     if ( key.startsWith( "uim-" ) )
-       imname = key.mid( 4 );
+        imname = key.mid( 4 );
     else
 #endif
     if ( key == "uim" )
@@ -84,7 +84,7 @@

     QStringList langs = createLanguageList( key );
     QUimInputContext *uic = new QUimInputContext( imname.toUtf8(),
-                                                 langs[ 0 ].toUtf8() );
+                                                  langs[ 0 ].toUtf8() );

     return uic;
 }
@@ -116,7 +116,7 @@
         if (!infoManager)
             infoManager = new QUimInfoManager();
 #if UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK
-       uim_x_kana_input_hack_init( QX11Info::display() );
+        uim_x_kana_input_hack_init( QX11Info::display() );
 #endif
         uimReady = true;
     }
@@ -167,7 +167,7 @@
QStringList UimInputContextPlugin::createLanguageList( const QString &key ) const
 {
     if ( key == "uim" )
-       return QStringList() << "ja" << "ko" << "zh" << "*";
+        return QStringList() << "ja" << "ko" << "zh" << "*";

 #if UIM_QT_LIST_SUBIM_AS_QTIM
     uim_context tmp_uc = uim_create_context( NULL, "UTF-8",
=======================================
--- /trunk/qt4/immodule/qhelpermanager.cpp      Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/qhelpermanager.cpp      Sun Feb 28 14:55:40 2010
@@ -106,7 +106,7 @@
         {
             QStringList list = str.split( "\n" );
             uim_prop_activate( focusedInputContext->uimContext(),
-                              list[ 1 ].toUtf8() );
+                               list[ 1 ].toUtf8() );
         }
         else if ( str.startsWith( "im_list_get" ) )
         {
@@ -160,8 +160,8 @@
             for ( it = contextList.begin(); it != contextList.end(); ++it )
             {
                 uim_prop_update_custom( ( *it )->uimContext(),
-                                       list[ 1 ].toUtf8(),
-                                       list[ 2 ].toUtf8() );
+                                        list[ 1 ].toUtf8(),
+                                        list[ 2 ].toUtf8() );
                 break;  /* all custom variables are global */
             }
         }
@@ -172,7 +172,7 @@

         QUimInfoManager *infoManager =
             UimInputContextPlugin::getQUimInfoManager();
-       infoManager->initUimInfo();
+        infoManager->initUimInfo();
     }
 }

@@ -187,7 +187,7 @@
         if ( focusedInputContext )
         {
             uim_switch_im( focusedInputContext->uimContext(),
-                          im_name.toUtf8() );
+                           im_name.toUtf8() );
             uim_prop_list_update( focusedInputContext->uimContext() );
             focusedInputContext->readIMConf();
         }
@@ -200,8 +200,8 @@
             uim_switch_im( ( *it )->uimContext(), im_name.toUtf8() );
             ( *it )->readIMConf();
             uim_prop_update_custom( ( *it )->uimContext(),
-                                   "custom-preserved-default-im-name",
-                                   im_name_sym.toUtf8() );
+                                    "custom-preserved-default-im-name",
+                                    im_name_sym.toUtf8() );
         }
     }
     else if ( str.startsWith( "im_change_this_application_only" ) )
=======================================
--- /trunk/qt4/immodule/qtextutil.h     Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/qtextutil.h     Sun Feb 28 14:55:40 2010
@@ -72,11 +72,11 @@
                               char **former, char **latter );
     int acquireSelectionTextInQLineEdit( enum UTextOrigin origin,
                                          int former_req_len,
-                                        int latter_req_len,
+                                         int latter_req_len,
                                          char **former, char **latter );
     int acquireSelectionTextInQTextEdit( enum UTextOrigin origin,
                                          int former_req_len,
-                                        int latter_req_len,
+                                         int latter_req_len,
                                          char **former, char **latter );

     int acquireClipboardText( enum UTextOrigin origin,
=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp    Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/quiminputcontext.cpp    Sun Feb 28 14:55:40 2010
@@ -257,7 +257,7 @@
             key = qkey - Qt::Key_F1 + UKey_F1;
         }
         else if ( qkey >= Qt::Key_Dead_Grave && qkey <= Qt::Key_Dead_Horn )
-       {
+        {
             key = qkey - Qt::Key_Dead_Grave + UKey_Dead_Grave;
         }
         else if ( qkey >= Qt::Key_Kanji && qkey <= Qt::Key_Eisu_toggle )
@@ -300,8 +300,8 @@
                 break;
             case Qt::Key_Control: key = UKey_Control_key;
                 if ( type == QEvent::KeyPress )
-                   modifier &= ~UMod_Control;
-               break;
+                    modifier &= ~UMod_Control;
+                break;
             case Qt::Key_Alt: key = UKey_Alt_key;
                 if ( type == QEvent::KeyPress )
                     modifier &= ~UMod_Alt;
@@ -354,9 +354,9 @@
     QInputContext::setFocusWidget( w );

     if ( w )
-       setFocus();
+        setFocus();
     else
-       unsetFocus();
+        unsetFocus();
 }

 // Qt4 does not have QInputContext::setFocus()
@@ -473,9 +473,9 @@
     qDebug( "QUimInputContext::update() w = %p", w );

     if ( w ) {
-       QRect mf = w->inputMethodQuery( Qt::ImMicroFocus ).toRect();
-       QPoint p = w->mapToGlobal( mf.topLeft() );
-       setMicroFocus( p.x(), p.y(), mf.width(), mf.height() );
+        QRect mf = w->inputMethodQuery( Qt::ImMicroFocus ).toRect();
+        QPoint p = w->mapToGlobal( mf.topLeft() );
+        setMicroFocus( p.x(), p.y(), mf.width(), mf.height() );
     }
 }

@@ -606,21 +606,21 @@
     QString newString = getPreeditString();

     if ( !isComposing() ) {
-       if ( newString.isEmpty() )
-           return;
-
-       // Start conversion
-       m_isComposing = true;
+        if ( newString.isEmpty() )
+            return;
+
+        // Start conversion
+        m_isComposing = true;
     }

     if ( !newString.isEmpty() ) {
         QInputMethodEvent e( newString, getPreeditAttrs() );
         sendEvent( e );
-       // Qt4.3.1 does not call back update() here
-       update();
+        // Qt4.3.1 does not call back update() here
+        update();
     } else {
-       // Complete conversion implicitly since the preedit is empty
-       commitString( "" );
+        // Complete conversion implicitly since the preedit is empty
+        commitString( "" );
     }
 }

@@ -628,7 +628,7 @@
 {
     // just send IMEnd and keep preedit string
     if ( isComposing() )
-       commitString( "" );
+        commitString( "" );
 }

 void QUimInputContext::restoreContext()
@@ -731,46 +731,46 @@
     const QList<PreeditSegment *>::ConstIterator end = psegs.end();
     int segPos = 0;
     for ( ; seg != end; ++seg ) {
-       int uimAttr = ( *seg )->attr;
-       int segStrLen = ( *seg )->str.length();
-       QTextCharFormat segFmt;
+        int uimAttr = ( *seg )->attr;
+        int segStrLen = ( *seg )->str.length();
+        QTextCharFormat segFmt;

         if ( uimAttr & UPreeditAttr_Cursor ) {
-           // Transparent cursor is required to set microfocus even
-           // if the caret is invisible to user.
-           //
-           // FIXME: Segment string may be outframed if the cursor is
-           // located near the right frame.
-           int visibility = ( segStrLen ) ? HIDE_CARET : SHOW_CARET;
-           QInputMethodEvent::Attribute cursor( QInputMethodEvent::Cursor,
-                                                segPos, visibility, DUMMY );
-           attrs << cursor;
-       } else if ( uimAttr & UPreeditAttr_Separator ) {
-           if ( !segStrLen )
-               segStrLen = QString( DEFAULT_SEPARATOR_STR ).length();
-       }
-
-       if ( segStrLen ) {
-           if ( uimAttr & UPreeditAttr_Reverse ) {
+            // Transparent cursor is required to set microfocus even
+            // if the caret is invisible to user.
+            //
+            // FIXME: Segment string may be outframed if the cursor is
+            // located near the right frame.
+            int visibility = ( segStrLen ) ? HIDE_CARET : SHOW_CARET;
+            QInputMethodEvent::Attribute cursor( QInputMethodEvent::Cursor,
+ segPos, visibility, DUMMY );
+            attrs << cursor;
+        } else if ( uimAttr & UPreeditAttr_Separator ) {
+            if ( !segStrLen )
+                segStrLen = QString( DEFAULT_SEPARATOR_STR ).length();
+        }
+
+        if ( segStrLen ) {
+            if ( uimAttr & UPreeditAttr_Reverse ) {
 #if 0
-               // FIXME: fmt.foreground() is white (expecting black)
-               QTextFormat fmt = standardFormat( PreeditFormat );
-               segFmt.setForeground( fmt.background() );
-               segFmt.setBackground( fmt.foreground() );
+                // FIXME: fmt.foreground() is white (expecting black)
+                QTextFormat fmt = standardFormat( PreeditFormat );
+                segFmt.setForeground( fmt.background() );
+                segFmt.setBackground( fmt.foreground() );
 #else
-               // FIXME: Retrieve customized colors from the text widget
-               segFmt.setForeground( Qt::white );
-               segFmt.setBackground( Qt::black );
+                // FIXME: Retrieve customized colors from the text widget
+                segFmt.setForeground( Qt::white );
+                segFmt.setBackground( Qt::black );
 #endif
-           }
-           if ( uimAttr & UPreeditAttr_UnderLine ) {
-               segFmt.setFontUnderline( TRUE );
-           }
-           QInputMethodEvent::Attribute segAttr( QInputMethodEvent::TextFormat,
-                                                 segPos, segStrLen, segFmt );
-           attrs << segAttr;
-           segPos += segStrLen;
-       }
+            }
+            if ( uimAttr & UPreeditAttr_UnderLine ) {
+                segFmt.setFontUnderline( TRUE );
+            }
+ QInputMethodEvent::Attribute segAttr( QInputMethodEvent::TextFormat, + segPos, segStrLen, segFmt );
+            attrs << segAttr;
+            segPos += segStrLen;
+        }
     }

     return attrs;
@@ -783,10 +783,10 @@
     list.clear();

     if ( page < 0 )
-       return;
+        return;

     if ( pageFilled[ page ] )
-       return;
+        return;

     // set page candidates
     uim_candidate cand;
@@ -797,14 +797,14 @@
     start = page * displayLimit;

     if ( displayLimit && ( nrCandidates - start ) > displayLimit )
-       pageNr = displayLimit;
+        pageNr = displayLimit;
     else
-       pageNr = nrCandidates - start;
+        pageNr = nrCandidates - start;

     for ( int i = start; i < ( pageNr + start ); i++ )
     {
-       cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i 
);
-       list.append( cand );
+ cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i );
+        list.append( cand );
     }
     pageFilled[ page ] = true;
     cwin->setPageCandidates( page, list );
@@ -832,7 +832,7 @@
     nrPages = displayLimit ? ( nr - 1 ) / displayLimit + 1 : 1;
     pageFilled.clear();
     for ( int i = 0; i < nrPages; i++ )
-       pageFilled.append( false );
+        pageFilled.append( false );

     cwin->setNrCandidates( nr, displayLimit );

@@ -850,12 +850,12 @@
     int new_page;

     if ( index >= cwin->nrCandidates )
-       index = 0;
+        index = 0;

     if ( index >= 0 && cwin->displayLimit )
-       new_page = index / cwin->displayLimit;
+        new_page = index / cwin->displayLimit;
     else
-       new_page = cwin->pageIndex;
+        new_page = cwin->pageIndex;

     prepare_page_candidates( new_page );
 #endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
@@ -869,11 +869,11 @@

     index = forward ? cwin->pageIndex + 1 : cwin->pageIndex - 1;
     if ( index < 0 )
-       new_page = nrPages - 1;
+        new_page = nrPages - 1;
     else if ( index >= nrPages )
-       new_page = 0;
+        new_page = 0;
     else
-       new_page = index;
+        new_page = index;

     prepare_page_candidates( new_page );
 #endif /* UIM_QT_USE_NEW_PAGE_HANDLING */
=======================================
--- /trunk/qt4/immodule/quiminputcontext_compose.cpp Tue Jan 20 18:11:15 2009 +++ /trunk/qt4/immodule/quiminputcontext_compose.cpp Sun Feb 28 14:55:40 2010
@@ -55,13 +55,13 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>

-#define COMPOSE_FILE   "Compose"
-#define COMPOSE_DIR_FILE       "X11/locale/compose.dir"
-#define XLOCALE_DIR    "X11/locale"
-#define FALLBACK_XLIB_DIR      "/usr/X11R6/lib"
-
-#define XLC_BUFSIZE    256
-#define iscomment(ch)  ((ch) == '#' || (ch) == '\0')
+#define COMPOSE_FILE        "Compose"
+#define COMPOSE_DIR_FILE        "X11/locale/compose.dir"
+#define XLOCALE_DIR        "X11/locale"
+#define FALLBACK_XLIB_DIR        "/usr/X11R6/lib"
+
+#define XLC_BUFSIZE        256
+#define iscomment(ch)        ((ch) == '#' || (ch) == '\0')

 static int parse_line(char *line, char **argv, int argsize);
 static unsigned int KeySymToUcs4(KeySym keysym);
@@ -89,31 +89,31 @@

     xstate = 0;
     if (qstate & Qt::ShiftButton)
-       xstate |= ShiftMask;
+        xstate |= ShiftMask;
     if (qstate & Qt::ControlButton)
-       xstate |= ControlMask;
+        xstate |= ControlMask;
     if (qstate & Qt::AltButton)
-       xstate |= Mod1Mask; // XXX
+        xstate |= Mod1Mask; // XXX
     if (qstate & Qt::MetaButton)
-       xstate |= Mod1Mask; // XXX
+        xstate |= Mod1Mask; // XXX

     if (qkey >= 0x20 && qkey <= 0xff) {
         if (isascii(qkey) && isprint(qkey)) {
-           int ascii = event->ascii();
-           if (isalpha(ascii))
-               xkeysym = ascii;
-           else
-               if ((qstate & Qt::ControlButton) &&
-                   (ascii >= 0x01 && ascii <= 0x1a))
-                   if (qstate & Qt::ShiftButton)
-                       xkeysym = ascii + 0x40;
-                   else
-                       xkeysym = ascii + 0x60;
-               else
-                   xkeysym = qkey;
-       } else {
+            int ascii = event->ascii();
+            if (isalpha(ascii))
+                    xkeysym = ascii;
+            else
+                if ((qstate & Qt::ControlButton) &&
+                    (ascii >= 0x01 && ascii <= 0x1a))
+                    if (qstate & Qt::ShiftButton)
+                        xkeysym = ascii + 0x40;
+                    else
+                        xkeysym = ascii + 0x60;
+                else
+                        xkeysym = qkey;
+        } else {
             xkeysym = qkey;
-       }
+        }
     } else if (qkey >= Qt::Key_Dead_Grave && qkey <= Qt::Key_Dead_Horn) {
         xkeysym = qkey + 0xec00 - 0x01000000;
     } else {
@@ -228,36 +228,36 @@
     DefTree *p;

     if ((is_push == false)  || m_top == NULL)
-       return false;
+        return false;

     if (IsModifierKey(xkeysym))
-       return false;
+        return false;

     for (p = m_context; p ; p = p->next) {
-       if (((xkeystate & p->modifier_mask) == p->modifier) &&
-               (xkeysym == p->keysym)) {
-           break;
-       }
+        if (((xkeystate & p->modifier_mask) == p->modifier) &&
+                (xkeysym == p->keysym)) {
+            break;
+        }
     }

     if (p) { // Matched
-       if (p->succession) { // Intermediate
-           m_context = p->succession;
-           return true;
-       } else { // Terminate (reached to leaf)
-           m_composed = p;
-           // commit string here
-           m_ic->commitString(QString::fromUtf8(m_composed->utf8));
-           // initialize internal state for next key sequence
-           m_context = m_top;
-           return true;
-       }
+        if (p->succession) { // Intermediate
+            m_context = p->succession;
+            return true;
+        } else { // Terminate (reached to leaf)
+            m_composed = p;
+            // commit string here
+            m_ic->commitString(QString::fromUtf8(m_composed->utf8));
+            // initialize internal state for next key sequence
+            m_context = m_top;
+            return true;
+        }
     } else { // Unmatched
-       if (m_context == m_top)
-           return false;
-       // Error (Sequence Unmatch occurred)
-       m_context = m_top;
-       return true;
+        if (m_context == m_top)
+            return false;
+        // Error (Sequence Unmatch occurred)
+        m_context = m_top;
+        return true;
     }
 }

@@ -273,19 +273,19 @@
     int c;

     if (*lastch != 0) {
-       c = *lastch;
-       *lastch = 0;
+        c = *lastch;
+        *lastch = 0;
     } else {
-       c = getc(fp);
-       if (c == '\\') {
-           c = getc(fp);
-           if (c == '\n') {
-               c = getc(fp);
-           } else {
-               ungetc(c, fp);
-               c = '\\';
-           }
-       }
+        c = getc(fp);
+        if (c == '\\') {
+            c = getc(fp);
+            if (c == '\n') {
+                c = getc(fp);
+            } else {
+                ungetc(c, fp);
+                c = '\\';
+            }
+        }
     }
     return(c);
 }
@@ -329,155 +329,155 @@
     }
     switch (c) {
     case EOF:
-       token = ENDOFFILE;
-       break;
+        token = ENDOFFILE;
+        break;
     case '\n':
-       token = ENDOFLINE;
-       break;
+        token = ENDOFLINE;
+        break;
     case '<':
-       token = LESS;
-       break;
+        token = LESS;
+        break;
     case '>':
-       token = GREATER;
-       break;
+        token = GREATER;
+        break;
     case ':':
-       token = COLON;
-       break;
+        token = COLON;
+        break;
     case '!':
-       token = EXCLAM;
-       break;
+        token = EXCLAM;
+        break;
     case '~':
-       token = TILDE;
-       break;
+        token = TILDE;
+        break;
     case '"':
-       p = *tokenbuf;
-       while ((c = nextch(fp, lastch)) != '"') {
-           if (len >= *buflen - 1) {
-                   *buflen += BUFSIZ;
-                   *tokenbuf = (char *)realloc(*tokenbuf, *buflen);
-                   p = *tokenbuf + len;
-           }
-           if (c == '\n' || c == EOF) {
-               putbackch(c, lastch);
-               token = ERROR;
-               goto string_error;
-           } else if (c == '\\') {
-               c = nextch(fp, lastch);
-               switch (c) {
-               case '\\':
-               case '"':
-                   *p++ = (char)c;
-                   len++;
-                   break;
-               case 'n':
-                   *p++ = '\n';
-                   len++;
-                   break;
-               case 'r':
-                   *p++ = '\r';
-                   len++;
-                   break;
-               case 't':
-                   *p++ = '\t';
-                   len++;
-                   break;
-               case '0':
-               case '1':
-               case '2':
-               case '3':
-               case '4':
-               case '5':
-               case '6':
-               case '7':
-                   i = c - '0';
-                   c = nextch(fp, lastch);
-                   for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
-                       i <<= 3;
-                       i += c - '0';
-                       c = nextch(fp, lastch);
-                   }
-                   putbackch(c, lastch);
-                   *p++ = (char)i;
-                   len++;
-                   break;
-               case 'X':
-               case 'x':
-                   i = 0;
-                   for (j = 0; j < 2; j++) {
-                       c = nextch(fp, lastch);
-                       i <<= 4;
-                       if (c >= '0' && c <= '9') {
-                           i += c - '0';
-                       } else if (c >= 'A' && c <= 'F') {
-                           i += c - 'A' + 10;
-                       } else if (c >= 'a' && c <= 'f') {
-                           i += c - 'a' + 10;
-                       } else {
-                           putbackch(c, lastch);
-                           i >>= 4;
-                           break;
-                       }
-                   }
-                   if (j == 0) {
-                       token = ERROR;
-                       goto string_error;
-                   }
-                   *p++ = (char)i;
-                   len++;
-                   break;
-               case EOF:
-                   putbackch(c, lastch);
-                   token = ERROR;
-                   goto string_error;
-               default:
-                   *p++ = (char)c;
-                   len++;
-                   break;
-               }
-           } else {
-               *p++ = (char)c;
-               len++;
-           }
-       }
-       *p = '\0';
-       token = STRING;
-       break;
+        p = *tokenbuf;
+        while ((c = nextch(fp, lastch)) != '"') {
+            if (len >= *buflen - 1) {
+                    *buflen += BUFSIZ;
+                    *tokenbuf = (char *)realloc(*tokenbuf, *buflen);
+                    p = *tokenbuf + len;
+            }
+            if (c == '\n' || c == EOF) {
+                putbackch(c, lastch);
+                token = ERROR;
+                goto string_error;
+            } else if (c == '\\') {
+                c = nextch(fp, lastch);
+                switch (c) {
+                case '\\':
+                case '"':
+                    *p++ = (char)c;
+                    len++;
+                    break;
+                case 'n':
+                    *p++ = '\n';
+                    len++;
+                    break;
+                case 'r':
+                    *p++ = '\r';
+                    len++;
+                    break;
+                case 't':
+                    *p++ = '\t';
+                    len++;
+                    break;
+                case '0':
+                case '1':
+                case '2':
+                case '3':
+                case '4':
+                case '5':
+                case '6':
+                case '7':
+                    i = c - '0';
+                    c = nextch(fp, lastch);
+                    for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
+                        i <<= 3;
+                        i += c - '0';
+                        c = nextch(fp, lastch);
+                    }
+                    putbackch(c, lastch);
+                    *p++ = (char)i;
+                    len++;
+                    break;
+                case 'X':
+                case 'x':
+                    i = 0;
+                    for (j = 0; j < 2; j++) {
+                        c = nextch(fp, lastch);
+                        i <<= 4;
+                        if (c >= '0' && c <= '9') {
+                            i += c - '0';
+                        } else if (c >= 'A' && c <= 'F') {
+                            i += c - 'A' + 10;
+                        } else if (c >= 'a' && c <= 'f') {
+                            i += c - 'a' + 10;
+                        } else {
+                            putbackch(c, lastch);
+                            i >>= 4;
+                            break;
+                        }
+                    }
+                    if (j == 0) {
+                        token = ERROR;
+                        goto string_error;
+                    }
+                    *p++ = (char)i;
+                    len++;
+                    break;
+                case EOF:
+                    putbackch(c, lastch);
+                    token = ERROR;
+                    goto string_error;
+                default:
+                    *p++ = (char)c;
+                    len++;
+                    break;
+                }
+            } else {
+                *p++ = (char)c;
+                len++;
+            }
+        }
+        *p = '\0';
+        token = STRING;
+        break;
     case '#':
-       while ((c = nextch(fp, lastch)) != '\n' && c != EOF) {
-       }
-       if (c == '\n') {
-           token = ENDOFLINE;
-       } else {
-           token = ENDOFFILE;
-       }
-       break;
+        while ((c = nextch(fp, lastch)) != '\n' && c != EOF) {
+        }
+        if (c == '\n') {
+            token = ENDOFLINE;
+        } else {
+            token = ENDOFFILE;
+        }
+        break;
     default:
-       if (isalnum(c) || c == '_' || c == '-') {
-           if (len >= *buflen - 1) {
-               *buflen += BUFSIZ;
-               *tokenbuf = (char *)realloc(*tokenbuf,  *buflen);
-           }
-           p = *tokenbuf;
-           *p++ = (char)c;
-           len++;
-           c = nextch(fp, lastch);
-           while (isalnum(c) || c == '_' || c == '-') {
-               if (len >= *buflen - 1) {
-                       *buflen += BUFSIZ;
-                       *tokenbuf = (char *)realloc(*tokenbuf,  *buflen);
-                       p = *tokenbuf + len;
-               }
-               *p++ = (char)c;
-               len++;
-               c = nextch(fp, lastch);
-           }
-           *p = '\0';
-           putbackch(c, lastch);
-           token = KEY;
-       } else {
-           token = ERROR;
-       }
-       break;
+        if (isalnum(c) || c == '_' || c == '-') {
+            if (len >= *buflen - 1) {
+                *buflen += BUFSIZ;
+                *tokenbuf = (char *)realloc(*tokenbuf,  *buflen);
+            }
+            p = *tokenbuf;
+            *p++ = (char)c;
+            len++;
+            c = nextch(fp, lastch);
+            while (isalnum(c) || c == '_' || c == '-') {
+                if (len >= *buflen - 1) {
+                        *buflen += BUFSIZ;
+                        *tokenbuf = (char *)realloc(*tokenbuf,  *buflen);
+                        p = *tokenbuf + len;
+                }
+                *p++ = (char)c;
+                len++;
+                c = nextch(fp, lastch);
+            }
+            *p = '\0';
+            putbackch(c, lastch);
+            token = KEY;
+        } else {
+            token = ERROR;
+        }
+        break;
     }
 string_error:
     return(token);
@@ -489,27 +489,27 @@
     long mask;

     struct _modtbl {
-       const char *name;
-       long mask;
+        const char *name;
+        long mask;
     };
     struct _modtbl *p;

     static struct _modtbl tbl[] = {
-       { "Ctrl",       ControlMask     },
-       { "Lock",       LockMask      },
-       { "Caps",       LockMask      },
-       { "Shift",      ShiftMask       },
-       { "Alt",      Mod1Mask        },
-       { "Meta",       Mod1Mask      },
-       { NULL,  0             }};
+        { "Ctrl",       ControlMask     },
+        { "Lock",       LockMask        },
+        { "Caps",       LockMask        },
+        { "Shift",      ShiftMask       },
+        { "Alt",        Mod1Mask        },
+        { "Meta",       Mod1Mask        },
+        { NULL,         0               }};

     p = tbl;
     mask = 0;
     for (p = tbl; p->name != NULL; p++) {
-       if (strcmp(name, p->name) == 0) {
-           mask = p->mask;
-           break;
-       }
+        if (strcmp(name, p->name) == 0) {
+            mask = p->mask;
+            break;
+        }
     }
     return(mask);
 }
@@ -527,32 +527,32 @@
     i = name;
     lcCompose[0] = ret[0] = '\0';
     while (*i && j - ret < MAXPATHLEN - 1) {
-       if (*i == '%') {
-           i++;
-           switch (*i) {
-           case '%':
-               *j++ = '%';
-               break;
-           case 'H':
-               home = getenv("HOME");
-               if (home) {
-                   strlcat(ret, home, sizeof(ret));
-                   j += strlen(home);
-               }
-               break;
-           case 'L':
-               get_compose_filename(lcCompose, sizeof(lcCompose));
-               if (lcCompose[0] != '\0') {
-                   strlcat(ret, lcCompose, sizeof(ret));
-                   j += strlen(lcCompose);
-               }
-               break;
-           }
-           i++;
-       } else {
-           *j++ = *i++;
-       }
-       *j = '\0';
+        if (*i == '%') {
+            i++;
+            switch (*i) {
+            case '%':
+                *j++ = '%';
+                break;
+            case 'H':
+                home = getenv("HOME");
+                if (home) {
+                    strlcat(ret, home, sizeof(ret));
+                    j += strlen(home);
+                }
+                break;
+            case 'L':
+                get_compose_filename(lcCompose, sizeof(lcCompose));
+                if (lcCompose[0] != '\0') {
+                    strlcat(ret, lcCompose, sizeof(ret));
+                    j += strlen(lcCompose);
+                }
+                break;
+            }
+            i++;
+        } else {
+            *j++ = *i++;
+        }
+        *j = '\0';
     }
     strlcpy(transname, ret, len);

@@ -581,7 +581,7 @@

     p = setlocale(LC_CTYPE, NULL);
     if (p)
-       p = strchr(p, '.');
+        p = strchr(p, '.');

     return p ? p + 1 : "UTF-8";
 #endif
@@ -617,7 +617,7 @@
     QString qs = QString(QChar(ks));
     mb = (const char *)qs.local8Bit();
     if (!mb)
-       return 0;
+        return 0;
     len = strlen(mb);
     strlcpy(buf, mb, MB_LEN_MAX + 1);

@@ -647,9 +647,9 @@
     char *rhs_string_utf8;

     struct DefBuffer {
-       unsigned modifier_mask;
-       unsigned modifier;
-       KeySym keysym;
+        unsigned modifier_mask;
+        unsigned modifier;
+        KeySym keysym;
     };

     struct DefBuffer buf[SEQUENCE_MAX];
@@ -658,180 +658,180 @@
     QString qs;

     do {
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
     } while (token == ENDOFLINE);

     if (token == ENDOFFILE) {
-       return(-1);
+        return(-1);
     }

     n = 0;
     do {
-       if ((token == KEY) && (strcmp("include", *tokenbuf) == 0)) {
-           char filename[MAXPATHLEN];
-           FILE *infp;
-           token = nexttoken(fp, tokenbuf, &lastch, buflen);
-           if (token != KEY && token != STRING)
-               goto error;
-
- if (!TransFileName(filename, *tokenbuf, sizeof(filename)) || filename[0] == '\0')
-               goto error;
-           infp = fopen(filename, "r");
-           if (infp == NULL)
-               goto error;
-           ParseComposeStringFile(infp);
-           fclose(infp);
-           return 0;
-       } else if ((token == KEY) && (strcmp("None", *tokenbuf) == 0)) {
-           modifier = 0;
-           modifier_mask = AllMask;
-           token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       } else {
-           modifier_mask = modifier = 0;
-           exclam = False;
-           if (token == EXCLAM) {
-               exclam = True;
-               token = nexttoken(fp, tokenbuf, &lastch, buflen);
-           }
-           while (token == TILDE || token == KEY) {
-               tilde = False;
-               if (token == TILDE) {
-                   tilde = True;
-                   token = nexttoken(fp, tokenbuf, &lastch, buflen);
-                   if (token != KEY)
-                       goto error;
-               }
-               tmp = modmask(*tokenbuf);
-               if (!tmp) {
-                   goto error;
-               }
-               modifier_mask |= tmp;
-               if (tilde) {
-                   modifier &= ~tmp;
-               } else {
-                   modifier |= tmp;
-               }
-               token = nexttoken(fp, tokenbuf, &lastch, buflen);
-           }
-           if (exclam) {
-               modifier_mask = AllMask;
-
-           }
-       }
-
-       if (token != LESS) {
-           goto error;
-       }
-
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       if (token != KEY) {
-           goto error;
-       }
-
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       if (token != GREATER) {
-           goto error;
-       }
-
-       keysym = XStringToKeysym(*tokenbuf);
-       if (keysym == NoSymbol) {
-           goto error;
-       }
-
-       buf[n].keysym = keysym;
-       buf[n].modifier = modifier;
-       buf[n].modifier_mask = modifier_mask;
-       n++;
-       if (n >= SEQUENCE_MAX)
-           goto error;
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        if ((token == KEY) && (strcmp("include", *tokenbuf) == 0)) {
+            char filename[MAXPATHLEN];
+            FILE *infp;
+            token = nexttoken(fp, tokenbuf, &lastch, buflen);
+            if (token != KEY && token != STRING)
+                goto error;
+
+ if (!TransFileName(filename, *tokenbuf, sizeof(filename)) || filename[0] == '\0')
+                goto error;
+            infp = fopen(filename, "r");
+            if (infp == NULL)
+                goto error;
+            ParseComposeStringFile(infp);
+            fclose(infp);
+            return 0;
+        } else if ((token == KEY) && (strcmp("None", *tokenbuf) == 0)) {
+            modifier = 0;
+            modifier_mask = AllMask;
+            token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        } else {
+            modifier_mask = modifier = 0;
+            exclam = False;
+            if (token == EXCLAM) {
+                exclam = True;
+                token = nexttoken(fp, tokenbuf, &lastch, buflen);
+            }
+            while (token == TILDE || token == KEY) {
+                tilde = False;
+                if (token == TILDE) {
+                    tilde = True;
+                    token = nexttoken(fp, tokenbuf, &lastch, buflen);
+                    if (token != KEY)
+                        goto error;
+                }
+                tmp = modmask(*tokenbuf);
+                if (!tmp) {
+                    goto error;
+                }
+                modifier_mask |= tmp;
+                if (tilde) {
+                    modifier &= ~tmp;
+                } else {
+                    modifier |= tmp;
+                }
+                token = nexttoken(fp, tokenbuf, &lastch, buflen);
+            }
+            if (exclam) {
+                modifier_mask = AllMask;
+
+            }
+        }
+
+        if (token != LESS) {
+            goto error;
+        }
+
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        if (token != KEY) {
+            goto error;
+        }
+
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        if (token != GREATER) {
+            goto error;
+        }
+
+        keysym = XStringToKeysym(*tokenbuf);
+        if (keysym == NoSymbol) {
+            goto error;
+        }
+
+        buf[n].keysym = keysym;
+        buf[n].modifier = modifier;
+        buf[n].modifier_mask = modifier_mask;
+        n++;
+        if (n >= SEQUENCE_MAX)
+            goto error;
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
     } while (token != COLON);

     token = nexttoken(fp, tokenbuf, &lastch, buflen);
     if (token == STRING) {
-       if ((rhs_string_mb = (char *)malloc(strlen(*tokenbuf) + 1)) == NULL)
-           goto error;
-       strcpy(rhs_string_mb, *tokenbuf);
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       if (token == KEY) {
-           rhs_keysym = XStringToKeysym(*tokenbuf);
-           if (rhs_keysym == NoSymbol) {
-               free(rhs_string_mb);
-               goto error;
-           }
-           token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       }
-       if (token != ENDOFLINE && token != ENDOFFILE) {
-           free(rhs_string_mb);
-           goto error;
-       }
+ if ((rhs_string_mb = (char *)malloc(strlen(*tokenbuf) + 1)) == NULL)
+            goto error;
+        strcpy(rhs_string_mb, *tokenbuf);
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        if (token == KEY) {
+            rhs_keysym = XStringToKeysym(*tokenbuf);
+            if (rhs_keysym == NoSymbol) {
+                free(rhs_string_mb);
+                goto error;
+            }
+            token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        }
+        if (token != ENDOFLINE && token != ENDOFFILE) {
+            free(rhs_string_mb);
+            goto error;
+        }
     } else if (token == KEY) {
-       rhs_keysym = XStringToKeysym(*tokenbuf);
-       if (rhs_keysym == NoSymbol) {
-           goto error;
-       }
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
-       if (token != ENDOFLINE && token != ENDOFFILE) {
-           goto error;
-       }
-
-       l = get_mb_string(local_mb_buf, rhs_keysym);
-       if (l == 0) {
-           rhs_string_mb = (char *)malloc(1);
-       } else {
-           rhs_string_mb = (char *)malloc(l + 1);
-       }
-       if (rhs_string_mb == NULL) {
-           goto error;
-       }
-       memcpy(rhs_string_mb, local_mb_buf, l);
-       rhs_string_mb[l] = '\0';
+        rhs_keysym = XStringToKeysym(*tokenbuf);
+        if (rhs_keysym == NoSymbol) {
+            goto error;
+        }
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        if (token != ENDOFLINE && token != ENDOFFILE) {
+            goto error;
+        }
+
+        l = get_mb_string(local_mb_buf, rhs_keysym);
+        if (l == 0) {
+            rhs_string_mb = (char *)malloc(1);
+        } else {
+            rhs_string_mb = (char *)malloc(l + 1);
+        }
+        if (rhs_string_mb == NULL) {
+            goto error;
+        }
+        memcpy(rhs_string_mb, local_mb_buf, l);
+        rhs_string_mb[l] = '\0';
     } else {
-       goto error;
+        goto error;
     }

     qs = codec->toUnicode(rhs_string_mb);
     rhs_string_utf8 = strdup((const char *)qs.utf8());

     for (i = 0; i < n; i++) {
-       for (p = *top; p; p = p->next) {
-           if (buf[i].keysym == p->keysym &&
-               buf[i].modifier == p->modifier &&
-               buf[i].modifier_mask == p->modifier_mask) {
-               break;
-           }
-       }
-       if (p) {
-           top = &p->succession;
-       } else {
-           if ((p = (DefTree*)malloc(sizeof(DefTree))) == NULL) {
-               free(rhs_string_mb);
-               goto error;
-           }
-           p->keysym = buf[i].keysym;
-           p->modifier = buf[i].modifier;
-           p->modifier_mask = buf[i].modifier_mask;
-           p->succession = NULL;
-           p->next = *top;
-           p->mb = NULL;
-           p->utf8 = NULL;
-           p->ks = NoSymbol;
-           *top = p;
-           top = &p->succession;
-       }
+        for (p = *top; p; p = p->next) {
+            if (buf[i].keysym == p->keysym &&
+                buf[i].modifier == p->modifier &&
+                buf[i].modifier_mask == p->modifier_mask) {
+                break;
+            }
+        }
+        if (p) {
+            top = &p->succession;
+        } else {
+            if ((p = (DefTree*)malloc(sizeof(DefTree))) == NULL) {
+                free(rhs_string_mb);
+                goto error;
+            }
+            p->keysym = buf[i].keysym;
+            p->modifier = buf[i].modifier;
+            p->modifier_mask = buf[i].modifier_mask;
+            p->succession = NULL;
+            p->next = *top;
+            p->mb = NULL;
+            p->utf8 = NULL;
+            p->ks = NoSymbol;
+            *top = p;
+            top = &p->succession;
+        }
     }

     if (p->mb != NULL)
-       free(p->mb);
+        free(p->mb);
     p->mb = rhs_string_mb;
     if (p->utf8 != NULL)
-       free(p->utf8);
+        free(p->utf8);
     p->utf8 = rhs_string_utf8;
     p->ks = rhs_keysym;
     return n;
 error:
     while (token != ENDOFLINE && token != ENDOFFILE) {
-       token = nexttoken(fp, tokenbuf, &lastch, buflen);
+        token = nexttoken(fp, tokenbuf, &lastch, buflen);
     }
     return 0;
 }
@@ -859,15 +859,15 @@
     size_t buflen = BUFSIZ;

     if (fstat(fileno(fp), &st) != -1 && S_ISREG(st.st_mode) &&
-       st.st_size > 0) {
-
-       tbp = (char *)malloc(buflen);
-       p[0] = tbp;
-       if (tbp != NULL) {
-           while (parse_compose_line(fp, p, &buflen) >= 0) {
-           }
-           free(p[0]);
-       }
+        st.st_size > 0) {
+
+        tbp = (char *)malloc(buflen);
+        p[0] = tbp;
+        if (tbp != NULL) {
+            while (parse_compose_line(fp, p, &buflen) >= 0) {
+            }
+            free(p[0]);
+        }
     }
 }

@@ -884,29 +884,29 @@
     compose_env = getenv("XCOMPOSEFILE");

     if (compose_env != NULL) {
-       strlcpy(name, compose_env, sizeof(name));
+        strlcpy(name, compose_env, sizeof(name));
     } else {
-       char *home = getenv("HOME");
-       if (home != NULL) {
-           snprintf(name, sizeof(name), "%s/.XCompose", home);
-           fp = fopen(name, "r");
-           if (fp == NULL)
-               name[0] = '\0';
-       }
+        char *home = getenv("HOME");
+        if (home != NULL) {
+            snprintf(name, sizeof(name), "%s/.XCompose", home);
+            fp = fopen(name, "r");
+            if (fp == NULL)
+                name[0] = '\0';
+        }
     }

     if (name[0] == '\0' && !get_compose_filename(name, sizeof(name)))
-       return;
+        return;

     if (fp == NULL && ((fp = fopen(name, "r")) == NULL))
-       return;
+        return;

     ret = get_lang_region(lang_region, sizeof(lang_region));
     encoding = get_encoding();
     if (!ret || encoding == NULL) {
-       fprintf(stderr, "Warning: locale name is NULL\n");
-       fclose(fp);
-       return;
+        fprintf(stderr, "Warning: locale name is NULL\n");
+        fclose(fp);
+        return;
     }

     ParseComposeStringFile(fp);
@@ -929,51 +929,51 @@
     encoding = get_encoding();

     if (!ret || encoding == NULL)
-       return 0;
+        return 0;

     snprintf(locale, sizeof(locale), "%s.%s", lang_region, encoding);
snprintf(compose_dir_file, sizeof(compose_dir_file), "%s/%s", XLIB_DIR, COMPOSE_DIR_FILE);

     fp = fopen(compose_dir_file, "r");
     if (fp == NULL) {
-       /* retry with fallback file */
-       if (strcmp(FALLBACK_XLIB_DIR, XLIB_DIR)) {
-           snprintf(compose_dir_file, sizeof(compose_dir_file), "%s/%s",
-                           FALLBACK_XLIB_DIR, COMPOSE_DIR_FILE);
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/qt4/immodule/quiminputcontext_compose.h      Tue Jan 20 18:11:15 2009
+++ /trunk/qt4/immodule/quiminputcontext_compose.h      Sun Feb 28 14:55:40 2010
@@ -39,14 +39,14 @@
 #undef KeyRelease

 typedef struct _DefTree {
-    struct _DefTree *next;             /* another Key definition */
-    struct _DefTree *succession;       /* successive Key Sequence */
-                                       /* Key definitions */
+    struct _DefTree *next;                /* another Key definition */
+    struct _DefTree *succession;        /* successive Key Sequence */
+                                        /* Key definitions */
     unsigned modifier_mask;
     unsigned modifier;
-    KeySym keysym;                     /* leaf only */
+    KeySym keysym;                        /* leaf only */
     char *mb;
-    char *utf8;                                /* make from mb */
+    char *utf8;                                /* make from mb */
     KeySym ks;
 } DefTree;

Reply via email to