[vlc-devel] commit: Lua SD: fix for scripts without a description and ".luac" files ( Fabio Ritrovato )

git version control git at videolan.org
Mon Feb 8 21:23:24 CET 2010


vlc | branch: master | Fabio Ritrovato <sephiroth87 at videolan.org> | Mon Feb  8 21:24:14 2010 +0100| [2fcddc868bfe74a9786c0ae71926e722ebb7b872] | committer: Fabio Ritrovato 

Lua SD: fix for scripts without a description and ".luac" files

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

 modules/misc/lua/vlc.c |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index f76b7fe..8aec82c 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -602,17 +602,39 @@ static int vlc_sd_probe_Open( vlc_object_t *obj )
                     char *temp = strchr( description, '\n' );
                     if( temp )
                         *temp = '\0';
-                    *(*ppsz_file + strlen(*ppsz_file) - 4 )= '\0';
+                    temp = strchr( *ppsz_file, '.' );
+                    if( temp )
+                        *temp = '\0';
+                    char *psz_longname;
+                    if( !strncmp( description, "--SD_Description=", 17 ) )
+                    {
+                        if( !( psz_longname = strdup( description + 17 ) ) )
+                        {
+                            fclose( fd );
+                            free( psz_filename );
+                            goto error;
+                        }
+                    }
+                    else
+                    {
+                        if( !( psz_longname = strdup( *ppsz_file ) ) )
+                        {
+                            fclose( fd );
+                            free( psz_filename );
+                            goto error;
+                        }
+                    }
                     if( asprintf( &psz_name, "lua{sd=%s,longname=%s}",
-                                  *ppsz_file, description + 17 ) < 0 )
+                                  *ppsz_file, psz_longname ) < 0 )
                     {
                         fclose( fd );
                         free( psz_filename );
+                        free( psz_longname );
                         goto error;
                     }
-                    vlc_sd_probe_Add( probe, psz_name,
-                                      description + 17 );
+                    vlc_sd_probe_Add( probe, psz_name, psz_longname );
                     free( psz_name );
+                    free( psz_longname );
                 }
                 fclose( fd );
             }




More information about the vlc-devel mailing list