From bd8fd8b1d25f796b84b62563019d2b85db99a761 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sat, 25 Nov 2017 01:38:28 +0100 Subject: [PATCH] Improve whitespace handling --- src/dbus.c | 24 ++++++++++++------------ src/notification.c | 1 - src/option_parser.c | 7 +------ src/settings.c | 2 +- src/utils.c | 4 ++-- src/x11/screen.c | 4 +--- src/x11/x.c | 23 +++++++++-------------- src/x11/x.h | 2 +- 8 files changed, 27 insertions(+), 40 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index 66f168d..7cba98d 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -114,7 +114,7 @@ static void on_get_capabilities(GDBusConnection *connection, g_variant_builder_add(builder, "s", "body"); g_variant_builder_add(builder, "s", "body-hyperlinks"); - if(settings.markup != MARKUP_NO) + if (settings.markup != MARKUP_NO) g_variant_builder_add(builder, "s", "body-markup"); value = g_variant_new("(as)", builder); @@ -421,15 +421,15 @@ static RawImage *get_raw_image_from_data_hint(GVariant *icon_data) GVariant *data_variant; gsize expected_len; - g_variant_get (icon_data, - "(iiibii@ay)", - &image->width, - &image->height, - &image->rowstride, - &image->has_alpha, - &image->bits_per_sample, - &image->n_channels, - &data_variant); + g_variant_get(icon_data, + "(iiibii@ay)", + &image->width, + &image->height, + &image->rowstride, + &image->has_alpha, + &image->bits_per_sample, + &image->n_channels, + &data_variant); expected_len = (image->height - 1) * image->rowstride + image->width * ((image->n_channels * image->bits_per_sample + 7) / 8); @@ -444,8 +444,8 @@ static RawImage *get_raw_image_from_data_hint(GVariant *icon_data) return NULL; } - image->data = (guchar *) g_memdup (g_variant_get_data (data_variant), - g_variant_get_size (data_variant)); + image->data = (guchar *) g_memdup(g_variant_get_data(data_variant), + g_variant_get_size(data_variant)); g_variant_unref(data_variant); return image; diff --git a/src/notification.c b/src/notification.c index b5a880b..60cbe0b 100644 --- a/src/notification.c +++ b/src/notification.c @@ -23,7 +23,6 @@ #include "utils.h" #include "x11/x.h" - /* * print a human readable representation * of the given notification to stdout. diff --git a/src/option_parser.c b/src/option_parser.c index a8d522f..7641ccb 100644 --- a/src/option_parser.c +++ b/src/option_parser.c @@ -41,7 +41,7 @@ static int cmdline_find_option(const char *key); section_t *new_section(const char *name) { for (int i = 0; i < section_count; i++) { - if(!strcmp(name, sections[i].name)) { + if (!strcmp(name, sections[i].name)) { die("Duplicated section in dunstrc detected.\n", -1); } } @@ -215,7 +215,6 @@ char *clean_value(const char *value) s[strlen(s) - 1] = '\0'; return s; - } int load_ini_file(FILE *fp) @@ -443,13 +442,11 @@ char *option_get_path(const char *ini_section, val = cmdline_get_path(cmdline_key, NULL, description); } - if (val) { return val; } else { return ini_get_path(ini_section, ini_key, def); } - } char *option_get_string(const char *ini_section, @@ -464,13 +461,11 @@ char *option_get_string(const char *ini_section, val = cmdline_get_string(cmdline_key, NULL, description); } - if (val) { return val; } else { return ini_get_string(ini_section, ini_key, def); } - } gint64 option_get_time(const char *ini_section, diff --git a/src/settings.c b/src/settings.c index 0d4a569..fe6aff4 100644 --- a/src/settings.c +++ b/src/settings.c @@ -139,7 +139,7 @@ void load_settings(char *cmdline_config_path) //Use markup if set //Use default if settings.markup not set yet // (=>c empty&&!allow_markup) - if(c){ + if (c) { settings.markup = parse_markup_mode(c); } else if (!settings.markup) { settings.markup = defaults.markup; diff --git a/src/utils.c b/src/utils.c index 015e593..5d807ee 100644 --- a/src/utils.c +++ b/src/utils.c @@ -10,7 +10,7 @@ char *string_replace_char(char needle, char replacement, char *haystack) { char *current = haystack; - while ((current = strchr (current, needle)) != NULL) + while ((current = strchr(current, needle)) != NULL) *current++ = replacement; return haystack; } @@ -34,7 +34,7 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl) memcpy(tmp + pos, repl, repl_len); memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1); - if(tmp != buf) { + if (tmp != buf) { g_free(buf); } diff --git a/src/x11/screen.c b/src/x11/screen.c index ee1f35b..79a0bd8 100644 --- a/src/x11/screen.c +++ b/src/x11/screen.c @@ -164,7 +164,6 @@ void xinerama_update() XFree(info); } - void screen_update_fallback() { alloc_screen_ar(1); @@ -177,7 +176,6 @@ void screen_update_fallback() screens[0].dim.w = DisplayWidth(xctx.dpy, screen); screens[0].dim.h = DisplayHeight(xctx.dpy, screen); - } /* @@ -297,7 +295,7 @@ static Window get_focused_window(void) &bytes_after, &prop_return); if (prop_return) { - focused = *(Window *) prop_return; + focused = *(Window *)prop_return; XFree(prop_return); } diff --git a/src/x11/x.c b/src/x11/x.c index cb8e171..05889c7 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -111,14 +111,13 @@ static color_t calculate_foreground_color(color_t bg) int signedness = darken ? -1 : 1; - color.r = _apply_delta(color.r, c_delta *signedness); - color.g = _apply_delta(color.g, c_delta *signedness); - color.b = _apply_delta(color.b, c_delta *signedness); + color.r = _apply_delta(color.r, c_delta * signedness); + color.g = _apply_delta(color.g, c_delta * signedness); + color.b = _apply_delta(color.b, c_delta * signedness); return color; } - static color_t x_get_separator_color(colored_layout *cl, colored_layout *cl_next) { switch (settings.sep_color) { @@ -200,7 +199,7 @@ static bool is_readable_file(const char *filename) const char *get_filename_ext(const char *filename) { const char *dot = strrchr(filename, '.'); - if(!dot || dot == filename) return ""; + if (!dot || dot == filename) return ""; return dot + 1; } @@ -630,7 +629,7 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou if (use_padding) dim.y += h + settings.padding; else - dim.y += (int) (floor(bg_half_height) + pango_offset); + dim.y += (int)(floor(bg_half_height) + pango_offset); if (settings.separator_height > 0 && !last) { color_t sep_color = x_get_separator_color(cl, cl_next); @@ -648,7 +647,7 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou } cairo_move_to(c, settings.h_padding, dim.y); - if (cl->icon) { + if (cl->icon) { unsigned int image_width = cairo_image_surface_get_width(cl->icon), image_height = cairo_image_surface_get_height(cl->icon), image_x, @@ -660,9 +659,9 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, colored_layou image_x = bg_width - settings.h_padding - image_width + settings.frame_width; } - cairo_set_source_surface (c, cl->icon, image_x, image_y); - cairo_rectangle (c, image_x, image_y, image_width, image_height); - cairo_fill (c); + cairo_set_source_surface(c, cl->icon, image_x, image_y); + cairo_rectangle(c, image_x, image_y, image_width, image_height); + cairo_fill(c); } return dim; @@ -703,7 +702,6 @@ void x_win_draw(void) cairo_destroy(c); cairo_surface_destroy(image_surface); r_free_layouts(layouts); - } static void x_win_move(int width, int height) @@ -732,7 +730,6 @@ static void x_win_move(int width, int height) XResizeWindow(xctx.dpy, xctx.win, width, height); } - xctx.window_dim.x = x; xctx.window_dim.y = y; xctx.window_dim.h = height; @@ -1036,7 +1033,6 @@ void x_setup(void) x_win_setup(); x_cairo_setup(); x_shortcut_grab(&settings.history_ks); - } static void x_set_wm(Window win) @@ -1210,7 +1206,6 @@ KeySym x_shortcut_string_to_mask(const char *str) fprintf(stderr, "Warning: Unknown Modifier: %s\n", str); return 0; } - } /* diff --git a/src/x11/x.h b/src/x11/x.h index bbc567f..1ccd9a3 100644 --- a/src/x11/x.h +++ b/src/x11/x.h @@ -10,7 +10,7 @@ #include "screen.h" -#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) +#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define FONT_HEIGHT_BORDER 2 #define DEFFONT "Monospace-11"