[FFmpeg-devel] [PATCH] rtsp.c small cleanups

Ronald S. Bultje rsbultje
Mon Mar 23 20:43:13 CET 2009


Hi,

2009/3/20 Ronald S. Bultje <rsbultje at gmail.com>:
> (2) merge get_word() and get_word_sep() into a general function,
> remove the redir_isspace() function by a macro that calls strchr()

This has a nasty side-effect (issue-919) that strchr(string, '\0')
returns the end of string instead of NULL, and that is sort of not
what I hoped for. As a result of this, redir_isspace('\0') expands to
strchr(" \r\t\n", '\0'); returns the end of the string instead of
NULL. Attached patch fixes that. I don't quite like this solution and
would like to hear if there's anything like strnchr() or so, or a way
to fix strchr() to not go beyond the end-of-string.

Ronald
-------------- next part --------------
Index: ffmpeg-svn/libavformat/rtsp.c
===================================================================
--- ffmpeg-svn.orig/libavformat/rtsp.c	2009-03-23 14:50:35.000000000 -0400
+++ ffmpeg-svn/libavformat/rtsp.c	2009-03-23 14:50:51.000000000 -0400
@@ -55,7 +55,11 @@
 }
 
 #define SPACE_CHARS " \t\r\n"
-#define redir_isspace(c) strchr(SPACE_CHARS, c)
+static int redir_isspace(int c)
+{
+    return c != '\0' && strchr(SPACE_CHARS, c);
+}
+
 static void skip_spaces(const char **pp)
 {
     const char *p;



More information about the ffmpeg-devel mailing list