Commit Graph

91 Commits

Author SHA1 Message Date
Sam Lantinga
f8400cbba9 Fixed bug 4692 - Command line parsing
Galadrim

As I have seen, SDL implements its own command line parser for Windows in SDL_windows_main.c. Unfortunately, it doesn't seem to allow command line arguments with trailing backslashes if quoting is required.

Usually, when you write an application that gets command line arguments passed as argc and argv, the parsing is done by parse_cmdline. The Windows API also provides the function CommandLineToArgvW, so an application can parse itself if only the command line string is provided. Both functions behave almost identically according to their documentation. If the argument "\\" (including the quotes) is passed, they both turn it into a single backslash.

The SDL command line parser on the other hand doesn't recognize the second quote character as the closing character in this example and therefore includes it in the parsed argument. The parser does not count the number of backslashes preceding a quote. It always treats a quote as escaped if a backslash is in front of it. Therefore, it should be impossible to quote and escape an argument correctly, if it has a trailing backslash and contains characters that require quoting.

Of course, each application is allowed to implement its own parsing rules, so SDL is free to do so. But the problem I see is that there are arguments, that are impossible to be passed to the parser correctly, as I described above. Is there a reason, why SDL does not simply use CommandLineToArgvW instead of implementing its own parser?

Here are some links that show that correct argument parsing, as it is usually done in Windows, is quite complicated:

https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-commandlinetoargvw

http://www.windowsinspired.com/how-a-windows-programs-splits-its-command-line-into-individual-arguments/
2019-07-31 09:11:20 -07:00
Ozkan Sezer
4953e050f5 use SDL_zeroa at more places where the argument is an array. 2019-07-31 05:11:40 +03:00
Sam Lantinga
67c67f3a6b Updated version to 2.0.10 2019-06-17 10:13:28 -07:00
Sam Lantinga
de82759c84 Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Ryan C. Gordon
e542d1a36d winmain: Patched to compile on C89 compilers. 2018-10-29 20:18:50 -04:00
Ryan C. Gordon
f434a98c26 winmain: Don't use SDL_malloc (or SDL_stack_alloc, which might be malloc).
Otherwise, we are using the allocator before the app can set up its own hooks.

Now we use VirtualAlloc, and WideCharToMultiByte (because SDL_iconv uses
SDL_malloc, too!) to get ready to call into SDL_main.

This also makes console_wmain() call into the same routines as everything
else, so we don't have to deal with those allocations, too. Hopefully we
end up with the same results from GetCommandLine() as we do in wargv.

Fixes Bugzilla #4340.
2018-10-29 20:00:03 -04:00
Sam Lantinga
bc6c199790 Updated version to 2.0.9 2018-09-26 10:08:14 -07:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Ryan C. Gordon
941c5b4760 haiku: Rename internal functions from BE_* to HAIKU_*
Fixes Bugzilla #2349.
2018-08-07 18:07:11 -04:00
Sam Lantinga
1143857d76 Fixed bug 4073 - Unquoted Unicode argument parsing broken on Windows due to incorrect usage of SDL_isspace() 2018-02-10 12:43:11 -08:00
Sam Lantinga
e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga
2c5724ef5d Updated version to 2.0.8 since SDL_image depends on it 2017-11-04 21:58:48 -07:00
David Ludwig
0e032d5860 WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main.
This allows C# UWP applications to use SDL2's SDL_WinRTRunApp function.

Kudos to Ethan Lee (flibitijibibo@flibitijibibo.com) for the patch.  Thanks!
2017-10-24 13:21:11 -04:00
Sam Lantinga
0ce23a5498 Updated version to 2.0.7 2017-10-12 08:08:04 -07:00
Sam Lantinga
dbb0a2aa74 Removed the need for libSDL2main.a on Android, and separated JNI initialization out for other integrations 2017-08-28 14:34:15 -07:00
Sam Lantinga
2dc5d32fab Updated version to 2.0.6 2017-08-18 18:16:37 -07:00
Sam Lantinga
df2d299447 Fixed bug 2812 - Make libSDL2main.a usable on Android via a dummy symbol
Jonas Kulla

This eliminates the need to manually compile in SDL_main_android.c.
Instead, add "-lSDL2main -Wl,-u,SDL_main_dummy" when linking.

I don't know how the nkd-build process works, but unless it was
for some reason linking libSDL2main.a it should be unaffected.
2017-08-13 18:12:06 -07:00
Philipp Wiesemann
c3bf69ca4b haiku: Fixed compiling without OpenGL support. 2017-07-07 23:00:22 +02:00
Olli Kallioinen
11289b766f Android cmake build fixed to work with the official android gradle plugin 2017-06-04 21:25:57 +03:00
Philipp Wiesemann
4b47fa38c3 Removed duplicate includes. 2017-06-04 23:15:47 +02:00
Philipp Wiesemann
07b0df0a22 haiku: Changed internal variable to be static. 2017-06-02 22:15:37 +02:00
Ryan C. Gordon
619ab7a22d haiku: Various fixes from haikuports.
Based on patch here:

