[MPlayer-cvslog] r33825 - in trunk/gui: cfg.c interface.c interface.h ui/actions.c ui/gtk/equalizer.c ui/gtk/fileselect.c ui/gtk/preferences.c ui/gtk/url.c ui/main.c util/string.c util/string.h win32/interface.c

ib subversion at mplayerhq.hu
Thu Jul 7 10:32:11 CEST 2011


Author: ib
Date: Thu Jul  7 10:32:10 2011
New Revision: 33825

Log:
Move string functions from interface.c to string.c.

Additionally, change char parameter of gstrchr() to const and
rename parameter size of gstrncmp() n.

The Win32 GUI now needs gstrdup() defined before its first usage.

Modified:
   trunk/gui/cfg.c
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/ui/actions.c
   trunk/gui/ui/gtk/equalizer.c
   trunk/gui/ui/gtk/fileselect.c
   trunk/gui/ui/gtk/preferences.c
   trunk/gui/ui/gtk/url.c
   trunk/gui/ui/main.c
   trunk/gui/util/string.c
   trunk/gui/util/string.h
   trunk/gui/win32/interface.c

Modified: trunk/gui/cfg.c
==============================================================================
--- trunk/gui/cfg.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/cfg.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -22,6 +22,7 @@
 
 #include "cfg.h"
 #include "interface.h"
+#include "util/string.h"
 
 #include "config.h"
 #include "help_mp.h"

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/interface.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -24,6 +24,7 @@
 #include "skin/skin.h"
 #include "ui/gmplayer.h"
 #include "ui/widgets.h"
+#include "util/string.h"
 #include "wm/ws.h"
 #include "wm/wsxdnd.h"
 
@@ -75,42 +76,6 @@ float gtkEquChannels[6][10];
 
 static int initialized;
 
-int gstrcmp(const char *a, const char *b)
-{
-    if (!a && !b)
-        return 0;
-    if (!a || !b)
-        return -1;
-
-    return strcmp(a, b);
-}
-
-static int gstrncmp(const char *a, const char *b, int size)
-{
-    if (!a && !b)
-        return 0;
-    if (!a || !b)
-        return -1;
-
-    return strncmp(a, b, size);
-}
-
-char *gstrdup(const char *str)
-{
-    if (!str)
-        return NULL;
-
-    return strdup(str);
-}
-
-char *gstrchr(char *str, int c)
-{
-    if (!str)
-        return NULL;
-
-    return strchr(str, c);
-}
-
 void gfree(void **p)
 {
     free(*p);

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/interface.h	Thu Jul  7 10:32:10 2011	(r33825)
@@ -227,9 +227,6 @@ extern float gtkEquChannels[6][10];
 void gaddlist(char ***list, const char *entry);
 void gfree(void **p);
 void gmp_msg(int mod, int lev, const char *format, ...);
-char *gstrchr(char *str, int c);
-int gstrcmp(const char *a, const char *b);
-char *gstrdup(const char *str);
 void *gtkSet(int cmd, float fparam, void *vparam);
 void guiDone(void);
 void guiExit(enum exit_reason how);

Modified: trunk/gui/ui/actions.c
==============================================================================
--- trunk/gui/ui/actions.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/actions.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -25,6 +25,7 @@
 #include "gui/interface.h"
 #include "gui/skin/font.h"
 #include "gui/skin/skin.h"
+#include "gui/util/string.h"
 #include "gui/wm/wsxdnd.h"
 #include "widgets.h"
 

Modified: trunk/gui/ui/gtk/equalizer.c
==============================================================================
--- trunk/gui/ui/gtk/equalizer.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/gtk/equalizer.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -38,6 +38,7 @@
 #include "libmpdemux/stheader.h"
 #include "libmpcodecs/dec_video.h"
 #include "gui/ui/widgets.h"
+#include "gui/util/string.h"
 
 #include "equalizer.h"
 #include "tools.h"

Modified: trunk/gui/ui/gtk/fileselect.c
==============================================================================
--- trunk/gui/ui/gtk/fileselect.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/gtk/fileselect.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -32,6 +32,7 @@
 
 #include "gui/app.h"
 #include "gui/interface.h"
+#include "gui/util/string.h"
 #include "help_mp.h"
 #include "mpcommon.h"
 #include "stream/stream.h"

Modified: trunk/gui/ui/gtk/preferences.c
==============================================================================
--- trunk/gui/ui/gtk/preferences.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/gtk/preferences.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -44,6 +44,7 @@
 #include "gui/interface.h"
 #include "gui/ui/gmplayer.h"
 #include "gui/ui/widgets.h"
+#include "gui/util/string.h"
 #include "preferences.h"
 #include "fileselect.h"
 #include "tools.h"

Modified: trunk/gui/ui/gtk/url.c
==============================================================================
--- trunk/gui/ui/gtk/url.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/gtk/url.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -32,6 +32,7 @@
 #include "gui/app.h"
 #include "gui/ui/gmplayer.h"
 #include "gui/ui/widgets.h"
+#include "gui/util/string.h"
 #include "help_mp.h"
 
 GtkWidget * URL = NULL;

Modified: trunk/gui/ui/main.c
==============================================================================
--- trunk/gui/ui/main.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/ui/main.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -29,6 +29,7 @@
 #include "gui/app.h"
 #include "gui/skin/font.h"
 #include "gui/skin/skin.h"
+#include "gui/util/string.h"
 #include "gui/wm/ws.h"
 
 #include "help_mp.h"

Modified: trunk/gui/util/string.c
==============================================================================
--- trunk/gui/util/string.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/util/string.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -16,6 +16,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "string.h"
 
 char *strlower(char *in)
@@ -92,3 +94,39 @@ char *decomment(char *in)
 
     return in;
 }
