| 46 | namespace { |
| 47 | |
| 48 | int sfind(const String &p_text, int p_from) { |
| 49 | if (p_from < 0) { |
| 50 | return -1; |
| 51 | } |
| 52 | |
| 53 | int src_len = 2; |
| 54 | int len = p_text.length(); |
| 55 | |
| 56 | if (len == 0) { |
| 57 | return -1; |
| 58 | } |
| 59 | |
| 60 | const char32_t *src = p_text.get_data(); |
| 61 | |
| 62 | for (int i = p_from; i <= (len - src_len); i++) { |
| 63 | bool found = true; |
| 64 | |
| 65 | for (int j = 0; j < src_len; j++) { |
| 66 | int read_pos = i + j; |
| 67 | |
| 68 | ERR_FAIL_COND_V(read_pos >= len, -1); |
| 69 | |
| 70 | switch (j) { |
| 71 | case 0: |
| 72 | found = src[read_pos] == '%'; |
| 73 | break; |
| 74 | case 1: { |
| 75 | char32_t c = src[read_pos]; |
| 76 | found = src[read_pos] == 's' || (c >= '0' && c <= '5'); |
| 77 | break; |
| 78 | } |
| 79 | default: |
| 80 | found = false; |
| 81 | } |
| 82 | |
| 83 | if (!found) { |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | if (found) { |
| 89 | return i; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return -1; |
| 94 | } |
| 95 | } // namespace |
| 96 | |
| 97 | String sformat(const String &p_text, const String &p1, const String &p2, |