Changeset - r27509:bafaa3ffa550
[Not reviewed]
master
0 4 0
Rubidium - 12 months ago 2023-06-04 16:02:46
rubidium@openttd.org
Cleanup: strecat has no uses anymore
4 files changed with 2 insertions and 30 deletions:
0 comments (0 inline, 0 general)
src/safeguards.h
Show inline comments
 
@@ -36,7 +36,7 @@
 
#define strcpy    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strncpy   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use strecat instead. */
 
/* Use std::string concatenation/fmt::format instead. */
 
#define strcat    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strncat   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
src/string.cpp
Show inline comments
 
@@ -49,33 +49,6 @@
 
#include "safeguards.h"
 
#undef vsnprintf
 

	
 
/**
 
 * Appends characters from one string to another.
 
 *
 
 * Appends the source string to the destination string with respect of the
 
 * terminating null-character and and the last pointer to the last element
 
 * in the destination buffer. If the last pointer is set to nullptr no
 
 * boundary check is performed.
 
 *
 
 * @note usage: strecat(dst, src, lastof(dst));
 
 * @note lastof() applies only to fixed size arrays
 
 *
 
 * @param dst The buffer containing the target string
 
 * @param src The buffer containing the string to append
 
 * @param last The pointer to the last element of the destination buffer
 
 * @return The pointer to the terminating null-character in the destination buffer
 
 */
 
char *strecat(char *dst, const char *src, const char *last)
 
{
 
	assert(dst <= last);
 
	while (*dst != '\0') {
 
		if (dst == last) return dst;
 
		dst++;
 
	}
 

	
 
	return strecpy(dst, src, last);
 
}
 

	
 

	
 
/**
 
 * Copies characters from one buffer to another.
src/string_func.h
Show inline comments
 
@@ -30,7 +30,6 @@
 
#include "core/span_type.hpp"
 
#include "string_type.h"
 

	
 
char *strecat(char *dst, const char *src, const char *last) NOACCESS(3);
 
char *strecpy(char *dst, const char *src, const char *last) NOACCESS(3);
 
char *stredup(const char *src, const char *last = nullptr) NOACCESS(2);
 

	
src/strings_internal.h
Show inline comments
 
@@ -122,7 +122,7 @@ public:
 
	}
 

	
 
	/**
 
	 * Add a string using the strecpy/strecat-esque calling signature.
 
	 * Add a string using the strecpy-esque calling signature.
 
	 * @param function The function to pass the current and last location to,
 
	 *                 that will then return the new current location.
 
	 */
0 comments (0 inline, 0 general)