[Mono-bugs] [Bug 49660][Nor] New - bad implementation of microsoft.visualbasic.strings.right

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 14 Oct 2003 18:13:17 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by smeegoan@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=49660

--- shadow/49660	2003-10-14 18:13:17.000000000 -0400
+++ shadow/49660.tmp.14503	2003-10-14 18:13:17.000000000 -0400
@@ -0,0 +1,83 @@
+Bug#: 49660
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: smeegoan@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: bad implementation of microsoft.visualbasic.strings.right
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+the right fuction in vb is bad implemented
+
+Steps to reproduce the problem:
+1. put the following in module1.vb
+
+Imports Microsoft.VisualBasic.Strings
+Imports System.Windows.Forms
+
+Module Module1
+
+    Sub Main()
+        Console.WriteLine(Right(Application.StartupPath, 1))
+    End Sub
+
+End Module
+
+2. compile with vbc or mbas
+3. run with mono
+
+Actual Results:
+
+C:\Documents and Settings\XML\Os meus documentos\Visual Studio 
+Projects\NET\Cons
+oleApplication1\bin>mono ConsoleApplication1.exe
+
+Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out 
+of rang
+e
+in <0x00042> System.String:Substring (int)
+in <0x00064> Microsoft.VisualBasic.Strings:Right (string,int)
+in <0x00015> ConsoleApplication1.Module1:Main ()
+
+Expected Results:
+
+C:\Documents and Settings\XML\Os meus documentos\Visual Studio 
+Projects\NET\Cons
+oleApplication1\bin>ConsoleApplication1.exe
+n
+
+How often does this happen? 
+
+always
+
+Additional Information:
+
+a fix can be to replace 
+
+return Str.Substring((Str.Length - Length));
+
+with 
+
+int num1;
+if ((Length == 0) || (str == null))
+{
+ return ""; 
+}
+num1 = str.Length;
+if (Length >= num1)
+{
+ return str; 
+}
+return str.Substring((num1 - Length), Length);