Skip to content

Commit c7c6927

Browse files
crondaemonAndersBroman
authored andcommitted
version_info: make indentation more consistent.
The preprocessor statements in the function get_compiler_info were indented with a mixed approach: indented, but not following the style of the rest of the file. The indented approach has been followed to increase the readability, but with tabs, as in the rest of the file. Other indentation issues fixed. Change-Id: I6486c2cfa640f87c90a7fe4b7d95848d02249d23 Reviewed-on: https://code.wireshark.org/review/37481 Reviewed-by: Alexis La Goutte <[email protected]> Petri-Dish: Guy Harris <[email protected]> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <[email protected]>
1 parent d91b0d5 commit c7c6927

File tree

1 file changed

+167
-168
lines changed

1 file changed

+167
-168
lines changed

version_info.c

Lines changed: 167 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ static char *runtime_info;
4747

4848
void
4949
ws_init_version_info(const char *appname,
50-
void (*prepend_compile_time_info)(GString *),
51-
void (*append_compile_time_info)(GString *),
52-
void (*additional_run_time_info)(GString *))
50+
void (*prepend_compile_time_info)(GString *),
51+
void (*append_compile_time_info)(GString *),
52+
void (*additional_run_time_info)(GString *))
5353
{
5454
GString *comp_info_str, *runtime_info_str;
5555

@@ -59,11 +59,11 @@ ws_init_version_info(const char *appname,
5959
* a checkout.
6060
*/
6161
appname_with_version = g_strdup_printf("%s %s",
62-
appname, get_ws_vcs_version_info());
62+
appname, get_ws_vcs_version_info());
6363

6464
/* Get the compile-time version information string */
6565
comp_info_str = get_compiled_version_info(prepend_compile_time_info,
66-
append_compile_time_info);
66+
append_compile_time_info);
6767

6868
/* Get the run-time version information string */
6969
runtime_info_str = get_runtime_version_info(additional_run_time_info);
@@ -73,10 +73,10 @@ ws_init_version_info(const char *appname,
7373

7474
/* Add this information to the information to be reported on a crash. */
7575
ws_add_crash_info("%s\n"
76-
"\n"
77-
"%s\n"
78-
"%s",
79-
appname_with_version, comp_info, runtime_info);
76+
"\n"
77+
"%s\n"
78+
"%s",
79+
appname_with_version, comp_info, runtime_info);
8080
}
8181

8282
const char *
@@ -143,7 +143,7 @@ get_zlib_compiled_version_info(void)
143143
*/
144144
GString *
145145
get_compiled_version_info(void (*prepend_info)(GString *),
146-
void (*append_info)(GString *))
146+
void (*append_info)(GString *))
147147
{
148148
GString *str;
149149

@@ -163,10 +163,10 @@ get_compiled_version_info(void (*prepend_info)(GString *),
163163
g_string_append(str, "with ");
164164
g_string_append_printf(str,
165165
#ifdef GLIB_MAJOR_VERSION
166-
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
167-
GLIB_MICRO_VERSION);
166+
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
167+
GLIB_MICRO_VERSION);
168168
#else
169-
"GLib (version unknown)");
169+
"GLib (version unknown)");
170170
#endif
171171

172172
g_string_append_printf(str, ", %s", get_zlib_compiled_version_info());
@@ -198,7 +198,7 @@ get_mem_info(GString *str)
198198
sysctlbyname("hw.memsize", &memsize, &len, NULL, 0);
199199
#elif __linux__
200200
struct sysinfo info;
201-
if (sysinfo(&info) == 0)
201+
if (sysinfo(&info) == 0)
202202
memsize = info.totalram * info.mem_unit;
203203
#endif
204204

