summaryrefslogtreecommitdiff
path: root/src/strgen
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-04-23 20:44:42 +0000
committerfrosch <frosch@openttd.org>2014-04-23 20:44:42 +0000
commitef4c2ce0317ae583e837722b6a41ea44cd83da71 (patch)
treec0c3d77ac495a6b9257cd7de4dadc6712db1acc8 /src/strgen
parent56e8ea6ddef08eb6ad1a28d06dddecb902e1bc04 (diff)
downloadopenttd-ef4c2ce0317ae583e837722b6a41ea44cd83da71.tar.xz
(svn r26485) -Codechange: Replace ttd_strlcpy and ttd_strlcat with strecpy and strecat.
Diffstat (limited to 'src/strgen')
-rw-r--r--src/strgen/strgen.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 61c36cd61..2fb89f088 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -386,13 +386,13 @@ static inline void ottd_mkdir(const char *directory)
* path separator and the filename. The separator is only appended if the path
* does not already end with a separator
*/
-static inline char *mkpath(char *buf, size_t buflen, const char *path, const char *file)
+static inline char *mkpath(char *buf, const char *last, const char *path, const char *file)
{
- ttd_strlcpy(buf, path, buflen); // copy directory into buffer
+ strecpy(buf, path, last); // copy directory into buffer
char *p = strchr(buf, '\0'); // add path separator if necessary
- if (p[-1] != PATHSEPCHAR && (size_t)(p - buf) + 1 < buflen) *p++ = PATHSEPCHAR;
- ttd_strlcpy(p, file, buflen - (size_t)(p - buf)); // concatenate filename at end of buffer
+ if (p[-1] != PATHSEPCHAR && p != last) *p++ = PATHSEPCHAR;
+ strecpy(p, file, last); // concatenate filename at end of buffer
return buf;
}
@@ -522,7 +522,7 @@ int CDECL main(int argc, char *argv[])
* with a (free) parameter the program will translate that language to destination
* directory. As input english.txt is parsed from the source directory */
if (mgo.numleft == 0) {
- mkpath(pathbuf, lengthof(pathbuf), src_dir, "english.txt");
+ mkpath(pathbuf, lastof(pathbuf), src_dir, "english.txt");
/* parse master file */
StringData data(TAB_COUNT);
@@ -532,7 +532,7 @@ int CDECL main(int argc, char *argv[])
/* write strings.h */
ottd_mkdir(dest_dir);
- mkpath(pathbuf, lengthof(pathbuf), dest_dir, "strings.h");
+ mkpath(pathbuf, lastof(pathbuf), dest_dir, "strings.h");
HeaderFileWriter writer(pathbuf);
writer.WriteHeader(data);
@@ -540,7 +540,7 @@ int CDECL main(int argc, char *argv[])
} else if (mgo.numleft >= 1) {
char *r;
- mkpath(pathbuf, lengthof(pathbuf), src_dir, "english.txt");
+ mkpath(pathbuf, lastof(pathbuf), src_dir, "english.txt");
StringData data(TAB_COUNT);
/* parse master file and check if target file is correct */
@@ -558,12 +558,12 @@ int CDECL main(int argc, char *argv[])
/* get the targetfile, strip any directories and append to destination path */
r = strrchr(mgo.argv[i], PATHSEPCHAR);
- mkpath(pathbuf, lengthof(pathbuf), dest_dir, (r != NULL) ? &r[1] : mgo.argv[i]);
+ mkpath(pathbuf, lastof(pathbuf), dest_dir, (r != NULL) ? &r[1] : mgo.argv[i]);
/* rename the .txt (input-extension) to .lng */
r = strrchr(pathbuf, '.');
if (r == NULL || strcmp(r, ".txt") != 0) r = strchr(pathbuf, '\0');
- ttd_strlcpy(r, ".lng", (size_t)(r - pathbuf));
+ strecpy(r, ".lng", lastof(pathbuf));
LanguageFileWriter writer(pathbuf);
writer.WriteLang(data);