Commit Graph

146 Commits

Author SHA1 Message Date
Haoyu Qiu 562e583872
Fix split_floats behavior when spaces are used as separators
(cherry picked from commit f483c3aafa)
2024-09-16 16:40:48 +02:00
A Thousand Ships a0dbdcc3ab
Replace `find` with `contains/has` where applicable
* Replaces `find(...) != -1` with `contains` for `String`
* Replaces `find(...) == -1` with `!contains` for `String`
* Replaces `find(...) != -1` with `has` for containers
* Replaces `find(...) == -1` with `!has` for containers
2024-05-08 12:37:42 +02:00
Wilson E. Alvarez d4154dbc55
Add const char * overloads to String class
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-05-07 10:53:00 -04:00
Haoyu Qiu 9bcda8f94c Prefer family name in fonts' names table 2024-04-06 16:08:59 +08:00
A Thousand Ships bb6305d1c4
[Core] Fix incorrect file sort method 2024-03-24 17:54:57 +01:00
Rémi Verschelde 8f9136963d
Merge pull request #89671 from alesliehughes/string_underrun
Stop possible underrun when processing a string
2024-03-24 01:21:12 +01:00
A Thousand Ships 2cbf469912
Fix sorting of files/dirs in dialogs
Sorts leading `_` before other characters except `.`.
2024-03-20 13:45:47 +01:00
Alistair Leslie-Hughes 87fe71f52f Stop possible underrun when processing a string
Calling String::utf8("Unicode String", -1) assumes that the string will be NULL terminated.
However, the length parameter is always used to find the end of the string.  So there is the
chance the character before th start of the string is read.

