@@ -70,86 +70,14 @@ bool cppcheck::Platform::set(Type t)
7070 return true ;
7171 case Type::Win32W:
7272 case Type::Win32A:
73- type = t;
74- sizeof_bool = 1 ; // 4 in Visual C++ 4.2
75- sizeof_short = 2 ;
76- sizeof_int = 4 ;
77- sizeof_long = 4 ;
78- sizeof_long_long = 8 ;
79- sizeof_float = 4 ;
80- sizeof_double = 8 ;
81- sizeof_long_double = 8 ;
82- sizeof_wchar_t = 2 ;
83- sizeof_size_t = 4 ;
84- sizeof_pointer = 4 ;
85- defaultSign = ' \0 ' ;
86- char_bit = 8 ;
87- short_bit = char_bit * sizeof_short;
88- int_bit = char_bit * sizeof_int;
89- long_bit = char_bit * sizeof_long;
90- long_long_bit = char_bit * sizeof_long_long;
91- return true ;
9273 case Type::Win64:
93- type = t;
94- sizeof_bool = 1 ;
95- sizeof_short = 2 ;
96- sizeof_int = 4 ;
97- sizeof_long = 4 ;
98- sizeof_long_long = 8 ;
99- sizeof_float = 4 ;
100- sizeof_double = 8 ;
101- sizeof_long_double = 8 ;
102- sizeof_wchar_t = 2 ;
103- sizeof_size_t = 8 ;
104- sizeof_pointer = 8 ;
105- defaultSign = ' \0 ' ;
106- char_bit = 8 ;
107- short_bit = char_bit * sizeof_short;
108- int_bit = char_bit * sizeof_int;
109- long_bit = char_bit * sizeof_long;
110- long_long_bit = char_bit * sizeof_long_long;
111- return true ;
11274 case Type::Unix32:
113- type = t;
114- sizeof_bool = 1 ;
115- sizeof_short = 2 ;
116- sizeof_int = 4 ;
117- sizeof_long = 4 ;
118- sizeof_long_long = 8 ;
119- sizeof_float = 4 ;
120- sizeof_double = 8 ;
121- sizeof_long_double = 12 ;
122- sizeof_wchar_t = 4 ;
123- sizeof_size_t = 4 ;
124- sizeof_pointer = 4 ;
125- defaultSign = ' \0 ' ;
126- char_bit = 8 ;
127- short_bit = char_bit * sizeof_short;
128- int_bit = char_bit * sizeof_int;
129- long_bit = char_bit * sizeof_long;
130- long_long_bit = char_bit * sizeof_long_long;
131- return true ;
13275 case Type::Unix64:
13376 type = t;
134- sizeof_bool = 1 ;
135- sizeof_short = 2 ;
136- sizeof_int = 4 ;
137- sizeof_long = 8 ;
138- sizeof_long_long = 8 ;
139- sizeof_float = 4 ;
140- sizeof_double = 8 ;
141- sizeof_long_double = 16 ;
142- sizeof_wchar_t = 4 ;
143- sizeof_size_t = 8 ;
144- sizeof_pointer = 8 ;
145- defaultSign = ' \0 ' ;
146- char_bit = 8 ;
147- short_bit = char_bit * sizeof_short;
148- int_bit = char_bit * sizeof_int;
149- long_bit = char_bit * sizeof_long;
150- long_long_bit = char_bit * sizeof_long_long;
77+ // read from platform file
15178 return true ;
15279 case Type::File:
80+ type = t;
15381 // sizes are not set.
15482 return false ;
15583 }
@@ -159,40 +87,73 @@ bool cppcheck::Platform::set(Type t)
15987
16088bool cppcheck::Platform::set (const std::string& platformstr, std::string& errstr, const std::vector<std::string>& paths, bool verbose)
16189{
162- if (platformstr == " win32A" )
163- set (Type::Win32A);
164- else if (platformstr == " win32W" )
165- set (Type::Win32W);
166- else if (platformstr == " win64" )
167- set (Type::Win64);
168- else if (platformstr == " unix32" )
169- set (Type::Unix32);
170- else if (platformstr == " unix64" )
171- set (Type::Unix64);
172- else if (platformstr == " native" )
173- set (Type::Native);
174- else if (platformstr == " unspecified" )
175- set (Type::Unspecified);
90+ Type t;
91+ std::string platformFile;
92+
93+ if (platformstr == " win32A" ) {
94+ // TODO: deprecate
95+ // std::cout << "Platform 'win32A' is deprecated and will be removed in a future version. Please use 'win32a' instead." << std::endl;
96+ t = Type::Win32A;
97+ platformFile = " win32a" ;
98+ }
99+ else if (platformstr == " win32a" ) {
100+ t = Type::Win32A;
101+ platformFile = platformstr;
102+ }
103+ else if (platformstr == " win32W" ) {
104+ // TODO: deprecate
105+ // std::cout << "Platform 'win32W' is deprecated and will be removed in a future version. Please use 'win32w' instead." << std::endl;
106+ t = Type::Win32W;
107+ platformFile = " win32w" ;
108+ }
109+ else if (platformstr == " win32w" ) {
110+ t = Type::Win32W;
111+ platformFile = platformstr;
112+ }
113+ else if (platformstr == " win64" ) {
114+ t = Type::Win64;
115+ platformFile = platformstr;
116+ }
117+ else if (platformstr == " unix32" ) {
118+ t = Type::Unix32;
119+ platformFile = platformstr;
120+ }
121+ else if (platformstr == " unix64" ) {
122+ t = Type::Unix64;
123+ platformFile = platformstr;
124+ }
125+ else if (platformstr == " native" ) {
126+ t = Type::Native;
127+ }
128+ else if (platformstr == " unspecified" ) {
129+ t = Type::Unspecified;
130+ }
176131 else if (paths.empty ()) {
177132 errstr = " unrecognized platform: '" + platformstr + " ' (no lookup)." ;
178133 return false ;
179134 }
180135 else {
136+ t = Type::File;
137+ platformFile = platformstr;
138+ }
139+
140+ if (!platformFile.empty ()) {
181141 bool found = false ;
182142 for (const std::string& path : paths) {
183143 if (verbose)
184- std::cout << " looking for platform '" + platformstr + " ' in '" + path + " '" << std::endl;
185- if (loadFromFile (path.c_str (), platformstr , verbose)) {
144+ std::cout << " looking for platform '" + platformFile + " ' in '" + path + " '" << std::endl;
145+ if (loadFromFile (path.c_str (), platformFile , verbose)) {
186146 found = true ;
187147 break ;
188148 }
189149 }
190150 if (!found) {
191- errstr = " unrecognized platform: '" + platformstr + " '." ;
151+ errstr = " unrecognized platform: '" + platformFile + " '." ;
192152 return false ;
193153 }
194154 }
195155
156+ set (t);
196157 return true ;
197158}
198159
@@ -297,6 +258,5 @@ bool cppcheck::Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc)
297258 long_bit = char_bit * sizeof_long;
298259 long_long_bit = char_bit * sizeof_long_long;
299260
300- type = Type::File;
301261 return !error;
302262}
0 commit comments