[MPlayer-cvslog] r33829 - in trunk: Makefile gui/interface.c gui/interface.h gui/ui/gtk/preferences.c gui/util/list.c gui/util/list.h

ib subversion at mplayerhq.hu
Thu Jul 7 12:37:58 CEST 2011


Author: ib
Date: Thu Jul  7 12:37:58 2011
New Revision: 33829

Log:
Create new file list.c for list related functions.

Move gaddlist() and greplace() from interface.c to list.c.

Added:
   trunk/gui/util/list.c
   trunk/gui/util/list.h
Modified:
   trunk/Makefile
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/ui/gtk/preferences.c

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Thu Jul  7 12:16:22 2011	(r33828)
+++ trunk/Makefile	Thu Jul  7 12:37:58 2011	(r33829)
@@ -541,6 +541,7 @@ SRCS_MPLAYER-$(GUI_GTK)      += gui/app.
                                 gui/ui/sub.c \
                                 gui/ui/widgets.c \
                                 gui/util/cut.c \
+                                gui/util/list.c \
                                 gui/util/string.c \
                                 gui/wm/ws.c \
                                 gui/wm/wsxdnd.c \

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Thu Jul  7 12:16:22 2011	(r33828)
+++ trunk/gui/interface.c	Thu Jul  7 12:37:58 2011	(r33829)
@@ -24,6 +24,7 @@
 #include "skin/skin.h"
 #include "ui/gmplayer.h"
 #include "ui/widgets.h"
+#include "util/list.h"
 #include "util/mem.h"
 #include "util/string.h"
 #include "wm/ws.h"
@@ -77,51 +78,6 @@ float gtkEquChannels[6][10];
 
 static int initialized;
 
-/**
- * \brief This actually creates a new list containing only one element...
- */
-void gaddlist(char ***list, const char *entry)
-{
-    int i;
-
-    if (*list) {
-        for (i = 0; (*list)[i]; i++)
-            free((*list)[i]);
-
-        free(*list);
-    }
-
-    *list      = malloc(2 * sizeof(char **));
-    (*list)[0] = gstrdup(entry);
-    (*list)[1] = NULL;
-}
-
-/**
- * \brief This replaces a string starting with search by replace.
- * If not found, replace is appended.
- */
-static void greplace(char ***list, const char *search, const char *replace)
-{
-    int i   = 0;
-    int len = (search ? strlen(search) : 0);
-
-    if (*list) {
-        for (i = 0; (*list)[i]; i++) {
-            if (search && (strncmp((*list)[i], search, len) == 0)) {
-                free((*list)[i]);
-                (*list)[i] = gstrdup(replace);
-                return;
-            }
-        }
-
-        *list = realloc(*list, (i + 2) * sizeof(char *));
-    } else
-        *list = malloc(2 * sizeof(char *));
-
-    (*list)[i]     = gstrdup(replace);
-    (*list)[i + 1] = NULL;
-}
-
 void guiInit(void)
 {
     int i;

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Thu Jul  7 12:16:22 2011	(r33828)
+++ trunk/gui/interface.h	Thu Jul  7 12:37:58 2011	(r33829)
@@ -211,7 +211,6 @@ extern char *fsHistory[fsPersistant_MaxP
 
 extern float gtkEquChannels[6][10];
 
-void gaddlist(char ***list, const char *entry);
 void gmp_msg(int mod, int lev, const char *format, ...);
 void *gtkSet(int cmd, float fparam, void *vparam);
 void guiDone(void);

Modified: trunk/gui/ui/gtk/preferences.c
==============================================================================
--- trunk/gui/ui/gtk/preferences.c	Thu Jul  7 12:16:22 2011	(r33828)
+++ trunk/gui/ui/gtk/preferences.c	Thu Jul  7 12:37:58 2011	(r33829)
@@ -44,6 +44,7 @@
 #include "gui/interface.h"
 #include "gui/ui/gmplayer.h"
 #include "gui/ui/widgets.h"
+#include "gui/util/list.h"
 #include "gui/util/mem.h"
 #include "gui/util/string.h"
 #include "preferences.h"

Added: trunk/gui/util/list.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/gui/util/list.c	Thu Jul  7 12:37:58 2011	(r33829)
@@ -0,0 +1,68 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "list.h"
+#include "string.h"
+
+/**
+ * \brief This actually creates a new list containing only one element...
+ */
+void gaddlist(char ***list, const char *entry)
+{
+    int i;
+
+    if (*list) {
+        for (i = 0; (*list)[i]; i++)
+            free((*list)[i]);
+
+        free(*list);
+    }
+
+    *list      = malloc(2 * sizeof(char **));
+    (*list)[0] = gstrdup(entry);
+    (*list)[1] = NULL;
+}
+
+/**
+ * \brief This replaces a string starting with search by replace.
+ * If not found, replace is appended.
+ */
+void greplace(char ***list, const char *search, const char *replace)
+{
+    int i   = 0;
+    int len = (search ? strlen(search) : 0);
+
+    if (*list) {
+        for (i = 0; (*list)[i]; i++) {
+            if (search && (strncmp((*list)[i], search, len) == 0)) {
+                free((*list)[i]);
+                (*list)[i] = gstrdup(replace);
+                return;
+            }
+        }
+
+        *list = realloc(*list, (i + 2) * sizeof(char *));
+    } else
+        *list = malloc(2 * sizeof(char *));
+
+    (*list)[i]     = gstrdup(replace);
+    (*list)[i + 1] = NULL;
+}

Added: trunk/gui/util/list.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/gui/util/list.h	Thu Jul  7 12:37:58 2011	(r33829)
@@ -0,0 +1,25 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_GUI_LIST_H
+#define MPLAYER_GUI_LIST_H
+
+void gaddlist(char ***list, const char *entry);
+void greplace(char ***list, const char *search, const char *replace);
+
+#endif /* MPLAYER_GUI_LIST_H */


More information about the MPlayer-cvslog mailing list