From 5b2a6e57b74683e764685d7f9be304a3c4b1b8da Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sat, 25 Nov 2017 01:39:54 +0100 Subject: [PATCH] curly braces style Curly braces should start on a new line, after a method declaration, but should continue on the same line after a control structure. --- src/menu.c | 6 +++--- src/notification.c | 10 ++++++---- src/utils.c | 18 +++++++++--------- src/x11/screen.c | 3 ++- src/x11/x.c | 6 ++++-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/menu.c b/src/menu.c index 8750e83..b45cdb5 100644 --- a/src/menu.c +++ b/src/menu.c @@ -43,8 +43,7 @@ static int regex_init(void) void regex_teardown(void) { - if (is_initialized) - { + if (is_initialized) { regfree(&cregex); is_initialized = false; } @@ -94,7 +93,8 @@ char *extract_urls(const char *to_match) * Open url in browser. * */ -void open_browser(const char *in) { +void open_browser(const char *in) +{ // remove prefix and test url char *url = extract_urls(in); if (!url) diff --git a/src/notification.c b/src/notification.c index 60cbe0b..1c54471 100644 --- a/src/notification.c +++ b/src/notification.c @@ -248,7 +248,8 @@ void notification_replace_single_field(char **haystack, g_free(input); } -char *notification_extract_markup_urls(char **str_ptr) { +char *notification_extract_markup_urls(char **str_ptr) +{ char *start, *end, *replace_buf, *str, *urls = NULL, *url, *index_buf; int linkno = 1; @@ -342,12 +343,12 @@ void notification_init(notification *n) /* replace all formatter */ for(char *substr = strchr(n->msg, '%'); substr; - substr = strchr(substr, '%')){ + substr = strchr(substr, '%')) { char pg[16]; char *icon_tmp; - switch(substr[1]){ + switch(substr[1]) { case 'a': notification_replace_single_field( &n->msg, @@ -553,7 +554,8 @@ void notification_update_text_to_render(notification *n) * invoke it. If there are multiple and no default, open the context menu. If * there are no actions, proceed similarly with urls. */ -void notification_do_action(notification *n) { +void notification_do_action(notification *n) +{ if (n->actions) { if (n->actions->count == 2) { action_invoked(n, n->actions->actions[0]); diff --git a/src/utils.c b/src/utils.c index 5d807ee..c79d06d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -8,7 +8,8 @@ #include #include -char *string_replace_char(char needle, char replacement, char *haystack) { +char *string_replace_char(char needle, char replacement, char *haystack) +{ char *current = haystack; while ((current = strchr(current, needle)) != NULL) *current++ = replacement; @@ -109,7 +110,8 @@ void string_strip_delimited(char *str, char a, char b) str[iwrite] = 0; } -char *string_to_path(char *string) { +char *string_to_path(char *string) +{ if (string && 0 == strncmp(string, "~/", 2)) { char *home = g_strconcat(getenv("HOME"), "/", NULL); @@ -122,7 +124,8 @@ char *string_to_path(char *string) { return string; } -gint64 string_to_time(const char *string) { +gint64 string_to_time(const char *string) +{ assert(string); @@ -133,16 +136,13 @@ gint64 string_to_time(const char *string) { if (errno != 0) { fprintf(stderr, "ERROR: Time: '%s': %s.\n", string, strerror(errno)); return 0; - } - else if (string == endptr) { + } else if (string == endptr) { fprintf(stderr, "ERROR: Time: No digits found.\n"); return 0; - } - else if (errno != 0 && val == 0) { + } else if (errno != 0 && val == 0) { fprintf(stderr, "ERROR: Time: '%s' unknown error.\n", string); return 0; - } - else if (errno == 0 && !*endptr) { + } else if (errno == 0 && !*endptr) { return val * G_USEC_PER_SEC; } diff --git a/src/x11/screen.c b/src/x11/screen.c index 79a0bd8..bce8c54 100644 --- a/src/x11/screen.c +++ b/src/x11/screen.c @@ -64,7 +64,8 @@ static double get_xft_dpi_value() return dpi; } -void init_screens() { +void init_screens() +{ if (!settings.force_xinerama) { randr_init(); randr_update(); diff --git a/src/x11/x.c b/src/x11/x.c index 05889c7..757c216 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -188,7 +188,8 @@ static bool have_dynamic_width(void) return (xctx.geometry.mask & WidthValue && xctx.geometry.w == 0); } -static bool does_file_exist(const char *filename){ +static bool does_file_exist(const char *filename) +{ return (access(filename, F_OK) != -1); } @@ -197,7 +198,8 @@ static bool is_readable_file(const char *filename) return (access(filename, R_OK) != -1); } -const char *get_filename_ext(const char *filename) { +const char *get_filename_ext(const char *filename) +{ const char *dot = strrchr(filename, '.'); if (!dot || dot == filename) return ""; return dot + 1;