Prevent infinite loop when reaching end of string on get_next_run

Prevent warning about conversion to non const bidi_txt
This commit is contained in:
Amir Gonnen
2019-11-11 22:43:12 +02:00
parent 90eeff7022
commit 23b58d598d
2 changed files with 5 additions and 3 deletions

View File

@@ -232,7 +232,7 @@ void lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len
/*Get and process the runs*/ /*Get and process the runs*/
while(rd < len) { while(rd < len && str_in[rd]) {
run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len);
if(base_dir == LV_BIDI_DIR_LTR) { if(base_dir == LV_BIDI_DIR_LTR) {

View File

@@ -626,7 +626,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
} }
} }
char *bidi_txt; const char *bidi_txt;
uint16_t visual_byte_pos; uint16_t visual_byte_pos;
#if LV_USE_BIDI #if LV_USE_BIDI
/*Handle Bidi*/ /*Handle Bidi*/
@@ -638,7 +638,9 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
uint16_t line_char_id = lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start); uint16_t line_char_id = lv_txt_encoded_get_char_id(&txt[line_start], byte_id - line_start);
bool is_rtl; bool is_rtl;
uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id, &is_rtl); char *mutable_bidi_txt;
uint16_t visual_char_pos = lv_bidi_get_visual_pos(&txt[line_start], &mutable_bidi_txt, new_line_start - line_start, lv_obj_get_base_dir(label), line_char_id, &is_rtl);
bidi_txt = mutable_bidi_txt;
if (is_rtl) visual_char_pos++; if (is_rtl) visual_char_pos++;
visual_byte_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_char_pos); visual_byte_pos = lv_txt_encoded_get_byte_id(bidi_txt, visual_char_pos);
} }