]> git.sesse.net Git - vlc/blobdiff - src/input/subtitles.c
Compat: relicense strcasestr to LGPL
[vlc] / src / input / subtitles.c
index 3881d2f76ddb088ff06c334010da93a89ec3e55a..ce1c7513e71fc9911582aad84b4be9ba87c65625 100644 (file)
 #include <vlc_fs.h>
 #include <vlc_url.h>
 
-#ifdef HAVE_DIRENT_H
-#   include <dirent.h>
-#endif
-
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
@@ -61,31 +57,33 @@ static const char const sub_exts[][6] = {
     "idx", "sub",  "srt",
     "ssa", "ass",  "smi",
     "utf", "utf8", "utf-8",
-    "txt", "rt",   "aqt",
+    "rt",   "aqt", "txt",
     "usf", "jss",  "cdg",
     "psb", "mpsub","mpl2",
-    "pjs", "dks",
+    "pjs", "dks", "stl",
     ""
 };
 
 static void strcpy_trim( char *d, const char *s )
 {
+    unsigned char c;
+
     /* skip leading whitespace */
-    while( *s && !isalnum(*s) )
+    while( ((c = *s) != '\0') && !isalnum(c) )
     {
         s++;
     }
     for(;;)
     {
         /* copy word */
-        while( *s && isalnum(*s) )
+        while( ((c = *s) != '\0') && isalnum(c) )
         {
-            *d = tolower(*s);
+            *d = tolower(c);
             s++; d++;
         }
         if( *s == 0 ) break;
         /* trim excess whitespace */
-        while( *s && !isalnum(*s) )
+        while( ((c = *s) != '\0') && !isalnum(c) )
         {
             s++;
         }
@@ -97,6 +95,8 @@ static void strcpy_trim( char *d, const char *s )
 
 static void strcpy_strip_ext( char *d, const char *s )
 {
+    unsigned char c;
+
     const char *tmp = strrchr(s, '.');
     if( !tmp )
     {
@@ -105,9 +105,9 @@ static void strcpy_strip_ext( char *d, const char *s )
     }
     else
         strlcpy(d, s, tmp - s + 1 );
-    while( *d )
+    while( (c = *d) != '\0' )
     {
-        *d = tolower(*d);
+        *d = tolower(c);
         d++;
     }
 }
@@ -123,9 +123,11 @@ static void strcpy_get_ext( char *d, const char *s )
 
 static int whiteonly( const char *s )
 {
-    while( *s )
+    unsigned char c;
+
+    while( (c = *s) != '\0' )
     {
-        if( isalnum( *s ) )
+        if( isalnum( c ) )
             return 0;
         s++;
     }
@@ -158,7 +160,7 @@ static int compare_sub_priority( const void *a, const void *b )
     if( p0->priority < p1->priority )
         return 1;
 
-#ifndef UNDER_CE
+#ifdef HAVE_STRCOLL
     return strcoll( p0->psz_fname, p1->psz_fname);
 #else
     return strcmp( p0->psz_fname, p1->psz_fname);