@@ -222,154 +222,153 @@ get_compiler_info(GString *str)
222222
* doesn't also offer a nice printable string, we try prettifying
223223
* the number somehow.
224224
*/
225-
#if defined(_MSC_FULL_VER)
226-
/*
227-
* We check for this first, as Microsoft have a version of their
228-
* compiler that has Clang as the front end and their code generator
229-
* as the back end.
230-
*
231-
* My head asplode.
232-
*/
233-
234-
/* As of Wireshark 3.0, we support only Visual Studio 2015 (14.x)
235-
* or later.
236-
*
237-
* https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd
238-
* has a *large* table of Microsoft product names, VC++ versions,
239-
* _MSC_VER values, and _MSC_FULL_VER values. All the versions
240-
* we support define _MSC_FULL_VER. We don't bother trying to
241-
* get the SP/update/version number from the build number, as
242-
* we'd have to keep updating that with every update; there's no
243-
* way to get that information directly from a predefine, and in
244-
* some cases multiple updates/versions have the *same* build
245-
* number (because they didn't update the toolchain).
246-
*
247-
* https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2017
248-
* defines the format of _MSC_VER and _MSC_FULL_VER. _MSC_FULL_VER
249-
* is a decimal number of the form MMmmBBBBB, where MM is the compiler/
250-
* toolchain major version, mm is the minor version, and BBBBB is the
251-
* build. We break it down based on that.
252-
*/
253-
#define COMPILER_MAJOR_VERSION (_MSC_FULL_VER / 10000000)
254-
#define COMPILER_MINOR_VERSION ((_MSC_FULL_VER % 10000000) / 100000)
255-
#define COMPILER_BUILD_NUMBER (_MSC_FULL_VER % 100000)
256-
257-
/*
258-
* From https://web.archive.org/web/20190125151548/https://blogs.msdn.microsoft.com/vcblog/2014/11/17/c111417-features-in-vs-2015-preview/
259-
*
260-
* Bakersfield: DevDiv's upper management determines the scheduling
261-
* of new major versions. They also decided to increment the product
262-
* version from 12 (for VS 2013) to 14 (for VS 2015). However, the
263-
* C++ compiler's version incremented normally, from 18 to 19.
264-
* (It's larger because the C++ compiler predates the "Visual" in
265-
* Visual C++.)
266-
*
267-
* So the product version number is 5 less than the compiler version
268-
* number.
269-
*/
270-
#define VCPP_MAJOR_VERSION (COMPILER_MAJOR_VERSION - 5)
271-
272-
#if VCPP_MAJOR_VERSION == 14
273-
/*
274-
* From https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
275-
*
276-
* We've been delivering improvements to Visual Studio 2017 more
277-
* frequently than ever before. Since its first release in March
278-
* we've released four major updates to VS2017 and are currently
279-
* previewing the fifth update, VS2017 version 15.5.
280-
*
281-
* The MSVC toolset in VS2017 is built as a minor version update to
282-
* the VS2015 compiler toolset. This minor version bump indicates
283-
* that the VS2017 MSVC toolset is binary compatible with the VS2015
284-
* MSVC toolset, enabling an easier upgrade for VS2015 users. Even
285-
* though the MSVC compiler toolset in VS2017 delivers many new
286-
* features and conformance improvements it is a minor version,
287-
* compatible update from 14.00 in VS2015 to 14.10 in VS2017.
288-
*/
289-
#if COMPILER_MINOR_VERSION < 10
290-
#define VS_VERSION "2015"
291-
#elif COMPILER_MINOR_VERSION < 20
292-
#define VS_VERSION "2017"
293-
#else
294-
#define VS_VERSION "2019"
295-
#endif
296-
#else
297-
/*
298-
* Add additional checks here, before the #else.
299-
*/
300-
#define VS_VERSION "(unknown)"
301-
#endif /* VCPP_MAJOR_VERSION */
302-
303-
/*
304-
* XXX - should we show the raw compiler version number, as is
305-
* shown by "cl /?", which would be %d.%d.%d.%d with
306-
* COMPILER_MAJOR_VERSION, COMPILER_MINOR_VERSION,
307-
* COMPILER_BUILD_NUMBER, and _MSC_BUILD, the last of which is
308-
* "the revision number element of the compiler's version number",
309-
* which I guess is not to be confused with the build number,
310-
* the _BUILD in the name nonwithstanding.
311-
*/
312-
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual Studio " VS_VERSION " (VC++ %d.%d, build %d)",
313-
VCPP_MAJOR_VERSION, COMPILER_MINOR_VERSION, COMPILER_BUILD_NUMBER);
314-
#if defined(__clang__)
315-
/*
316-
* See above.
317-
*/
318-
g_string_append_printf(str, " clang/C2 %s and -fno-ms-compatibility.\n",
319-
__VERSION__);
320-
#else
321-
g_string_append_printf(str, ".\n");
322-
#endif
323-
#elif defined(__GNUC__) && defined(__VERSION__)
324-
/*
325-
* Clang and llvm-gcc also define __GNUC__ and __VERSION__;
326-
* distinguish between them.
327-
*/
328-
#if defined(__clang__)
329-
/*
330-
* We know this isn't clang/C2, as _MSC_FULL_VER isn't defined.
331-
*
332-
* Strip out trailing space from clang's __VERSION__ to be consistent
333-
* with other compilers.
334-
*/
335-
gchar* version = g_strstrip(g_strdup(__VERSION__));
336-
g_string_append_printf(str, "\n\nBuilt using clang %s.\n", version);
337-
g_free(version);
338-
#elif defined(__llvm__)
339-
/* llvm-gcc */
340-
g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
341-
#else /* boring old GCC */
342-
g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
343-
#endif /* llvm */
344-
#elif defined(__HP_aCC)
345-
g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
346-
#elif defined(__xlC__)
347-
g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
348-
(__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
349-
#ifdef __IBMC__
350-
if ((__IBMC__ % 10) != 0)
351-
g_string_append_printf(str, " patch %d", __IBMC__ % 10);
352-
#endif /* __IBMC__ */
353-
g_string_append_printf(str, "\n");
354-
#elif defined(__INTEL_COMPILER)
355-
g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
356-
__INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
357-
if ((__INTEL_COMPILER % 10) != 0)
358-
g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
359-
#ifdef __INTEL_COMPILER_BUILD_DATE
360-
g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
361-
__INTEL_COMPILER_BUILD_DATE / 10000,
362-
(__INTEL_COMPILER_BUILD_DATE / 100) % 100,
363-
__INTEL_COMPILER_BUILD_DATE % 100);
364-
#endif /* __INTEL_COMPILER_BUILD_DATE */
365-
g_string_append_printf(str, "\n");
366-
#elif defined(__SUNPRO_C)
367-
g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
368-
(__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
369-
if ((__SUNPRO_C & 0xF) != 0)
370-
g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
371-
g_string_append_printf(str, "\n");
372-
#endif
225+
#if defined(_MSC_FULL_VER)
226+
/*
227+
* We check for this first, as Microsoft have a version of their
228+
* compiler that has Clang as the front end and their code generator
229+
* as the back end.
230+
*
231+
* My head asplode.
232+
*/
233+
234+
/* As of Wireshark 3.0, we support only Visual Studio 2015 (14.x)
235+
* or later.
236+
*
237+
* https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd
238+
* has a *large* table of Microsoft product names, VC++ versions,
239+
* _MSC_VER values, and _MSC_FULL_VER values. All the versions
240+
* we support define _MSC_FULL_VER. We don't bother trying to
241+
* get the SP/update/version number from the build number, as
242+
* we'd have to keep updating that with every update; there's no
243+
* way to get that information directly from a predefine, and in
244+
* some cases multiple updates/versions have the *same* build
245+
* number (because they didn't update the toolchain).
246+
*
247+
* https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2017
248+
* defines the format of _MSC_VER and _MSC_FULL_VER. _MSC_FULL_VER
249+
* is a decimal number of the form MMmmBBBBB, where MM is the compiler/
250+
* toolchain major version, mm is the minor version, and BBBBB is the
251+
* build. We break it down based on that.
252+
*/
253+
#define COMPILER_MAJOR_VERSION (_MSC_FULL_VER / 10000000)
254+
#define COMPILER_MINOR_VERSION ((_MSC_FULL_VER % 10000000) / 100000)
255+
#define COMPILER_BUILD_NUMBER (_MSC_FULL_VER % 100000)
256+
257+
/*
258+
* From https://web.archive.org/web/20190125151548/https://blogs.msdn.microsoft.com/vcblog/2014/11/17/c111417-features-in-vs-2015-preview/
259+
* Bakersfield: DevDiv's upper management determines the scheduling
260+
* of new major versions. They also decided to increment the product
261+
* version from 12 (for VS 2013) to 14 (for VS 2015). However, the
262+
* C++ compiler's version incremented normally, from 18 to 19.
263+
* (It's larger because the C++ compiler predates the "Visual" in
264+
* Visual C++.)
265+
*
266+
* So the product version number is 5 less than the compiler version
267+
* number.
268+
*/
269+
#define VCPP_MAJOR_VERSION (COMPILER_MAJOR_VERSION - 5)
270+
271+
#if VCPP_MAJOR_VERSION == 14
272+
/*
273+
* From https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
274+
*
275+
* We've been delivering improvements to Visual Studio 2017 more
276+
* frequently than ever before. Since its first release in March
277+
* we've released four major updates to VS2017 and are currently
278+
* previewing the fifth update, VS2017 version 15.5.
279+
*
280+
* The MSVC toolset in VS2017 is built as a minor version update to
281+
* the VS2015 compiler toolset. This minor version bump indicates
282+
* that the VS2017 MSVC toolset is binary compatible with the VS2015
283+
* MSVC toolset, enabling an easier upgrade for VS2015 users. Even
284+
* though the MSVC compiler toolset in VS2017 delivers many new
285+
* features and conformance improvements it is a minor version,
286+
* compatible update from 14.00 in VS2015 to 14.10 in VS2017.
287+
*/
288+
#if COMPILER_MINOR_VERSION < 10
289+
#define VS_VERSION "2015"
290+
#elif COMPILER_MINOR_VERSION < 20
291+
#define VS_VERSION "2017"
292+
#else
293+
#define VS_VERSION "2019"
294+
#endif
295+
#else
296+
/*
297+
* Add additional checks here, before the #else.
298+
*/
299+
#define VS_VERSION "(unknown)"
300+
#endif /* VCPP_MAJOR_VERSION */
301+
302+
/*
303+
* XXX - should we show the raw compiler version number, as is
304+
* shown by "cl /?", which would be %d.%d.%d.%d with
305+
* COMPILER_MAJOR_VERSION, COMPILER_MINOR_VERSION,
306+
* COMPILER_BUILD_NUMBER, and _MSC_BUILD, the last of which is
307+
* "the revision number element of the compiler's version number",
308+
* which I guess is not to be confused with the build number,
309+
* the _BUILD in the name nonwithstanding.
310+
*/
311+
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual Studio " VS_VERSION " (VC++ %d.%d, build %d)",
312+
VCPP_MAJOR_VERSION, COMPILER_MINOR_VERSION, COMPILER_BUILD_NUMBER);
313+
#if defined(__clang__)
314+
/*
315+
* See above.
316+
*/
317+
g_string_append_printf(str, " clang/C2 %s and -fno-ms-compatibility.\n",
318+
__VERSION__);
319+
#else
320+
g_string_append_printf(str, ".\n");
321+
#endif
322+
#elif defined(__GNUC__) && defined(__VERSION__)
323+
/*
324+
* Clang and llvm-gcc also define __GNUC__ and __VERSION__;
325+
* distinguish between them.
326+
*/
327+
#if defined(__clang__)
328+
/*
329+
* We know this isn't clang/C2, as _MSC_FULL_VER isn't defined.
330+
*
331+
* Strip out trailing space from clang's __VERSION__ to be consistent
332+
* with other compilers.
333+
*/
334+
gchar* version = g_strstrip(g_strdup(__VERSION__));
335+
g_string_append_printf(str, "\n\nBuilt using clang %s.\n", version);
336+
g_free(version);
337+
#elif defined(__llvm__)
338+
/* llvm-gcc */
339+
g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
340+
#else /* boring old GCC */
341+
g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
342+
#endif /* llvm */
343+
#elif defined(__HP_aCC)
344+
g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
345+
#elif defined(__xlC__)
346+
g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
347+
(__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
348+
#ifdef __IBMC__
349+
if ((__IBMC__ % 10) != 0)
350+
g_string_append_printf(str, " patch %d", __IBMC__ % 10);
351+
#endif /* __IBMC__ */
352+
g_string_append_printf(str, "\n");
353+
#elif defined(__INTEL_COMPILER)
354+
g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
355+
__INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
356+
if ((__INTEL_COMPILER % 10) != 0)
357+
g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
358+
#ifdef __INTEL_COMPILER_BUILD_DATE
359+
g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
360+
__INTEL_COMPILER_BUILD_DATE / 10000,
361+
(__INTEL_COMPILER_BUILD_DATE / 100) % 100,
362+
__INTEL_COMPILER_BUILD_DATE % 100);
363+
#endif /* __INTEL_COMPILER_BUILD_DATE */
364+
g_string_append_printf(str, "\n");
365+
#elif defined(__SUNPRO_C)
366+
g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
367+
(__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
368+
if ((__SUNPRO_C & 0xF) != 0)
369+
g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
370+
g_string_append_printf(str, "\n");
371+
#endif
373372
}
374373

375374
/* XXX - is the setlocale() return string opaque? For glibc the separator is ';' */
@@ -495,12 +494,12 @@ void
495494
show_version(void)
496495
{
497496
ws_debug_printf("%s\n"
498-
"\n"
499-
"%s\n"
500-
"%s\n"
501-
"%s",
502-
appname_with_version, get_copyright_info(),
503-
comp_info, runtime_info);
497+
"\n"
498+
"%s\n"
499+
"%s\n"
500+
"%s",
501+
appname_with_version, get_copyright_info(),
502+
comp_info, runtime_info);
504503
}
505504

506505
void

0 commit comments

Comments
 (0)