// Licensed under the terms of the GNU GPL
//
// (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
-// (C) 2004 Novell, Inc
+// (C) 2004, 2005 Novell, Inc
//
namespace Mono.CSharp
//
// Encoding.
//
+ static Encoding default_encoding;
static Encoding encoding;
static public void Reset ()
win32ResourceFile = win32IconFile = null;
defines = null;
output_file = null;
- encoding = null;
+ encoding = default_encoding = null;
first_source = null;
}
}
SeekableStreamReader reader = new SeekableStreamReader (input, encoding);
-
+
+ // Check 'MZ' header
+ if (reader.Read () == 77 && reader.Read () == 90) {
+ Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
+ input.Close ();
+ return;
+ }
+
+ reader.Position = 0;
parser = new CSharpParser (reader, file, defines);
parser.ErrorOutput = Report.Stderr;
try {
static void Usage ()
{
Console.WriteLine (
- "Mono C# compiler, (C) 2001 - 2003 Ximian, Inc.\n" +
+ "Mono C# compiler, (C) 2001 - 2005 Novell, Inc.\n" +
"mcs [options] source-files\n" +
" --about About the Mono C# compiler\n" +
" -addmodule:MODULE Adds the module to the generated assembly\n" +
static void About ()
{
Console.WriteLine (
- "The Mono C# compiler is (C) 2001, 2002, 2003 Ximian, Inc.\n\n" +
+ "The Mono C# compiler is (C) 2001-2005, Novell, Inc.\n\n" +
"The compiler source code is released under the terms of the GNU GPL\n\n" +
"For more information on Mono, visit the project Web site\n" +
public static int counter1, counter2;
- public static int Main (string[] args)
+ public static int Main (string[] args)
{
RootContext.Version = LanguageVersion.Default;
+ Location.InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
+
bool ok = MainDriver (args);
if (ok && Report.Errors == 0) {
encoding = new UTF8Encoding();
break;
case "reset":
- encoding = Encoding.Default;
+ encoding = default_encoding;
break;
default:
try {
encoding = Encoding.GetEncoding (
- Int32.Parse (value));
+ Int32.Parse (value));
} catch {
Report.Error (2016, "Code page `{0}' is invalid or not installed", value);
}
}
return true;
}
- //Report.Error (2007, String.Format ("Unrecognized command-line option: `{0}'", option));
- //Environment.Exit (1);
+
return false;
}
+ static void Error_WrongOption (string option)
+ {
+ Report.Error (2007, "Unrecognized command-line option: `{0}'", option);
+ }
+
static string [] AddArgs (string [] args, string [] extra_args)
{
string [] new_args;
int i;
bool parsing_options = true;
- encoding = Encoding.Default;
+ try {
+ // Latin1
+ default_encoding = Encoding.GetEncoding (28591);
+ } catch (Exception) {
+ // iso-8859-1
+ default_encoding = Encoding.GetEncoding (1252);
+ }
+ encoding = default_encoding;
references = new ArrayList ();
soft_references = new ArrayList ();
string csc_opt = "/" + arg.Substring (1);
if (CSCParseOption (csc_opt, ref args, ref i))
continue;
+
+ Error_WrongOption (arg);
+ return false;
} else {
- if (arg.StartsWith ("/")){
+ if (arg [0] == '/'){
if (CSCParseOption (arg, ref args, ref i))
continue;
+
+ // Need to skip `/home/test.cs' however /test.cs is considered as error
+ if (arg.Length < 2 || arg.IndexOf ('/', 2) == -1) {
+ Error_WrongOption (arg);
+ return false;
+ }
}
}
}
if (CodeGen.Assembly.IsClsCompliant) {
AttributeTester.VerifyModulesClsCompliance ();
TypeManager.LoadAllImportedTypes ();
- AttributeTester.VerifyTopLevelNameClsCompliance ();
}
}
if (Report.Errors > 0)
if (ep == null) {
if (RootContext.MainClass != null) {
- DeclSpace main_cont = RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass));
+ DeclSpace main_cont = RootContext.Tree.GetDecl (MemberName.FromDotted (RootContext.MainClass, Location.Null));
if (main_cont == null) {
Report.Error (1555, "Could not find `{0}' specified for Main method", RootContext.MainClass);
return false;