https://github.com/haikuports/haikuports/blob/master/media-libs/libsdl2/patches/libsdl2-2.0.5.patchset
2017-05-01 18:39:05 -04:00
Philipp Wiesemann
63e83a3127 Haiku: Removed unused variable.
Found by Cppcheck.
2017-01-21 22:01:17 +01:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
8a73f7e893 Fixed bug 3461 - Implement TEXTINPUT events for Haiku
Kai Sterker

Apparently, SDL2 on Haiku does not generate SDL_TEXTINPUT events.
Attached is a patch that adds this functionality.

Tested with SDLs own checkkeys program and different keymaps as well as my own SDL application and German keyboard layout to verify it generates the expected input.
2016-10-19 20:42:22 -07:00
Sam Lantinga
8aab39cb7d Fixed bug 3452 - Getting unicode arguments for the main entry point on Windows
Simon Hug

There are currently three entry points in the SDL2_main code for windows: main, wmain and WinMain. Only the latter two properly convert the arguments to UTF-8.

Console applications linked with MSVC will always link with the main entry point (wmain has to be selected by manually setting the entry point). This makes it likely that such programs will not have proper unicode arguments.
2016-10-14 08:27:44 -07:00
Sam Lantinga
14e7da75b2 Backed out change 7d3df1df4e91 which was: Fixed bug 3320 - SDL_windows_main.c defines both console application entry points
With that change only the wmain() entry point was defined, and applications that linked with main() would no longer build.
2016-10-12 19:50:16 -07:00
Sam Lantinga
d870f2719b Fixed bug 3320 - SDL_windows_main.c defines both console application entry points
Simon Hug

The SDLmain file src/main/windows/SDL_windows_main.c defines both entry points for console applications, main and wmain. This seems to confuse MSVC. It outputs a LNK4067 warning and then chooses main, which is a shame because only wmain has the unicode handling. Using SDLmain.lib provided on libsdl.org, the linker also goes for main.

I'm proposing to not define the main entry point at all. wmain should be supported well enough with MSVC.
2016-10-01 12:31:31 -07:00
Sam Lantinga
708def87f3 Fixed bug 3338 - console_wmain doesn't null terminate the argv array
Simon Hug

The function console_wmain in src/main/windows/SDL_windows_main.c does not null terminate the argument list it is creating. As specified by the C standard, "argv[argc] shall be a null pointer."

The SDLTest framework makes use of that null pointer and some test programs can cause an access violation because it's missing.
2016-10-01 11:48:15 -07:00
Sam Lantinga
e45698d218 Updated version to 2.0.5 in preparation for release 2016-09-28 22:24:01 -07:00
Philipp Wiesemann
6b1d5f4461 Android: Fixed compile warning about a missing prototype (thanks, Sylvain!).
Fixes Bugzilla #3351.
2016-07-17 21:42:53 +02:00
David Ludwig
441359bd5a WinRT: workaround a possible Windows bug, whereby hiding cursors, disables mouse-moved events
This workaround, unfortunately, requires that apps directly link to a set of
Win32-style cursor resource files (that contain a transparent cursor image).
Copies of suitable resource files are in src/core/winrt/, and should be
included directly in an app's MSVC project.

A rough explanation of this workaround/hack, and why it's needed (and
seemingly can't be done through programmatic means), is in this change's code.
2016-05-14 23:29:49 -04:00
Ryan C. Gordon
c137eb61d7 Patched to compile on Haiku...? 2016-04-12 18:40:44 -04:00
Ryan C. Gordon
9b4db2b8aa Patched to compile on various platforms. 2016-04-12 18:11:36 -04:00
Ryan C. Gordon
c61675dc5d threads: Move SDL's own thread creation to a new internal API.
This allows us to set an explicit stack size (overriding the system default
and the global hint an app might have set), and remove all the macro salsa
for dealing with _beginthreadex and such, as internal threads always set those
to NULL anyhow.

I've taken some guesses on reasonable (and tiny!) stack sizes for our
internal threads, but some of these might turn out to be too small in
practice and need an increase. Most of them are simple functions, though.
2016-04-12 16:45:10 -04:00
Eric Wing
704298c0c2 Android: C89 cleanup to avoid warnings/errors since the default gcc mode on Android is still pre-C99. 2016-02-09 17:36:42 -08:00
Sam Lantinga
68a3272852 Fixed sed error on Mac OS X and updated copyright on a few last files 2016-01-02 10:38:51 -08:00
Sam Lantinga
42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
270f38db08 Fixed bug 3083 - Android JNIEXPORT and JNICALL missing
Martin Gerhardy

Just a minor thing, but a huge outcome. All the other jni related functions already have those flags, but the nativeInit function lacks them - so it might be stripped away.
2015-08-01 22:03:50 -07:00
Philipp Wiesemann
0e45984fa0 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().
2015-06-21 17:33:46 +02:00