mshtml: Added edit mode IDM_CUT implementation.
[wine/gsoc_dplay.git] / dlls / msvcrt / string.c
blobec4bd703b77fa519ffefd5fccec4119589cd05f5
1 /*
2 * MSVCRT string functions
4 * Copyright 1996,1998 Marcus Meissner
5 * Copyright 1996 Jukka Iivonen
6 * Copyright 1997,2000 Uwe Bonnes
7 * Copyright 2000 Jon Griffiths
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define _ISOC99_SOURCE
25 #include "config.h"
27 #include <stdlib.h>
28 #include "msvcrt.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
33 /* INTERNAL: MSVCRT_malloc() based strndup */
34 char* msvcrt_strndup(const char* buf, unsigned int size)
36 char* ret;
37 unsigned int len = strlen(buf), max_len;
39 max_len = size <= len? size : len + 1;
41 ret = MSVCRT_malloc(max_len);
42 if (ret)
44 memcpy(ret,buf,max_len);
45 ret[max_len] = 0;
47 return ret;
50 /*********************************************************************
51 * _mbsdup (MSVCRT.@)
52 * _strdup (MSVCRT.@)
54 char* CDECL _strdup(const char* str)
56 if(str)
58 char * ret = MSVCRT_malloc(strlen(str)+1);
59 if (ret) strcpy( ret, str );
60 return ret;
62 else return 0;
65 /*********************************************************************
66 * _strnset (MSVCRT.@)
68 char* CDECL _strnset(char* str, int value, MSVCRT_size_t len)
70 if (len > 0 && str)
71 while (*str && len--)
72 *str++ = value;
73 return str;
76 /*********************************************************************
77 * _strrev (MSVCRT.@)
79 char* CDECL _strrev(char* str)
81 char * p1;
82 char * p2;
84 if (str && *str)
85 for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
87 *p1 ^= *p2;
88 *p2 ^= *p1;
89 *p1 ^= *p2;
92 return str;
95 /*********************************************************************
96 * _strset (MSVCRT.@)
98 char* CDECL _strset(char* str, int value)
100 char *ptr = str;
101 while (*ptr)
102 *ptr++ = value;
104 return str;
107 /*********************************************************************
108 * strtok (MSVCRT.@)
110 char * CDECL MSVCRT_strtok( char *str, const char *delim )
112 thread_data_t *data = msvcrt_get_thread_data();
113 char *ret;
115 if (!str)
116 if (!(str = data->strtok_next)) return NULL;
118 while (*str && strchr( delim, *str )) str++;
119 if (!*str) return NULL;
120 ret = str++;
121 while (*str && !strchr( delim, *str )) str++;
122 if (*str) *str++ = 0;
123 data->strtok_next = str;
124 return ret;
128 /*********************************************************************
129 * _swab (MSVCRT.@)
131 void CDECL MSVCRT__swab(char* src, char* dst, int len)
133 if (len > 1)
135 len = (unsigned)len >> 1;
137 while (len--) {
138 char s0 = src[0];
139 char s1 = src[1];
140 *dst++ = s1;
141 *dst++ = s0;
142 src = src + 2;
147 /*********************************************************************
148 * atof (MSVCRT.@)
150 double CDECL MSVCRT_atof( const char *str )
152 return atof( str );
155 /*********************************************************************
156 * strtod (MSVCRT.@)
158 double CDECL MSVCRT_strtod( const char *str, char **end )
160 return strtod( str, end );
163 /*********************************************************************
164 * strcoll (MSVCRT.@)
166 int CDECL MSVCRT_strcoll( const char* str1, const char* str2 )
168 /* FIXME: handle Windows locale */
169 return strcoll( str1, str2 );
172 /*********************************************************************
173 * strxfrm (MSVCRT.@)
175 MSVCRT_size_t CDECL MSVCRT_strxfrm( char *dest, const char *src, MSVCRT_size_t len )
177 /* FIXME: handle Windows locale */
178 return strxfrm( dest, src, len );
181 /*********************************************************************
182 * _stricoll (MSVCRT.@)
184 int CDECL MSVCRT__stricoll( const char* str1, const char* str2 )
186 /* FIXME: handle collates */
187 TRACE("str1 %s str2 %s\n", debugstr_a(str1), debugstr_a(str2));
188 return lstrcmpiA( str1, str2 );
191 /********************************************************************
192 * _atoldbl (MSVCRT.@)
194 int CDECL MSVCRT__atoldbl(_LDOUBLE * value, char * str)
196 /* FIXME needs error checking for huge/small values */
197 #ifdef HAVE_STRTOLD
198 TRACE("str %s value %p\n",str,value);
199 value->x = strtold(str,0);
200 #else
201 FIXME("stub, str %s value %p\n",str,value);
202 #endif
203 return 0;