Commit Graph

107 Commits

Author SHA1 Message Date
Ozkan Sezer
1a83bf2399 fix a possible memory leak in SDL_vasprintf() 2023-11-05 20:01:02 +03:00
Sam Lantinga
f3261fedcc Code cleanup now that SDL_bool is equivalent to a C boolean expression 2023-11-03 09:54:04 -07:00
Sam Lantinga
39a961ba41 Added support for "%[]" sscanf syntax
Fixes https://github.com/libsdl-org/SDL/issues/8423
2023-10-24 17:28:15 -07:00
Anonymous Maarten
342ec51131 Fix overflow when doing SDL_sscanf("%hd", ...)
An overflow occured in the stdlib_sscanf test, when using msys2 clang32 toolchain.
2023-08-10 15:06:42 -07:00
Brick
c03f5b4b69 Fixed rounding up in SDL_PrintFloat
This wasn't caught by the 9.9999999 case, because that value is actually just equal to 10.0
2023-08-07 14:15:19 -07:00
Sam Lantinga
0a4e6f6d29 Added SDL_strnlen() and SDL_wcsnlen() 2023-07-17 19:37:51 -07:00
Sam Lantinga
f3d6320bac Added SDL_strndup() 2023-07-16 04:32:12 -07:00
Sam Lantinga
f4bd17deee Fixed %p formatting when there is following text 2023-07-06 08:04:20 -07:00
Sam Lantinga
c63aa9545e Fixed printf formatting for "%p" and added a unit test to check it 2023-07-05 20:06:59 -07:00
Sam Lantinga
6150b5b3cb Don't bother re-encoding Latin1 characters in the ASCII range 2023-06-04 05:37:06 -07:00
Sam Lantinga
491ae20d96 Only convert the result of XLookupString() if it's not already UTF-8
Fixes https://github.com/libsdl-org/SDL/issues/7766
2023-06-04 02:50:03 -07:00
Sam Lantinga
128ca70160 Added support for printing wide strings using "%ls" syntax 2023-05-26 13:58:10 -07:00
Sam Lantinga
c9d8a04945 Added SDL_swprintf() and SDL_vswprintf() 2023-05-26 08:19:04 -07:00
Sam Lantinga
6c28546828 Added SDL_wcstol() 2023-05-26 08:19:04 -07:00
Sam Lantinga
ddbdd73258 Updated source to match SDL function prototype style 2023-05-23 11:29:41 -07:00
Sam Lantinga
737aa881fa Updated source to match SDL function prototype style 2023-05-23 09:37:07 -07:00
Anonymous Maarten
b6ae281e97 Use #ifdef/#ifndef instead of #if defined/#if \!defined 2023-03-30 21:35:01 +00:00
Sam Lantinga
308bcbbe76 Fixed Visual Studio warning 4244 2023-03-30 14:04:32 -07:00
Sam Lantinga
0bd77a5b93 Fixed Visual Studio warning 4389 2023-03-30 14:02:04 -07:00
Sam Lantinga
b078122c53 Fixed Visual Studio warning 4701 2023-03-30 14:02:02 -07:00
Sam Lantinga
fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga
38b138cd0a Fixed rounding of floating point values in snprintf 2023-01-03 06:35:25 -08:00
Sam Lantinga
ead4f122e4 Added basic support for %g snprintf format specifier 2022-12-29 23:12:19 -08:00
Sam Lantinga
36d4395c97 SDL API renaming: internal functions 2022-12-27 15:05:51 -08:00
Sam Lantinga
63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Pierre Wendling
3c501b963d Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga
5750bcb174 Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga
c5790359fd Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sylvain Becker
6a2200823c Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga
63f307fe1f Remove SDL_config.h from the public headers
The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Sam Lantinga
297ecb706d Added SDL_strcasestr() for a case insensitive version of SDL_strstr() 2022-11-05 15:58:30 -07:00
Sam Lantinga
dc2a682a82 Use the right kind of 0 2022-09-20 09:22:43 -07:00
Sam Lantinga
2461930601 Fixed build on RISC OS 2022-09-20 09:16:10 -07:00
Ozkan Sezer
887ae0c6eb fix build failure after commit 2a8d00634d if strtod isn't available. 2022-09-20 18:20:00 +03:00
Sam Lantinga
2a8d00634d Fixed scanning a negative number as an unsigned value
e.g. sscanf("-1", "%zu", &v)

Thanks to @sezero for the test case
2022-09-20 07:25:49 -07:00
Ozkan Sezer
3f5c46663e SDL_vsscanf: fix an uninitialized warning 2022-09-20 11:56:40 +03:00
Sam Lantinga
216e3f10bb Implemented size_t format specifiers for SDL_snprintf() and SDL_sscanf()
Fixes https://github.com/libsdl-org/SDL/issues/6264
2022-09-19 15:42:11 -07:00
Ivan Epifanov
7115ceb775 Vita: restore sceClibMemcmp 2022-09-17 10:12:46 -07:00
Sam Lantinga
67cb3874ef Fixed potential uninitialized variable usage 2022-08-12 20:51:28 -07:00
Dav999-v
51f75b8b30 Fix fallback implementations of SDL_strchr and SDL_strrchr for '\0'
strchr and strrchr return a pointer to the first/last occurrence of a
character in a string, or NULL if the character is not found. According
to the C standard, the final null terminator is part of the string, and
it should thus be possible to get a pointer to the final null with
these functions. The fallback implementations of SDL_strchr and
SDL_strrchr would always return NULL if trying to find '\0', and this
commit fixes that.
2022-07-04 11:10:26 -04:00
Sam Lantinga
12f14bdbeb Fixed digit count in sscanf, e.g. "%1x" 2022-06-18 07:02:38 -07:00
Anonymous Maarten
ae7446a959 stlib: Extract SDL_memcpy and SDL_memset to its own file respectively
This is done such that we can disable LTO for these 2 functions when
building with MSVC.

This is due to a limitation of Link Time Code Generation (LTCG).
Code generation might generate a new reference to memset after linking
has started. The LTCG must make assumptions about where memset is
defined which is normally the C runtime.
2022-06-15 14:17:35 -07:00
Guldoman
74bcc5a0a3 stdlib: Add SDL_utf8strnlen 2022-06-09 15:18:50 -07:00
Sam Lantinga
8cd908e0b9 Fixed building with Visual Studio 2013
Added SDL_vacopy.h since it needs to be included after Windows headers
2022-05-06 10:51:55 -07:00
Eddy Jansson
97774cdf72 Move in va_copy() define block from stdlib. 2022-04-29 10:39:02 -07:00
pionere
25203222f5 optimize the SDL_str(case)cmp functions 2022-03-22 12:17:50 -07:00
pionere
aec58d8208 make SDL_strcasecmp standard compliant 2022-03-22 12:17:50 -07:00
Sam Lantinga
bdafe1e049 Fixed whitespace 2022-03-04 11:01:55 -08:00
Ozkan Sezer
0abc0a6f32 SDL_string.c: tidy-up gcc2 va_copy defines after previous haiku commit. 2022-01-12 20:37:32 +03:00
kenmays
d37c9777b9 haiku: updated for Haiku 2022-01-12 09:32:56 -08:00