Commit Graph
174 Commits
Author SHA1 Message Date
Henry Wilsonandrubidium42 8330957a4d Codechange: Remove manual memory management from IcuStringIterator 2025-07-14 23:55:24 +02:00
Rubidiumandrubidium42 3f2b39e3f8 Codechange: replace char* where out-of-date 2025-05-04 10:43:56 +02:00
Rubidiumandrubidium42 96fd291693 Codechange: introduce GetEnv that returns optional based on std::getenv 2025-05-03 15:58:14 +02:00
Rubidiumandrubidium42 1f39d469ff Codechange: pass the characters to trim to StrTrimView 2025-05-03 15:57:53 +02:00
Rubidiumandrubidium42 e2db8277b8 Codefix: implement StrTrimInPlace without assigning a borrowed view of itself 2025-05-03 15:57:53 +02:00
froschandfrosch fda93b6f35 Codechange: Add format_append as short-hand to format_to + back_inserter. 2025-04-29 20:26:23 +02:00
Rubidiumandrubidium42 af25eecc15 Codechange: use const for std::string_view where appropriate 2025-04-29 10:15:18 +02:00
froschandfrosch 45917dbaa3 Codechange: Remove unused macro strncasecmp. 2025-04-18 17:16:48 +02:00
Peter NelsonandGitHub fa0814e257 Codefix: Codestyle consistency fixes. (#14008) 2025-04-15 20:57:13 +00:00
froschandfrosch 588fedb5db Codechange: Remove unused Utf8Consume, Utf8Decode, Utf8EncodedCharLen. 2025-04-14 18:56:23 +02:00
froschandfrosch b81a35ea89 Codechange: Use StringConsumer and Builder in StrMakeValid and StrValid. 2025-04-14 18:07:23 +02:00
froschandfrosch 9229956f04 Codechange: Replace strcasestr with StrContainsIgnoreCase. 2025-04-09 17:19:11 +02:00
froschandfrosch 14bab7d76b Codechange: Remove unused Utf8TrimString, Utf8PrevChar. 2025-04-09 17:19:11 +02:00
froschandfrosch 9dc751ed8a Codechange: Remove now unused Utf8Encode. 2025-04-08 23:10:58 +02:00
froschandGitHub 04246c530f Codechange: Use fmt::format instead of stringstream with iomanip flags. (#13964) 2025-04-08 20:57:50 +00:00
Peter NelsonandGitHub 5b9d171e63 Codechange: Use EnumBitSet for StringValidationSettings. (#13974) 2025-04-08 21:19:17 +01:00
froschandGitHub 2cdf2bedfa Codechange: Add a std::string overload for StrMakeValidInPlace() and a moving std::string&& overload for StrMakeValid(). (#13962) 2025-04-07 18:22:47 +02:00
froschandGitHub 44984f8410 Codechange: Remove broken and unused StrMakeValidInPlace overload. (#13960)
If an otherwise valid string without NUL termination was passed, a NUL was appended out of bounds.
2025-04-04 11:48:32 +02:00
froschandfrosch f06bfc0dad Codechange: Use Utf8View to const-iterate over strings, if no particular error handling is needed. 2025-04-03 18:43:41 +02:00
froschandfrosch f19e75b606 Codechange: Use Utf8View in Utf8StringLength. 2025-04-03 18:43:41 +02:00
froschandfrosch 83401ad5e2 Codechange: Use Utf8View::iterator in StringIterator. 2025-04-03 18:43:41 +02:00
froschandGitHub d4ae0f70da Codechange: StringFilter now uses std::string_view entirely (#13869) 2025-03-22 20:35:31 +01:00
Rubidiumandrubidium42 02f040b22a Codechange: remove unused alloc_func.hpp includes 2025-02-24 20:00:19 +01:00
Peter NelsonandPeter Nelson 1f21e9dc74 Codechange: String parameter encoding for regular strings.
This allows a string and its parameters to be encoded and stored as just one string, instead of juggling with capturing and restoring string parameters.

The advantage of EncodedStrings over raw strings is they use current language and parameter values at the point of decoding.
2025-02-10 22:49:14 +00:00
Peter NelsonandGitHub dccc6185b9 Codechange: Change internal format of encoded strings to improve robustness and allow expansion. (#13499) 2025-02-09 12:45:50 +00:00
Peter NelsonandGitHub 9cf47e69d6 Fix bb8a0c7641: Skip control codes when sorting strings. (#13035)
Now that SkipGarbage doesn't skip all multi-byte utf-8 characters, string control codes are not skipped either. This gave unintended sorting when NewGRF names start with colour codes.

Make SkipGarbage UTF-8 aware so that it is able to skip some unicode ranges as well.
2024-10-27 15:49:09 +00:00
Peter NelsonandGitHub bb8a0c7641 Fix: SkipGarbage() skipped all multi-byte utf-8 characters. (#13032)
`char` is signed so `str[0] < '0'` applies to all characters higher than 127.
2024-10-26 21:01:33 +01:00
Peter NelsonandGitHub 56b0eac2e9 Codechange: Use std::span/std::string_view for strecpy. (#12848)
This avoids needing to manually pass the last character of the destination buffer, and allows use of standard library functions.
2024-07-09 00:05:42 +01:00
Peter NelsonandGitHub aee04e7bc6 Codechange: Pass span to StrValid instead of first and last - 1. (#12846)
`std::span` is used instead of `std::string_view` as this is only used for fixed-length buffers.

This removes some callers of `lastof()`
2024-07-08 08:36:57 +01:00
Patric StoutandGitHub a3cfd23cf9 Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Ivan FeferandGitHub 23d733be95 Add: Basic autocompletion on tab for console commands (#12163) 2024-03-13 21:43:08 +01:00
Patric StoutandGitHub 75f21065c9 Codechange: refactor DecodeHexText to a generic purpose ConvertHexToBytes (#11866)
DecodeHexText() does more than just decoding hex. ConvertHexToBytes()
now only does pure hex decoding. This required a bit of refactoring
for the code using DecodeHexText().
2024-01-22 19:42:47 +01:00
Rubidiumandrubidium42 2d77cf9c80 Codechange: replace StrStartsWith/StrEndsWith with starts_with and ends_with 2024-01-17 19:48:22 +01:00
Patric StoutandPatric Stout fd073a2810 Remove: replace custom span with std::span 2024-01-17 00:25:08 +01:00
Jonathan G RennisonandGitHub 88324a253e Fix #11644: Off by one error/buffer over-read in StrMakeValid (#11645)
* Fix #11644: Off by one error in StrMakeValid UTF-8 decode overrun detection

* Fix #11644: Off by one error in StrMakeValid buffer last character

* Fix: Unnecessary string duplication at StrMakeValid call sites
2024-01-01 13:26:31 -05:00
Michael Lutz 86e28e79fb Fix #11402: Make string filter locale-aware. 2023-11-03 22:34:01 +01:00
Michael Lutz c294eaacc1 Fix: char_traits::find needs to return nullptr if nothing was found. 2023-11-03 22:34:01 +01:00
Rubidiumandrubidium42 37f84b7372 Codechange: replace x.size() != 0 with !x.empty() 2023-10-20 23:05:43 +02:00
Peter NelsonandPeterN 49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
Rubidiumandrubidium42 eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Rubidiumandrubidium42 b958a343fe Codechange: the templated StrMakeValidInPlace is not in place 2023-07-06 19:59:41 +02:00
Rubidiumandrubidium42 e04d43f396 Remove: now unused stredup 2023-07-03 18:08:03 +02:00
Rubidiumandrubidium42 48dcb79145 Cleanup: remove seprintf and vsnprintf 2023-06-09 06:41:33 +02:00
Rubidiumandrubidium42 97dd84d1e0 Codechange: move saveload string fixing code to saveload 2023-06-08 20:36:27 +02:00
Rubidiumandrubidium42 e762855201 Cleanup: remove str_strip_colours; StrMakeValid also removes the colours
Essentially str_strip_colours followed by StrMakeValid makes the calling of
str_strip_colours useless, as StrMakeValid would have removed them too.
2023-06-08 19:32:15 +02:00
Rubidiumandrubidium42 4ca23a19b6 Cleanup: char-pointer variant of strtolower 2023-06-08 18:09:11 +02:00
Rubidiumandrubidium42 ce8933d63e Add: std::back_insert_iterator<std::string> Utf8Encode function 2023-06-05 23:26:12 +02:00
Rubidiumandrubidium42 6a519f5d89 Cleanup: strecat has no uses anymore 2023-06-04 19:45:42 +02:00
Rubidiumandrubidium42 acec34a0fe Cleanup: remove MD5SumToString in lieu of FormatArrayAsHex 2023-05-19 11:24:44 +02:00
Rubidiumandrubidium42 d9a04ba446 Codechange: make the MD5 hash/digest/checksum variables a std::array 2023-05-19 11:24:44 +02:00