From f010411492e25417a6f8fec22f49f873d02734e0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 3 Jul 2023 06:19:30 -0700 Subject: [PATCH] Rename SDL_strtokr() to SDL_strtok_r() Fixes https://github.com/libsdl-org/SDL/issues/7914 --- build-scripts/SDL_migration.cocci | 5 +++++ docs/README-migration.md | 3 +++ include/SDL3/SDL_oldnames.h | 6 ++++++ include/SDL3/SDL_stdinc.h | 4 ++-- src/core/linux/SDL_evdev.c | 2 +- src/dynapi/SDL_dynapi.sym | 2 +- src/dynapi/SDL_dynapi_overrides.h | 2 +- src/dynapi/SDL_dynapi_procs.h | 2 +- src/stdlib/SDL_strtokr.c | 2 +- src/video/wayland/SDL_waylandevents.c | 8 ++++---- src/video/wayland/SDL_waylandwindow.c | 4 ++-- src/video/x11/SDL_x11events.c | 4 ++-- 12 files changed, 29 insertions(+), 15 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index 6c2c69913..bb4fd6a39 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -2685,3 +2685,8 @@ typedef SDL_cond, SDL_Condition; @@ - SDL_PIXELFORMAT_BGR888 + SDL_PIXELFORMAT_XBGR8888 +@@ +@@ +- SDL_strtokr ++ SDL_strtok_r + (...) diff --git a/docs/README-migration.md b/docs/README-migration.md index 5ccbf47c9..e8b6b1af8 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -949,6 +949,9 @@ The standard C headers like stdio.h and stdlib.h are no longer included, you sho M_PI is no longer defined in SDL_stdinc.h, you can use the new symbols SDL_PI_D (double) and SDL_PI_F (float) instead. +The following functions have been renamed: +* SDL_strtokr() => SDL_strtok_r() + ## SDL_surface.h Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat. diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index 36700846b..3a502e8c6 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -438,6 +438,9 @@ #define SDL_SensorOpen SDL_OpenSensor #define SDL_SensorUpdate SDL_UpdateSensors +/* ##SDL_stdinc.h */ +#define SDL_strtokr SDL_strtok_r + /* ##SDL_surface.h */ #define SDL_FillRect SDL_FillSurfaceRect #define SDL_FillRects SDL_FillSurfaceRects @@ -878,6 +881,9 @@ #define SDL_SensorOpen SDL_SensorOpen_renamed_SDL_OpenSensor #define SDL_SensorUpdate SDL_SensorUpdate_renamed_SDL_UpdateSensors +/* ##SDL_stdinc.h */ +#define SDL_strtokr SDL_strtokr_renamed_SDL_strtok_r + /* ##SDL_surface.h */ #define SDL_FillRect SDL_FillRect_renamed_SDL_FillSurfaceRect #define SDL_FillRects SDL_FillRects_renamed_SDL_FillSurfaceRects diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h index bcdfc235e..304c8b5b5 100644 --- a/include/SDL3/SDL_stdinc.h +++ b/include/SDL3/SDL_stdinc.h @@ -556,7 +556,7 @@ extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); extern DECLSPEC char *SDLCALL SDL_strcasestr(const char *haystack, const char *needle); -extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr); +extern DECLSPEC char *SDLCALL SDL_strtok_r(char *s1, const char *s2, char **saveptr); extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); extern DECLSPEC size_t SDLCALL SDL_utf8strnlen(const char *str, size_t bytes); @@ -733,7 +733,7 @@ size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); #define SDL_strrchr strrchr #define SDL_strstr strstr #define SDL_wcsstr wcsstr -#define SDL_strtokr strtok_r +#define SDL_strtok_r strtok_r #define SDL_strcmp strcmp #define SDL_wcscmp wcscmp #define SDL_strncmp strncmp diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index e1b691060..679390016 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -192,7 +192,7 @@ int SDL_EVDEV_Init(void) ROM. */ char *rest = (char *)devices; char *spec; - while ((spec = SDL_strtokr(rest, ",", &rest))) { + while ((spec = SDL_strtok_r(rest, ",", &rest))) { char *endofcls = 0; long cls = SDL_strtol(spec, &endofcls, 0); if (endofcls) { diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 1cef20c00..2ec47ef11 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -836,7 +836,7 @@ SDL3_0.0.0 { SDL_strrev; SDL_strstr; SDL_strtod; - SDL_strtokr; + SDL_strtok_r; SDL_strtol; SDL_strtoll; SDL_strtoul; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index f50fe65e1..16c71f4ec 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -860,7 +860,7 @@ #define SDL_strrev SDL_strrev_REAL #define SDL_strstr SDL_strstr_REAL #define SDL_strtod SDL_strtod_REAL -#define SDL_strtokr SDL_strtokr_REAL +#define SDL_strtok_r SDL_strtok_r_REAL #define SDL_strtol SDL_strtol_REAL #define SDL_strtoll SDL_strtoll_REAL #define SDL_strtoul SDL_strtoul_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 30e9c9c07..d4978ec3c 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -906,7 +906,7 @@ SDL_DYNAPI_PROC(char*,SDL_strrchr,(const char *a, int b),(a,b),return) SDL_DYNAPI_PROC(char*,SDL_strrev,(char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_strstr,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_strtod,(const char *a, char **b),(a,b),return) -SDL_DYNAPI_PROC(char*,SDL_strtokr,(char *a, const char *b, char **c),(a,b,c),return) +SDL_DYNAPI_PROC(char*,SDL_strtok_r,(char *a, const char *b, char **c),(a,b,c),return) SDL_DYNAPI_PROC(long,SDL_strtol,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(Sint64,SDL_strtoll,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(unsigned long,SDL_strtoul,(const char *a, char **b, int c),(a,b,c),return) diff --git a/src/stdlib/SDL_strtokr.c b/src/stdlib/SDL_strtokr.c index 80ff68eef..e67c0ed41 100644 --- a/src/stdlib/SDL_strtokr.c +++ b/src/stdlib/SDL_strtokr.c @@ -21,7 +21,7 @@ #include "SDL_internal.h" -char *SDL_strtokr(char *s1, const char *s2, char **ptr) +char *SDL_strtok_r(char *s1, const char *s2, char **ptr) { #ifdef HAVE_STRTOK_R return strtok_r(s1, s2, ptr); diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 80d96deb3..06e81c5b6 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -1876,7 +1876,7 @@ static void data_device_handle_motion(void *data, struct wl_data_device *wl_data &length, FILE_MIME, SDL_TRUE); if (buffer) { char *saveptr = NULL; - char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); + char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr); while (token != NULL) { char *fn = Wayland_URIToLocal(token); if (fn) { @@ -1886,7 +1886,7 @@ static void data_device_handle_motion(void *data, struct wl_data_device *wl_data dy = wl_fixed_to_double(y); SDL_SendDropPosition(data_device->dnd_window, fn, (float)dx, (float)dy); } - token = SDL_strtokr(NULL, "\r\n", &saveptr); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); } SDL_free(buffer); } @@ -2025,13 +2025,13 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d &length, FILE_MIME, SDL_TRUE); if (buffer) { char *saveptr = NULL; - char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); + char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr); while (token != NULL) { char *fn = Wayland_URIToLocal(token); if (fn) { SDL_SendDropFile(data_device->dnd_window, fn); } - token = SDL_strtokr(NULL, "\r\n", &saveptr); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); } SDL_SendDropComplete(data_device->dnd_window); SDL_free(buffer); diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 77a457fbb..4193dbce8 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1808,7 +1808,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * char *tmp = SDL_strdup(newValue); char *saveptr = NULL; - char *flag = SDL_strtokr(tmp, " ", &saveptr); + char *flag = SDL_strtok_r(tmp, " ", &saveptr); while (flag) { if (SDL_strcmp(flag, "OverridesSystemGestures") == 0) { flags |= QT_EXTENDED_SURFACE_WINDOWFLAG_OVERRIDESSYSTEMGESTURES; @@ -1819,7 +1819,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * flags |= 4 /* QT_EXTENDED_SURFACE_WINDOWFLAG_BYPASSWINDOWMANAGER */; } - flag = SDL_strtokr(NULL, " ", &saveptr); + flag = SDL_strtok_r(NULL, " ", &saveptr); } SDL_free(tmp); diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index b5ae55791..6607c1502 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1591,7 +1591,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) char *saveptr = NULL; char *name = X11_XGetAtomName(display, target); if (name) { - char *token = SDL_strtokr((char *)p.data, "\r\n", &saveptr); + char *token = SDL_strtok_r((char *)p.data, "\r\n", &saveptr); while (token != NULL) { if (SDL_strcmp("text/plain", name) == 0) { SDL_SendDropText(data->window, token); @@ -1601,7 +1601,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_SendDropFile(data->window, fn); } } - token = SDL_strtokr(NULL, "\r\n", &saveptr); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); } X11_XFree(name); }