Commit Graph

182 Commits

Author SHA1 Message Date
5d6ff7f2a2 Fix MinGW/clang/LLD/UCRT build. 2019-11-08 15:04:35 +02:00
bdb7adecfb Fix #24137 Different number of leading zeros on MINGW printf("%lg")
Use _set_output_format() on MINGW platform to force _snprintf_s() to
conform to the C99 standard and match the other platforms.

Fixes #24137
2019-11-07 16:23:35 -08:00
9ddb3265e1 Fix some crashes, overflows and using variables without values 2019-11-01 16:16:31 +01:00
3b8004865d Remove redundant condition in String::_humanize_digits() 2019-10-04 18:07:06 +02:00
a0d00c0e99 Bind the String::humanize_size method
The method signature is also changed to use `uint64_t` instead of `size_t`
for it to be Variant-compatible.
2019-10-04 15:51:13 +03:00
ef2a7834c9 Merge pull request #31883 from aole/create-string-function-repeat
Create a GDScript String function repeat
2019-09-24 11:50:58 +02:00
ed18e3f195 Merge pull request #32273 from Calinou/humanize-size-fix-i18n
Fix i18n in `String::humanize_size()`
2019-09-23 15:57:18 +02:00
a51e8b1ff0 Fix i18n in String::humanize_size()
Calls to `RTR()` must be added to each string so the PO file generator
can pick them up.
2019-09-23 13:54:10 +02:00
50be65bf43 Changed some code found by Clang Tidy and Coverity 2019-09-22 18:45:08 +02:00
9a94fe7d26 Improve the String::humanize_size() method
- Use "B" insted of "Bytes" to be more compact
- Use suffixes that denote a binary prefix
- Make suffixes localizable

This removes the need for the custom
`EditorNetworkProfiler:_format_bandwidth()` method.
2019-09-05 19:48:46 +02:00
073f625a91 Create a GDScript String function repeat
Fixes #30610
2019-09-03 13:06:13 -04:00
33c62db7af Add forgotten pointer checking 2019-08-24 13:34:14 +02:00
3a53e792ef Merge pull request #31513 from qarmin/int_overflow
Prevent int overflow and underflow
2019-08-23 09:05:25 +02:00
538405f9c7 Prevent int overflow and underflow 2019-08-22 17:22:35 +02:00
c19871af6d Move CryptoCore to it's own folder.
Crypto classes will be placed in core/crypto.
2019-08-19 16:31:05 +02:00
080c0bb7fe Added count method to String 2019-07-23 18:55:54 +03:00
2f91e250f6 Add NULL-terminator the string passed to strtol.
This is actually expected by the function although it was apparently
working in GCC without the terminator, it breaks (at least some) clang
versions.
2019-07-08 17:15:10 +02:00
9a77d748c0 Fixes minor issues found by static analyzer 2019-07-07 23:08:51 +02:00
6c512e21a9 Add sha1 functions to string (using new CryptoCore) 2019-07-03 18:42:46 +02:00
564d93ff10 CryptoCore class to access to base crypto utils.
Godot core needs MD5/SHA256/AES/Base64 which used to be provided by
separate libraries.
Since we bundle mbedtls in most cases, and we can easily only include
the needed sources if we so desire, let's use it.

To simplify library changes in the future, and better isolate header
dependencies all functions have been wrapped around inside a class in
`core/math/crypto_base.h`.

If the mbedtls module is disabled, we only bundle the needed source
files independently of the `builtin_mbedtls` option.
If the module is enabled, the `builtin_mbedtls` option works as usual.

Also remove some unused headers from StreamPeerMbedTLS which were
causing build issues.
2019-07-02 12:36:27 +02:00
3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
2b52cd3e5c Merge pull request #28648 from KoBeWi/substr-1
Make second parameter of substr optional
2019-06-19 12:43:46 +02:00
f410e7a8a9 Merge pull request #29616 from Calinou/humanize-size-clearer-rounding
Make humanized size rounding clearer by padding decimals with zeroes
2019-06-12 16:25:10 +02:00
704f2c5d85 Merge pull request #29615 from Calinou/fix-editor-monitor-large-sizes
Fix display of large sizes in the editor monitors
2019-06-12 15:21:37 +02:00
971b5160c6 Merge pull request #29306 from qarmin/small_code_fixes
Small fixes to unrechable code, possibly overflows, using NULL pointers
2019-06-12 12:49:21 +02:00
463d0988dd Make humanized size rounding clearer by padding decimals with zeroes
For example, "5 MB" will now be displayed as "5.00 MB" to make the
rounding precision clear, regardless of the value being rounded.

