changeset 2188:2984f6c7221a

demac: tag reading routine now case-insensitive
author Eugene Zagidullin <e.asphyx@gmail.com>
date Sun, 25 Nov 2007 22:36:59 +0300
parents 9a7822a4762e
children 549009824758
files src/demac/apev2.c
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/demac/apev2.c	Sun Nov 25 18:03:23 2007 +0100
+++ b/src/demac/apev2.c	Sun Nov 25 22:36:59 2007 +0300
@@ -51,6 +51,21 @@
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
+static gboolean strcase_equal (gconstpointer v1, gconstpointer v2) {
+  return (g_ascii_strcasecmp((gchar *)v1, (gchar *)v2) == 0);
+}
+
+static guint strcase_hash (gconstpointer v) {
+  gchar *tmp;
+  gchar buf[TMP_BUFSIZE+1];
+  gchar *p = buf;
+  
+  for(tmp=(gchar*)v; (*tmp && (p < buf+TMP_BUFSIZE)); tmp++)
+    *(p++) = g_ascii_toupper(*tmp);
+  *p = '\0';
+  return g_str_hash((gconstpointer)buf);
+}
+
 GHashTable* parse_apev2_tag(VFSFile *vfd) {
   unsigned char tmp[TMP_BUFSIZE+1];
   unsigned char tmp2[TMP_BUFSIZE+1];
@@ -84,7 +99,7 @@
     return NULL;
   }
   
-  hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); /* string-keyed table with dynamically allocated keys and items */
+  hash = g_hash_table_new_full(strcase_hash, strcase_equal, g_free, g_free); /* string-keyed table with dynamically allocated keys and items */
 
   aud_vfs_fseek(vfd, -tag_size, SEEK_END);
   int i;