Bug fix: #48: Compilation failure with old libconfig/libpcre
- Fix compilation failure with <libpcre-8.20 and <libconfig-1.4. Tested with libpcre-8.12 and libconfig-1.3.2, but not extensively tested. libconfig-1.3* probably has more limitations on configuration file syntax (enforces comma at the end of a setting?) and does not support @include. - Make it possible to turn off PCRE and libconfig support using environment variable "CFG". Not well tested. CMake might provide a better solution.
This commit is contained in:
parent
69513d6231
commit
9139d038c2
6
Makefile
6
Makefile
|
@ -12,6 +12,12 @@ INCS += $(shell pcre-config --cflags)
|
||||||
CFLAGS += -Wall -std=c99
|
CFLAGS += -Wall -std=c99
|
||||||
OBJS = compton.o
|
OBJS = compton.o
|
||||||
|
|
||||||
|
CFG ?= -DCONFIG_LIBCONFIG -DCONFIG_REGEX_PCRE -DCONFIG_REGEX_PCRE_JIT
|
||||||
|
# libconfig-1.3* does not define LIBCONFIG_VER* macros, so we use pkg-config
|
||||||
|
# to determine its version here
|
||||||
|
CFG += $(shell pkg-config --atleast-version=1.4 libconfig || echo '-DCONFIG_LIBCONFIG_LEGACY')
|
||||||
|
CFLAGS += $(CFG)
|
||||||
|
|
||||||
%.o: src/%.c src/%.h
|
%.o: src/%.c src/%.h
|
||||||
$(CC) $(CFLAGS) $(INCS) -c src/$*.c
|
$(CC) $(CFLAGS) $(INCS) -c src/$*.c
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@ shadow = true;
|
||||||
no-dnd-shadow = true;
|
no-dnd-shadow = true;
|
||||||
no-dock-shadow = true;
|
no-dock-shadow = true;
|
||||||
clear-shadow = true;
|
clear-shadow = true;
|
||||||
shadow-radius = 7
|
shadow-radius = 7;
|
||||||
shadow-offset-x = -7
|
shadow-offset-x = -7;
|
||||||
shadow-offset-y = -7
|
shadow-offset-y = -7;
|
||||||
# shadow-opacity = 0.7
|
# shadow-opacity = 0.7;
|
||||||
# shadow-red = 0.0
|
# shadow-red = 0.0;
|
||||||
# shadow-green = 0.0
|
# shadow-green = 0.0;
|
||||||
# shadow-blue = 0.0
|
# shadow-blue = 0.0;
|
||||||
shadow-exclude = [ "n:e:Notification" ];
|
shadow-exclude = [ "n:e:Notification" ];
|
||||||
# shadow-exclude = "n:e:Notification";
|
# shadow-exclude = "n:e:Notification";
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ inactive-opacity-override = true;
|
||||||
|
|
||||||
# Fading
|
# Fading
|
||||||
fading = true;
|
fading = true;
|
||||||
# fade-delta = 30
|
# fade-delta = 30;
|
||||||
fade-in-step = 0.03
|
fade-in-step = 0.03;
|
||||||
fade-out-step = 0.03
|
fade-out-step = 0.03;
|
||||||
# no-fading-openclose = true;
|
# no-fading-openclose = true;
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
@ -34,4 +34,4 @@ mark-ovredir-focused = true;
|
||||||
wintypes:
|
wintypes:
|
||||||
{
|
{
|
||||||
tooltip = { fade = true; shadow = false; opacity = 0.75; };
|
tooltip = { fade = true; shadow = false; opacity = 0.75; };
|
||||||
}
|
};
|
||||||
|
|
|
@ -3071,7 +3071,7 @@ open_config_file(char *cpath, char **ppath) {
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
parse_config(char *cpath, struct options_tmp *pcfgtmp) {
|
parse_config(char *cpath, struct options_tmp *pcfgtmp) {
|
||||||
char *path = NULL, *parent = NULL;
|
char *path = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
config_t cfg;
|
config_t cfg;
|
||||||
int ival = 0;
|
int ival = 0;
|
||||||
|
@ -3085,9 +3085,11 @@ parse_config(char *cpath, struct options_tmp *pcfgtmp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
config_init(&cfg);
|
config_init(&cfg);
|
||||||
parent = dirname(path);
|
#ifndef CONFIG_LIBCONFIG_LEGACY
|
||||||
|
char *parent = dirname(path);
|
||||||
if (parent)
|
if (parent)
|
||||||
config_set_include_dir(&cfg, parent);
|
config_set_include_dir(&cfg, parent);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (CONFIG_FALSE == config_read(&cfg, f)) {
|
if (CONFIG_FALSE == config_read(&cfg, f)) {
|
||||||
printf("Error when reading configuration file \"%s\", line %d: %s\n",
|
printf("Error when reading configuration file \"%s\", line %d: %s\n",
|
||||||
|
@ -3104,7 +3106,7 @@ parse_config(char *cpath, struct options_tmp *pcfgtmp) {
|
||||||
// right now. It will be done later
|
// right now. It will be done later
|
||||||
|
|
||||||
// -D (fade_delta)
|
// -D (fade_delta)
|
||||||
if (config_lookup_int(&cfg, "fade-delta", &ival))
|
if (lcfg_lookup_int(&cfg, "fade-delta", &ival))
|
||||||
opts.fade_delta = ival;
|
opts.fade_delta = ival;
|
||||||
// -I (fade_in_step)
|
// -I (fade_in_step)
|
||||||
if (config_lookup_float(&cfg, "fade-in-step", &dval))
|
if (config_lookup_float(&cfg, "fade-in-step", &dval))
|
||||||
|
@ -3113,13 +3115,13 @@ parse_config(char *cpath, struct options_tmp *pcfgtmp) {
|
||||||
if (config_lookup_float(&cfg, "fade-out-step", &dval))
|
if (config_lookup_float(&cfg, "fade-out-step", &dval))
|
||||||
opts.fade_out_step = normalize_d(dval) * OPAQUE;
|
opts.fade_out_step = normalize_d(dval) * OPAQUE;
|
||||||
// -r (shadow_radius)
|
// -r (shadow_radius)
|
||||||
config_lookup_int(&cfg, "shadow-radius", &opts.shadow_radius);
|
lcfg_lookup_int(&cfg, "shadow-radius", &opts.shadow_radius);
|
||||||
// -o (shadow_opacity)
|
// -o (shadow_opacity)
|
||||||
config_lookup_float(&cfg, "shadow-opacity", &opts.shadow_opacity);
|
config_lookup_float(&cfg, "shadow-opacity", &opts.shadow_opacity);
|
||||||
// -l (shadow_offset_x)
|
// -l (shadow_offset_x)
|
||||||
config_lookup_int(&cfg, "shadow-offset-x", &opts.shadow_offset_x);
|
lcfg_lookup_int(&cfg, "shadow-offset-x", &opts.shadow_offset_x);
|
||||||
// -t (shadow_offset_y)
|
// -t (shadow_offset_y)
|
||||||
config_lookup_int(&cfg, "shadow-offset-y", &opts.shadow_offset_y);
|
lcfg_lookup_int(&cfg, "shadow-offset-y", &opts.shadow_offset_y);
|
||||||
// -i (inactive_opacity)
|
// -i (inactive_opacity)
|
||||||
if (config_lookup_float(&cfg, "inactive-opacity", &dval))
|
if (config_lookup_float(&cfg, "inactive-opacity", &dval))
|
||||||
opts.inactive_opacity = normalize_d(dval) * OPAQUE;
|
opts.inactive_opacity = normalize_d(dval) * OPAQUE;
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
// Whether to enable PCRE regular expression support in blacklists, enabled
|
// Whether to enable PCRE regular expression support in blacklists, enabled
|
||||||
// by default
|
// by default
|
||||||
#define CONFIG_REGEX_PCRE 1
|
// #define CONFIG_REGEX_PCRE 1
|
||||||
// Whether to enable JIT support of libpcre. This may cause problems on PaX
|
// Whether to enable JIT support of libpcre. This may cause problems on PaX
|
||||||
// kernels.
|
// kernels.
|
||||||
#define CONFIG_REGEX_PCRE_JIT 1
|
// #define CONFIG_REGEX_PCRE_JIT 1
|
||||||
// Whether to enable parsing of configuration files using libconfig
|
// Whether to enable parsing of configuration files using libconfig
|
||||||
#define CONFIG_LIBCONFIG 1
|
// #define CONFIG_LIBCONFIG 1
|
||||||
|
|
||||||
// === Includes ===
|
// === Includes ===
|
||||||
|
|
||||||
|
@ -49,6 +49,12 @@
|
||||||
|
|
||||||
#ifdef CONFIG_REGEX_PCRE
|
#ifdef CONFIG_REGEX_PCRE
|
||||||
#include <pcre.h>
|
#include <pcre.h>
|
||||||
|
|
||||||
|
// For compatiblity with <libpcre-8.20
|
||||||
|
#ifndef PCRE_STUDY_JIT_COMPILE
|
||||||
|
#define PCRE_STUDY_JIT_COMPILE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LIBCONFIG
|
#ifdef CONFIG_LIBCONFIG
|
||||||
|
@ -923,7 +929,7 @@ static void
|
||||||
fork_after(void);
|
fork_after(void);
|
||||||
|
|
||||||
#ifdef CONFIG_LIBCONFIG
|
#ifdef CONFIG_LIBCONFIG
|
||||||
static void
|
static inline void
|
||||||
lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
|
lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
|
||||||
int ival;
|
int ival;
|
||||||
|
|
||||||
|
@ -931,6 +937,21 @@ lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
|
||||||
*value = ival;
|
*value = ival;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
lcfg_lookup_int(const config_t *config, const char *path, int *value) {
|
||||||
|
#ifndef CONFIG_LIBCONFIG_LEGACY
|
||||||
|
return config_lookup_int(config, path, value);
|
||||||
|
#else
|
||||||
|
long lval;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((ret = config_lookup_int(config, path, &lval)))
|
||||||
|
*value = lval;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static FILE *
|
static FILE *
|
||||||
open_config_file(char *cpath, char **path);
|
open_config_file(char *cpath, char **path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue