diff --git a/src/buttons.c b/src/buttons.c index 4e4304de..b6ceb25f 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1466,7 +1466,7 @@ void Button_Skins(int btn) Menu_font = new_font; Print_in_window( 172, 33,"Font:" ,MC_Black,MC_Light); Print_in_window_limited(font_dropdown->Pos_X+2,font_dropdown->Pos_Y+(font_dropdown->Height-7)/2, - fontName->Short_name,strlen(fontName->Short_name) ,MC_Black,MC_Light); + fontName->Short_name,(byte)strlen(fontName->Short_name) ,MC_Black,MC_Light); Update_window_area(172, 33, 8 * 5, 8); } break; @@ -3415,18 +3415,18 @@ void Button_Reload(int btn) } -void Backup_filename(char * fname, char * backup_name) +static void Backup_filename(const char * fname, char * backup_name) { - short i; + int i; strcpy(backup_name,fname); - for (i=strlen(fname)-strlen(Main.backups->Pages->Filename); backup_name[i]!='.'; i++); + for (i=strlen(fname)-strlen(Main.backups->Pages->Filename); backup_name[i]!='.' && backup_name[i]!='\0'; i++); backup_name[i+1]='\0'; strcat(backup_name,"BAK"); } -void Backup_existing_file(void) +static void Backup_existing_file(void) { char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier char new_filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier backup diff --git a/src/miscfileformats.c b/src/miscfileformats.c index dcf9f39a..ede9a3ca 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -665,7 +665,7 @@ void Save_PKM(T_IO_Context * context) word repetitions; byte last_color; byte pixel_value; - byte comment_size; + size_t comment_size; @@ -681,8 +681,9 @@ void Save_PKM(T_IO_Context * context) // Calcul de la taille du Post-header header.Jump=9; // 6 pour les dimensions de l'ecran + 3 pour la back-color comment_size=strlen(context->Comment); + if (comment_size > 255) comment_size = 255; if (comment_size) - header.Jump+=comment_size+2; + header.Jump+=(word)comment_size+2; File_error=0; @@ -705,10 +706,10 @@ void Save_PKM(T_IO_Context * context) // Ecriture du commentaire // (Compteur_de_pixels est utilisé ici comme simple index de comptage) - if (comment_size) + if (comment_size > 0) { Write_one_byte(file,0); - Write_one_byte(file,comment_size); + Write_one_byte(file,(byte)comment_size); for (Compteur_de_pixels=0; Compteur_de_pixelsComment[Compteur_de_pixels]); } diff --git a/src/readline.c b/src/readline.c index 654be3e2..d13825c0 100644 --- a/src/readline.c +++ b/src/readline.c @@ -457,7 +457,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt word initial_string_unicode[256]; word display_string_unicode[256]; byte position; - byte size; + size_t size; word input_key=0; word window_x=Window_pos_X; word window_y=Window_pos_Y; @@ -622,15 +622,16 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt if (str_unicode != NULL) { size = Unicode_strlen(str_unicode); + if (size > 255) size = 255; memcpy(initial_string_unicode, str_unicode, 2*(size+1)); - position=(size=visible_size) offset=position-visible_size+1; // copy only part of the string if it is too long Unicode_strlcpy(display_string_unicode, str_unicode+offset, visible_size); if (offset>0) display_string_unicode[0] = (byte)LEFT_TRIANGLE_CHARACTER; - if (visible_size + offset + 1 < size ) + if ((size_t)visible_size + offset + 1 < size ) display_string_unicode[visible_size-1] = (byte)RIGHT_TRIANGLE_CHARACTER; Display_whole_string_unicode(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string_unicode,position - offset); @@ -638,7 +639,8 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt else { size=strlen(str); - position=(size 255) size = 255; + position = (byte)((size=visible_size) offset=position-visible_size+1; // copy only part of the string if it is too long @@ -646,7 +648,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt display_string[visible_size]='\0'; if (offset>0) display_string[0]=LEFT_TRIANGLE_CHARACTER; - if (visible_size + offset + 1 < size ) + if ((size_t)visible_size + offset + 1 < size ) display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; Display_whole_string(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string,position - offset); @@ -830,7 +832,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt case SDLK_END : // End if ((position=visible_size) offset=position-visible_size+1; goto affichage; @@ -868,6 +870,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt // On restaure la chaine initiale strcpy(str,initial_string); size=strlen(str); + if (size > 255) size = 255; if (str_unicode != NULL) { Unicode_strlcpy(str_unicode, initial_string_unicode, 256); @@ -915,11 +918,12 @@ affichage: if (str_unicode != NULL) { size=Unicode_strlen(str_unicode); + if (size > 255) size = 255; // only show part of the string if too long Unicode_strlcpy(display_string_unicode, str_unicode + offset, visible_size); if (offset>0) display_string_unicode[0] = (byte)LEFT_TRIANGLE_CHARACTER; - if (visible_size + offset + 0 < size ) + if ((size_t)visible_size + offset + 0 < size ) display_string_unicode[visible_size-1] = (byte)RIGHT_TRIANGLE_CHARACTER; Display_whole_string_unicode(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string_unicode,position - offset); @@ -927,12 +931,13 @@ affichage: else { size=strlen(str); + if (size > 255) size = 255; // only show part of the string if too long strncpy(display_string, str + offset, visible_size); display_string[visible_size]='\0'; if (offset>0) display_string[0]=LEFT_TRIANGLE_CHARACTER; - if (visible_size + offset + 0 < size ) + if ((size_t)visible_size + offset + 0 < size ) display_string[visible_size-1]=RIGHT_TRIANGLE_CHARACTER; Display_whole_string(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string,position - offset); @@ -962,7 +967,7 @@ affichage: strcpy(str,"0"); size=1; } - Print_in_window(x_pos+((max_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); + Print_in_window(x_pos+(((short)max_size-(short)size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); } else if (input_type==INPUT_TYPE_DECIMAL) { @@ -972,9 +977,10 @@ affichage: Sprint_double(str,value,decimal_places,visible_size); // Recompute updated size size = strlen(str); + if (size > 255) size = 255; if (size<=visible_size) - Print_in_window(x_pos+((visible_size-size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); + Print_in_window(x_pos+(((short)visible_size-(short)size)<<3),y_pos,str,TEXT_COLOR,BACKGROUND_COLOR); else Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR); }