Skip to content

Commit

Permalink
Fix bug causing flood of error messages in terminal when trying to hi…
Browse files Browse the repository at this point in the history
…ghlight an invalid command, reported by Denilson F. de Sa.

darcs-hash:20080204230905-ac50b-0829b69835347e5875656ae735181b724f10de2a.gz
  • Loading branch information
liljencrantz committed Feb 4, 2008
1 parent 3f439e9 commit d7396ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions expand.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
Use unencoded private-use keycodes for internal characters
*/
#define EXPAND_RESERVED 0xf000
/**
End of range reserved for expand
*/
#define EXPAND_RESERVED_END 0xf000f

enum
{
Expand Down
22 changes: 18 additions & 4 deletions highlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,20 @@ static void highlight_param( const wchar_t * buff,
}
}

static int has_expand_reserved( wchar_t *str )
{
while( *str )
{
if( *str >= EXPAND_RESERVED &&
*str <= EXPAND_RESERVED_END )
{
return 1;
}
str++;
}
return 0;
}


void highlight_shell( wchar_t * buff,
int *color,
Expand Down Expand Up @@ -636,10 +650,10 @@ void highlight_shell( wchar_t * buff,
Command. First check that the command actually exists.
*/
cmd = expand_one( context,
wcsdup(tok_last( &tok )),
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);
wcsdup(tok_last( &tok )),
EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES);

if( cmd == 0 )
if( (cmd == 0) || has_expand_reserved( cmd ) )
{
color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR;
}
Expand Down Expand Up @@ -698,7 +712,7 @@ void highlight_shell( wchar_t * buff,
}
tok_set_pos( &tok, mark );
}

if( !is_subcommand )
{
wchar_t *tmp;
Expand Down

0 comments on commit d7396ac

Please sign in to comment.