} else {
commentList[index] = (char *) malloc(len + 6); // perhaps wastes 4...
if(addBraces)
- safeStrCpy(commentList[index], "{\n", sizeof(commentList[index])/sizeof(commentList[index][0]));
+ safeStrCpy(commentList[index], "{\n", 3);
else commentList[index][0] = NULLCHAR;
strcat(commentList[index], text);
strcat(commentList[index], "\n");
// correct FRC-style castlings in variant normal.
// [HGM] This is buggy code! e1h1 could very well be a normal R or Q move.
if(!strcmp(move_s,"e1h1")){
- safeStrCpy(move_s,"e1g1", sizeof(move_s)/sizeof(move_s[0]));
+ safeStrCpy(move_s,"e1g1", 6);
}else if(!strcmp(move_s,"e1a1")){
- safeStrCpy(move_s,"e1c1", sizeof(move_s)/sizeof(move_s[0]));
+ safeStrCpy(move_s,"e1c1", 6);
}else if(!strcmp(move_s,"e8h8")){
- safeStrCpy(move_s,"e8g8", sizeof(move_s)/sizeof(move_s[0]));
+ safeStrCpy(move_s,"e8g8", 6);
}else if(!strcmp(move_s,"e8a8")){
- safeStrCpy(move_s,"e8c8", sizeof(move_s)/sizeof(move_s[0]));
+ safeStrCpy(move_s,"e8c8", 6);
}
}
* automatically call XtFree on the value returned. So have to
* make a copy of it allocated with XtMalloc */
selection_tmp= XtMalloc(strlen(selected_fen_position)+16);
- safeStrCpy(selection_tmp, selected_fen_position, sizeof(selection_tmp)/sizeof(selection_tmp[0]) );
+ safeStrCpy(selection_tmp, selected_fen_position, strlen(selected_fen_position)+16 );
*value_return=selection_tmp;
*length_return=strlen(selection_tmp);
strncpy(hist->white[i/2+1], movelist[i], p-movelist[i]);
hist->white[i/2+1][p-movelist[i]] = NULLCHAR;
} else {
- safeStrCpy(hist->white[i/2+1],movelist[i], sizeof(hist->white[i/2+1])/sizeof(hist->white[i/2+1][0]));
+ safeStrCpy(hist->white[i/2+1],movelist[i], MOVE_LEN);
}
} else {
- safeStrCpy(hist->white[i/2+1],dots, sizeof(hist->white[i/2+1])/sizeof(hist->white[i/2+1][0]));
+ safeStrCpy(hist->white[i/2+1],dots, MOVE_LEN);
}
} else {
if(movelist[i][0]) {
strncpy(hist->black[i/2+1], movelist[i], p-movelist[i]);
hist->black[i/2+1][p-movelist[i]] = NULLCHAR;
} else {
- safeStrCpy(hist->black[i/2+1],movelist[i], sizeof(hist->black[i/2+1])/sizeof(hist->black[i/2+1][0]));
+ safeStrCpy(hist->black[i/2+1],movelist[i], MOVE_LEN);
}
} else {
- safeStrCpy(hist->black[i/2+1],"", sizeof(hist->black[i/2+1])/sizeof(hist->black[i/2+1][0]));
+ safeStrCpy(hist->black[i/2+1],"", MOVE_LEN);
}
}
}
- safeStrCpy(hist->black[last/2+1],"", sizeof(hist->black[last/2+1])/sizeof(hist->black[last/2+1][0]));
+ safeStrCpy(hist->black[last/2+1],"", MOVE_LEN);
b=first/2;
m=(last+3)/2-b;
XawFormDoLayout(hist->vbox, False);
CatchDeleteWindow(hist->sh, "HistoryPopDown");
for(i=1;i<hist->aNr;i++){
- safeStrCpy(hist->white[i],dots, sizeof(hist->white[i])/sizeof(hist->white[i][0]));
- safeStrCpy(hist->black[i],"", sizeof(hist->black[i])/sizeof(hist->black[i][0]));
+ safeStrCpy(hist->white[i],dots, MOVE_LEN);
+ safeStrCpy(hist->black[i],"", MOVE_LEN);
}
if(wpMoveHistory.width > 0) {
XtSetArg(args[0], XtNstring, &val);
XtGetValues(currentCps->option[i].handle, args, 1);
if(strcmp(currentCps->option[i].textValue, val)) {
- safeStrCpy(currentCps->option[i].textValue, val, sizeof(currentCps->option[i].textValue)/sizeof(currentCps->option[i].textValue[0]));
+ safeStrCpy(currentCps->option[i].textValue, val, MSG_SIZ - (currentCps->option[i].textValue - currentCps->option[i].name) );
snprintf(buf, MSG_SIZ, "option %s=%s\n", currentCps->option[i].name, val);
SendToProgram(buf, currentCps);
}