| Summary: | Suggestion + implementation: SDL_strtok which will became as a platform idependent safe strtok() | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vitaly Novichkov <admin> |
| Component: | video | Assignee: | Ozkan Sezer <sezeroz> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sezeroz |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
SDL_strtokr.c
SDL_strtokr.c (V2) SDL_strtokr.patch |
||
|
Description
Vitaly Novichkov
2018-01-14 00:06:16 UTC
This uses libc functions to implement strtok(). I suggest adapting a version based on PDCLib (https://github.com/DevSolar/pdclib.git / CC0 - public domain license.) See string/strtok[_s].c and _PDCLIB/_PDCLIB_strtok.c in there. I can give a shot at this if required. Sure, that sounds good. Please only pull in one file for the strtok implementation. Created attachment 4060 [details] SDL_strtokr.c See attached. Adapted from: https://github.com/DevSolar/pdclib/blob/master/functions/_PDCLIB/_PDCLIB_strtok.c .. with following modifications: - size checks removed (not a thing in strtok_r), - __restrict keyword removed (no support in SDL), - small whitecpace / indentation changes so it follows SDL_string.c style. The extern declaration at the top to go into SDL_stdinc.h. Please review and test carefully and extensively. - Ok to add to hg? - Is the license notification Ok? Created attachment 4061 [details]
SDL_strtokr.c (V2)
V2: Better format, fixed a preprocessor check for strtok_s,
better CC0 original license notification.
Looks fine, it should work! Created attachment 4062 [details]
SDL_strtokr.patch
OK then, here is a patch version:
Build tested:
- Linux (autotools & cmake)
- MinGW (cross- from Linux, autotools & cmake)
- VisualC (VS2017)
NOT build tested:
- Xcode-iOS
- Xcode
- VisualC-WinRT
Config headers NOT touched:
- SDL_config_pandora.h, SDL_config_psp.h
(don't know whether they have strtok_r)
OK? (Please review and run-test.)
I merged the tree layout changes of Vitaly Novichkov to help with his preparing his changesets. Build status: Autotools, Xcode, and VicualC works for me. Xcode-iOS and VisualC-WinRT projects are updated but NOT tested at all: please test/update them as needed (I can not do that myself.) (In reply to Ozkan Sezer from comment #7) Obviously posted that to wrong bug entry. (shame..) Pushed http://hg.libsdl.org/SDL/rev/d6decc5d2464 Closing. If any issues show up, add a note here. |