wine/dlls/msvcrt tests/string.c mbcs.c

Alexandre Julliard julliard at wine.codeweavers.com
Mon Nov 21 06:03:18 CST 2005


ChangeSet ID:	21363
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/21 06:03:18

Modified files:
	dlls/msvcrt/tests: string.c 
	dlls/msvcrt    : mbcs.c 

Log message:
	Rein Klazes <wijn at wanadoo.nl>
	Fix _mbsspn() with conformance tests.

Patch: http://cvs.winehq.org/patch.py?id=21363

Old revision  New revision  Changes     Path
 1.5           1.6           +18 -0      wine/dlls/msvcrt/tests/string.c
 1.34          1.35          +22 -20     wine/dlls/msvcrt/mbcs.c

Index: wine/dlls/msvcrt/tests/string.c
diff -u -p wine/dlls/msvcrt/tests/string.c:1.5 wine/dlls/msvcrt/tests/string.c:1.6
--- wine/dlls/msvcrt/tests/string.c:1.5	21 Nov 2005 12: 3:18 -0000
+++ wine/dlls/msvcrt/tests/string.c	21 Nov 2005 12: 3:18 -0000
@@ -21,6 +21,7 @@
 #include "wine/test.h"
 #include "winbase.h"
 #include <string.h>
+#include <mbstring.h>
 #include <stdlib.h>
 #include <mbctype.h>
 
@@ -83,6 +84,21 @@ void test_ismbblead()
     _setmbcp(1252);
 }
 
+static void test_mbsspn( void)
+{
+    unsigned char str1[]="cabernet";
+    unsigned char str2[]="shiraz";
+    unsigned char set[]="abc";
+    unsigned char empty[]="";
+    int ret;
+    ret=_mbsspn( str1, set);
+    ok( ret==3, "_mbsspn returns %d should be 3\n", ret);
+    ret=_mbsspn( str2, set);
+    ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
+    ret=_mbsspn( str1, empty);
+    ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
+}
+
 START_TEST(string)
 {
     void *mem;
@@ -107,4 +123,6 @@ START_TEST(string)
 
     /* Test ismbblead*/
     test_ismbblead();
+   /* test _mbsspn */
+    test_mbsspn();
 }
Index: wine/dlls/msvcrt/mbcs.c
diff -u -p wine/dlls/msvcrt/mbcs.c:1.34 wine/dlls/msvcrt/mbcs.c:1.35
--- wine/dlls/msvcrt/mbcs.c:1.34	21 Nov 2005 12: 3:18 -0000
+++ wine/dlls/msvcrt/mbcs.c	21 Nov 2005 12: 3:18 -0000
@@ -1154,29 +1154,31 @@ unsigned char* _mbsupr(unsigned char* s)
  */
 MSVCRT_size_t _mbsspn(const unsigned char* string, const unsigned char* set)
 {
-  const unsigned char *p, *q;
+    const unsigned char *p, *q;
 
-  for (p = string; *p; p++)
+    for (p = string; *p; p++)
     {
-      if (MSVCRT_isleadbyte(*p))
-	{
-	  for (q = set; *q; q++)
-	    {
-	      if (!q[1])
-		break;
-	      if ((*p == *q) &&  (p[1] == q[1]))
-		break;
-	      q++;
-	    }
-	  if (*++p == '\0')
-	    break;
-	}
-      else
-	for (q = set; *q; q++)
-	  if (*p == *q)
-	    break;
+        if (MSVCRT_isleadbyte(*p))
+        {
+            for (q = set; *q; q++)
+            {
+                if (!q[1])
+                    break;
+                if ((*p == *q) &&  (p[1] == q[1]))
+                    break;
+                q++;
+            }
+            if (!q[0] || !q[1]) break;
+        }
+        else
+        {
+            for (q = set; *q; q++)
+                if (*p == *q)
+                    break;
+            if (!*q) break;
+        }
     }
-  return p - string;
+    return p - string;
 }
 
 /*********************************************************************



More information about the wine-cvs mailing list