- Add math calls: scalb, fpclass, nextafter, logb, _CI*
[wine] / dlls / crtdll / mbstring.c
1 /*
2  * CRTDLL multi-byte string functions
3  *
4  * Copyright 1999 Alexandre Julliard
5  */
6
7 #include "crtdll.h"
8
9
10 DEFAULT_DEBUG_CHANNEL(crtdll);
11
12
13 /*********************************************************************
14  *                  _mbsicmp      (CRTDLL.204)
15  */
16 int __cdecl CRTDLL__mbsicmp(unsigned char *x,unsigned char *y)
17 {
18     do {
19         if (!*x)
20             return !!*y;
21         if (!*y)
22             return !!*x;
23         /* FIXME: MBCS handling... */
24         if (*x!=*y)
25             return 1;
26         x++;
27         y++;
28     } while (1);
29 }
30
31
32 /*********************************************************************
33  *           CRTDLL__mbsinc    (CRTDLL.205)
34  */
35 LPSTR __cdecl CRTDLL__mbsinc( LPCSTR str )
36 {
37     if (IsDBCSLeadByte( *str )) str++;
38     return (LPSTR)(str + 1);
39 }
40
41
42 /*********************************************************************
43  *           CRTDLL__mbslen    (CRTDLL.206)
44  */
45 INT __cdecl CRTDLL__mbslen( LPCSTR str )
46 {
47     INT len;
48     for (len = 0; *str; len++, str++) if (IsDBCSLeadByte(str[0]) && str[1]) str++;
49     return len;
50 }
51
52
53
54 /*********************************************************************
55  *                  _mbsrchr           (CRTDLL.223)
56  */
57 LPSTR __cdecl CRTDLL__mbsrchr(LPSTR s,CHAR x)
58 {
59     /* FIXME: handle multibyte strings */
60     return strrchr(s,x);
61 }
62
63
64 /*********************************************************************
65  *           CRTDLL_mbtowc    (CRTDLL.430)
66  */
67 INT __cdecl CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n )
68 {
69     if (n <= 0) return 0;
70     if (!str) return 0;
71     if (!MultiByteToWideChar( CP_ACP, 0, str, n, dst, 1 )) return 0;
72     /* return the number of bytes from src that have been used */
73     if (!*str) return 0;
74     if (n >= 2 && IsDBCSLeadByte(*str) && str[1]) return 2;
75     return 1;
76 }
77
78
79 /*********************************************************************
80  *                  _mbccpy           (CRTDLL.??)
81  *
82  * Copy one multibyte character to another
83  */
84 VOID __cdecl CRTDLL__mbccpy(LPSTR dest, LPSTR src)
85 {
86   FIXME("MBCS copy treated as ASCII\n");
87   *dest = *src;
88 }
89