mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix for crash when unescaping a string with unbalanced quotes
Add Mac OS X's default term name to terms for which we know how to set a title
This commit is contained in:
parent
bef046a51a
commit
99000e68b7
6 changed files with 24 additions and 11 deletions
11
common.cpp
11
common.cpp
|
@ -1508,11 +1508,16 @@ wchar_t *unescape( const wchar_t * orig, int flags )
|
|||
return in;
|
||||
}
|
||||
|
||||
void unescape_string(wcstring &str, int escape_special)
|
||||
bool unescape_string(wcstring &str, int escape_special)
|
||||
{
|
||||
bool success = false;
|
||||
wchar_t *result = unescape(str.c_str(), escape_special);
|
||||
str.replace(str.begin(), str.end(), result);
|
||||
free(result);
|
||||
if ( result) {
|
||||
str.replace(str.begin(), str.end(), result);
|
||||
free(result);
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
2
common.h
2
common.h
|
@ -478,7 +478,7 @@ wcstring escape_string( const wcstring &in, int escape_all );
|
|||
wchar_t *unescape( const wchar_t * in,
|
||||
int escape_special );
|
||||
|
||||
void unescape_string( wcstring &str,
|
||||
bool unescape_string( wcstring &str,
|
||||
int escape_special );
|
||||
|
||||
/**
|
||||
|
|
2
fish.cpp
2
fish.cpp
|
@ -278,6 +278,8 @@ static int fish_parse_opt( int argc, char **argv, char **cmd_ptr )
|
|||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
struct stat tmp;
|
||||
stat("----------FISH_HIT_MAIN----------", &tmp);
|
||||
int res=1;
|
||||
char *cmd=0;
|
||||
int my_optind=0;
|
||||
|
|
|
@ -72,18 +72,20 @@ static const wchar_t *highlight_var[] =
|
|||
\return zero it this is not a valid prefix, non-zero otherwise
|
||||
*/
|
||||
// PCA DOES_IO
|
||||
static int is_potential_path( const wcstring &cpath )
|
||||
static bool is_potential_path( const wcstring &cpath )
|
||||
{
|
||||
ASSERT_IS_BACKGROUND_THREAD();
|
||||
|
||||
const wchar_t *unescaped, *in;
|
||||
wcstring cleaned_path;
|
||||
int has_magic = 0;
|
||||
int res = 0;
|
||||
bool res = false;
|
||||
|
||||
wcstring path(cpath);
|
||||
expand_tilde(path);
|
||||
unescape_string(path, 1);
|
||||
if (! unescape_string(path, 1))
|
||||
return false;
|
||||
|
||||
unescaped = path.c_str();
|
||||
|
||||
// debug( 1, L"%ls -> %ls ->%ls", path, tilde, unescaped );
|
||||
|
@ -142,7 +144,7 @@ static int is_potential_path( const wcstring &cpath )
|
|||
|
||||
if( dir_name == L"/" && base_name == L"/" )
|
||||
{
|
||||
res = 1;
|
||||
res = true;
|
||||
}
|
||||
else if( (dir = wopendir( dir_name.c_str() )) )
|
||||
{
|
||||
|
@ -151,7 +153,7 @@ static int is_potential_path( const wcstring &cpath )
|
|||
{
|
||||
if( wcsncmp( base_name.c_str(), base_name.c_str(), base_name.length() ) == 0 )
|
||||
{
|
||||
res = 1;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
2
proc.cpp
2
proc.cpp
|
@ -1113,7 +1113,7 @@ void job_continue (job_t *j, int cont)
|
|||
if( p->pid )
|
||||
{
|
||||
int status = proc_format_status(p->status);
|
||||
|
||||
//wprintf(L"setting status %d for %ls\n", job_get_flag( j, JOB_NEGATE )?!status:status, j->command);
|
||||
proc_set_last_status( job_get_flag( j, JOB_NEGATE )?!status:status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -627,7 +627,11 @@ void reader_write_title()
|
|||
return;
|
||||
}
|
||||
|
||||
if( !contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) )
|
||||
bool recognized = false;
|
||||
recognized = recognized || contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" );
|
||||
recognized = recognized || ! wcsncmp(term, L"xterm-", wcslen(L"xterm-"));
|
||||
|
||||
if( ! recognized )
|
||||
{
|
||||
char *n = ttyname( STDIN_FILENO );
|
||||
|
||||
|
|
Loading…
Reference in a new issue