[Scummvm-git-logs] scummvm master -> 4a25b60875f394eb7cf34a1cec8089cf6b696267
bluegr
noreply at scummvm.org
Sun Feb 8 22:22:37 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
4a25b60875 JANITORIAL: DEVTOOLS: replace sprintf with snprintf
Commit: 4a25b60875f394eb7cf34a1cec8089cf6b696267
https://github.com/scummvm/scummvm/commit/4a25b60875f394eb7cf34a1cec8089cf6b696267
Author: meekee7 (michael_kuerbis at web.de)
Date: 2026-02-09T00:22:34+02:00
Commit Message:
JANITORIAL: DEVTOOLS: replace sprintf with snprintf
Changed paths:
devtools/create_kyradat/create_kyradat.cpp
devtools/create_mm/create_xeen/file.h
devtools/create_supernova/create_supernova.cpp
devtools/create_titanic/create_titanic_dat.cpp
devtools/create_ultima/file.h
devtools/skycpt/cptcompiler.cpp
diff --git a/devtools/create_kyradat/create_kyradat.cpp b/devtools/create_kyradat/create_kyradat.cpp
index 224b9537cd3..c5e83b97a9d 100644
--- a/devtools/create_kyradat/create_kyradat.cpp
+++ b/devtools/create_kyradat/create_kyradat.cpp
@@ -1269,8 +1269,8 @@ uint32 getFilename(const ResourceProvider *provider, const ExtractFilename *fDes
return getFilename(provider->game, provider->platform, provider->special, provider->language, fDesc);
}
-bool getFilename(char *dstFilename, const Game *g, const int id) {
- sprintf(dstFilename, "%08X", getFilename(g, id));
+bool getFilename(char *dstFilename, size_t bufcnt, const Game *g, const int id) {
+ snprintf(dstFilename, bufcnt, "%08X", getFilename(g, id));
return true;
}
@@ -1374,7 +1374,7 @@ bool createIDMap(PAKFile &out, const Game *g, const int *needList) {
// present
for (const int *n = needList; *n != -1; ++n) {
char filename[12];
- if (!getFilename(filename, g, *n) || !out.getFileList()->findEntry(filename)) {
+ if (!getFilename(filename, ARRAYSIZE(filename), g, *n) || !out.getFileList()->findEntry(filename)) {
fprintf(stderr, "ERROR: Could not find need %d for game %04X", *n, createGameDef(g));
return false;
}
@@ -1398,7 +1398,7 @@ bool createIDMap(PAKFile &out, const Game *g, const int *needList) {
}
char filename[12];
- if (!getFilename(filename, g, 0)) {
+ if (!getFilename(filename, ARRAYSIZE(filename), g, 0)) {
fprintf(stderr, "ERROR: Could not create ID map for game\n");
delete[] map;
return false;
diff --git a/devtools/create_mm/create_xeen/file.h b/devtools/create_mm/create_xeen/file.h
index d8d64e937c1..d6cbd9eb5fd 100644
--- a/devtools/create_mm/create_xeen/file.h
+++ b/devtools/create_mm/create_xeen/file.h
@@ -246,7 +246,7 @@ public:
_f = fopen(filename, "rb");
} else {
char fname[256];
- sprintf(fname, "../files/xeen/%s", filename);
+ snprintf(fname, ARRAYSIZE(fname), "../files/xeen/%s", filename);
_f = fopen(fname, "wb+");
}
diff --git a/devtools/create_supernova/create_supernova.cpp b/devtools/create_supernova/create_supernova.cpp
index 6a17dc51321..9bf64948933 100644
--- a/devtools/create_supernova/create_supernova.cpp
+++ b/devtools/create_supernova/create_supernova.cpp
@@ -4,6 +4,9 @@
#include "po_parser.h"
#include <iostream>
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#include "common/util.h"
+
// List of languages to look for. To add new languages you only need to change the array below
// and add the supporting files:
// - 640x480 bitmap picture for the newpaper named 'img1-##.pbm' and 'img2-##.pbm'
@@ -20,9 +23,9 @@ void writeDatafile(File& outputFile, int fileNumber, const char* language, int p
File dataFile;
char fileName[20];
if (part == 1)
- sprintf(fileName, "msn_data.%03d-%s", fileNumber, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "msn_data.%03d-%s", fileNumber, language);
if (part == 2)
- sprintf(fileName, "ms2_data.%03d-%s", fileNumber, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "ms2_data.%03d-%s", fileNumber, language);
if (!dataFile.open(fileName, kFileReadMode)) {
printf("Cannot find dataFile %s. This file will be skipped.\n", fileName);
return;
@@ -31,7 +34,7 @@ void writeDatafile(File& outputFile, int fileNumber, const char* language, int p
// Write block header in output file (4 bytes).
// M(fileNumber) for example M015
char number[4];
- sprintf(number, "%03d", fileNumber);
+ snprintf(number, ARRAYSIZE(number), "%03d", fileNumber);
outputFile.writeByte('M');
for (int i = 0 ; i < 3 ; ++i) {
outputFile.writeByte(number[i]);
@@ -67,9 +70,9 @@ void writeDocFile(File& outputFile, const char *fileExtension, const char* langu
File docFile;
char fileName[20];
if (part == 1)
- sprintf(fileName, "msn.%s-%s", fileExtension, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "msn.%s-%s", fileExtension, language);
if (part == 2)
- sprintf(fileName, "ms2.%s-%s", fileExtension, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "ms2.%s-%s", fileExtension, language);
if (!docFile.open(fileName, kFileReadMode)) {
printf("Cannot find file '%s'. This file will be skipped.\n", fileName);
return;
@@ -113,7 +116,7 @@ void writeDocFile(File& outputFile, const char *fileExtension, const char* langu
void writeImage(File& outputFile, const char *name, const char* language) {
File imgFile;
char fileName[16];
- sprintf(fileName, "%s-%s.pbm", name, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "%s-%s.pbm", name, language);
if (!imgFile.open(fileName, kFileReadMode)) {
printf("Cannot find image '%s' for language '%s'. This image will be skipped.\n", name, language);
return;
@@ -256,7 +259,7 @@ void writeGermanStrings(File& outputFile, int part) {
void writeStrings(File& outputFile, const char* language, int part) {
char fileName[16];
- sprintf(fileName, "strings%d-%s.po", part, language);
+ snprintf(fileName, ARRAYSIZE(fileName), "strings%d-%s.po", part, language);
PoMessageList* poList = parsePoFile(fileName);
if (!poList) {
printf("Cannot find strings%d file for language '%s'.\n", part, language);
diff --git a/devtools/create_titanic/create_titanic_dat.cpp b/devtools/create_titanic/create_titanic_dat.cpp
index 930557d7f5c..a5f984fffd3 100644
--- a/devtools/create_titanic/create_titanic_dat.cpp
+++ b/devtools/create_titanic/create_titanic_dat.cpp
@@ -1143,7 +1143,7 @@ void writeResource(const char *resName, const char *sectionStr, uint32 resId, bo
void writeResource(const char *sectionStr, uint32 resId, bool isEnglish = true) {
char nameBuffer[256];
- sprintf(nameBuffer, "%s/%u", sectionStr, resId);
+ snprintf(nameBuffer, ARRAYSIZE(nameBuffer), "%s/%u", sectionStr, resId);
if (!isEnglish)
strcat(nameBuffer, "/DE");
@@ -1160,7 +1160,7 @@ void writeResource(const char *resName, const char *sectionStr, const char *resI
void writeResource(const char *sectionStr, const char *resId, bool isEnglish = true) {
char nameBuffer[256];
- sprintf(nameBuffer, "%s/%s", sectionStr, resId);
+ snprintf(nameBuffer, ARRAYSIZE(nameBuffer), "%s/%s", sectionStr, resId);
if (!isEnglish)
strcat(nameBuffer, "/DE");
@@ -1204,7 +1204,7 @@ void writeBitmap(const char *name, Common::File *file) {
void writeBitmap(const char *sectionStr, const char *resId, bool isEnglish = true) {
char nameBuffer[256];
- sprintf(nameBuffer, "%s/%s%s", sectionStr, resId,
+ snprintf(nameBuffer, ARRAYSIZE(nameBuffer), "%s/%s%s", sectionStr, resId,
isEnglish ? "" : "/DE");
Common::PEResources *res = isEnglish ? resEng : resGer;
@@ -1216,7 +1216,7 @@ void writeBitmap(const char *sectionStr, const char *resId, bool isEnglish = tru
void writeBitmap(const char *sectionStr, uint32 resId, bool isEnglish = true) {
char nameBuffer[256];
- sprintf(nameBuffer, "%s/%u%s", sectionStr, resId,
+ snprintf(nameBuffer, ARRAYSIZE(nameBuffer), "%s/%u%s", sectionStr, resId,
isEnglish ? "" : "/DE");
Common::PEResources *res = isEnglish ? resEng : resGer;
diff --git a/devtools/create_ultima/file.h b/devtools/create_ultima/file.h
index 248339a0b4b..f5c4cd99baa 100644
--- a/devtools/create_ultima/file.h
+++ b/devtools/create_ultima/file.h
@@ -32,6 +32,9 @@
typedef unsigned char byte;
typedef unsigned int uint32;
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#include "common/util.h"
+
#include "create_ultima.h"
class File {
@@ -42,7 +45,7 @@ public:
_file = fopen(filename, "rb");
if (!_file) {
char buf[255];
- sprintf(buf, "Could not open file %s", filename);
+ snprintf(buf, ARRAYSIZE(buf), "Could not open file %s", filename);
error(buf);
}
}
diff --git a/devtools/skycpt/cptcompiler.cpp b/devtools/skycpt/cptcompiler.cpp
index c0c60ff7e30..7f119deadb5 100644
--- a/devtools/skycpt/cptcompiler.cpp
+++ b/devtools/skycpt/cptcompiler.cpp
@@ -26,6 +26,11 @@
#include <stdlib.h>
#include <string.h>
+// Including common/util.h would cause type declaration conflicts
+#ifndef ARRAYSIZE
+#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
+#endif
+
uint32 crop(char *line);
uint16 findCptId(char *name, TextFile *cptFile);
@@ -477,7 +482,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *
bool filesExist = true;
char inName[32];
for (int i = 0; i < 7; i++) {
- sprintf(inName, "RESET.%03d", gameVers[i]);
+ snprintf(inName, ARRAYSIZE(inName), "RESET.%03d", gameVers[i]);
FILE *test = fopen(inName, "rb");
if (test)
fclose(test);
@@ -511,7 +516,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *
for (int cnt = 0; cnt < 6; cnt++) {
printf("Processing diff v0.0%03d\n", gameVers[cnt]);
uint16 diffPos = 0;
- sprintf(inName, "RESET.%03d", gameVers[cnt]);
+ snprintf(inName, ARRAYSIZE(inName), "RESET.%03d", gameVers[cnt]);
FILE *resDiff = fopen(inName, "rb");
fseek(resDiff, 0, SEEK_END);
assert(ftell(resDiff) == (resSize * 2));
More information about the Scummvm-git-logs
mailing list