Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Cleaned up the const_cast mess a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 16, 2013
1 parent de5bfb1 commit baa7a25
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions include/SDL_stdinc.h
Expand Up @@ -93,9 +93,11 @@
#ifdef __cplusplus
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
#define SDL_static_cast(type, expression) static_cast<type>(expression)
#define SDL_const_cast(type, expression) const_cast<type>(expression)
#else
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
#define SDL_static_cast(type, expression) ((type)(expression))
#define SDL_const_cast(type, expression) ((type)(expression))
#endif
/*@}*//*Cast operators*/

Expand Down Expand Up @@ -502,49 +504,25 @@ SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); }

extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
#ifdef HAVE_STRCHR
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
#ifdef __cplusplus
return const_cast<char*>(strchr(str, c));
#else
return (char*)strchr(str, c);
#endif
}
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
#define SDL_strchr SDL_strchr_inline
#elif defined(HAVE_INDEX) /* !!! FIXME: is there anywhere that has this but not strchr? */
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
#define SDL_strchr SDL_strchr_inline
#endif

extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
#ifdef HAVE_STRRCHR
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
#ifdef __cplusplus
return const_cast<char*>(strrchr(str, c));
#else
return (char*)strrchr(str, c);
#endif
}
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
#define SDL_strrchr SDL_strrchr_inline
#elif defined(HAVE_RINDEX) /* !!! FIXME: is there anywhere that has this but not strrchr? */
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
#ifdef __cplusplus
return const_cast<char*>(rindex(str, c));
#else
return (char*)rindex(str, c);
#endif
}
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
#define SDL_strrchr SDL_strrchr_inline
#endif

extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
#ifdef HAVE_STRSTR
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
#ifdef __cplusplus
return const_cast<char*>(strstr(haystack, needle));
#else
return (char*)strstr(haystack, needle);
#endif
}
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
#define SDL_strstr SDL_strstr_inline
#endif

Expand Down

0 comments on commit baa7a25

Please sign in to comment.