mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 05:48:01 +01:00
Remove code duplication by calling readGlobalDomain()
The code in defaults.c to get the shared database is included in the same file (function readGlobalDomain).
This commit is contained in:
committed by
Carlos R. Mafra
parent
f8291de919
commit
1a594de74e
@@ -803,7 +803,6 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
|
|||||||
WDDomain *db;
|
WDDomain *db;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
char path[PATH_MAX];
|
|
||||||
char *the_path;
|
char *the_path;
|
||||||
WMPropList *shared_dict = NULL;
|
WMPropList *shared_dict = NULL;
|
||||||
|
|
||||||
@@ -832,32 +831,19 @@ WDDomain *wDefaultsInitDomain(char *domain, Bool requireDictionary)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* global system dictionary */
|
/* global system dictionary */
|
||||||
snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domain);
|
shared_dict = readGlobalDomain(domain, requireDictionary);
|
||||||
if (stat(path, &stbuf) >= 0) {
|
|
||||||
shared_dict = WMReadPropListFromFile(path);
|
if (shared_dict && db->dictionary && WMIsPLDictionary(shared_dict) &&
|
||||||
if (shared_dict) {
|
WMIsPLDictionary(db->dictionary)) {
|
||||||
if (requireDictionary && !WMIsPLDictionary(shared_dict)) {
|
WMMergePLDictionaries(shared_dict, db->dictionary, True);
|
||||||
wwarning(_("Domain %s (%s) of global defaults database is corrupted!"),
|
WMReleasePropList(db->dictionary);
|
||||||
domain, path);
|
db->dictionary = shared_dict;
|
||||||
WMReleasePropList(shared_dict);
|
if (stbuf.st_mtime > db->timestamp)
|
||||||
shared_dict = NULL;
|
db->timestamp = stbuf.st_mtime;
|
||||||
} else {
|
} else if (!db->dictionary) {
|
||||||
if (db->dictionary && WMIsPLDictionary(shared_dict) &&
|
db->dictionary = shared_dict;
|
||||||
WMIsPLDictionary(db->dictionary)) {
|
if (stbuf.st_mtime > db->timestamp)
|
||||||
WMMergePLDictionaries(shared_dict, db->dictionary, True);
|
db->timestamp = stbuf.st_mtime;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
|
|||||||
Reference in New Issue
Block a user