Review OpenURL()

This commit is contained in:
Ray 2018-11-12 00:34:32 +01:00
parent 657897b493
commit 30a1edd40e

View file

@ -1822,19 +1822,17 @@ int StorageLoadValue(int position)
// Open URL with default system browser (if available) // Open URL with default system browser (if available)
void OpenURL(const char *url) void OpenURL(const char *url)
{ {
char *cmd = calloc(10 + strlen(url), sizeof(char)); char *cmd = calloc(strlen(url) + 10, sizeof(char));
#if defined(_WIN32) #if defined(_WIN32)
strcpy(cmd, "explorer "); sprintf(cmd, "explorer '%s'", url);
strcat(cmd, url);
#elif defined(__linux__) #elif defined(__linux__)
sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser sprintf(cmd, "xdg-open '%s'", url); // Alternatives: firefox, x-www-browser
#elif defined(__APPLE__) #elif defined(__APPLE__)
strcpy(cmd, "open "); sprintf(cmd, "open '%s'", url);
strcat(cmd, url);
#endif #endif
system(cmd); system(cmd);
free(cmd); free(cmd);
} }