From 358f412abb7513a906077f1792112b216d75d40f Mon Sep 17 00:00:00 2001 From: axel Date: Thu, 15 Jun 2006 11:00:38 +1000 Subject: [PATCH] Highlight invalid directories red for the cd builtin darcs-hash:20060615010038-ac50b-30ada1c67dcb393390f67cf709e433dafc8801b7.gz --- highlight.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/highlight.c b/highlight.c index 586e7e7e3..336f4b482 100644 --- a/highlight.c +++ b/highlight.c @@ -519,6 +519,7 @@ void highlight_shell( wchar_t * buff, int len; void *context; + wchar_t *cmd=0; if( !buff || !color ) { @@ -545,6 +546,7 @@ void highlight_shell( wchar_t * buff, int last_type = tok_last_type( &tok ); int prev_argc=0; + switch( last_type ) { case TOK_STRING: @@ -570,7 +572,15 @@ void highlight_shell( wchar_t * buff, &color[tok_get_pos( &tok )], pos-tok_get_pos( &tok ), error ); - + + if( cmd && (wcscmp( cmd, L"cd" ) == 0) ) + { + if( !parser_cdpath_get( context, param ) ) + { + color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; + } + } + } else { @@ -579,9 +589,9 @@ void highlight_shell( wchar_t * buff, /* Command. First check that the command actually exists. */ - wchar_t *cmd = expand_one( context, - wcsdup(tok_last( &tok )), - EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES); + cmd = expand_one( context, + wcsdup(tok_last( &tok )), + EXPAND_SKIP_SUBSHELL | EXPAND_SKIP_VARIABLES); if( cmd == 0 ) { @@ -853,7 +863,7 @@ void highlight_shell( wchar_t * buff, wchar_t *tok_begin, *tok_end; wchar_t *token; - + parse_util_token_extent( buff, pos, &tok_begin, &tok_end, 0, 0 ); if( tok_begin ) {