174 Commits

Author SHA1 Message Date
Sergio
d136a5f54c COMMON: fix String::rfind for default value of pos (max value of size_t) 2022-11-26 23:13:42 +02:00
Le Philousophe
cd785e2208 COMMON: Add sprintf_s and vsprintf_s
These functions will issue warnings and truncate strings.
It's like snprintf and vsnprintf but noisier.
There are also versions automatically determining size based on the destination
array size.
This raises a compilation error when the size cannot be determined by
the compiler.
2022-10-23 22:46:19 +02:00
Le Philousophe
9c04d72471 COMMON: Forbid use of unsafe strcat and strcpy 2022-10-23 22:46:19 +02:00
Le Philousophe
f8c25e2374 COMMON: Add strcpy_s and strcat_s
These functions will issue warnings and truncate strings.
It's like strlcpy and strlcat but noisier.
There are also versions automatically determining size based on the destination
array size.
This raises a compilation error when the size cannot be determined by
the compiler.
2022-10-23 22:46:19 +02:00
elasota
cdedda7fa8 COMMON: Add move semantic assign and construct to strings 2022-09-28 17:09:34 +02:00
Eugene Sandulenko
498b2ca3a0
COMMON: Added firstPathComponents() method.
A better name is welcome
2022-03-14 21:16:03 +01:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh
cb61ec37c4 COMMON: Use nullptr
Using clang-tidy modernize-use-nullptr
2021-11-14 15:51:59 +02:00
Eugene Sandulenko
c544e5119b
COMMON: Remove USE_CXX11 checks, it is now always present 2021-10-31 11:52:29 +02:00
djsrv
2aa7e3e558 COMMON: Replace matchString pathMode with general wildcard exclusions
Different characters may need to be excluded for different path styles.
2021-08-09 17:43:12 -04:00
Eugene Sandulenko
f6e33231bb
COMMON: Add an optional parameter to tag2str() for printing non-printables
This time without variadic macros
2021-06-29 22:15:02 +02:00
Eugene Sandulenko
76c6bcef2b
Revert "COMMON: Add an optional parameter to tag2str() for printing non-printables"
This reverts commit c11fedb47e82da56b193a24222816addae13df1c.

It is a C++11 feature...
2021-06-29 22:12:25 +02:00
Eugene Sandulenko
c11fedb47e
COMMON: Add an optional parameter to tag2str() for printing non-printables 2021-06-29 20:42:40 +02:00
D G Turner
b8c4cd8129 COMMON: Use Correct Symbol in New String Function 2021-03-15 23:01:24 +00:00
Zvika Haramaty
dc5783c910 COMMON: Add String::forEachLine and convertBiDiStringByLines
`convertBiDiStringByLines` calls the BiDi algo for each line in isolation,
and returns a joined result.
That's needed to support BiDi in AGI, and might be needed for other engines
in the future.

