[vlc-commits] Reimplement NumInRange without strtol

Hugo Beauzée-Luyssen git at videolan.org
Wed Mar 11 10:38:40 CET 2015


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Mar 11 10:35:22 2015 +0100| [e85242dd3b1888bba954cd4b8562117dcf9b668f] | committer: Jean-Baptiste Kempf

Reimplement NumInRange without strtol

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e85242dd3b1888bba954cd4b8562117dcf9b668f
---

 modules/stream_out/duplicate.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/stream_out/duplicate.c b/modules/stream_out/duplicate.c
index f22b3b0..e51d9c1 100644
--- a/modules/stream_out/duplicate.c
+++ b/modules/stream_out/duplicate.c
@@ -307,7 +307,14 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
  *****************************************************************************/
 static bool NumInRange( const char *psz_range, int i_num )
 {
-    return true;
+    int beginRange, endRange;
+    int res = sscanf(psz_range, "%d-%d", &beginRange, &endRange);
+    if (res == 0)
+        return false;
+    else if (res == 1)
+        return beginRange == i_num;
+    return (i_num >= beginRange && i_num <= endRange)
+        || (beginRange > endRange && (i_num <= beginRange && i_num >= endRange));
 }
 
 static bool ESSelected( const es_format_t *fmt, char *psz_select )



More information about the vlc-commits mailing list