Browse Source

faux.str: faux_str_is_empty()

Serj Kalichev 3 years ago
parent
commit
25c59d037e
2 changed files with 17 additions and 0 deletions
  1. 1 0
      faux/str.h
  2. 16 0
      faux/str/str.c

+ 1 - 0
faux/str.h

@@ -34,6 +34,7 @@ int faux_str_casecmp(const char *str1, const char *str2);
 char *faux_str_casestr(const char *haystack, const char *needle);
 char *faux_str_charsn(const char *str, const char *chars_to_search, size_t n);
 char *faux_str_chars(const char *str, const char *chars_to_search);
+bool_t faux_str_is_empty(const char *str);
 
 char *faux_str_c_esc(const char *src);
 char *faux_str_c_bin(const char *src, size_t n);

+ 16 - 0
faux/str/str.c

@@ -796,3 +796,19 @@ char *faux_str_nextword(const char *str, const char **saveptr,
 
 	return result;
 }
+
+
+/** @brief Indicates is string is empty.
+ *
+ * @param [in] str String to analyze.
+ * @return BOOL_TRUE if pointer is NULL or empty, BOOL_FALSE if not empty.
+ */
+bool_t faux_str_is_empty(const char *str)
+{
+	if (!str)
+		return BOOL_TRUE;
+	if ('\0' == *str)
+		return BOOL_TRUE;
+
+	return BOOL_FALSE;
+}