[sound-juicer] Add sj_str_is_empty (const char *s)



commit b59383adfad80621a20f30b33f36dc2e37f846da
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Sat May 5 14:18:56 2012 +0100

    Add sj_str_is_empty (const char *s)
    
    utility function to test if string is NULL, NUL or just ascii space.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=661646

 libjuicer/sj-util.c |   16 ++++++++++++++++
 libjuicer/sj-util.h |    2 +-
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/libjuicer/sj-util.c b/libjuicer/sj-util.c
index ea02355..1d4d9f9 100644
--- a/libjuicer/sj-util.c
+++ b/libjuicer/sj-util.c
@@ -120,3 +120,19 @@ sj_add_default_dirs (GtkFileChooser *dialog)
 	}
 }
 
+/*
+ * True if string is NULL, empty or contains only ascii space
+ */
+gboolean
+sj_str_is_empty (const char *s)
+{
+  int i = 0;
+
+  if (s == NULL)
+    return TRUE;
+  while (s[i]) {
+    if (!g_ascii_isspace (s[i++]))
+      return FALSE;
+  }
+  return TRUE;
+}
diff --git a/libjuicer/sj-util.h b/libjuicer/sj-util.h
index 5335d2b..2ed24e5 100644
--- a/libjuicer/sj-util.h
+++ b/libjuicer/sj-util.h
@@ -33,5 +33,5 @@ void g_list_deep_free (GList *l, GFunc free_func);
 
 void sj_add_default_dirs (GtkFileChooser *dialog);
 GFile *sj_get_default_music_directory (void);
-
+gboolean sj_str_is_empty (const char *s);
 #endif /* SJ_UTIL_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]