Ticket #46748: patch-vlc-for-macports.diff

File patch-vlc-for-macports.diff, 5.8 KB (added by RJVB (René Bertin), 10 years ago)
  • modules/lua/vlc.c

    diff --git modules/lua/vlc.c modules/lua/vlc.c
    index 14b5520..92668f1 100644
    int vlclua_dir_list( const char *luadirname, char ***pppsz_dir_list ) 
    234234            i++;
    235235
    236236#if defined(__APPLE__)
    237         if( likely(asprintf( &ppsz_dir_list[i],
     237        if( strcasestr (psz_datapath, "/share") == NULL
     238            && likely(asprintf( &ppsz_dir_list[i],
    238239                             "%s"DIR_SEP"share"DIR_SEP"lua"DIR_SEP"%s",
    239240                             psz_datapath, luadirname ) != -1) )
    240241            i++;
     242        // When installed through MacPorts (or Fink, or HomeBrew, or...?) we do have
     243        // meta/reader under LibDir/lua (/opt/local/lib/vlc/lua for MacPorts's standard install prefix)
     244        // so we add that location at the end.
     245        char *psz_libpath = config_GetLibDir();
     246        if( likely(psz_libpath != NULL) )
     247        {
     248            if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
     249                                 psz_libpath, luadirname ) != -1) )
     250                i++;
     251            free( psz_libpath );
     252        }
    241253#endif
    242254        free( psz_datapath );
    243255    }
  • src/darwin/dirs.c

    diff --git src/darwin/dirs.c src/darwin/dirs.c
    index 83c27a4..7e8b0cb 100644
     
    4242# define MAXPATHLEN 1024
    4343#endif
    4444
     45// this is set to true in config_GetLibDir() if it detects we're installed
     46// in a (linux-specific) posix way.
     47static int libDirIsPosix = FALSE;
     48
     49// 20150205: we should do case-insensitive filename comparisons. HFS is case-insensitive by default,
     50// and while it strives to preserve case there is no guarantee that case folding will never occur,
     51// especially in directory components.
     52
    4553static char *config_GetLibPath (void)
    4654{
    4755    /* Get the full program path and name */
    static char *config_GetLibPath (void) 
    4957    for (unsigned i = 0; i < _dyld_image_count(); i++)
    5058    {
    5159        const char *psz_img_name = _dyld_get_image_name(i);
    52         const char *p = strstr( psz_img_name, "VLCKit.framework/Versions/" );
     60        const char *p = strcasestr( psz_img_name, "VLCKit.framework/Versions/" );
    5361
    5462        /* Check for "VLCKit.framework/Versions/Current/VLCKit",
    5563         * as well as "VLCKit.framework/Versions/A/VLCKit" and
    static char *config_GetLibPath (void) 
    6169            p += strcspn( p, "/" );
    6270
    6371            /* If the string ends with VLC then we've found a winner */
    64             if ( !strcmp( p, "/VLCKit" ) )
     72            if ( !strcasecmp( p, "/VLCKit" ) )
    6573                return strdup( psz_img_name );
    6674        }
    6775
    68         /* Do we end by "VLC"? If so we are the legacy VLC.app that doesn't
     76        /* Do we end in "MacOS/VLC"? If so we are the legacy (?!) VLC.app that doesn't
    6977         * link to VLCKit. */
    7078        size_t len = strlen(psz_img_name);
    71         if( len >= 3 && !strcmp( psz_img_name + len - 3, "VLC") )
     79        if( len >= 9 && !strcasecmp( psz_img_name + len - 9, "MacOS/VLC") )
    7280            return strdup( psz_img_name );
    7381
    74         /* Do we end by "VLC-Plugin"? oh, we must be the NPAPI plugin */
    75         if( len >= 10 && !strcmp( psz_img_name + len - 10, "VLC-Plugin") )
     82        /* Do we end in "VLC-Plugin"? oh, we must be the NPAPI plugin */
     83        if( len >= 10 && !strcasecmp( psz_img_name + len - 10, "VLC-Plugin") )
    7684            return strdup( psz_img_name );
    7785    }
    7886
    79     /* We are not linked to the VLC.framework, let's use dladdr to figure
    80      * libvlc path */
     87    /* We are not linked to the VLC.framework, we'rebreak not VLC.app either,
     88     * so let's use dladdr to figure the libvlc path */
    8189    Dl_info info;
    8290    if( dladdr(system_Init, &info) )
    83         return strdup(dirname( info.dli_fname ));
     91        return strdup(dirname( (char*)info.dli_fname ));
    8492
    8593    char path[MAXPATHLEN+1];
    8694    uint32_t path_len = sizeof(path) - 1;
    char *config_GetLibDir (void) 
    99107        if (p != NULL)
    100108        {
    101109            *p = '\0';
     110            p = strrchr (path, '.');
     111            if (p == NULL || !strcasestr(p, ".app/Contents/MacOS"))
     112            {
     113                // we're NOT running an OS X style app bundle;
     114                // return the Linux/POSIX style LibDir.
     115                free(path);
     116                path = strdup (PKGLIBDIR);
     117                libDirIsPosix = TRUE;
     118            }
     119            else
     120            {
     121                libDirIsPosix = FALSE;
     122            }
    102123            return path;
    103124        }
    104125        free (path);
    char *config_GetDataDir (void) 
    115136        return strdup (path);
    116137
    117138    char *vlcpath = config_GetLibDir ();
    118     char *datadir;
     139    char *datadir = NULL;
    119140
     141    if (libDirIsPosix)
     142    {
     143        // vlcpath should point to something like /opt/local/lib/vlc
     144        // if so, we can chop off the /lib/vlc bit, and then add /share
     145        // like we would otherwise.
     146        char *p = strcasestr (vlcpath, "/lib/");
     147        if (p != NULL)
     148        {
     149            *p = '\0';
     150        }
     151        else
     152        {
     153            // something else ... return PKGDATADIR
     154            free(vlcpath);
     155            datadir = strdup(PKGDATADIR);
     156            return datadir;
     157        }
     158    }
    120159    if (asprintf (&datadir, "%s/share", vlcpath) == -1)
    121160        datadir = NULL;
    122161
  • src/interface/interface.c

    diff --git src/interface/interface.c src/interface/interface.c
    index b1dcfaf..f31a4a5 100644
    int intf_Create( vlc_object_t *p_this, const char *chain ) 
    113113    char *module;
    114114    char *psz_tmp = config_ChainCreate( &module, &p_intf->p_cfg,
    115115                                        psz_parser );
    116     free( psz_tmp );
    117     free( psz_parser );
     116    if (psz_tmp)
     117    {
     118        free( psz_tmp );
     119    }
     120    if (psz_parser)
     121    {
     122        free( psz_parser );
     123    }
    118124    p_intf->p_module = module_need( p_intf, "interface", module, true );
    119125    free(module);
    120126    if( p_intf->p_module == NULL )