19 Commits

Author SHA1 Message Date
Torbjörn Andersson
976d6564bc COMMON: Allow \0 to be appended to Strings
This has been discussed on the mailing list. While there wasn't much
input, the consensus was that it should be allowed for consistency with
std::string.

While most engines don't do this, it is possible that some engines will
break because of it. (A few have already been fixed.) But it will also
repear the currently broken ADL engine. For now, the warning() message
will remain so that it can be investigated on a case-by-case basis.
2021-07-13 10:35:19 +02:00
D G Turner
e83f23f264 COMMON: Fix Development Tools Build
This is not the best solution as it removes the warning when this
code is used by devtools such as create_titanic, but getting this to
link would need inclusion of textconsole.o via shim and then still
breaks on g_system, so fastest solution to restore build.
2021-06-29 15:39:27 +01:00
Torbjörn Andersson
a420aa9594 COMMON: Include textconsole.h in base-str.cpp
While it's not needed to build ScummVM, apparently some of the other
tools that use String do not include textconsole.h and complain that
warning() is undefined.
2021-06-29 15:12:20 +02:00
Torbjörn Andersson
ab06f27d43 COMMON: Add warning when adding \0 to a String
Some engines do this, and it's not really known what should happen. We
need to decide on a behavior, and stick to that. This warning is to help
find where it happens.

From my own tests, it can happen in at least ADL, Avalanche, Chewy,
Director, Blazing Dragons, MacVenture, MADS, Prince, Stark, Startrek,
and Trecision. Only ADL is known to be broken by the current behavior.

The result of my test can be found at
http://www.update.uu.se/~d91tan/tmp/string.txt
2021-06-29 13:37:05 +02:00
lb_ii
6f8764b14c COMMON: Rewrite BASESTRING::contains() with algorithm from BASESTRING::find() 2021-06-21 02:29:05 +03:00
lb_ii
b886c238fe COMMON: Fix BASESTRING::contains() 2021-06-21 02:29:05 +03:00
Orgad Shaneh
a05e54f00c JANITORIAL: Remove trailing whitespaces 2021-05-04 11:46:30 +03:00
Eugene Sandulenko
5e7fe2dc57
JANITORIAL: Replace spaces in indentation with tabs 2021-04-15 21:20:36 +02:00
Thierry Crozat
7988c1a23c COMMON: Fix compilation of devtools 2021-03-31 23:28:11 +01:00
Thierry Crozat
93e8e2a8c5 COMMON: Fix regression on String thread safety
The string memory pool mutex lock/unlock were lost during the
merge of String and U32String. This caused the cloud feature
to randomly crash for example when synchronizing savegames or
downloading game data.
2021-03-31 22:50:11 +01:00
Jonathan Phénix
7d5405cea5 COMMON: Fix build warning with LLVM's scan-build 2020-12-22 01:49:55 +01:00
Vladimir Serbinenko
68a9136e4d
COMMON: Rewrite Encoder and drop dependency on iconv (#2586)
Different platforms have different levels of support of encodings and
often have slight variations. We already have tables for most encoding
with only CJK missing. Full transcoding inclusion allows us to get reliable
encoding results independently of platform. The biggest con is the need for
external tables encoding.dat.

It removes a duplicate table for korean in graphics/korfont.cpp
2020-11-15 16:20:35 +01:00
Mathias Parnaudeau
4880fab063 COMMON: Use appropriate equals() in BaseString
Remove a useless creation of a BaseString object with a C string in
comparison operators of this class, because there is a function
equals() that accepts a C string in parameter.
2020-11-06 21:21:05 +00:00
Thierry Crozat
e5bfe63087 COMMON: Merge the String and U32String destructors
The call to decRefCount has been moved to the destructor
of the base class BaseString.

Note that BaseString only exists for the purpose of being able
to reuse code for our String and U32String implementations. As
such it is not meant to be used polymorphically and its
destructor does not need to be virtual (with the overhead that
this generates). And to ensure that it is not used in a
polymorphic way, the destructor is declared protected.
2020-11-05 23:52:19 +00:00
Thierry Crozat
f18ee89b27 JANITORIAL: Fix indentation issues 2020-11-05 23:52:19 +00:00
Vladimir Serbinenko
54b0b4ac4c COMMON: Restore old behaviour for appending char to string
Appending \0 to string and expecting it to be just dropped is
still an invalid behaviour but it already happened in 2 engines, so
restore old behaviour, at least for now
2020-11-03 11:19:20 +01:00
Paul Gilbert
7775330954 COMMON: Ignore string erase calls when the passed length is zero 2020-11-02 21:49:05 -08:00
Vladimir Serbinenko
0d7ab6cd64 COMMON: compilation fix on some older compilers 2020-11-01 14:58:46 +01:00
Vladimir Serbinenko
29cfa7bb0f COMMON: Merge code for str.cpp and ustr.cpp
Most of the code in str.cpp and ustr.cpp is actually the same. Do some
template magic to merge them.
2020-10-31 14:05:30 +01:00