msvcrt: fix _mbsspn()

Rein Klazes wijn at wanadoo.nl
Fri Nov 18 12:10:31 CST 2005


Hi,

Fixes an issue for Visual C++ compiler.

Changelog:
dlls/msvcrt	: mbcs.c
dlls/msvcrt/tests	: string.c

Fix _mbsspn() with conformance tests.

Rein.
-------------- next part --------------
--- wine/dlls/msvcrt/mbcs.c	2005-08-25 15:29:39.000000000 +0200
+++ mywine/dlls/msvcrt/mbcs.c	2005-11-18 17:57:39.000000000 +0100
@@ -1168,13 +1168,13 @@ MSVCRT_size_t _mbsspn(const unsigned cha
 		break;
 	      q++;
 	    }
-	  if (*++p == '\0')
-	    break;
+          if( !( *q) || !q[1]) break;
 	}
       else
 	for (q = set; *q; q++)
 	  if (*p == *q)
 	    break;
+        if( !( *q)) break;
     }
   return p - string;
 }
--- wine/dlls/msvcrt/tests/string.c	2005-10-11 10:40:46.000000000 +0200
+++ mywine/dlls/msvcrt/tests/string.c	2005-11-18 18:30:00.000000000 +0100
@@ -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,20 @@ void test_ismbblead()
     _setmbcp(1252);
 }
 
+static void test_mbsspn( void)
+{
+    char str1[]="cabernet";
+    char str2[]="shiraz";
+    char set[]="abc";
+    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, "");
+    ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
+}
+
 START_TEST(string)
 {
     void *mem;
@@ -107,4 +122,6 @@ START_TEST(string)
 
     /* Test ismbblead*/
     test_ismbblead();
+   /* test _mbsspn */
+    test_mbsspn();
 }


More information about the wine-patches mailing list