summaryrefslogtreecommitdiffstats
path: root/stream/freesdp
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-06 12:25:52 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-06 12:25:52 +0000
commitf030c777b89511639f6d1325804cb5c6d2099e96 (patch)
treef2a76394885fccc1bdec78d0fda831d5589bc537 /stream/freesdp
parenta900d6f59a814bf147713c2ea45fad6f9273aa09 (diff)
downloadmpv-f030c777b89511639f6d1325804cb5c6d2099e96.tar.bz2
mpv-f030c777b89511639f6d1325804cb5c6d2099e96.tar.xz
Simplify NEXT_LINE macro and put most of it in a separate function.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21520 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream/freesdp')
-rw-r--r--stream/freesdp/parser.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/stream/freesdp/parser.c b/stream/freesdp/parser.c
index 476f66caca..16ca9e666a 100644
--- a/stream/freesdp/parser.c
+++ b/stream/freesdp/parser.c
@@ -36,6 +36,21 @@
#include "parserpriv.h"
/**
+ * \brief find the start of the next line
+ * \param c pointer to current position in string
+ * \return pointer to start of next line or NULL if illegal (i.e.
+ * a '\r' is not followed by a '\n'
+ */
+static const char *next_line(const char *c) {
+ c += strcspn(c, "\n\r");
+ if (*c == 0) return c;
+ if (*c == '\r') c++;
+ if (*c == '\n')
+ return c + 1;
+ return NULL;
+}
+
+/**
* Moves the <code>c<code> pointer up to the beginning of the next
* line.
*
@@ -43,22 +58,7 @@
* @retval FSDPE_ILLEGAL_CHARACTER, when an illegal '\r' character
* (not followed by a '\n') is found, returns
*/
-#define NEXT_LINE(c) \
-{ \
- while ((*(c) != '\0') && (*(c) != '\r') && (*(c) != '\n')) { \
- (c)++; \
- } \
- if (*(c) == '\n') { \
- (c)++; \
- } else if (*(c) == '\r') { \
- (c)++; \
- if (*(c) == '\n') { \
- (c)++; \
- } else { \
- return FSDPE_ILLEGAL_CHARACTER; \
- } \
- } \
-}
+#define NEXT_LINE(c) do { if (!(c = next_line(c))) return FSDPE_ILLEGAL_CHARACTER; } while (0);
fsdp_error_t
fsdp_parse (const char *text_description, fsdp_description_t * dsc)