Mercurial > mplayer.hg
changeset 27086:1d0ac8ff2527
fixes two bugs:
1. doesn't add \ before spaces when showing dirname in interface title.
2. when replace_path() string is to be parsed by input command,
I assume that the path is to be run in shell,
and I do special escaping of 'into \'\\\'\'
(tested useful and ok with geexbox for last 3 years ...)
author | ben |
---|---|
date | Fri, 20 Jun 2008 20:36:05 +0000 |
parents | 34f9f883600d |
children | 42726ce8f60a |
files | libmenu/menu_filesel.c |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libmenu/menu_filesel.c Fri Jun 20 20:31:19 2008 +0000 +++ b/libmenu/menu_filesel.c Fri Jun 20 20:36:05 2008 +0000 @@ -82,7 +82,7 @@ free(entry); } -static char* replace_path(char* title , char* dir) { +static char* replace_path(char* title , char* dir , int escape) { char *p = strstr(title,"%p"); if(p) { int tl = strlen(title); @@ -90,18 +90,29 @@ int t1l = p-title; int l = tl - 2 + dl; char *r, *n, *d = dir; - char term = *(p-1); + if (escape) { do { - if (*d == '\\' || *d == term) + if (*d == '\\') l++; + else if (*d == '\'') /* ' -> \'\\\'\' */ + l+=7; } while (*d++); + } r = malloc(l + 1); n = r + t1l; memcpy(r,title,t1l); do { - if (*dir == '\\' || *dir == term) + if (escape) { + if (*dir == '\\') *n++ = '\\'; + else if (*dir == '\'') { /* ' -> \'\\\'\' */ + *n++ = '\\'; *n++ = '\''; + *n++ = '\\'; *n++ = '\\'; + *n++ = '\\'; *n++ = '\''; + *n++ = '\\'; + } + } } while ((*n++ = *dir++)); if(tl - t1l - 2 > 0) strcpy(n-1,p+2); @@ -219,7 +230,7 @@ free(mpriv->p.title); p = strstr(mpriv->title,"%p"); - mpriv->p.title = replace_path(mpriv->title,mpriv->dir); + mpriv->p.title = replace_path(mpriv->title,mpriv->dir,0); if ((dirp = opendir (mpriv->dir)) == NULL){ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_OpendirError, strerror(errno)); @@ -351,7 +362,7 @@ char *str; char *action = mpriv->p.current->d ? mpriv->dir_action:mpriv->file_action; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); - str = replace_path(action, filename); + str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(str); if (str != action) free(str); @@ -362,7 +373,7 @@ char filename[fname_len]; char *str; sprintf(filename,"%s%s",mpriv->dir,mpriv->p.current->p.txt); - str = replace_path(action, filename); + str = replace_path(action, filename,1); mp_input_parse_and_queue_cmds(str); if(str != action) free(str);