Commit Graph

83 Commits

Author SHA1 Message Date
Ryan C. Gordon
e410b34f92 stdlib: Corrected implementation of SDL_wcsncmp.
It was a copy/paste of SDL_strcmp, apparently, not SDL_strncmp, so it ignored
the maxlen parameter.

Thanks to Jack Powell for pointing this out!
2020-07-24 22:24:03 -04:00
Sam Lantinga
31916f11aa Fixed compiler warning building on FreeBSD 2020-05-27 09:22:12 -07:00
Ryan C. Gordon
b0a20a153c stdlib: Fixed compiler warnings about int vs size_t. 2020-05-05 12:48:55 -04:00
Sam Lantinga
8b60d39cb0 Fixed bug 5112 - CMake won't compile in VS2019
dark_sylinc

Trying to build SDL with VS2019 using CMake will encounter a linking error

More specifically:

    1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
2020-05-02 14:43:17 -07:00
Sam Lantinga
1d8797876a Fixed implicit linkage to ftol2() on Windows 2020-04-13 13:24:56 -07:00
Ryan C. Gordon
d292f6bd4f stdlib: Add SDL_trunc and SDL_truncf 2020-04-10 12:17:14 -04:00
Sam Lantinga
342f62ca69 Fixed bug 5022 - SDL_iconv_string can get stuck in an infinite loop when encountering invalid characters
ciremo6483

In `SDL_iconv_string` the `while (inbytesleft > 0)` loop can end up in a state where it never terminates because the library `iconv` function called from `SDL_iconv` doesn't consume any bytes.

This happened when a `WCHAR_T` input string was being converted to `UTF-8` but contained invalid characters. It would first It would first skip a few bytes due to `case SDL_ICONV_EILSEQ` but when there were 3 bytes remaining of `inbytesleft` `iconv` just didn't consume anything more (but didn't throw an error either).

It just so happens that the Microsoft Classic IntelliMouse `product_string` contains such invalid characters (`"Microsoft? Classic IntelliMouse?"`), meaning the function would get stuck with said mouse plugged in.