In order to do that, a new utility function was added:
`String::forEachLine` which gets a function as input, and its arg(s) (if it has any),
and calls the function on each line, and returns a new string which is all
concatenation of all the lines results (with '\n' added between them).
2021-03-14 18:52:36 +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
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
0b93a68a0d COMMON: Attempt to fix compilation for some compilers 2020-10-31 16:56:50 +00:00
Thierry Crozat
23ce3edac9 COMMON: Add contains overload for char32_t in String 2020-10-31 16:56:50 +00: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
Vladimir Serbinenko
18e6878311 COMMON: Add String::asUint64Ext
This is the same as String::asUint64 but supports 0x and 0 prefixes
2020-10-17 22:34:58 +02:00
aryanrawlani28
e5445fb901 GUI: U32: Small improvements/fixes
- Remove = operator in String, which compared to a U32String.
- Let implicit cast take care of results from getResultString, so in-future easy to spot new changes.
- Use uint32 for each char when encodingUrlStrings, to avoid unsafe comparision.
2020-08-30 14:43:41 +02:00
aryanrawlani28
388473656e GUI: U32: Add contains utility for string, which takes in a uint. 2020-08-30 14:43:41 +02:00
Thierry Crozat
94035cf7aa COMMON: Fix creating a String from a U32String
There were memory issues due to class member variables not initialized
by the constructor.
2020-08-30 14:43:41 +02:00
aryanrawlani28
a9bfe35216 GUI: U32: More issue fixes and general improvements
- Use the fake constructor for message dialog less often
- solve errors regarding comparision between string and u32string in midi
- solve errors in testbed/speech related to ttsMan->say
- fix unsigned comparision warning in tab.cpp
- fix issue with static strings and translations in sdl-graphics
2020-08-30 14:43:41 +02:00
aryanrawlani28
fd763b61e5 GUI: U32: Add U32String conversion helpers to str.cpp
This commit adds a constructor and a "=" operator to allow conversion from u32strings->strings
2020-08-30 14:43:41 +02:00
Cameron Cawley
cf068bcc08 ALL: Remove direct use of OSystem::createMutex() 2020-08-21 09:39:00 +02:00
Henrik "Henke37" Andersson
dc7b0a7909 COMMON: Dedicated function for in buffer check
It's UB to compare pointers that aren't from the same array. Cast to uintptr to reduce the issue to IB.
2020-07-19 23:07:35 +01:00
Eugene Sandulenko
6059566777 COMMON: Added scumm_strcasestr() 2020-06-18 14:38:12 +02:00
Eugene Sandulenko
b9fab94dbf COMMON: Shut coverity up with tons of false positives 2020-04-27 23:51:56 +02:00
Eugene Sandulenko
eb04cff38d COMMON: Swtich scumm_strdup to malloc(), so its behaviour matches strdup() 2020-04-27 22:46:22 +02:00
Eugene Sandulenko
a08dc72eab COMMON: Skip "an " in dictionary sort 2020-04-24 10:54:00 +02:00
Eugene Sandulenko
0b00d71643 COMMON: Add methods for dictionary string comparison 2020-04-24 10:54:00 +02:00
Paul Gilbert
b2095095ed ULTIMA8: Starting the game will now auto-load the previous used savegame 2020-02-26 21:35:48 -08:00
Matthew Duggan
ff840ba47b COMMON: Fix return value of String::findLastNotOf 2020-02-25 18:48:37 -08:00
Paul Gilbert
3717b672d1 ULTIMA: Further compilation fixes 2020-02-01 17:48:37 -08:00
Paul Gilbert
e8eb67f82e ULTIMA: Fix crashes in String::erase 2020-02-01 13:13:51 -08:00
Paul Gilbert
f972d68ae2 COMMON: Change recently added string methods to be camelcase 2020-02-01 13:13:51 -08:00
Paul Gilbert
a178952464 ULTIMA: Moving many string methods from Std::String to Common::String 2020-02-01 13:13:51 -08:00
Eugene Sandulenko
a6307b768c COMMON: Fix reading beyond array pointers in toString() 2020-01-06 13:31:58 +01:00
Eugene Sandulenko
c85e5a64d7 COMMON: Fix toPrintable() for upper characters 2019-12-11 00:45:12 +01:00
Eugene Sandulenko
6b6dc21813 COMMON: Added helper function to produce printable strings 2019-12-10 00:32:54 +01:00
Eugene Sandulenko
eb72d6b479 COMMON: Added String::find() 2019-10-18 00:28:36 +02:00
D G Turner
e895548237 COMMON: Fix MSVC Compiler Warning
The enum is implicitly int32 by default so causes signed vs. unsigned
assignment warnings. Changing this to a const uint32 avoids the issue.
2019-09-30 01:44:14 +01:00
sluicebox
85333d8050 COMMON: Allow '\#' to match '#' in matchString
matchString patterns couldn't be used to find files with the # character
as it was only treated as a digit wildcard. SCI expected that to work as
it looks for files that start with the # character.
2019-03-03 22:44:29 +02:00
Thierry Crozat
1e11da712b COMMON: Add mutex to protect access to the String memory pool
This fixes a crash due to concurrent access to the global MemoryPool
used by the String class when String objects are used simultaneously
from several threads (as is for example the case when enabling the
cloud features).

See bug #10524: Thread safety issue with MemoryPool
2018-10-14 21:25:16 +01:00
Cameron Cawley
7a437e909c COMMON: Move new_strdup to common/str.cpp 2018-08-18 16:30:05 +02:00
Bastien Bouclet
955e18c648 COMMON: Use nullptr instead of NULL or 0 where appropriate 2018-05-10 08:35:46 +02:00
Bastien Bouclet
7382af32be GUI: Make the tab completion case insensitive in the debug console
It made little sense for the tab-completion to be case sensitive while
command execution itself is case insensitive.
2018-04-30 20:31:44 +02:00
Adrian Frühwirth
3747d852ee JANITORIAL: Fix whitespace 2018-04-15 16:31:31 +02:00