mirror of https://github.com/encounter/SDL.git
Add all missing "is characteristic" stdlib functions
SDL has been missing a bunch of these 'isX' functions for some time, where X is some characteristic of a given character. This commit adds the rest of them to the SDL stdlib, so now we have: - SDL_isalpha() - SDL_isalnum() - SDL_isblank() - SDL_iscntrl() - SDL_isxdigit() - SDL_ispunct() - SDL_isprint() - SDL_isgraph()
This commit is contained in:
parent
88f1c2c1b0
commit
dfe219ec71
|
@ -440,10 +440,18 @@ extern DECLSPEC int SDLCALL SDL_abs(int x);
|
|||
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
extern DECLSPEC int SDLCALL SDL_isalpha(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isalnum(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isblank(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_iscntrl(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isdigit(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isxdigit(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_ispunct(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isspace(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isupper(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_islower(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isprint(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_isgraph(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_toupper(int x);
|
||||
extern DECLSPEC int SDLCALL SDL_tolower(int x);
|
||||
|
||||
|
|
|
@ -799,3 +799,11 @@
|
|||
#define SDL_SetWindowMouseGrab SDL_SetWindowMouseGrab_REAL
|
||||
#define SDL_GetWindowKeyboardGrab SDL_GetWindowKeyboardGrab_REAL
|
||||
#define SDL_GetWindowMouseGrab SDL_GetWindowMouseGrab_REAL
|
||||
#define SDL_isalpha SDL_isalpha_REAL
|
||||
#define SDL_isalnum SDL_isalnum_REAL
|
||||
#define SDL_isblank SDL_isblank_REAL
|
||||
#define SDL_iscntrl SDL_iscntrl_REAL
|
||||
#define SDL_isxdigit SDL_isxdigit_REAL
|
||||
#define SDL_ispunct SDL_ispunct_REAL
|
||||
#define SDL_isprint SDL_isprint_REAL
|
||||
#define SDL_isgraph SDL_isgraph_REAL
|
||||
|
|
|
@ -862,3 +862,11 @@ SDL_DYNAPI_PROC(void,SDL_SetWindowKeyboardGrab,(SDL_Window *a, SDL_bool b),(a,b)
|
|||
SDL_DYNAPI_PROC(void,SDL_SetWindowMouseGrab,(SDL_Window *a, SDL_bool b),(a,b),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowKeyboardGrab,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMouseGrab,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isalpha,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isalnum,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isblank,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_iscntrl,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isxdigit,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ispunct,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isprint,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_isgraph,(int a),(a),return)
|
||||
|
|
|
@ -504,21 +504,40 @@ int SDL_abs(int x)
|
|||
}
|
||||
|
||||
#if defined(HAVE_CTYPE_H)
|
||||
int SDL_isalpha(int x) { return isalpha(x); }
|
||||
int SDL_isalnum(int x) { return isalnum(x); }
|
||||
int SDL_isdigit(int x) { return isdigit(x); }
|
||||
int SDL_isxdigit(int x) { return isxdigit(x); }
|
||||
int SDL_ispunct(int x) { return ispunct(x); }
|
||||
int SDL_isspace(int x) { return isspace(x); }
|
||||
int SDL_isupper(int x) { return isupper(x); }
|
||||
int SDL_islower(int x) { return islower(x); }
|
||||
int SDL_isprint(int x) { return isprint(x); }
|
||||
int SDL_isgraph(int x) { return isgraph(x); }
|
||||
int SDL_iscntrl(int x) { return iscntrl(x); }
|
||||
int SDL_toupper(int x) { return toupper(x); }
|
||||
int SDL_tolower(int x) { return tolower(x); }
|
||||
#else
|
||||
int SDL_isalpha(int x) { return (SDL_isupper(x)) || (SDL_islower(x)); }
|
||||
int SDL_isalnum(int x) { return (SDL_isalpha(x)) || (SDL_isdigit(x)); }
|
||||
int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); }
|
||||
int SDL_isxdigit(int x) { return (SDL_isalpha(x)) || (SDL_isdigit(x)); }
|
||||
int SDL_ispunct(int x) { return (SDL_isprint(x)) && (!SDL_isalnum(x)); }
|
||||
int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
|
||||
int SDL_isupper(int x) { return ((x) >= 'A') && ((x) <= 'Z'); }
|
||||
int SDL_islower(int x) { return ((x) >= 'a') && ((x) <= 'z'); }
|
||||
int SDL_isprint(int x) { return ((x) >= ' ') && ((x) < '\x7f'); }
|
||||
int SDL_isgraph(int x) { return (SDL_isprint(x)) && ((x) != ' '); }
|
||||
int SDL_iscntrl(int x) { return (((x) >= '\0') && ((x) <= '\x1f')) || ((x) == '\x7f'); }
|
||||
int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
|
||||
int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CTYPE_H) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
int SDL_isblank(int x) { return isblank(x); }
|
||||
#else
|
||||
int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); }
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LIBC
|
||||
/* These are some C runtime intrinsics that need to be defined */
|
||||
|
|
Loading…
Reference in New Issue