Commit Graph

45 Commits

Author SHA1 Message Date
Václav Slavík
c7972da951 Be more permissive when validating format string arguments.
Previously, the code would assert if the caller passed too many
arguments to wxPrintf() or other printf-like functions. But that can
happen legitimately in translations: in some languages such as Hebrew,
using "1" (i.e. "%d") in the singular feels unnatural and it's better to
use the word "one" and left the variadic argument unused.

Relax the check not to assert in this case. This is consistent with the
standard library and other implementations. Notice that gettext's msgfmt
doesn't complain about this case either in the specific case of singular
forms.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-02-27 15:24:21 +00:00
Paul Cornett
1e35c3b915 Silence warnings in headers with MSC -W4
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-10-16 16:45:53 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
4d3845c073 Avoid using "do { ... } while ( wxFalse )" pseudo-loop.
This loop can't be optimized away by the compiler because wxFalse is an extern
variable which can't be known to be always false. Additionally, this creates
many false positives from Coverity as it assumes that the loop can be executed
more than once.

Define wxSTATEMENT_MACRO_BEGIN/END macros abstracting the exact solution used
and replace wxFalse with "(void)0, 0" for now as this seems to placate MSVC
(which warns about using a bare "0" as a condition) while still allowing the
loop to be completely optimized away.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-12-02 23:48:36 +00:00
Vadim Zeitlin
715efa4e25 Allow passing wxLongLong values directly to wx pseudo-vararg functions.
Allow passing wxLongLong objects when a "%lld" format specifier (or
equivalent) is used just as we already do for wxString objects when "%s" is
used. This is more convenient and makes wxLongLong closes to the native type.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-05-17 22:12:39 +00:00
Dimitri Schoolwerth
4c51a665c6 Fixed various typos.
Applied patch by snowleopard2 fixing a bunch of typos such as misspellings and double words in the documentation. Combined the patch with some local queued typos waiting to be committed as well as adding new typo fixes inspired by the patch.

Function names with American spelling were not changed nor was third-party code touched. The only code changes involve some changes in strings that are translated ("Can not" -> "Cannot").

Closes #13063 (again).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-03-22 14:17:38 +00:00
Vadim Zeitlin
f675b4f521 Fix harmless unused parameter warnings in wxDEBUG_LEVEL==0 build.
These warnings were harmless as they concerned the parameters used inside
wxASSERTs only but there were hundreds if not thousands of them in
wx/strvararg.h alone so all the rest of build output was completely lost in
them.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-22 13:42:49 +00:00
Václav Slavík
3b12da351c Fix vararg type checking to accept ints for %c.
It's perfectly legitimate to format int values as %c, so don't assert in
this case.

Fixes #12192.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-03 14:24:12 +00:00
Václav Slavík
5b4a88f4db Simply varargs type checking by adding subtypes to check mask.
Instead of always declaraing that a C++ type corresponds to either
Arg_String or Arg_Pointer, make Arg_String superset of Arg_Pointer.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64797 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-03 14:24:06 +00:00
Václav Slavík
afc1f37c65 Fix printf arguments validation code for ANSI build.
char arguments weren't recognized as allowed variadic types. Unlike in
Unicode build, where chars are treated specially, they are primitive
types in ANSI build.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-01 15:28:35 +00:00
Václav Slavík
227c030f98 Don't assume size_t is either int- or long-sized.
On 64bit Windows systems, sizeof(int)==sizeof(long)=4, but size_t is 8
bytes large.

