Package: libmono-system2.0-cil
Version: 2.6.7-5
Severity: normal
Tags: upstream patch

Hello,

There is a difference at runtime between Mono and Microsoft interpretation of
the {0} RegExp qualifier:

The "a(?:b|c){0}c" should not match "abc" because of "{0}" (test #1).
I have the following output on Debian Squeeze:
Test #1: (expected NO match)
0:acd   1:d     
Got 1 match(s)
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d     
Got 1 match(s)
-----------------------------
Test #3: (expected 1 match)
0:abbcbcd       1:d     
Got 1 match(s)
-----------------------------
Test #4: (expected NO match)
Got 0 match(s)
Ends.

Expected result (On Windows for example):

Test #1: (expected NO match)
Got 0 match(s)
-----------------------------
Test #2: (expected 1 match)
0:ad    1:d
Got 1 match(s)
-----------------------------
Test #3: (expected 1 match)
0:abbcbcd       1:d
Got 1 match(s)
-----------------------------
Test #4: (expected NO match)
Got 0 match(s)
Ends.


I also tested with python re and the result is as expected (as MS 
implementation).

You'll find the code used for the test just below (and the proposed patch 
upstream
for review https://bugzilla.novell.com/show_bug.cgi?id=675288 ).

Regards,
Damien Degois

-------------------------------------------------------------------------------------
--- mcs/class/System/System.Text.RegularExpressions/ORG_parser.cs    2011-02-26 
01:53:57.492607003 +0100
+++ mcs/class/System/System.Text.RegularExpressions/parser.cs    2011-02-26 
02:00:03.912607003 +0100
@@ -774,7 +774,7 @@
             /* assign min and max */

             min = n;
-            if (m > 0)
+            if (m >= 0)
                 max = m;
             else
                 max = 0x7fffffff;

-------------------------------------------------------------------------------------
using System;
using System.Text.RegularExpressions;

namespace testREGEXP
{
        class MainClass
        {
                public static void Main (string[] args)
                {
                        Regex r;
                        MatchCollection mc;

                        Console.WriteLine("Test #1: (expected NO match)");
                        r = new Regex("a(?:b|c){0}(d)");
                        mc = r.Matches("acd");
                        ShowMatchCollection(mc);

                        Console.WriteLine("-----------------------------");
                        Console.WriteLine("Test #2: (expected 1 match)");
                        r = new Regex("a(?:b|c){0}(d)");
                        mc = r.Matches("ad");
                        ShowMatchCollection(mc);

                        Console.WriteLine("-----------------------------");
                        Console.WriteLine("Test #3: (expected 1 match)");
                        r = new Regex("a(?:b|c){0,}(d)");
                        mc = r.Matches("abbcbcd");
                        ShowMatchCollection(mc);

                        Console.WriteLine("-----------------------------");
                        Console.WriteLine("Test #4: (expected NO match)");
                        r = new Regex("a(?:b|c){,2}(d)");
                        mc = r.Matches("abbcbcd");
                        ShowMatchCollection(mc);

                        Console.WriteLine ("Ends.");

                }
                public static void ShowMatchCollection(MatchCollection mc) {
                        int match_count = 0;
                        foreach(Match m in mc) {
                                for (int i = 0; i < m.Groups.Count; i++) {
                                        
Console.Write(string.Format("{0}:{1}\t",i,m.Groups[i].Value));
                                }
                                match_count++;
                                Console.WriteLine();
                        }
                        Console.WriteLine("Got {0} match(s)",match_count);
                }
        }
}
-------------------------------------------------------------------------------------




-- System Information:
Debian Release: 6.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-openvz-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libmono-system2.0-cil depends on:
ii  libc6                         2.11.2-10  Embedded GNU C Library: Shared lib
ii  libmono-corlib2.0-cil         2.6.7-5    Mono core library (for CLI 2.0)
ii  libmono-posix2.0-cil          2.6.7-5    Mono.Posix library (for CLI 2.0)
ii  libmono-security2.0-cil       2.6.7-5    Mono Security library (for CLI 2.0
ii  mono-runtime                  2.6.7-5    Mono runtime

libmono-system2.0-cil recommends no packages.

Versions of packages libmono-system2.0-cil suggests:
ii  libasound2                    1.0.23-2.1 shared library for ALSA applicatio
ii  libcups2                      1.4.4-7    Common UNIX Printing System(tm) - 
pn  libgamin0                     <none>     (no description available)
ii  libgdiplus                    2.6.7-3    interface library for System.Drawi
ii  libmono-winforms2.0-cil       2.6.7-5    Mono System.Windows.Forms library 
ii  libx11-6                      2:1.3.3-4  X11 client-side library

-- no debconf information
--- ./mcs/class/System/System.Text.RegularExpressions/ORG_parser.cs	2011-02-26 01:42:54.000000000 +0000
+++ ./mcs/class/System/System.Text.RegularExpressions/parser.cs	2011-02-26 01:43:12.000000000 +0000
@@ -774,7 +774,7 @@
 			/* assign min and max */
 			
 			min = n;
-			if (m > 0)
+			if (m >= 0)
 				max = m;
 			else
 				max = 0x7fffffff;

Reply via email to