Skip to content

Commit

Permalink
strtol(3) can optionally set errno to EINVAL if no conversion could be
Browse files Browse the repository at this point in the history
performed and FreeBSD (at least) implements thin behaviour.  Add an
explicit test to detect this situation in Dispatcher::parse_params().
(This behaviour difference is not relevant to other uses of strtol()).

This corrects the mishandling of (eg) "CSI m" on FreeBSD.
  • Loading branch information
peterjeremy committed Apr 10, 2012
1 parent d37b1c4 commit 37c86a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/terminal/terminaldispatcher.cc
Expand Up @@ -85,7 +85,7 @@ void Dispatcher::parse_params( void )
if ( endptr == segment_begin ) {
val = -1;
}
if ( errno == 0 ) {
if ( errno == 0 || segment_begin == endptr ) {
parsed_params.push_back( val );
}

Expand All @@ -99,7 +99,7 @@ void Dispatcher::parse_params( void )
if ( endptr == segment_begin ) {
val = -1;
}
if ( errno == 0 ) {
if ( errno == 0 || segment_begin == endptr ) {
parsed_params.push_back( val );
}

Expand Down

2 comments on commit 37c86a9

@wez
Copy link

@wez wez commented on 37c86a9 Apr 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the weird color bleed I experienced this morning with vim on OSX, and also fixes my regular text color in zsh

@wez
Copy link

@wez wez commented on 37c86a9 Apr 11, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also: mobile-shell#110

Please sign in to comment.