Mercurial > mplayer.hg
changeset 33048:c6d0adf896ea
Move auxiliary string functions into separate file.
(Besides, name parameters more intelligibly.)
author | ib |
---|---|
date | Mon, 28 Mar 2011 15:51:20 +0000 |
parents | 901dc2c4130f |
children | fc7a3f9f74f8 |
files | Makefile gui/skin/font.c gui/skin/skin.c gui/skin/skin.h gui/util/string.c gui/util/string.h |
diffstat | 6 files changed, 87 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Mar 28 13:46:50 2011 +0000 +++ b/Makefile Mon Mar 28 15:51:20 2011 +0000 @@ -541,6 +541,7 @@ gui/skin/font.c \ gui/skin/skin.c \ gui/util/cut.c \ + gui/util/string.c \ gui/wm/ws.c \ gui/wm/wsxdnd.c \
--- a/gui/skin/font.c Mon Mar 28 13:46:50 2011 +0000 +++ b/gui/skin/font.c Mon Mar 28 15:51:20 2011 +0000 @@ -24,6 +24,7 @@ #include "font.h" #include "gui/interface.h" #include "gui/util/cut.h" +#include "gui/util/string.h" #include "skin.h" #include "libavutil/avstring.h"
--- a/gui/skin/skin.c Mon Mar 28 13:46:50 2011 +0000 +++ b/gui/skin/skin.c Mon Mar 28 15:51:20 2011 +0000 @@ -25,6 +25,7 @@ #include "gui/interface.h" #include "gui/mplayer/widgets.h" #include "gui/util/cut.h" +#include "gui/util/string.h" #include "config.h" #include "help_mp.h" @@ -818,43 +819,6 @@ { "menu", cmd_menu } }; -char *strswap(char *in, char what, char whereof) -{ - int i; - - if (!*in) - return NULL; - - for (i = 0; in[i]; i++) - if (in[i] == what) - in[i] = whereof; - - return in; -} - -char *trim(char *in) -{ - int c = 0, id = 0, i; - - if (!*in) - return NULL; - - while (c != (int)strlen(in)) { - if (in[c] == '"') - id = !id; - - if ((in[c] == ' ') && (!id)) { - for (i = 0; i < (int)strlen(in) - c; i++) - in[c + i] = in[c + i + 1]; - continue; - } - - c++; - } - - return in; -} - static char *setname(char *item1, char *item2) { static char fn[512];
--- a/gui/skin/skin.h Mon Mar 28 13:46:50 2011 +0000 +++ b/gui/skin/skin.h Mon Mar 28 15:51:20 2011 +0000 @@ -23,7 +23,5 @@ int skinBPRead(char *fname, txSample *bf); int skinRead(char *dname); -char *strswap(char *in, char what, char whereof); -char *trim(char *in); #endif /* MPLAYER_GUI_SKIN_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/util/string.c Mon Mar 28 15:51:20 2011 +0000 @@ -0,0 +1,59 @@ +/* + * 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 <stddef.h> +#include <string.h> + +#include "string.h" + +char *strswap(char *in, char from, char to) +{ + int i; + + if (!*in) + return NULL; + + for (i = 0; in[i]; i++) + if (in[i] == from) + in[i] = to; + + return in; +} + +char *trim(char *in) +{ + int c = 0, id = 0, i; + + if (!*in) + return NULL; + + while (c != (int)strlen(in)) { + if (in[c] == '"') + id = !id; + + if ((in[c] == ' ') && (!id)) { + for (i = 0; i < (int)strlen(in) - c; i++) + in[c + i] = in[c + i + 1]; + continue; + } + + c++; + } + + return in; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/util/string.h Mon Mar 28 15:51:20 2011 +0000 @@ -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_STRING_H +#define MPLAYER_GUI_STRING_H + +char *strswap(char *in, char from, char to); +char *trim(char *in); + +#endif /* MPLAYER_GUI_STRING_H */