mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Bug fix: Compilation failure with NO_LIBCONFIG / NO_C2
- Fix compilation failure with NO_LIBCONFIG or NO_C2. Thanks to Spaulding for reporting.
This commit is contained in:
parent
48fb54dfae
commit
90099d371d
2 changed files with 86 additions and 86 deletions
168
src/compton.c
168
src/compton.c
|
@ -4389,90 +4389,6 @@ fork_after(session_t *ps) {
|
|||
return success;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIBCONFIG
|
||||
/**
|
||||
* Get a file stream of the configuration file to read.
|
||||
*
|
||||
* Follows the XDG specification to search for the configuration file.
|
||||
*/
|
||||
static FILE *
|
||||
open_config_file(char *cpath, char **ppath) {
|
||||
const static char *config_filename = "/compton.conf";
|
||||
const static char *config_filename_legacy = "/.compton.conf";
|
||||
const static char *config_home_suffix = "/.config";
|
||||
const static char *config_system_dir = "/etc/xdg";
|
||||
|
||||
char *dir = NULL, *home = NULL;
|
||||
char *path = cpath;
|
||||
FILE *f = NULL;
|
||||
|
||||
if (path) {
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
return f;
|
||||
}
|
||||
|
||||
// Check user configuration file in $XDG_CONFIG_HOME firstly
|
||||
if (!((dir = getenv("XDG_CONFIG_HOME")) && strlen(dir))) {
|
||||
if (!((home = getenv("HOME")) && strlen(home)))
|
||||
return NULL;
|
||||
|
||||
path = mstrjoin3(home, config_home_suffix, config_filename);
|
||||
}
|
||||
else
|
||||
path = mstrjoin(dir, config_filename);
|
||||
|
||||
f = fopen(path, "r");
|
||||
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
|
||||
// Then check user configuration file in $HOME
|
||||
if ((home = getenv("HOME")) && strlen(home)) {
|
||||
path = mstrjoin(home, config_filename_legacy);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
}
|
||||
|
||||
// Check system configuration file in $XDG_CONFIG_DIRS at last
|
||||
if ((dir = getenv("XDG_CONFIG_DIRS")) && strlen(dir)) {
|
||||
char *part = strtok(dir, ":");
|
||||
while (part) {
|
||||
path = mstrjoin(part, config_filename);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
part = strtok(NULL, ":");
|
||||
}
|
||||
}
|
||||
else {
|
||||
path = mstrjoin(config_system_dir, config_filename);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a floating-point number in matrix.
|
||||
*/
|
||||
|
@ -4601,6 +4517,90 @@ parse_conv_kern(session_t *ps, const char *src) {
|
|||
return parse_matrix(ps, src);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LIBCONFIG
|
||||
/**
|
||||
* Get a file stream of the configuration file to read.
|
||||
*
|
||||
* Follows the XDG specification to search for the configuration file.
|
||||
*/
|
||||
static FILE *
|
||||
open_config_file(char *cpath, char **ppath) {
|
||||
const static char *config_filename = "/compton.conf";
|
||||
const static char *config_filename_legacy = "/.compton.conf";
|
||||
const static char *config_home_suffix = "/.config";
|
||||
const static char *config_system_dir = "/etc/xdg";
|
||||
|
||||
char *dir = NULL, *home = NULL;
|
||||
char *path = cpath;
|
||||
FILE *f = NULL;
|
||||
|
||||
if (path) {
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
return f;
|
||||
}
|
||||
|
||||
// Check user configuration file in $XDG_CONFIG_HOME firstly
|
||||
if (!((dir = getenv("XDG_CONFIG_HOME")) && strlen(dir))) {
|
||||
if (!((home = getenv("HOME")) && strlen(home)))
|
||||
return NULL;
|
||||
|
||||
path = mstrjoin3(home, config_home_suffix, config_filename);
|
||||
}
|
||||
else
|
||||
path = mstrjoin(dir, config_filename);
|
||||
|
||||
f = fopen(path, "r");
|
||||
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
|
||||
// Then check user configuration file in $HOME
|
||||
if ((home = getenv("HOME")) && strlen(home)) {
|
||||
path = mstrjoin(home, config_filename_legacy);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
}
|
||||
|
||||
// Check system configuration file in $XDG_CONFIG_DIRS at last
|
||||
if ((dir = getenv("XDG_CONFIG_DIRS")) && strlen(dir)) {
|
||||
char *part = strtok(dir, ":");
|
||||
while (part) {
|
||||
path = mstrjoin(part, config_filename);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
part = strtok(NULL, ":");
|
||||
}
|
||||
}
|
||||
else {
|
||||
path = mstrjoin(config_system_dir, config_filename);
|
||||
f = fopen(path, "r");
|
||||
if (f && ppath)
|
||||
*ppath = path;
|
||||
else
|
||||
free(path);
|
||||
if (f)
|
||||
return f;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a condition list in configuration file.
|
||||
*/
|
||||
|
|
|
@ -146,16 +146,16 @@ free_damage(session_t *ps, Damage *p) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_C2
|
||||
/**
|
||||
* Destroy a condition list.
|
||||
*/
|
||||
static inline void
|
||||
free_wincondlst(c2_lptr_t **pcondlst) {
|
||||
#ifdef CONFIG_C2
|
||||
while ((*pcondlst = c2_free_lptr(*pcondlst)))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a paint_t contains enough data.
|
||||
|
|
Loading…
Reference in a new issue