Display thread id instead of %fs in relay trace.
[wine.git] / dlls / msvcrt / string.c
blob1736707635aae7c0ccef41680907ff1574b8a028
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
8 */
9 #include "msvcrt.h"
12 DEFAULT_DEBUG_CHANNEL(msvcrt);
14 /* INTERNAL: MSVCRT_malloc() based strndup */
15 char * MSVCRT__strndup(const char * buf, unsigned int size)
17 char* ret;
18 unsigned int len = strlen(buf), max_len;
20 max_len = size <= len? size : len + 1;
22 ret = MSVCRT_malloc(max_len);
23 if (ret)
25 memcpy(ret,buf,max_len);
26 ret[max_len] = 0;
28 return ret;
31 /*********************************************************************
32 * _strdec (MSVCRT.@)
34 char * __cdecl MSVCRT__strdec(const char * str1, const char * str2)
36 /* Hmm. While the docs suggest that the following should work... */
37 /* return (str2<=str1?0:str2-1); */
38 /* ...Version 2.50.4170 (NT) from win98 constantly decrements! */
39 str1 = str1; /* remove warning */
40 return (char *)str2-1;
43 /*********************************************************************
44 * _strdup (MSVCRT.@)
46 char * __cdecl MSVCRT__strdup(const char * str)
48 char * ret = MSVCRT_malloc(strlen(str)+1);
49 if (ret) strcpy( ret, str );
50 return ret;
53 /*********************************************************************
54 * _strinc (MSVCRT.@)
56 char * __cdecl MSVCRT__strinc(const char * str)
58 return (char*)str+1;
61 /*********************************************************************
62 * _strnextc (MSVCRT.@)
64 unsigned int __cdecl MSVCRT__strnextc(const char * str)
66 return (unsigned int)*str;
69 /*********************************************************************
70 * _strninc (MSVCRT.@)
72 * Return a pointer to the 'n'th character in a string
74 char * __cdecl MSVCRT__strninc(char * str, unsigned int n)
76 return str + n;
79 /*********************************************************************
80 * _strnset (MSVCRT.@)
82 char * __cdecl MSVCRT__strnset(char * str, int value, unsigned int len)
84 if (len > 0 && str)
85 while (*str && len--)
86 *str++ = value;
87 return str;
90 /*********************************************************************
91 * _strrev (MSVCRT.@)
93 char * __cdecl MSVCRT__strrev (char * str)
95 char * p1;
96 char * p2;
98 if (str && *str)
99 for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2)
101 *p1 ^= *p2;
102 *p2 ^= *p1;
103 *p1 ^= *p2;
106 return str;
109 /*********************************************************************
110 * _strset (MSVCRT.@)
112 char * __cdecl MSVCRT__strset (char * str, int value)
114 char *ptr = str;
115 while (*ptr)
116 *ptr++ = value;
118 return str;
121 /*********************************************************************
122 * _strncnt (MSVCRT.@)
124 unsigned int __cdecl MSVCRT__strncnt(char * str, unsigned int max)
126 unsigned int len = strlen(str);
127 return (len > max? max : len);
130 /*********************************************************************
131 * _strspnp (MSVCRT.@)
133 char * __cdecl MSVCRT__strspnp(char * str1, char * str2)
135 str1 += strspn(str1,str2);
136 return *str1? str1 : 0;
139 /*********************************************************************
140 * _swab (MSVCRT.@)
142 void __cdecl MSVCRT__swab(char * src, char * dst, int len)
144 if (len > 1)
146 len = (unsigned)len >> 1;
148 while (len--) {
149 *dst++ = src[1];
150 *dst++ = *src++;
151 src++;