@@ -4866,7 +4866,7 @@ check_termcode(
4866
4866
* {tail} can be Esc>\ or STERM
4867
4867
*
4868
4868
* Check for cursor shape response from xterm:
4869
- * {lead}1$r<number > q{tail}
4869
+ * {lead}1$r<digit > q{tail}
4870
4870
*
4871
4871
* {lead} can be <Esc>P or DCS
4872
4872
* {tail} can be Esc>\ or STERM
@@ -4897,35 +4897,46 @@ check_termcode(
4897
4897
break ;
4898
4898
}
4899
4899
}
4900
- else if ((len >= j + 6 && isdigit (argp [3 ]))
4901
- && argp [4 ] == ' '
4902
- && argp [5 ] == 'q' )
4900
+ else
4903
4901
{
4904
- /* cursor shape response */
4905
- i = j + 6 ;
4906
- if (( tp [ i ] == ESC && i + 1 < len && tp [ i + 1 ] == '\\' )
4907
- || tp [ i ] == STERM )
4902
+ /* Probably the cursor shape response. Make sure that "i"
4903
+ * is equal to "len" when there are not sufficient
4904
+ * characters. */
4905
+ for ( i = j + 3 ; i < len ; ++ i )
4908
4906
{
4909
- int number = argp [3 ] - '0' ;
4910
-
4911
- /* 0, 1 = block blink, 2 = block
4912
- * 3 = underline blink, 4 = underline
4913
- * 5 = vertical bar blink, 6 = vertical bar */
4914
- number = number == 0 ? 1 : number ;
4915
- initial_cursor_shape = (number + 1 ) / 2 ;
4916
- /* The blink flag is actually inverted, compared to
4917
- * the value set with T_SH. */
4918
- initial_cursor_shape_blink =
4907
+ if (i - j == 3 && !isdigit (tp [i ]))
4908
+ break ;
4909
+ if (i - j == 4 && tp [i ] != ' ' )
4910
+ break ;
4911
+ if (i - j == 5 && tp [i ] != 'q' )
4912
+ break ;
4913
+ if (i - j == 6 && tp [i ] != ESC && tp [i ] != STERM )
4914
+ break ;
4915
+ if ((i - j == 6 && tp [i ] == STERM )
4916
+ || (i - j == 7 && tp [i ] == '\\' ))
4917
+ {
4918
+ int number = argp [3 ] - '0' ;
4919
+
4920
+ /* 0, 1 = block blink, 2 = block
4921
+ * 3 = underline blink, 4 = underline
4922
+ * 5 = vertical bar blink, 6 = vertical bar */
4923
+ number = number == 0 ? 1 : number ;
4924
+ initial_cursor_shape = (number + 1 ) / 2 ;
4925
+ /* The blink flag is actually inverted, compared to
4926
+ * the value set with T_SH. */
4927
+ initial_cursor_shape_blink =
4919
4928
(number & 1 ) ? FALSE : TRUE;
4920
- rcs_status = STATUS_GOT ;
4921
- LOG_TR ("Received cursor shape response" );
4929
+ rcs_status = STATUS_GOT ;
4930
+ LOG_TR ("Received cursor shape response" );
4922
4931
4923
- key_name [0 ] = (int )KS_EXTRA ;
4924
- key_name [1 ] = (int )KE_IGNORE ;
4925
- slen = i + 1 + ( tp [ i ] == ESC ) ;
4932
+ key_name [0 ] = (int )KS_EXTRA ;
4933
+ key_name [1 ] = (int )KE_IGNORE ;
4934
+ slen = i + 1 ;
4926
4935
# ifdef FEAT_EVAL
4927
- set_vim_var_string (VV_TERMSTYLERESP , tp , slen );
4936
+ set_vim_var_string (VV_TERMSTYLERESP , tp , slen );
4928
4937
# endif
4938
+ break ;
4939
+ }
4929
4940
}
4930
4941
}
4931
4942
0 commit comments