diff --git a/main.c b/main.c index abc9101..fb0ab64 100644 --- a/main.c +++ b/main.c @@ -1,9 +1,5 @@ /* See LICENSE file for license and copyright information */ -#define _BSD_SOURCE -#define _XOPEN_SOURCE 700 - -#include #include #include #include @@ -13,7 +9,6 @@ #include #include #include -#include #include "zathura.h" #include "utils.h" @@ -101,9 +96,16 @@ main(int argc, char* argv[]) return -1; } - char* real_path = realpath(argv[1], NULL); + GFile* file = g_file_new_for_commandline_arg(argv[1]); + if (file == NULL) { + girara_error("Unable to handle argument '%s'.", argv[1]); + return -1; + } + + char* real_path = g_file_get_path(file); + g_object_unref(file); if (real_path == NULL) { - girara_error("Failed to determine real path: %s", strerror(errno)); + girara_error("Failed to determine path for '%s'", argv[1]); return -1; } @@ -111,7 +113,7 @@ main(int argc, char* argv[]) if (split_fwd == NULL || split_fwd[0] == NULL || split_fwd[1] == NULL || split_fwd[2] == NULL || split_fwd[3] != NULL) { girara_error("Failed to parse argument to --synctex-forward."); - free(real_path); + g_free(real_path); g_strfreev(split_fwd); return -1; } @@ -121,14 +123,12 @@ main(int argc, char* argv[]) const bool ret = zathura_dbus_synctex_position(real_path, split_fwd[2], line, column, synctex_pid); g_strfreev(split_fwd); - if (ret == true) { - free(real_path); - return 0; - } else { + if (ret == false) { girara_error("Could not find open instance for '%s' or got no usable data from synctex.", real_path); - free(real_path); - return -1; } + + g_free(real_path); + return ret == true ? 0 : -1; } /* check mode */ diff --git a/page-widget.c b/page-widget.c index 033a9de..54905b2 100644 --- a/page-widget.c +++ b/page-widget.c @@ -874,7 +874,7 @@ zathura_page_widget_popup_menu(GtkWidget* widget, GdkEventButton* event) void (*callback)(GtkMenuItem*, ZathuraPage*); } menu_item_t; - menu_item_t menu_items[] = { + const menu_item_t menu_items[] = { { _("Copy image"), cb_menu_image_copy }, { _("Save image as"), cb_menu_image_save }, };