threads / patch / 23052

patch, 2 partsReport errors when failing to launch the html browser in mingw.

Subject: [PATCH 2/2] Report errors when failing to launch the html browser in mingw.

## tl;dr

2 messages between Mar 17, 2010 and Mar 17, 2010. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Pat Thoyts· Mar 17, 2010, 15:20 UTC · lore

The mingw function to launch the system html browser is silent if the target file does not exist leaving the user confused. Make it display something.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 compat/mingw.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
Show changes to compat/mingw.c +5 −2
diff --git a/compat/mingw.c b/compat/mingw.c
index 9c10a4c..d6539ef 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1548,6 +1548,7 @@ void mingw_open_html(const char *unixpath)
 			const char *, const char *, const char *, INT);
 	T ShellExecute;
 	HMODULE shell32;
+	int r;
 
 	shell32 = LoadLibrary("shell32.dll");
 	if (!shell32)
@@ -1557,9 +1558,11 @@ void mingw_open_html(const char *unixpath)
 		die("cannot run browser");
 
 	printf("Launching default browser to display HTML ...\n");
-	ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0);
-
+	r = (int)ShellExecute(NULL, "open", htmlpath, NULL, "\\", SW_SHOWNORMAL);
 	FreeLibrary(shell32);
+	if (r < 33) {
+		die("failed to launch browser for %.*s", MAX_PATH, unixpath);
+	}
 }
 
 int link(const char *oldpath, const char *newpath)
-- 
1.7.0.2.msysgit.0.3.g3c992.dirty
Erik Faye-Lund· Mar 17, 2010, 17:01 UTC · re: Pat Thoyts · lore

Re: [PATCH 2/2] Report errors when failing to launch the html browser in mingw.

On Wed, Mar 17, 2010 at 4:20 PM, Pat Thoyts <patthoyts@users.sourceforge.net> wrote:

Show 30 quoted lines
> The mingw function to launch the system html browser is silent if the
> target file does not exist leaving the user confused. Make it display
> something.
>
> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
> ---
>  compat/mingw.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 9c10a4c..d6539ef 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1548,6 +1548,7 @@ void mingw_open_html(const char *unixpath)
>                        const char *, const char *, const char *, INT);
>        T ShellExecute;
>        HMODULE shell32;
> +       int r;
>
>        shell32 = LoadLibrary("shell32.dll");
>        if (!shell32)
> @@ -1557,9 +1558,11 @@ void mingw_open_html(const char *unixpath)
>                die("cannot run browser");
>
>        printf("Launching default browser to display HTML ...\n");
> -       ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0);
> -
> +       r = (int)ShellExecute(NULL, "open", htmlpath, NULL, "\\", SW_SHOWNORMAL);
>        FreeLibrary(shell32);
> +       if (r < 33) {

While entirely correct, this looks a little weird to me. How about "if (r <= 32)" (since 32 is the number MSDN mentions) and a comment?

-- 
Erik "kusma" Faye-Lund

← back to recent threads