Introduce STR_EQ and STRN_EQ macros
This commit is contained in:
		
							parent
							
								
									516161e765
								
							
						
					
					
						commit
						bb02897bc8
					
				| @ -8,6 +8,8 @@ | |||||||
| 
 | 
 | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| 
 | 
 | ||||||
|  | #include "utils.h" | ||||||
|  | 
 | ||||||
| static GLogLevelFlags log_level = G_LOG_LEVEL_WARNING; | static GLogLevelFlags log_level = G_LOG_LEVEL_WARNING; | ||||||
| 
 | 
 | ||||||
| /* see log.h */ | /* see log.h */ | ||||||
|  | |||||||
| @ -6,7 +6,6 @@ | |||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> |  | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| #include "log.h" | #include "log.h" | ||||||
|  | |||||||
| @ -3,9 +3,18 @@ | |||||||
| #define DUNST_UTILS_H | #define DUNST_UTILS_H | ||||||
| 
 | 
 | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
|  | #include <string.h> | ||||||
| 
 | 
 | ||||||
|  | //! Test if a string is NULL or empty
 | ||||||
| #define STR_EMPTY(s) (!s || (*s == '\0')) | #define STR_EMPTY(s) (!s || (*s == '\0')) | ||||||
|  | //! Test if a string is non-NULL and not empty
 | ||||||
| #define STR_FULL(s) !(STR_EMPTY(s)) | #define STR_FULL(s) !(STR_EMPTY(s)) | ||||||
|  | //! Test if string a and b contain the same chars
 | ||||||
|  | #define STR_EQ(a, b) (strcmp(a, b) == 0) | ||||||
|  | //! Test if string a and b are same up to n chars
 | ||||||
|  | #define STRN_EQ(a, b, n) (strncmp(a, b, n) == 0) | ||||||
|  | //! Test if string a and b are the same case-insensitively
 | ||||||
|  | #define STR_CASEQ(a, b) (strcasecmp(a, b) == 0) | ||||||
| 
 | 
 | ||||||
| /* replace all occurrences of the character needle with the character replacement in haystack */ | /* replace all occurrences of the character needle with the character replacement in haystack */ | ||||||
| char *string_replace_char(char needle, char replacement, char *haystack); | char *string_replace_char(char needle, char replacement, char *haystack); | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ | |||||||
| 
 | 
 | ||||||
| #include "src/log.h" | #include "src/log.h" | ||||||
| #include "src/settings.h" | #include "src/settings.h" | ||||||
|  | #include "src/utils.h" | ||||||
| #include "x.h" | #include "x.h" | ||||||
| 
 | 
 | ||||||
| struct screen_info *screens; | struct screen_info *screens; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine