Commit Graph

148 Commits

Author SHA1 Message Date
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
Colin Snover
dda0f77bcf COMMON: Add basic fixed-width word wrap to Common::String 2017-11-10 09:57:41 -06:00
Colin Snover
9d3893459f COMMON: Add strnlen for safer C string length reads
This API is intended for use in cases where C strings come
from untrusted sources like game files, where malformed data
missing the null terminator would cause strlen to read out of
bounds.
2017-01-05 22:07:24 +01:00
Alexander Tkachev
627bda9d82 COMMON: Add replace(String, String, String)
Searches for a substring in the string and replaces it with the other
string.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c99b24c16d COMMON: Add String::asUint64()
Instead of all these atoull() I've added everywhere.
2016-08-24 16:07:55 +06:00
Eugene Sandulenko
31913eee17 COMMON: Fix warning about shadowing class members 2016-05-28 17:18:17 +02:00
Borja Lorente Escobar
a19b50ddf2 COMMON: Add replace functions to Common and String.
COMMON: Add replacement to common/algorithm.h

COMMON: Intermediate commit to show doubts.

 COMMON: Basic String::replace() methods implemented.

COMMON: Fix typo in the algorithm.h documentation.

COMMON: Fix documentation of String::replace()

COMMON: Fix formatting issues in method signatures.

COMMON: Add assert and reformat loops in str and algorithm.

COMMON: Fix typo in comment.

COMMON: Fix style in string test cases.

COMMON: Add Doxygen documentation to algorithm and String.

COMMON: Add Doxygen documentation to algorithm and String.

COMMON: Add Doxygen documentation to algorithm.

COMMON: Fix style in algorithm comments.

COMMON: Add Doxygen comments to String.

COMMON: Add Doxygen comments to algorithm test function.

COMMON: Add String support for substring replace.

COMMON: Fix string replace to comply with STL

COMMON: Fix documentation on string replace

COMMON: Fix style in string replace

COMMON: Fix unwanted reference problem in String::replace().

COMMON: Fix indentation in comments for replace

COMMON: Fix indentation in replace

COMMON: Fix comments in String::replace to match implementation.

COMMON: Remove assert to allow for not-null-terminated character arrays

COMMON: Add new test for String::replace

COMMON: Fix broken comments on String::replace

COMMON: Fix sharing bug on ensureCapacity

COMMON: Remove superfluous call to makeUnique()
2016-05-16 22:01:21 +02:00
Johannes Schickel
06641f29a7 COMMON: Allow '#' to only match digits in matchString. 2016-01-26 16:35:30 +01:00
Johannes Schickel
854e22b38b COMMON: Make GPL headers consistent in themselves. 2014-02-18 02:39:33 +01:00
richiesams
e1ff60da7a COMMON: Add erase method to String class 2013-06-20 15:40:25 -05:00
Thierry Crozat
33a29ca61c COMMON: Fix assert condition in String::setChar() 2013-03-20 20:10:13 +00:00
Johannes Schickel
b4d0a8ba66 JANITORIAL: Enforce "} // End of namespace" with a single space after }. 2013-01-26 19:38:02 +01:00
Johannes Schickel
b0ba4b01a4 COMMON: Add wrapper for isprint.
This is done in the spirit of 658080deed.
2012-12-13 21:08:47 +01:00
Willem Jan Palenstijn
9ffe3e11d9 Merge pull request #182 from fingolfin/forbid-ctype
ALL: Avoid using is* macros from ctype.h
2012-02-21 11:33:32 -08:00
Max Horn
2017ba338a COMMON: Fix typo 2012-02-16 11:12:39 +01:00
Max Horn
658080deed ALL: Avoid using is* macros from ctype.h
On some systems, passing signed chars to macros like isspace() etc. lead
to a runtime error. Hence, mark these macros as forbidden by default,
and introduce otherwise equivalent alternatives for them.
2012-02-15 16:51:37 +01:00
Littleboy
b694a78f62 ANALYSIS: Add static casts to is* functions
This fixes a potential problem with passing char values that would be sign-extended and yield unexpected results.
See http://msdn.microsoft.com/en-us/library/ms245348.aspx
2011-06-23 08:52:52 -04:00
Max Horn
e792adb1b8 COMMON: Add vformat() function (Common::String analog to vsprintf) 2011-06-18 01:36:15 +02:00
Max Horn
0a0258edcf COMMON: Let Common::normalizePath normalize '..' in paths
There are some unit tests to verify that this works correctly.
There is a small chance that this causes regressions in weird setups.
2011-06-03 17:33:07 +02:00
Max Horn
8e3aafd30d COMMON: Provide our own implementations for scumm_str(n)icmp
This takes up a tiny little bit of extra binary size, but gets
rid of some awful #ifdef hackery.
2011-05-23 19:12:25 +02:00
strangerke
69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Max Horn
e27b05ef35 COMMON: Rename String::printf() to String::format()
This is a first step towards getting rid of all uses of regular printf,
fprintf, vprintf, vfprintf, puts, fputs, etc. in our codebase.

The name format() reflects the purpose of the function, and parallels
String.format() in Java, boost::format, and others.

svn-id: r54004
2010-11-01 16:02:28 +00:00
Eugene Sandulenko
f7645fea45 Revert "COMMON: Implement Common::vprintf(). Patch by littleboy"
svn-id: r53586
2010-10-18 20:20:14 +00:00
Eugene Sandulenko
4b5640883c COMMON: Implement Common::vprintf(). Patch by littleboy
svn-id: r53576
2010-10-18 19:04:41 +00:00
Joost Peters
426d6749cf COMMON: work around different vsnprintf behaviour on IRIX
The return value of vsnprintf when the provided buffer is not large
enough to hold the formatted string is implementation-dependent:

C99:  The size the formatted string would take up.
MSVC: -1, with no indication of how large the buffer should be.
IRIX: The number of characters actually written, which is at most
      the size of the buffer minus one, as the string is truncated
      to fit.  This means the only way to be sure the entire string
      is written is if the return value is less than the capacity - 1.

This change means that whenever we try to format a string where the size
is 1 below the built-in capacity, that the capacity will be needlessly increased.

If this turns out to be problematic we could make this behaviour __sgi conditional.

svn-id: r53143
2010-10-10 22:36:03 +00:00
Willem Jan Palenstijn
532663c742 COMMON: Fix edge case for wildcard in matchString
svn-id: r52618
2010-09-07 11:40:44 +00:00
Florian Kagerer
b480f0f2f0 COMMON: fix MSVC assert when using umlauts (or other characters > 127) in the global save/load menu
svn-id: r52173
2010-08-17 20:58:01 +00:00