[easytag] Convert most g_utf8_strlen() to new et_str_empty()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Convert most g_utf8_strlen() to new et_str_empty()
- Date: Sat, 21 Feb 2015 23:17:43 +0000 (UTC)
commit afa3ed43e88762179339bdfad137c21d123deb8f
Author: David King <amigadave amigadave com>
Date: Sat Feb 21 22:39:56 2015 +0000
Convert most g_utf8_strlen() to new et_str_empty()
Nearly all uses of g_utf8_strlen() were to check that a string was not
empty. The check for empty was often paired with a check that the char
pointer was not NULL. Simplify the combination of checks into a new
et_str_empty() function, which returns TRUE if either the supplied char
pointer is NULL or the string is empty.
Leave checks that are only concerned with one of the two checks as they
are, but remove g_utf8_strlen() where possible.
src/browser.c | 4 +-
src/cddb_dialog.c | 20 +++++++++-------
src/file.c | 35 ++++++++++++++--------------
src/load_files_dialog.c | 4 +-
src/misc.c | 16 ++++++++++++-
src/misc.h | 1 +
src/playlist_dialog.c | 2 +-
src/scan_dialog.c | 8 ++----
src/setting.c | 2 +-
src/tag_area.c | 51 +++++++++++++++++++++++++----------------
src/tags/ape_tag.c | 32 +++++++++++++-------------
src/tags/flac_tag.c | 48 ++++++++++++++++++++++++++-------------
src/tags/id3_tag.c | 43 +++++++++++++++++++++++------------
src/tags/ogg_tag.c | 57 ++++++++++++++++++++++++++++-------------------
14 files changed, 194 insertions(+), 129 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 8f39396..b3d5f1c 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -3151,7 +3151,7 @@ et_browser_reload (EtBrowser *self)
/* If no node selected, get path from BrowserEntry or default path */
if (priv->current_path != NULL)
current_path = g_strdup(priv->current_path);
- else if (g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->entry_combo)))),
-1) > 0)
+ else if (*(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->entry_combo))))))
current_path =
filename_from_display(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->entry_combo)))));
else
{
@@ -4337,7 +4337,7 @@ Rename_Directory (EtBrowser *self)
}
/* Check if a name for the directory have been supplied */
- if (!directory_new_name || g_utf8_strlen(directory_new_name, -1) < 1)
+ if (et_str_empty (directory_new_name))
{
GtkWidget *msgdialog;
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index a6a8d0a..7c5a6f6 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -236,7 +236,7 @@ update_search_button_sensitivity (EtCDDBDialog *self)
priv = et_cddb_dialog_get_instance_private (self);
if (priv->search_button
- && g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY (priv->search_string_entry)), -1) > 0
+ && *(gtk_entry_get_text (GTK_ENTRY (priv->search_string_entry)))
&& (g_settings_get_flags (MainSettings, "cddb-search-fields") != 0)
&& (g_settings_get_flags (MainSettings, "cddb-search-categories") != 0))
{
@@ -1131,7 +1131,7 @@ Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection)
}else if ( strncmp(cddb_out,"DYEAR=",6)==0 ) // Year
{
valid = Try_To_Validate_Utf8_String(cddb_out+6); // '6' to skip 'DYEAR='
- if (g_utf8_strlen(valid, -1))
+ if (!et_str_empty (valid))
cddbalbum->year = valid;
g_free (cddb_out);
@@ -1140,7 +1140,7 @@ Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection)
}else if ( strncmp(cddb_out,"DGENRE=",7)==0 ) // Genre
{
valid = Try_To_Validate_Utf8_String(cddb_out+7); // '7' to skip 'DGENRE='
- if (g_utf8_strlen(valid, -1))
+ if (!et_str_empty (valid))
cddbalbum->genre = valid;
g_free (cddb_out);
@@ -1515,8 +1515,10 @@ Cddb_Search_Album_List_From_String_Freedb (EtCDDBDialog *self)
/* Get words to search... */
string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->search_string_entry)));
- if (!string || g_utf8_strlen(string, -1) <= 0)
+ if (et_str_empty (string))
+ {
return FALSE;
+ }
/* Format the string of words */
g_strstrip (string);
@@ -1849,8 +1851,10 @@ Cddb_Search_Album_List_From_String_Gnudb (EtCDDBDialog *self)
/* Get words to search... */
string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->search_string_entry)));
- if (!string || g_utf8_strlen(string, -1) <= 0)
+ if (et_str_empty (string))
+ {
return FALSE;
+ }
/* Format the string of words */
g_strstrip (string);
@@ -2424,8 +2428,7 @@ Cddb_Set_Track_Infos_To_File_List (EtCDDBDialog *self)
&& (cddbtrackalbum->cddbalbum->genre
|| cddbtrackalbum->cddbalbum->category))
{
- if (cddbtrackalbum->cddbalbum->genre
- && g_utf8_strlen (cddbtrackalbum->cddbalbum->genre, -1) > 0)
+ if (!et_str_empty (cddbtrackalbum->cddbalbum->genre))
{
et_file_tag_set_genre (FileTag,
Cddb_Get_Id3_Genre_From_Cddb_Genre
(cddbtrackalbum->cddbalbum->genre));
@@ -2555,8 +2558,7 @@ Cddb_Set_Track_Infos_To_File_List (EtCDDBDialog *self)
&& (cddbtrackalbum->cddbalbum->genre
|| cddbtrackalbum->cddbalbum->category) )
{
- if (cddbtrackalbum->cddbalbum->genre
- && g_utf8_strlen (cddbtrackalbum->cddbalbum->genre, -1) > 0)
+ if (!et_str_empty (cddbtrackalbum->cddbalbum->genre))
{
et_file_tag_set_genre (FileTag,
Cddb_Get_Id3_Genre_From_Cddb_Genre
(cddbtrackalbum->cddbalbum->genre));
diff --git a/src/file.c b/src/file.c
index f57ad6b..01c0d34 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1104,7 +1104,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
FileTagCur = (File_Tag *)ETFile->FileTag->data;
/* Title */
- if ( FileTagCur->title && g_utf8_strlen(FileTagCur->title, -1)>0 )
+ if (!et_str_empty (FileTagCur->title))
{
FileTag->title = g_strdup(FileTagCur->title);
g_strstrip (FileTag->title);
@@ -1114,7 +1114,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
}
/* Artist */
- if ( FileTagCur->artist && g_utf8_strlen(FileTagCur->artist, -1)>0 )
+ if (!et_str_empty (FileTagCur->artist))
{
FileTag->artist = g_strdup(FileTagCur->artist);
g_strstrip (FileTag->artist);
@@ -1123,8 +1123,8 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
FileTag->artist = NULL;
}
- /* Album Artist */
- if ( FileTagCur->album_artist && g_utf8_strlen(FileTagCur->album_artist, -1)>0 )
+ /* Album Artist */
+ if (!et_str_empty (FileTagCur->album_artist))
{
FileTag->album_artist = g_strdup(FileTagCur->album_artist);
g_strstrip (FileTag->album_artist);
@@ -1135,7 +1135,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Album */
- if ( FileTagCur->album && g_utf8_strlen(FileTagCur->album, -1)>0 )
+ if (!et_str_empty (FileTagCur->album))
{
FileTag->album = g_strdup(FileTagCur->album);
g_strstrip (FileTag->album);
@@ -1146,7 +1146,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Disc Number */
- if ( FileTagCur->disc_number && g_utf8_strlen(FileTagCur->disc_number, -1)>0 )
+ if (!et_str_empty (FileTagCur->disc_number))
{
FileTag->disc_number = g_strdup(FileTagCur->disc_number);
g_strstrip (FileTag->disc_number);
@@ -1157,8 +1157,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Discs Total */
- if (FileTagCur->disc_total
- && g_utf8_strlen (FileTagCur->disc_total, -1) > 0)
+ if (!et_str_empty (FileTagCur->disc_total))
{
FileTag->disc_total = et_disc_number_to_string (atoi (FileTagCur->disc_total));
g_strstrip (FileTag->disc_total);
@@ -1170,7 +1169,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Year */
- if ( FileTagCur->year && g_utf8_strlen(FileTagCur->year, -1)>0 )
+ if (!et_str_empty (FileTagCur->year))
{
FileTag->year = g_strdup(FileTagCur->year);
g_strstrip (FileTag->year);
@@ -1181,7 +1180,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Track */
- if ( FileTagCur->track && g_utf8_strlen(FileTagCur->track, -1)>0 )
+ if (!et_str_empty (FileTagCur->track))
{
gchar *tmp_str;
@@ -1199,7 +1198,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Track Total */
- if ( FileTagCur->track_total && g_utf8_strlen(FileTagCur->track_total, -1)>0 )
+ if (!et_str_empty (FileTagCur->track_total))
{
FileTag->track_total = et_track_number_to_string (atoi (FileTagCur->track_total));
g_strstrip (FileTag->track_total);
@@ -1210,7 +1209,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Genre */
- if ( FileTagCur->genre && g_utf8_strlen(FileTagCur->genre, -1)>0 )
+ if (!et_str_empty (FileTagCur->genre))
{
FileTag->genre = g_strdup(FileTagCur->genre);
g_strstrip (FileTag->genre);
@@ -1221,7 +1220,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Comment */
- if ( FileTagCur->comment && g_utf8_strlen(FileTagCur->comment, -1)>0 )
+ if (!et_str_empty (FileTagCur->comment))
{
FileTag->comment = g_strdup(FileTagCur->comment);
g_strstrip (FileTag->comment);
@@ -1232,7 +1231,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Composer */
- if ( FileTagCur->composer && g_utf8_strlen(FileTagCur->composer, -1)>0 )
+ if (!et_str_empty (FileTagCur->composer))
{
FileTag->composer = g_strdup(FileTagCur->composer);
g_strstrip (FileTag->composer);
@@ -1243,7 +1242,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Original Artist */
- if ( FileTagCur->orig_artist && g_utf8_strlen(FileTagCur->orig_artist, -1)>0 )
+ if (!et_str_empty (FileTagCur->orig_artist))
{
FileTag->orig_artist = g_strdup(FileTagCur->orig_artist);
g_strstrip (FileTag->orig_artist);
@@ -1254,7 +1253,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Copyright */
- if ( FileTagCur->copyright && g_utf8_strlen(FileTagCur->copyright, -1)>0 )
+ if (!et_str_empty (FileTagCur->copyright))
{
FileTag->copyright = g_strdup(FileTagCur->copyright);
g_strstrip (FileTag->copyright);
@@ -1265,7 +1264,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* URL */
- if ( FileTagCur->url && g_utf8_strlen(FileTagCur->url, -1)>0 )
+ if (!et_str_empty (FileTagCur->url))
{
FileTag->url = g_strdup(FileTagCur->url);
g_strstrip (FileTag->url);
@@ -1276,7 +1275,7 @@ ET_Save_File_Tag_Internal (ET_File *ETFile, File_Tag *FileTag)
/* Encoded by */
- if ( FileTagCur->encoded_by && g_utf8_strlen(FileTagCur->encoded_by, -1)>0 )
+ if (!et_str_empty (FileTagCur->encoded_by))
{
FileTag->encoded_by = g_strdup(FileTagCur->encoded_by);
g_strstrip (FileTag->encoded_by);
diff --git a/src/load_files_dialog.c b/src/load_files_dialog.c
index 0225674..aaa057c 100644
--- a/src/load_files_dialog.c
+++ b/src/load_files_dialog.c
@@ -113,7 +113,7 @@ Load_Filename_Set_Filenames (EtLoadFilesDialog *self)
gtk_tree_model_get(GTK_TREE_MODEL(priv->load_file_content_model), &iter_content,
LOAD_FILE_CONTENT_TEXT, &list_text, -1);
- if (ETFile && list_text && (g_utf8_strlen (list_text, -1) > 0))
+ if (ETFile && !et_str_empty (list_text))
{
gchar *list_text_tmp;
gchar *filename_new_utf8;
@@ -398,7 +398,7 @@ Load_Filename_List_Delete_All_Blank_Lines (GtkWidget *treeview)
gtk_tree_model_get(model, &iter, LOAD_FILE_NAME_TEXT, &text, -1);
/* Check for blank entry */
- if (!text || g_utf8_strlen(text, -1) == 0)
+ if (et_str_empty (text))
{
g_free(text);
diff --git a/src/misc.c b/src/misc.c
index d0df252..139680e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -47,7 +47,7 @@ gboolean Add_String_To_Combo_List (GtkListStore *liststore, const gchar *str)
//gboolean found = FALSE;
gchar *string = g_strdup(str);
- if (!string || g_utf8_strlen(string, -1) <= 0)
+ if (et_str_empty (string))
{
g_free (string);
return FALSE;
@@ -471,3 +471,17 @@ et_normalized_strcmp0 (const gchar *str1,
return result;
}
+
+/*
+ * et_str_empty:
+ * @str: string to test for emptiness
+ *
+ * Test if @str is empty, in other words either %NULL or the empty string.
+ *
+ * Returns: %TRUE is @str is either %NULL or "", %FALSE otherwise
+ */
+gboolean
+et_str_empty (const gchar *str)
+{
+ return !str || !str[0];
+}
diff --git a/src/misc.h b/src/misc.h
index 48b0891..72a25f7 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -41,6 +41,7 @@ void et_filename_prepare (gchar *filename_utf8, gboolean replace_illegal);
guint et_undo_key_new (void);
gint et_normalized_strcmp0 (const gchar *str1, const gchar *str2);
+gboolean et_str_empty (const gchar *str);
G_END_DECLS
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index 9ee4b52..1a2d6c8 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -429,7 +429,7 @@ write_button_clicked (EtPlaylistDialog *self)
/* Check if playlist name was filled. */
if (g_settings_get_boolean (MainSettings, "playlist-use-mask")
- && g_utf8_strlen (gtk_entry_get_text (GTK_ENTRY(priv->name_mask_entry)), -1) <=0)
+ && *(gtk_entry_get_text (GTK_ENTRY (priv->name_mask_entry))) == '\0')
{
/* TODO: Can this happen? */
g_settings_set_boolean (MainSettings, "playlist-use-mask", FALSE);
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 1525448..9174779 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -793,11 +793,9 @@ Scan_Rename_File_With_Mask (EtScanDialog *self, ET_File *ETFile)
FALSE);
g_free(mask);
- if (!filename_generated_utf8)
- return;
- if (g_utf8_strlen(filename_generated_utf8,-1)<1)
+ if (!et_str_empty (filename_generated_utf8))
{
- g_free(filename_generated_utf8);
+ g_free (filename_generated_utf8);
return;
}
@@ -1735,7 +1733,7 @@ Mask_Editor_Clean_Up_Masks_List (EtScanDialog *self)
gtk_tree_model_get(treemodel, ¤tIter, MASK_EDITOR_TEXT, &text, -1);
/* Check for blank entry */
- if (text && g_utf8_strlen(text, -1) == 0)
+ if (text && *text == '\0')
{
g_free(text);
diff --git a/src/setting.c b/src/setting.c
index e5d6e70..cad24ff 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -298,7 +298,7 @@ Populate_List_Store_From_File (const gchar *filename,
utf8_line = Try_To_Validate_Utf8_String (line);
g_free (line);
- if (utf8_line && g_utf8_strlen (utf8_line, -1) > 0)
+ if (!et_str_empty (utf8_line))
{
gtk_list_store_insert_with_values (liststore, NULL, G_MAXINT,
text_column, utf8_line, -1);
diff --git a/src/tag_area.c b/src/tag_area.c
index 9ae4ca8..1ee216d 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -180,7 +180,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_title (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with title ‘%s’"),
string_to_set);
@@ -202,7 +203,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with artist ‘%s’"),
string_to_set);
@@ -223,7 +225,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_album_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with album artist ‘%s’"),
string_to_set);
@@ -245,7 +248,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_album (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with album ‘%s’"),
string_to_set);
@@ -285,10 +289,9 @@ on_apply_to_selection (GObject *object,
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen (string_to_set, -1) > 0)
+ if (!et_str_empty (string_to_set))
{
- if (string_to_set1 != NULL
- && g_utf8_strlen (string_to_set1, -1) > 0)
+ if (!et_str_empty (string_to_set1))
{
msg = g_strdup_printf (_("Selected files tagged with disc number ‘%s/%s’"),
string_to_set, string_to_set1);
@@ -315,7 +318,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_year (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with year ‘%s’"),
string_to_set);
@@ -339,7 +343,7 @@ on_apply_to_selection (GObject *object,
// We apply the TrackEntry field to all others files only if it is to delete
// the field (string=""). Else we don't overwrite the track number
- if (!string_to_set || g_utf8_strlen(string_to_set, -1) == 0)
+ if (et_str_empty (string_to_set))
{
et_file_tag_set_track_number (FileTag, string_to_set);
}
@@ -348,9 +352,9 @@ on_apply_to_selection (GObject *object,
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if ( string_to_set && g_utf8_strlen(string_to_set, -1) > 0 ) //&& atoi(string_to_set)>0 )
+ if (!et_str_empty (string_to_set))
{
- if ( string_to_set1 != NULL && g_utf8_strlen(string_to_set1, -1)>0 ) //&& atoi(string_to_set1)>0
)
+ if (!et_str_empty (string_to_set1))
{
msg = g_strdup_printf (_("Selected files tagged with track like ‘xx/%s’"),
string_to_set1);
@@ -444,7 +448,7 @@ on_apply_to_selection (GObject *object,
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if ( string_to_set1 != NULL && g_utf8_strlen(string_to_set1, -1)>0 ) //&& atoi(string_to_set1)>0 )
+ if (!et_str_empty (string_to_set1))
{
msg = g_strdup_printf (_("Selected files tagged with track like ‘xx/%s’"),
string_to_set1);
@@ -466,7 +470,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_genre (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with genre ‘%s’"),
string_to_set);
@@ -495,7 +500,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_comment (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with comment ‘%s’"),
string_to_set);
@@ -516,7 +522,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_composer (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with composer ‘%s’"),
string_to_set);
@@ -538,7 +545,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_orig_artist (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with original artist ‘%s’"),
string_to_set);
@@ -560,7 +568,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_copyright (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with copyright ‘%s’"),
string_to_set);
@@ -582,7 +591,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_url (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with URL ‘%s’"),
string_to_set);
@@ -604,7 +614,8 @@ on_apply_to_selection (GObject *object,
et_file_tag_set_encoded_by (FileTag, string_to_set);
ET_Manage_Changes_Of_File_Data(etfile,NULL,FileTag);
}
- if (string_to_set != NULL && g_utf8_strlen(string_to_set, -1)>0)
+
+ if (!et_str_empty (string_to_set))
{
msg = g_strdup_printf (_("Selected files tagged with encoder name ‘%s’"),
string_to_set);
@@ -2767,7 +2778,7 @@ et_tag_area_create_file_tag (EtTagArea *self)
separator = g_utf8_strchr (buffer, -1, '/');
- if (separator != NULL && g_utf8_strlen (separator + 1, -1) > 0)
+ if (separator && *(separator + 1))
{
/* Copy before the separator for the disc number, beyond the
* separator for the total number of discs. */
diff --git a/src/tags/ape_tag.c b/src/tags/ape_tag.c
index d808217..91db733 100644
--- a/src/tags/ape_tag.c
+++ b/src/tags/ape_tag.c
@@ -243,7 +243,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*********
* Title *
*********/
- if ( FileTag->title && g_utf8_strlen(FileTag->title, -1) > 0)
+ if (!et_str_empty (FileTag->title))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_TITLE, FileTag->title);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_TITLE);
@@ -252,13 +252,13 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/**********
* Artist *
**********/
- if ( FileTag->artist && g_utf8_strlen(FileTag->artist, -1) > 0)
+ if (!et_str_empty (FileTag->artist))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_ARTIST, FileTag->artist);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_ARTIST);
/* Album artist. */
- if (FileTag->album_artist && g_utf8_strlen (FileTag->album_artist, -1) > 0)
+ if (!et_str_empty (FileTag->album_artist))
{
apefrm_add (ape_mem, 0, APE_TAG_FIELD_ALBUMARTIST,
FileTag->album_artist);
@@ -271,7 +271,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*********
* Album *
*********/
- if ( FileTag->album && g_utf8_strlen(FileTag->album, -1) > 0)
+ if (!et_str_empty (FileTag->album))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_ALBUM, FileTag->album);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_ALBUM);
@@ -279,9 +279,9 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/******************************
* Disc Number and Disc Total *
******************************/
- if (FileTag->disc_number && g_utf8_strlen (FileTag->disc_number, -1) > 0)
+ if (!et_str_empty (FileTag->disc_number))
{
- if (FileTag->disc_total && g_utf8_strlen (FileTag->disc_total, -1) > 0)
+ if (!et_str_empty (FileTag->disc_total))
{
string = g_strconcat (FileTag->disc_number, "/",
FileTag->disc_total, NULL);
@@ -302,7 +302,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/********
* Year *
********/
- if ( FileTag->year && g_utf8_strlen(FileTag->year, -1) > 0)
+ if (!et_str_empty (FileTag->year))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_YEAR, FileTag->year);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_YEAR);
@@ -310,9 +310,9 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*************************
* Track and Total Track *
*************************/
- if ( FileTag->track && g_utf8_strlen(FileTag->track, -1) > 0)
+ if (!et_str_empty (FileTag->track))
{
- if ( FileTag->track_total && g_utf8_strlen(FileTag->track_total, -1) > 0 )
+ if (!et_str_empty (FileTag->track_total))
string = g_strconcat(FileTag->track,"/",FileTag->track_total,NULL);
else
string = g_strconcat(FileTag->track,NULL);
@@ -324,7 +324,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*********
* Genre *
*********/
- if ( FileTag->genre && g_utf8_strlen(FileTag->genre, -1) > 0)
+ if (!et_str_empty (FileTag->genre))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_GENRE, FileTag->genre);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_GENRE);
@@ -332,7 +332,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/***********
* Comment *
***********/
- if ( FileTag->comment && g_utf8_strlen(FileTag->comment, -1) > 0)
+ if (!et_str_empty (FileTag->comment))
apefrm_add (ape_mem, 0, APE_TAG_FIELD_COMMENT, FileTag->comment);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_COMMENT);
@@ -340,7 +340,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/************
* Composer *
************/
- if ( FileTag->composer && g_utf8_strlen(FileTag->composer, -1) > 0)
+ if (!et_str_empty (FileTag->composer))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_COMPOSER, FileTag->composer);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_COMPOSER);
@@ -348,7 +348,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*******************
* Original artist *
*******************/
- if ( FileTag->orig_artist && g_utf8_strlen(FileTag->orig_artist, -1) > 0)
+ if (!et_str_empty (FileTag->orig_artist))
apefrm_add(ape_mem, 0, "Original Artist", FileTag->orig_artist);
else
apefrm_remove(ape_mem,"Original Artist");
@@ -356,7 +356,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*************
* Copyright *
*************/
- if ( FileTag->copyright && g_utf8_strlen(FileTag->copyright, -1) > 0)
+ if (!et_str_empty (FileTag->copyright))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_COPYRIGHT, FileTag->copyright);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_COPYRIGHT);
@@ -364,7 +364,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/*******
* URL *
*******/
- if ( FileTag->url && g_utf8_strlen(FileTag->url, -1) > 0)
+ if (!et_str_empty (FileTag->url))
apefrm_add(ape_mem, 0, APE_TAG_FIELD_RELATED_URL, FileTag->url);
else
apefrm_remove(ape_mem,APE_TAG_FIELD_RELATED_URL);
@@ -372,7 +372,7 @@ ape_tag_write_file_tag (const ET_File *ETFile,
/**************
* Encoded by *
**************/
- if ( FileTag->encoded_by && g_utf8_strlen(FileTag->encoded_by, -1) > 0)
+ if (!et_str_empty (FileTag->encoded_by))
apefrm_add(ape_mem, 0, "Encoded By", FileTag->encoded_by);
else
apefrm_remove(ape_mem,"Encoded By");
diff --git a/src/tags/flac_tag.c b/src/tags/flac_tag.c
index 494c4d1..f2f4f01 100644
--- a/src/tags/flac_tag.c
+++ b/src/tags/flac_tag.c
@@ -162,7 +162,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -190,7 +191,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -218,7 +220,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -246,7 +249,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -273,7 +277,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if (field_value && g_utf8_strlen (field_value, -1) > 0)
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup (field_value,
@@ -297,7 +302,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -330,7 +336,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -353,7 +360,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -376,7 +384,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -409,7 +418,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -457,7 +467,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -485,7 +496,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -513,7 +525,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -541,7 +554,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -569,7 +583,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
@@ -597,7 +612,8 @@ flac_tag_read_file_tag (GFile *file,
if (field_value)
{
field_value++;
- if ( field_value && g_utf8_strlen(field_value, -1) > 0 )
+
+ if (!et_str_empty (field_value))
{
field_len = field->length - (field_value - (gchar*) field->entry);
field_value_tmp = g_strndup(field_value, field_len);
diff --git a/src/tags/id3_tag.c b/src/tags/id3_tag.c
index f27627e..bd48e3a 100644
--- a/src/tags/id3_tag.c
+++ b/src/tags/id3_tag.c
@@ -243,7 +243,7 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_TITLE)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->title && g_utf8_strlen(FileTag->title, -1) > 0)
+ if (!et_str_empty (FileTag->title))
{
id3_frame = ID3Frame_NewID(ID3FID_TITLE);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -257,7 +257,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
**********/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_LEADARTIST)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->artist && g_utf8_strlen(FileTag->artist, -1) > 0)
+
+ if (!et_str_empty (FileTag->artist))
{
id3_frame = ID3Frame_NewID(ID3FID_LEADARTIST);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -270,7 +271,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
***************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_BAND)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->album_artist && g_utf8_strlen(FileTag->album_artist, -1) > 0)
+
+ if (!et_str_empty (FileTag->album_artist))
{
id3_frame = ID3Frame_NewID(ID3FID_BAND);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -283,7 +285,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*********/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_ALBUM)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->album && g_utf8_strlen(FileTag->album, -1) > 0)
+
+ if (!et_str_empty (FileTag->album))
{
id3_frame = ID3Frame_NewID(ID3FID_ALBUM);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -297,7 +300,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*****************************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_PARTINSET)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->disc_number && g_utf8_strlen(FileTag->disc_number, -1) > 0)
+
+ if (!et_str_empty (FileTag->disc_number))
{
id3_frame = ID3Frame_NewID (ID3FID_PARTINSET);
ID3Tag_AttachFrame (id3_tag, id3_frame);
@@ -313,7 +317,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
********/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_YEAR)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->year && g_utf8_strlen(FileTag->year, -1) > 0)
+
+ if (!et_str_empty (FileTag->year))
{
id3_frame = ID3Frame_NewID(ID3FID_YEAR);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -327,12 +332,13 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*************************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_TRACKNUM)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->track && g_utf8_strlen(FileTag->track, -1) > 0)
+
+ if (!et_str_empty (FileTag->track))
{
id3_frame = ID3Frame_NewID(ID3FID_TRACKNUM);
ID3Tag_AttachFrame(id3_tag,id3_frame);
- if ( FileTag->track_total && g_utf8_strlen(FileTag->track_total, -1) > 0)
+ if (!et_str_empty (FileTag->track_total))
string1 = g_strconcat(FileTag->track,"/",FileTag->track_total,NULL);
else
string1 = g_strdup(FileTag->track);
@@ -352,7 +358,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_CONTENTTYPE)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->genre && strlen(FileTag->genre)>0 )
+
+ if (!et_str_empty (FileTag->genre))
{
gchar *genre_string_tmp;
guchar genre_value;
@@ -383,7 +390,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
***********/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_COMMENT)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->comment && g_utf8_strlen(FileTag->comment, -1) > 0)
+
+ if (!et_str_empty (FileTag->comment))
{
id3_frame = ID3Frame_NewID(ID3FID_COMMENT);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -401,7 +409,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_COMPOSER)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->composer && g_utf8_strlen(FileTag->composer, -1) > 0)
+
+ if (!et_str_empty (FileTag->composer))
{
id3_frame = ID3Frame_NewID(ID3FID_COMPOSER);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -415,7 +424,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*******************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_ORIGARTIST)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->orig_artist && g_utf8_strlen(FileTag->orig_artist, -1) > 0)
+
+ if (!et_str_empty (FileTag->orig_artist))
{
id3_frame = ID3Frame_NewID(ID3FID_ORIGARTIST);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -429,7 +439,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_COPYRIGHT)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->copyright && g_utf8_strlen(FileTag->copyright, -1) > 0)
+
+ if (!et_str_empty (FileTag->copyright))
{
id3_frame = ID3Frame_NewID(ID3FID_COPYRIGHT);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -443,7 +454,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
*******/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_WWWUSER)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->url && g_utf8_strlen(FileTag->url, -1) > 0)
+
+ if (!et_str_empty (FileTag->url))
{
id3_frame = ID3Frame_NewID(ID3FID_WWWUSER);
ID3Tag_AttachFrame(id3_tag,id3_frame);
@@ -457,7 +469,8 @@ id3tag_write_file_v23tag (const ET_File *ETFile,
**************/
while ( (id3_frame = ID3Tag_FindFrameWithID(id3_tag,ID3FID_ENCODEDBY)) )
ID3Tag_RemoveFrame(id3_tag,id3_frame);
- if (FileTag->encoded_by && g_utf8_strlen(FileTag->encoded_by, -1) > 0)
+
+ if (!et_str_empty (FileTag->encoded_by))
{
id3_frame = ID3Frame_NewID(ID3FID_ENCODEDBY);
ID3Tag_AttachFrame(id3_tag,id3_frame);
diff --git a/src/tags/ogg_tag.c b/src/tags/ogg_tag.c
index 159c5b2..e143852 100644
--- a/src/tags/ogg_tag.c
+++ b/src/tags/ogg_tag.c
@@ -183,7 +183,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->title==NULL)
FileTag->title = g_strdup(string);
@@ -203,7 +203,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->artist==NULL)
FileTag->artist = g_strdup(string);
@@ -222,7 +222,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->album_artist==NULL)
FileTag->album_artist = g_strdup(string);
@@ -241,7 +241,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->album==NULL)
FileTag->album = g_strdup(string);
@@ -256,11 +256,11 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
* Disc Number (Part of a Set) and Disc Total *
**********************************************/
if ((string = vorbis_comment_query (vc, "DISCNUMBER", 0)) != NULL
- && g_utf8_strlen (string, -1) > 0)
+ && !et_str_empty (string))
{
/* Check if DISCTOTAL used, else takes it in DISCNUMBER. */
if ((string1 = vorbis_comment_query (vc, "DISCTOTAL", 0)) != NULL
- && g_utf8_strlen (string1, -1) > 0)
+ && !et_str_empty (string1))
{
FileTag->disc_total = et_disc_number_to_string (atoi (string1));
}
@@ -277,7 +277,9 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
/********
* Year *
********/
- if ( (string = vorbis_comment_query(vc,"DATE",0)) != NULL && g_utf8_strlen(string, -1) > 0 )
+ string = vorbis_comment_query (vc, "DATE", 0);
+
+ if (!et_str_empty (string))
{
FileTag->year = g_strdup(string);
}
@@ -285,11 +287,13 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
/*************************
* Track and Total Track *
*************************/
- if ( (string = vorbis_comment_query(vc,"TRACKNUMBER",0)) != NULL && g_utf8_strlen(string, -1) > 0 )
+ string = vorbis_comment_query (vc, "TRACKNUMBER", 0);
+
+ if (!et_str_empty (string))
{
/* Check if TRACKTOTAL used, else takes it in TRACKNUMBER. */
if ((string1 = vorbis_comment_query (vc, "TRACKTOTAL", 0)) != NULL
- && g_utf8_strlen (string1, -1) > 0)
+ && !et_str_empty (string1))
{
FileTag->track_total = et_track_number_to_string (atoi (string1));
}
@@ -310,7 +314,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->genre==NULL)
FileTag->genre = g_strdup(string);
@@ -334,29 +338,36 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
string1 = Try_To_Validate_Utf8_String(string1);
string2 = Try_To_Validate_Utf8_String(string2);
- if ( string2 && g_utf8_strlen(string2, -1) > 0 ) // Contains comment to new specifications format
and we prefer this format (field name defined)
+ /* Contains comment in new specifications format and we prefer this
+ * format (field name defined). */
+ if (!et_str_empty (string2))
{
if (FileTag->comment==NULL)
FileTag->comment = g_strdup(string2);
else
FileTag->comment = g_strconcat(FileTag->comment,MULTIFIELD_SEPARATOR,string2,NULL);
- // Frees allocated data
- if (string && g_utf8_strlen(string, -1) > 0)
+ /* Frees allocated data. */
+ if (!et_str_empty (string))
g_free(string);
- if (string1 && g_utf8_strlen(string1, -1) > 0)
+ if (!et_str_empty (string1))
g_free(string1);
- }else if ( string && g_utf8_strlen(string, -1) > 0 ) // Contains comment to Winamp format and we
prefer this format (field name defined)
+ }
+ /* Contains comment to Winamp format and we prefer this format (field
+ * name defined). */
+ else if (!et_str_empty (string))
{
if (FileTag->comment==NULL)
FileTag->comment = g_strdup(string);
else
FileTag->comment = g_strconcat(FileTag->comment,MULTIFIELD_SEPARATOR,string,NULL);
- // Frees allocated data
- if (string1 && g_utf8_strlen(string1, -1) > 0)
+ /* Frees allocated data. */
+ if (!et_str_empty (string1))
g_free(string1);
- }else if ( string1 && g_utf8_strlen(string1, -1) > 0 ) // Contains comment to Xmms format only
+ }
+ /* Contains comment in XMMS format only. */
+ else if (!et_str_empty (string1))
{
if (FileTag->comment==NULL)
FileTag->comment = g_strdup(string1);
@@ -381,7 +392,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->composer==NULL)
FileTag->composer = g_strdup(string);
@@ -400,7 +411,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->orig_artist==NULL)
FileTag->orig_artist = g_strdup(string);
@@ -419,7 +430,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->copyright==NULL)
FileTag->copyright = g_strdup(string);
@@ -438,7 +449,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->url==NULL)
FileTag->url = g_strdup(string);
@@ -457,7 +468,7 @@ et_add_file_tags_from_vorbis_comments (vorbis_comment *vc,
{
string = Try_To_Validate_Utf8_String(string);
- if ( g_utf8_strlen(string, -1) > 0 )
+ if (!et_str_empty (string))
{
if (FileTag->encoded_by==NULL)
FileTag->encoded_by = g_strdup(string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]