Переглянути джерело

Properly handle calculator characters which use 2 UTF-16 codepoints during source file splitting.

git-svn-id: file:///var/svn/tigccpp/trunk@772 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 роки тому
батько
коміт
474a65766a
1 змінених файлів з 30 додано та 1 видалено
  1. 30 1
      ktigcc/tpr.cpp

+ 30 - 1
ktigcc/tpr.cpp

@@ -952,7 +952,36 @@ int saveAndSplitFileText(const char *fileName, const QString &fileText,
           break;
       }
       if (!noInsert) {
-        INSERT_CHAR(c);
+        // Special cases:
+        switch(c.unicode()) {
+          // Surrogate pairs.
+          case 0xd800 ... 0xdbff:
+            if (curPos<l && text[curPos+1].unicode()>=0xdc00
+                         && text[curPos+1].unicode()<=0xdfff) {
+              INSERT_STRING(QString(c)+text[curPos+1]);
+              // Allow the UI to respond, splitting is a lengthy operation.
+              if ((curPos++)&127)
+                QApplication::eventLoop()->processEvents(QEventLoop::AllEvents,1000);
+              curPos++;
+              curCol++;
+              break;
+            } else goto de_fault;
+          // x-bar and y-bar are special if we use the calculator charset.
+          case 0x305:
+            if (preferences.useCalcCharset && curPos<l
+                && (text[curPos+1]=='x' || text[curPos+1]=='y')) {
+              INSERT_STRING(QString(c)+text[curPos+1]);
+              // Allow the UI to respond, splitting is a lengthy operation.
+              if ((curPos++)&127)
+                QApplication::eventLoop()->processEvents(QEventLoop::AllEvents,1000);
+              curCol++;
+              break;
+            }
+          default:
+          de_fault:
+            INSERT_CHAR(c);
+            break;
+        }
         if (c!='\n') atLineStart=FALSE;
       }
       if (c=='\n') {