* RTF.cs: look ahead for the end of the group, so we don't read
authorJackson Harper <jackson@novell.com>
Wed, 4 Apr 2007 23:10:43 +0000 (23:10 -0000)
committerJackson Harper <jackson@novell.com>
Wed, 4 Apr 2007 23:10:43 +0000 (23:10 -0000)
        past the end and pull out a piece of the next token.

svn path=/trunk/mcs/; revision=75411

mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms.RTF/RTF.cs

index 7f8a4ea438392f29fb2d800fee2c0bbd68ace03b..bc7567e3060049ef6c0410a4d26354792a7dff4b 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-04  Jackson Harper  <jackson@ximian.com>
+
+       * RTF.cs: look ahead for the end of the group, so we don't read
+       past the end and pull out a piece of the next token.
+
 2007-04-04  Jackson Harper  <jackson@ximian.com>
 
        * Picture.cs: Correct twips calculation.
index 5d085eac59dc1f6e39ea55ba474ab78605058f1d..212b7abc862c2407eaade595a15d590d950cc3ec 100644 (file)
@@ -297,7 +297,6 @@ SkipCRLF:
                /// <summary>Parse the RTF stream</summary>
                public void Read() {
                        while (GetToken() != TokenClass.EOF) {
-
                                RouteToken();
                        }
                }
@@ -958,12 +957,23 @@ SkipCRLF:
 
                                        while (true) {
 
-                                               while (hexDigit1 == '\n' || hexDigit1 == '\r')
+                                               while (hexDigit1 == '\n' || hexDigit1 == '\r') {
+                                                       hexDigit1 = (char) source.Peek ();
+                                                       if (hexDigit1 == '}')
+                                                               break;
                                                        hexDigit1 = (char) source.Read ();
-
+                                               }
+                                               
+                                               hexDigit2 = (char) source.Peek ();
+                                               if (hexDigit2 == '}')
+                                                       break;
                                                hexDigit2 = (char) source.Read ();
-                                               while (hexDigit2 == '\n' || hexDigit2 == '\r')
+                                               while (hexDigit2 == '\n' || hexDigit2 == '\r') {
+                                                       hexDigit2 = (char) source.Peek ();
+                                                       if (hexDigit2 == '}')
+                                                               break;
                                                        hexDigit2 = (char) source.Read ();
+                                               }
 
                                                if (Char.IsDigit (hexDigit1))
                                                        digitValue1 = (uint) (hexDigit1 - '0');
@@ -984,16 +994,20 @@ SkipCRLF:
                                                        digitValue2 = (uint) (hexDigit2 - 'A' + 10);
                                                else if (hexDigit2 == '\n' || hexDigit2 == '\r')
                                                        continue;
-                                               else
+                                               else 
                                                        break;
 
                                                image_data.Add ((byte) checked (digitValue1 * 16 + digitValue2));
 
                                                // We get the first hex digit at the end, since in the very first
                                                // iteration we use rtf.major as the first hex digit
+                                               hexDigit1 = (char) source.Peek ();
+                                               if (hexDigit1 == '}')
+                                                       break;
                                                hexDigit1 = (char) source.Read ();
                                        }
 
+                                       
                                        read_image_data = false;
                                        picture.Data = (byte []) image_data.ToArray (typeof (byte));
                                        break;