mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-26 14:27:14 +00:00
Replace KYRA's strncpy and strncat usages by strlcpy/strlcat.
svn-id: r48954
This commit is contained in:
parent
388e4b65bf
commit
7da8c8949b
@ -582,8 +582,7 @@ void GUI_LoK::setupSavegames(Menu &menu, int num) {
|
||||
KyraEngine_v1::SaveHeader header;
|
||||
for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); i++) {
|
||||
if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header))) {
|
||||
strncpy(savenames[i], header.description.c_str(), ARRAYSIZE(savenames[0]));
|
||||
savenames[i][34] = 0;
|
||||
Common::strlcpy(savenames[i], header.description.c_str(), ARRAYSIZE(savenames[0]));
|
||||
|
||||
Util::convertISOToDOS(savenames[i]);
|
||||
|
||||
@ -748,8 +747,7 @@ int GUI_LoK::saveGame(Button *button) {
|
||||
} else {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (_menu[2].item[i].saveSlot == _vm->_gameToLoad) {
|
||||
strncpy(_savegameName, _menu[2].item[i].itemString, 31);
|
||||
_savegameName[30] = 0;
|
||||
Common::strlcpy(_savegameName, _menu[2].item[i].itemString, 31);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2312,39 +2312,32 @@ int GUI_LoL::runMenu(Menu &menu) {
|
||||
|
||||
if (_currentMenu == &_gameOptions) {
|
||||
char *s = (char *)_vm->_tempBuffer5120;
|
||||
strncpy(s, _vm->getLangString(0x406f + _vm->_monsterDifficulty), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(0x406f + _vm->_monsterDifficulty), 30);
|
||||
_currentMenu->item[_vm->gameFlags().isTalkie ? 0 : 2].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
|
||||
strncpy(s, _vm->getLangString(_vm->_smoothScrollingEnabled ? 0x4068 : 0x4069), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(_vm->_smoothScrollingEnabled ? 0x4068 : 0x4069), 30);
|
||||
_currentMenu->item[_vm->gameFlags().isTalkie ? 1 : 3].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
|
||||
strncpy(s, _vm->getLangString(_vm->_floatingCursorsEnabled ? 0x4068 : 0x4069), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(_vm->_floatingCursorsEnabled ? 0x4068 : 0x4069), 30);
|
||||
_currentMenu->item[_vm->gameFlags().isTalkie ? 2 : 4].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
|
||||
if (_vm->gameFlags().isTalkie) {
|
||||
strncpy(s, _vm->getLangString(0x42d6 + _vm->_lang), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(0x42d6 + _vm->_lang), 30);
|
||||
_currentMenu->item[3].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
|
||||
strncpy(s, _vm->getLangString(_vm->textEnabled() ? 0x4068 : 0x4069), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(_vm->textEnabled() ? 0x4068 : 0x4069), 30);
|
||||
_currentMenu->item[4].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
} else {
|
||||
strncpy(s, _vm->getLangString(_vm->_configMusic ? 0x4068 : 0x4069), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(_vm->_configMusic ? 0x4068 : 0x4069), 30);
|
||||
_currentMenu->item[0].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
|
||||
strncpy(s, _vm->getLangString(_vm->_configSounds ? 0x4068 : 0x4069), 30);
|
||||
s[29] = 0;
|
||||
Common::strlcpy(s, _vm->getLangString(_vm->_configSounds ? 0x4068 : 0x4069), 30);
|
||||
_currentMenu->item[1].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
}
|
||||
@ -2582,8 +2575,7 @@ void GUI_LoL::setupSaveMenuSlots(Menu &menu, int num) {
|
||||
|
||||
for (int i = startSlot; i < num && _savegameOffset + i - slotOffs < _savegameListSize; ++i) {
|
||||
if (_savegameList[_saveSlots[i + _savegameOffset - slotOffs]]) {
|
||||
strncpy(s, _savegameList[_saveSlots[i + _savegameOffset - slotOffs]], 80);
|
||||
s[79] = 0;
|
||||
Common::strlcpy(s, _savegameList[_saveSlots[i + _savegameOffset - slotOffs]], 80);
|
||||
menu.item[i].itemString = s;
|
||||
s += (strlen(s) + 1);
|
||||
menu.item[i].saveSlot = _saveSlots[i + _savegameOffset - slotOffs];
|
||||
@ -2628,7 +2620,7 @@ void GUI_LoL::updateSavegameList() {
|
||||
in = _vm->openSaveForReading(_vm->getSavegameFilename(i), header);
|
||||
if (in) {
|
||||
_savegameList[i] = new char[header.description.size() + 1];
|
||||
strncpy(_savegameList[i], header.description.c_str(), header.description.size() + 1);
|
||||
Common::strlcpy(_savegameList[i], header.description.c_str(), header.description.size() + 1);
|
||||
Util::convertISOToDOS(_savegameList[i]);
|
||||
delete in;
|
||||
} else {
|
||||
|
@ -457,8 +457,7 @@ void GUI_v2::setupSavegameNames(Menu &menu, int num) {
|
||||
for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); ++i) {
|
||||
if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header)) != 0) {
|
||||
char *s = getTableString(menu.item[i].itemId);
|
||||
strncpy(s, header.description.c_str(), 80);
|
||||
s[79] = 0;
|
||||
Common::strlcpy(s, header.description.c_str(), 80);
|
||||
Util::convertISOToDOS(s);
|
||||
|
||||
menu.item[i].saveSlot = _saveSlots[i + _savegameOffset];
|
||||
|
@ -1297,18 +1297,12 @@ void KyraEngine_MR::restoreGfxRect32x32(int x, int y) {
|
||||
char *KyraEngine_MR::appendLanguage(char *buf, int lang, int bufSize) {
|
||||
assert(lang < _languageExtensionSize);
|
||||
|
||||
int size = strlen(buf) + strlen(_languageExtension[lang]);
|
||||
|
||||
if (size > bufSize) {
|
||||
const int size = Common::strlcat(buf, _languageExtension[lang], bufSize);
|
||||
if (size >= bufSize) {
|
||||
warning("buffer too small to append language extension");
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *temp = buf + strlen(buf);
|
||||
bufSize -= strlen(buf);
|
||||
|
||||
strncat(temp, _languageExtension[lang], bufSize);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1318,8 +1312,7 @@ int KyraEngine_MR::loadLanguageFile(const char *file, uint8 *&buffer) {
|
||||
|
||||
uint32 size = 0;
|
||||
char nBuf[32];
|
||||
strncpy(nBuf, file, 32);
|
||||
nBuf[31] = 0;
|
||||
Common::strlcpy(nBuf, file, sizeof(nBuf));
|
||||
buffer = _res->fileData(appendLanguage(nBuf, _lang, sizeof(nBuf)), &size);
|
||||
|
||||
return buffer ? size : 0 ;
|
||||
|
@ -131,8 +131,7 @@ bool EMCInterpreter::load(const char *filename, EMCData *scriptData, const Commo
|
||||
|
||||
_scriptData->sysFuncs = opcodes;
|
||||
|
||||
strncpy(_scriptData->filename, filename, 13);
|
||||
_scriptData->filename[12] = 0;
|
||||
Common::strlcpy(_scriptData->filename, filename, 13);
|
||||
|
||||
_scriptData = 0;
|
||||
_filename = 0;
|
||||
|
@ -174,8 +174,7 @@ TIM *TIMInterpreter::load(const char *filename, const Common::Array<const TIMOpc
|
||||
for (int i = 0; i < num; ++i)
|
||||
_tim->func[i].avtl = _tim->avtl + _tim->avtl[i];
|
||||
|
||||
strncpy(_tim->filename, filename, 13);
|
||||
_tim->filename[12] = 0;
|
||||
Common::strlcpy(_tim->filename, filename, 13);
|
||||
|
||||
_tim->isLoLOutro = (_vm->gameFlags().gameID == GI_LOL) && !scumm_stricmp(filename, "LOLFINAL.TIM");
|
||||
_tim->lolCharacter = 0;
|
||||
|
@ -458,8 +458,7 @@ int SoundDigital::playSound(const char *filename, uint8 priority, Audio::Mixer::
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(use->filename, filename, sizeof(use->filename));
|
||||
use->filename[sizeof(use->filename) - 1] = 0;
|
||||
Common::strlcpy(use->filename, filename, sizeof(use->filename));
|
||||
use->priority = priority;
|
||||
Audio::SeekableAudioStream *audioStream = _supportedCodecs[usedCodec].streamFunc(stream, DisposeAfterUse::YES);
|
||||
if (!audioStream) {
|
||||
|
@ -348,10 +348,9 @@ void KyraEngine_LoK::drawSentenceCommand(const char *sentence, int color) {
|
||||
|
||||
void KyraEngine_LoK::updateSentenceCommand(const char *str1, const char *str2, int color) {
|
||||
char sentenceCommand[500];
|
||||
strncpy(sentenceCommand, str1, 500);
|
||||
sentenceCommand[499] = 0;
|
||||
Common::strlcpy(sentenceCommand, str1, sizeof(sentenceCommand));
|
||||
if (str2)
|
||||
strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand));
|
||||
Common::strlcat(sentenceCommand, str2, sizeof(sentenceCommand));
|
||||
|
||||
drawSentenceCommand(sentenceCommand, color);
|
||||
_screen->updateScreen();
|
||||
|
Loading…
x
Reference in New Issue
Block a user