Move all strcmp operations to STR*EQ macros
This commit is contained in:
		
							parent
							
								
									bb02897bc8
								
							
						
					
					
						commit
						c0e2a2a7e3
					
				| @ -92,13 +92,13 @@ void handle_method_call(GDBusConnection *connection, | |||||||
|                         GDBusMethodInvocation *invocation, |                         GDBusMethodInvocation *invocation, | ||||||
|                         gpointer user_data) |                         gpointer user_data) | ||||||
| { | { | ||||||
|         if (g_strcmp0(method_name, "GetCapabilities") == 0) { |         if (STR_EQ(method_name, "GetCapabilities")) { | ||||||
|                 on_get_capabilities(connection, sender, parameters, invocation); |                 on_get_capabilities(connection, sender, parameters, invocation); | ||||||
|         } else if (g_strcmp0(method_name, "Notify") == 0) { |         } else if (STR_EQ(method_name, "Notify")) { | ||||||
|                 on_notify(connection, sender, parameters, invocation); |                 on_notify(connection, sender, parameters, invocation); | ||||||
|         } else if (g_strcmp0(method_name, "CloseNotification") == 0) { |         } else if (STR_EQ(method_name, "CloseNotification")) { | ||||||
|                 on_close_notification(connection, sender, parameters, invocation); |                 on_close_notification(connection, sender, parameters, invocation); | ||||||
|         } else if (g_strcmp0(method_name, "GetServerInformation") == 0) { |         } else if (STR_EQ(method_name, "GetServerInformation")) { | ||||||
|                 on_get_server_information(connection, sender, parameters, invocation); |                 on_get_server_information(connection, sender, parameters, invocation); | ||||||
|         } else { |         } else { | ||||||
|                 LOG_M("Unknown method name: '%s' (sender: '%s').", |                 LOG_M("Unknown method name: '%s' (sender: '%s').", | ||||||
|  | |||||||
							
								
								
									
										18
									
								
								src/log.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/log.c
									
									
									
									
									
								
							| @ -32,23 +32,23 @@ void log_set_level_from_string(const char *level) | |||||||
|         if (!level) |         if (!level) | ||||||
|                 return; |                 return; | ||||||
| 
 | 
 | ||||||
|         if (g_ascii_strcasecmp(level, "critical") == 0) |         if (STR_CASEQ(level, "critical")) | ||||||
|                 log_level = G_LOG_LEVEL_CRITICAL; |                 log_level = G_LOG_LEVEL_CRITICAL; | ||||||
|         else if (g_ascii_strcasecmp(level, "crit") == 0) |         else if (STR_CASEQ(level, "crit")) | ||||||
|                 log_level = G_LOG_LEVEL_CRITICAL; |                 log_level = G_LOG_LEVEL_CRITICAL; | ||||||
|         else if (g_ascii_strcasecmp(level, "warning") == 0) |         else if (STR_CASEQ(level, "warning")) | ||||||
|                 log_level = G_LOG_LEVEL_WARNING; |                 log_level = G_LOG_LEVEL_WARNING; | ||||||
|         else if (g_ascii_strcasecmp(level, "warn") == 0) |         else if (STR_CASEQ(level, "warn")) | ||||||
|                 log_level = G_LOG_LEVEL_WARNING; |                 log_level = G_LOG_LEVEL_WARNING; | ||||||
|         else if (g_ascii_strcasecmp(level, "message") == 0) |         else if (STR_CASEQ(level, "message")) | ||||||
|                 log_level = G_LOG_LEVEL_MESSAGE; |                 log_level = G_LOG_LEVEL_MESSAGE; | ||||||
|         else if (g_ascii_strcasecmp(level, "mesg") == 0) |         else if (STR_CASEQ(level, "mesg")) | ||||||
|                 log_level = G_LOG_LEVEL_MESSAGE; |                 log_level = G_LOG_LEVEL_MESSAGE; | ||||||
|         else if (g_ascii_strcasecmp(level, "info") == 0) |         else if (STR_CASEQ(level, "info")) | ||||||
|                 log_level = G_LOG_LEVEL_INFO; |                 log_level = G_LOG_LEVEL_INFO; | ||||||
|         else if (g_ascii_strcasecmp(level, "debug") == 0) |         else if (STR_CASEQ(level, "debug")) | ||||||
|                 log_level = G_LOG_LEVEL_DEBUG; |                 log_level = G_LOG_LEVEL_DEBUG; | ||||||
|         else if (g_ascii_strcasecmp(level, "deb") == 0) |         else if (STR_CASEQ(level, "deb")) | ||||||
|                 log_level = G_LOG_LEVEL_DEBUG; |                 log_level = G_LOG_LEVEL_DEBUG; | ||||||
|         else |         else | ||||||
|                 LOG_W("Unknown log level: '%s'", level); |                 LOG_W("Unknown log level: '%s'", level); | ||||||
|  | |||||||
| @ -178,10 +178,10 @@ int notification_is_duplicate(const struct notification *a, const struct notific | |||||||
|                 && (a->raw_icon || b->raw_icon)) |                 && (a->raw_icon || b->raw_icon)) | ||||||
|                 return false; |                 return false; | ||||||
| 
 | 
 | ||||||
|         return strcmp(a->appname, b->appname) == 0 |         return STR_EQ(a->appname, b->appname) | ||||||
|             && strcmp(a->summary, b->summary) == 0 |             && STR_EQ(a->summary, b->summary) | ||||||
|             && strcmp(a->body,    b->body) == 0 |             && STR_EQ(a->body, b->body) | ||||||
|             && (settings.icon_position != ICON_OFF ? strcmp(a->icon, b->icon) == 0 : 1) |             && (settings.icon_position != ICON_OFF ? STR_EQ(a->icon, b->icon) : 1) | ||||||
|             && a->urgency == b->urgency; |             && a->urgency == b->urgency; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -534,7 +534,7 @@ void notification_do_action(const struct notification *n) | |||||||
|                         return; |                         return; | ||||||
|                 } |                 } | ||||||
|                 for (int i = 0; i < n->actions->count; i += 2) { |                 for (int i = 0; i < n->actions->count; i += 2) { | ||||||
|                         if (strcmp(n->actions->actions[i], "default") == 0) { |                         if (STR_EQ(n->actions->actions[i], "default")) { | ||||||
|                                 signal_action_invoked(n, n->actions->actions[i]); |                                 signal_action_invoked(n, n->actions->actions[i]); | ||||||
|                                 return; |                                 return; | ||||||
|                         } |                         } | ||||||
|  | |||||||
| @ -43,7 +43,7 @@ static int cmdline_find_option(const char *key); | |||||||
| struct section *new_section(const char *name) | struct section *new_section(const char *name) | ||||||
| { | { | ||||||
|         for (int i = 0; i < section_count; i++) { |         for (int i = 0; i < section_count; i++) { | ||||||
|                 if (!strcmp(name, sections[i].name)) { |                 if (STR_EQ(name, sections[i].name)) { | ||||||
|                         DIE("Duplicated section in dunstrc detected."); |                         DIE("Duplicated section in dunstrc detected."); | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| @ -73,7 +73,7 @@ void free_ini(void) | |||||||
| struct section *get_section(const char *name) | struct section *get_section(const char *name) | ||||||
| { | { | ||||||
|         for (int i = 0; i < section_count; i++) { |         for (int i = 0; i < section_count; i++) { | ||||||
|                 if (strcmp(sections[i].name, name) == 0) |                 if (STR_EQ(sections[i].name, name)) | ||||||
|                         return §ions[i]; |                         return §ions[i]; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -101,7 +101,7 @@ const char *get_value(const char *section, const char *key) | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         for (int i = 0; i < s->entry_count; i++) { |         for (int i = 0; i < s->entry_count; i++) { | ||||||
|                 if (strcmp(s->entries[i].key, key) == 0) { |                 if (STR_EQ(s->entries[i].key, key)) { | ||||||
|                         return s->entries[i].value; |                         return s->entries[i].value; | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| @ -166,7 +166,7 @@ const char *next_section(const char *section) | |||||||
|                 return sections[0].name; |                 return sections[0].name; | ||||||
| 
 | 
 | ||||||
|         for (int i = 0; i < section_count; i++) { |         for (int i = 0; i < section_count; i++) { | ||||||
|                 if (strcmp(section, sections[i].name) == 0) { |                 if (STR_EQ(section, sections[i].name)) { | ||||||
|                         if (i + 1 >= section_count) |                         if (i + 1 >= section_count) | ||||||
|                                 return NULL; |                                 return NULL; | ||||||
|                         else |                         else | ||||||
| @ -306,7 +306,7 @@ int cmdline_find_option(const char *key) | |||||||
| 
 | 
 | ||||||
|         /* look for first key */ |         /* look for first key */ | ||||||
|         for (int i = 0; i < cmdline_argc; i++) { |         for (int i = 0; i < cmdline_argc; i++) { | ||||||
|                 if (strcmp(key1, cmdline_argv[i]) == 0) { |                 if (STR_EQ(key1, cmdline_argv[i])) { | ||||||
|                         g_free(key1); |                         g_free(key1); | ||||||
|                         return i; |                         return i; | ||||||
|                 } |                 } | ||||||
| @ -315,7 +315,7 @@ int cmdline_find_option(const char *key) | |||||||
|         /* look for second key if one was specified */ |         /* look for second key if one was specified */ | ||||||
|         if (key2) { |         if (key2) { | ||||||
|                 for (int i = 0; i < cmdline_argc; i++) { |                 for (int i = 0; i < cmdline_argc; i++) { | ||||||
|                         if (strcmp(key2, cmdline_argv[i]) == 0) { |                         if (STR_EQ(key2, cmdline_argv[i])) { | ||||||
|                                 g_free(key1); |                                 g_free(key1); | ||||||
|                                 return i; |                                 return i; | ||||||
|                         } |                         } | ||||||
| @ -554,11 +554,11 @@ enum behavior_fullscreen parse_enum_fullscreen(const char *string, enum behavior | |||||||
|         if (!string) |         if (!string) | ||||||
|                 return def; |                 return def; | ||||||
| 
 | 
 | ||||||
|         if (strcmp(string, "show") == 0) |         if (STR_EQ(string, "show")) | ||||||
|                 return FS_SHOW; |                 return FS_SHOW; | ||||||
|         else if (strcmp(string, "delay") == 0) |         else if (STR_EQ(string, "delay")) | ||||||
|                 return FS_DELAY; |                 return FS_DELAY; | ||||||
|         else if (strcmp(string, "pushback") == 0) |         else if (STR_EQ(string, "pushback")) | ||||||
|                 return FS_PUSHBACK; |                 return FS_PUSHBACK; | ||||||
|         else { |         else { | ||||||
|                 LOG_W("Unknown fullscreen value: '%s'\n", string); |                 LOG_W("Unknown fullscreen value: '%s'\n", string); | ||||||
|  | |||||||
| @ -133,15 +133,15 @@ int queues_notification_insert(struct notification *n) | |||||||
|                 return 0; |                 return 0; | ||||||
|         } |         } | ||||||
|         /* Do not insert the message if it's a command */ |         /* Do not insert the message if it's a command */ | ||||||
|         if (strcmp("DUNST_COMMAND_PAUSE", n->summary) == 0) { |         if (STR_EQ("DUNST_COMMAND_PAUSE", n->summary)) { | ||||||
|                 pause_displayed = true; |                 pause_displayed = true; | ||||||
|                 return 0; |                 return 0; | ||||||
|         } |         } | ||||||
|         if (strcmp("DUNST_COMMAND_RESUME", n->summary) == 0) { |         if (STR_EQ("DUNST_COMMAND_RESUME", n->summary)) { | ||||||
|                 pause_displayed = false; |                 pause_displayed = false; | ||||||
|                 return 0; |                 return 0; | ||||||
|         } |         } | ||||||
|         if (strcmp("DUNST_COMMAND_TOGGLE", n->summary) == 0) { |         if (STR_EQ("DUNST_COMMAND_TOGGLE", n->summary)) { | ||||||
|                 pause_displayed = !pause_displayed; |                 pause_displayed = !pause_displayed; | ||||||
|                 return 0; |                 return 0; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -32,11 +32,11 @@ static enum follow_mode parse_follow_mode(const char *mode) | |||||||
|         if (!mode) |         if (!mode) | ||||||
|                 return FOLLOW_NONE; |                 return FOLLOW_NONE; | ||||||
| 
 | 
 | ||||||
|         if (strcmp(mode, "mouse") == 0) |         if (STR_EQ(mode, "mouse")) | ||||||
|                 return FOLLOW_MOUSE; |                 return FOLLOW_MOUSE; | ||||||
|         else if (strcmp(mode, "keyboard") == 0) |         else if (STR_EQ(mode, "keyboard")) | ||||||
|                 return FOLLOW_KEYBOARD; |                 return FOLLOW_KEYBOARD; | ||||||
|         else if (strcmp(mode, "none") == 0) |         else if (STR_EQ(mode, "none")) | ||||||
|                 return FOLLOW_NONE; |                 return FOLLOW_NONE; | ||||||
|         else { |         else { | ||||||
|                 LOG_W("Unknown follow mode: '%s'", mode); |                 LOG_W("Unknown follow mode: '%s'", mode); | ||||||
| @ -46,11 +46,11 @@ static enum follow_mode parse_follow_mode(const char *mode) | |||||||
| 
 | 
 | ||||||
| static enum markup_mode parse_markup_mode(const char *mode) | static enum markup_mode parse_markup_mode(const char *mode) | ||||||
| { | { | ||||||
|         if (strcmp(mode, "strip") == 0) { |         if (STR_EQ(mode, "strip")) { | ||||||
|                 return MARKUP_STRIP; |                 return MARKUP_STRIP; | ||||||
|         } else if (strcmp(mode, "no") == 0) { |         } else if (STR_EQ(mode, "no")) { | ||||||
|                 return MARKUP_NO; |                 return MARKUP_NO; | ||||||
|         } else if (strcmp(mode, "full") == 0 || strcmp(mode, "yes") == 0) { |         } else if (STR_EQ(mode, "full") || STR_EQ(mode, "yes")) { | ||||||
|                 return MARKUP_FULL; |                 return MARKUP_FULL; | ||||||
|         } else { |         } else { | ||||||
|                 LOG_W("Unknown markup mode: '%s'", mode); |                 LOG_W("Unknown markup mode: '%s'", mode); | ||||||
| @ -60,13 +60,13 @@ static enum markup_mode parse_markup_mode(const char *mode) | |||||||
| 
 | 
 | ||||||
| static enum mouse_action parse_mouse_action(const char *action) | static enum mouse_action parse_mouse_action(const char *action) | ||||||
| { | { | ||||||
|         if (strcmp(action, "none") == 0) |         if (STR_EQ(action, "none")) | ||||||
|                 return MOUSE_NONE; |                 return MOUSE_NONE; | ||||||
|         else if (strcmp(action, "do_action") == 0) |         else if (STR_EQ(action, "do_action")) | ||||||
|                 return MOUSE_DO_ACTION; |                 return MOUSE_DO_ACTION; | ||||||
|         else if (strcmp(action, "close_current") == 0) |         else if (STR_EQ(action, "close_current")) | ||||||
|                 return MOUSE_CLOSE_CURRENT; |                 return MOUSE_CLOSE_CURRENT; | ||||||
|         else if (strcmp(action, "close_all") == 0) |         else if (STR_EQ(action, "close_all")) | ||||||
|                 return MOUSE_CLOSE_ALL; |                 return MOUSE_CLOSE_ALL; | ||||||
|         else { |         else { | ||||||
|                 LOG_W("Unknown mouse action: '%s'", action); |                 LOG_W("Unknown mouse action: '%s'", action); | ||||||
| @ -81,11 +81,11 @@ static enum urgency ini_get_urgency(const char *section, const char *key, const | |||||||
|         char *urg = ini_get_string(section, key, ""); |         char *urg = ini_get_string(section, key, ""); | ||||||
| 
 | 
 | ||||||
|         if (STR_FULL(urg)) { |         if (STR_FULL(urg)) { | ||||||
|                 if (strcmp(urg, "low") == 0) |                 if (STR_EQ(urg, "low")) | ||||||
|                         ret = URG_LOW; |                         ret = URG_LOW; | ||||||
|                 else if (strcmp(urg, "normal") == 0) |                 else if (STR_EQ(urg, "normal")) | ||||||
|                         ret = URG_NORM; |                         ret = URG_NORM; | ||||||
|                 else if (strcmp(urg, "critical") == 0) |                 else if (STR_EQ(urg, "critical")) | ||||||
|                         ret = URG_CRIT; |                         ret = URG_CRIT; | ||||||
|                 else |                 else | ||||||
|                         LOG_W("Unknown urgency: '%s'", urg); |                         LOG_W("Unknown urgency: '%s'", urg); | ||||||
| @ -124,7 +124,7 @@ void load_settings(char *cmdline_config_path) | |||||||
|         FILE *config_file = NULL; |         FILE *config_file = NULL; | ||||||
| 
 | 
 | ||||||
|         if (cmdline_config_path) { |         if (cmdline_config_path) { | ||||||
|                 if (0 == strcmp(cmdline_config_path, "-")) { |                 if (STR_EQ(cmdline_config_path, "-")) { | ||||||
|                         config_file = stdin; |                         config_file = stdin; | ||||||
|                 } else { |                 } else { | ||||||
|                         config_file = fopen(cmdline_config_path, "r"); |                         config_file = fopen(cmdline_config_path, "r"); | ||||||
| @ -249,11 +249,11 @@ void load_settings(char *cmdline_config_path) | |||||||
| 
 | 
 | ||||||
|                 if (STR_EMPTY(c)) { |                 if (STR_EMPTY(c)) { | ||||||
|                         settings.ellipsize = defaults.ellipsize; |                         settings.ellipsize = defaults.ellipsize; | ||||||
|                 } else if (strcmp(c, "start") == 0) { |                 } else if (STR_EQ(c, "start")) { | ||||||
|                         settings.ellipsize = ELLIPSE_START; |                         settings.ellipsize = ELLIPSE_START; | ||||||
|                 } else if (strcmp(c, "middle") == 0) { |                 } else if (STR_EQ(c, "middle")) { | ||||||
|                         settings.ellipsize = ELLIPSE_MIDDLE; |                         settings.ellipsize = ELLIPSE_MIDDLE; | ||||||
|                 } else if (strcmp(c, "end") == 0) { |                 } else if (STR_EQ(c, "end")) { | ||||||
|                         settings.ellipsize = ELLIPSE_END; |                         settings.ellipsize = ELLIPSE_END; | ||||||
|                 } else { |                 } else { | ||||||
|                         LOG_W("Unknown ellipsize value: '%s'", c); |                         LOG_W("Unknown ellipsize value: '%s'", c); | ||||||
| @ -347,11 +347,11 @@ void load_settings(char *cmdline_config_path) | |||||||
|                         "Text alignment left/center/right" |                         "Text alignment left/center/right" | ||||||
|                 ); |                 ); | ||||||
|                 if (STR_FULL(c)) { |                 if (STR_FULL(c)) { | ||||||
|                         if (strcmp(c, "left") == 0) |                         if (STR_EQ(c, "left")) | ||||||
|                                 settings.align = ALIGN_LEFT; |                                 settings.align = ALIGN_LEFT; | ||||||
|                         else if (strcmp(c, "center") == 0) |                         else if (STR_EQ(c, "center")) | ||||||
|                                 settings.align = ALIGN_CENTER; |                                 settings.align = ALIGN_CENTER; | ||||||
|                         else if (strcmp(c, "right") == 0) |                         else if (STR_EQ(c, "right")) | ||||||
|                                 settings.align = ALIGN_RIGHT; |                                 settings.align = ALIGN_RIGHT; | ||||||
|                         else |                         else | ||||||
|                                 LOG_W("Unknown alignment value: '%s'", c); |                                 LOG_W("Unknown alignment value: '%s'", c); | ||||||
| @ -427,11 +427,11 @@ void load_settings(char *cmdline_config_path) | |||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|                 if (STR_FULL(c)) { |                 if (STR_FULL(c)) { | ||||||
|                         if (strcmp(c, "auto") == 0) |                         if (STR_EQ(c, "auto")) | ||||||
|                                 settings.sep_color = SEP_AUTO; |                                 settings.sep_color = SEP_AUTO; | ||||||
|                         else if (strcmp(c, "foreground") == 0) |                         else if (STR_EQ(c, "foreground")) | ||||||
|                                 settings.sep_color = SEP_FOREGROUND; |                                 settings.sep_color = SEP_FOREGROUND; | ||||||
|                         else if (strcmp(c, "frame") == 0) |                         else if (STR_EQ(c, "frame")) | ||||||
|                                 settings.sep_color = SEP_FRAME; |                                 settings.sep_color = SEP_FRAME; | ||||||
|                         else { |                         else { | ||||||
|                                 settings.sep_color = SEP_CUSTOM; |                                 settings.sep_color = SEP_CUSTOM; | ||||||
| @ -484,11 +484,11 @@ void load_settings(char *cmdline_config_path) | |||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|                 if (STR_FULL(c)) { |                 if (STR_FULL(c)) { | ||||||
|                         if (strcmp(c, "left") == 0) |                         if (STR_EQ(c, "left")) | ||||||
|                                 settings.icon_position = ICON_LEFT; |                                 settings.icon_position = ICON_LEFT; | ||||||
|                         else if (strcmp(c, "right") == 0) |                         else if (STR_EQ(c, "right")) | ||||||
|                                 settings.icon_position = ICON_RIGHT; |                                 settings.icon_position = ICON_RIGHT; | ||||||
|                         else if (strcmp(c, "off") == 0) |                         else if (STR_EQ(c, "off")) | ||||||
|                                 settings.icon_position = ICON_OFF; |                                 settings.icon_position = ICON_OFF; | ||||||
|                         else |                         else | ||||||
|                                 LOG_W("Unknown icon position: '%s'", c); |                                 LOG_W("Unknown icon position: '%s'", c); | ||||||
| @ -745,13 +745,13 @@ void load_settings(char *cmdline_config_path) | |||||||
|                 cur_section = next_section(cur_section); |                 cur_section = next_section(cur_section); | ||||||
|                 if (!cur_section) |                 if (!cur_section) | ||||||
|                         break; |                         break; | ||||||
|                 if (strcmp(cur_section, "global") == 0 |                 if (STR_EQ(cur_section, "global") | ||||||
|                     || strcmp(cur_section, "frame") == 0 |                     || STR_EQ(cur_section, "frame") | ||||||
|                     || strcmp(cur_section, "experimental") == 0 |                     || STR_EQ(cur_section, "experimental") | ||||||
|                     || strcmp(cur_section, "shortcuts") == 0 |                     || STR_EQ(cur_section, "shortcuts") | ||||||
|                     || strcmp(cur_section, "urgency_low") == 0 |                     || STR_EQ(cur_section, "urgency_low") | ||||||
|                     || strcmp(cur_section, "urgency_normal") == 0 |                     || STR_EQ(cur_section, "urgency_normal") | ||||||
|                     || strcmp(cur_section, "urgency_critical") == 0) |                     || STR_EQ(cur_section, "urgency_critical")) | ||||||
|                         continue; |                         continue; | ||||||
| 
 | 
 | ||||||
|                 /* check for existing rule with same name */ |                 /* check for existing rule with same name */ | ||||||
| @ -759,7 +759,7 @@ void load_settings(char *cmdline_config_path) | |||||||
|                 for (GSList *iter = rules; iter; iter = iter->next) { |                 for (GSList *iter = rules; iter; iter = iter->next) { | ||||||
|                         struct rule *match = iter->data; |                         struct rule *match = iter->data; | ||||||
|                         if (match->name && |                         if (match->name && | ||||||
|                             strcmp(match->name, cur_section) == 0) |                             STR_EQ(match->name, cur_section)) | ||||||
|                                 r = match; |                                 r = match; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								src/utils.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/utils.c
									
									
									
									
									
								
							| @ -114,7 +114,7 @@ void string_strip_delimited(char *str, char a, char b) | |||||||
| char *string_to_path(char *string) | char *string_to_path(char *string) | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|         if (string && 0 == strncmp(string, "~/", 2)) { |         if (string && STRN_EQ(string, "~/", 2)) { | ||||||
|                 char *home = g_strconcat(getenv("HOME"), "/", NULL); |                 char *home = g_strconcat(getenv("HOME"), "/", NULL); | ||||||
| 
 | 
 | ||||||
|                 string = string_replace("~/", home, string); |                 string = string_replace("~/", home, string); | ||||||
| @ -151,15 +151,15 @@ gint64 string_to_time(const char *string) | |||||||
|         while (*endptr == ' ') |         while (*endptr == ' ') | ||||||
|                 endptr++; |                 endptr++; | ||||||
| 
 | 
 | ||||||
|         if (0 == strncmp(endptr, "ms", 2)) |         if (STRN_EQ(endptr, "ms", 2)) | ||||||
|                 return val * 1000; |                 return val * 1000; | ||||||
|         else if (0 == strncmp(endptr, "s", 1)) |         else if (STRN_EQ(endptr, "s", 1)) | ||||||
|                 return val * G_USEC_PER_SEC; |                 return val * G_USEC_PER_SEC; | ||||||
|         else if (0 == strncmp(endptr, "m", 1)) |         else if (STRN_EQ(endptr, "m", 1)) | ||||||
|                 return val * G_USEC_PER_SEC * 60; |                 return val * G_USEC_PER_SEC * 60; | ||||||
|         else if (0 == strncmp(endptr, "h", 1)) |         else if (STRN_EQ(endptr, "h", 1)) | ||||||
|                 return val * G_USEC_PER_SEC * 60 * 60; |                 return val * G_USEC_PER_SEC * 60 * 60; | ||||||
|         else if (0 == strncmp(endptr, "d", 1)) |         else if (STRN_EQ(endptr, "d", 1)) | ||||||
|                 return val * G_USEC_PER_SEC * 60 * 60 * 24; |                 return val * G_USEC_PER_SEC * 60 * 60 * 24; | ||||||
|         else |         else | ||||||
|                 return 0; |                 return 0; | ||||||
|  | |||||||
| @ -260,7 +260,7 @@ bool window_is_fullscreen(Window window) | |||||||
|                         char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); |                         char *atom = XGetAtomName(xctx.dpy, ((Atom*)prop_to_return)[i]); | ||||||
| 
 | 
 | ||||||
|                         if (atom) { |                         if (atom) { | ||||||
|                                 if(0 == strcmp("_NET_WM_STATE_FULLSCREEN", atom)) |                                 if(STR_EQ("_NET_WM_STATE_FULLSCREEN", atom)) | ||||||
|                                         fs = true; |                                         fs = true; | ||||||
|                                 XFree(atom); |                                 XFree(atom); | ||||||
|                                 if(fs) |                                 if(fs) | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								src/x11/x.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/x11/x.c
									
									
									
									
									
								
							| @ -712,17 +712,17 @@ void x_win_hide(struct window_x11 *win) | |||||||
|  */ |  */ | ||||||
| KeySym x_shortcut_string_to_mask(const char *str) | KeySym x_shortcut_string_to_mask(const char *str) | ||||||
| { | { | ||||||
|         if (!strcmp(str, "ctrl")) { |         if (STR_EQ(str, "ctrl")) { | ||||||
|                 return ControlMask; |                 return ControlMask; | ||||||
|         } else if (!strcmp(str, "mod4")) { |         } else if (STR_EQ(str, "mod4")) { | ||||||
|                 return Mod4Mask; |                 return Mod4Mask; | ||||||
|         } else if (!strcmp(str, "mod3")) { |         } else if (STR_EQ(str, "mod3")) { | ||||||
|                 return Mod3Mask; |                 return Mod3Mask; | ||||||
|         } else if (!strcmp(str, "mod2")) { |         } else if (STR_EQ(str, "mod2")) { | ||||||
|                 return Mod2Mask; |                 return Mod2Mask; | ||||||
|         } else if (!strcmp(str, "mod1")) { |         } else if (STR_EQ(str, "mod1")) { | ||||||
|                 return Mod1Mask; |                 return Mod1Mask; | ||||||
|         } else if (!strcmp(str, "shift")) { |         } else if (STR_EQ(str, "shift")) { | ||||||
|                 return ShiftMask; |                 return ShiftMask; | ||||||
|         } else { |         } else { | ||||||
|                 LOG_W("Unknown Modifier: '%s'", str); |                 LOG_W("Unknown Modifier: '%s'", str); | ||||||
| @ -828,7 +828,7 @@ static void x_shortcut_init(struct keyboard_shortcut *ks) | |||||||
|         if (!ks|| !ks->str) |         if (!ks|| !ks->str) | ||||||
|                 return; |                 return; | ||||||
| 
 | 
 | ||||||
|         if (!strcmp(ks->str, "none") || (!strcmp(ks->str, ""))) { |         if (STR_EQ(ks->str, "none") || (STR_EQ(ks->str, ""))) { | ||||||
|                 ks->is_valid = false; |                 ks->is_valid = false; | ||||||
|                 return; |                 return; | ||||||
|         } |         } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine