Commit Graph

2171 Commits

Author SHA1 Message Date
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
Max Horn
7a85365004 COMMON: Change some (f)printf to debug calls; clenaup hashmap.h
svn-id: r54003
2010-11-01 16:00:53 +00:00
Max Horn
e67ab53d89 COMMON: Document forbidden.h
svn-id: r53990
2010-10-31 21:50:20 +00:00
Max Horn
a41d4424af COMMON: Allow forbidden symbols in debug.cpp and textconsole.cpp
This is currently necessary for the PS2 port and possibly others.

svn-id: r53989
2010-10-31 21:49:53 +00:00
Max Horn
44393b2dc8 ALL: Add code to help stop people from accidentally using "bad" APIs
A new header file common/forbidden.h is included by scummsys.h and it
re-#defines numerous symbols like fopen(), fread(), system(), etc. with
garbage, in order to provoke compile errors in any code using them.

If a .cpp file really *must* use any of these (e.g. because it is a
backend file), then these redefinitions can be disabled by #defining
FORBIDDEN_SYMBOL_ALLOW_ALL as the first thing in the .cpp file. Whenever
this is done, an explanatory comment should be added.

Note that this system cannot catch all "bad" usages (notably the Lua
code in the sword25 engine), as it can only work if scummsys.h is
included.

