2005-08-25 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 25 Aug 2005 14:20:53 +0000 (14:20 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 25 Aug 2005 14:20:53 +0000 (14:20 -0000)
* driver.cs, support.cs : merged r48826.
  Marek Safer wrote:
  > could you integrate your mcs changes to gmcs otherwise
  > gmcs cannot compile some files.

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

mcs/gmcs/ChangeLog
mcs/gmcs/driver.cs
mcs/gmcs/support.cs

index b351cd0853308405c9356f1770b734d58fbc87fd..0be314abe6bb69d9b5d8f26cc932a028a3b3883e 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * driver.cs, support.cs : merged r48826.
+         Marek Safer wrote:
+         > could you integrate your mcs changes to gmcs otherwise
+         > gmcs cannot compile some files.
+
 2005-08-20  Martin Baulig  <martin@ximian.com>
 
        * anonymous.cs (CaptureContext.CaptureThis): Create the topmost
index e961c62bacf78dacf8e3a6f3090c2f3b3555beeb..88b702164849f2ed01d3f056cf866574bdc12217 100644 (file)
@@ -92,16 +92,10 @@ namespace Mono.CSharp
                static DateTime last_time, first_time;
 
                //
-               // Encoding: ISO-Latin1 is 28591
+               // Encoding.
                //
                static Encoding encoding;
 
-               //
-               // Whether the user has specified a different encoder manually
-               //
-               static bool using_default_encoder = true;
-
-
                static public void Reset ()
                {
                        want_debugging_support = false;
@@ -115,7 +109,6 @@ namespace Mono.CSharp
                        defines = null;
                        output_file = null;
                        encoding = null;
-                       using_default_encoder = true;
                        first_source = null;
                }
 
@@ -159,7 +152,7 @@ namespace Mono.CSharp
                        }
 
                        using (input){
-                               SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
+                               SeekableStreamReader reader = new SeekableStreamReader (input, encoding);
                                Tokenizer lexer = new Tokenizer (reader, file, defines);
                                int token, tokens = 0, errors = 0;
 
@@ -187,7 +180,7 @@ namespace Mono.CSharp
                                return;
                        }
 
-                       SeekableStreamReader reader = new SeekableStreamReader (input, encoding, using_default_encoder);
+                       SeekableStreamReader reader = new SeekableStreamReader (input, encoding);
                                
                        parser = new CSharpParser (reader, file, defines);
                        parser.ErrorOutput = Report.Stderr;
@@ -1298,27 +1291,21 @@ namespace Mono.CSharp
                                return true;
 
                        case "/codepage":
-                               int cp = -1;
-
-                               if (value == "utf8"){
+                               switch (value) {
+                               case "utf8":
                                        encoding = new UTF8Encoding();
-                                       using_default_encoder = false;
-                                       return true;
-                               }
-                               if (value == "reset"){
-                                       //
-                                       // 28591 is the code page for ISO-8859-1 encoding.
-                                       //
-                                       cp = 28591;
-                                       using_default_encoder = true;
-                               }
-                               
-                               try {
-                                       cp = Int32.Parse (value);
-                                       encoding = Encoding.GetEncoding (cp);
-                                       using_default_encoder = false;
-                               } catch {
-                                       Report.Error (2016, "Code page `{0}' is invalid or not installed", value);
+                                       break;
+                               case "reset":
+                                       encoding = Encoding.Default;
+                                       break;
+                               default:
+                                       try {
+                                               encoding = Encoding.GetEncoding (
+                                                       Int32.Parse (value));
+                                       } catch {
+                                               Report.Error (2016, "Code page `{0}' is invalid or not installed", value);
+                                       }
+                                       break;
                                }
                                return true;
                        }
@@ -1366,13 +1353,8 @@ namespace Mono.CSharp
                        int i;
                        bool parsing_options = true;
 
-                       try {
-                               encoding = Encoding.GetEncoding (28591);
-                       } catch {
-                               Console.WriteLine ("Error: could not load encoding 28591, trying 1252");
-                               encoding = Encoding.GetEncoding (1252);
-                       }
-                       
+                       encoding = Encoding.Default;
+
                        references = new ArrayList ();
                        soft_references = new ArrayList ();
                        modules = new ArrayList ();
index c70913507fd3649a75b7b2d24dc86c0ecca98cea..9b9f6878a767e3e64ba84596be8ad662cd46fd0b 100644 (file)
@@ -447,40 +447,12 @@ namespace Mono.CSharp {
                        // Let the StreamWriter autodetect the encoder
                        reader.Peek ();
                        
-                       reader.BaseStream.Position = 0;
                        Encoding enc = reader.CurrentEncoding;
-                       // First of all, get at least a char
-                       
-                       byte[] auxb = new byte [50];
-                       int num_bytes = 0;
-                       int num_chars = 0;
-                       int br = 0;
-                       do {
-                               br = reader.BaseStream.Read (auxb, num_bytes, auxb.Length - num_bytes);
-                               num_bytes += br;
-                               num_chars = enc.GetCharCount (auxb, 0, num_bytes);
-                       }
-                       while (num_chars == 0 && br > 0);
-                       
-                       if (num_chars != 0)
-                       {
-                               // Now, check which bytes at the beginning have no effect in the
-                               // char count
-                               
-                               int p = 0;
-                               while (enc.GetCharCount (auxb, p, num_bytes-p) >= num_chars)
-                                       p++;
-                               
-                               preamble_size = p - 1;
-                               reader.BaseStream.Position = 0;
-                               reader.DiscardBufferedData ();
-                               
-                               buffer_start = preamble_size;
-                       }
+                       preamble_size = (int) reader.BaseStream.Position;
                }
 
-               public SeekableStreamReader (Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks)
-                       : this (new StreamReader (stream, encoding, detect_encoding_from_bytemarks))
+               public SeekableStreamReader (Stream stream, Encoding encoding)
+                       : this (new StreamReader (stream, encoding, true))
                { }
 
                StreamReader reader;