ecere/gui/EditBox: Fixed hanging caused by 308c3f8a022f58c179f5d52f87be2609fba4ddd8
authorJerome St-Louis <jerome@ecere.com>
Wed, 20 Mar 2013 03:45:21 +0000 (23:45 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 20 Mar 2013 03:45:21 +0000 (23:45 -0400)
- The EditBox assumed the UTF8_GET_CHAR macro would return numBytes = 1 for \0
  (But e.g. the text rendering in LFBDisplayDriver.ec assumed numBytes would be 0)

ecere/locale/ecere.pot
ecere/src/com/instance.ec
ecere/src/gui/controls/EditBox.ec

index 6f46c5f..3a3f9ed 100644 (file)
@@ -185,7 +185,7 @@ msgid "Control contains other controls. Delete control and children?"
 msgstr "Control contains other controls. Delete control and children?"
 
 #: ./src/gui/controls/EditBox.ec:966
-#: ./src/gui/controls/EditBox.ec:3086
+#: ./src/gui/controls/EditBox.ec:3085
 msgid "Copy\tCtrl+C"
 msgstr "Copy\tCtrl+C"
 
@@ -215,7 +215,7 @@ msgid "Custom"
 msgstr "Custom"
 
 #: ./src/gui/controls/EditBox.ec:955
-#: ./src/gui/controls/EditBox.ec:3085
+#: ./src/gui/controls/EditBox.ec:3084
 msgid "Cut\tCtrl+X"
 msgstr "Cut\tCtrl+X"
 
@@ -240,7 +240,7 @@ msgid "Defined"
 msgstr "Defined"
 
 #: ./src/gui/controls/EditBox.ec:987
-#: ./src/gui/controls/EditBox.ec:3088
+#: ./src/gui/controls/EditBox.ec:3087
 msgid "Delete\tDel"
 msgstr "Delete\tDel"
 
@@ -579,7 +579,7 @@ msgid "Open"
 msgstr "Open"
 
 #: ./src/gui/controls/EditBox.ec:976
-#: ./src/gui/controls/EditBox.ec:3087
+#: ./src/gui/controls/EditBox.ec:3086
 msgid "Paste\tCtrl+V"
 msgstr "Paste\tCtrl+V"
 
@@ -686,7 +686,7 @@ msgid "Select"
 msgstr "Select"
 
 #: ./src/gui/controls/EditBox.ec:999
-#: ./src/gui/controls/EditBox.ec:3090
+#: ./src/gui/controls/EditBox.ec:3089
 msgid "Select All\tCtrl+A"
 msgstr "Select All\tCtrl+A"
 
index 9d5dc82..21e0c55 100644 (file)
@@ -6635,6 +6635,7 @@ public int UTF16toUTF8Buffer(uint16 * source, byte * dest, int max)
    return d;
 }
 
+// NOTE: UTF8GetChar now returns 0 into numBytes for the null-terminating character ('\0')
 public unichar UTF8GetChar(char * string, int * numBytes)
 {
    unichar ch;
index faf79a8..ff0116a 100644 (file)
@@ -2024,9 +2024,8 @@ private:
       int c, position = 0;
       unichar ch;
       int nb;
-      for(c = 0; c<this.line.count && c<this.x; c+= nb)
+      for(c = 0; c<this.line.count && c<this.x && (ch = UTF8_GET_CHAR(this.line.buffer + c, nb)); c+= nb)
       {
-         ch = UTF8_GET_CHAR(this.line.buffer + c, nb);
          // TODO: MIGHT WANT TO RETHINK WHAT COLUMN SHOULD BE REGARDING TABS
          if(ch == '\t')
             position += this.tabSize - (position % this.tabSize);
@@ -3369,7 +3368,7 @@ private:
             for(c = start; c<line.count; c += numBytes)
             {
                unichar ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
-               if(!IS_ALUNDER(ch))
+               if(!ch || !IS_ALUNDER(ch))
                   break;
             }
             SelDirty();
@@ -3811,9 +3810,9 @@ private:
                      int start = (line == this.line) ? this.x : 0;
                      int c;
                      int numBytes;
-                     for(c = start; c < line.count; c += numBytes)
+                     unichar ch;
+                     for(c = start; c < line.count && (ch = UTF8_GET_CHAR(line.buffer + c, numBytes)); c += numBytes)
                      {
-                        unichar ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
                         if(IS_ALUNDER(ch))
                         {
                            foundAlpha = true;
@@ -3860,9 +3859,9 @@ private:
                      int start = (line == this.line) ? this.x : 0;
                      int c;
                      int numBytes;
-                     for(c = start; c < line.count; c += numBytes)
+                     unichar ch;
+                     for(c = start; c < line.count && (ch = UTF8_GET_CHAR(line.buffer + c, numBytes)); c += numBytes)
                      {
-                        unichar ch = UTF8_GET_CHAR(line.buffer + c, numBytes);
                         if(!IS_ALUNDER(ch))
                            foundAlpha = true;
                         else if(foundAlpha)