Mercurial > mplayer.hg
changeset 33737:71c29e8ec68f
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.
author | ib |
---|---|
date | Thu, 07 Jul 2011 08:32:10 +0000 |
parents | a5a54c7a15ce |
children | 998f94e62a61 |
files | gui/cfg.c gui/interface.c gui/interface.h gui/ui/actions.c gui/ui/gtk/equalizer.c gui/ui/gtk/fileselect.c gui/ui/gtk/preferences.c gui/ui/gtk/url.c gui/ui/main.c gui/util/string.c gui/util/string.h gui/win32/interface.c |
diffstat | 12 files changed, 56 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/cfg.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/cfg.c Thu Jul 07 08:32:10 2011 +0000 @@ -22,6 +22,7 @@ #include "cfg.h" #include "interface.h" +#include "util/string.h" #include "config.h" #include "help_mp.h"
--- a/gui/interface.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/interface.c Thu Jul 07 08:32:10 2011 +0000 @@ -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 @@ 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);
--- a/gui/interface.h Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/interface.h Thu Jul 07 08:32:10 2011 +0000 @@ -227,9 +227,6 @@ 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);
--- a/gui/ui/actions.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/actions.c Thu Jul 07 08:32:10 2011 +0000 @@ -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"
--- a/gui/ui/gtk/equalizer.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/gtk/equalizer.c Thu Jul 07 08:32:10 2011 +0000 @@ -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"
--- a/gui/ui/gtk/fileselect.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/gtk/fileselect.c Thu Jul 07 08:32:10 2011 +0000 @@ -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"
--- a/gui/ui/gtk/preferences.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/gtk/preferences.c Thu Jul 07 08:32:10 2011 +0000 @@ -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"
--- a/gui/ui/gtk/url.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/gtk/url.c Thu Jul 07 08:32:10 2011 +0000 @@ -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;
--- a/gui/ui/main.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/ui/main.c Thu Jul 07 08:32:10 2011 +0000 @@ -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"
--- a/gui/util/string.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/util/string.c Thu Jul 07 08:32:10 2011 +0000 @@ -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 @@ 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); +}
--- a/gui/util/string.h Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/util/string.h Thu Jul 07 08:32:10 2011 +0000 @@ -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);
--- a/gui/win32/interface.c Wed Jul 06 23:35:39 2011 +0000 +++ b/gui/win32/interface.c Thu Jul 07 08:32:10 2011 +0000 @@ -90,6 +90,12 @@ 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 @@ (*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.