Mercurial > sdl-ios-xcode
comparison src/stdlib/SDL_string.c @ 1338:604d73db6802
Removed uses of stdlib.h and string.h
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 09:29:18 +0000 |
parents | 3692456e7b0f |
children | d02b552e5304 |
comparison
equal
deleted
inserted
replaced
1337:c687f06c7473 | 1338:604d73db6802 |
---|---|
341 #ifndef HAVE__STRUPR | 341 #ifndef HAVE__STRUPR |
342 char *SDL_strupr(char *string) | 342 char *SDL_strupr(char *string) |
343 { | 343 { |
344 char *bufp = string; | 344 char *bufp = string; |
345 while ( *bufp ) { | 345 while ( *bufp ) { |
346 *bufp++ = toupper(*bufp); | 346 *bufp = toupper(*bufp); |
347 ++bufp; | |
347 } | 348 } |
348 return string; | 349 return string; |
349 } | 350 } |
350 #endif | 351 #endif |
351 | 352 |
352 #ifndef HAVE__STRLWR | 353 #ifndef HAVE__STRLWR |
353 char *SDL_strlwr(char *string) | 354 char *SDL_strlwr(char *string) |
354 { | 355 { |
355 char *bufp = string; | 356 char *bufp = string; |
356 while ( *bufp ) { | 357 while ( *bufp ) { |
357 *bufp++ = tolower(*bufp); | 358 *bufp = tolower(*bufp); |
359 ++bufp; | |
358 } | 360 } |
359 return string; | 361 return string; |
360 } | 362 } |
361 #endif | 363 #endif |
362 | 364 |
365 { | 367 { |
366 while ( *string ) { | 368 while ( *string ) { |
367 if ( *string == c ) { | 369 if ( *string == c ) { |
368 return (char *)string; | 370 return (char *)string; |
369 } | 371 } |
372 ++string; | |
370 } | 373 } |
371 return NULL; | 374 return NULL; |
372 } | 375 } |
373 #endif | 376 #endif |
374 | 377 |
378 const char *bufp = string + SDL_strlen(string) - 1; | 381 const char *bufp = string + SDL_strlen(string) - 1; |
379 while ( bufp >= string ) { | 382 while ( bufp >= string ) { |
380 if ( *bufp == c ) { | 383 if ( *bufp == c ) { |
381 return (char *)bufp; | 384 return (char *)bufp; |
382 } | 385 } |
386 --bufp; | |
383 } | 387 } |
384 return NULL; | 388 return NULL; |
385 } | 389 } |
386 #endif | 390 #endif |
387 | 391 |
391 size_t length = SDL_strlen(needle); | 395 size_t length = SDL_strlen(needle); |
392 while ( *haystack ) { | 396 while ( *haystack ) { |
393 if ( SDL_strncmp(haystack, needle, length) == 0 ) { | 397 if ( SDL_strncmp(haystack, needle, length) == 0 ) { |
394 return (char *)haystack; | 398 return (char *)haystack; |
395 } | 399 } |
400 ++haystack; | |
396 } | 401 } |
397 return NULL; | 402 return NULL; |
398 } | 403 } |
399 #endif | 404 #endif |
400 | 405 |