completion: do not duplicate non-escaped strings
Signed-off-by: Sergei Trofimovich <st@anti-virus.by>
Этот коммит содержится в:
родитель
09cdc11c3c
Коммит
4ecef05511
@ -73,9 +73,8 @@ static const char * show_c_flags(INPUT_COMPLETE_FLAGS flags)
|
|||||||
#endif /* DO_CMPLETION_DEBUG */
|
#endif /* DO_CMPLETION_DEBUG */
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
filename_completion_function (const char *_text, int state, INPUT_COMPLETE_FLAGS flags)
|
filename_completion_function (const char * text, int state, INPUT_COMPLETE_FLAGS flags)
|
||||||
{
|
{
|
||||||
char *text;
|
|
||||||
static DIR *directory;
|
static DIR *directory;
|
||||||
static char *filename = NULL;
|
static char *filename = NULL;
|
||||||
static char *dirname = NULL;
|
static char *dirname = NULL;
|
||||||
@ -87,10 +86,22 @@ filename_completion_function (const char *_text, int state, INPUT_COMPLETE_FLAGS
|
|||||||
|
|
||||||
SHOW_C_CTX("filename_completion_function");
|
SHOW_C_CTX("filename_completion_function");
|
||||||
|
|
||||||
if (_text && (flags & INPUT_COMPLETE_SHELL_ESC))
|
if (text && (flags & INPUT_COMPLETE_SHELL_ESC))
|
||||||
text = shell_unescape (_text);
|
{
|
||||||
else
|
char * u_text;
|
||||||
text = g_strdup (_text);
|
char * result;
|
||||||
|
char * e_result;
|
||||||
|
|
||||||
|
u_text = shell_unescape (text);
|
||||||
|
|
||||||
|
result = filename_completion_function (u_text, state, flags & (~INPUT_COMPLETE_SHELL_ESC));
|
||||||
|
g_free (u_text);
|
||||||
|
|
||||||
|
e_result = shell_escape (result);
|
||||||
|
g_free (result);
|
||||||
|
|
||||||
|
return e_result;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we're starting the match process, initialize us a bit. */
|
/* If we're starting the match process, initialize us a bit. */
|
||||||
if (!state){
|
if (!state){
|
||||||
@ -212,13 +223,6 @@ filename_completion_function (const char *_text, int state, INPUT_COMPLETE_FLAGS
|
|||||||
if (isdir)
|
if (isdir)
|
||||||
strcat (temp, PATH_SEP_STR);
|
strcat (temp, PATH_SEP_STR);
|
||||||
|
|
||||||
if (temp && (flags & INPUT_COMPLETE_SHELL_ESC))
|
|
||||||
{
|
|
||||||
char *temp2 = temp;
|
|
||||||
temp = shell_escape(temp);
|
|
||||||
g_free(temp2);
|
|
||||||
}
|
|
||||||
g_free(text);
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user