[Github-comments] [geany] Use multi-byte variant of CreateProcess on Windows (#809)

Colomban Wendling notifications at xxxxx
Mon Dec 14 14:21:52 UTC 2015


> @@ -372,8 +374,29 @@ static gchar *spawn_create_process_with_pipes(char *command_line, const char *wo
>  	startup.hStdOutput = hpipe[WRITE_STDOUT];
>  	startup.hStdError = hpipe[WRITE_STDERR];
>  
> -	if (!CreateProcess(NULL, command_line, NULL, NULL, TRUE, pipe_io ? CREATE_NO_WINDOW : 0,
> -		environment, working_directory, &startup, &process))
> +	if (! MultiByteToWideChar(
> +		CP_UTF8, 0, working_directory, -1, w_working_directory, G_N_ELEMENTS(w_working_directory)))
> +	{
> +		gchar *err = g_win32_error_message(GetLastError());
> +		message = g_strdup_printf(
> +			"Failed to convert working directory to multi-byte string: %s", err);
> +		g_free(err);
> +		failed = "";  /* report the message only */

if I read the error handler below correctly, it would be shorter, simpler and more consistent to just do
```C
failed = "convert working directory to multi-byte string";
goto leave;
```
and let the common handler build the full message.

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/809/files#r47502059
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20151214/cd5d1c86/attachment.html>


More information about the Github-comments mailing list