Commit graph

171 commits

Author SHA1 Message Date
qarmin
33c62db7af Add forgotten pointer checking 2019-08-24 13:34:14 +02:00
Rémi Verschelde
3a53e792ef
Merge pull request #31513 from qarmin/int_overflow
Prevent int overflow and underflow
2019-08-23 09:05:25 +02:00
qarmin
538405f9c7 Prevent int overflow and underflow 2019-08-22 17:22:35 +02:00
Fabio Alessandrelli
c19871af6d Move CryptoCore to it's own folder.
Crypto classes will be placed in core/crypto.
2019-08-19 16:31:05 +02:00
Chaosus
080c0bb7fe Added count method to String 2019-07-23 18:55:54 +03:00
Fabio Alessandrelli
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
qarmin
9a77d748c0 Fixes minor issues found by static analyzer 2019-07-07 23:08:51 +02:00
Fabio Alessandrelli
6c512e21a9 Add sha1 functions to string (using new CryptoCore) 2019-07-03 18:42:46 +02:00
Fabio Alessandrelli
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
qarmin
3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
qarmin
4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
Rémi Verschelde
2b52cd3e5c
Merge pull request #28648 from KoBeWi/substr-1
Make second parameter of substr optional
2019-06-19 12:43:46 +02:00
Rémi Verschelde
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
Rémi Verschelde
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
Rémi Verschelde
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
Hugo Locurcio
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
Hugo Locurcio
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
qarmin
8245db869f Small fixes to unrechable code, possibly overflows, using NULL pointers 2019-06-03 21:52:50 +02:00
Rémi Verschelde
af2c742f53 Fix and expose String::strip_escapes(), use it in LineEdit paste
Supersedes #27736.
2019-05-31 15:49:14 +02:00
Tomasz Chabora
0b8a785539 Make second parameter of substr optional 2019-05-03 19:46:56 +02:00
jude-lafitteIII
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
Ibrahn Sahir
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
Juan Linietsky
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
Hein-Pieter van Braam
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
marxin
c11e7ffd0e Fix warnings seen with -Wignored-qualifiers. 2019-02-21 20:24:29 +01:00
marxin
8d51618949 Add -Wshadow=local to warnings and fix reported issues.
Fixes #25316.
2019-02-20 19:44:12 +01:00
lupoDharkael
597aac382b Fix wrong bounds check in String::right 2019-02-20 16:47:25 +01:00
Ibrahn Sahir
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
Hein-Pieter van Braam
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
Hein-Pieter van Braam
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
Rémi Verschelde
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
Rémi Verschelde
b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Andrii Doroshenko (Xrayez)
c891cf32ca Fix crash when checking empty string for valid hex number 2018-12-24 20:06:35 +02:00
Hein-Pieter van Braam
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
Poommetee Ketson
aa311320d9 Fix formatting -0.0 by %+f displays +-0.0 2018-11-09 15:27:06 +07:00
Juan Linietsky
c8765b459a
Merge pull request #23159 from DavidSichma/string-escape
Fix: String::format Variant to String conversion
2018-11-01 12:54:51 -03:00
David Sichma
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
Dualtagh Murray
b902a2f2a7 Fixing warnings generated by MSVC
Fixes #22684.
2018-10-19 11:45:24 +02:00
K. S. Ernest (iFire) Lee
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
exts
18b6f5a6c9 fixes #22828 - res://user had incorrect substr value 2018-10-07 09:49:48 -05:00
Rémi Verschelde
6ab78d9ffb Fix some more warnings reported by CI
Fixes the following Clang 7 warnings:
```
core/io/marshalls.cpp:872:10: warning: unused variable 'f' [-Wunused-variable]

core/ustring.cpp:1831:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
core/ustring.cpp:1832:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]

drivers/gles3/rasterizer_gles3.cpp:82:24: warning: unused function '_gl_debug_print' [-Wunused-function,34]

main/main.cpp:118:13: warning: unused variable 'auto_build_solutions' [-Wunused-variable]

modules/csg/csg_gizmos.cpp:225:46: warning: 'current' may be used uninitialized in this function [-Wmaybe-uninitialized]
```
2018-10-03 14:13:42 +02:00
Rémi Verschelde
277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Rémi Verschelde
52466d57e9 Make some debug prints verbose-only, remove others 2018-08-24 14:59:01 +02:00
Rémi Verschelde
7718b90d92
Merge pull request #20443 from AlexHolly/add-string-format-no-index
Added String.format "no index" support
2018-08-14 16:13:34 +02:00
Rémi Verschelde
9a6e4d10b4
Merge pull request #20772 from dragmz/string_copy_oob_read_fix
Fix out of buffer read when copying from a non-null-terminated string
2018-08-14 15:47:34 +02:00
Ibrahn Sahir
62f0dd9d57 removed some surplus null appends that got typoed in 0e29f7974b
A couple of null appends got typoed to append a '0' character instead.
Removed them here since String already takes care of the null terminator for us.
2018-08-07 03:30:14 +01:00
Marcin Zawiejski
f3b2689aa6 fix out of buffer read when copying non-null terminated strings 2018-08-06 23:51:07 +02:00
Hein-Pieter van Braam
0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
Alexander Holland
2290cc6227 Added String.format "no index" support 2018-07-25 13:23:44 +02:00
Alexander Holland
84db7056b7 Fix format ignores case in placeholder 2018-07-25 12:14:48 +02:00