[easytag] Improve check for numeric genres in ID3 tags
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Improve check for numeric genres in ID3 tags
- Date: Thu, 10 Nov 2016 16:29:19 +0000 (UTC)
commit 5d4b94caf2639cf78d38a915b3bc2ea76426e24e
Author: David King <amigadave amigadave com>
Date: Thu Nov 10 16:27:20 2016 +0000
Improve check for numeric genres in ID3 tags
Check that the string between two brackets in an ID3v1-compatible
genre field is numeric.
src/tags/id3v24_tag.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/src/tags/id3v24_tag.c b/src/tags/id3v24_tag.c
index 90156af..b73e946 100644
--- a/src/tags/id3v24_tag.c
+++ b/src/tags/id3v24_tag.c
@@ -351,23 +351,29 @@ id3tag_read_file_tag (GFile *gfile,
unsigned genre = 0;
FileTag->genre = NULL;
- if ((string1[0] == '(') && (tmp = strchr (string1,')')) && *(tmp+1))
+ if ((string1[0] == '(') && g_ascii_isdigit (string1[1])
+ && (tmp = strchr (string1 + 1, ')')) && *(tmp+1))
/* Convert a genre written as '(3)EuroDance' into 'EuroDance' */
{
- FileTag->genre = g_strdup(tmp+1);
- } else if ( (string1[0]=='(') && strchr(string1,')') )
+ FileTag->genre = g_strdup (tmp + 1);
+ }
+ else if ((string1[0] == '(') && g_ascii_isdigit (string1[1])
+ && strchr (string1, ')'))
{
/* Convert a genre written as '(3)' into 'Dance' */
- genre = strtol(string1+1, &tmp, 10);
+ genre = strtol (string1 +1 , &tmp, 10);
if (*tmp != ')')
{
- FileTag->genre = g_strdup(string1);
+ FileTag->genre = g_strdup (string1);
}
- } else
+ }
+ else
{
- genre = strtol(string1, &tmp, 10);
+ genre = strtol (string1, &tmp, 10);
if (tmp == string1)
- FileTag->genre = g_strdup(string1);
+ {
+ FileTag->genre = g_strdup (string1);
+ }
}
if (!FileTag->genre)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]