+
+char *gstrchr(const char *str, int c)
+{
+    if (!str)
+        return NULL;
+
+    return strchr(str, c);
+}
+
+int gstrcmp(const char *a, const char *b)
+{
+    if (!a && !b)
+        return 0;
+    if (!a || !b)
+        return -1;
+
+    return strcmp(a, b);
+}
+
+int gstrncmp(const char *a, const char *b, int n)
+{
+    if (!a && !b)
+        return 0;
+    if (!a || !b)
+        return -1;
+
+    return strncmp(a, b, n);
+}
+
+char *gstrdup(const char *str)
+{
+    if (!str)
+        return NULL;
+
+    return strdup(str);
+}

Modified: trunk/gui/util/string.h
==============================================================================
--- trunk/gui/util/string.h	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/util/string.h	Thu Jul  7 10:32:10 2011	(r33825)
@@ -20,6 +20,10 @@
 #define MPLAYER_GUI_STRING_H
 
 char *decomment(char *in);
+char *gstrchr(const char *str, int c);
+int gstrcmp(const char *a, const char *b);
+char *gstrdup(const char *str);
+int gstrncmp(const char *a, const char *b, int n);
 char *strlower(char *in);
 char *strswap(char *in, char from, char to);
 char *trim(char *in);

Modified: trunk/gui/win32/interface.c
==============================================================================
--- trunk/gui/win32/interface.c	Thu Jul  7 01:35:39 2011	(r33824)
+++ trunk/gui/win32/interface.c	Thu Jul  7 10:32:10 2011	(r33825)
@@ -90,6 +90,12 @@ int parse_filename(char *file, play_tree
     return 0;
 }
 
+char *gstrdup(const char *str)
+{
+    if (!str) return NULL;
+    return strdup(str);
+}
+
 /**
  * \brief this actually creates a new list containing only one element...
  */
@@ -108,12 +114,6 @@ void gaddlist( char ***list, const char 
     (*list)[1] = NULL;
 }
 
-char *gstrdup(const char *str)
-{
-    if (!str) return NULL;
-    return strdup(str);
-}
-
 /**
  * \brief this replaces a string starting with search by replace.
  * If not found, replace is appended.


More information about the MPlayer-cvslog mailing list