[MPlayer-cvslog] r33874 - in trunk/gui: ui/gtk/preferences.c util/string.c util/string.h

ib subversion at mplayerhq.hu
Mon Jul 11 14:40:30 CEST 2011


Author: ib
Date: Mon Jul 11 14:40:30 2011
New Revision: 33874

Log:
Compare encodings case insensitively.

Add and use new function gstrcasecmp().

This closes Bugzilla #644.

Modified:
   trunk/gui/ui/gtk/preferences.c
   trunk/gui/util/string.c
   trunk/gui/util/string.h

Modified: trunk/gui/ui/gtk/preferences.c
==============================================================================
--- trunk/gui/ui/gtk/preferences.c	Mon Jul 11 14:32:03 2011	(r33873)
+++ trunk/gui/ui/gtk/preferences.c	Mon Jul 11 14:40:30 2011	(r33874)
@@ -321,7 +321,7 @@ void ShowPreferences( void )
   {
    int i;
    for ( i=0;lEncoding[i].name;i++ )
-    if ( !gstrcmp( sub_cp,lEncoding[i].name ) ) break;
+    if ( !gstrcasecmp( sub_cp,lEncoding[i].name ) ) break;
    if ( lEncoding[i].name ) gtk_entry_set_text( GTK_ENTRY( ESubEncoding ),lEncoding[i].comment );
   }
 #endif
@@ -340,7 +340,7 @@ void ShowPreferences( void )
   {
    int i;
    for ( i=0;lEncoding[i].name;i++ )
-    if ( !gstrcmp( subtitle_font_encoding,lEncoding[i].name ) ) break;
+    if ( !gstrcasecmp( subtitle_font_encoding,lEncoding[i].name ) ) break;
    if ( lEncoding[i].name ) gtk_entry_set_text( GTK_ENTRY( EFontEncoding ),lEncoding[i].comment );
   }
  switch ( subtitle_autoscale )

Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c	Mon Jul 11 14:32:03 2011	(r33873)
+++ trunk/gui/util/string.c	Mon Jul 11 14:40:30 2011	(r33874)
@@ -115,6 +115,16 @@ int gstrcmp(const char *a, const char *b
     return strcmp(a, b);
 }
 
+int gstrcasecmp(const char *a, const char *b)
+{
+    if (!a && !b)
+        return 0;
+    if (!a || !b)
+        return -1;
+
+    return strcasecmp(a, b);
+}
+
 int gstrncmp(const char *a, const char *b, int n)
 {
     if (!a && !b)

Modified: trunk/gui/util/string.h
==============================================================================
--- trunk/gui/util/string.h	Mon Jul 11 14:32:03 2011	(r33873)
+++ trunk/gui/util/string.h	Mon Jul 11 14:40:30 2011	(r33874)
@@ -20,6 +20,7 @@
 #define MPLAYER_GUI_STRING_H
 
 char *decomment(char *in);
+int gstrcasecmp(const char *a, const char *b);
 char *gstrchr(const char *str, int c);
 int gstrcmp(const char *a, const char *b);
 char *gstrdup(const char *str);


More information about the MPlayer-cvslog mailing list