X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.Text%2FDecoder.cs;h=c44176989c8acdac1df35754ad32cffbc069bf14;hb=bd002446fc59b1c7f2e69f15a99f8f70da8c8756;hp=74062465718f4c05303dfe4d855bbcbf831dd165;hpb=04d1b4116331e3813b8f75304f714a5d61ba1214;p=mono.git diff --git a/mcs/class/corlib/System.Text/Decoder.cs b/mcs/class/corlib/System.Text/Decoder.cs index 74062465718..c44176989c8 100644 --- a/mcs/class/corlib/System.Text/Decoder.cs +++ b/mcs/class/corlib/System.Text/Decoder.cs @@ -29,16 +29,13 @@ using System; using System.Runtime.InteropServices; [Serializable] -#if NET_2_0 [ComVisible (true)] -#endif public abstract class Decoder { // Constructor. protected Decoder () {} -#if NET_2_0 DecoderFallback fallback = new DecoderReplacementFallback (); DecoderFallbackBuffer fallback_buffer; @@ -61,7 +58,6 @@ public abstract class Decoder return fallback_buffer; } } -#endif // Get the number of characters needed to decode a buffer. public abstract int GetCharCount (byte[] bytes, int index, int count); @@ -70,7 +66,6 @@ public abstract class Decoder public abstract int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex); -#if NET_2_0 [ComVisible (false)] public virtual int GetCharCount (byte [] bytes, int index, int count, bool flush) { @@ -113,10 +108,11 @@ public abstract class Decoder CheckArguments (chars, charCount, bytes, byteCount); char [] carr = new char [charCount]; - Marshal.Copy ((IntPtr) chars, carr, 0, charCount); byte [] barr = new byte [byteCount]; Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount); - return GetChars (barr, 0, byteCount, carr, 0, flush); + int charsUsed = GetChars (barr, 0, byteCount, carr, 0, flush); + Marshal.Copy (carr, 0, (IntPtr) chars, charsUsed); + return charsUsed; } [ComVisible (false)] @@ -154,7 +150,10 @@ public abstract class Decoder out int bytesUsed, out int charsUsed, out bool completed) { CheckArguments (bytes, byteIndex, byteCount); - CheckArguments (chars, charIndex); + if (chars == null) + throw new ArgumentNullException ("chars"); + if (charIndex < 0) + throw new ArgumentOutOfRangeException ("charIndex"); if (charCount < 0 || chars.Length < charIndex + charCount) throw new ArgumentOutOfRangeException ("charCount"); @@ -174,7 +173,7 @@ public abstract class Decoder { if (chars == null) throw new ArgumentNullException ("chars"); - if (charIndex < 0 || chars.Length <= charIndex) + if (charIndex < 0 || chars.Length < charIndex) throw new ArgumentOutOfRangeException ("charIndex"); } @@ -182,7 +181,7 @@ public abstract class Decoder { if (bytes == null) throw new ArgumentNullException ("bytes"); - if (byteIndex < 0 || bytes.Length <= byteIndex) + if (byteIndex < 0) throw new ArgumentOutOfRangeException ("byteIndex"); if (byteCount < 0 || bytes.Length < byteIndex + byteCount) throw new ArgumentOutOfRangeException ("byteCount"); @@ -199,8 +198,6 @@ public abstract class Decoder if (byteCount < 0) throw new ArgumentOutOfRangeException ("byteCount"); } -#endif - }; // class Decoder }; // namespace System.Text