mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Clean up some uses of String::substr
Cases where the end position is either equvalent to the default or past the end of the string.
This commit is contained in:
parent
f2cc3f1275
commit
5113022dfe
54 changed files with 123 additions and 123 deletions
|
|
@ -218,7 +218,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter
|
|||
int brk_end = bbcode.find_char(']', brk_pos + 1);
|
||||
|
||||
if (brk_end == -1) {
|
||||
String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos);
|
||||
String text = bbcode.substr(brk_pos);
|
||||
if (code_tag || tag_stack.size() > 0) {
|
||||
output.append("'" + text + "'");
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter
|
|||
String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
|
||||
|
||||
if (tag.begins_with("/")) {
|
||||
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
|
||||
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1);
|
||||
|
||||
if (!tag_ok) {
|
||||
output.append("]");
|
||||
|
|
@ -246,7 +246,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter
|
|||
} else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) {
|
||||
const int tag_end = tag.find_char(' ');
|
||||
const String link_tag = tag.substr(0, tag_end);
|
||||
const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" ");
|
||||
const String link_target = tag.substr(tag_end + 1).lstrip(" ");
|
||||
|
||||
const Vector<String> link_target_parts = link_target.split(".");
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter
|
|||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag.begins_with("url=")) {
|
||||
String url = tag.substr(4, tag.length());
|
||||
String url = tag.substr(4);
|
||||
// Not supported. Just append the url.
|
||||
output.append(url);
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
|
|||
|
||||
if (brk_end == -1) {
|
||||
if (!line_del) {
|
||||
String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos);
|
||||
String text = bbcode.substr(brk_pos);
|
||||
if (code_tag || tag_stack.size() > 0) {
|
||||
xml_output.append(text.xml_escape());
|
||||
} else {
|
||||
|
|
@ -522,7 +522,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
|
|||
String tag = bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
|
||||
|
||||
if (tag.begins_with("/")) {
|
||||
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
|
||||
bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1);
|
||||
|
||||
if (!tag_ok) {
|
||||
if (!line_del) {
|
||||
|
|
@ -558,7 +558,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
|
|||
} else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) {
|
||||
const int tag_end = tag.find_char(' ');
|
||||
const String link_tag = tag.substr(0, tag_end);
|
||||
const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" ");
|
||||
const String link_target = tag.substr(tag_end + 1).lstrip(" ");
|
||||
|
||||
const Vector<String> link_target_parts = link_target.split(".");
|
||||
|
||||
|
|
@ -763,7 +763,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
|
|||
pos = brk_end + 1;
|
||||
tag_stack.push_front(tag);
|
||||
} else if (tag.begins_with("url=")) {
|
||||
String url = tag.substr(4, tag.length());
|
||||
String url = tag.substr(4);
|
||||
xml_output.append("<a href=\"");
|
||||
xml_output.append(url);
|
||||
xml_output.append("\">");
|
||||
|
|
@ -3011,7 +3011,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
|
|||
}
|
||||
|
||||
// Apparently the name attribute must not include the @
|
||||
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1, iarg.name.length()) : iarg.name;
|
||||
String param_tag_name = iarg.name.begins_with("@") ? iarg.name.substr(1) : iarg.name;
|
||||
// Escape < and > in the attribute default value
|
||||
String param_def_arg = def_arg.replacen("<", "<").replacen(">", ">");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue