[MPlayer-dev-eng] Trivial subreader fix: compare constant string with memcmp instead of sscanf

Clément Bœsch ubitux at gmail.com
Wed Sep 29 12:26:47 CEST 2010


Hi,

While diving in subreader.c I ran into a strange string comparison. I
think this is more correct. It also allows to get ride of the p variable.

Regards,

-- 
Clément B.
-------------- next part --------------
Index: subreader.c
===================================================================
--- subreader.c	(revision 32401)
+++ subreader.c	(working copy)
@@ -1101,7 +1101,6 @@
 static int sub_autodetect (stream_t* st, int *uses_time, int utf16) {
     char line[LINE_LEN+1];
     int i,j=0;
-    char p;
 
     while (j < 100) {
 	j++;
@@ -1145,7 +1144,7 @@
 		{*uses_time=1;return SUB_PJS;}
 	if (sscanf (line, "FORMAT=%d", &i) == 1)
 		{*uses_time=0; return SUB_MPSUB;}
-	if (sscanf (line, "FORMAT=TIM%c", &p)==1 && p=='E')
+	if (!memcmp(line, "FORMAT=TIME", 11))
 		{*uses_time=1; return SUB_MPSUB;}
 	if (strstr (line, "-->>"))
 		{*uses_time=0; return SUB_AQTITLE;}


More information about the MPlayer-dev-eng mailing list