{"thread":{"id":"23052","subject":"[PATCH 2/2] Report errors when failing to launch the html browser in mingw.","startedAt":"2010-03-17T15:20:03Z","lastAt":"2010-03-17T17:01:07Z","messageCount":2,"participants":["Pat Thoyts","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"137023","messageId":"87aau7dkon.fsf@fox.patthoyts.tk","threadId":"23052","inReplyTo":null,"subject":"[PATCH 2/2] Report errors when failing to launch the html browser in mingw.","fromName":"Pat Thoyts","fromEmail":"patthoyts@users.sourceforge.net","sentAt":"2010-03-17T15:20:03Z","receivedAt":"2010-03-17T15:20:03Z","isPatch":true,"sender":{"key":"patthoyts@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/30739?v=4"},"body":"The mingw function to launch the system html browser is silent if the\ntarget file does not exist leaving the user confused. Make it display\nsomething.\n\nSigned-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\n---\n compat/mingw.c |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 9c10a4c..d6539ef 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1548,6 +1548,7 @@ void mingw_open_html(const char *unixpath)\n \t\t\tconst char *, const char *, const char *, INT);\n \tT ShellExecute;\n \tHMODULE shell32;\n+\tint r;\n \n \tshell32 = LoadLibrary(\"shell32.dll\");\n \tif (!shell32)\n@@ -1557,9 +1558,11 @@ void mingw_open_html(const char *unixpath)\n \t\tdie(\"cannot run browser\");\n \n \tprintf(\"Launching default browser to display HTML ...\\n\");\n-\tShellExecute(NULL, \"open\", htmlpath, NULL, \"\\\\\", 0);\n-\n+\tr = (int)ShellExecute(NULL, \"open\", htmlpath, NULL, \"\\\\\", SW_SHOWNORMAL);\n \tFreeLibrary(shell32);\n+\tif (r < 33) {\n+\t\tdie(\"failed to launch browser for %.*s\", MAX_PATH, unixpath);\n+\t}\n }\n \n int link(const char *oldpath, const char *newpath)\n-- \n1.7.0.2.msysgit.0.3.g3c992.dirty\n"},{"id":"137037","messageId":"40aa078e1003171001s2c6a8765ve3bee38dddc2211c@mail.gmail.com","threadId":"23052","inReplyTo":"87aau7dkon.fsf@fox.patthoyts.tk","subject":"Re: [PATCH 2/2] Report errors when failing to launch the html browser in mingw.","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-03-17T17:01:07Z","receivedAt":"2010-03-17T17:01:07Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Mar 17, 2010 at 4:20 PM, Pat Thoyts\n<patthoyts@users.sourceforge.net> wrote:\n> The mingw function to launch the system html browser is silent if the\n> target file does not exist leaving the user confused. Make it display\n> something.\n>\n> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>\n> ---\n>  compat/mingw.c |    7 +++++--\n>  1 files changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> index 9c10a4c..d6539ef 100644\n> --- a/compat/mingw.c\n> +++ b/compat/mingw.c\n> @@ -1548,6 +1548,7 @@ void mingw_open_html(const char *unixpath)\n>                        const char *, const char *, const char *, INT);\n>        T ShellExecute;\n>        HMODULE shell32;\n> +       int r;\n>\n>        shell32 = LoadLibrary(\"shell32.dll\");\n>        if (!shell32)\n> @@ -1557,9 +1558,11 @@ void mingw_open_html(const char *unixpath)\n>                die(\"cannot run browser\");\n>\n>        printf(\"Launching default browser to display HTML ...\\n\");\n> -       ShellExecute(NULL, \"open\", htmlpath, NULL, \"\\\\\", 0);\n> -\n> +       r = (int)ShellExecute(NULL, \"open\", htmlpath, NULL, \"\\\\\", SW_SHOWNORMAL);\n>        FreeLibrary(shell32);\n> +       if (r < 33) {\n\nWhile entirely correct, this looks a little weird to me. How about \"if\n(r <= 32)\" (since 32 is the number MSDN mentions) and a comment?\n\n-- \nErik \"kusma\" Faye-Lund\n"}]}