Fix a few warnings (from MS Visual Studio 2015)

This commit is contained in:
Thomas Bernard 2018-03-26 10:16:16 +02:00
parent a584fe65b9
commit 187c7d53e3
3 changed files with 26 additions and 19 deletions

View File

@ -1466,7 +1466,7 @@ void Button_Skins(int btn)
Menu_font = new_font; Menu_font = new_font;
Print_in_window( 172, 33,"Font:" ,MC_Black,MC_Light); 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, 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); Update_window_area(172, 33, 8 * 5, 8);
} }
break; 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); 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'; backup_name[i+1]='\0';
strcat(backup_name,"BAK"); 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 filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
char new_filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier backup char new_filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier backup

View File

@ -665,7 +665,7 @@ void Save_PKM(T_IO_Context * context)
word repetitions; word repetitions;
byte last_color; byte last_color;
byte pixel_value; 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 // Calcul de la taille du Post-header
header.Jump=9; // 6 pour les dimensions de l'ecran + 3 pour la back-color header.Jump=9; // 6 pour les dimensions de l'ecran + 3 pour la back-color
comment_size=strlen(context->Comment); comment_size=strlen(context->Comment);
if (comment_size > 255) comment_size = 255;
if (comment_size) if (comment_size)
header.Jump+=comment_size+2; header.Jump+=(word)comment_size+2;
File_error=0; File_error=0;
@ -705,10 +706,10 @@ void Save_PKM(T_IO_Context * context)
// Ecriture du commentaire // Ecriture du commentaire
// (Compteur_de_pixels est utilisé ici comme simple index de comptage) // (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,0);
Write_one_byte(file,comment_size); Write_one_byte(file,(byte)comment_size);
for (Compteur_de_pixels=0; Compteur_de_pixels<comment_size; Compteur_de_pixels++) for (Compteur_de_pixels=0; Compteur_de_pixels<comment_size; Compteur_de_pixels++)
Write_one_byte(file,context->Comment[Compteur_de_pixels]); Write_one_byte(file,context->Comment[Compteur_de_pixels]);
} }

View File

@ -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 initial_string_unicode[256];
word display_string_unicode[256]; word display_string_unicode[256];
byte position; byte position;
byte size; size_t size;
word input_key=0; word input_key=0;
word window_x=Window_pos_X; word window_x=Window_pos_X;
word window_y=Window_pos_Y; 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) if (str_unicode != NULL)
{ {
size = Unicode_strlen(str_unicode); size = Unicode_strlen(str_unicode);
if (size > 255) size = 255;
memcpy(initial_string_unicode, str_unicode, 2*(size+1)); memcpy(initial_string_unicode, str_unicode, 2*(size+1));
position=(size<max_size)? size:size-1; position =(byte)((size<max_size) ? size : size-1);
if (position-offset>=visible_size) if (position-offset>=visible_size)
offset=position-visible_size+1; offset=position-visible_size+1;
// copy only part of the string if it is too long // copy only part of the string if it is too long
Unicode_strlcpy(display_string_unicode, str_unicode+offset, visible_size); Unicode_strlcpy(display_string_unicode, str_unicode+offset, visible_size);
if (offset>0) if (offset>0)
display_string_unicode[0] = (byte)LEFT_TRIANGLE_CHARACTER; 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_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); 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 else
{ {
size=strlen(str); size=strlen(str);
position=(size<max_size)? size:size-1; if (size > 255) size = 255;
position = (byte)((size<max_size) ? size : size-1);
if (position-offset>=visible_size) if (position-offset>=visible_size)
offset=position-visible_size+1; offset=position-visible_size+1;
// copy only part of the string if it is too long // 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'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
display_string[0]=LEFT_TRIANGLE_CHARACTER; 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_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); 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 case SDLK_END : // End
if ((position<size) && (position<max_size-1)) if ((position<size) && (position<max_size-1))
{ {
position=(size<max_size)?size:size-1; position = (byte)((size<max_size) ? size : size-1);
if (position-offset>=visible_size) if (position-offset>=visible_size)
offset=position-visible_size+1; offset=position-visible_size+1;
goto affichage; 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 // On restaure la chaine initiale
strcpy(str,initial_string); strcpy(str,initial_string);
size=strlen(str); size=strlen(str);
if (size > 255) size = 255;
if (str_unicode != NULL) if (str_unicode != NULL)
{ {
Unicode_strlcpy(str_unicode, initial_string_unicode, 256); Unicode_strlcpy(str_unicode, initial_string_unicode, 256);
@ -915,11 +918,12 @@ affichage:
if (str_unicode != NULL) if (str_unicode != NULL)
{ {
size=Unicode_strlen(str_unicode); size=Unicode_strlen(str_unicode);
if (size > 255) size = 255;
// only show part of the string if too long // only show part of the string if too long
Unicode_strlcpy(display_string_unicode, str_unicode + offset, visible_size); Unicode_strlcpy(display_string_unicode, str_unicode + offset, visible_size);
if (offset>0) if (offset>0)
display_string_unicode[0] = (byte)LEFT_TRIANGLE_CHARACTER; 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_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); 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 else
{ {
size=strlen(str); size=strlen(str);
if (size > 255) size = 255;
// only show part of the string if too long // only show part of the string if too long
strncpy(display_string, str + offset, visible_size); strncpy(display_string, str + offset, visible_size);
display_string[visible_size]='\0'; display_string[visible_size]='\0';
if (offset>0) if (offset>0)
display_string[0]=LEFT_TRIANGLE_CHARACTER; 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_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); 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"); strcpy(str,"0");
size=1; 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) else if (input_type==INPUT_TYPE_DECIMAL)
{ {
@ -972,9 +977,10 @@ affichage:
Sprint_double(str,value,decimal_places,visible_size); Sprint_double(str,value,decimal_places,visible_size);
// Recompute updated size // Recompute updated size
size = strlen(str); size = strlen(str);
if (size > 255) size = 255;
if (size<=visible_size) 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 else
Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR); Print_in_window_limited(x_pos,y_pos,str,visible_size,TEXT_COLOR,BACKGROUND_COLOR);
} }