A fix for this would be to check if `inbytesleft` was unchanged after an iteration and in that case either decrement the counter like when `SDL_ICONV_EILSEQ` is returned or simply break the loop.
2020-03-10 16:29:28 -07:00
Sam Lantinga
aa384ad02b Fixed bug 5001 - Feature request: SDL_isupper & SDL_islower 2020-03-02 15:21:07 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
650964461e Improved XInput VID/PID detection and added SDL_wcsstr() and SDL_wcsncmp() 2019-11-20 16:42:50 -08:00
Ozkan Sezer
eb8f14bb6a added SDL_strtokr() as a replacement for POSIX strtok_r (bug #4046.) 2019-11-20 20:40:50 +03:00
Ozkan Sezer
fea3c8bdef SDL_qsort.c: sync comments with version 1.15 from mainstream 2019-10-31 17:10:02 +03:00
Sylvain Becker
b458d7a28f Readability: remove redundant cast to the same type 2019-10-30 15:13:55 +01:00
Ryan C. Gordon
4001e6b351 stdlib: Patched to compile. 2019-09-26 13:44:49 -04:00
Ryan C. Gordon
987aa3113c stdlib: Try to coerce VS2019 to not replace some loops with memset() calls.
Fixes (?) Bugzilla #4759.
2019-09-26 12:55:05 -04:00
Ozkan Sezer
2ea0ec6207 better readability.. 2019-07-31 00:07:15 +03:00
Ozkan Sezer
5f04ed5fbd SDL_iconv_string: add (char*) casts before SDL_malloc() calls. 2019-07-31 00:06:50 +03:00
Cameron Cawley
e7b514d8ff riscos: Fix iconv warnings 2019-01-13 23:36:31 +00:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ozkan Sezer
d3fa42b8c4 os/2 bits for SDL_malloc.c -- from libffi 2018-11-18 19:28:20 +03:00
Sam Lantinga
9e8e0fb7b1 Fixed bug 4283 - SDL's version of memset is different from libc's
janisozaur

memset's documentation reads:

* The memset() function shall copy c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s. (http://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html)
* Sets the first count characters of dest to the character c. (https://msdn.microsoft.com/en-us/library/1fdeehz6.aspx)
* write a byte to a byte string (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/memset.3.html)

The highlight here is they all mean a single _byte_, even though memset receives a parameter of type int, which can hold more data than a single byte. SDL's implementation of memset, however, does not clear any of the higher bits, causing an erroneous behaviour when passed an argument bigger than 0xff.
2018-09-28 20:48:18 -07:00
Ozkan Sezer
31596f23ce SDL_vsnprintf: implemented '+' flag for signed integers printing.
it is, of course, ignored for %u, %x, %o and %p.
2018-09-29 01:24:10 +03:00
Ozkan Sezer
49803c8660 SDL_vsnprintf: fix numerics if both zero-padding and a field are given.
it used to place zeroes between the sign and the number. (space-padding
from within SDL_PrintString() seems OK:  spaces are added before sign.)

also fixed the maxlen handling if the number has a sign.
2018-09-29 00:51:24 +03:00
Ozkan Sezer
bb5516ac8e SDL_vsnprintf() updates for zero-padding:
- remove force-enabling of pad_zeroes for %u for compatibility
 (was added in https://hg.libsdl.org/SDL/rev/701f4a25df89)
- ignore pad_zeroes for %s and %S
- ignore pad_zeroes for %d, %i and %u if a precision is given
2018-09-27 09:37:36 +03:00
Ozkan Sezer
6eeb8593ba SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning 2018-09-27 01:10:50 +03:00
Ozkan Sezer
5342ae2bba SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset() 2018-09-27 01:00:50 +03:00
Ozkan Sezer
d2131ac165 SDL_vsnprintf: implement precision for the integral value printers. 2018-09-27 00:32:15 +03:00
Ozkan Sezer
ffc19ee255 SDL_string.c: added comments to three SDL_FormatInfo members. 2018-09-26 20:47:34 +03:00
Ozkan Sezer
8743e9759e SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0. 2018-09-26 17:11:40 +03:00
Ozkan Sezer
69ab8541a9 SDL_vsnprintf: string printer now honors the precision. (bug #4263.) 2018-09-26 10:40:02 +03:00
Ozkan Sezer
d0e9a36460 SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.) 2018-09-26 10:38:40 +03:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Ozkan Sezer
f45f33bdc0 SDL_expf: return SDL_exp() instead of SDL_uclibc_exp() for consistency. 2018-08-05 10:01:01 +03:00
Ethan Lee
b4fe7412f9 SDL_exp 2018-08-04 11:52:46 -04:00
Ozkan Sezer
652d59fb3b make sure SDL_vsnprintf() nul terminates if it is using _vsnprintf
The change makes sure that SDL_vsnprintf() nul terminates if it is
using _vsnprintf() for the job.

I made this patch for Watcom, whose _vsnprintf() doesn't guarantee
nul termination.  The preprocessor check can be extended to windows
in general too, if required.

Closes bug #3769.
2018-05-10 09:02:39 +03:00
Sam Lantinga
3b4c2fdf5d Fixed bug 3947 - replace strlcpy with memcpy in SDL_strdup() 2018-02-13 08:13:29 -08:00
Ethan Lee
11c348b4d7 SDL_log10 2018-01-17 11:53:09 -05:00
Sam Lantinga
e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
bcdf8b916b Added SDL_fmod() and SDL_fmodf() 2017-11-04 17:35:03 -07:00
Sam Lantinga
34502143d9 Added float versions of SDL's math functions 2017-11-04 15:34:14 -07:00
Sam Lantinga
758156a765 Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
We're going to push the manifest environment variables from the Java side instead of continually querying for them from the native side.
2017-11-04 09:37:29 -07:00
Sam Lantinga
8fd0c22adc Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
2017-10-24 00:17:07 -07:00
Sam Lantinga
fc60db86b3 Fixed compiler warning 2017-10-12 17:17:09 -07:00
Sam Lantinga
21cd2df694 Fixed compiler warning 2017-10-12 14:02:24 -07:00
Sam Lantinga
9c580e14c9 Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
    SDL_SetMemoryFunctions()
    SDL_GetNumAllocations()
2017-10-12 13:44:28 -07:00
Ozkan Sezer
bef0fec121 make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL. 2017-10-12 14:28:05 +03:00
Sam Lantinga
19114b0378 Fixed bug 3813 - gcc7 fallthrough warnings in SDL_iconv.c and SDL_pixels.c 2017-09-10 12:42:38 -07:00
Sam Lantinga
8ed16ea465 Fixed compile warning 2017-09-10 10:43:04 -07:00
Sam Lantinga
1b2492ed8a Fixed 64-bit build warning 2017-09-08 15:08:03 -07:00