[gnome-menus] Switch to modern realpath()
- From: Jeremy Bicha <jbicha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-menus] Switch to modern realpath()
- Date: Tue, 25 Dec 2018 15:37:23 +0000 (UTC)
commit f8708a09630eedd038cbc377007cbf687228a2e6
Author: Pino Toscano <toscano pino tiscali it>
Date: Mon Dec 24 22:36:36 2018 +0100
Switch to modern realpath()
Assume everywhere that the realpath() implementation has the
POSIX.1-2008 behaviour, i.e. allowing NULL as second parameter and thus
returning a newly allocated buffer; it is not just a GNU extension,
and supported already by modern libc's on other OSes.
menu_canonicalize_file_name() is always called with FALSE as second
parameter, so it is replaced directly by realpath(); this allows the
complete removal of canonicalize.{c,h}.
libmenu/Makefile.am | 2 -
libmenu/canonicalize.c | 254 --------------------------------------------
libmenu/canonicalize.h | 32 ------
libmenu/entry-directories.c | 4 +-
libmenu/gmenu-tree.c | 10 +-
libmenu/menu-layout.c | 1 -
6 files changed, 7 insertions(+), 296 deletions(-)
---
diff --git a/libmenu/Makefile.am b/libmenu/Makefile.am
index 235a812..6b911e7 100644
--- a/libmenu/Makefile.am
+++ b/libmenu/Makefile.am
@@ -13,7 +13,6 @@ libgnome_menu_3_include_HEADERS = \
gmenu-tree.h
libgnome_menu_3_sources = \
- canonicalize.c \
desktop-entries.c \
entry-directories.c \
gmenu-tree.c \
@@ -23,7 +22,6 @@ libgnome_menu_3_sources = \
libgnome_menu_3_la_SOURCES = \
$(libgnome_menu_3_sources) \
- canonicalize.h \
desktop-entries.h \
entry-directories.h \
gmenu-tree.h \
diff --git a/libmenu/entry-directories.c b/libmenu/entry-directories.c
index 9186782..8fb9813 100644
--- a/libmenu/entry-directories.c
+++ b/libmenu/entry-directories.c
@@ -23,10 +23,10 @@
#include <errno.h>
#include <sys/types.h>
#include <dirent.h>
+#include <stdlib.h>
#include "menu-util.h"
#include "menu-monitor.h"
-#include "canonicalize.h"
typedef struct CachedDir CachedDir;
typedef struct CachedDirMonitor CachedDirMonitor;
@@ -766,7 +766,7 @@ entry_directory_new (DesktopEntryType entry_type,
menu_verbose ("Loading entry directory \"%s\"\n", path);
- canonical = menu_canonicalize_file_name (path, FALSE);
+ canonical = realpath (path, NULL);
if (canonical == NULL)
{
menu_verbose ("Failed to canonicalize \"%s\": %s\n",
diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index a6b5e2c..5bbd0e4 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -21,11 +21,11 @@
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include "menu-layout.h"
#include "menu-monitor.h"
#include "menu-util.h"
-#include "canonicalize.h"
/* private */
typedef struct GMenuTreeItem GMenuTreeItem;
@@ -330,7 +330,7 @@ static gboolean
canonicalize_path (GMenuTree *tree,
const char *path)
{
- tree->canonical_path = menu_canonicalize_file_name (path, FALSE);
+ tree->canonical_path = realpath (path, NULL);
if (tree->canonical_path)
{
tree->canonical = TRUE;
@@ -1888,7 +1888,7 @@ load_merge_file (GMenuTree *tree,
if (!is_canonical)
{
- canonical = freeme = menu_canonicalize_file_name (filename, FALSE);
+ canonical = freeme = realpath (filename, NULL);
if (canonical == NULL)
{
if (add_monitor)
@@ -1983,7 +1983,7 @@ compare_basedir_to_config_dir (const char *canonical_basedir,
retval = FALSE;
- canonical_menus_dir = menu_canonicalize_file_name (dirname, FALSE);
+ canonical_menus_dir = realpath (dirname, NULL);
if (canonical_menus_dir != NULL &&
strcmp (canonical_basedir, canonical_menus_dir) == 0)
{
@@ -2060,7 +2060,7 @@ load_parent_merge_file (GMenuTree *tree,
basedir = menu_layout_node_root_get_basedir (root);
menu_name = menu_layout_node_root_get_name (root);
- canonical_basedir = menu_canonicalize_file_name (basedir, FALSE);
+ canonical_basedir = realpath (basedir, NULL);
if (canonical_basedir == NULL)
{
menu_verbose ("Menu basedir '%s' no longer exists, not merging parent\n",
diff --git a/libmenu/menu-layout.c b/libmenu/menu-layout.c
index a8bbeb4..9df266e 100644
--- a/libmenu/menu-layout.c
+++ b/libmenu/menu-layout.c
@@ -27,7 +27,6 @@
#include <unistd.h>
#include <errno.h>
-#include "canonicalize.h"
#include "entry-directories.h"
#include "menu-util.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]