Simplify code reading.
authorAntoine Cellerier <dionoea@videolan.org>
Wed, 2 Apr 2008 20:43:29 +0000 (22:43 +0200)
committerAntoine Cellerier <dionoea@videolan.org>
Wed, 2 Apr 2008 20:43:29 +0000 (22:43 +0200)
modules/misc/lua/vlc.c

index 4a7e6e7..624a3e9 100644 (file)
@@ -405,39 +405,44 @@ static int file_compare( const char **a, const char **b )
 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
                      char **ppsz_dir_list )
 {
 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
                      char **ppsz_dir_list )
 {
-    if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP "lua" DIR_SEP "%s",
+    int i = 0;
+    if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
                    p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
         return VLC_ENOMEM;
                    p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
         return VLC_ENOMEM;
+    i++;
 
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
     {
         const char *psz_vlcpath = config_GetDataDir();
 
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
     {
         const char *psz_vlcpath = config_GetDataDir();
-        if( asprintf( &ppsz_dir_list[1], "%s" DIR_SEP "lua" DIR_SEP "%s",
+        if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
+        i++;
 
 
-        if( asprintf( &ppsz_dir_list[2], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
+        if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "share" DIR_SEP "lua" DIR_SEP "%s",
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
                       psz_vlcpath, luadirname )  < 0 )
             return VLC_ENOMEM;
+        i++;
     }
 #   else
     }
 #   else
-    if( asprintf( &ppsz_dir_list[1],
+    if( asprintf( &ppsz_dir_list[i],
                   "share" DIR_SEP "lua" DIR_SEP "%s", luadirname ) < 0 )
         return VLC_ENOMEM;
 
 #   ifdef HAVE_SYS_STAT_H
     {
         struct stat stat_info;
                   "share" DIR_SEP "lua" DIR_SEP "%s", luadirname ) < 0 )
         return VLC_ENOMEM;
 
 #   ifdef HAVE_SYS_STAT_H
     {
         struct stat stat_info;
-        if( ( utf8_stat( ppsz_dir_list[1], &stat_info ) == -1 )
+        if( ( utf8_stat( ppsz_dir_list[i], &stat_info ) == -1 )
             || !S_ISDIR( stat_info.st_mode ) )
         {
             || !S_ISDIR( stat_info.st_mode ) )
         {
-            free(ppsz_dir_list[1]);
-            if( asprintf( &ppsz_dir_list[1], "%s" DIR_SEP "lua" DIR_SEP "%s",
+            free(ppsz_dir_list[i]);
+            if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
                           config_GetDataDir (), luadirname ) < 0 )
                 return VLC_ENOMEM;
         }
     }
 #   endif
                           config_GetDataDir (), luadirname ) < 0 )
                 return VLC_ENOMEM;
         }
     }
 #   endif
+    i++;
 #   endif
     return VLC_SUCCESS;
 }
 #   endif
     return VLC_SUCCESS;
 }