]> git.sesse.net Git - vlc/commitdiff
Lua SD: fix for scripts without a description and ".luac" files
authorFabio Ritrovato <sephiroth87@videolan.org>
Mon, 8 Feb 2010 20:24:14 +0000 (21:24 +0100)
committerFabio Ritrovato <sephiroth87@videolan.org>
Mon, 8 Feb 2010 20:24:27 +0000 (21:24 +0100)
modules/misc/lua/vlc.c

index f76b7fe2ff130ccf6c5465d38f650929eaaae6b9..8aec82c7fa15d6253992d9dcb2bfdffce5048e68 100644 (file)
@@ -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 );
             }