comparison mplayer.c @ 25790:6aad76cd84d3

Fix auto-sub code to support filenames with any extension length.
author ulion
date Sun, 20 Jan 2008 15:39:13 +0000
parents 304fc0bbefe1
children eb338d06c638
comparison
equal deleted inserted replaced
25789:5cdba0d1c4cf 25790:6aad76cd84d3
2893 if (vobsub_name){ 2893 if (vobsub_name){
2894 vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec); 2894 vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec);
2895 if(vo_vobsub==NULL) 2895 if(vo_vobsub==NULL)
2896 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub, 2896 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,
2897 filename_recode(vobsub_name)); 2897 filename_recode(vobsub_name));
2898 }else if(sub_auto && filename && (strlen(filename)>=5)){ 2898 } else if (sub_auto && filename){
2899 /* try to autodetect vobsub from movie filename ::atmos */ 2899 /* try to autodetect vobsub from movie filename ::atmos */
2900 char *buf = malloc((strlen(filename)-3)),*psub; 2900 char *buf = strdup(filename), *psub;
2901 memset(buf,0,strlen(filename)-3); // make sure string is terminated 2901 char *pdot = strrchr(buf, '.');
2902 strncpy(buf, filename, strlen(filename)-4); 2902 char *pslash = strrchr(buf, '/');
2903 #ifdef WIN32
2904 if (!pslash) pslash = strrchr(buf, '\\');
2905 #endif
2906 if (pdot && (!pslash || pdot > pslash))
2907 *pdot = '\0';
2903 vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec); 2908 vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec);
2904 /* try from ~/.mplayer/sub */ 2909 /* try from ~/.mplayer/sub */
2905 if(!vo_vobsub && (psub = get_path( "sub/" ))) { 2910 if(!vo_vobsub && (psub = get_path( "sub/" ))) {
2906 char *bname; 2911 char *bname;
2907 int l; 2912 int l;