Commit 1ef36a70 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Merge functional code from get_word() and get_word_sep() into a single

function, since they both do approximately the same thing. At the same time,
remove redir_isspace() altogether since code elsewhere (including
get_word_sep()) uses strchr() for the same purpose. See summary in "[PATCH]
rtsp.c small cleanups" thread.

Originally committed as revision 18122 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 7e726132
...@@ -57,11 +57,8 @@ static int rtsp_probe(AVProbeData *p) ...@@ -57,11 +57,8 @@ static int rtsp_probe(AVProbeData *p)
return 0; return 0;
} }
static int redir_isspace(int c) #define SPACE_CHARS " \t\r\n"
{ #define redir_isspace(c) strchr(SPACE_CHARS, c)
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
static void skip_spaces(const char **pp) static void skip_spaces(const char **pp)
{ {
const char *p; const char *p;
...@@ -71,15 +68,13 @@ static void skip_spaces(const char **pp) ...@@ -71,15 +68,13 @@ static void skip_spaces(const char **pp)
*pp = p; *pp = p;
} }
static void get_word_sep(char *buf, int buf_size, const char *sep, static void get_word_until_chars(char *buf, int buf_size,
const char **pp) const char *sep, const char **pp)
{ {
const char *p; const char *p;
char *q; char *q;
p = *pp; p = *pp;
if (*p == '/')
p++;
skip_spaces(&p); skip_spaces(&p);
q = buf; q = buf;
while (!strchr(sep, *p) && *p != '\0') { while (!strchr(sep, *p) && *p != '\0') {
...@@ -92,22 +87,16 @@ static void get_word_sep(char *buf, int buf_size, const char *sep, ...@@ -92,22 +87,16 @@ static void get_word_sep(char *buf, int buf_size, const char *sep,
*pp = p; *pp = p;
} }
static void get_word(char *buf, int buf_size, const char **pp) static void get_word_sep(char *buf, int buf_size, const char *sep,
const char **pp)
{ {
const char *p; if (**pp == '/') (*pp)++;
char *q; get_word_until_chars(buf, buf_size, sep, pp);
}
p = *pp; static void get_word(char *buf, int buf_size, const char **pp)
skip_spaces(&p); {
q = buf; get_word_until_chars(buf, buf_size, SPACE_CHARS, pp);
while (!redir_isspace(*p) && *p != '\0') {
if ((q - buf) < buf_size - 1)
*q++ = *p;
p++;
}
if (buf_size > 0)
*q = '\0';
*pp = p;
} }
/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other /* parse the rtpmap description: <codec_name>/<clock_rate>[/<other
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment