From 5338f7bf545374bafaf455db3c4c98f1225c163e Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 15 Nov 2014 17:35:28 +0100 Subject: [PATCH] new tool functions --- source/src/tools.cpp | 6 ++++++ source/src/tools.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 4ac00657..b5a03d9f 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -403,6 +403,12 @@ char *concatformatstring(char *d, const char *s, ...) return concatstring(d, temp); } +char *tempformatstring(const char *s, ...) +{ + static defvformatstring(temp, s, s); + return temp; +} + const char *hiddenpwd(const char *pwd, int showchars) { static int sc = 3; diff --git a/source/src/tools.h b/source/src/tools.h index 35de88bf..343f82aa 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -95,10 +95,12 @@ static inline float round(float x) { return floor(x + 0.5f); } #define strcasecmp(a,b) _stricmp(a,b) #define strncasecmp(a,b,n) _strnicmp(a,b,n) #define PATHDIV '\\' +#define PATHDIVS "\\" #else #define __cdecl #define _vsnprintf vsnprintf #define PATHDIV '/' +#define PATHDIVS "/" #endif // easy safe strings @@ -110,6 +112,7 @@ inline void vformatstring(char *d, const char *fmt, va_list v, int len = MAXSTRL inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; } inline char *concatstring(char *d, const char *s, size_t len = MAXSTRLEN) { size_t used = strlen(d); return used < len ? copystring(d+used, s, len-used) : d; } extern char *concatformatstring(char *d, const char *s, ...); +extern char *tempformatstring(const char *s, ...); struct stringformatter { @@ -831,6 +834,7 @@ inline char *newstring(const char *s, size_t l) { return copystring(newstring(l) inline char *newstring(const char *s) { return newstring(s, strlen(s)); } inline char *newstringbuf() { return newstring(MAXSTRLEN-1); } inline char *newstringbuf(const char *s) { return newstring(s, MAXSTRLEN-1); } +inline void delstring(const char *s) { delete[] (char *)s; } #ifndef STANDALONE inline const char *_gettext(const char *msgid)