[monkey-bubble: 678/753] use an internal version of cancat dir and file which always works with '/'
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 678/753] use an internal version of cancat dir and file which always works with '/'
- Date: Wed, 14 Jul 2010 22:52:41 +0000 (UTC)
commit 6626bedac8e3c9383e1c9b01e264100022d7d0c8
Author: George Lebl <jirka 5z com>
Date: Mon Aug 27 08:12:25 2001 +0000
use an internal version of cancat dir and file which always works with '/'
Mon Aug 27 00:55:56 2001 George Lebl <jirka 5z com>
* gnome-config.c, parse-path.cP: use an internal version of
cancat dir and file which always works with '/'
libgnome/ChangeLog | 5 +++++
libgnome/gnome-config.c | 32 +++++++++++++++++++++++---------
libgnome/parse-path.cP | 3 +--
3 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/libgnome/ChangeLog b/libgnome/ChangeLog
index 9dd862e..23302ab 100644
--- a/libgnome/ChangeLog
+++ b/libgnome/ChangeLog
@@ -1,3 +1,8 @@
+Mon Aug 27 00:55:56 2001 George Lebl <jirka 5z com>
+
+ * gnome-config.c, parse-path.cP: use an internal version of
+ cancat dir and file which always works with '/'
+
Mon Aug 27 00:32:57 2001 George Lebl <jirka 5z com>
* gnome-gconf.c: include gnome-i18nP.h
diff --git a/libgnome/gnome-config.c b/libgnome/gnome-config.c
index d701b32..ac0984f 100644
--- a/libgnome/gnome-config.c
+++ b/libgnome/gnome-config.c
@@ -128,6 +128,20 @@ static TProfile *Current = 0;
*/
static TProfile *Base = 0;
+static char *
+config_concat_dir_and_key (const char *dir, const char *key)
+{
+ g_return_val_if_fail (dir != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+
+ /* If the directory name doesn't have a / on the end, we need
+ to add one so we get a proper path to the file */
+ if (dir[0] != '\0' && dir [strlen(dir) - 1] != '/')
+ return g_strconcat (dir, "/", key, NULL);
+ else
+ return g_strconcat (dir, key, NULL);
+}
+
/* The `release_path' and `parsed_path' routines are inside the
following file. It is in a separate file to allow the test-suite
to get at it, without needing to export special symbols.
@@ -565,7 +579,7 @@ access_config_extended (access_type mode, const char *section_name,
if (cache_overrride_filename)
g_free (cache_overrride_filename);
- tmp = g_concat_dir_and_file ("gnome/config-override",rel_file);
+ tmp = config_concat_dir_and_key ("gnome/config-override",rel_file);
filename = gnome_program_locate_file
(gnome_program_get (), GNOME_FILE_DOMAIN_CONFIG,
tmp, TRUE, NULL);
@@ -575,7 +589,7 @@ access_config_extended (access_type mode, const char *section_name,
if (cache_global_filename)
g_free (cache_global_filename);
- tmp = g_concat_dir_and_file ("gnome/config", rel_file);
+ tmp = config_concat_dir_and_key ("gnome/config", rel_file);
filename = gnome_program_locate_file
(gnome_program_get (), GNOME_FILE_DOMAIN_CONFIG,
tmp, TRUE, NULL);
@@ -848,7 +862,7 @@ _gnome_config_sync_file (char *path, gboolean priv)
if (!path)
return ret;
- fake_path = g_concat_dir_and_file (path, "section/key");
+ fake_path = config_concat_dir_and_key (path, "section/key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -895,7 +909,7 @@ _gnome_config_clean_file (const char *path, gboolean priv)
if (!path)
return;
- fake_path = g_concat_dir_and_file (path, "section/key");
+ fake_path = config_concat_dir_and_key (path, "section/key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -941,7 +955,7 @@ _gnome_config_drop_file (const char *path, gboolean priv)
if (!path)
return;
- fake_path = g_concat_dir_and_file (path, "section/key");
+ fake_path = config_concat_dir_and_key (path, "section/key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -997,7 +1011,7 @@ _gnome_config_init_iterator (const char *path, gboolean priv)
iterator_type *iter;
- fake_path = g_concat_dir_and_file (path, "key");
+ fake_path = config_concat_dir_and_key (path, "key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -1066,7 +1080,7 @@ _gnome_config_init_iterator_sections (const char *path, gboolean priv)
iterator_type *iter;
- fake_path = g_concat_dir_and_file (path, "section/key");
+ fake_path = config_concat_dir_and_key (path, "section/key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -1186,7 +1200,7 @@ _gnome_config_clean_section (const char *path, gboolean priv)
ParsedPath *pp;
char *fake_path;
- fake_path = g_concat_dir_and_file (path, "key");
+ fake_path = config_concat_dir_and_key (path, "key");
pp = parse_path (fake_path, priv);
g_free (fake_path);
@@ -1306,7 +1320,7 @@ _gnome_config_has_section (const char *path, gboolean priv)
ParsedPath *pp;
char *fake_path;
- fake_path = g_concat_dir_and_file (path, "key");
+ fake_path = config_concat_dir_and_key (path, "key");
pp = parse_path (fake_path,priv);
g_free (fake_path);
diff --git a/libgnome/parse-path.cP b/libgnome/parse-path.cP
index 5a6442c..2a8fd8c 100644
--- a/libgnome/parse-path.cP
+++ b/libgnome/parse-path.cP
@@ -27,7 +27,6 @@ parse_path (const char *path, gboolean priv)
p->opath = g_strdup (path);
else
p->opath = g_strconcat (prefix, path,NULL);
- /*p->opath = g_concat_dir_and_file (prefix, path);*/
p->path = p->opath;
p->file = (char *)GNOME_CONFIG_PARSE_ERROR;
@@ -43,7 +42,7 @@ parse_path (const char *path, gboolean priv)
p->file = g_strdup (token);
else {
char *cwd = g_get_current_dir();
- p->file = g_concat_dir_and_file(cwd,token);
+ p->file = config_concat_dir_and_key (cwd,token);
g_free(cwd);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]