Fixes #12179.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-01 14:30:29 +00:00
Václav Slavík
c869479eb4 Compilation fix for compilers that don't have native wchar_t.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-06-24 11:25:49 +00:00
Václav Slavík
0f895b0cf5 Check wxPrintf etc. arguments types.
Implements checks similar to gcc's compile-time checks: verify that the
arguments are of correct types. This works partially at compile time
(e.g. passing an object as argument fails to compile) and partially at
runtime (assert if the specifier doesn't match the type).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-06-24 10:34:18 +00:00
Václav Slavík
2fe2d3de6b Add correct wxArgNormalizer code for signed char.
Signed char is distict type (see 3.9.1 [basic.fundamental] part of the
standard), covering just char and unsigned char is not enough.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64709 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-06-24 10:34:11 +00:00
Václav Slavík
5412c6ad17 variadic macros need specializations for both wxCharBuffer and wxScopedCharBuffer (fixes #10651)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59901 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-03-28 12:32:06 +00:00
Václav Slavík
de4983f323 split wxCharTypeBuffer<T> into wxScopedCharTypeBuffer<T> and wxCharTypeBuffer<T> -- the former is for transient data with validity limited to parent's lifetime, the latter is for permanent storage of string data (bug #9638)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-03-27 15:33:55 +00:00
Vadim Zeitlin
c0c133e13b add wx-prefixed and semicolon-requiring versions of DECLARE_NO_{COPY,ASSIGN}_CLASS macros
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-02-08 11:45:59 +00:00
Václav Slavík
e68a8744ee silence gcc warnings in "vararg" functions such as wxPrintf when compiling with -Wformat-security
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-01-16 12:07:47 +00:00
Vadim Zeitlin
5c69ef61f3 fix some of icc 11.0 warnings and disable a few others
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56792 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-11-16 14:24:13 +00:00
Vadim Zeitlin
5c33522fca replace wx_{const,static,reinterpret}_cast with their standard C++ equivalents
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-11-02 02:39:52 +00:00
Václav Slavík
5431a79f1e optimize wxFormatStringArgumentFinder<T> for strings and make it work correctly for wxCharBuffer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2008-07-29 23:10:04 +00:00
Vadim Zeitlin
9183da066e no need to reenable VC warning 4251 now as it's globally disabled in wx/defs.h
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50844 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-12-20 00:55:03 +00:00
Paul Cornett
9356b709aa allow copying wxFormatString for compiler-generated temporaries
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-09-21 16:04:24 +00:00
Václav Slavík
04e7692af1 VC6 compilation fix for _WX_VARARG_FORMAT_STRING macro
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-08-22 20:07:11 +00:00
Václav Slavík
1f5df26884 Watcom compilation fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-08-22 18:15:23 +00:00
Václav Slavík
4734640692 fixed variadic templates in the case when char value is passed in place of (e.g.) %i or %d argument
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48224 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-08-20 19:20:10 +00:00
Václav Slavík
d6694e1017 removed outdated comment
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-08-15 15:28:30 +00:00
Václav Slavík
b5dbe15d0b added WXDLLIMPEXP_FWD_FOO macros in addition to WXDLLIMPEXP_FOO for use with forward declarations (in preparation for GCC visibility support)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47254 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-07-09 10:09:52 +00:00
Václav Slavík
50e2789913 normalize printf/scanf format strings correctly on all platforms, while accounting for wxArgNormalizer<T> conversions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-22 11:10:36 +00:00
Václav Slavík
541aa82180 fixed VC6 warnings about non-dllexported members in dllexported classes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-11 19:59:11 +00:00
Václav Slavík
24d68c95ad partially fixed passing wxUniChar as vararg argument (non-ASCII characters are still broken in UTF8 build, other cases work)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46266 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-06-02 12:45:19 +00:00
Václav Slavík
59a14f6984 fix compation with Watcom after latest vararg templates changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-06 14:11:14 +00:00
Václav Slavík
4960f9fc9a compilation fix for --enable-utf8 --disable-utf8only case
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-04 11:10:06 +00:00
Václav Slavík
1528e0b85f use wxFormatString helper class for 'vararg' functions' format argument; this prepares the code for removal of implicit wxString conversion to char* in STL build and also fixes VC6 compilation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45803 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-04 10:41:08 +00:00
Václav Slavík
c9afb3cbc5 fixed passing raw unconverted strings through wxArgNormalizer<> for VC++
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45795 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-03 17:58:18 +00:00
Václav Slavík
f461887a02 don't do char*->wchar_t*>char* roundtrip in wxArgNormalizerUtf8<const char*> if current locale uses UTF-8
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45787 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-03 14:34:29 +00:00
Václav Slavík
d1f6e2cfe2 fixed vararg functions with format argument to not use wxString or reference argument (the latter is invalid C++, the former doesn't work with Watcom and produces at least warnings with GCC 3.3)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45781 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-05-03 10:50:25 +00:00
Václav Slavík
82e77a8027 compilation fixes for --disable-log
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45711 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-04-29 09:02:38 +00:00
Václav Slavík
564a5bbe57 added support for passing std::[w]string to 'vararg' templates
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-04-29 08:04:58 +00:00
Václav Slavík
2523e9b700 use UTF8-encoded char* strings in UTF8 build instead of wchar_t* if the current locale uses UTF8;
fall back to widechar CRT functions in the locale is not UTF8


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-04-26 11:40:04 +00:00
Václav Slavík
817270659e initial version of UTF-8 strings representation (still converting to wchar_t* a lot); it has to be explicitly enabled with --enable-utf8 for now
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45433 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-04-12 21:15:07 +00:00
Václav Slavík
359bd4d1a2 allow passing wx[W]CharBuffer to wx vararg templates
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45099 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-28 18:03:26 +00:00
Václav Slavík
8f93a29f8e Preparing wxString for UTF-8 representation:
1) split into wxStringImpl class that has std::string-like API and operates on char* or wchar_t* data and wxString class that provides Unicode iterators and indexes
2) added both char* and wchar_t* versions of many wxString methods to avoid having to use _T()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45078 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-26 20:28:04 +00:00
Václav Slavík
e3f6cbd99c split wxchar.h into several smaller headers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-19 14:45:38 +00:00
Václav Slavík
c9f7896861 first phase of transition to unified Unicode build:
1. changed c_str() to return wxCStrData (implicitly convertible to wxChar*)
2. added template type-safe wrappers for vararg functions
3. added wxUniChar class representing single Unicode character
4. changed wxString::operator[] and wxString::iterator to return wxUniChar


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2007-03-17 10:26:10 +00:00