summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--audio/filter/af.c9
-rwxr-xr-xconfigure15
-rw-r--r--core/bstr.c13
-rw-r--r--core/bstr.h1
-rw-r--r--core/command.c14
-rw-r--r--demux/mf.c11
-rw-r--r--osdep/strsep.c58
-rw-r--r--osdep/strsep.h30
9 files changed, 37 insertions, 115 deletions
diff --git a/Makefile b/Makefile
index 4bc2492768..304bb34ad1 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,6 @@ SOURCES-$(MPG123) += audio/decode/ad_mpg123.c
SOURCES-$(NEED_GETTIMEOFDAY) += osdep/gettimeofday.c
SOURCES-$(NEED_GLOB) += osdep/glob-win.c
SOURCES-$(NEED_SHMEM) += osdep/shmem.c
-SOURCES-$(NEED_STRSEP) += osdep/strsep.c
SOURCES-$(NETWORKING) += stream/stream_netstream.c \
stream/asf_mmst_streaming.c \
stream/asf_streaming.c \
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 1f3e446821..8afedbcfe5 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "osdep/strsep.h"
#include "af.h"
@@ -129,7 +128,13 @@ static struct af_instance* af_create(struct af_stream* s, const char* name_with_
memset(new,0,sizeof(struct af_instance));
// Check for commandline parameters
- strsep(&cmdline, "=");
+ char *skip = strstr(cmdline, "=");
+ if (skip) {
+ *skip = '\0'; // for name
+ cmdline = skip + 1;
+ } else {
+ cmdline = NULL;
+ }
// Find filter from name
if(NULL == (new->info=af_find(name)))
diff --git a/configure b/configure
index f87c45199d..365826f5d8 100755
--- a/configure
+++ b/configure
@@ -1617,19 +1617,6 @@ fi
echores "$_shm"
-echocheck "strsep()"
-_strsep=no
-statement_check string.h 'char *s = "Hello, world!"; strsep(&s, ",")' && _strsep=yes
-if test "$_strsep" = yes ; then
- def_strsep='#define HAVE_STRSEP 1'
- need_strsep=no
-else
- def_strsep='#undef HAVE_STRSEP'
- need_strsep=yes
-fi
-echores "$_strsep"
-
-
echocheck "POSIX select()"
cat > $TMPC << EOF
#include <stdio.h>
@@ -3110,7 +3097,6 @@ $(mak_enable "$subarch_all" "$subarch" ARCH)
NEED_GLOB = $need_glob
NEED_SHMEM = $need_shmem
-NEED_STRSEP = $need_strsep
# features
ALSA = $_alsa
@@ -3246,7 +3232,6 @@ $def_posix_select
$def_select
$def_setmode
$def_shm
-$def_strsep
$def_sysi86
$def_sysi86_iv
$def_termcap
diff --git a/core/bstr.c b/core/bstr.c
index 5d8a47e9ac..a472fbfb02 100644
--- a/core/bstr.c
+++ b/core/bstr.c
@@ -121,6 +121,19 @@ struct bstr bstr_split(struct bstr str, const char *sep, struct bstr *rest)
return bstr_splice(str, 0, end);
}
+// Unlike with bstr_split(), tok is a string, and not a set of char.
+// If tok is in str, return true, and: concat(out_left, tok, out_right) == str
+// Otherwise, return false, and set out_left==str, out_right==""
+bool bstr_split_tok(bstr str, const char *tok, bstr *out_left, bstr *out_right)
+{
+ bstr bsep = bstr0(tok);
+ int pos = bstr_find(str, bsep);
+ if (pos < 0)
+ pos = str.len;
+ *out_left = bstr_splice(str, 0, pos);
+ *out_right = bstr_cut(str, pos + bsep.len);
+ return pos != str.len;
+}
struct bstr bstr_splice(struct bstr str, int start, int end)
{
diff --git a/core/bstr.h b/core/bstr.h
index dfe6f3a556..bcac6cdba3 100644
--- a/core/bstr.h
+++ b/core/bstr.h
@@ -65,6 +65,7 @@ struct bstr *bstr_splitlines(void *talloc_ctx, struct bstr str);
struct bstr bstr_lstrip(struct bstr str);
struct bstr bstr_strip(struct bstr str);
struct bstr bstr_split(struct bstr str, const char *sep, struct bstr *rest);
+bool bstr_split_tok(bstr str, const char *tok, bstr *out_left, bstr *out_right);
struct bstr bstr_splice(struct bstr str, int start, int end);
long long bstrtoll(struct bstr str, struct bstr *rest, int base);
double bstrtod(struct bstr str, struct bstr *rest);
diff --git a/core/command.c b/core/command.c
index 1e4ccd88bc..bad1543224 100644
--- a/core/command.c
+++ b/core/command.c
@@ -51,7 +51,6 @@
#include "audio/filter/af.h"
#include "video/decode/dec_video.h"
#include "audio/decode/dec_audio.h"
-#include "osdep/strsep.h"
#include "sub/spudec.h"
#include "core/path.h"
#include "sub/ass_mp.h"
@@ -2266,16 +2265,19 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (!sh_audio)
break;
char *af_args = strdup(cmd->args[0].v.s);
- char *af_commands = af_args;
- char *af_command;
+ bstr af_commands = bstr0(af_args);
struct af_instance *af;
- while ((af_command = strsep(&af_commands, ",")) != NULL) {
+ while (af_commands.len) {
+ bstr af_command;
+ bstr_split_tok(af_commands, ",", &af_command, &af_commands);
+ char *af_command0 = bstrdup0(NULL, af_command);
if (cmd->id == MP_CMD_AF_DEL) {
- af = af_get(mpctx->mixer.afilter, af_command);
+ af = af_get(mpctx->mixer.afilter, af_command0);
if (af != NULL)
af_remove(mpctx->mixer.afilter, af);
} else
- af_add(mpctx->mixer.afilter, af_command);
+ af_add(mpctx->mixer.afilter, af_command0);
+ talloc_free(af_command0);
}
reinit_audio_chain(mpctx);
free(af_args);
diff --git a/demux/mf.c b/demux/mf.c
index 6ab23b36e9..daeb6baa79 100644
--- a/demux/mf.c
+++ b/demux/mf.c
@@ -35,7 +35,6 @@
#else
#include "osdep/glob.h"
#endif
-#include "osdep/strsep.h"
#include "core/mp_msg.h"
#include "stream/stream.h"
@@ -91,9 +90,14 @@ mf_t* open_mf_pattern(char * filename)
if( strchr( filename,',') )
{
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename );
+ bstr bfilename = bstr0(filename);
- while ( ( fname=strsep( &filename,"," ) ) )
+ while (bfilename.len)
{
+ bstr bfname;
+ bstr_split_tok(bfilename, ",", &bfname, &bfilename);
+ char *fname = bstrdup0(NULL, bfname);
+
if ( !mp_path_exists( fname ) )
{
mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
@@ -101,10 +105,11 @@ mf_t* open_mf_pattern(char * filename)
else
{
mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
- mf->names[mf->nr_of_files]=strdup( fname );
+ mf->names[mf->nr_of_files] = strdup(fname);
// mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
mf->nr_of_files++;
}
+ talloc_free(fname);
}
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
diff --git a/osdep/strsep.c b/osdep/strsep.c
deleted file mode 100644
index 3f911ac0e7..0000000000
--- a/osdep/strsep.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * strsep implementation for systems that do not have it in libc
- *
- * 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 <string.h>
-
-#include "config.h"
-#include "strsep.h"
-
-char *strsep(char **stringp, const char *delim) {
- char *begin, *end;
-
- begin = *stringp;
- if(begin == NULL)
- return NULL;
-
- if(delim[0] == '\0' || delim[1] == '\0') {
- char ch = delim[0];
-
- if(ch == '\0')
- end = NULL;
- else {
- if(*begin == ch)
- end = begin;
- else if(*begin == '\0')
- end = NULL;
- else
- end = strchr(begin + 1, ch);
- }
- }
- else
- end = strpbrk(begin, delim);
-
- if(end) {
- *end++ = '\0';
- *stringp = end;
- }
- else
- *stringp = NULL;
-
- return begin;
-}
diff --git a/osdep/strsep.h b/osdep/strsep.h
deleted file mode 100644
index fbd377f084..0000000000
--- a/osdep/strsep.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * strsep implementation for systems that do not have it in libc
- *
- * 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_STRSEP_H
-#define MPLAYER_STRSEP_H
-
-#include <string.h>
-#include "config.h"
-
-#ifndef HAVE_STRSEP
-char *strsep(char **stringp, const char *delim);
-#endif
-
-#endif /* MPLAYER_STRSEP_H */