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()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 81e3a8c..d0634b9 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -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);
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index bb592c0..4d698c6 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -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
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index b461985..8e67893 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -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)
diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c
index 533117c..93fdd50 100644
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -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 */