>From 7e58f37e93bee3331109dc9fbc59fdf232b3d9c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 12:34:36 +0200
Subject: [PATCH 08/10] Remove code duplication by calling readGlobalDomain()
The code in defaults.c to get the shared database is
included in the same file (function readGlobalDomain).
---
src/defaults.c | 40 +++++++++++++---------------------------
1 file changed, 13 insertions(+), 27 deletions(-)
diff --git a/src/defaults.c b/src/defaults.c
index 0c4daf1..50e8cbe 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -803,7 +803,6 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool
requireDictionary)
WDDomain *db;
struct stat stbuf;
static int inited = 0;
- char path[PATH_MAX];
char *the_path;
WMPropList *shared_dict = NULL;
@@ -832,32 +831,19 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool
requireDictionary)
}
/* global system dictionary */
- snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR,
GLOBAL_DEFAULTS_SUBDIR, domain);
- if (stat(path, &stbuf) >= 0) {
- shared_dict = WMReadPropListFromFile(path);
- if (shared_dict) {
- if (requireDictionary &&
!WMIsPLDictionary(shared_dict)) {
- wwarning(_("Domain %s (%s) of global defaults
database is corrupted!"),
- domain, path);
- WMReleasePropList(shared_dict);
- shared_dict = NULL;
- } else {
- if (db->dictionary &&
WMIsPLDictionary(shared_dict) &&
- WMIsPLDictionary(db->dictionary)) {
- WMMergePLDictionaries(shared_dict,
db->dictionary, True);
- WMReleasePropList(db->dictionary);
- db->dictionary = shared_dict;
- if (stbuf.st_mtime > db->timestamp)
- db->timestamp = stbuf.st_mtime;
- } else if (!db->dictionary) {
- db->dictionary = shared_dict;
- if (stbuf.st_mtime > db->timestamp)
- db->timestamp = stbuf.st_mtime;
- }
- }
- } else {
- wwarning(_("could not load domain %s from global
defaults database (%s)"), domain, path);
- }
+ shared_dict = readGlobalDomain(domain, requireDictionary);
+
+ if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
+ WMIsPLDictionary(db->dictionary)) {
+ WMMergePLDictionaries(shared_dict, db->dictionary, True);
+ WMReleasePropList(db->dictionary);
+ db->dictionary = shared_dict;
+ if (stbuf.st_mtime > db->timestamp)
+ db->timestamp = stbuf.st_mtime;
+ } else if (!db->dictionary) {
+ db->dictionary = shared_dict;
+ if (stbuf.st_mtime > db->timestamp)
+ db->timestamp = stbuf.st_mtime;
}
return db;
--
1.7.10
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 7e58f37e93bee3331109dc9fbc59fdf232b3d9c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 12:34:36 +0200
Subject: [PATCH 08/10] Remove code duplication by calling readGlobalDomain()
The code in defaults.c to get the shared database is
included in the same file (function readGlobalDomain).
---
src/defaults.c | 40 +++++++++++++---------------------------
1 file changed, 13 insertions(+), 27 deletions(-)
diff --git a/src/defaults.c b/src/defaults.c
index 0c4daf1..50e8cbe 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -803,7 +803,6 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
WDDomain *db;
struct stat stbuf;
static int inited = 0;
- char path[PATH_MAX];
char *the_path;
WMPropList *shared_dict = NULL;
@@ -832,32 +831,19 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
}
/* global system dictionary */
- snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domain);
- if (stat(path, &stbuf) >= 0) {
- shared_dict = WMReadPropListFromFile(path);
- if (shared_dict) {
- if (requireDictionary && !WMIsPLDictionary(shared_dict)) {
- wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
- domain, path);
- WMReleasePropList(shared_dict);
- shared_dict = NULL;
- } else {
- if (db->dictionary && WMIsPLDictionary(shared_dict) &&
- WMIsPLDictionary(db->dictionary)) {
- WMMergePLDictionaries(shared_dict, db->dictionary, True);
- WMReleasePropList(db->dictionary);
- db->dictionary = shared_dict;
- if (stbuf.st_mtime > db->timestamp)
- db->timestamp = stbuf.st_mtime;
- } else if (!db->dictionary) {
- db->dictionary = shared_dict;
- if (stbuf.st_mtime > db->timestamp)
- db->timestamp = stbuf.st_mtime;
- }
- }
- } else {
- wwarning(_("could not load domain %s from global defaults database (%s)"), domain, path);
- }
+ shared_dict = readGlobalDomain(domain, requireDictionary);
+
+ if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
+ WMIsPLDictionary(db->dictionary)) {
+ WMMergePLDictionaries(shared_dict, db->dictionary, True);
+ WMReleasePropList(db->dictionary);
+ db->dictionary = shared_dict;
+ if (stbuf.st_mtime > db->timestamp)
+ db->timestamp = stbuf.st_mtime;
+ } else if (!db->dictionary) {
+ db->dictionary = shared_dict;
+ if (stbuf.st_mtime > db->timestamp)
+ db->timestamp = stbuf.st_mtime;
}
return db;
--
1.7.10