diff --git a/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs b/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs index fa637e9b2a..97ba3670b6 100644 --- a/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs +++ b/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/BaseConstructor.cs @@ -414,7 +414,52 @@ public class BaseConstructor : IEnumerable { throw new ConstructorException("could not determine a constructor for the tag: " + node.Tag); } - private static Regex TIMESTAMP_REGEXP = new Regex("^(-?[0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \t]*(Z|([-+][0-9][0-9]?)(?::([0-9][0-9])?)?)))?$"); + private static Regex TIMESTAMP_REGEXP = new Regex(@" + ^[ \t]* + + ( # Year + -? + [0-9][0-9][0-9][0-9] + ) + - + ([0-9][0-9]?) # Month + - + ([0-9][0-9]?) # Day + + (?: + (?: + [Tt] + | + [ \t]+ + ) + + ([0-9][0-9]?) # Hour + : + ([0-9][0-9]) # Minute + : + ([0-9][0-9]) # Seconds + + (?: + \\. + ([0-9]*) # Fractional seconds + )? + + (?: + [ \t]* + ( # utc + Z + | + ([-+][0-9][0-9]?) # timezoneh + (?: # timezonem + :([0-9][0-9])? + )? + )? + ) + )? + + [ \t]*$", + RegexOptions.IgnorePatternWhitespace); + internal static Regex YMD_REGEXP = new Regex("^(-?[0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)$"); public static object ConstructYamlTimestampYMD(BaseConstructor ctor, Node node) { diff --git a/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/Scanner.cs b/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/Scanner.cs index a0e3a31f45..1940c8da3c 100644 --- a/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/Scanner.cs +++ b/Merlin/External/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Engine/Scanner.cs @@ -294,7 +294,7 @@ private class SimpleKey { private void ScanToNextToken() { while (true) { - while (Peek() == ' ') { + while (Peek() == ' ' || Peek() == '\t') { Forward(); } if (Peek() == '#') { diff --git a/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb b/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb index 380636700a..973629b1ab 100644 --- a/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb +++ b/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb @@ -39,15 +39,33 @@ File.expand_path(".", "#{@rootdir}").should == "#{@rootdir}" end - # FIXME: do not use conditionals like this around #it blocks - unless not home = ENV['HOME'].tr('\\', '/') - it "converts a pathname to an absolute pathname, using ~ (home) as base" do + it "converts a pathname to an absolute pathname, using ~ (home) as base" do + home = ENV['HOME'] + initial_home = home + begin + platform_is :windows do + if not home then + home = "c:\\Users\\janedoe" + ENV['HOME'] = home + end + home = home.tr '\\', '/' + end File.expand_path('~').should == home File.expand_path('~', '/tmp/gumby/ddd').should == home File.expand_path('~/a', '/tmp/gumby/ddd').should == File.join(home, 'a') + File.expand_path('~a').should == '~a' + File.expand_path('~/').should == home + File.expand_path('~/..badfilename').should == "#{home}/..badfilename" + File.expand_path('~/a','~/b').should == "#{home}/a" + + + ENV['HOME'] = nil + lambda { File.expand_path('~') }.should raise_error(ArgumentError) + ensure + ENV['HOME'] = initial_home end end - + platform_is_not :windows do # FIXME: these are insane! it "expand path with " do @@ -64,11 +82,8 @@ File.expand_path('./////').should == Dir.pwd File.expand_path('.').should == Dir.pwd File.expand_path(Dir.pwd).should == Dir.pwd - File.expand_path('~/').should == ENV['HOME'] - File.expand_path('~/..badfilename').should == "#{ENV['HOME']}/..badfilename" File.expand_path('..').should == Dir.pwd.split('/')[0...-1].join("/") File.expand_path('//').should == '//' - File.expand_path('~/a','~/b').should == "#{ENV['HOME']}/a" end it "raises an ArgumentError if the path is not valid" do diff --git a/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/marshal/fixtures/marshal_data.rb b/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/marshal/fixtures/marshal_data.rb index 473f1fa4a0..d6e9d4b1ee 100644 --- a/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/marshal/fixtures/marshal_data.rb +++ b/Merlin/External/Languages/IronRuby/mspec/rubyspec/core/marshal/fixtures/marshal_data.rb @@ -138,6 +138,10 @@ class UserString < String include AnAttribute end +class UserRange < Range + include AnAttribute +end + module Meths def meths_method() end end @@ -161,6 +165,9 @@ module MarshalSpec "'a'..'b'" => [('a'..'b'), "\004\bo:\nRange\b:\nbegin\"\006a:\texclF:\bend\"\006b", { :begin => 'a', :end => 'b', :exclude_end? => false }], + "Range subclass" => [UserRange.new(1,2), + "\004\bo:\016UserRange\t:\bendi\a:\nbegini\006:\texclF:\a@ai\006", + { :begin => 1, :end => 2, :exclude_end? => false, :a => 1 }], "Struct" => [Struct::Useful.new(1, 2), "\004\bS:\023Struct::Useful\a:\006ai\006:\006bi\a"], "Symbol" => [:symbol, diff --git a/Merlin/External/Languages/IronRuby/mspec/rubyspec/library/yaml/load_spec.rb b/Merlin/External/Languages/IronRuby/mspec/rubyspec/library/yaml/load_spec.rb index f70b74b2c3..f82dd594f6 100644 --- a/Merlin/External/Languages/IronRuby/mspec/rubyspec/library/yaml/load_spec.rb +++ b/Merlin/External/Languages/IronRuby/mspec/rubyspec/library/yaml/load_spec.rb @@ -16,7 +16,7 @@ it "loads strings" do strings = ["str", - " str", + "\s\tstr\s\t", "'str'", "str", " str", @@ -87,4 +87,8 @@ expected = { :"user name" => "This is the user name."} YAML.load(string).should == expected end + + it "ignores whitespace" do + YAML.load("!timestamp \s\t '\s\t 2009-03-22 \s\t 00:00:00 \s\t'").class.should == Time + end end diff --git a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs index 2dc37010cf..f82539c177 100644 --- a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs +++ b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs @@ -504,20 +504,36 @@ public static class Constants { private static MutableString/*!*/ ExpandPath(RubyContext/*!*/ context, MutableString/*!*/ path) { PlatformAdaptationLayer pal = context.DomainManager.Platform; int length = path.Length; + bool raisingRubyException = false; try { if (path == null || length == 0) return Glob.CanonicalizePath(MutableString.Create(Directory.GetCurrentDirectory())); - if (length == 1 && path.GetChar(0) == '~') - return Glob.CanonicalizePath(MutableString.Create(Path.GetFullPath(pal.GetEnvironmentVariable("HOME")))); + if (path.GetChar(0) == '~') { + if (length == 1 || (path.GetChar(1) == Path.DirectorySeparatorChar || + path.GetChar(1) == Path.AltDirectorySeparatorChar)) { - if (path.GetChar(0) == '~' && (path.GetChar(1) == Path.DirectorySeparatorChar || path.GetChar(1) == Path.AltDirectorySeparatorChar)) { - string homeDirectory = pal.GetEnvironmentVariable("HOME"); - return Glob.CanonicalizePath(length < 3 ? MutableString.Create(homeDirectory) : MutableString.Create(Path.Combine(homeDirectory, path.GetSlice(2).ConvertToString()))); + string homeDirectory = pal.GetEnvironmentVariable("HOME"); + if (homeDirectory == null) { + raisingRubyException = true; + throw RubyExceptions.CreateArgumentError("couldn't find HOME environment -- expanding `~'"); + } + if (length <= 2) { + path = MutableString.Create(homeDirectory); + } else { + path = MutableString.Create(Path.Combine(homeDirectory, path.GetSlice(2).ConvertToString())); + } + return Glob.CanonicalizePath(path); + } else { + return path; + } } else { return Glob.CanonicalizePath(MutableString.Create(Path.GetFullPath(path.ConvertToString()))); } } catch (Exception e) { + if (raisingRubyException) { + throw; + } // Re-throw exception as a reasonable Ruby exception throw new Errno.InvalidError(path.ConvertToString(), e); } diff --git a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs index e8aadda086..0d7661929f 100644 --- a/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs +++ b/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs @@ -279,9 +279,10 @@ class SubclassData { } private void WriteRange(Range/*!*/ range) { - _writer.Write((byte)'o'); - WriteSymbol("Range"); + WriteObject(range); WriteInt32(3); + // Write the attributes that are implemented in C#. Any user-defined attributes (for subtypes of Range) + // will be handled by the default handling of IRubyObject WriteSymbol("begin"); WriteAnObject(range.Begin); WriteSymbol("end"); diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/igem.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/igem.bat index dd2fc41fb8..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/igem.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/igem.bat @@ -1,2 +1,10 @@ -@ECHO OFF -@"ir.exe" "%~dpn0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %* diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/iirb.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/iirb.bat index c3cd36eb0e..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/iirb.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/iirb.bat @@ -1,2 +1,10 @@ -@ECHO OFF -"%~d0%~p0ir.exe" "%~d0%~p0%~n0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %* diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/irails.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/irails.bat index dd2fc41fb8..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/irails.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/irails.bat @@ -1,2 +1,10 @@ -@ECHO OFF -@"ir.exe" "%~dpn0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %* diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/irake.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/irake.bat index dd2fc41fb8..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/irake.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/irake.bat @@ -1,2 +1,10 @@ -@ECHO OFF -@"ir.exe" "%~dpn0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %* diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/irdoc.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/irdoc.bat index c3cd36eb0e..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/irdoc.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/irdoc.bat @@ -1,2 +1,10 @@ -@ECHO OFF -"%~d0%~p0ir.exe" "%~d0%~p0%~n0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %* diff --git a/Merlin/Main/Languages/Ruby/Scripts/bin/iri.bat b/Merlin/Main/Languages/Ruby/Scripts/bin/iri.bat index c3cd36eb0e..41487051ab 100644 --- a/Merlin/Main/Languages/Ruby/Scripts/bin/iri.bat +++ b/Merlin/Main/Languages/Ruby/Scripts/bin/iri.bat @@ -1,2 +1,10 @@ -@ECHO OFF -"%~d0%~p0ir.exe" "%~d0%~p0%~n0" %* +@echo off +setlocal + +set IR_CMD="%~dp0ir.exe" +if defined MERLIN_ROOT ( + REM - This is a dev environment. See http://wiki.github.com/ironruby/ironruby + set IR_CMD="%MERLIN_ROOT%\bin\Debug\ir.exe" +) + +%IR_CMD% "%~dpn0" %*