Re: GRegex(win32) : 500 tests passed, 3 failed



On 15.03.2007 18:45, Jake Goulding wrote:
> Having newlines seems suspicious. What kind of newlines are they?
>
\r\n and \r were failing (NEWLINE was defined to 10 in makefile.msc but -1
in Makefile.am).

I have modified my patch, the crash was somewhere else than expected, i.e.
completely in the test application ;)

Now it also prints readable newlines for the failed cases:

D:\devel\from-svn\glib\glib>..\tests\regex-test.exe
failed  (unexpected mismatch) '^b$' against 'a\r\nb\r\nc'
failed  (unexpected mismatch) '^b$' against 'a\rb\rc'
failed  (unexpected match) 'a#\rb' against 'a'

But after NEWLINE=-1 it does not fail anymore.

Thanks,
	Hans

> Hans Breuer wrote:
>> with only small modifications I was able to compile GRegex with msvc,
>> thanks for providing an almost working makefile.msc ;-)
>>
>> The first attempt to run
>>
>> 	regex-test.exe --noisy
>>
>> did crash due to gnulib not liking
>>
>> g_strdup_vprintf ("matching \"%s\" against \"%s\" \t", "%", "\p{Common}")
>>
>> The attached patch works around this and also removes the
>> #include <glib.h> from gregex.h. I think it is better to only include
>> required sub-headers like almost all glib/*.h do.
>>
>> But now for the question: are these 3 failed specific to my build so I
>> should investigate them further?
>>
>> Thanks,
>> 	Hans
>>
>> matching "a
>>
>> b
>>
>> c" against "^b$" (start: 0, len: -1) 	failed 	(unexpected mismatch)
>> matching "a
>> b
>> c" against "^b$" (start: 0, len: -1) 	failed 	(unexpected mismatch)
>>
>> matching "a" against "a#
>> b" (start: 0, len: -1) 	failed 	(unexpected match)
>>
>>
>> -------- Hans "at" Breuer "dot" Org -----------
>> Tell me what you need, and I'll tell you how to
>> get along without it.                -- Dilbert
>>   
>> ------------------------------------------------------------------------
>>
>> Index: glib/gregex.h
>> ===================================================================
>> --- glib/gregex.h	(revision 5410)
>> +++ glib/gregex.h	(working copy)
>> @@ -22,7 +22,8 @@
>>  #ifndef __G_REGEX_H__
>>  #define __G_REGEX_H__
>>  
>> -#include <glib.h>
>> +#include <glib/gerror.h>
>> +#include <glib/gstring.h>
>>  
>>  G_BEGIN_DECLS
>>  
>> Index: tests/regex-test.c
>> ===================================================================
>> --- tests/regex-test.c	(revision 5409)
>> +++ tests/regex-test.c	(working copy)
>> @@ -230,7 +230,10 @@
>>  		   gboolean            expected)
>>  {
>>    gboolean match;
>> -  
>> +  
>> +  if (string[0] == '%' && string[1] == '\0')
>> +      string = "%%";
>> +
>>    verbose ("matching \"%s\" against \"%s\" \t", string, pattern);
>>  
>>    match = g_regex_match_simple (pattern, string, compile_opts, match_opts);
>>   
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> gtk-devel-list mailing list
>> gtk-devel-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>>   
> 


-- 
-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert
Index: glib/gregex.h
===================================================================
--- glib/gregex.h	(revision 5410)
+++ glib/gregex.h	(working copy)
@@ -22,7 +22,8 @@
 #ifndef __G_REGEX_H__
 #define __G_REGEX_H__
 
-#include <glib.h>
+#include <glib/gerror.h>
+#include <glib/gstring.h>
 
 G_BEGIN_DECLS
 
Index: tests/regex-test.c
===================================================================
--- tests/regex-test.c	(revision 5409)
+++ tests/regex-test.c	(working copy)
@@ -87,7 +87,7 @@
   va_end (args);
 
   if (noisy) 
-    g_print (msg);
+    g_print ("%s", msg);
   g_free (msg);
 }
 
@@ -230,8 +230,8 @@
 		   gboolean            expected)
 {
   gboolean match;
-  
-  verbose ("matching \"%s\" against \"%s\" \t", string, pattern);
+  
+  verbose ("matching \"%s\" against \"%s\" \t", string, pattern);
 
   match = g_regex_match_simple (pattern, string, compile_opts, match_opts);
   if (match != expected)
@@ -274,8 +274,12 @@
   match = g_regex_match_full (regex, string, string_len,
 			      start_position, match_opts2, NULL);
   if (match != expected)
-    {
-      g_print ("failed \t(unexpected %s)\n", match ? "match" : "mismatch");
+    {
+      gchar *e1 = g_strescape (pattern, NULL);
+      gchar *e2 = g_strescape (string, NULL);
+      g_print ("failed \t(unexpected %s) '%s' against '%s'\n", match ? "match" : "mismatch", e1, e2);
+      g_free (e1);
+      g_free (e2);
       g_regex_free (regex);
       return FALSE;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]