Changeset 444 for trunk/libs/mini-libc/string.c
- Timestamp:
- May 16, 2018, 8:31:35 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/string.c
r439 r444 24 24 #define NULL (void *)0 25 25 26 /////////////////////////// 27 inline int tolower( int c ) 28 { 29 if (c >= 'A' && c <= 'Z') return (c | 0x20); 30 else return c; 31 } 32 33 34 /////////////////////////// 35 inline int toupper( int c ) 36 { 37 if (c >= 'a' && c <= 'z') return (c & ~(0x20)); 38 else return c; 39 } 26 #include <string.h> 40 27 41 28 /////////////////////////////////////// … … 92 79 } 93 80 94 //////////////////////////////////95 int strcasecmp( const char * str1,96 const char * str2 )97 {98 char c1;99 char c2;100 81 101 do102 {103 c1 = (char)toupper( (int)*++str1 );104 c2 = (char)toupper( (int)*++str2 );105 c2 = toupper(*++str2);106 }107 while(c1 && c1 == c2);108 109 return (c1 - c2);110 }111 82 112 83 /////////////////////////// … … 190 161 } 191 162 163 /////////////////////////////////////////////////////////////// 164 void * memcpy(void *_dst, const void * _src, unsigned int size) 165 { 166 unsigned int * dst = _dst; 167 const unsigned int * src = _src; 168 if (!((unsigned int) dst & 3) && !((unsigned int) src & 3) ) 169 { 170 while (size > 3) 171 { 172 *dst++ = *src++; 173 size -= 4; 174 } 175 } 192 176 177 unsigned char *cdst = (unsigned char*)dst; 178 unsigned char *csrc = (unsigned char*)src; 179 180 while (size--) 181 { 182 *cdst++ = *csrc++; 183 } 184 return _dst; 185 } 186 187 ////////////////////////////////////////////////////////// 188 inline void * memset(void * dst, int s, unsigned int size) 189 { 190 char * a = (char *) dst; 191 while (size--) 192 { 193 *a++ = (char)s; 194 } 195 return dst; 196 } 197 198
Note: See TracChangeset
for help on using the changeset viewer.