[vlc-devel] commit: Simplify code reading. (Antoine Cellerier )

git version control git at videolan.org
Wed Apr 2 23:43:43 CEST 2008


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Wed Apr  2 22:43:29 2008 +0200| [aae60936d25a41b92b4827c2c7b32ee2b3b5266c]

Simplify code reading.

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

 modules/misc/lua/vlc.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index 4a7e6e7..624a3e9 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -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 )
 {
-    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;
+    i++;
 
 #   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;
+        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;
+        i++;
     }
 #   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;
-        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 ) )
         {
-            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
+    i++;
 #   endif
     return VLC_SUCCESS;
 }




More information about the vlc-devel mailing list