fix variable name.
[ruby-svn.git] / wince / string_wce.c
blob257eee101d609a3efb7fce3fa4f9a4f10127a74c
1 /***************************************************************
2 string.c
3 ***************************************************************/
5 #include <windows.h>
6 #include "wince.h" /* for wce_mbtowc */
8 /* _strdup already exists in stdlib.h? */
9 char *strdup(const char * str)
11 char *p;
13 p = malloc( strlen(str)+1 );
14 strcpy( p, str );
15 return p;
18 char* strerror(int errno)
20 static char buf[32]="wince::strerror called.";
21 return buf;
24 /* strnicmp already exists in stdlib.h? */
25 int strnicmp( const char *s1, const char *s2, size_t count )
27 wchar_t *w1, *w2;
28 int n;
30 w1 = wce_mbtowc(s1);
31 w2 = wce_mbtowc(s2);
33 n = wcsnicmp(w1, w2, count);
35 free(w1);
36 free(w2);
38 return n;
41 #if _WIN32_WCE < 300
42 #include "..\missing\strtoul.c"
44 char *strrchr( const char *p, int c )
46 char *pp;
47 for( pp=(char*)p+strlen(p); pp!=p; pp-- )
49 if( *pp==c ) break;
51 return pp==p ? NULL : pp;
54 int stricmp( const char *s1, const char *s2 )
56 wchar_t *w1, *w2;
57 int n;
59 w1 = wce_mbtowc(s1);
60 w2 = wce_mbtowc(s2);
62 n = wcsicmp(w1, w2);
64 free(w1);
65 free(w2);
67 return n;
70 char *strpbrk(const char *str, const char *cs)
72 wchar_t *wstr, *wcs, *w;
73 char *s = NULL;
75 wstr = wce_mbtowc(str);
76 wcs = wce_mbtowc(cs);
78 w = wcspbrk(wstr, wcs);
80 if( w!=NULL )
81 s = str + (wcs-wstr)/sizeof(wchar_t);
83 free(wstr);
84 free(wcs);
86 return s;
89 #endif