mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Remove dependency of strlcat()
There was only one place where `strlcat` was used, and `snprintf` actually does a better job at what the code was trying to achieve. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -236,6 +236,9 @@ FILE *fstk_FindFile(char *fname)
|
||||
int32_t i;
|
||||
FILE *f;
|
||||
|
||||
if (fname == NULL)
|
||||
return NULL;
|
||||
|
||||
f = fopen(fname, "rb");
|
||||
|
||||
if (f != NULL || errno != ENOENT) {
|
||||
@@ -246,13 +249,19 @@ FILE *fstk_FindFile(char *fname)
|
||||
}
|
||||
|
||||
for (i = 0; i < NextIncPath; ++i) {
|
||||
if (strlcpy(path, IncludePaths[i], sizeof(path))
|
||||
/*
|
||||
* The function snprintf() does not write more than `size` bytes
|
||||
* (including the terminating null byte ('\0')). If the output
|
||||
* was truncated due to this limit, the return value is the
|
||||
* number of characters (excluding the terminating null byte)
|
||||
* which would have been written to the final string if enough
|
||||
* space had been available. Thus, a return value of `size` or
|
||||
* more means that the output was truncated.
|
||||
*/
|
||||
if (snprintf(path, sizeof(path), "%s%s", IncludePaths[i], fname)
|
||||
>= sizeof(path))
|
||||
continue;
|
||||
|
||||
if (strlcat(path, fname, sizeof(path)) >= sizeof(path))
|
||||
continue;
|
||||
|
||||
f = fopen(path, "rb");
|
||||
|
||||
if (f != NULL || errno != ENOENT) {
|
||||
|
||||
Reference in New Issue
Block a user