# HG changeset patch # User ulion # Date 1200843553 0 # Node ID 6aad76cd84d3fb170605a62ba05a8ff8a886729d # Parent 5cdba0d1c4cf6916272997ed081306c127f0510e Fix auto-sub code to support filenames with any extension length. diff -r 5cdba0d1c4cf -r 6aad76cd84d3 mplayer.c --- a/mplayer.c Sun Jan 20 12:57:53 2008 +0000 +++ b/mplayer.c Sun Jan 20 15:39:13 2008 +0000 @@ -2895,11 +2895,16 @@ if(vo_vobsub==NULL) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub, filename_recode(vobsub_name)); - }else if(sub_auto && filename && (strlen(filename)>=5)){ + } else if (sub_auto && filename){ /* try to autodetect vobsub from movie filename ::atmos */ - char *buf = malloc((strlen(filename)-3)),*psub; - memset(buf,0,strlen(filename)-3); // make sure string is terminated - strncpy(buf, filename, strlen(filename)-4); + char *buf = strdup(filename), *psub; + char *pdot = strrchr(buf, '.'); + char *pslash = strrchr(buf, '/'); +#ifdef WIN32 + if (!pslash) pslash = strrchr(buf, '\\'); +#endif + if (pdot && (!pslash || pdot > pslash)) + *pdot = '\0'; vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec); /* try from ~/.mplayer/sub */ if(!vo_vobsub && (psub = get_path( "sub/" ))) {