This closes #29611.
2019-06-08 22:17:57 +02:00
746bfc3662 Fix display of large sizes in the editor monitors
Unlike the old custom method, the `String::humanize_size()`
method works well with file sizes above 2 GB.

This also tweaks the suffixes for spacing consistency and
uses the correct acronym for exabytes (EB).

This closes #29610.
2019-06-08 22:05:57 +02:00
8245db869f Small fixes to unrechable code, possibly overflows, using NULL pointers 2019-06-03 21:52:50 +02:00
af2c742f53 Fix and expose String::strip_escapes(), use it in LineEdit paste
Supersedes #27736.
2019-05-31 15:49:14 +02:00
0b8a785539 Make second parameter of substr optional 2019-05-03 19:46:56 +02:00
d3cc9c0bf1 Support for binary literals in GDScript. Added an error that shows if a point is written in a hex literal. Added highlighting for binary literals in GDScript 2019-04-25 13:44:27 +01:00
9d0b3b300c fixed an access after free in OS_X11::set_context.
Added constructor and assignment operator for CharString
from const char* to simplify memory management when working with
utf8/ascii strings for APIs taking char*.
Reworked OS_X11::set_context to use CharString and avoid some manual
memory management.
2019-04-22 13:34:17 +01:00
a20235aeb0 Add ability to edit editor feature profiles
Allows enabling/disabling parts of the editor and storing/loading profiles for that.
2019-04-08 19:18:51 -03:00
4f49d09272 Don't crash when parse_utf8 receives a NULL pointer
This can happen when chaining calls to various string methods when the
string is empty.
2019-02-22 19:28:19 +01:00
c11e7ffd0e Fix warnings seen with -Wignored-qualifiers. 2019-02-21 20:24:29 +01:00
8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
597aac382b Fix wrong bounds check in String::right 2019-02-20 16:47:25 +01:00
cbb396c006 Repair String lstrip and rstrip.
Background: lstrip and rstrip were broken by changes to String in:
0e29f7974b
which removed it's access to Vector::find(CharType).

Moved Vector's find up into CowData so it can be shared by Vector and String.
Added String::find_char using CowData::find.
Implemented rstrip and lstrip using find_char.
Added a few tests for String rstrip and lstrip.
2019-01-07 17:34:44 +00:00
5e6c6f3bb7 Merge pull request #21708 from hpvb/fix-21242v2
String[size()] should return a default constructed CharType
2019-01-04 20:57:22 +01:00
ac99ed3cda String[size()] should return a default constructed CharType
As per the C++ standard 21.3.4.1 for std::string:
Returns: If pos < size(), returns data()[pos]. Otherwise, if pos ==
size(), the const version returns charT(). Otherwise, the behavior is
undefined.

Since the behavior is undefined Godot now does the same thing for const
and non-const versions of operator[].

This fixes #21242 and fixes #22221.
2019-01-04 17:48:03 +00:00
70de8ca9a9 Merge pull request #24585 from Xrayez/fix-crash-hex-number
Fix crash when checking empty string for valid hex number
2019-01-04 16:19:29 +01:00
b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
c891cf32ca Fix crash when checking empty string for valid hex number 2018-12-24 20:06:35 +02:00
4e25e5066b Reduce String CoW
By introducing an intermediate proxy class for the array subscript
operator for String and CharString we can control better when CowData
will actually CoW.

This should improve performance of String usage for most cases.
2018-12-16 16:51:38 +01:00
aa311320d9 Fix formatting -0.0 by %+f displays +-0.0 2018-11-09 15:27:06 +07:00
c8765b459a Merge pull request #23159 from DavidSichma/string-escape
Fix: String::format Variant to String conversion
2018-11-01 12:54:51 -03:00
62848f94ee Fix: String::format Variant to String conversion
Previosly String::format used variant.get_construct_string() to convert
the passed Variants to Strings. This however did not match the expected
printing behavior of some datatypes: Strings for example turned out
escaped.

This fix replaces the call to get_construct_string() with a simple
conversion. This makes String::format consistent with "%s" % "sth" and
formated Variants turn out like printed as expected.
2018-10-25 20:36:49 +02:00
b902a2f2a7 Fixing warnings generated by MSVC
Fixes #22684.
2018-10-19 11:45:24 +02:00
47b42787e3 Make visualscript search better.
* There were spaces unequally inside the function definitions.
* camelcase_to_underscore() should also work for numbers inside of the camel case.
* Removed the builtin concept
* Capitalize descriptions from methods too.
* Match the visual script functions by removing the empty arguments "( )"
* Add some test cases
2018-10-11 14:22:40 -07:00