Files
@ r3016:b28a60dfd364
Branch filter:
Location: cpp/openttd-patchpack/source/string.h - annotation
r3016:b28a60dfd364
1.4 KiB
text/x-c
(svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
This increases the execution speed a lot since GCC can't detect the OTTD macro as an endian conversion
while Apple's code uses the instruction to convert endian instead of a series of instructions to produce the same result
Since we don't have that many endian conversions in the game, overall performance should not increase noteworthy
This increases the execution speed a lot since GCC can't detect the OTTD macro as an endian conversion
while Apple's code uses the instruction to convert endian instead of a series of instructions to produce the same result
Since we don't have that many endian conversions in the game, overall performance should not increase noteworthy
r2186:5ee653b1b5e1 r2186:5ee653b1b5e1 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r1317:3783af524858 r2234:6f59925a7314 r2234:6f59925a7314 r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2775:3e6efcedc84d r2436:963efe8b84cc | /* $Id$ */
#ifndef STRING_H
#define STRING_H
/*
* dst: destination buffer
* src: string to copy/concatenate
* size: size of the destination buffer
* usage: ttd_strlcpy(dst, src, lengthof(dst));
*/
void ttd_strlcat(char *dst, const char *src, size_t size);
void ttd_strlcpy(char *dst, const char *src, size_t size);
/*
* dst: destination buffer
* src: string to copy
* last: pointer to the last element in the dst array
* if NULL no boundary check is performed
* returns a pointer to the terminating \0 in the destination buffer
* usage: strecpy(dst, src, lastof(dst));
*/
char* strecat(char* dst, const char* src, const char* last);
char* strecpy(char* dst, const char* src, const char* last);
char* CDECL str_fmt(const char* str, ...);
/** Scans the string for valid characters and if it finds invalid ones,
* replaces them with a question mark '?' */
void str_validate(char *str);
/** Only allow valid ascii-function codes. Filter special codes like BELL and
* so on [we need a special filter here later]
* @param key character to be checked
* @return true or false depending if the character is printable/valid or not */
static inline bool IsValidAsciiChar(byte key)
{
// XXX This filter stops certain crashes, but may be too restrictive.
return (key >= ' ' && key < 127) || (key >= 160 &&
key != 0xAA && key != 0xAC && key != 0xAD && key != 0xAF &&
key != 0xB5 && key != 0xB6 && key != 0xB7 && key != 0xB9);
}
#endif /* STRING_H */
|