# HG changeset patch # User rbultje # Date 1237668887 0 # Node ID 1c9751d3065cc0e95c50a35fc8af2d7bff91c01b # Parent fb0b1e68356c9abe6d7eecab2b9ad07198cafba0 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. diff -r fb0b1e68356c -r 1c9751d3065c rtsp.c --- a/rtsp.c Sat Mar 21 20:46:36 2009 +0000 +++ b/rtsp.c Sat Mar 21 20:54:47 2009 +0000 @@ -57,11 +57,8 @@ return 0; } -static int redir_isspace(int c) -{ - return c == ' ' || c == '\t' || c == '\n' || c == '\r'; -} - +#define SPACE_CHARS " \t\r\n" +#define redir_isspace(c) strchr(SPACE_CHARS, c) static void skip_spaces(const char **pp) { const char *p; @@ -71,15 +68,13 @@ *pp = p; } -static void get_word_sep(char *buf, int buf_size, const char *sep, - const char **pp) +static void get_word_until_chars(char *buf, int buf_size, + const char *sep, const char **pp) { const char *p; char *q; p = *pp; - if (*p == '/') - p++; skip_spaces(&p); q = buf; while (!strchr(sep, *p) && *p != '\0') { @@ -92,22 +87,16 @@ *pp = p; } +static void get_word_sep(char *buf, int buf_size, const char *sep, + const char **pp) +{ + if (**pp == '/') (*pp)++; + get_word_until_chars(buf, buf_size, sep, pp); +} + static void get_word(char *buf, int buf_size, const char **pp) { - const char *p; - char *q; - - p = *pp; - skip_spaces(&p); - q = buf; - while (!redir_isspace(*p) && *p != '\0') { - if ((q - buf) < buf_size - 1) - *q++ = *p; - p++; - } - if (buf_size > 0) - *q = '\0'; - *pp = p; + get_word_until_chars(buf, buf_size, SPACE_CHARS, pp); } /* parse the rtpmap description: /[/