mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 20:12:07 +00:00
Deprecate 1-indexed string functions
This commit is contained in:
@@ -351,6 +351,8 @@ std::string
|
||||
}
|
||||
|
||||
std::string act_StringSub(std::string const &str, int32_t negPos, std::optional<uint32_t> optLen) {
|
||||
warning(WARNING_OBSOLETE, "`STRSUB` is deprecated; use 0-indexed `STRSLICE` instead");
|
||||
|
||||
size_t adjustLen = act_StringLen(str, false);
|
||||
uint32_t pos = adjustNegativePos(negPos, adjustLen, "STRSUB");
|
||||
uint32_t len = optLen ? *optLen : pos > adjustLen ? 0 : adjustLen + 1 - pos;
|
||||
@@ -447,6 +449,8 @@ std::string act_StringChar(std::string const &str, int32_t negIdx) {
|
||||
}
|
||||
|
||||
std::string act_CharSub(std::string const &str, int32_t negPos) {
|
||||
warning(WARNING_OBSOLETE, "`CHARSUB` is deprecated; use 0-indexed `STRCHAR` instead");
|
||||
|
||||
size_t adjustLen = act_CharLen(str);
|
||||
uint32_t pos = adjustNegativePos(negPos, adjustLen, "CHARSUB");
|
||||
|
||||
|
||||
@@ -1493,10 +1493,12 @@ relocexpr_no_str:
|
||||
$$.makeNumber(pos != std::string::npos ? pos : -1);
|
||||
}
|
||||
| OP_STRIN LPAREN string COMMA string RPAREN {
|
||||
warning(WARNING_OBSOLETE, "`STRIN` is deprecated; use 0-indexed `STRFIND` instead");
|
||||
size_t pos = $3.find($5);
|
||||
$$.makeNumber(pos != std::string::npos ? pos + 1 : 0);
|
||||
}
|
||||
| OP_STRRIN LPAREN string COMMA string RPAREN {
|
||||
warning(WARNING_OBSOLETE, "`STRRIN` is deprecated; use 0-indexed `STRRFIND` instead");
|
||||
size_t pos = $3.rfind($5);
|
||||
$$.makeNumber(pos != std::string::npos ? pos + 1 : 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user