src/stdlib/SDL_string.c


Log

Author Commit Date CI Message
Ozkan Sezer 2ea0ec62 2019-07-31T00:07:15 better readability..
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 9e8e0fb7 2018-09-28T20:48:18 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.
Ozkan Sezer 31596f23 2018-09-29T01:24:10 SDL_vsnprintf: implemented '+' flag for signed integers printing. it is, of course, ignored for %u, %x, %o and %p.
Ozkan Sezer 49803c86 2018-09-29T00:51:24 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.
Ozkan Sezer bb5516ac 2018-09-27T09:37:36 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
Ozkan Sezer 6eeb8593 2018-09-27T01:10:50 SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning
Ozkan Sezer 5342ae2b 2018-09-27T01:00:50 SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset()
Ozkan Sezer d2131ac1 2018-09-27T00:32:15 SDL_vsnprintf: implement precision for the integral value printers.
Ozkan Sezer ffc19ee2 2018-09-26T20:47:34 SDL_string.c: added comments to three SDL_FormatInfo members.
Ozkan Sezer 8743e975 2018-09-26T17:11:40 SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0.
Ozkan Sezer 69ab8541 2018-09-26T10:40:02 SDL_vsnprintf: string printer now honors the precision. (bug #4263.)
Ozkan Sezer d0e9a364 2018-09-26T10:38:40 SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.)
Sam Lantinga d2042e1e 2018-08-09T16:00:17 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
Ozkan Sezer 652d59fb 2018-05-10T09:02:39 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.
Sam Lantinga 3b4c2fdf 2018-02-13T08:13:29 Fixed bug 3947 - replace strlcpy with memcpy in SDL_strdup()
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga 9c580e14 2017-10-12T13:44:28 Added functions to query and set the SDL memory allocation functions: SDL_GetMemoryFunctions() SDL_SetMemoryFunctions() SDL_GetNumAllocations()
Sam Lantinga c1fd0fbb 2017-09-04T22:14:57 Fixed compiler warning with mingw-w64
Sam Lantinga f1829d95 2017-08-13T20:37:49 Added SDL_wcscmp()
Sam Lantinga affab6ad 2017-08-12T00:01:24 More fixes for the SDL_scanf code
Sam Lantinga 441d9ba2 2017-08-11T19:36:12 Fixed bug 3341 - SDL_sscanf() problem e_pluschauskas Why does SDL_sscanf() always returns the number of format specifiers and doesn't implements standard C library behavior?
Ryan C. Gordon d4086e4a 2017-05-29T03:01:05 stdlib: added SDL_utf8strlen().
Ryan C. Gordon 29a047df 2017-05-29T00:51:38 Fixed whitespace code style.
Ryan C. Gordon c93bca48 2017-02-14T02:49:08 stdlib: Fixed crash on SDL_snprintf("%s", NULL). Like other C runtimes, it should probably produce the string "(null)". This bug probably only affected Windows, as most platforms use their standard C runtime's snprintf().
Sam Lantinga 5cb1ca55 2017-01-18T11:57:27 Fixed building with mingw32
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga 880842cf 2016-12-31T16:14:51 Fixed bug 3531 - internal SDL_vsnprintf implementation access memory outside given buffer ranges Tristan The internal SDL_vsnprintf implementation accesses memory outside buffer. The bug existed also inside the format (%) processing, which was fixed with Bug 3441. But there is still an invalid access, if we do not have any format inside the source string and the destination string is shorter than the format string. You can use any string for this test, as long it is longer than the buffer. Example: va_list argList; char buffer[4]; SDL_vsnprintf(buffer, sizeof(buffer), "Testing", argList); The bug is located on the 'else' branch of the format char test: while (*fmt) { if (*fmt == '%') { ... } else { if (left > 1) { *text = *fmt; --left; } ++fmt; ++text; } } if (left > 0) { *text = '\0'; } As you can see that text is always incremented, even when left is already one. When then on the last lines, *text is assigned the NULL char, the pointer is located outside bounds.
Sam Lantinga 57d01d7d 2016-11-13T22:57:41 Patch from Sylvain to fix clang warnings
Sam Lantinga 74e1dd4c 2016-11-11T13:14:00 Define _GNU_SOURCE when building SDL
Ryan C. Gordon 46f44f66 2016-10-04T14:25:31 Fixed potential buffer overflow in SDL_vsnprintf() (thanks, Taylor!). Fixes Bugzilla #3441. "When using internal SDL_vsnprintf(), and source string length is greater than destination, the final NULL char will be written beyond destination size. Primary issue that is SDL_strlcpy returns length of source string (SDL_PrintString()), not how much is written to destination. The destination ptr is then incremented by this length before the sanity check is done. Destination string is properly terminated, but an extra NULL char will be written beyond destination buffer length. Patch used internally is attached which fixes primary issue with SDL_strlcpy() in SDL_PrintString() and adjusts sanity checks to increment destination ptr safely."
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Ryan C. Gordon 75702ffe 2015-05-28T14:34:38 Make sure we have the vsscanf() prototype (thanks, Ozkan!). issue seen with glibc-2.8. Fixes Bugzilla #2721.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
Ryan C. Gordon a823982e 2015-01-05T01:41:42 Clang static analysis builds should use C runtime directly. This is a little macro magic to use malloc() directly instead of SDL_malloc(), etc, so static analysis tests that know about the C runtime can function properly, and understand that we are dealing with heap allocations, etc. This changed our static analysis report from 5 outstanding bugs to 30. 5x as many bugs were hidden by SDL_malloc() not being recognized as malloc() by the static analyzer!
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 0d673844 2014-06-21T11:52:53 Fixed bug 2596 - SDL_SetError fails on on NULL on systems with vsnprintf sfalexrog On systems with vsnprintf call SDL_SetError fails when passed a NULL as an argument. SDL's implementation checks for NULL (as seen in the commit: https://hg.libsdl.org/SDL/rev/835403a6aec8), but system implementation may crash.
Sam Lantinga 40538446 2014-06-07T17:31:50 Fixed crash with SDL_SetError(NULL)
Sam Lantinga da6d9a9f 2014-06-04T10:56:56 Added annotations to help code analysis tools CR: Bruce Dawson
Yuri Kunde Schlesner d12d7952 2014-05-10T21:48:46 Align pointer in SDL_memset before doing Uint32 loop Some more recent compilers emit SSE aligned store instructions for the loop, causing crashes if the destination buffer isn't aligned on a 32-bit boundary. This would also crash on platforms like ARM that require aligned stores. This fixes a crash inside SDL_FillRect that happens with the official x64 mingw build.
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Sam Lantinga 35ab76d0 2013-12-11T21:17:24 Fixed bug 2050 - Obvious bugs in SDL_ltoa and SDL_lltoa pjz SDL_ltoa(-2147483648,s,10) only returns "-" because there is a bug in the code: if ( value < 0 ) { *bufp++ = '-'; value = -value; } but -(-2147483648) is still -2147483648 (0x80000000) as signed int (or long), so the following loop doesn't run at all. Similar bug are also in SDL_lltoa. BTW, there is no sanity check for radix.
Ryan C. Gordon 31caa22d 2013-12-09T13:30:35 Patched stdlib changes to compile on Windows.
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Ryan C. Gordon e7693740 2013-11-24T23:35:38 Added SDL_vsscanf().
Sam Lantinga cefffd61 2013-09-05T06:59:34 Fixed bug 2082 - SDL stdlib implementation does not force upper case for %X format specifier norfanin When SDL_vsnprintf handles the %x format specifier, a boolean is set to signal forced lower case. It also should be able to signal forced upper case for the %X specifier. A boolean is not sufficient anymore. The attached patch adds an enum for the three cases: lower, upper and no change.
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.