Making the pointer NULL in the case where it's out of range, still allows the following
to work as expected
while (ptrtmp != ptrtmp_limit && *ptrtmp)
....
2024-03-19 20:17:11 +11:00
Thaddeus Crews 9903e6779b
Enforce template syntax `typename` over `class` 2024-03-07 22:39:09 -06:00
Mika Viskari 3026b566b0 Fix String::begins_with when both strings are empty 2024-03-05 20:46:10 +02:00
Michael Alexsander d70c45b5c8
Add option to add built-in strings in the POT generation 2024-02-28 11:34:26 -03:00
Robert Yevdokimov 13e82094ee Remove word duplicates in comments and strings, and fix casing and punctuation 2024-02-23 17:28:28 -05:00
Danil Alexeev c0aa88ae4f
Add Unicode support to `String.to_*_case()` methods 2024-02-22 13:58:46 +03:00
Muller-Castro a8bc9f3e78 Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
A Thousand Ships 15369fdb1d
Remove unnecessary `this->` expressions 2024-01-29 09:59:18 +01:00
Rémi Verschelde 5fd5176a79
Merge pull request #84462 from MewPurPur/optimize-humanizesize
Optimize `String.humanize_size()`
2024-01-04 14:25:40 +01:00
Rémi Verschelde 6c390b620d
Merge pull request #84445 from Rubonnek/add-const-references-clang-tidy
Add const references detected by clang-tidy
2024-01-04 14:25:33 +01:00
Rémi Verschelde b66d16fcc9
Merge pull request #84375 from Rubonnek/use-const-reference
Add const references in `String` class
2024-01-04 14:25:27 +01:00
Wilson E. Alvarez a3cb1b096f
Add const references detected by clang-tidy 2023-12-16 13:36:44 -05:00
Pedro J. Estébanez 208c1020f5 Add 'u' format modifier for unsigned int/hex 2023-12-01 16:42:26 +01:00
bruvzg ec052cd38a
Add unsigned char cast ifdef. 2023-11-29 11:59:18 +02:00
Yuri Sizov edcad2ea88 Allow auto-generated node names in `PopupMenu::add_submenu_item` 2023-11-09 17:12:41 +01:00
MewPurPur 931928feb9 Optimize String.humanize_size() 2023-11-05 02:42:54 +02:00
Wilson E. Alvarez dbc49d2a68
Add const references in String class 2023-11-02 13:49:39 -04:00
Alfonso J. Ramos 5cd7ca0ccc Do not replace starting digit with underscore when making identifier 2023-10-04 08:05:04 -05:00
Jan Haller 43be9fa0c8 Fix platform-dependent hashing for char* and wchar_t*
Since char/wchar_t can be either signed or unsigned, its conversion to uint32_t leads to different values depending on platform.
In particular, the same string represented as char* (Latin-1; StringName direct construction) or uint32_t (UTF-8; constructed
via String) previously resulted in different hashes.
2023-09-24 20:57:57 +02:00
bruvzg 2b3bbde6da
[String] Fix string conversion for -0.0 float values. 2023-09-05 11:32:55 +03:00
MewPurPur c9287e5224 Optimize String.left() and String.right() 2023-08-20 20:01:06 +03:00
Rémi Verschelde 20e24bd2bb
Merge pull request #78529 from Chaosus/string_reverse
Add `String.reverse` method
2023-08-16 16:53:40 +02:00
bruvzg 84a6f0d232 [String] Fix Unicode parsing error message encoding and related JSON tests. 2023-07-28 12:27:01 +03:00
MewPurPur cc5500f7de Fix erroneous pad_zeros warning 2023-07-08 16:16:01 +03:00
Rémi Verschelde 100082b3ac
Merge pull request #74760 from lassade/unicode-err-uses-replacement-char
Don't append non unicode scalar values on the string, instead use the unicode replacement char
2023-06-22 18:30:04 +02:00
Yuri Roubinski 230385b587 Add `String.reverse` method 2023-06-21 20:40:48 +03:00
Rémi Verschelde 5ade250c7d
Merge pull request #76735 from AThousandShips/natural_cmp
Add `naturalcasecmp_to` function to `String`
2023-05-09 17:44:37 +02:00
Ninni Pipping 46a7018e3c Add `naturalcasecmp_to` function to `String`
Functions as a complement to `naturalnocasecmp_to`
2023-05-07 10:17:53 +02:00
Clay John 7a13cf9aeb
Merge pull request #75510 from SilicDev/string_erase
Reimplement `String.erase()` as immutable method
2023-05-05 10:03:49 -07:00
Clay John 610877e326
Merge pull request #72288 from MewPurPur/use-string-repeat
Use `String.repeat()` to optimize several String methods
2023-05-05 09:56:48 -07:00
SilicDev 6fa4f71ca6 Reimplement String.erase 2023-05-04 00:52:35 +02:00
VolTer 6b84e258d2 Use String.repeat() in more places 2023-05-01 02:27:46 +02:00
Danil Alexeev 36bedd341a
Fix misuses of error macros 2023-04-18 10:20:48 +03:00
Juan Linietsky 223ce4fcb9 Optimize Node::add_child validation
Adding 10k nodes is almost twice as fast.
2023-04-07 13:18:47 +02:00
bendn ca0feabbb0
add `hex_decode()` to `String` 2023-04-05 19:44:00 +07:00
bruvzg d72b563250
Add GDScript `to_wchar_buffer` and `get_string_from_wchar` functions. 2023-03-21 15:39:54 +02:00
Felipe Jorge 999f3e2c13 use the unicode replacement char on error
update tests

also fix utf8 and ascii parse functions to use the replacement char

created a _replacement_char const inside the string
2023-03-12 11:46:56 -03:00
VolTer 57e39d0ce9 Fix String.split() with empty string and delimeter 2023-02-02 01:34:11 +01:00
K. S. Ernest (iFire) Lee 39922d7167 Handle gltf binary
[ Ignore and Warn | Extract Textures (default) | Optimize Loading Embedded as Basisu ]

Enable compressed mip maps from Basis Universal for faster compressions.

Increase the quality of Basis to avoid corruption.

To keep compatibility use the first mip of the previous internal Godot format.

Because texture names may have invalid filename characters, adds String::validate_filename to sanitize filenames for import pipeline use.
2023-01-27 02:02:02 -08:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Haoyu Qiu 207e52c161 Fix String::word_wrap() for long words
- Changes `TextServer.string_get_word_breaks()`
  - Returns pairs of boundary start and end offsets
  - Accepts `chars_per_line` to return line breaks
- Removes `String::word_wrap()`

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>
2022-12-16 13:18:57 +08:00
Bastiaan Olij a479f5af22 Improve logic for detecting and tracking extensions 2022-11-24 21:48:16 +11:00
Micky e791f4fce2 Double precision of `String.split_floats` 2022-11-20 12:29:50 +01:00