diff --git a/config.mk b/config.mk index 78c340f..e06c15c 100644 --- a/config.mk +++ b/config.mk @@ -25,7 +25,7 @@ ifeq (${PKG_CONFIG}, ${EMPTY}) $(error "Failed to find pkg-config, please make sure it is installed) endif -pkg_config_packs:="dbus-1 libxdg-basedir x11 freetype2 xext xft xscrnsaver" +pkg_config_packs:="dbus-1 libxdg-basedir x11 freetype2 xext xft xscrnsaver glib-2.0" # includes and libs INCS := $(shell ${PKG_CONFIG} --cflags ${pkg_config_packs}) diff --git a/dunst.c b/dunst.c index 805f905..72cc685 100644 --- a/dunst.c +++ b/dunst.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -38,8 +39,6 @@ #define INRECT(x,y,rx,ry,rw,rh) ((x) >= (rx) && (x) < (rx)+(rw) && (y) >= (ry) && (y) < (ry)+(rh)) #define LENGTH(X) (sizeof X / sizeof X[0]) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define FONT_HEIGHT_BORDER 2 @@ -522,7 +521,7 @@ void r_line_cache_reset(r_line_cache *c) int do_word_wrap(char *source, int max_width) { - rstrip(source); + g_strstrip(source); if (!source || strlen(source) == 0) return 0; @@ -562,10 +561,7 @@ int do_word_wrap(char *source, int max_width) void add_notification_to_line_cache(notification *n, int max_width) { - rstrip(n->msg); - char *msg = n->msg; - while (isspace(*msg)) - msg++; + char *msg = g_strstrip(n->msg); char *buf; @@ -1086,7 +1082,7 @@ int init_notification(notification * n, int id) while (strstr(n->msg, "\n") != NULL) n->msg = string_replace("\n", " ", n->msg); - n->msg = rstrip(n->msg); + n->msg = g_strstrip(n->msg); n->dup_count = 0; @@ -1253,10 +1249,10 @@ void init_shortcut(keyboard_shortcut * ks) str++; *str = '\0'; str++; - rstrip(mod); + g_strchomp(mod); ks->mask = ks->mask | string_to_mask(mod); } - rstrip(str); + g_strstrip(str); ks->sym = XStringToKeysym(str); /* find matching keycode for ks->sym */ diff --git a/options.c b/options.c index 3cd4f79..3f88346 100644 --- a/options.c +++ b/options.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "options.h" #include "utils.h" @@ -200,7 +201,7 @@ int load_ini_file(FILE * fp) while (fgets(line, sizeof(line), fp) != NULL) { line_num++; - char *start = lskip(rstrip(line)); + char *start = g_strstrip(line); if (*start == ';' || *start == '#' || strlen(start) == 0) continue; @@ -233,8 +234,8 @@ int load_ini_file(FILE * fp) } *equal = '\0'; - char *key = rstrip(start); - char *value = lskip(equal + 1); + char *key = g_strstrip(start); + char *value = g_strstrip(equal + 1); char *quote = strstr(value, "\""); if (quote) { @@ -255,7 +256,7 @@ int load_ini_file(FILE * fp) if (comment) comment = '\0'; } - value = rstrip(value); + value = g_strstrip(value); if (!current_section) { printf("Warning: invalid config file at line: %d\n", diff --git a/utils.c b/utils.c index 910328d..89cd333 100644 --- a/utils.c +++ b/utils.c @@ -8,23 +8,6 @@ #include "utils.h" #include "dunst.h" -char *rstrip(char *str) -{ - char *end; - end = str + strlen(str) - 1; - while (isspace(*end)) { - *end = '\0'; - end--; - } - return str; -} - -char *lskip(char *s) -{ - for (; *s && isspace(*s); s++) ; - return s; -} - char *string_replace_all(const char *needle, const char *replacement, char *haystack) { diff --git a/utils.h b/utils.h index 9b99353..39894ee 100644 --- a/utils.h +++ b/utils.h @@ -1,9 +1,5 @@ #ifndef UTIL_H #define UTIL_H -/* remove spaces before and after str */ -char *rstrip(char *str); -char *lskip(char *str); - /* replace all occurrences of needle with replacement in haystack */ char *string_replace_all(const char *needle, const char *replacement, char *haystack);