svn-id: r53961
2010-10-30 21:27:42 +00:00
Max Horn
c0063a6d50 COMMON: Add SCUMMVM_CURRENT_FUNCTION macro (useful for debugging)
svn-id: r53931
2010-10-30 00:32:45 +00:00
Max Horn
c975ed11a1 ALL: Fix various typos (patch #3093266)
svn-id: r53762
2010-10-24 13:04:33 +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
Johannes Schickel
cf8b589984 COMMON: Made some constructors explicit, where we wouldn't really like implicit conversion.
svn-id: r53508
2010-10-15 18:30:29 +00:00
Johannes Schickel
08afc68df0 COMMON: Extend workaround in HashMap code for sgi IRIX MIPSpro to also apply for Intel's C++ compiler.
svn-id: r53507
2010-10-15 18:20:21 +00:00
Johannes Schickel
4306a65577 COMMON: Revert attempt to silence MSVC warning in Common::gcd.
svn-id: r53506
2010-10-15 18:20:01 +00:00
Johannes Schickel
5c102d4f08 COMMON: Silence gcc warning introduced with r53496.
svn-id: r53497
2010-10-15 14:18:58 +00:00
Johannes Schickel
8fc3c21bd0 COMMON: Attempt to silence MSVC warning in Common::gcd.
svn-id: r53496
2010-10-15 14:14:51 +00:00
Max Horn
2fed5ff832 COMMON: Move XMLParser method impls to .cpp file; make skipComments non-virtual
svn-id: r53480
2010-10-15 12:19:34 +00:00
Max Horn
36cd5caf95 COMMON: Add XMLParser::parseIntegerKey variant accepting a Common::String
Almost all places where we used XMLParser::parseIntegerKey were using
it like this:
  XMLParser::parseIntegerKey(str.c_str(), ...)
Since this makes the code harder to read, I overloaded the method to
also accept Commmon::String directly.
Also removed all .c_str() invocations where necessary.

svn-id: r53479
2010-10-15 12:19:13 +00:00
Jordi Vilalta Prat
8388e0dfea JANITORAL: Clean trailing whitespaces.
svn-id: r53160
2010-10-12 02:18:11 +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
f98536eef5 SCI: Allow multiple word groups in parser
In SCI01 and up, each typed word may be interpreted as multiple
class,group pairs. This patch adds support to the vocabulary and
parser. It uses the matcher support added in r52985.

This fixes parser issues in German LSL3, but needs testing.

svn-id: r52989
2010-10-03 10:49:42 +00:00
Thierry Crozat
1177692701 GUI: Fix bug #3075649 (Fonts not found with built-in theme)
When switching to a theme that do not have the fonts needed to properly
display the current language, it now revert to the previously used theme
and display an error message telling the user to change the language
first if he wants to use the theme he selected.

svn-id: r52969
2010-10-01 21:41:40 +00:00
Yotam Barnoy
f7f743ac31 PSP: switch from wrapping memcpy to defining our own memcpy
The advantage is that we get to do inlining and even use lwl and lwr instructions where appropriate. We have to do it ourselves because the PSP doesn't tolerate built-in instructions, but also we have a more efficient memcpy than the lib's.

svn-id: r52817
2010-09-20 14:10:44 +00:00
Matthew Hoops
7835ce5cb8 COMMON: Extend getting a Mac resource fork resource with a name
Resource names can be the same across types (ie. 'PICT' "Foo" and 'snd ' "Foo"), so this ensures that the right type is chosen in those cases.

svn-id: r52756
2010-09-17 03:55:41 +00:00
Yotam Barnoy
94b41f5d2e COMMON: remove virtual functions from BufferedStreams
As Max pointed out to me, they don't work as expected when called from constructors/destructors.

svn-id: r52724
2010-09-14 14:57:30 +00:00
Willem Jan Palenstijn
9dfb24851c COMMON: Remove dangerous virtual keywords.
See r52722.

svn-id: r52723
2010-09-14 14:18:25 +00:00
Sven Hesse
a71f3aa99c COMMON: Fix int-Rational operators
svn-id: r52675
2010-09-11 10:03:31 +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
Willem Jan Palenstijn
8f1143bfdc COMMON: Remove Rational::operator int/double
This prevents accidental implicit rounding
and might also fix compilation on AmigaOS4 (bug #3060981).

svn-id: r52616
2010-09-07 09:02:46 +00:00
Matthew Hoops
df7158c0ee COMMON: Add a debugPrint function to Rational
svn-id: r52593
2010-09-06 14:59:13 +00:00
Matthew Hoops
a960ac66ce COMMON: Fix Rational::operator!=(int)
svn-id: r52535
2010-09-04 23:45:23 +00:00
Yotam Barnoy
cdd27ca943 COMMON: changed read/write endian function to use __may_alias__ attribute
This is a better solution for the gcc aliasing problem that happens when aliasing a struct onto something else. What happens is that the compiler assumes no aliasing can happen when -O2 and -O3 are activated, and a call to READ_UINT32() followed by WRITE_UINT32() and another READ_UINT32() will be optimized to return the original read value instead of re-reading.

svn-id: r52480
2010-09-01 12:41:16 +00:00
Thierry Crozat
37027d6531 I18N: Add "lowres" context for several GUI strings when in 1x mode.
This enables translators to use a different translation for these strings in
1x mode (e.g. 320x200 or 320x240) and in 2x or 3x modes.

svn-id: r52461
2010-08-30 22:24:40 +00:00
Thierry Crozat
bf9404485e I18N: Add a macro to define a context for a translatable string.
Currently static strings are marked with the _s() macro so that xgettext knows
the string needs to be translated. But there was no way to tell xgettext that
the string could get translated in different contexts. This is the role of this new
macro.

svn-id: r52460
2010-08-30 22:20:16 +00:00
Thierry Crozat
a2a3073562 I18N: Look for translations data file in Themes path
If the translations.dat file is not found using the SearchMan, it now looks
for that file into the themepath directory and sub-directories (if the path is
defined).

svn-id: r52428
2010-08-28 15:51:23 +00:00
Willem Jan Palenstijn
05c2cc4d1d COMMON: Fix eos handling in BufferedReadStream
This makes it pass the test added in r52382.

svn-id: r52389
2010-08-25 14:43:42 +00:00
Yotam Barnoy
4368d3c574 COMMON: fixed EOS handling in BufferedReadStream and BufferedSeekableReadStream
EOS problem was causing Discworld to crash and zip files not to load on the PSP.

svn-id: r52377
2010-08-25 09:14:41 +00:00
Yotam Barnoy
efdbb076a2 COMMON: implemented BufferedWriteStream and fixed bug in BufferedReadStream
I need the write buffering for the new version of the PSP streams and thought the simplest way to implement it would be along the lines of BufferedReadStream. Sadly, I found a nasty little bug in BRS but that's taken care of.
Also, I adapted these streams for target-specific memory allocation by using virtual functions for allocation/deallocation.

svn-id: r52325
2010-08-24 11:18:48 +00:00
Thierry Crozat
bc821136fd i18n: Add support for context in translations.
This change means there can now be different translations for the same
english string depending on the context. It is based on gettext msgctxt feature.
There is a new macro _c(msg, ctxt) that should be used instead of _(msg) in
the source code when we want to add a context to the message. For the
moment I have added contexts to only one message ("None") so that I could
test the changes. Context could be added also to get shorter translations when
GUI is in 1x mode.

I have also added back the fuzzy option to msmerge since it is useful when
adding contexts to populate the translations for the new contexts.

svn-id: r52308
2010-08-23 19:45:14 +00:00
Max Horn
db7e69b258 CONFIG: Always sort 'scummvm' and keymapper domains first
svn-id: r52296
2010-08-23 10:00:40 +00:00
Johannes Schickel
ff06f0c9d5 i18n: Changed wording of messages about translations.dat file.
svn-id: r52261
2010-08-21 14:05:38 +00:00
Johannes Schickel
7fd7689370 i18n: Formatting fixes.
svn-id: r52260
2010-08-21 13:38:08 +00:00
Johannes Schickel
a53d4dde66 i18n: Style fixes.
svn-id: r52257
2010-08-21 13:21:09 +00:00
Paul Gilbert
5c30303794 COMMON: Added equality operators to Common::Rect
svn-id: r52249
2010-08-21 08:17:06 +00:00
Thierry Crozat
9015a14531 i18n: Fix previous commit when translation support is disabled
Previous commit of translation.cpp introduced a defined but not
implemented operator when the translation support was disabled.
This was probably fine since it was not used, but not very clean.

svn-id: r52241
2010-08-20 21:04:39 +00:00
Thierry Crozat
d00b8a5753 i18n: Sort the list of available languages alphabetically
svn-id: r52239
2010-08-20 20:42:13 +00:00
Eugene Sandulenko
26dc4c2425 DINGOO: new port. Patch #3039277
svn-id: r52210
2010-08-19 12:43:37 +00:00
Eugene Sandulenko
040dfff8ce i18n: Move translations to standalone file. Patch #3044975
svn-id: r52208
2010-08-19 11:46:55 +00:00
Eugene Sandulenko
2bd5077d2e COMMON: Add caching to ZipArchive. Patch #3048388
Based on patch #3048388: "Hash map for ZipArchive class", though
I made the hashing by default and removed the old code.

It is a really good thing and will speed up any archive operations.

svn-id: r52204
2010-08-19 10:15:12 +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
Eugene Sandulenko
7dfd8f9ce2 COMMON: Remove redundant include from str.cpp
If it is needed for your specific platform, then readd it,
but for that platform. Although to me it looks all redundant.

svn-id: r52155
2010-08-17 12:47:18 +00:00
Max Horn
861e520579 COMMON: Try to clarify and update some Common::Archive docs
svn-id: r52131
2010-08-16 19:58:20 +00:00