Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-03-11 23:52:25 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-03-11 23:52:25 +0400
commit42b3463030b07ba3a87574c173e759e3bb15353b (patch)
tree1f7c20c45c294d9137bd75efabc414b02e6d7f60 /extern
parentc21c58f44c16b3d503d81577c1943f1f4b47b675 (diff)
Bundle new upstream version of libmv from own branch
This version of libmv includes new gflags and glog libraries which makes it possible to compile libmv with clang compiler. Also remove code from CMakeLists which was disabling libmv if using clang. Tested on linux with gcc-4.6 and clang-3.0, windows cmake+msvc and scons+mingw. Could be some issues with other platforms/build system which shall be simple to resolve.
Diffstat (limited to 'extern')
-rw-r--r--extern/libmv/CMakeLists.txt6
-rw-r--r--extern/libmv/ChangeLog75
-rw-r--r--extern/libmv/files.txt10
-rw-r--r--extern/libmv/libmv-capi.cpp1
-rw-r--r--extern/libmv/libmv/logging/logging.h2
-rw-r--r--extern/libmv/libmv/simple_pipeline/pipeline.cc19
-rw-r--r--extern/libmv/patches/bundle_tweaks.patch152
-rw-r--r--extern/libmv/patches/clang-3.diff49
-rw-r--r--extern/libmv/patches/series2
-rw-r--r--extern/libmv/third_party/gflags/AUTHORS2
-rw-r--r--extern/libmv/third_party/gflags/COPYING28
-rw-r--r--extern/libmv/third_party/gflags/ChangeLog195
-rw-r--r--extern/libmv/third_party/gflags/NEWS158
-rw-r--r--extern/libmv/third_party/gflags/README.libmv2
-rw-r--r--extern/libmv/third_party/gflags/config.h19
-rw-r--r--extern/libmv/third_party/gflags/gflags.cc285
-rw-r--r--extern/libmv/third_party/gflags/gflags/gflags.h (renamed from extern/libmv/third_party/gflags/gflags.h)255
-rw-r--r--extern/libmv/third_party/gflags/gflags/gflags_completions.h (renamed from extern/libmv/third_party/gflags/gflags_completions.h)23
-rw-r--r--extern/libmv/third_party/gflags/gflags/gflags_declare.h112
-rw-r--r--extern/libmv/third_party/gflags/gflags_completions.cc109
-rw-r--r--extern/libmv/third_party/gflags/gflags_reporting.cc81
-rw-r--r--extern/libmv/third_party/gflags/mutex.h13
-rw-r--r--extern/libmv/third_party/gflags/util.h339
-rw-r--r--extern/libmv/third_party/glog/ChangeLog10
-rw-r--r--extern/libmv/third_party/glog/README.libmv50
-rw-r--r--extern/libmv/third_party/glog/src/base/commandlineflags.h4
-rw-r--r--extern/libmv/third_party/glog/src/base/googleinit.h2
-rw-r--r--extern/libmv/third_party/glog/src/config_freebsd.h11
-rw-r--r--extern/libmv/third_party/glog/src/config_linux.h30
-rw-r--r--extern/libmv/third_party/glog/src/config_mac.h12
-rw-r--r--extern/libmv/third_party/glog/src/demangle.cc378
-rw-r--r--extern/libmv/third_party/glog/src/glog/log_severity.h10
-rw-r--r--extern/libmv/third_party/glog/src/glog/logging.h96
-rw-r--r--extern/libmv/third_party/glog/src/glog/raw_logging.h12
-rw-r--r--extern/libmv/third_party/glog/src/logging.cc83
-rw-r--r--extern/libmv/third_party/glog/src/raw_logging.cc2
-rw-r--r--extern/libmv/third_party/glog/src/signalhandler.cc10
-rw-r--r--extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h2
-rw-r--r--extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h4
-rw-r--r--extern/libmv/third_party/glog/src/symbolize.cc8
-rw-r--r--extern/libmv/third_party/glog/src/symbolize.h2
-rw-r--r--extern/libmv/third_party/glog/src/utilities.cc27
-rw-r--r--extern/libmv/third_party/glog/src/utilities.h4
-rw-r--r--extern/libmv/third_party/glog/src/vlog_is_on.cc6
-rw-r--r--extern/libmv/third_party/glog/src/windows/glog/log_severity.h10
-rw-r--r--extern/libmv/third_party/glog/src/windows/glog/logging.h95
-rw-r--r--extern/libmv/third_party/glog/src/windows/glog/raw_logging.h12
-rw-r--r--extern/libmv/third_party/glog/src/windows/port.h18
-rw-r--r--[-rwxr-xr-x]extern/libmv/third_party/glog/src/windows/preprocess.sh0
49 files changed, 1850 insertions, 985 deletions
diff --git a/extern/libmv/CMakeLists.txt b/extern/libmv/CMakeLists.txt
index 3bd021209df..c16d842dd65 100644
--- a/extern/libmv/CMakeLists.txt
+++ b/extern/libmv/CMakeLists.txt
@@ -132,9 +132,11 @@ set(SRC
third_party/fast/fast.h
third_party/gflags/config.h
- third_party/gflags/gflags_completions.h
- third_party/gflags/gflags.h
+ third_party/gflags/gflags/gflags_completions.h
+ third_party/gflags/gflags/gflags_declare.h
+ third_party/gflags/gflags/gflags.h
third_party/gflags/mutex.h
+ third_party/gflags/util.h
third_party/ldl/Include/ldl.h
third_party/msinttypes/inttypes.h
third_party/msinttypes/stdint.h
diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog
index f49a07de350..68c3431314a 100644
--- a/extern/libmv/ChangeLog
+++ b/extern/libmv/ChangeLog
@@ -1,3 +1,60 @@
+commit bf0c3423ba41b90638e89a56500aeaeb120fbaf1
+Author: Sergey I. Sharybin <g.ulairi@gmail.com>
+Date: Sun Mar 11 20:34:15 2012 +0600
+
+ Replace "third_party/glog/src/glog/logging.h" with <glog/logging.h>
+
+ It was needed because of how build systems is setup in Blender but think
+ this will be helpful change for other applications too because it makes
+ it's easier to move libraries around and even use libraries installed
+ on the operation system.
+
+commit 3e2673282f313c5bd19720f26d769f5d240a0563
+Author: Sergey I. Sharybin <g.ulairi@gmail.com>
+Date: Sun Mar 11 19:27:41 2012 +0600
+
+ Upgrade gflags and glog libraries - stage 2 (final)
+
+ Changes to upstream code which are needed to make libmv compile smooth on all platforms
+
+ * Replace <gflags/gflags.h> with "third_party/gflags/gflags/gflags.h" which is easier
+ to setup things in libmv and also helps with setting up building libmv into
+ external applications.
+ * Replace "glog/logging.h" and "glog/logging.h" with <glog/logging.h> and <glog/logging.h>
+ which is needed on Windows platform because otherwise files like logging.cc will be using
+ relative path which points to headers used by linux instead of headers need to be used
+ on Windows.
+ * Replace _asm int 3 with __debugbreak(). Such assembler code is obsolete and doesn't work
+ with 64bit versions of MSVC compilers.
+ * Do not use stacktrace for MinGW and FreeBSD because it leads into issues accessing
+ some specific data on this platforms.
+ * Define HAVE_LIB_GFLAGS for Windows builds.
+ * Do not define __declspec(dllimport) for MinGW platforms.
+ * Setup proper includes and datatypes for int32, uint32, int64 and uint64 for MinGW
+ * Do not define va_copy for MinGW platforms (it's already defined there).
+ * Patch localtime_r to be working fine with MinGW, disable strerror_r for MinGW because
+ of lack of needed functions.
+
+commit 8ed07abfa49d1e0511752021c972e0715e5a1383
+Author: Sergey I. Sharybin <g.ulairi@gmail.com>
+Date: Sun Mar 11 19:06:33 2012 +0600
+
+ Upgrade gflags and glog libraries - stage 1
+
+ This commit copies sources from latest original release of gflags and glog
+ over currently bundled versions of this libraries without any modifications.
+
+ This revision can't b compiled, all needed changes to make new libraries working
+ fine will be done with next commit to make it clear which changes were necessary
+ for easier bundling further newer version and extract patches and put them to
+ gflags/glog upstream repo.
+
+ Such upgrade of libraries is needed to make it able to compile libmv
+ with clang compilers. Currently used versions:
+
+ - gflags is version 2.0
+ - glog is version 0.3.2
+
commit 75b9af405964ff2c7d3f0a44500e27e63b37c91b
Author: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Fri Feb 17 23:29:11 2012 +0600
@@ -429,21 +486,3 @@ Author: Matthias Fauconneau <matthias.fauconneau@gmail.com>
Date: Thu Aug 18 23:14:17 2011 +0200
Fix affine iteration.
-
-commit 4e8e0aa6018e3eb2fbebdad7f1cbd6c909d26e79
-Author: Matthias Fauconneau <matthias.fauconneau@gmail.com>
-Date: Thu Aug 18 23:03:26 2011 +0200
-
- Handle rotations.
-
-commit 3ce41cf3c1b5c136a61d8f4c63ccae3cafbdb8da
-Author: Matthias Fauconneau <matthias.fauconneau@gmail.com>
-Date: Thu Aug 18 22:24:47 2011 +0200
-
- Slow brute-force affine diamond search implementation.
-
-commit 1c4acd03e030c1c50dc6fc36c419c72ea69a0713
-Author: Matthias Fauconneau <matthias.fauconneau@gmail.com>
-Date: Thu Aug 18 20:51:43 2011 +0200
-
- Fix detect.cc.
diff --git a/extern/libmv/files.txt b/extern/libmv/files.txt
index 96dfd89828e..028af579d11 100644
--- a/extern/libmv/files.txt
+++ b/extern/libmv/files.txt
@@ -78,14 +78,20 @@ third_party/fast/LICENSE
third_party/fast/nonmax.c
third_party/fast/README
third_party/fast/README.libmv
+third_party/gflags/AUTHORS
+third_party/gflags/ChangeLog
third_party/gflags/config.h
+third_party/gflags/COPYING
third_party/gflags/gflags.cc
third_party/gflags/gflags_completions.cc
-third_party/gflags/gflags_completions.h
-third_party/gflags/gflags.h
+third_party/gflags/gflags/gflags_completions.h
+third_party/gflags/gflags/gflags_declare.h
+third_party/gflags/gflags/gflags.h
third_party/gflags/gflags_reporting.cc
third_party/gflags/mutex.h
+third_party/gflags/NEWS
third_party/gflags/README.libmv
+third_party/gflags/util.h
third_party/glog/AUTHORS
third_party/glog/ChangeLog
third_party/glog/COPYING
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp
index 1835c53b53f..465bf519dbd 100644
--- a/extern/libmv/libmv-capi.cpp
+++ b/extern/libmv/libmv-capi.cpp
@@ -30,6 +30,7 @@
#include "libmv-capi.h"
+#include "third_party/gflags/gflags/gflags.h"
#include "glog/logging.h"
#include "libmv/logging/logging.h"
diff --git a/extern/libmv/libmv/logging/logging.h b/extern/libmv/libmv/logging/logging.h
index af86c4baa42..776d9d52f7a 100644
--- a/extern/libmv/libmv/logging/logging.h
+++ b/extern/libmv/libmv/logging/logging.h
@@ -21,7 +21,7 @@
#ifndef LIBMV_LOGGING_LOGGING_H
#define LIBMV_LOGGING_LOGGING_H
-#include "glog/logging.h"
+#include <glog/logging.h>
#define LG LOG(INFO)
#define V0 LOG(INFO)
diff --git a/extern/libmv/libmv/simple_pipeline/pipeline.cc b/extern/libmv/libmv/simple_pipeline/pipeline.cc
index 2e4e5a6491d..2459d059114 100644
--- a/extern/libmv/libmv/simple_pipeline/pipeline.cc
+++ b/extern/libmv/libmv/simple_pipeline/pipeline.cc
@@ -280,6 +280,25 @@ double InternalReprojectionError(const Tracks &image_tracks,
double ex = reprojected_marker.x - markers[i].x;
double ey = reprojected_marker.y - markers[i].y;
+ const int N = 100;
+ char line[N];
+ snprintf(line, N,
+ "image %-3d track %-3d "
+ "x %7.1f y %7.1f "
+ "rx %7.1f ry %7.1f "
+ "ex %7.1f ey %7.1f"
+ " e %7.1f",
+ markers[i].image,
+ markers[i].track,
+ markers[i].x,
+ markers[i].y,
+ reprojected_marker.x,
+ reprojected_marker.y,
+ ex,
+ ey,
+ sqrt(ex*ex + ey*ey));
+ LG << line;
+
total_error += sqrt(ex*ex + ey*ey);
}
LG << "Skipped " << num_skipped << " markers.";
diff --git a/extern/libmv/patches/bundle_tweaks.patch b/extern/libmv/patches/bundle_tweaks.patch
deleted file mode 100644
index aebc257f7f9..00000000000
--- a/extern/libmv/patches/bundle_tweaks.patch
+++ /dev/null
@@ -1,152 +0,0 @@
-diff --git a/src/libmv/logging/logging.h b/src/libmv/logging/logging.h
-index 067da52..af86c4b 100644
---- a/src/libmv/logging/logging.h
-+++ b/src/libmv/logging/logging.h
-@@ -21,7 +21,7 @@
- #ifndef LIBMV_LOGGING_LOGGING_H
- #define LIBMV_LOGGING_LOGGING_H
-
--#include "third_party/glog/src/glog/logging.h"
-+#include "glog/logging.h"
-
- #define LG LOG(INFO)
- #define V0 LOG(INFO)
-diff --git a/src/libmv/simple_pipeline/pipeline.cc b/src/libmv/simple_pipeline/pipeline.cc
-index 2459d05..2e4e5a6 100644
---- a/src/libmv/simple_pipeline/pipeline.cc
-+++ b/src/libmv/simple_pipeline/pipeline.cc
-@@ -280,25 +280,6 @@ double InternalReprojectionError(const Tracks &image_tracks,
- double ex = reprojected_marker.x - markers[i].x;
- double ey = reprojected_marker.y - markers[i].y;
-
-- const int N = 100;
-- char line[N];
-- snprintf(line, N,
-- "image %-3d track %-3d "
-- "x %7.1f y %7.1f "
-- "rx %7.1f ry %7.1f "
-- "ex %7.1f ey %7.1f"
-- " e %7.1f",
-- markers[i].image,
-- markers[i].track,
-- markers[i].x,
-- markers[i].y,
-- reprojected_marker.x,
-- reprojected_marker.y,
-- ex,
-- ey,
-- sqrt(ex*ex + ey*ey));
-- LG << line;
--
- total_error += sqrt(ex*ex + ey*ey);
- }
- LG << "Skipped " << num_skipped << " markers.";
-diff --git a/src/third_party/glog/src/glog/logging.h b/src/third_party/glog/src/glog/logging.h
-index 57615ef..a58d478 100644
---- a/src/third_party/glog/src/glog/logging.h
-+++ b/src/third_party/glog/src/glog/logging.h
-@@ -33,6 +33,7 @@
- // Pretty much everybody needs to #include this file so that they can
- // log various happenings.
- //
-+
- #ifndef _LOGGING_H_
- #define _LOGGING_H_
-
-diff --git a/src/third_party/glog/src/logging.cc b/src/third_party/glog/src/logging.cc
-index 868898f..1bb3867 100644
---- a/src/third_party/glog/src/logging.cc
-+++ b/src/third_party/glog/src/logging.cc
-@@ -58,8 +58,8 @@
- #include <errno.h> // for errno
- #include <sstream>
- #include "base/commandlineflags.h" // to get the program name
--#include "glog/logging.h"
--#include "glog/raw_logging.h"
-+#include <glog/logging.h>
-+#include <glog/raw_logging.h>
- #include "base/googleinit.h"
-
- #ifdef HAVE_STACKTRACE
-@@ -1232,7 +1232,9 @@ void LogMessage::RecordCrashReason(
- }
-
- static void logging_fail() {
--#if defined(_DEBUG) && defined(_MSC_VER)
-+// #if defined(_DEBUG) && defined(_MSC_VER)
-+// doesn't work for my laptop (sergey)
-+#if 0
- // When debugging on windows, avoid the obnoxious dialog and make
- // it possible to continue past a LOG(FATAL) in the debugger
- _asm int 3
-diff --git a/src/third_party/glog/src/raw_logging.cc b/src/third_party/glog/src/raw_logging.cc
-index 50c6a71..b179a1e 100644
---- a/src/third_party/glog/src/raw_logging.cc
-+++ b/src/third_party/glog/src/raw_logging.cc
-@@ -42,8 +42,8 @@
- #include <fcntl.h> // for open()
- #include <time.h>
- #include "config.h"
--#include "glog/logging.h" // To pick up flag settings etc.
--#include "glog/raw_logging.h"
-+#include <glog/logging.h> // To pick up flag settings etc.
-+#include <glog/raw_logging.h>
- #include "base/commandlineflags.h"
-
- #ifdef HAVE_STACKTRACE
-diff --git a/src/third_party/glog/src/utilities.h b/src/third_party/glog/src/utilities.h
-index c4ae256..5c841a0 100644
---- a/src/third_party/glog/src/utilities.h
-+++ b/src/third_party/glog/src/utilities.h
-@@ -79,7 +79,7 @@
- #endif
-
- #include "config.h"
--#include "glog/logging.h"
-+#include <glog/logging.h>
-
- // There are three different ways we can try to get the stack trace:
- //
-diff --git a/src/third_party/glog/src/vlog_is_on.cc b/src/third_party/glog/src/vlog_is_on.cc
-index ee0e412..ed88514 100644
---- a/src/third_party/glog/src/vlog_is_on.cc
-+++ b/src/third_party/glog/src/vlog_is_on.cc
-@@ -40,8 +40,8 @@
- #include <cstdio>
- #include <string>
- #include "base/commandlineflags.h"
--#include "glog/logging.h"
--#include "glog/raw_logging.h"
-+#include <glog/logging.h>
-+#include <glog/raw_logging.h>
- #include "base/googleinit.h"
-
- // glog doesn't have annotation
-diff --git a/src/third_party/glog/src/windows/config.h b/src/third_party/glog/src/windows/config.h
-index 114762e..682a1b9 100755
---- a/src/third_party/glog/src/windows/config.h
-+++ b/src/third_party/glog/src/windows/config.h
-@@ -19,7 +19,7 @@
- #undef HAVE_LIBUNWIND_H
-
- /* define if you have google gflags library */
--#undef HAVE_LIB_GFLAGS
-+#define HAVE_LIB_GFLAGS 1
-
- /* define if you have libunwind */
- #undef HAVE_LIB_UNWIND
-diff --git a/src/third_party/glog/src/windows/glog/logging.h b/src/third_party/glog/src/windows/glog/logging.h
-index 4257375..2f41681 100755
---- a/src/third_party/glog/src/windows/glog/logging.h
-+++ b/src/third_party/glog/src/windows/glog/logging.h
-@@ -82,8 +82,8 @@
- #include <inttypes.h> // a third place for uint16_t or u_int16_t
- #endif
-
--#if 0
--#include <gflags/gflags.h>
-+#if 1
-+#include "third_party/gflags/gflags.h"
- #endif
-
- #ifdef __MINGW32__
diff --git a/extern/libmv/patches/clang-3.diff b/extern/libmv/patches/clang-3.diff
deleted file mode 100644
index 9e73490827d..00000000000
--- a/extern/libmv/patches/clang-3.diff
+++ /dev/null
@@ -1,49 +0,0 @@
-Index: third_party/glog/src/utilities.h
-===================================================================
---- third_party/glog/src/utilities.h (revision 44501)
-+++ third_party/glog/src/utilities.h (working copy)
-@@ -105,7 +105,7 @@
- # undef STACKTRACE_H
- #elif defined(HAVE_LIB_UNWIND)
- # define STACKTRACE_H "stacktrace_libunwind-inl.h"
--#elif !defined(NO_FRAME_POINTER)
-+#elif !defined(NO_FRAME_POINTER) && !defined(__clang__)
- # if defined(__i386__) && __GNUC__ >= 2
- # define STACKTRACE_H "stacktrace_x86-inl.h"
- # elif defined(__x86_64__) && __GNUC__ >= 2
-Index: third_party/glog/src/logging.cc
-===================================================================
---- third_party/glog/src/logging.cc (revision 44501)
-+++ third_party/glog/src/logging.cc (working copy)
-@@ -1231,6 +1231,14 @@
- #endif
- }
-
-+#if defined(HAVE___ATTRIBUTE__)
-+typedef void (*fail_func_t)() __attribute__((noreturn));
-+static void logging_fail() __attribute__((noreturn));
-+#else
-+typedef void (*fail_func_t)();
-+static void logging_fail();
-+#endif
-+
- static void logging_fail() {
- // #if defined(_DEBUG) && defined(_MSC_VER)
- // doesn't work for my laptop (sergey)
-@@ -1243,14 +1251,9 @@
- #endif
- }
-
--#ifdef HAVE___ATTRIBUTE__
--GOOGLE_GLOG_DLL_DECL
--void (*g_logging_fail_func)() __attribute__((noreturn)) = &logging_fail;
--#else
--GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() = &logging_fail;
--#endif
-+GOOGLE_GLOG_DLL_DECL fail_func_t g_logging_fail_func = &logging_fail;
-
--void InstallFailureFunction(void (*fail_func)()) {
-+void InstallFailureFunction(fail_func_t fail_func) {
- g_logging_fail_func = fail_func;
- }
-
diff --git a/extern/libmv/patches/series b/extern/libmv/patches/series
index 2b2e69bd849..1db7983fdd0 100644
--- a/extern/libmv/patches/series
+++ b/extern/libmv/patches/series
@@ -1,3 +1 @@
v3d_verbosity.patch
-bundle_tweaks.patch
-clang-3.diff
diff --git a/extern/libmv/third_party/gflags/AUTHORS b/extern/libmv/third_party/gflags/AUTHORS
new file mode 100644
index 00000000000..887918bd00e
--- /dev/null
+++ b/extern/libmv/third_party/gflags/AUTHORS
@@ -0,0 +1,2 @@
+google-gflags@googlegroups.com
+
diff --git a/extern/libmv/third_party/gflags/COPYING b/extern/libmv/third_party/gflags/COPYING
new file mode 100644
index 00000000000..d15b0c24134
--- /dev/null
+++ b/extern/libmv/third_party/gflags/COPYING
@@ -0,0 +1,28 @@
+Copyright (c) 2006, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/extern/libmv/third_party/gflags/ChangeLog b/extern/libmv/third_party/gflags/ChangeLog
new file mode 100644
index 00000000000..f9ef9350984
--- /dev/null
+++ b/extern/libmv/third_party/gflags/ChangeLog
@@ -0,0 +1,195 @@
+Wed Jan 25 15:09:14 2012 Google Inc. <google-gflags@googlegroups.com>
+
+ * gflags: version 2.0
+ * Changed the 'official' gflags email in setup.py/etc
+ * Renamed google-gflags.sln to gflags.sln
+ * Changed copyright text to reflect Google's relinquished ownership
+
+Tue Dec 20 19:48:57 2011 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.7
+ * Add CommandLineFlagInfo::flag_ptr pointing to current storage (musji)
+ * PORTING: flush after writing to stderr, needed on cygwin
+ * PORTING: Clean up the GFLAGS_DLL_DECL stuff better
+ * Fix a bug in StringPrintf() that affected large strings (csilvers)
+ * Die at configure-time when g++ isn't installed
+
+Fri Jul 29 19:05:21 2011 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.6
+ * BUGFIX: Fix a bug where we were leaving out a required $(top_srcdir)
+ * Fix definition of clstring (jyrki)
+ * Split up flag declares into its own file (jyrki)
+ * Add --version support (csilvers)
+ * Update the README for gflags with static libs
+ * Update acx_pthread.m4 for nostdlib
+ * Change ReparseCommandLineFlags to return void (csilvers)
+ * Some doc typofixes and example augmentation (various)
+
+Mon Jan 24 16:11:35 2011 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.5
+ * Better reporting of current vs default value (handler)
+ * Add API for cleaning up of memory at program-exit (jmarantz)
+ * Fix macros to work inside namespaces (csilvers)
+ * Use our own string typedef in case string is redefined (csilvers)
+ * Updated to autoconf 2.65
+
+Wed Oct 13 17:40:12 2010 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.4
+ * Add a check to prevent passing 0 to DEFINE_string (jorg)
+ * Reduce compile (.o) size (jyrki)
+ * Some small changes to quiet debug compiles (alexk)
+ * PORTING: better support static linking on windows (csilvers)
+ * DOCUMENTATION: change default values, use validators, etc.
+ * Update the NEWS file to be non-empty
+ * Add pkg-config (.pc) files for libgflags and libgflags_nothreads
+
+Mon Jan 4 18:09:30 2010 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.3
+ * PORTABILITY: can now build and run tests under MSVC (csilvers)
+ * Remove the python gflags code, which is now its own package (tansell)
+ * Clarify that "last flag wins" in the docs (csilvers)
+ * Comment danger of using GetAllFlags in validators (wojtekm)
+ * PORTABILITY: Some fixes necessary for c++0x (mboerger)
+ * Makefile fix: $(srcdir) -> $(top_srcdir) in one place (csilvres)
+ * INSTALL: autotools to autoconf v2.64 + automake v1.11 (csilvers)
+
+Thu Sep 10 12:53:04 2009 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.2
+ * PORTABILITY: can now build and run tests under mingw (csilvers)
+ * Using a string arg for a bool flag is a compile-time error (rbayardo)
+ * Add --helpxml to gflags.py (salcianu)
+ * Protect against a hypothetical global d'tor mutex problem (csilvers)
+ * BUGFIX: can now define a flag after 'using namespace google' (hamaji)
+
+Tue Apr 14 12:35:25 2009 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.1
+ * Add both foo and nofoo for boolean flags, with --undefok (andychu)
+ * Better document how validators work (wojtekm)
+ * Improve binary-detection for bash-completion (mtamsky)
+ * Python: Add a concept of "key flags", used with --help (salcianu)
+ * Python: Robustify flag_values (salcianu)
+ * Python: Add a new DEFINE_bool alias (keir, andrewliu)
+ * Python: Do module introspection based on module name (dsturtevant)
+ * Fix autoconf a bit better, especially on windows and solaris (ajenjo)
+ * BUG FIX: gflags_nothreads was linking against the wrong lib (ajenjo)
+ * BUG FIX: threads-detection failed on FreeBSD; replace it (ajenjo)
+ * PORTABILITY: Quiet an internal compiler error with SUSE 10 (csilvers)
+ * PORTABILITY: Update deb.sh for more recenty debuilds (csilvers)
+ * PORTABILITY: #include more headers to satify new gcc's (csilvers)
+ * INSTALL: Updated to autoconf 2.61 and libtool 1.5.26 (csilvers)
+
+Fri Oct 3 15:16:46 2008 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.0
+ * Add a missing newline to an error string (bcmills)
+ * (otherwise exactly the same as gflags 1.0rc2)
+
+Thu Sep 18 12:58:05 2008 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 1.0rc2
+ * Report current flag values in --helpxml (hdn)
+ * Fix compilation troubles with gcc 4.3.3 (simonb)
+ * BUG FIX: I was missing a std:: in DECLARE_string (csilvers)
+ * BUG FIX: Clarify in docs how to specify --bool flags (csilvers)
+ * BUG FIX: Fix --helpshort for source files not in a subdir (csilvers)
+ * BUG FIX: Fix python unittest for 64-bit builds (bcmills)
+
+Tue Aug 19 16:15:48 2008
+
+ * google-gflags: version 1.0rc1
+ * Move #include files from google/ to gflags/ (csilvers)
+ * Small optimizations to reduce binary (library) size (jyrki)
+ * BUGFIX: forgot a std:: in one of the .h files (csilvers)
+ * Speed up locking by making sure calls are inlined (ajenjo)
+ * 64-BIT COMPATIBILITY: Use %PRId64 instead of %lld (csilvers)
+ * PORTABILITY: fix Makefile to work with Cygwin (ajenjo)
+ * PORTABILITY: fix code to compile under Visual Studio (ajenjo)
+ * PORTABILITY: fix code to compile under Solaris 10 with CC (csilvers)
+
+Mon Jul 21 23:01:38 2008 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.9
+ * Add the ability to validate a command-line flag (csilvers)
+ * Add completion support for commandline flags in bash (daven)
+ * Add -W compile flags to Makefile, when using gcc (csilvers)
+ * Allow helpstring to be NULL (cristianoc)
+ * Improved documentation of classes in the .cc file (csilvers)
+ * Fix python bug with AppendFlagValues + shortnames (jjtswan)
+ * Use bool instead of int for boolean flags in gflags.py (bcmills)
+ * Simplify the way we declare flags, now more foolproof (csilvers)
+ * Better error messages when bool flags collide (colohan)
+ * Only evaluate DEFINE_foo macro args once (csilvers)
+
+Wed Mar 26 15:20:18 2008 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.8
+ * Export DescribeOneFlag() in the API
+ * Add support for automatic line wrapping at 80 cols for gflags.py
+ * Bugfix: do not treat an isolated "-" the same as an isolated "--"
+ * Update rpm spec to point to Google Code rather than sourceforge (!)
+ * Improve documentation (including documenting thread-safety)
+ * Improve #include hygiene
+ * Improve testing
+
+Thu Oct 18 11:33:20 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.7
+ * Deal even more correctly with libpthread not linked in (csilvers)
+ * Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe)
+ * Be more accurate printing default flag values in --help (dsturtevant)
+ * Reduce .o file size a bit by using shorter namespace names (jeff)
+ * Use relative install path, so 'setup.py --home' works (csilvers)
+ * Notice when a boolean flag has a non-boolean default (bnmouli)
+ * Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie)
+ * Fix "no modules match" message for --helpshort, etc (hendrie)
+
+Wed Aug 15 07:35:51 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.6
+ * Deal correctly with case that libpthread is not linked in (csilvers)
+ * Update Makefile/tests so we pass "make distcheck" (csilvers)
+ * Document and test that last assignment to a flag wins (wan)
+
+Tue Jun 12 15:23:42 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.5
+ * Include all m4 macros in the distribution (csilvers)
+ * Python: Fix broken data_files field in setup.py (sidlon)
+ * Python: better string serliaizing and unparsing (abo, csimmons)
+ * Fix checks for NaN and inf to work with Mac OS X (csilvers)
+
+Thu Apr 19 15:15:07 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.4
+ * Remove is_default from GetCommandLineFlagInfo (csilvers)
+ * Portability fixes: includes, strtoll, gcc4.3 errors (csilvers)
+ * A few doc typo cleanups (csilvers)
+
+Wed Mar 28 12:15:56 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.3
+ * python portability fix: use popen instead of subprocess (csilvers)
+ * Add is_default to CommandLineFlagInfo (pchien)
+ * Make docs a bit prettier (csilvers)
+ * Actually include the python files in the distribution! :-/ (csilvers)
+
+Mon Jan 22 15:33:06 2007 Google Inc. <opensource@google.com>
+
+ * google-gflags: version 0.2
+ * added support for python commandlineflags, as well as c++
+ * gflags2man, a script to turn flags into a man page (dchristian)
+
+Wed Dec 13 12:37:19 2006 Google Inc. <opensource@google.com>
+
+ * google-gflags: initial release:
+ The gflags package contains a library that implements commandline
+ flags processing. As such it's a replacement for getopt(). It
+ has increased flexibility, including built-in support for C++
+ types like string, and the ability to define flags in the source
+ file in which they're used.
diff --git a/extern/libmv/third_party/gflags/NEWS b/extern/libmv/third_party/gflags/NEWS
new file mode 100644
index 00000000000..ffc0127d91e
--- /dev/null
+++ b/extern/libmv/third_party/gflags/NEWS
@@ -0,0 +1,158 @@
+== 25 January 2012 ==
+
+I've just released gflags 2.0.
+
+The `google-gflags` project has been renamed to `gflags`. I
+(csilvers) am stepping down as maintainer, to be replaced by Andreas
+Schuh. Welcome to the team, Andreas! I've seen the energy you have
+around gflags and the ideas you have for the project going forward,
+and look forward to having you on the team.
+
+I bumped the major version number up to 2 to reflect the new community
+ownership of the project. All the
+[http://gflags.googlecode.com/svn/tags/gflags-2.0/ChangeLog changes]
+are related to the renaming. There are no functional changes from
+gflags 1.7. In particular, I've kept the code in the namespace
+`google`, though in a future version it should be renamed to `gflags`.
+I've also kept the `/usr/local/include/google/` subdirectory as
+synonym of `/usr/local/include/gflags/`, though the former name has
+been obsolete for some time now.
+
+
+=== 18 January 2011 ===
+
+The `google-gflags` Google Code page has been renamed to
+`gflags`, in preparation for the project being renamed to
+`gflags`. In the coming weeks, I'll be stepping down as
+maintainer for the gflags project, and as part of that Google is
+relinquishing ownership of the project; it will now be entirely
+community run. The name change reflects that shift.
+
+
+=== 20 December 2011 ===
+
+I've just released gflags 1.7. This is a minor release; the major
+change is that `CommandLineFlagInfo` now exports the address in memory
+where the flag is located. There has also been a bugfix involving
+very long --help strings, and some other minor
+[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.7/ChangeLog changes].
+
+=== 29 July 2011 ===
+
+I've just released gflags 1.6. The major new feature in this release
+is support for setting version info, so that --version does something
+useful.
+
+One minor change has required bumping the library number:
+`ReparseCommandlineFlags` now returns `void` instead of `int` (the int
+return value was always meaningless). Though I doubt anyone ever used
+this (meaningless) return value, technically it's a change to the ABI
+that requires a version bump. A bit sad.
+
+There's also a procedural change with this release: I've changed the
+internal tools used to integrate Google-supplied patches for gflags
+into the opensource release. These new tools should result in more
+frequent updates with better change descriptions. They will also
+result in future `ChangeLog` entries being much more verbose (for better
+or for worse).
+
+See the
+[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.6/ChangeLog ChangeLog]
+for a full list of changes for this release.
+
+=== 24 January 2011 ===
+
+I've just released gflags 1.5. This release has only minor changes
+from 1.4, including some slightly better reporting in --help, and
+an new memory-cleanup function that can help when running gflags-using
+libraries under valgrind. The major change is to fix up the macros
+(`DEFINE_bool` and the like) to work more reliably inside namespaces.
+
+If you have not had a problem with these macros, and don't need any of
+the other changes described, there is no need to upgrade. See the
+[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.5/ChangeLog ChangeLog]
+for a full list of changes for this release.
+
+=== 11 October 2010 ===
+
+I've just released gflags 1.4. This release has only minor changes
+from 1.3, including some documentation tweaks and some work to make
+the library smaller. If 1.3 is working well for you, there's no
+particular reason to upgrade.
+
+=== 4 January 2010 ===
+
+I've just released gflags 1.3. gflags now compiles under MSVC, and
+all tests pass. I *really* never thought non-unix-y Windows folks
+would want gflags, but at least some of them do.
+
+The major news, though, is that I've separated out the python package
+into its own library, [http://code.google.com/p/python-gflags python-gflags].
+If you're interested in the Python version of gflags, that's the place to
+get it now.
+
+=== 10 September 2009 ==
+
+I've just released gflags 1.2. The major change from gflags 1.1 is it
+now compiles under MinGW (as well as cygwin), and all tests pass. I
+never thought Windows folks would want unix-style command-line flags,
+since they're so different from the Windows style, but I guess I was
+wrong!
+
+The other changes are minor, such as support for --htmlxml in the
+python version of gflags.
+
+=== 15 April 2009 ===
+
+I've just released gflags 1.1. It has only minor changes fdrom gflags
+1.0 (see the
+[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.1/ChangeLog ChangeLog]
+for details). The major change is that I moved to a new
+system for creating .deb and .rpm files. This allows me to create
+x86_64 deb and rpm files.
+
+In the process of moving to this new system, I noticed an
+inconsistency: the tar.gz and .rpm files created libraries named
+libgflags.so, but the deb file created libgoogle-gflags.so. I have
+fixed the deb file to create libraries like the others. I'm no expert
+in debian packaging, but I believe this has caused the package name to
+change as well. Please let me know (at
+[mailto:google-gflags@googlegroups.com
+google-gflags@googlegroups.com]) if this causes problems for you --
+especially if you know of a fix! I would be happy to change the deb
+packages to add symlinks from the old library name to the new
+(libgoogle-gflags.so -> libgflags.so), but that is beyond my knowledge
+of how to make .debs.
+
+If you've tried to install a .rpm or .deb and it doesn't work for you,
+let me know. I'm excited to finally have 64-bit package files, but
+there may still be some wrinkles in the new system to iron out.
+
+===1 October 2008===
+
+gflags 1.0rc2 was out for a few weeks without any issues, so gflags
+1.0 is now released. This is much like gflags 0.9. The major change
+is that the .h files have been moved from `/usr/include/google` to
+`/usr/include/gflags`. While I have backwards-compatibility
+forwarding headeds in place, please rewrite existing code to say
+{{{
+ #include <gflags/gflags.h>
+}}}
+instead of
+{{{
+ #include <google/gflags.h>
+}}}
+
+I've kept the default namespace to google. You can still change with
+with the appropriate flag to the configure script (`./configure
+--help` to see the flags). If you have feedback as to whether the
+default namespace should change to gflags, which would be a
+non-backwards-compatible change, send mail to
+`google-gflags@googlegroups.com`!
+
+Version 1.0 also has some neat new features, like support for bash
+commandline-completion of help flags. See the
+[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.0rc2/ChangeLog
+ChangeLog] for more details.
+
+If I don't hear any bad news for a few weeks, I'll release 1.0-final.
diff --git a/extern/libmv/third_party/gflags/README.libmv b/extern/libmv/third_party/gflags/README.libmv
index f2bdef6563e..673099ce618 100644
--- a/extern/libmv/third_party/gflags/README.libmv
+++ b/extern/libmv/third_party/gflags/README.libmv
@@ -1,7 +1,7 @@
Project: Google Flags
URL: http://code.google.com/p/google-gflags/
License: New BSD
-Upstream version: 1.5
+Upstream version: 2.0
Local modifications:
- Flattened the tree and only included files needed for libmv. This involved
diff --git a/extern/libmv/third_party/gflags/config.h b/extern/libmv/third_party/gflags/config.h
index ca2c1276c44..03ed03ca99b 100644
--- a/extern/libmv/third_party/gflags/config.h
+++ b/extern/libmv/third_party/gflags/config.h
@@ -15,7 +15,7 @@
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <fnmatch.h> header file. */
-#undef HAVE_FNMATCH_H
+/* #ubdef HAVE_FNMATCH_H 1 */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -29,12 +29,6 @@
/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1
-/* Define to 1 if you have the `putenv' function. */
-#define HAVE_PUTENV 1
-
-/* Define to 1 if you have the `setenv' function. */
-#define HAVE_SETENV 1
-
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -73,22 +67,19 @@
#define PACKAGE "gflags"
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "opensource@google.com"
+#define PACKAGE_BUGREPORT "google-gflags@googlegroups.com"
/* Define to the full name of this package. */
#define PACKAGE_NAME "gflags"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "gflags 1.5"
+#define PACKAGE_STRING "gflags 2.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "gflags"
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.5"
+#define PACKAGE_VERSION "2.0"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -101,7 +92,7 @@
#define STL_NAMESPACE std
/* Version number of package */
-#define VERSION "1.5"
+#define VERSION "2.0"
/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_ }
diff --git a/extern/libmv/third_party/gflags/gflags.cc b/extern/libmv/third_party/gflags/gflags.cc
index 34fe95dac59..4ba2b6f393c 100644
--- a/extern/libmv/third_party/gflags/gflags.cc
+++ b/extern/libmv/third_party/gflags/gflags.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006, Google Inc.
+// Copyright (c) 1999, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
-// Author: Ray Sidney
// Revamped and reorganized by Craig Silverstein
//
// This file contains the implementation of all our command line flags
@@ -88,76 +87,35 @@
// other hand, hooks into CommandLineFlagParser. Other API functions
// are, similarly, mostly hooks into the functionality described above.
-#include "config.h"
// This comes first to ensure we define __STDC_FORMAT_MACROS in time.
-#ifdef HAVE_INTTYPES_H
-#ifndef __STDC_FORMAT_MACROS
+#include "config.h"
+#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1 // gcc requires this to get PRId64, etc.
#endif
-#include <inttypes.h>
-#endif // HAVE_INTTYPES_H
-#include <stdio.h> // for snprintf
+
+#include "gflags/gflags.h"
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
-#include <stdio.h>
+#ifdef HAVE_FNMATCH_H
+# include <fnmatch.h>
+#endif
#include <stdarg.h> // For va_list and related operations
+#include <stdio.h>
#include <string.h>
-#include <assert.h>
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif // HAVE_FNMATCH_H
-#include <string>
+
+#include <algorithm>
#include <map>
-#include <vector>
+#include <string>
#include <utility> // for pair<>
-#include <algorithm>
-#include "gflags.h"
+#include <vector>
#include "mutex.h"
+#include "util.h"
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
#endif
-// Work properly if either strtoll or strtoq is on this system
-#ifdef HAVE_STRTOLL
-# define strtoint64 strtoll
-# define strtouint64 strtoull
-#elif HAVE_STRTOQ
-# define strtoint64 strtoq
-# define strtouint64 strtouq
-#else
-// Neither strtoll nor strtoq are defined. I hope strtol works!
-# define strtoint64 strtol
-# define strtouint64 strtoul
-#endif
-
-// If we have inttypes.h, it will have defined PRId32/etc for us. If
-// not, take our best guess.
-#ifndef PRId32
-# define PRId32 "d"
-#endif
-#ifndef PRId64
-# define PRId64 "lld"
-#endif
-#ifndef PRIu64
-# define PRIu64 "llu"
-#endif
-
-// Windows is missing random bits like strcasecmp, strtoll, strtoull, and
-// snprintf in the usual locations. Put them somewhere sensible.
-//
-// TODO(keir): Get the upstream Windows port and use that instead.
-#ifdef _MSC_VER
-# define snprintf _snprintf
-# undef strtoint64
-# define strtoint64 _strtoi64
-# undef strtouint64
-# define strtouint64 _strtoui64
-# define strcasecmp _stricmp
-#endif
-
-typedef signed char int8;
-typedef unsigned char uint8;
// Special flags, type 1: the 'recursive' flags. They set another flag's val.
DEFINE_string(flagfile, "",
@@ -183,20 +141,21 @@ using std::sort;
using std::string;
using std::vector;
+// This is used by the unittest to test error-exit code
+void GFLAGS_DLL_DECL (*gflags_exitfunc)(int) = &exit; // from stdlib.h
+
+
// The help message indicating that the commandline flag has been
// 'stripped'. It will not show up when doing "-help" and its
// variants. The flag is stripped if STRIP_FLAG_HELP is set to 1
-// before including gflags/gflags.h.
+// before including base/gflags.h
-// This is used by this file, and also in commandlineflags_reporting.cc
+// This is used by this file, and also in gflags_reporting.cc
const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001";
-// This is used by the unittest to test error-exit code
-void GFLAGS_DLL_DECL (*commandlineflags_exitfunc)(int) = &exit; // from stdlib.h
-
namespace {
-// There are also 'reporting' flags, in commandlineflags_reporting.cc.
+// There are also 'reporting' flags, in gflags_reporting.cc.
static const char kError[] = "ERROR: ";
@@ -218,12 +177,14 @@ enum DieWhenReporting { DIE, DO_NOT_DIE };
// Report Error and exit if requested.
static void ReportError(DieWhenReporting should_die, const char* format, ...) {
+ char error_message[255];
va_list ap;
va_start(ap, format);
- vfprintf(stderr, format, ap);
+ vsnprintf(error_message, sizeof(error_message), format, ap);
va_end(ap);
- if (should_die == DIE)
- commandlineflags_exitfunc(1); // almost certainly exit()
+ fprintf(stderr, "%s", error_message);
+ fflush(stderr); // should be unnecessary, but cygwin's rxvt buffers stderr
+ if (should_die == DIE) gflags_exitfunc(1);
}
@@ -317,6 +278,7 @@ bool FlagValue::ParseFrom(const char* value) {
if (type_ == FV_BOOL) {
const char* kTrue[] = { "1", "t", "true", "y", "yes" };
const char* kFalse[] = { "0", "f", "false", "n", "no" };
+ COMPILE_ASSERT(sizeof(kTrue) == sizeof(kFalse), true_false_equal);
for (size_t i = 0; i < sizeof(kTrue)/sizeof(*kTrue); ++i) {
if (strcasecmp(value, kTrue[i]) == 0) {
SET_VALUE_AS(bool, true);
@@ -346,7 +308,7 @@ bool FlagValue::ParseFrom(const char* value) {
switch (type_) {
case FV_INT32: {
- const int64 r = strtoint64(value, &end, base);
+ const int64 r = strto64(value, &end, base);
if (errno || end != value + strlen(value)) return false; // bad parse
if (static_cast<int32>(r) != r) // worked, but number out of range
return false;
@@ -354,7 +316,7 @@ bool FlagValue::ParseFrom(const char* value) {
return true;
}
case FV_INT64: {
- const int64 r = strtoint64(value, &end, base);
+ const int64 r = strto64(value, &end, base);
if (errno || end != value + strlen(value)) return false; // bad parse
SET_VALUE_AS(int64, r);
return true;
@@ -362,7 +324,7 @@ bool FlagValue::ParseFrom(const char* value) {
case FV_UINT64: {
while (*value == ' ') value++;
if (*value == '-') return false; // negative number
- const uint64 r = strtouint64(value, &end, base);
+ const uint64 r = strtou64(value, &end, base);
if (errno || end != value + strlen(value)) return false; // bad parse
SET_VALUE_AS(uint64, r);
return true;
@@ -531,6 +493,7 @@ class CommandLineFlag {
string default_value() const { return defvalue_->ToString(); }
const char* type_name() const { return defvalue_->TypeName(); }
ValidateFnProto validate_function() const { return validate_fn_proto_; }
+ const void* flag_ptr() const { return current_->value_buffer_; }
void FillCommandLineFlagInfo(struct CommandLineFlagInfo* result);
@@ -583,7 +546,6 @@ const char* CommandLineFlag::CleanFileName() const {
// search full path backwards.
// Stop going backwards at kRootDir; and skip by the first slash.
static const char kRootDir[] = ""; // can set this to root directory,
- // e.g. "myproject"
if (sizeof(kRootDir)-1 == 0) // no prefix to strip
return filename();
@@ -592,8 +554,7 @@ const char* CommandLineFlag::CleanFileName() const {
while ( clean_name > filename() ) {
if (*clean_name == PATH_SEPARATOR) {
if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) {
- // ".../myproject/base/logging.cc" ==> "base/logging.cc"
- clean_name += sizeof(kRootDir)-1; // past "/myproject/"
+ clean_name += sizeof(kRootDir)-1; // past root-dir
break;
}
}
@@ -614,6 +575,7 @@ void CommandLineFlag::FillCommandLineFlagInfo(
UpdateModifiedBit();
result->is_default = !modified_;
result->has_validator_fn = validate_function() != NULL;
+ result->flag_ptr = flag_ptr();
}
void CommandLineFlag::UpdateModifiedBit() {
@@ -634,6 +596,7 @@ void CommandLineFlag::CopyFrom(const CommandLineFlag& src) {
}
bool CommandLineFlag::Validate(const FlagValue& value) const {
+
if (validate_function() == NULL)
return true;
else
@@ -657,10 +620,14 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s
}
};
+
class FlagRegistry {
public:
- FlagRegistry() { }
+ FlagRegistry() {
+ }
~FlagRegistry() {
+ // Not using STLDeleteElements as that resides in util and this
+ // class is base.
for (FlagMap::iterator p = flags_.begin(), e = flags_.end(); p != e; ++p) {
CommandLineFlag* flag = p->second;
delete flag;
@@ -672,12 +639,12 @@ class FlagRegistry {
global_registry_ = NULL;
}
- void Lock() { lock_.Lock(); }
- void Unlock() { lock_.Unlock(); }
-
// Store a flag in this registry. Takes ownership of the given pointer.
void RegisterFlag(CommandLineFlag* flag);
+ void Lock() { lock_.Lock(); }
+ void Unlock() { lock_.Unlock(); }
+
// Returns the flag object for the specified name, or NULL if not found.
CommandLineFlag* FindFlagLocked(const char* name);
@@ -718,26 +685,26 @@ class FlagRegistry {
typedef map<const void*, CommandLineFlag*> FlagPtrMap;
FlagPtrMap flags_by_ptr_;
+ static FlagRegistry* global_registry_; // a singleton registry
+
Mutex lock_;
+ static Mutex global_registry_lock_;
- static FlagRegistry* global_registry_; // a singleton registry
- static Mutex global_registry_lock_; // guards creation of global_registry_
+ static void InitGlobalRegistry();
// Disallow
FlagRegistry(const FlagRegistry&);
FlagRegistry& operator=(const FlagRegistry&);
};
-FlagRegistry* FlagRegistry::global_registry_ = NULL;
-Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
+class FlagRegistryLock {
+ public:
+ explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); }
+ ~FlagRegistryLock() { fr_->Unlock(); }
+ private:
+ FlagRegistry *const fr_;
+};
-FlagRegistry* FlagRegistry::GlobalRegistry() {
- MutexLock acquire_lock(&global_registry_lock_);
- if (!global_registry_) {
- global_registry_ = new FlagRegistry;
- }
- return global_registry_;
-}
void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
Lock();
@@ -807,22 +774,22 @@ CommandLineFlag* FlagRegistry::SplitArgumentLocked(const char* arg,
// In that case, we want to return flag 'x'.
if (!(flag_name[0] == 'n' && flag_name[1] == 'o')) {
// flag-name is not 'nox', so we're not in the exception case.
- *error_message = (string(kError) +
- "unknown command line flag '" + *key + "'\n");
+ *error_message = StringPrintf("%sunknown command line flag '%s'\n",
+ kError, key->c_str());
return NULL;
}
flag = FindFlagLocked(flag_name+2);
if (flag == NULL) {
// No flag named 'x' exists, so we're not in the exception case.
- *error_message = (string(kError) +
- "unknown command line flag '" + *key + "'\n");
+ *error_message = StringPrintf("%sunknown command line flag '%s'\n",
+ kError, key->c_str());
return NULL;
}
if (strcmp(flag->type_name(), "bool") != 0) {
// 'x' exists but is not boolean, so we're not in the exception case.
- *error_message = (string(kError) +
- "boolean value (" + *key + ") specified for " +
- flag->type_name() + " command line flag\n");
+ *error_message = StringPrintf(
+ "%sboolean value (%s) specified for %s command line flag\n",
+ kError, key->c_str(), flag->type_name());
return NULL;
}
// We're in the exception case!
@@ -845,25 +812,27 @@ bool TryParseLocked(const CommandLineFlag* flag, FlagValue* flag_value,
FlagValue* tentative_value = flag_value->New();
if (!tentative_value->ParseFrom(value)) {
if (msg) {
- *msg += (string(kError) + "illegal value '" + value +
- + "' specified for " + flag->type_name() + " flag '"
- + flag->name() + "'\n");
+ StringAppendF(msg,
+ "%sillegal value '%s' specified for %s flag '%s'\n",
+ kError, value,
+ flag->type_name(), flag->name());
}
delete tentative_value;
return false;
} else if (!flag->Validate(*tentative_value)) {
if (msg) {
- *msg += (string(kError) + "failed validation of new value "
- + "'" + tentative_value->ToString() + "' for flag '" +
- + flag->name() + "'\n");
+ StringAppendF(msg,
+ "%sfailed validation of new value '%s' for flag '%s'\n",
+ kError, tentative_value->ToString().c_str(),
+ flag->name());
}
delete tentative_value;
return false;
} else {
flag_value->CopyFrom(*tentative_value);
if (msg) {
- *msg += (string(flag->name()) + " set to " + flag_value->ToString()
- + "\n");
+ StringAppendF(msg, "%s set to %s\n",
+ flag->name(), flag_value->ToString().c_str());
}
delete tentative_value;
return true;
@@ -890,7 +859,8 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
return false;
flag->modified_ = true;
} else {
- *msg = string(flag->name()) + " set to " + flag->current_value();
+ *msg = StringPrintf("%s set to %s",
+ flag->name(), flag->current_value().c_str());
}
break;
}
@@ -914,13 +884,17 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
return true;
}
-class FlagRegistryLock {
- public:
- explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); }
- ~FlagRegistryLock() { fr_->Unlock(); }
- private:
- FlagRegistry *const fr_;
-};
+// Get the singleton FlagRegistry object
+FlagRegistry* FlagRegistry::global_registry_ = NULL;
+Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
+
+FlagRegistry* FlagRegistry::GlobalRegistry() {
+ MutexLock acquire_lock(&global_registry_lock_);
+ if (!global_registry_) {
+ global_registry_ = new FlagRegistry;
+ }
+ return global_registry_;
+}
// --------------------------------------------------------------------
// CommandLineFlagParser
@@ -1002,12 +976,12 @@ class CommandLineFlagParser {
static void ParseFlagList(const char* value, vector<string>* flags) {
for (const char *p = value; p && *p; value = p) {
p = strchr(value, ',');
- int len;
+ size_t len;
if (p) {
- len = static_cast<int>(p - value);
+ len = p - value;
p++;
} else {
- len = static_cast<int>(strlen(value));
+ len = strlen(value);
}
if (len == 0)
@@ -1023,7 +997,7 @@ static void ParseFlagList(const char* value, vector<string>* flags) {
// can do all the I/O in one place and not worry about it everywhere.
// Plus, it's convenient to have the whole file contents at hand.
// Adds a newline at the end of the file.
-#define PFATAL(s) do { perror(s); commandlineflags_exitfunc(1); } while (0)
+#define PFATAL(s) do { perror(s); gflags_exitfunc(1); } while (0)
static string ReadFileIntoString(const char* filename) {
const int kBufSize = 8092;
@@ -1112,9 +1086,9 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
&& strcmp(flag->type_name(), "string") == 0
&& (strstr(flag->help(), "true")
|| strstr(flag->help(), "false"))) {
- fprintf(stderr, "Did you really mean to set flag '%s'"
- " to the value '%s'?\n",
- flag->name(), value);
+ LOG(WARNING) << "Did you really mean to set flag '"
+ << flag->name() << "' to the value '"
+ << value << "'?";
}
}
}
@@ -1165,9 +1139,10 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval,
const char* flagname = flaglist[i].c_str();
CommandLineFlag* flag = registry_->FindFlagLocked(flagname);
if (flag == NULL) {
- error_flags_[flagname] = (string(kError) + "unknown command line flag"
- + " '" + flagname + "'"
- + " (via --fromenv or --tryfromenv)\n");
+ error_flags_[flagname] =
+ StringPrintf("%sunknown command line flag '%s' "
+ "(via --fromenv or --tryfromenv)\n",
+ kError, flagname);
undefined_names_[flagname] = "";
continue;
}
@@ -1185,8 +1160,9 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval,
// Avoid infinite recursion.
if ((strcmp(envval, "fromenv") == 0) ||
(strcmp(envval, "tryfromenv") == 0)) {
- error_flags_[flagname] = (string(kError) + "infinite recursion on " +
- "environment flag '" + envval + "'\n");
+ error_flags_[flagname] =
+ StringPrintf("%sinfinite recursion on environment flag '%s'\n",
+ kError, envval);
continue;
}
@@ -1289,7 +1265,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
while (*flagfile_contents && isspace(*flagfile_contents))
++flagfile_contents;
line_end = strchr(flagfile_contents, '\n');
- size_t len = line_end ? static_cast<size_t>(line_end - flagfile_contents)
+ size_t len = line_end ? line_end - flagfile_contents
: strlen(flagfile_contents);
string line(flagfile_contents, len);
@@ -1340,17 +1316,17 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
space = word + strlen(word);
const string glob(word, space - word);
// We try matching both against the full argv0 and basename(argv0)
+ if (glob == ProgramInvocationName() // small optimization
+ || glob == ProgramInvocationShortName()
#ifdef HAVE_FNMATCH_H
- if (fnmatch(glob.c_str(),
- ProgramInvocationName(),
- FNM_PATHNAME) == 0 ||
- fnmatch(glob.c_str(),
- ProgramInvocationShortName(),
- FNM_PATHNAME) == 0) {
-#else // !HAVE_FNMATCH_H
- if ((glob == ProgramInvocationName()) ||
- (glob == ProgramInvocationShortName())) {
-#endif // HAVE_FNMATCH_H
+ || fnmatch(glob.c_str(),
+ ProgramInvocationName(),
+ FNM_PATHNAME) == 0
+ || fnmatch(glob.c_str(),
+ ProgramInvocationShortName(),
+ FNM_PATHNAME) == 0
+#endif
+ ) {
flags_are_relevant = true;
}
}
@@ -1391,14 +1367,14 @@ bool AddFlagValidator(const void* flag_ptr, ValidateFnProto validate_fn_proto) {
// This is the CommandLineFlag whose current_->value_buffer_ == flag
CommandLineFlag* flag = registry->FindFlagViaPtrLocked(flag_ptr);
if (!flag) {
- // WARNING << "Ignoring RegisterValidateFunction() for flag pointer "
- // << flag_ptr << ": no flag found at that address";
+ LOG(WARNING) << "Ignoring RegisterValidateFunction() for flag pointer "
+ << flag_ptr << ": no flag found at that address";
return false;
} else if (validate_fn_proto == flag->validate_function()) {
return true; // ok to register the same function over and over again
} else if (validate_fn_proto != NULL && flag->validate_function() != NULL) {
- // WARNING << "Ignoring RegisterValidateFunction() for flag '"
- // << flag->name() << "': validate-fn already registered";
+ LOG(WARNING) << "Ignoring RegisterValidateFunction() for flag '"
+ << flag->name() << "': validate-fn already registered";
return false;
} else {
flag->validate_fn_proto_ = validate_fn_proto;
@@ -1549,6 +1525,24 @@ const char* ProgramUsage() {
}
// --------------------------------------------------------------------
+// SetVersionString()
+// VersionString()
+// --------------------------------------------------------------------
+
+static const char* version_string = NULL;
+
+void SetVersionString(const string& version) {
+ if (version_string != NULL)
+ ReportError(DIE, "ERROR: SetVersionString() called twice\n");
+ version_string = strdup(version.c_str()); // small memory leak
+}
+
+const char* VersionString() {
+ return version_string ? version_string : "";
+}
+
+
+// --------------------------------------------------------------------
// GetCommandLineOption()
// GetCommandLineFlagInfo()
// GetCommandLineFlagInfoOrDie()
@@ -1601,7 +1595,7 @@ CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name) {
CommandLineFlagInfo info;
if (!GetCommandLineFlagInfo(name, &info)) {
fprintf(stderr, "FATAL ERROR: flag name '%s' doesn't exist\n", name);
- commandlineflags_exitfunc(1); // almost certainly exit()
+ gflags_exitfunc(1); // almost certainly gflags_exitfunc()
}
return info;
}
@@ -1616,10 +1610,7 @@ string SetCommandLineOptionWithMode(const char* name, const char* value,
CommandLineFlagParser parser(registry);
result = parser.ProcessSingleOptionLocked(flag, value, set_mode);
if (!result.empty()) { // in the error case, we've already logged
- // You could consider logging this change, if you wanted to know it:
- //fprintf(stderr, "%sFLAGS_%s\n",
- // (set_mode == SET_FLAGS_DEFAULT ? "default value of " : ""),
- // result);
+ // Could consider logging this change
}
}
// The API of this function is that we return empty string on error
@@ -1765,7 +1756,7 @@ bool ReadFlagsFromString(const string& flagfilecontents,
if (parser.ReportErrors()) {
// Error. Restore all global flags to their previous values.
if (errors_are_fatal)
- commandlineflags_exitfunc(1); // almost certainly exit()
+ gflags_exitfunc(1);
saved_states.RestoreToRegistry();
return false;
}
@@ -1917,7 +1908,7 @@ static uint32 ParseCommandLineFlagsInternal(int* argc, char*** argv,
parser.ValidateAllFlags();
if (parser.ReportErrors()) // may cause us to exit on illegal flags
- commandlineflags_exitfunc(1); // almost certainly exit()
+ gflags_exitfunc(1);
return r;
}
@@ -1947,7 +1938,7 @@ void AllowCommandLineReparsing() {
allow_command_line_reparsing = true;
}
-uint32 ReparseCommandLineNonHelpFlags() {
+void ReparseCommandLineNonHelpFlags() {
// We make a copy of argc and argv to pass in
const vector<string>& argvs = GetArgvs();
int tmp_argc = static_cast<int>(argvs.size());
@@ -1955,13 +1946,11 @@ uint32 ReparseCommandLineNonHelpFlags() {
for (int i = 0; i < tmp_argc; ++i)
tmp_argv[i] = strdup(argvs[i].c_str()); // TODO(csilvers): don't dup
- const int retval = ParseCommandLineNonHelpFlags(&tmp_argc, &tmp_argv, false);
+ ParseCommandLineNonHelpFlags(&tmp_argc, &tmp_argv, false);
for (int i = 0; i < tmp_argc; ++i)
free(tmp_argv[i]);
delete[] tmp_argv;
-
- return retval;
}
void ShutDownCommandLineFlags() {
diff --git a/extern/libmv/third_party/gflags/gflags.h b/extern/libmv/third_party/gflags/gflags/gflags.h
index cefbd62ae51..e69812c8c38 100644
--- a/extern/libmv/third_party/gflags/gflags.h
+++ b/extern/libmv/third_party/gflags/gflags/gflags.h
@@ -28,7 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
-// Author: Ray Sidney
// Revamped and reorganized by Craig Silverstein
//
// This is the file that should be included by any file which declares
@@ -52,8 +51,8 @@
// if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
// }
//
-// Then, at the command-line:
-// ./foo --noverbose --start=5 --end=100
+// Then, at the command-line:
+// ./foo --noverbose --start=5 --end=100
//
// For more details, see
// doc/gflags.html
@@ -76,48 +75,22 @@
// other thread is writing to the variable or calling non-const
// methods of this class.
-#ifndef GOOGLE_GFLAGS_H_
-#define GOOGLE_GFLAGS_H_
+#ifndef BASE_COMMANDLINEFLAGS_H_
+#define BASE_COMMANDLINEFLAGS_H_
#include <string>
#include <vector>
-
-// We care a lot about number of bits things take up. Unfortunately,
-// systems define their bit-specific ints in a lot of different ways.
-// We use our own way, and have a typedef to get there.
-// Note: these commands below may look like "#if 1" or "#if 0", but
-// that's because they were constructed that way at ./configure time.
-// Look at gflags.h.in to see how they're calculated (based on your config).
-#if 1
-#include <stdint.h> // the normal place uint16_t is defined
-#endif
-#if 1
-#include <sys/types.h> // the normal place u_int16_t is defined
-#endif
-#if 1
-#include <inttypes.h> // a third place for uint16_t or u_int16_t
-#endif
-
+#include "gflags_declare.h" // IWYU pragma: export
namespace google {
-#if 1 // the C99 format
-typedef int32_t int32;
-typedef uint32_t uint32;
-typedef int64_t int64;
-typedef uint64_t uint64;
-#elif 1 // the BSD format
-typedef int32_t int32;
-typedef u_int32_t uint32;
-typedef int64_t int64;
-typedef u_int64_t uint64;
-#elif 0 // the windows (vc7) format
-typedef __int32 int32;
-typedef unsigned __int32 uint32;
-typedef __int64 int64;
-typedef unsigned __int64 uint64;
-#else
-#error Do not know how to define a 32-bit integer quantity on your system
-#endif
+//
+// NOTE: all functions below MUST have an explicit 'extern' before
+// them. Our automated opensourcing tools use this as a signal to do
+// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
+//
+#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
+#define GFLAGS_DLL_DEFINE_FLAG /* rewritten to be non-empty in windows dir */
+
// --------------------------------------------------------------------
// To actually define a flag in a file, use DEFINE_bool,
@@ -148,18 +121,19 @@ typedef unsigned __int64 uint64;
// Returns true if successfully registered, false if not (because the
// first argument doesn't point to a command-line flag, or because a
// validator is already registered for this flag).
-bool RegisterFlagValidator(const bool* flag,
- bool (*validate_fn)(const char*, bool));
-bool RegisterFlagValidator(const int32* flag,
- bool (*validate_fn)(const char*, int32));
-bool RegisterFlagValidator(const int64* flag,
- bool (*validate_fn)(const char*, int64));
-bool RegisterFlagValidator(const uint64* flag,
- bool (*validate_fn)(const char*, uint64));
-bool RegisterFlagValidator(const double* flag,
- bool (*validate_fn)(const char*, double));
-bool RegisterFlagValidator(const std::string* flag,
- bool (*validate_fn)(const char*, const std::string&));
+extern bool RegisterFlagValidator(const bool* flag,
+ bool (*validate_fn)(const char*, bool));
+extern bool RegisterFlagValidator(const int32* flag,
+ bool (*validate_fn)(const char*, int32));
+extern bool RegisterFlagValidator(const int64* flag,
+ bool (*validate_fn)(const char*, int64));
+extern bool RegisterFlagValidator(const uint64* flag,
+ bool (*validate_fn)(const char*, uint64));
+extern bool RegisterFlagValidator(const double* flag,
+ bool (*validate_fn)(const char*, double));
+extern bool RegisterFlagValidator(const std::string* flag,
+ bool (*validate_fn)(const char*,
+ const std::string&));
// --------------------------------------------------------------------
@@ -173,26 +147,27 @@ bool RegisterFlagValidator(const std::string* flag,
// name) and argv (the entire commandline), which we sock away a copy of.
// These variables are static, so you should only set them once.
-struct CommandLineFlagInfo {
- std::string name; // the name of the flag
- std::string type; // the type of the flag: int32, etc
- std::string description; // the "help text" associated with the flag
- std::string current_value; // the current value, as a string
- std::string default_value; // the default value, as a string
- std::string filename; // 'cleaned' version of filename holding the flag
- bool has_validator_fn; // true if RegisterFlagValidator called on flag
- bool is_default; // true if the flag has the default value and
- // has not been set explicitly from the cmdline
- // or via SetCommandLineOption
+struct GFLAGS_DLL_DECL CommandLineFlagInfo {
+ std::string name; // the name of the flag
+ std::string type; // the type of the flag: int32, etc
+ std::string description; // the "help text" associated with the flag
+ std::string current_value; // the current value, as a string
+ std::string default_value; // the default value, as a string
+ std::string filename; // 'cleaned' version of filename holding the flag
+ bool has_validator_fn; // true if RegisterFlagValidator called on this flag
+ bool is_default; // true if the flag has the default value and
+ // has not been set explicitly from the cmdline
+ // or via SetCommandLineOption
+ const void* flag_ptr; // pointer to the flag's current value (i.e. FLAGS_foo)
};
// Using this inside of a validator is a recipe for a deadlock.
-// TODO(wojtekm) Fix locking when validators are running, to make it safe to
+// TODO(user) Fix locking when validators are running, to make it safe to
// call validators during ParseAllFlags.
// Also make sure then to uncomment the corresponding unit test in
-// commandlineflags_unittest.sh
+// gflags_unittest.sh
extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
-// These two are actually defined in commandlineflags_reporting.cc.
+// These two are actually defined in gflags_reporting.cc.
extern void ShowUsageWithFlags(const char *argv0); // what --help does
extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
@@ -202,17 +177,24 @@ extern std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
// Thread-hostile; meant to be called before any threads are spawned.
extern void SetArgv(int argc, const char** argv);
+
// The following functions are thread-safe as long as SetArgv() is
// only called before any threads start.
-extern const std::vector<std::string>& GetArgvs(); // all of argv as a vector
-extern const char* GetArgv(); // all of argv as a string
-extern const char* GetArgv0(); // only argv0
-extern uint32 GetArgvSum(); // simple checksum of argv
-extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
+extern const std::vector<std::string>& GetArgvs();
+extern const char* GetArgv(); // all of argv as a string
+extern const char* GetArgv0(); // only argv0
+extern uint32 GetArgvSum(); // simple checksum of argv
+extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
extern const char* ProgramInvocationShortName(); // basename(argv0)
+
// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
// called before any threads start.
-extern const char* ProgramUsage(); // string set by SetUsageMessage()
+extern const char* ProgramUsage(); // string set by SetUsageMessage()
+
+// VersionString() is thread-safe as long as SetVersionString() is only
+// called before any threads start.
+extern const char* VersionString(); // string set by SetVersionString()
+
// --------------------------------------------------------------------
@@ -237,7 +219,7 @@ extern bool GetCommandLineFlagInfo(const char* name,
// if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
extern CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
-enum FlagSettingMode {
+enum GFLAGS_DLL_DECL FlagSettingMode {
// update the flag's value (can call this multiple times).
SET_FLAGS_VALUE,
// update the flag's value, but *only if* it has not yet been updated
@@ -259,7 +241,7 @@ enum FlagSettingMode {
// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
extern std::string SetCommandLineOption(const char* name, const char* value);
extern std::string SetCommandLineOptionWithMode(const char* name, const char* value,
- FlagSettingMode set_mode);
+ FlagSettingMode set_mode);
// --------------------------------------------------------------------
@@ -280,14 +262,17 @@ extern std::string SetCommandLineOptionWithMode(const char* name, const char* va
// // without worrying about restoring the FLAG values.
// }
//
-// Note: This class is marked with __attribute__((unused)) because all the
+// Note: This class is marked with ATTRIBUTE_UNUSED because all the
// work is done in the constructor and destructor, so in the standard
// usage example above, the compiler would complain that it's an
// unused variable.
//
-// This class is thread-safe.
+// This class is thread-safe. However, its destructor writes to
+// exactly the set of flags that have changed value during its
+// lifetime, so concurrent _direct_ access to those flags
+// (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe.
-class FlagSaver {
+class GFLAGS_DLL_DECL FlagSaver {
public:
FlagSaver();
~FlagSaver();
@@ -311,12 +296,11 @@ extern std::string CommandlineFlagsIntoString();
// Usually where this is used, a FlagSaver should be used instead.
extern bool ReadFlagsFromString(const std::string& flagfilecontents,
const char* prog_name,
- bool errors_are_fatal); // uses SET_FLAGS_VALUE
+ bool errors_are_fatal); // uses SET_FLAGS_VALUE
// These let you manually implement --flagfile functionality.
// DEPRECATED.
extern bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
-extern bool SaveCommandFlags(); // actually defined in google.cc !
extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
bool errors_are_fatal); // uses SET_FLAGS_VALUE
@@ -338,7 +322,7 @@ extern const char *StringFromEnv(const char *varname, const char *defval);
// --------------------------------------------------------------------
-// The next two functions parse commandlineflags from main():
+// The next two functions parse gflags from main():
// Set the "usage" message for this program. For example:
// string usage("This program does nothing. Sample usage:\n");
@@ -348,6 +332,12 @@ extern const char *StringFromEnv(const char *varname, const char *defval);
// Thread-hostile; meant to be called before any threads are spawned.
extern void SetUsageMessage(const std::string& usage);
+// Sets the version string, which is emitted with --version.
+// For instance: SetVersionString("1.3");
+// Thread-hostile; meant to be called before any threads are spawned.
+extern void SetVersionString(const std::string& version);
+
+
// Looks for flags in argv and parses them. Rearranges argv to put
// flags first, or removes them entirely if remove_flags is true.
// If a flag is defined more than once in the command line or flag
@@ -355,8 +345,7 @@ extern void SetUsageMessage(const std::string& usage);
// of the first non-flag argument.
// See top-of-file for more details on this function.
#ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
-extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
- bool remove_flags);
+extern uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
#endif
@@ -372,10 +361,10 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
// non-flag argument. (If remove_flags is true, will always return 1.)
extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
bool remove_flags);
-// This is actually defined in commandlineflags_reporting.cc.
+// This is actually defined in gflags_reporting.cc.
// This function is misnamed (it also handles --version, etc.), but
// it's too late to change that now. :-(
-extern void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc
+extern void HandleCommandLineHelpFlags(); // in gflags_reporting.cc
// Allow command line reparsing. Disables the error normally
// generated when an unknown flag is found, since it may be found in a
@@ -389,18 +378,17 @@ extern void AllowCommandLineReparsing();
// separate command line argument that follows the flag argument.
// Intended for handling flags from dynamically loaded libraries,
// since their flags are not registered until they are loaded.
-// Returns the index (into the original argv) of the first non-flag
-// argument. (If remove_flags is true, will always return 1.)
-extern uint32 ReparseCommandLineNonHelpFlags();
+extern void ReparseCommandLineNonHelpFlags();
// Clean up memory allocated by flags. This is only needed to reduce
// the quantity of "potentially leaked" reports emitted by memory
// debugging tools such as valgrind. It is not required for normal
-// operation, or for the perftools heap-checker. It must only be called
-// when the process is about to exit, and all threads that might
-// access flags are quiescent. Referencing flags after this is called
-// will have unexpected consequences. This is not safe to run when
-// multiple threads might be running: the function is thread-hostile.
+// operation, or for the google perftools heap-checker. It must only
+// be called when the process is about to exit, and all threads that
+// might access flags are quiescent. Referencing flags after this is
+// called will have unexpected consequences. This is not safe to run
+// when multiple threads might be running: the function is
+// thread-hostile.
extern void ShutDownCommandLineFlags();
@@ -441,15 +429,13 @@ extern void ShutDownCommandLineFlags();
// people can't DECLARE_int32 something that they DEFINE_bool'd
// elsewhere.
-class FlagRegisterer {
+class GFLAGS_DLL_DECL FlagRegisterer {
public:
FlagRegisterer(const char* name, const char* type,
const char* help, const char* filename,
void* current_storage, void* defvalue_storage);
};
-extern bool FlagsTypeWarn(const char *name);
-
// If your application #defines STRIP_FLAG_HELP to a non-zero value
// before #including this file, we remove the help message from the
// binary file. This can reduce the size of the resulting binary
@@ -463,7 +449,8 @@ extern const char kStrippedFlagHelp[];
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
// Need this construct to avoid the 'defined but not used' warning.
-#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : ::google::kStrippedFlagHelp)
+#define MAYBE_STRIPPED_HELP(txt) \
+ (false ? (txt) : ::google::kStrippedFlagHelp)
#else
#define MAYBE_STRIPPED_HELP(txt) txt
#endif
@@ -479,21 +466,16 @@ extern const char kStrippedFlagHelp[];
// FLAGS_no<name>. This serves the second purpose of assuring a
// compile error if someone tries to define a flag named no<name>
// which is illegal (--foo and --nofoo both affect the "foo" flag).
-#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
- namespace fL##shorttype { \
- static const type FLAGS_nono##name = value; \
- type FLAGS_##name = FLAGS_nono##name; \
- type FLAGS_no##name = FLAGS_nono##name; \
- static ::google::FlagRegisterer o_##name( \
- #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
- &FLAGS_##name, &FLAGS_no##name); \
- } \
- using fL##shorttype::FLAGS_##name
-
-#define DECLARE_VARIABLE(type, shorttype, name) \
- namespace fL##shorttype { \
- extern type FLAGS_##name; \
- } \
+#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
+ namespace fL##shorttype { \
+ static const type FLAGS_nono##name = value; \
+ /* We always want to export defined variables, dll or no */ \
+ GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
+ type FLAGS_no##name = FLAGS_nono##name; \
+ static ::google::FlagRegisterer o_##name( \
+ #name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
+ &FLAGS_##name, &FLAGS_no##name); \
+ } \
using fL##shorttype::FLAGS_##name
// For DEFINE_bool, we want to do the extra check that the passed-in
@@ -503,34 +485,39 @@ extern const char kStrippedFlagHelp[];
// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
// that the compiler have different sizes for bool & double. Since
// this is not guaranteed by the standard, we check it with a
-// compile-time assert (msg[-1] will give a compile-time error).
+// COMPILE_ASSERT.
namespace fLB {
struct CompileAssert {};
typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
(sizeof(double) != sizeof(bool)) ? 1 : -1];
-template<typename From> double IsBoolFlag(const From& from);
-bool IsBoolFlag(bool from);
+template<typename From> double GFLAGS_DLL_DECL IsBoolFlag(const From& from);
+GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
} // namespace fLB
-#define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name)
-#define DEFINE_bool(name, val, txt) \
- namespace fLB { \
- typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
+// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
+// are in a separate include, gflags_declare.h, for reducing
+// the physical transitive size for DECLARE use.
+#define DEFINE_bool(name, val, txt) \
+ namespace fLB { \
+ typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double)) ? 1 : -1]; \
- } \
+ } \
DEFINE_VARIABLE(bool, B, name, val, txt)
-#define DECLARE_int32(name) DECLARE_VARIABLE(::google::int32, I, name)
-#define DEFINE_int32(name,val,txt) DEFINE_VARIABLE(::google::int32, I, name, val, txt)
+#define DEFINE_int32(name, val, txt) \
+ DEFINE_VARIABLE(::google::int32, I, \
+ name, val, txt)
-#define DECLARE_int64(name) DECLARE_VARIABLE(::google::int64, I64, name)
-#define DEFINE_int64(name,val,txt) DEFINE_VARIABLE(::google::int64, I64, name, val, txt)
+#define DEFINE_int64(name, val, txt) \
+ DEFINE_VARIABLE(::google::int64, I64, \
+ name, val, txt)
-#define DECLARE_uint64(name) DECLARE_VARIABLE(::google::uint64, U64, name)
-#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(::google::uint64, U64, name, val, txt)
+#define DEFINE_uint64(name,val, txt) \
+ DEFINE_VARIABLE(::google::uint64, U64, \
+ name, val, txt)
-#define DECLARE_double(name) DECLARE_VARIABLE(double, D, name)
-#define DEFINE_double(name, val, txt) DEFINE_VARIABLE(double, D, name, val, txt)
+#define DEFINE_double(name, val, txt) \
+ DEFINE_VARIABLE(double, D, name, val, txt)
// Strings are trickier, because they're not a POD, so we can't
// construct them at static-initialization time (instead they get
@@ -540,11 +527,6 @@ bool IsBoolFlag(bool from);
// into it later. It's not perfect, but the best we can do.
namespace fLS {
-// The meaning of "string" might be different between now and when the
-// macros below get invoked (e.g., if someone is experimenting with
-// other string implementations that get defined after this file is
-// included). Save the current meaning now and use it in the macros.
-typedef std::string clstring;
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
const char *value) {
@@ -558,9 +540,6 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
int value);
} // namespace fLS
-#define DECLARE_string(name) namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
- using fLS::FLAGS_##name
-
// We need to define a var named FLAGS_no##name so people don't define
// --string and --nostring. And we need a temporary place to put val
// so we don't have to evaluate it twice. Two great needs that go
@@ -575,10 +554,10 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
clstring* const FLAGS_no##name = ::fLS:: \
dont_pass0toDEFINE_string(s_##name[0].s, \
val); \
- static ::google::FlagRegisterer o_##name( \
+ static ::google::FlagRegisterer o_##name( \
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
- extern clstring& FLAGS_##name; \
+ extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
using fLS::FLAGS_##name; \
clstring& FLAGS_##name = *FLAGS_no##name; \
} \
@@ -586,4 +565,4 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
#endif // SWIG
-#endif // GOOGLE_GFLAGS_H_
+#endif // BASE_COMMANDLINEFLAGS_H_
diff --git a/extern/libmv/third_party/gflags/gflags_completions.h b/extern/libmv/third_party/gflags/gflags/gflags_completions.h
index 9d9ce7a5f75..37f5b0ec2cf 100644
--- a/extern/libmv/third_party/gflags/gflags_completions.h
+++ b/extern/libmv/third_party/gflags/gflags/gflags_completions.h
@@ -28,7 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---
-// Author: Dave Nicponski
+
//
// Implement helpful bash-style command line flag completions
//
@@ -88,8 +88,8 @@
// file would be (your path to gflags_completions.sh file may differ):
/*
-$ complete -o bashdefault -o default -o nospace -C \
- '/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \
+$ complete -o bashdefault -o default -o nospace -C \
+ '/home/build/eng/bash/bash_completions.sh --tab_completion_columns $COLUMNS' \
time env binary_name another_binary [...]
*/
@@ -109,13 +109,22 @@ $ complete -o bashdefault -o default -o nospace -C \
// produce the expected completion output.
-#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_
-#define GOOGLE_GFLAGS_COMPLETIONS_H_
+#ifndef BASE_COMMANDLINEFLAGS_COMPLETIONS_H_
+#define BASE_COMMANDLINEFLAGS_COMPLETIONS_H_
+
+// Annoying stuff for windows -- makes sure clients can import these functions
+//
+// NOTE: all functions below MUST have an explicit 'extern' before
+// them. Our automated opensourcing tools use this as a signal to do
+// appropriate munging for windows, which needs to add GFLAGS_DLL_DECL.
+//
+#define GFLAGS_DLL_DECL /* rewritten to be non-empty in windows dir */
+
namespace google {
-void HandleCommandLineCompletions(void);
+extern void HandleCommandLineCompletions(void);
}
-#endif // GOOGLE_GFLAGS_COMPLETIONS_H_
+#endif // BASE_COMMANDLINEFLAGS_COMPLETIONS_H_
diff --git a/extern/libmv/third_party/gflags/gflags/gflags_declare.h b/extern/libmv/third_party/gflags/gflags/gflags_declare.h
new file mode 100644
index 00000000000..e3013826d53
--- /dev/null
+++ b/extern/libmv/third_party/gflags/gflags/gflags_declare.h
@@ -0,0 +1,112 @@
+// Copyright (c) 1999, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// ---
+//
+// Revamped and reorganized by Craig Silverstein
+//
+// This is the file that should be included by any file which declares
+// command line flag.
+
+#ifndef BASE_COMMANDLINEFLAGS_DECLARE_H_
+#define BASE_COMMANDLINEFLAGS_DECLARE_H_
+
+#include <string>
+#if 1
+#include <stdint.h> // the normal place uint16_t is defined
+#endif
+#if 1
+#include <sys/types.h> // the normal place u_int16_t is defined
+#endif
+#if 1
+#include <inttypes.h> // a third place for uint16_t or u_int16_t
+#endif
+
+namespace google {
+#if 1 // the C99 format
+typedef int32_t int32;
+typedef uint32_t uint32;
+typedef int64_t int64;
+typedef uint64_t uint64;
+#elif 1 // the BSD format
+typedef int32_t int32;
+typedef u_int32_t uint32;
+typedef int64_t int64;
+typedef u_int64_t uint64;
+#elif 0 // the windows (vc7) format
+typedef __int32 int32;
+typedef unsigned __int32 uint32;
+typedef __int64 int64;
+typedef unsigned __int64 uint64;
+#else
+#error Do not know how to define a 32-bit integer quantity on your system
+#endif
+}
+
+
+#define GFLAGS_DLL_DECLARE_FLAG /* rewritten to be non-empty in windows dir */
+
+namespace fLS {
+
+// The meaning of "string" might be different between now and when the
+// macros below get invoked (e.g., if someone is experimenting with
+// other string implementations that get defined after this file is
+// included). Save the current meaning now and use it in the macros.
+typedef std::string clstring;
+
+}
+
+#define DECLARE_VARIABLE(type, shorttype, name) \
+ /* We always want to import declared variables, dll or no */ \
+ namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
+ using fL##shorttype::FLAGS_##name
+
+#define DECLARE_bool(name) \
+ DECLARE_VARIABLE(bool, B, name)
+
+#define DECLARE_int32(name) \
+ DECLARE_VARIABLE(::google::int32, I, name)
+
+#define DECLARE_int64(name) \
+ DECLARE_VARIABLE(::google::int64, I64, name)
+
+#define DECLARE_uint64(name) \
+ DECLARE_VARIABLE(::google::uint64, U64, name)
+
+#define DECLARE_double(name) \
+ DECLARE_VARIABLE(double, D, name)
+
+#define DECLARE_string(name) \
+ namespace fLS { \
+ using ::fLS::clstring; \
+ extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
+ } \
+ using fLS::FLAGS_##name
+
+#endif // BASE_COMMANDLINEFLAGS_DECLARE_H_
diff --git a/extern/libmv/third_party/gflags/gflags_completions.cc b/extern/libmv/third_party/gflags/gflags_completions.cc
index a129611d8a1..75e9236ef63 100644
--- a/extern/libmv/third_party/gflags/gflags_completions.cc
+++ b/extern/libmv/third_party/gflags/gflags_completions.cc
@@ -28,8 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---
-// Author: Dave Nicponski
-//
+
// Bash-style command line flag completion for C++ binaries
//
// This module implements bash-style completions. It achieves this
@@ -58,7 +57,12 @@
#include <utility>
#include <vector>
-#include "gflags.h"
+#include "gflags/gflags.h"
+#include "util.h"
+
+using std::set;
+using std::string;
+using std::vector;
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
@@ -74,11 +78,6 @@ DEFINE_int32(tab_completion_columns, 80,
_START_GOOGLE_NAMESPACE_
namespace {
-
-using std::set;
-using std::string;
-using std::vector;
-
// Function prototypes and Type forward declarations. Code may be
// more easily understood if it is roughly ordered according to
// control flow, rather than by C's "declare before use" ordering
@@ -210,12 +209,12 @@ static void PrintFlagCompletionInfo(void) {
&canonical_token,
&options);
- //VLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
+ DVLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
vector<CommandLineFlagInfo> all_flags;
set<const CommandLineFlagInfo *> matching_flags;
GetAllFlags(&all_flags);
- //VLOG(2) << "Found " << all_flags.size() << " flags overall";
+ DVLOG(2) << "Found " << all_flags.size() << " flags overall";
string longest_common_prefix;
FindMatchingFlags(
@@ -224,28 +223,28 @@ static void PrintFlagCompletionInfo(void) {
canonical_token,
&matching_flags,
&longest_common_prefix);
- //VLOG(1) << "Identified " << matching_flags.size() << " matching flags";
- //VLOG(1) << "Identified " << longest_common_prefix
- // << " as longest common prefix.";
+ DVLOG(1) << "Identified " << matching_flags.size() << " matching flags";
+ DVLOG(1) << "Identified " << longest_common_prefix
+ << " as longest common prefix.";
if (longest_common_prefix.size() > canonical_token.size()) {
// There's actually a shared common prefix to all matching flags,
// so may as well output that and quit quickly.
- //VLOG(1) << "The common prefix '" << longest_common_prefix
- // << "' was longer than the token '" << canonical_token
- // << "'. Returning just this prefix for completion.";
+ DVLOG(1) << "The common prefix '" << longest_common_prefix
+ << "' was longer than the token '" << canonical_token
+ << "'. Returning just this prefix for completion.";
fprintf(stdout, "--%s", longest_common_prefix.c_str());
return;
}
if (matching_flags.empty()) {
- //VLOG(1) << "There were no matching flags, returning nothing.";
+ VLOG(1) << "There were no matching flags, returning nothing.";
return;
}
string module;
string package_dir;
TryFindModuleAndPackageDir(all_flags, &module, &package_dir);
- //VLOG(1) << "Identified module: '" << module << "'";
- //VLOG(1) << "Identified package_dir: '" << package_dir << "'";
+ DVLOG(1) << "Identified module: '" << module << "'";
+ DVLOG(1) << "Identified package_dir: '" << package_dir << "'";
NotableFlags notable_flags;
CategorizeAllMatchingFlags(
@@ -254,12 +253,12 @@ static void PrintFlagCompletionInfo(void) {
module,
package_dir,
&notable_flags);
- //VLOG(2) << "Categorized matching flags:";
- //VLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
- //VLOG(2) << " module: " << notable_flags.module_flags.size();
- //VLOG(2) << " package: " << notable_flags.package_flags.size();
- //VLOG(2) << " most common: " << notable_flags.most_common_flags.size();
- //VLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
+ DVLOG(2) << "Categorized matching flags:";
+ DVLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
+ DVLOG(2) << " module: " << notable_flags.module_flags.size();
+ DVLOG(2) << " package: " << notable_flags.package_flags.size();
+ DVLOG(2) << " most common: " << notable_flags.most_common_flags.size();
+ DVLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
vector<string> completions;
FinalizeCompletionOutput(
@@ -271,13 +270,13 @@ static void PrintFlagCompletionInfo(void) {
if (options.force_no_update)
completions.push_back("~");
- //VLOG(1) << "Finalized with " << completions.size()
- // << " chosen completions";
+ DVLOG(1) << "Finalized with " << completions.size()
+ << " chosen completions";
for (vector<string>::const_iterator it = completions.begin();
it != completions.end();
++it) {
- //VLOG(9) << " Completion entry: '" << *it << "'";
+ DVLOG(9) << " Completion entry: '" << *it << "'";
fprintf(stdout, "%s\n", it->c_str());
}
}
@@ -397,7 +396,7 @@ static bool DoesSingleFlagMatch(
flag.filename.find(match_token) != string::npos)
return true;
- // TODO(daven): All searches should probably be case-insensitive
+ // TODO(user): All searches should probably be case-insensitive
// (especially this one...)
if (options.flag_description_substring_search &&
flag.description.find(match_token) != string::npos)
@@ -426,8 +425,8 @@ static void CategorizeAllMatchingFlags(
all_matches.begin();
it != all_matches.end();
++it) {
- //VLOG(2) << "Examining match '" << (*it)->name << "'";
- //VLOG(7) << " filename: '" << (*it)->filename << "'";
+ DVLOG(2) << "Examining match '" << (*it)->name << "'";
+ DVLOG(7) << " filename: '" << (*it)->filename << "'";
string::size_type pos = string::npos;
if (!package_dir.empty())
pos = (*it)->filename.find(package_dir);
@@ -440,36 +439,34 @@ static void CategorizeAllMatchingFlags(
if ((*it)->name == search_token) {
// Exact match on some flag's name
notable_flags->perfect_match_flag.insert(*it);
- //VLOG(3) << "Result: perfect match";
+ DVLOG(3) << "Result: perfect match";
} else if (!module.empty() && (*it)->filename == module) {
// Exact match on module filename
notable_flags->module_flags.insert(*it);
- //VLOG(3) << "Result: module match";
+ DVLOG(3) << "Result: module match";
} else if (!package_dir.empty() &&
pos != string::npos && slash == string::npos) {
// In the package, since there was no slash after the package portion
notable_flags->package_flags.insert(*it);
- //VLOG(3) << "Result: package match";
+ DVLOG(3) << "Result: package match";
} else if (false) {
// In the list of the XXX most commonly supplied flags overall
- // TODO(daven): Compile this list.
- //VLOG(3) << "Result: most-common match";
+ // TODO(user): Compile this list.
+ DVLOG(3) << "Result: most-common match";
} else if (!package_dir.empty() &&
pos != string::npos && slash != string::npos) {
// In a subdirectory of the package
notable_flags->subpackage_flags.insert(*it);
- //VLOG(3) << "Result: subpackage match";
+ DVLOG(3) << "Result: subpackage match";
}
- //VLOG(3) << "Result: not special match";
+ DVLOG(3) << "Result: not special match";
}
}
static void PushNameWithSuffix(vector<string>* suffixes, const char* suffix) {
- string s("/");
- s += ProgramInvocationShortName();
- s += suffix;
- suffixes->push_back(s);
+ suffixes->push_back(
+ StringPrintf("/%s%s", ProgramInvocationShortName(), suffix));
}
static void TryFindModuleAndPackageDir(
@@ -480,7 +477,7 @@ static void TryFindModuleAndPackageDir(
package_dir->clear();
vector<string> suffixes;
- // TODO(daven): There's some inherant ambiguity here - multiple directories
+ // TODO(user): There's some inherant ambiguity here - multiple directories
// could share the same trailing folder and file structure (and even worse,
// same file names), causing us to be unsure as to which of the two is the
// actual package for this binary. In this case, we'll arbitrarily choose.
@@ -499,7 +496,7 @@ static void TryFindModuleAndPackageDir(
for (vector<string>::const_iterator suffix = suffixes.begin();
suffix != suffixes.end();
++suffix) {
- // TODO(daven): Make sure the match is near the end of the string
+ // TODO(user): Make sure the match is near the end of the string
if (it->filename.find(*suffix) != string::npos) {
*module = it->filename;
string::size_type sep = it->filename.rfind(PATH_SEPARATOR);
@@ -696,12 +693,14 @@ static void OutputSingleGroupWithLimit(
static string GetShortFlagLine(
const string &line_indentation,
const CommandLineFlagInfo &info) {
- string prefix =
- line_indentation + "--" + info.name + " [" +
- (info.type == "string" ?
- ("'" + info.default_value + "'") :
- info.default_value)
- + "] ";
+ string prefix;
+ bool is_string = (info.type == "string");
+ SStringPrintf(&prefix, "%s--%s [%s%s%s] ",
+ line_indentation.c_str(),
+ info.name.c_str(),
+ (is_string ? "'" : ""),
+ info.default_value.c_str(),
+ (is_string ? "'" : ""));
int remainder =
FLAGS_tab_completion_columns - static_cast<int>(prefix.size());
string suffix;
@@ -731,8 +730,12 @@ static string GetLongFlagLine(
static const char kNewlineWithIndent[] = "\n ";
output.replace(output.find(" type:"), 1, string(kNewlineWithIndent));
output.replace(output.find(" default:"), 1, string(kNewlineWithIndent));
- output = line_indentation + " Details for '--" + info.name + "':\n" +
- output + " defined: " + info.filename;
+ output = StringPrintf("%s Details for '--%s':\n"
+ "%s defined: %s",
+ line_indentation.c_str(),
+ info.name.c_str(),
+ output.c_str(),
+ info.filename.c_str());
// Eliminate any doubled newlines that crept in. Specifically, if
// DescribeOneFlag() decided to break the line just before "type"
@@ -759,7 +762,7 @@ static string GetLongFlagLine(
void HandleCommandLineCompletions(void) {
if (FLAGS_tab_completion_word.empty()) return;
PrintFlagCompletionInfo();
- exit(0);
+ gflags_exitfunc(0);
}
_END_GOOGLE_NAMESPACE_
diff --git a/extern/libmv/third_party/gflags/gflags_reporting.cc b/extern/libmv/third_party/gflags/gflags_reporting.cc
index fa3024d974e..c74bcc8d762 100644
--- a/extern/libmv/third_party/gflags/gflags_reporting.cc
+++ b/extern/libmv/third_party/gflags/gflags_reporting.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006, Google Inc.
+// Copyright (c) 1999, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ---
-// Author: Ray Sidney
+//
// Revamped and reorganized by Craig Silverstein
//
// This file contains code for handling the 'reporting' flags. These
@@ -40,7 +40,7 @@
// HandleCommandLineHelpFlags(). (Well, actually, ShowUsageWithFlags(),
// ShowUsageWithFlagsRestrict(), and DescribeOneFlag() can be called
// externally too, but there's little need for it.) These are all
-// declared in the main commandlineflags.h header file.
+// declared in the main gflags.h header file.
//
// HandleCommandLineHelpFlags() will check what 'reporting' flags have
// been defined, if any -- the "help" part of the function name is a
@@ -55,14 +55,15 @@
#include <assert.h>
#include <string>
#include <vector>
-#include "gflags.h"
-#include "gflags_completions.h"
+#include "gflags/gflags.h"
+#include "gflags/gflags_completions.h"
+#include "util.h"
#ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/'
#endif
-// The 'reporting' flags. They all call exit().
+// The 'reporting' flags. They all call gflags_exitfunc().
DEFINE_bool(help, false,
"show help on all flags [tip: all flags can have two dashes]");
DEFINE_bool(helpfull, false,
@@ -85,11 +86,12 @@ _START_GOOGLE_NAMESPACE_
using std::string;
using std::vector;
+
// --------------------------------------------------------------------
// DescribeOneFlag()
// DescribeOneFlagInXML()
// Routines that pretty-print info about a flag. These use
-// a CommandLineFlagInfo, which is the way the commandlineflags
+// a CommandLineFlagInfo, which is the way the gflags
// API exposes static info about a flag.
// --------------------------------------------------------------------
@@ -114,17 +116,19 @@ static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag,
const char* c_string = (current ? flag.current_value.c_str() :
flag.default_value.c_str());
if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings
- return text + ": \"" + c_string + "\"";
+ return StringPrintf("%s: \"%s\"", text.c_str(), c_string);
} else {
- return text + ": " + c_string;
+ return StringPrintf("%s: %s", text.c_str(), c_string);
}
}
// Create a descriptive string for a flag.
// Goes to some trouble to make pretty line breaks.
string DescribeOneFlag(const CommandLineFlagInfo& flag) {
- string main_part = (string(" -") + flag.name +
- " (" + flag.description + ')');
+ string main_part;
+ SStringPrintf(&main_part, " -%s (%s)",
+ flag.name.c_str(),
+ flag.description.c_str());
const char* c_string = main_part.c_str();
int chars_left = static_cast<int>(main_part.length());
string final_string = "";
@@ -164,7 +168,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
}
if (*c_string == '\0')
break;
- final_string += "\n ";
+ StringAppendF(&final_string, "\n ");
chars_in_line = 6;
}
@@ -173,7 +177,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
// The listed default value will be the actual default from the flag
// definition in the originating source file, unless the value has
// subsequently been modified using SetCommandLineOptionWithMode() with mode
- // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before initializing.
+ // SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before ParseCommandLineFlags().
AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string,
&chars_in_line);
if (!flag.is_default) {
@@ -181,7 +185,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
&final_string, &chars_in_line);
}
- final_string += '\n';
+ StringAppendF(&final_string, "\n");
return final_string;
}
@@ -196,15 +200,10 @@ static string XMLText(const string& txt) {
}
static void AddXMLTag(string* r, const char* tag, const string& txt) {
- *r += ('<');
- *r += (tag);
- *r += ('>');
- *r += (XMLText(txt));
- *r += ("</");
- *r += (tag);
- *r += ('>');
+ StringAppendF(r, "<%s>%s</%s>", tag, XMLText(txt).c_str(), tag);
}
+
static string DescribeOneFlagInXML(const CommandLineFlagInfo& flag) {
// The file and flagname could have been attributes, but default
// and meaning need to avoid attribute normalization. This way it
@@ -265,9 +264,9 @@ static bool FileMatchesSubstring(const string& filename,
// Show help for every filename which matches any of the target substrings.
// If substrings is empty, shows help for every file. If a flag's help message
-// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' before
-// including gflags/gflags.h), then this flag will not be displayed by
-// '--help' and its variants.
+// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1'
+// before including gflags/gflags.h), then this flag will not be displayed
+// by '--help' and its variants.
static void ShowUsageWithFlagsMatching(const char *argv0,
const vector<string> &substrings) {
fprintf(stdout, "%s: %s\n", Basename(argv0), ProgramUsage());
@@ -347,10 +346,13 @@ static void ShowXMLOfFlags(const char *prog_name) {
// --------------------------------------------------------------------
static void ShowVersion() {
- fprintf(stdout, "%s\n", ProgramInvocationShortName());
- // TODO: add other stuff, like a timestamp, who built it, what
- // target they built, etc.
-
+ const char* version_string = VersionString();
+ if (version_string && *version_string) {
+ fprintf(stdout, "%s version %s\n",
+ ProgramInvocationShortName(), version_string);
+ } else {
+ fprintf(stdout, "%s\n", ProgramInvocationShortName());
+ }
# if !defined(NDEBUG)
fprintf(stdout, "Debug build (NDEBUG not #defined)\n");
# endif
@@ -375,7 +377,6 @@ static void AppendPrognameStrings(vector<string>* substrings,
void HandleCommandLineHelpFlags() {
const char* progname = ProgramInvocationShortName();
- extern void (*commandlineflags_exitfunc)(int); // in gflags.cc
HandleCommandLineCompletions();
@@ -386,21 +387,21 @@ void HandleCommandLineHelpFlags() {
// show only flags related to this binary:
// E.g. for fileutil.cc, want flags containing ... "/fileutil." cc
ShowUsageWithFlagsMatching(progname, substrings);
- commandlineflags_exitfunc(1); // almost certainly exit()
+ gflags_exitfunc(1);
} else if (FLAGS_help || FLAGS_helpfull) {
// show all options
ShowUsageWithFlagsRestrict(progname, ""); // empty restrict
- commandlineflags_exitfunc(1);
+ gflags_exitfunc(1);
} else if (!FLAGS_helpon.empty()) {
string restrict = "/" + FLAGS_helpon + ".";
ShowUsageWithFlagsRestrict(progname, restrict.c_str());
- commandlineflags_exitfunc(1);
+ gflags_exitfunc(1);
} else if (!FLAGS_helpmatch.empty()) {
ShowUsageWithFlagsRestrict(progname, FLAGS_helpmatch.c_str());
- commandlineflags_exitfunc(1);
+ gflags_exitfunc(1);
} else if (FLAGS_helppackage) {
// Shows help for all files in the same directory as main(). We
@@ -419,27 +420,27 @@ void HandleCommandLineHelpFlags() {
const string package = Dirname(flag->filename) + "/";
if (package != last_package) {
ShowUsageWithFlagsRestrict(progname, package.c_str());
+ VLOG(7) << "Found package: " << package;
if (!last_package.empty()) { // means this isn't our first pkg
- fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n",
- progname);
+ LOG(WARNING) << "Multiple packages contain a file=" << progname;
}
last_package = package;
}
}
if (last_package.empty()) { // never found a package to print
- fprintf(stderr, "WARNING: Unable to find a package for file=%s\n",
- progname);
+ LOG(WARNING) << "Unable to find a package for file=" << progname;
}
- commandlineflags_exitfunc(1);
+ gflags_exitfunc(1);
} else if (FLAGS_helpxml) {
ShowXMLOfFlags(progname);
- commandlineflags_exitfunc(1);
+ gflags_exitfunc(1);
} else if (FLAGS_version) {
ShowVersion();
// Unlike help, we may be asking for version in a script, so return 0
- commandlineflags_exitfunc(0);
+ gflags_exitfunc(0);
+
}
}
diff --git a/extern/libmv/third_party/gflags/mutex.h b/extern/libmv/third_party/gflags/mutex.h
index 6e1e8976b6d..7c3c060a043 100644
--- a/extern/libmv/third_party/gflags/mutex.h
+++ b/extern/libmv/third_party/gflags/mutex.h
@@ -28,7 +28,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---
-// Author: Craig Silverstein.
//
// A simple mutex wrapper, supporting locks and read-write locks.
// You should assume the locks are *not* re-entrant.
@@ -117,7 +116,12 @@
#if defined(NO_THREADS)
typedef int MutexType; // to keep a lock-count
#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
-# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# endif
+# ifndef NOMINMAX
+# define NOMINMAX // Don't want windows to override min()/max()
+# endif
# ifdef GMUTEX_TRYLOCK
// We need Windows NT or later for TryEnterCriticalSection(). If you
// don't need that functionality, you can remove these _WIN32_WINNT
@@ -134,7 +138,10 @@
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
// for locking there.)
# ifdef __linux__
-# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
+# if _XOPEN_SOURCE < 500 // including not being defined at all
+# undef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
+# endif
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
diff --git a/extern/libmv/third_party/gflags/util.h b/extern/libmv/third_party/gflags/util.h
new file mode 100644
index 00000000000..8e2b1b89525
--- /dev/null
+++ b/extern/libmv/third_party/gflags/util.h
@@ -0,0 +1,339 @@
+// Copyright (c) 2011, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// ---
+//
+// Some generically useful utility routines that in google-land would
+// be their own projects. We make a shortened version here.
+
+#ifndef GFLAGS_UTIL_H_
+#define GFLAGS_UTIL_H_
+
+#include <assert.h>
+#include "config.h"
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#include <stdarg.h> // for va_*
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream>
+#include <string>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif // for mkdir()
+
+_START_GOOGLE_NAMESPACE_
+
+// This is used for unittests for death-testing. It is defined in gflags.cc.
+extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int);
+
+// Work properly if either strtoll or strtoq is on this system
+#ifdef HAVE_STRTOLL
+# define strto64 strtoll
+# define strtou64 strtoull
+#elif HAVE_STRTOQ
+# define strto64 strtoq
+# define strtou64 strtouq
+#else
+// Neither strtoll nor strtoq are defined. I hope strtol works!
+# define strto64 strtol
+# define strtou64 strtoul
+#endif
+
+// If we have inttypes.h, it will have defined PRId32/etc for us. If
+// not, take our best guess.
+#ifndef PRId32
+# define PRId32 "d"
+#endif
+#ifndef PRId64
+# define PRId64 "lld"
+#endif
+#ifndef PRIu64
+# define PRIu64 "llu"
+#endif
+
+typedef signed char int8;
+typedef unsigned char uint8;
+
+// -- utility macros ---------------------------------------------------------
+
+template <bool> struct CompileAssert {};
+#define COMPILE_ASSERT(expr, msg) \
+ typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+
+// Returns the number of elements in an array.
+#define arraysize(arr) (sizeof(arr)/sizeof(*(arr)))
+
+
+// -- logging and testing ---------------------------------------------------
+
+// For now, we ignore the level for logging, and don't show *VLOG's at
+// all, except by hand-editing the lines below
+#define LOG(level) std::cerr
+#define VLOG(level) if (true) {} else std::cerr
+#define DVLOG(level) if (true) {} else std::cerr
+
+// CHECK dies with a fatal error if condition is not true. It is *not*
+// controlled by NDEBUG, so the check will be executed regardless of
+// compilation mode. Therefore, it is safe to do things like:
+// CHECK(fp->Write(x) == 4)
+// We allow stream-like objects after this for debugging, but they're ignored.
+#define EXPECT_TRUE(condition) \
+ if (true) { \
+ if (!(condition)) { \
+ fprintf(stderr, "Check failed: %s\n", #condition); \
+ exit(1); \
+ } \
+ } else std::cerr << ""
+
+#define EXPECT_OP(op, val1, val2) \
+ if (true) { \
+ if (!((val1) op (val2))) { \
+ fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \
+ exit(1); \
+ } \
+ } else std::cerr << ""
+
+#define EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2)
+#define EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2)
+#define EXPECT_LE(val1, val2) EXPECT_OP(<=, val1, val2)
+#define EXPECT_LT(val1, val2) EXPECT_OP(< , val1, val2)
+#define EXPECT_GE(val1, val2) EXPECT_OP(>=, val1, val2)
+#define EXPECT_GT(val1, val2) EXPECT_OP(> , val1, val2)
+#define EXPECT_FALSE(cond) EXPECT_TRUE(!(cond))
+
+// C99 declares isnan and isinf should be macros, so the #ifdef test
+// should be reliable everywhere. Of course, it's not, but these
+// are testing pertty marginal functionality anyway, so it's ok to
+// not-run them even in situations they might, with effort, be made to work.
+#ifdef isnan // Some compilers, like sun's for Solaris 10, don't define this
+#define EXPECT_NAN(arg) \
+ do { \
+ if (!isnan(arg)) { \
+ fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \
+ exit(1); \
+ } \
+ } while (0)
+#else
+#define EXPECT_NAN(arg)
+#endif
+
+#ifdef isinf // Some compilers, like sun's for Solaris 10, don't define this
+#define EXPECT_INF(arg) \
+ do { \
+ if (!isinf(arg)) { \
+ fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \
+ exit(1); \
+ } \
+ } while (0)
+#else
+#define EXPECT_INF(arg)
+#endif
+
+#define EXPECT_DOUBLE_EQ(val1, val2) \
+ do { \
+ if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \
+ fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \
+ exit(1); \
+ } \
+ } while (0)
+
+#define EXPECT_STREQ(val1, val2) \
+ do { \
+ if (strcmp((val1), (val2)) != 0) { \
+ fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \
+ exit(1); \
+ } \
+ } while (0)
+
+// Call this in a .cc file where you will later call RUN_ALL_TESTS in main().
+#define TEST_INIT \
+ static std::vector<void (*)()> g_testlist; /* the tests to run */ \
+ static int RUN_ALL_TESTS() { \
+ std::vector<void (*)()>::const_iterator it; \
+ for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { \
+ (*it)(); /* The test will error-exit if there's a problem. */ \
+ } \
+ fprintf(stderr, "\nPassed %d tests\n\nPASS\n", \
+ static_cast<int>(g_testlist.size())); \
+ return 0; \
+ }
+
+// Note that this macro uses a FlagSaver to keep tests isolated.
+#define TEST(a, b) \
+ struct Test_##a##_##b { \
+ Test_##a##_##b() { g_testlist.push_back(&Run); } \
+ static void Run() { \
+ FlagSaver fs; \
+ fprintf(stderr, "Running test %s/%s\n", #a, #b); \
+ RunTest(); \
+ } \
+ static void RunTest(); \
+ }; \
+ static Test_##a##_##b g_test_##a##_##b; \
+ void Test_##a##_##b::RunTest()
+
+// This is a dummy class that eases the google->opensource transition.
+namespace testing {
+class Test {};
+}
+
+// Call this in a .cc file where you will later call EXPECT_DEATH
+#define EXPECT_DEATH_INIT \
+ static bool g_called_exit; \
+ static void CalledExit(int) { g_called_exit = true; }
+
+#define EXPECT_DEATH(fn, msg) \
+ do { \
+ g_called_exit = false; \
+ gflags_exitfunc = &CalledExit; \
+ fn; \
+ gflags_exitfunc = &exit; /* set back to its default */ \
+ if (!g_called_exit) { \
+ fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \
+ exit(1); \
+ } \
+ } while (0)
+
+#define GTEST_HAS_DEATH_TEST 1
+
+// -- path routines ----------------------------------------------------------
+
+// Tries to create the directory path as a temp-dir. If it fails,
+// changes path to some directory it *can* create.
+#if defined(__MINGW32__)
+#include <io.h>
+inline void MakeTmpdir(std::string* path) {
+ // I had trouble creating a directory in /tmp from mingw
+ *path = "./gflags_unittest_testdir";
+ mkdir(path->c_str()); // mingw has a weird one-arg mkdir
+}
+#elif defined(_MSC_VER)
+#include <direct.h>
+#include <windows.h>
+inline void MakeTmpdir(std::string* path) {
+ char tmppath_buffer[1024];
+ int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
+ assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer));
+ assert(tmppath_buffer[tmppath_len - 1] == '\\'); // API guarantees it
+ *path = std::string(tmppath_buffer) + "gflags_unittest_testdir";
+ _mkdir(path->c_str());
+}
+// Windows is missing random bits like strcasecmp, strtoll, strtoull, and
+// snprintf in the usual locations. Put them somewhere sensible.
+//
+// TODO(keir): Get the upstream Windows port and use that instead.
+#define snprintf _snprintf
+#undef strtoint64
+#define strtoint64 _strtoi64
+#undef strtouint64
+#define strtouint64 _strtoui64
+#define strcasecmp _stricmp
+#define va_copy(dst, src) ((dst) = (src))
+#define strto64 _strtoi64
+#define strtou64 _strtoui64
+#else
+inline void MakeTmpdir(std::string* path) {
+ mkdir(path->c_str(), 0755);
+}
+#endif
+
+// -- string routines --------------------------------------------------------
+
+inline void InternalStringPrintf(std::string* output, const char* format,
+ va_list ap) {
+ char space[128]; // try a small buffer and hope it fits
+
+ // It's possible for methods that use a va_list to invalidate
+ // the data in it upon use. The fix is to make a copy
+ // of the structure before using it and use that copy instead.
+ va_list backup_ap;
+ va_copy(backup_ap, ap);
+ int bytes_written = vsnprintf(space, sizeof(space), format, backup_ap);
+ va_end(backup_ap);
+
+ if ((bytes_written >= 0) && (bytes_written < sizeof(space))) {
+ output->append(space, bytes_written);
+ return;
+ }
+
+ // Repeatedly increase buffer size until it fits.
+ int length = sizeof(space);
+ while (true) {
+ if (bytes_written < 0) {
+ // Older snprintf() behavior. :-( Just try doubling the buffer size
+ length *= 2;
+ } else {
+ // We need exactly "bytes_written+1" characters
+ length = bytes_written+1;
+ }
+ char* buf = new char[length];
+
+ // Restore the va_list before we use it again
+ va_copy(backup_ap, ap);
+ bytes_written = vsnprintf(buf, length, format, backup_ap);
+ va_end(backup_ap);
+
+ if ((bytes_written >= 0) && (bytes_written < length)) {
+ output->append(buf, bytes_written);
+ delete[] buf;
+ return;
+ }
+ delete[] buf;
+ }
+}
+
+// Clears output before writing to it.
+inline void SStringPrintf(std::string* output, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ output->clear();
+ InternalStringPrintf(output, format, ap);
+ va_end(ap);
+}
+
+inline void StringAppendF(std::string* output, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ InternalStringPrintf(output, format, ap);
+ va_end(ap);
+}
+
+inline std::string StringPrintf(const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ std::string output;
+ InternalStringPrintf(&output, format, ap);
+ va_end(ap);
+ return output;
+}
+
+_END_GOOGLE_NAMESPACE_
+
+#endif // GFLAGS_UTIL_H_
diff --git a/extern/libmv/third_party/glog/ChangeLog b/extern/libmv/third_party/glog/ChangeLog
index 350fee921e3..6ac0b0f0575 100644
--- a/extern/libmv/third_party/glog/ChangeLog
+++ b/extern/libmv/third_party/glog/ChangeLog
@@ -1,3 +1,13 @@
+2012-01-12 Google Inc. <opensource@google.com>
+
+ * google-glog: version 0.3.2
+ * Clang support.
+ * Demangler and stacktrace improvement for newer GCCs.
+ * Now fork(2) doesn't mess up log files.
+ * Make valgrind happier.
+ * Reduce warnings for more -W options.
+ * Provide a workaround for ERROR defined by windows.h.
+
2010-06-15 Google Inc. <opensource@google.com>
* google-glog: version 0.3.1
diff --git a/extern/libmv/third_party/glog/README.libmv b/extern/libmv/third_party/glog/README.libmv
index 8f1243b2430..025a70b76a5 100644
--- a/extern/libmv/third_party/glog/README.libmv
+++ b/extern/libmv/third_party/glog/README.libmv
@@ -1,38 +1,24 @@
Project: Google Logging
URL: http://code.google.com/p/google-glog/
License: New BSD
-Upstream version: 0.3.1
+Upstream version: 0.3.2
Local modifications:
Upgrading Notes
-* Had to change #include <gflags/gflags.h> to #include "gflags/gflags.h"
-* Make sure to copy over a config_YOUR_PLATFORM.h and put it in config.h
-
-Old changes which got obsoleted (maybe?) by 0.3.1 merge:
-* The config_linux.h is generated by configure on Keir's Ubuntu 9.04 desktop.
-* Commented out some struct ::tm weirdness causing compile failures on
- ubuntu 8.10 and 9.04.
-* Switched several initializers to memset instead of = {}.
-* Changed some includes pointing to gflags. Not sure why the regular inclusion
- didn't work.
-* Added some compile flags to silence various warnings, allowing us to keep the
- differences between upstream small.
-* Don't redefine _XOPEN_SOURCE.
-* Added "google::" to GetReferenceableValue in CHECK_OP_LOG.
-* Add virtual destructor to Thread in googletest.h.
-* Update windows/glog/log_severity to build with QT library that include WinGDI
- (It cause a double definition of ERROR variable).
-
-Old changes which got obsoleted (maybe?) by 0.2.1 merge:
-* Added #ifndef / def REG_EIP; not sure what that is.
-* Added (void) arg stuff to prevent unused variable warnings.
-* Added google:: namespace prefix to GetReferencableValue
-* Added assignments for several functions marked with no_ignore_return, where
- the return value was ignored.
-* Commented out the unused function DumpPCAndSymbol() in utilities.cc to silent
- gcc on the mac
-
-TODO(keir): Remove any obsoleted changes above if they are not necessary after
-testing on more platforms.
-
-WARNING: Mac port not updated for 0.2.1
+* Replace <gflags/gflags.h> with "third_party/gflags/gflags/gflags.h" which is easier
+ to setup things in libmv and also helps with setting up building libmv into
+ external applications.
+* Replace "glog/logging.h" and "glog/logging.h" with <glog/logging.h> and <glog/logging.h>
+ which is needed on Windows platform because otherwise files like logging.cc will be using
+ relative path which points to headers used by linux instead of headers need to be used
+ on Windows.
+* Replace _asm int 3 with __debugbreak(). Such assembler code is obsolete and doesn't work
+ with 64bit versions of MSVC compilers.
+* Do not use stacktrace for MinGW and FreeBSD because it leads into issues accessing
+ some specific data on this platforms.
+* Define HAVE_LIB_GFLAGS for Windows builds.
+* Do not define __declspec(dllimport) for MinGW platforms.
+* Setup proper includes and datatypes for int32, uint32, int64 and uint64 for MinGW
+* Do not define va_copy for MinGW platforms (it's already defined there).
+* Patch localtime_r to be working fine with MinGW, disable strerror_r for MinGW because
+ of lack of needed functions.
diff --git a/extern/libmv/third_party/glog/src/base/commandlineflags.h b/extern/libmv/third_party/glog/src/base/commandlineflags.h
index 6c529ccd847..483a96ee80b 100644
--- a/extern/libmv/third_party/glog/src/base/commandlineflags.h
+++ b/extern/libmv/third_party/glog/src/base/commandlineflags.h
@@ -55,11 +55,11 @@
#ifdef HAVE_LIB_GFLAGS
-#include "third_party/gflags/gflags.h"
+#include "third_party/gflags/gflags/gflags.h"
#else
-#include "glog/logging.h"
+#include <glog/logging.h>
#define DECLARE_VARIABLE(type, name, tn) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##tn##_instead { \
diff --git a/extern/libmv/third_party/glog/src/base/googleinit.h b/extern/libmv/third_party/glog/src/base/googleinit.h
index c907308e852..5a8b515cd60 100644
--- a/extern/libmv/third_party/glog/src/base/googleinit.h
+++ b/extern/libmv/third_party/glog/src/base/googleinit.h
@@ -36,7 +36,7 @@
class GoogleInitializer {
public:
typedef void (*void_function)(void);
- GoogleInitializer(const char* name, void_function f) {
+ GoogleInitializer(const char*, void_function f) {
f();
}
};
diff --git a/extern/libmv/third_party/glog/src/config_freebsd.h b/extern/libmv/third_party/glog/src/config_freebsd.h
index 28fa1f1c78b..a671a0080b3 100644
--- a/extern/libmv/third_party/glog/src/config_freebsd.h
+++ b/extern/libmv/third_party/glog/src/config_freebsd.h
@@ -122,13 +122,13 @@
#define PACKAGE_NAME "glog"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "glog 0.3.1"
+#define PACKAGE_STRING "glog 0.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "glog"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.3.1"
+#define PACKAGE_VERSION "0.3.2"
/* How to access the PC from a struct ucontext */
/* #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP] */
@@ -151,7 +151,7 @@
#define TEST_SRC_DIR "."
/* Version number of package */
-#define VERSION "0.3.1"
+#define VERSION "0.3.2"
/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_ }
@@ -159,3 +159,8 @@
/* Puts following code inside the Google namespace */
#define _START_GOOGLE_NAMESPACE_ namespace google {
+/* isn't getting defined by configure script when clang compilers are used
+ and cuases compilation errors in stactrace/unwind modules */
+#ifdef __clang__
+# define NO_FRAME_POINTER
+#endif
diff --git a/extern/libmv/third_party/glog/src/config_linux.h b/extern/libmv/third_party/glog/src/config_linux.h
index faf032949bb..19beaa5cf40 100644
--- a/extern/libmv/third_party/glog/src/config_linux.h
+++ b/extern/libmv/third_party/glog/src/config_linux.h
@@ -110,7 +110,11 @@
#define HAVE___BUILTIN_EXPECT 1
/* define if your compiler has __sync_val_compare_and_swap */
-/* #undef HAVE___SYNC_VAL_COMPARE_AND_SWAP */
+#define HAVE___SYNC_VAL_COMPARE_AND_SWAP 1
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "glog"
@@ -122,22 +126,19 @@
#define PACKAGE_NAME "glog"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "glog 0.3.1"
+#define PACKAGE_STRING "glog 0.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "glog"
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.3.1"
+#define PACKAGE_VERSION "0.3.2"
/* How to access the PC from a struct ucontext */
-#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
- #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP]
-#elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
- #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_EIP]
-#else
- #undef PC_FROM_UCONTEXT
-#endif
+#define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP]
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@@ -149,7 +150,6 @@
/* Define to 1 if you have the ANSI C header files. */
/* #undef STDC_HEADERS */
-#define STDC_HEADERS 1
/* the namespace where STL code like vector<> is defined */
#define STL_NAMESPACE std
@@ -157,10 +157,16 @@
#define TEST_SRC_DIR "."
/* Version number of package */
-#define VERSION "0.3.1"
+#define VERSION "0.3.2"
/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_ }
/* Puts following code inside the Google namespace */
#define _START_GOOGLE_NAMESPACE_ namespace google {
+
+/* isn't getting defined by configure script when clang compilers are used
+ and cuases compilation errors in stactrace/unwind modules */
+#ifdef __clang__
+# define NO_FRAME_POINTER
+#endif
diff --git a/extern/libmv/third_party/glog/src/config_mac.h b/extern/libmv/third_party/glog/src/config_mac.h
index 5f953d17ba9..9756fde22f3 100644
--- a/extern/libmv/third_party/glog/src/config_mac.h
+++ b/extern/libmv/third_party/glog/src/config_mac.h
@@ -122,13 +122,13 @@
#define PACKAGE_NAME "glog"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "glog 0.3.1"
+#define PACKAGE_STRING "glog 0.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "glog"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.3.1"
+#define PACKAGE_VERSION "0.3.2"
/* How to access the PC from a struct ucontext */
#undef PC_FROM_UCONTEXT
@@ -150,10 +150,16 @@
#define TEST_SRC_DIR "."
/* Version number of package */
-#define VERSION "0.3.1"
+#define VERSION "0.3.2"
/* Stops putting the code inside the Google namespace */
#define _END_GOOGLE_NAMESPACE_ }
/* Puts following code inside the Google namespace */
#define _START_GOOGLE_NAMESPACE_ namespace google {
+
+/* isn't getting defined by configure script when clang compilers are used
+ and cuases compilation errors in stactrace/unwind modules */
+#ifdef __clang__
+# define NO_FRAME_POINTER
+#endif
diff --git a/extern/libmv/third_party/glog/src/demangle.cc b/extern/libmv/third_party/glog/src/demangle.cc
index 46556bf3c13..0daf30893b3 100644
--- a/extern/libmv/third_party/glog/src/demangle.cc
+++ b/extern/libmv/third_party/glog/src/demangle.cc
@@ -28,6 +28,11 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Satoru Takabayashi
+//
+// For reference check out:
+// http://www.codesourcery.com/public/cxx-abi/abi.html#mangling
+//
+// Note that we only have partial C++0x support yet.
#include <stdio.h> // for NULL
#include "demangle.h"
@@ -138,14 +143,12 @@ static const AbbrevPair kSubstitutionList[] = {
// State needed for demangling.
typedef struct {
const char *mangled_cur; // Cursor of mangled name.
- const char *mangled_end; // End of mangled name.
char *out_cur; // Cursor of output string.
const char *out_begin; // Beginning of output string.
const char *out_end; // End of output string.
const char *prev_name; // For constructors/destructors.
int prev_name_length; // For constructors/destructors.
- int nest_level; // For nested names.
- int number; // Remember the previous number.
+ short nest_level; // For nested names.
bool append; // Append flag.
bool overflowed; // True if output gets overflowed.
} State;
@@ -161,6 +164,16 @@ static size_t StrLen(const char *str) {
return len;
}
+// Returns true if "str" has at least "n" characters remaining.
+static bool AtLeastNumCharsRemaining(const char *str, int n) {
+ for (int i = 0; i < n; ++i) {
+ if (str == '\0') {
+ return false;
+ }
+ }
+ return true;
+}
+
// Returns true if "str" has "prefix" as a prefix.
static bool StrPrefix(const char *str, const char *prefix) {
size_t i = 0;
@@ -174,39 +187,33 @@ static bool StrPrefix(const char *str, const char *prefix) {
static void InitState(State *state, const char *mangled,
char *out, int out_size) {
state->mangled_cur = mangled;
- state->mangled_end = mangled + StrLen(mangled);
state->out_cur = out;
state->out_begin = out;
state->out_end = out + out_size;
state->prev_name = NULL;
state->prev_name_length = -1;
state->nest_level = -1;
- state->number = -1;
state->append = true;
state->overflowed = false;
}
-// Calculates the remaining length of the mangled name.
-static int RemainingLength(State *state) {
- return state->mangled_end - state->mangled_cur;
-}
-
-// Returns true and advances "mangled_cur" if we find "c" at
-// "mangled_cur" position.
-static bool ParseChar(State *state, const char c) {
- if (RemainingLength(state) >= 1 && *state->mangled_cur == c) {
+// Returns true and advances "mangled_cur" if we find "one_char_token"
+// at "mangled_cur" position. It is assumed that "one_char_token" does
+// not contain '\0'.
+static bool ParseOneCharToken(State *state, const char one_char_token) {
+ if (state->mangled_cur[0] == one_char_token) {
++state->mangled_cur;
return true;
}
return false;
}
-// Returns true and advances "mangled_cur" if we find "two_chars" at
-// "mangled_cur" position.
-static bool ParseTwoChar(State *state, const char *two_chars) {
- if (RemainingLength(state) >= 2 &&
- state->mangled_cur[0] == two_chars[0] &&
- state->mangled_cur[1] == two_chars[1]) {
+// Returns true and advances "mangled_cur" if we find "two_char_token"
+// at "mangled_cur" position. It is assumed that "two_char_token" does
+// not contain '\0'.
+static bool ParseTwoCharToken(State *state, const char *two_char_token) {
+ if (state->mangled_cur[0] == two_char_token[0] &&
+ state->mangled_cur[1] == two_char_token[1]) {
state->mangled_cur += 2;
return true;
}
@@ -216,13 +223,13 @@ static bool ParseTwoChar(State *state, const char *two_chars) {
// Returns true and advances "mangled_cur" if we find any character in
// "char_class" at "mangled_cur" position.
static bool ParseCharClass(State *state, const char *char_class) {
- if (state->mangled_cur == state->mangled_end) {
+ if (state->mangled_cur == '\0') {
return false;
}
const char *p = char_class;
for (; *p != '\0'; ++p) {
- if (*state->mangled_cur == *p) {
- state->mangled_cur += 1;
+ if (state->mangled_cur[0] == *p) {
+ ++state->mangled_cur;
return true;
}
}
@@ -230,7 +237,7 @@ static bool ParseCharClass(State *state, const char *char_class) {
}
// This function is used for handling an optional non-terminal.
-static bool Optional(bool status) {
+static bool Optional(bool) {
return true;
}
@@ -245,6 +252,16 @@ static bool OneOrMore(ParseFunc parse_func, State *state) {
return false;
}
+// This function is used for handling <non-terminal>* syntax. The function
+// always returns true and must be followed by a termination token or a
+// terminating sequence not handled by parse_func (e.g.
+// ParseOneCharToken(state, 'E')).
+static bool ZeroOrMore(ParseFunc parse_func, State *state) {
+ while (parse_func(state)) {
+ }
+ return true;
+}
+
// Append "str" at "out_cur". If there is an overflow, "overflowed"
// is set to true for later use. The output string is ensured to
// always terminate with '\0' as long as there is no overflow.
@@ -270,7 +287,37 @@ static bool IsLower(char c) {
}
static bool IsAlpha(char c) {
- return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+}
+
+static bool IsDigit(char c) {
+ return c >= '0' && c <= '9';
+}
+
+// Returns true if "str" is a function clone suffix. These suffixes are used
+// by GCC 4.5.x and later versions to indicate functions which have been
+// cloned during optimization. We treat any sequence (.<alpha>+.<digit>+)+ as
+// a function clone suffix.
+static bool IsFunctionCloneSuffix(const char *str) {
+ size_t i = 0;
+ while (str[i] != '\0') {
+ // Consume a single .<alpha>+.<digit>+ sequence.
+ if (str[i] != '.' || !IsAlpha(str[i + 1])) {
+ return false;
+ }
+ i += 2;
+ while (IsAlpha(str[i])) {
+ ++i;
+ }
+ if (str[i] != '.' || !IsDigit(str[i + 1])) {
+ return false;
+ }
+ i += 2;
+ while (IsDigit(str[i])) {
+ ++i;
+ }
+ }
+ return true; // Consumed everything in "str".
}
// Append "str" with some tweaks, iff "append" state is true.
@@ -309,7 +356,7 @@ static bool EnterNestedName(State *state) {
}
// This function is used for handling nested names.
-static bool LeaveNestedName(State *state, int prev_value) {
+static bool LeaveNestedName(State *state, short prev_value) {
state->nest_level = prev_value;
return true;
}
@@ -349,11 +396,11 @@ static void MaybeCancelLastSeparator(State *state) {
}
}
-// Returns true if identifier pointed by "mangled_cur" is anonymous
-// namespace.
-static bool IdentifierIsAnonymousNamespace(State *state) {
- const char anon_prefix[] = "_GLOBAL__N_";
- return (state->number > sizeof(anon_prefix) - 1 && // Should be longer.
+// Returns true if the identifier of the given length pointed to by
+// "mangled_cur" is anonymous namespace.
+static bool IdentifierIsAnonymousNamespace(State *state, int length) {
+ static const char anon_prefix[] = "_GLOBAL__N_";
+ return (length > (int)sizeof(anon_prefix) - 1 && // Should be longer.
StrPrefix(state->mangled_cur, anon_prefix));
}
@@ -368,10 +415,10 @@ static bool ParsePrefix(State *state);
static bool ParseUnqualifiedName(State *state);
static bool ParseSourceName(State *state);
static bool ParseLocalSourceName(State *state);
-static bool ParseNumber(State *state);
+static bool ParseNumber(State *state, int *number_out);
static bool ParseFloatNumber(State *state);
static bool ParseSeqId(State *state);
-static bool ParseIdentifier(State *state);
+static bool ParseIdentifier(State *state, int length);
static bool ParseOperatorName(State *state);
static bool ParseSpecialName(State *state);
static bool ParseCallOffset(State *state);
@@ -428,17 +475,7 @@ static bool ParseSubstitution(State *state);
// <mangled-name> ::= _Z <encoding>
static bool ParseMangledName(State *state) {
- if (ParseTwoChar(state, "_Z") && ParseEncoding(state)) {
- // Append trailing version suffix if any.
- // ex. _Z3foo@@GLIBCXX_3.4
- if (state->mangled_cur < state->mangled_end &&
- state->mangled_cur[0] == '@') {
- MaybeAppend(state, state->mangled_cur);
- state->mangled_cur = state->mangled_end;
- }
- return true;
- }
- return false;
+ return ParseTwoCharToken(state, "_Z") && ParseEncoding(state);
}
// <encoding> ::= <(function) name> <bare-function-type>
@@ -488,7 +525,7 @@ static bool ParseUnscopedName(State *state) {
}
State copy = *state;
- if (ParseTwoChar(state, "St") &&
+ if (ParseTwoCharToken(state, "St") &&
MaybeAppend(state, "std::") &&
ParseUnqualifiedName(state)) {
return true;
@@ -507,12 +544,12 @@ static bool ParseUnscopedTemplateName(State *state) {
// ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
static bool ParseNestedName(State *state) {
State copy = *state;
- if (ParseChar(state, 'N') &&
+ if (ParseOneCharToken(state, 'N') &&
EnterNestedName(state) &&
Optional(ParseCVQualifiers(state)) &&
ParsePrefix(state) &&
LeaveNestedName(state, copy.nest_level) &&
- ParseChar(state, 'E')) {
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
@@ -565,7 +602,8 @@ static bool ParseUnqualifiedName(State *state) {
// <source-name> ::= <positive length number> <identifier>
static bool ParseSourceName(State *state) {
State copy = *state;
- if (ParseNumber(state) && ParseIdentifier(state)) {
+ int length = -1;
+ if (ParseNumber(state, &length) && ParseIdentifier(state, length)) {
return true;
}
*state = copy;
@@ -579,7 +617,7 @@ static bool ParseSourceName(State *state) {
// http://gcc.gnu.org/viewcvs?view=rev&revision=124467
static bool ParseLocalSourceName(State *state) {
State copy = *state;
- if (ParseChar(state, 'L') && ParseSourceName(state) &&
+ if (ParseOneCharToken(state, 'L') && ParseSourceName(state) &&
Optional(ParseDiscriminator(state))) {
return true;
}
@@ -588,15 +626,17 @@ static bool ParseLocalSourceName(State *state) {
}
// <number> ::= [n] <non-negative decimal integer>
-static bool ParseNumber(State *state) {
+// If "number_out" is non-null, then *number_out is set to the value of the
+// parsed number on success.
+static bool ParseNumber(State *state, int *number_out) {
int sign = 1;
- if (ParseChar(state, 'n')) {
+ if (ParseOneCharToken(state, 'n')) {
sign = -1;
}
const char *p = state->mangled_cur;
int number = 0;
- for (;p < state->mangled_end; ++p) {
- if ((*p >= '0' && *p <= '9')) {
+ for (;*p != '\0'; ++p) {
+ if (IsDigit(*p)) {
number = number * 10 + (*p - '0');
} else {
break;
@@ -604,7 +644,9 @@ static bool ParseNumber(State *state) {
}
if (p != state->mangled_cur) { // Conversion succeeded.
state->mangled_cur = p;
- state->number = number * sign;
+ if (number_out != NULL) {
+ *number_out = number * sign;
+ }
return true;
}
return false;
@@ -614,19 +656,13 @@ static bool ParseNumber(State *state) {
// hexadecimal string.
static bool ParseFloatNumber(State *state) {
const char *p = state->mangled_cur;
- int number = 0;
- for (;p < state->mangled_end; ++p) {
- if ((*p >= '0' && *p <= '9')) {
- number = number * 16 + (*p - '0');
- } else if (*p >= 'a' && *p <= 'f') {
- number = number * 16 + (*p - 'a' + 10);
- } else {
+ for (;*p != '\0'; ++p) {
+ if (!IsDigit(*p) && !(*p >= 'a' && *p <= 'f')) {
break;
}
}
if (p != state->mangled_cur) { // Conversion succeeded.
state->mangled_cur = p;
- state->number = number;
return true;
}
return false;
@@ -636,37 +672,30 @@ static bool ParseFloatNumber(State *state) {
// using digits and upper case letters
static bool ParseSeqId(State *state) {
const char *p = state->mangled_cur;
- int number = 0;
- for (;p < state->mangled_end; ++p) {
- if ((*p >= '0' && *p <= '9')) {
- number = number * 36 + (*p - '0');
- } else if (*p >= 'A' && *p <= 'Z') {
- number = number * 36 + (*p - 'A' + 10);
- } else {
+ for (;*p != '\0'; ++p) {
+ if (!IsDigit(*p) && !(*p >= 'A' && *p <= 'Z')) {
break;
}
}
if (p != state->mangled_cur) { // Conversion succeeded.
state->mangled_cur = p;
- state->number = number;
return true;
}
return false;
}
-// <identifier> ::= <unqualified source code identifier>
-static bool ParseIdentifier(State *state) {
- if (state->number == -1 ||
- RemainingLength(state) < state->number) {
+// <identifier> ::= <unqualified source code identifier> (of given length)
+static bool ParseIdentifier(State *state, int length) {
+ if (length == -1 ||
+ !AtLeastNumCharsRemaining(state->mangled_cur, length)) {
return false;
}
- if (IdentifierIsAnonymousNamespace(state)) {
+ if (IdentifierIsAnonymousNamespace(state, length)) {
MaybeAppend(state, "(anonymous namespace)");
} else {
- MaybeAppendWithLength(state, state->mangled_cur, state->number);
+ MaybeAppendWithLength(state, state->mangled_cur, length);
}
- state->mangled_cur += state->number;
- state->number = -1; // Reset the number.
+ state->mangled_cur += length;
return true;
}
@@ -674,12 +703,12 @@ static bool ParseIdentifier(State *state) {
// ::= cv <type> # (cast)
// ::= v <digit> <source-name> # vendor extended operator
static bool ParseOperatorName(State *state) {
- if (RemainingLength(state) < 2) {
+ if (!AtLeastNumCharsRemaining(state->mangled_cur, 2)) {
return false;
}
// First check with "cv" (cast) case.
State copy = *state;
- if (ParseTwoChar(state, "cv") &&
+ if (ParseTwoCharToken(state, "cv") &&
MaybeAppend(state, "operator ") &&
EnterNestedName(state) &&
ParseType(state) &&
@@ -689,7 +718,7 @@ static bool ParseOperatorName(State *state) {
*state = copy;
// Then vendor extended operators.
- if (ParseChar(state, 'v') && ParseCharClass(state, "0123456789") &&
+ if (ParseOneCharToken(state, 'v') && ParseCharClass(state, "0123456789") &&
ParseSourceName(state)) {
return true;
}
@@ -738,34 +767,34 @@ static bool ParseOperatorName(State *state) {
// stack traces. The are special data.
static bool ParseSpecialName(State *state) {
State copy = *state;
- if (ParseChar(state, 'T') &&
+ if (ParseOneCharToken(state, 'T') &&
ParseCharClass(state, "VTIS") &&
ParseType(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "Tc") && ParseCallOffset(state) &&
+ if (ParseTwoCharToken(state, "Tc") && ParseCallOffset(state) &&
ParseCallOffset(state) && ParseEncoding(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "GV") &&
+ if (ParseTwoCharToken(state, "GV") &&
ParseName(state)) {
return true;
}
*state = copy;
- if (ParseChar(state, 'T') && ParseCallOffset(state) &&
+ if (ParseOneCharToken(state, 'T') && ParseCallOffset(state) &&
ParseEncoding(state)) {
return true;
}
*state = copy;
// G++ extensions
- if (ParseTwoChar(state, "TC") && ParseType(state) &&
- ParseNumber(state) && ParseChar(state, '_') &&
+ if (ParseTwoCharToken(state, "TC") && ParseType(state) &&
+ ParseNumber(state, NULL) && ParseOneCharToken(state, '_') &&
DisableAppend(state) &&
ParseType(state)) {
RestoreAppend(state, copy.append);
@@ -773,23 +802,23 @@ static bool ParseSpecialName(State *state) {
}
*state = copy;
- if (ParseChar(state, 'T') && ParseCharClass(state, "FJ") &&
+ if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "FJ") &&
ParseType(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "GR") && ParseName(state)) {
+ if (ParseTwoCharToken(state, "GR") && ParseName(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "GA") && ParseEncoding(state)) {
+ if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) {
return true;
}
*state = copy;
- if (ParseChar(state, 'T') && ParseCharClass(state, "hv") &&
+ if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "hv") &&
ParseCallOffset(state) && ParseEncoding(state)) {
return true;
}
@@ -801,14 +830,14 @@ static bool ParseSpecialName(State *state) {
// ::= v <v-offset> _
static bool ParseCallOffset(State *state) {
State copy = *state;
- if (ParseChar(state, 'h') &&
- ParseNVOffset(state) && ParseChar(state, '_')) {
+ if (ParseOneCharToken(state, 'h') &&
+ ParseNVOffset(state) && ParseOneCharToken(state, '_')) {
return true;
}
*state = copy;
- if (ParseChar(state, 'v') &&
- ParseVOffset(state) && ParseChar(state, '_')) {
+ if (ParseOneCharToken(state, 'v') &&
+ ParseVOffset(state) && ParseOneCharToken(state, '_')) {
return true;
}
*state = copy;
@@ -818,14 +847,14 @@ static bool ParseCallOffset(State *state) {
// <nv-offset> ::= <(offset) number>
static bool ParseNVOffset(State *state) {
- return ParseNumber(state);
+ return ParseNumber(state, NULL);
}
// <v-offset> ::= <(offset) number> _ <(virtual offset) number>
static bool ParseVOffset(State *state) {
State copy = *state;
- if (ParseNumber(state) && ParseChar(state, '_') &&
- ParseNumber(state)) {
+ if (ParseNumber(state, NULL) && ParseOneCharToken(state, '_') &&
+ ParseNumber(state, NULL)) {
return true;
}
*state = copy;
@@ -836,7 +865,7 @@ static bool ParseVOffset(State *state) {
// ::= D0 | D1 | D2
static bool ParseCtorDtorName(State *state) {
State copy = *state;
- if (ParseChar(state, 'C') &&
+ if (ParseOneCharToken(state, 'C') &&
ParseCharClass(state, "123")) {
const char * const prev_name = state->prev_name;
const int prev_name_length = state->prev_name_length;
@@ -845,7 +874,7 @@ static bool ParseCtorDtorName(State *state) {
}
*state = copy;
- if (ParseChar(state, 'D') &&
+ if (ParseOneCharToken(state, 'D') &&
ParseCharClass(state, "012")) {
const char * const prev_name = state->prev_name;
const int prev_name_length = state->prev_name_length;
@@ -858,11 +887,12 @@ static bool ParseCtorDtorName(State *state) {
}
// <type> ::= <CV-qualifiers> <type>
-// ::= P <type>
-// ::= R <type>
-// ::= C <type>
-// ::= G <type>
-// ::= U <source-name> <type>
+// ::= P <type> # pointer-to
+// ::= R <type> # reference-to
+// ::= O <type> # rvalue reference-to (C++0x)
+// ::= C <type> # complex pair (C 2000)
+// ::= G <type> # imaginary (C 2000)
+// ::= U <source-name> <type> # vendor extended type qualifier
// ::= <builtin-type>
// ::= <function-type>
// ::= <class-enum-type>
@@ -871,6 +901,11 @@ static bool ParseCtorDtorName(State *state) {
// ::= <template-template-param> <template-args>
// ::= <template-param>
// ::= <substitution>
+// ::= Dp <type> # pack expansion of (C++0x)
+// ::= Dt <expression> E # decltype of an id-expression or class
+// # member access (C++0x)
+// ::= DT <expression> E # decltype of an expression (C++0x)
+//
static bool ParseType(State *state) {
// We should check CV-qualifers, and PRGC things first.
State copy = *state;
@@ -879,12 +914,23 @@ static bool ParseType(State *state) {
}
*state = copy;
- if (ParseCharClass(state, "PRCG") && ParseType(state)) {
+ if (ParseCharClass(state, "OPRCG") && ParseType(state)) {
+ return true;
+ }
+ *state = copy;
+
+ if (ParseTwoCharToken(state, "Dp") && ParseType(state)) {
return true;
}
*state = copy;
- if (ParseChar(state, 'U') && ParseSourceName(state) &&
+ if (ParseOneCharToken(state, 'D') && ParseCharClass(state, "tT") &&
+ ParseExpression(state) && ParseOneCharToken(state, 'E')) {
+ return true;
+ }
+ *state = copy;
+
+ if (ParseOneCharToken(state, 'U') && ParseSourceName(state) &&
ParseType(state)) {
return true;
}
@@ -918,9 +964,9 @@ static bool ParseType(State *state) {
// ParseType().
static bool ParseCVQualifiers(State *state) {
int num_cv_qualifiers = 0;
- num_cv_qualifiers += ParseChar(state, 'r');
- num_cv_qualifiers += ParseChar(state, 'V');
- num_cv_qualifiers += ParseChar(state, 'K');
+ num_cv_qualifiers += ParseOneCharToken(state, 'r');
+ num_cv_qualifiers += ParseOneCharToken(state, 'V');
+ num_cv_qualifiers += ParseOneCharToken(state, 'K');
return num_cv_qualifiers > 0;
}
@@ -937,7 +983,7 @@ static bool ParseBuiltinType(State *state) {
}
State copy = *state;
- if (ParseChar(state, 'u') && ParseSourceName(state)) {
+ if (ParseOneCharToken(state, 'u') && ParseSourceName(state)) {
return true;
}
*state = copy;
@@ -947,8 +993,9 @@ static bool ParseBuiltinType(State *state) {
// <function-type> ::= F [Y] <bare-function-type> E
static bool ParseFunctionType(State *state) {
State copy = *state;
- if (ParseChar(state, 'F') && Optional(ParseChar(state, 'Y')) &&
- ParseBareFunctionType(state) && ParseChar(state, 'E')) {
+ if (ParseOneCharToken(state, 'F') &&
+ Optional(ParseOneCharToken(state, 'Y')) &&
+ ParseBareFunctionType(state) && ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
@@ -977,14 +1024,14 @@ static bool ParseClassEnumType(State *state) {
// ::= A [<(dimension) expression>] _ <(element) type>
static bool ParseArrayType(State *state) {
State copy = *state;
- if (ParseChar(state, 'A') && ParseNumber(state) &&
- ParseChar(state, '_') && ParseType(state)) {
+ if (ParseOneCharToken(state, 'A') && ParseNumber(state, NULL) &&
+ ParseOneCharToken(state, '_') && ParseType(state)) {
return true;
}
*state = copy;
- if (ParseChar(state, 'A') && Optional(ParseExpression(state)) &&
- ParseChar(state, '_') && ParseType(state)) {
+ if (ParseOneCharToken(state, 'A') && Optional(ParseExpression(state)) &&
+ ParseOneCharToken(state, '_') && ParseType(state)) {
return true;
}
*state = copy;
@@ -994,7 +1041,7 @@ static bool ParseArrayType(State *state) {
// <pointer-to-member-type> ::= M <(class) type> <(member) type>
static bool ParsePointerToMemberType(State *state) {
State copy = *state;
- if (ParseChar(state, 'M') && ParseType(state) &&
+ if (ParseOneCharToken(state, 'M') && ParseType(state) &&
ParseType(state)) {
return true;
}
@@ -1005,14 +1052,14 @@ static bool ParsePointerToMemberType(State *state) {
// <template-param> ::= T_
// ::= T <parameter-2 non-negative number> _
static bool ParseTemplateParam(State *state) {
- if (ParseTwoChar(state, "T_")) {
+ if (ParseTwoCharToken(state, "T_")) {
MaybeAppend(state, "?"); // We don't support template substitutions.
return true;
}
State copy = *state;
- if (ParseChar(state, 'T') && ParseNumber(state) &&
- ParseChar(state, '_')) {
+ if (ParseOneCharToken(state, 'T') && ParseNumber(state, NULL) &&
+ ParseOneCharToken(state, '_')) {
MaybeAppend(state, "?"); // We don't support template substitutions.
return true;
}
@@ -1032,9 +1079,9 @@ static bool ParseTemplateTemplateParam(State *state) {
static bool ParseTemplateArgs(State *state) {
State copy = *state;
DisableAppend(state);
- if (ParseChar(state, 'I') &&
+ if (ParseOneCharToken(state, 'I') &&
OneOrMore(ParseTemplateArg, state) &&
- ParseChar(state, 'E')) {
+ ParseOneCharToken(state, 'E')) {
RestoreAppend(state, copy.append);
MaybeAppend(state, "<>");
return true;
@@ -1045,16 +1092,25 @@ static bool ParseTemplateArgs(State *state) {
// <template-arg> ::= <type>
// ::= <expr-primary>
+// ::= I <template-arg>* E # argument pack
// ::= X <expression> E
static bool ParseTemplateArg(State *state) {
+ State copy = *state;
+ if (ParseOneCharToken(state, 'I') &&
+ ZeroOrMore(ParseTemplateArg, state) &&
+ ParseOneCharToken(state, 'E')) {
+ return true;
+ }
+ *state = copy;
+
if (ParseType(state) ||
ParseExprPrimary(state)) {
return true;
}
+ *state = copy;
- State copy = *state;
- if (ParseChar(state, 'X') && ParseExpression(state) &&
- ParseChar(state, 'E')) {
+ if (ParseOneCharToken(state, 'X') && ParseExpression(state) &&
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
@@ -1097,19 +1153,19 @@ static bool ParseExpression(State *state) {
}
*state = copy;
- if (ParseTwoChar(state, "st") && ParseType(state)) {
+ if (ParseTwoCharToken(state, "st") && ParseType(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "sr") && ParseType(state) &&
+ if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
ParseUnqualifiedName(state) &&
ParseTemplateArgs(state)) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "sr") && ParseType(state) &&
+ if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
ParseUnqualifiedName(state)) {
return true;
}
@@ -1124,28 +1180,28 @@ static bool ParseExpression(State *state) {
// ::= LZ <encoding> E
static bool ParseExprPrimary(State *state) {
State copy = *state;
- if (ParseChar(state, 'L') && ParseType(state) &&
- ParseNumber(state) &&
- ParseChar(state, 'E')) {
+ if (ParseOneCharToken(state, 'L') && ParseType(state) &&
+ ParseNumber(state, NULL) &&
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
- if (ParseChar(state, 'L') && ParseType(state) &&
+ if (ParseOneCharToken(state, 'L') && ParseType(state) &&
ParseFloatNumber(state) &&
- ParseChar(state, 'E')) {
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
- if (ParseChar(state, 'L') && ParseMangledName(state) &&
- ParseChar(state, 'E')) {
+ if (ParseOneCharToken(state, 'L') && ParseMangledName(state) &&
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
- if (ParseTwoChar(state, "LZ") && ParseEncoding(state) &&
- ParseChar(state, 'E')) {
+ if (ParseTwoCharToken(state, "LZ") && ParseEncoding(state) &&
+ ParseOneCharToken(state, 'E')) {
return true;
}
*state = copy;
@@ -1158,15 +1214,15 @@ static bool ParseExprPrimary(State *state) {
// := Z <(function) encoding> E s [<discriminator>]
static bool ParseLocalName(State *state) {
State copy = *state;
- if (ParseChar(state, 'Z') && ParseEncoding(state) &&
- ParseChar(state, 'E') && MaybeAppend(state, "::") &&
+ if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
+ ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") &&
ParseName(state) && Optional(ParseDiscriminator(state))) {
return true;
}
*state = copy;
- if (ParseChar(state, 'Z') && ParseEncoding(state) &&
- ParseTwoChar(state, "Es") && Optional(ParseDiscriminator(state))) {
+ if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
+ ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) {
return true;
}
*state = copy;
@@ -1176,7 +1232,7 @@ static bool ParseLocalName(State *state) {
// <discriminator> := _ <(non-negative) number>
static bool ParseDiscriminator(State *state) {
State copy = *state;
- if (ParseChar(state, '_') && ParseNumber(state)) {
+ if (ParseOneCharToken(state, '_') && ParseNumber(state, NULL)) {
return true;
}
*state = copy;
@@ -1187,21 +1243,21 @@ static bool ParseDiscriminator(State *state) {
// ::= S <seq-id> _
// ::= St, etc.
static bool ParseSubstitution(State *state) {
- if (ParseTwoChar(state, "S_")) {
+ if (ParseTwoCharToken(state, "S_")) {
MaybeAppend(state, "?"); // We don't support substitutions.
return true;
}
State copy = *state;
- if (ParseChar(state, 'S') && ParseSeqId(state) &&
- ParseChar(state, '_')) {
+ if (ParseOneCharToken(state, 'S') && ParseSeqId(state) &&
+ ParseOneCharToken(state, '_')) {
MaybeAppend(state, "?"); // We don't support substitutions.
return true;
}
*state = copy;
// Expand abbreviations like "St" => "std".
- if (ParseChar(state, 'S')) {
+ if (ParseOneCharToken(state, 'S')) {
const AbbrevPair *p;
for (p = kSubstitutionList; p->abbrev != NULL; ++p) {
if (state->mangled_cur[0] == p->abbrev[1]) {
@@ -1210,7 +1266,7 @@ static bool ParseSubstitution(State *state) {
MaybeAppend(state, "::");
MaybeAppend(state, p->real_name);
}
- state->mangled_cur += 1;
+ ++state->mangled_cur;
return true;
}
}
@@ -1219,13 +1275,33 @@ static bool ParseSubstitution(State *state) {
return false;
}
+// Parse <mangled-name>, optionally followed by either a function-clone suffix
+// or version suffix. Returns true only if all of "mangled_cur" was consumed.
+static bool ParseTopLevelMangledName(State *state) {
+ if (ParseMangledName(state)) {
+ if (state->mangled_cur[0] != '\0') {
+ // Drop trailing function clone suffix, if any.
+ if (IsFunctionCloneSuffix(state->mangled_cur)) {
+ return true;
+ }
+ // Append trailing version suffix if any.
+ // ex. _Z3foo@@GLIBCXX_3.4
+ if (state->mangled_cur[0] == '@') {
+ MaybeAppend(state, state->mangled_cur);
+ return true;
+ }
+ return false; // Unconsumed suffix.
+ }
+ return true;
+ }
+ return false;
+}
+
// The demangler entry point.
bool Demangle(const char *mangled, char *out, int out_size) {
State state;
InitState(&state, mangled, out, out_size);
- return (ParseMangledName(&state) &&
- state.overflowed == false &&
- RemainingLength(&state) == 0);
+ return ParseTopLevelMangledName(&state) && !state.overflowed;
}
_END_GOOGLE_NAMESPACE_
diff --git a/extern/libmv/third_party/glog/src/glog/log_severity.h b/extern/libmv/third_party/glog/src/glog/log_severity.h
index 17805fbadd4..99945a426da 100644
--- a/extern/libmv/third_party/glog/src/glog/log_severity.h
+++ b/extern/libmv/third_party/glog/src/glog/log_severity.h
@@ -44,7 +44,15 @@
// you ever need to change their values or add a new severity.
typedef int LogSeverity;
-const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
+const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
+ NUM_SEVERITIES = 4;
+#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
+# ifdef ERROR
+# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
+# endif
+const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
+ ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
+#endif
// DFATAL is FATAL in debug mode, ERROR in normal mode
#ifdef NDEBUG
diff --git a/extern/libmv/third_party/glog/src/glog/logging.h b/extern/libmv/third_party/glog/src/glog/logging.h
index a58d478ab17..005649c17c2 100644
--- a/extern/libmv/third_party/glog/src/glog/logging.h
+++ b/extern/libmv/third_party/glog/src/glog/logging.h
@@ -33,7 +33,6 @@
// Pretty much everybody needs to #include this file so that they can
// log various happenings.
//
-
#ifndef _LOGGING_H_
#define _LOGGING_H_
@@ -80,7 +79,7 @@
#endif
#if 1
-#include "third_party/gflags/gflags.h"
+#include "third_party/gflags/gflags/gflags.h"
#endif
namespace google {
@@ -153,21 +152,21 @@ typedef unsigned __int64 uint64;
// You can also do occasional logging (log every n'th occurrence of an
// event):
//
-// LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
+// LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
//
// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed. Note that the special COUNTER value is used to
-// identify which repetition is happening.
+// times it is executed. Note that the special google::COUNTER value is used
+// to identify which repetition is happening.
//
// You can also do occasional conditional logging (log every n'th
// occurrence of an event, when condition is satisfied):
//
-// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
+// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
// << "th big cookie";
//
// You can log messages the first N times your code executes a line. E.g.
//
-// LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie";
+// LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
//
// Outputs log messages for the first 20 times it is executed.
//
@@ -184,7 +183,7 @@ typedef unsigned __int64 uint64;
//
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
//
-// DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
+// DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
//
// All "debug mode" logging is compiled away to nothing for non-debug mode
// compiles.
@@ -228,11 +227,11 @@ typedef unsigned __int64 uint64;
// "program with --v=1 or more";
// VLOG_EVERY_N(1, 10)
// << "I'm printed every 10th occurrence, and when you run the program "
-// "with --v=1 or more. Present occurence is " << COUNTER;
+// "with --v=1 or more. Present occurence is " << google::COUNTER;
// VLOG_IF_EVERY_N(1, (size > 1024), 10)
// << "I'm printed on every 10th occurence of case when size is more "
// " than 1024, when you run the program with --v=1 or more. ";
-// "Present occurence is " << COUNTER;
+// "Present occurence is " << google::COUNTER;
//
// The supported severity levels for macros that allow you to specify one
// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
@@ -369,7 +368,7 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
__FILE__, __LINE__)
#define LOG_TO_STRING_INFO(message) google::LogMessage( \
- __FILE__, __LINE__, google::INFO, message)
+ __FILE__, __LINE__, google::GLOG_INFO, message)
#else
#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
#define LOG_TO_STRING_INFO(message) google::NullStream()
@@ -377,9 +376,9 @@ DECLARE_bool(stop_logging_if_full_disk);
#if GOOGLE_STRIP_LOG <= 1
#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
- __FILE__, __LINE__, google::WARNING)
+ __FILE__, __LINE__, google::GLOG_WARNING)
#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
- __FILE__, __LINE__, google::WARNING, message)
+ __FILE__, __LINE__, google::GLOG_WARNING, message)
#else
#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
#define LOG_TO_STRING_WARNING(message) google::NullStream()
@@ -387,9 +386,9 @@ DECLARE_bool(stop_logging_if_full_disk);
#if GOOGLE_STRIP_LOG <= 2
#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
- __FILE__, __LINE__, google::ERROR)
+ __FILE__, __LINE__, google::GLOG_ERROR)
#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
- __FILE__, __LINE__, google::ERROR, message)
+ __FILE__, __LINE__, google::GLOG_ERROR, message)
#else
#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
#define LOG_TO_STRING_ERROR(message) google::NullStream()
@@ -399,7 +398,7 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
__FILE__, __LINE__)
#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
- __FILE__, __LINE__, google::FATAL, message)
+ __FILE__, __LINE__, google::GLOG_FATAL, message)
#else
#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
@@ -411,32 +410,32 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
#elif GOOGLE_STRIP_LOG <= 3
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
- __FILE__, __LINE__, google::FATAL)
+ __FILE__, __LINE__, google::GLOG_FATAL)
#else
#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
#endif
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
+#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog)
#define SYSLOG_INFO(counter) \
- google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_WARNING(counter) \
- google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_WARNING(counter) \
- google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_ERROR(counter) \
- google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_ERROR(counter) \
- google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_FATAL(counter) \
- google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_FATAL(counter) \
- google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_DFATAL(counter) \
google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
@@ -455,7 +454,7 @@ DECLARE_bool(stop_logging_if_full_disk);
FORMAT_MESSAGE_FROM_SYSTEM, \
0, result, 0, msg, 100, NULL); \
if (message_length > 0) { \
- google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \
&google::LogMessage::SendToLog).stream() << message; \
LocalFree(message); \
} \
@@ -502,12 +501,12 @@ class LogSink; // defined below
#define LOG_TO_SINK(sink, severity) \
google::LogMessage( \
__FILE__, __LINE__, \
- google::severity, \
+ google::GLOG_ ## severity, \
static_cast<google::LogSink*>(sink), true).stream()
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
google::LogMessage( \
__FILE__, __LINE__, \
- google::severity, \
+ google::GLOG_ ## severity, \
static_cast<google::LogSink*>(sink), false).stream()
// If a non-NULL string pointer is given, we write this message to that string.
@@ -772,7 +771,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
#define GOOGLE_PLOG(severity, counter) \
google::ErrnoLogMessage( \
- __FILE__, __LINE__, google::severity, counter, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, counter, \
&google::LogMessage::SendToLog)
#define PLOG_IF(severity, condition) \
@@ -811,7 +810,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
if (LOG_OCCURRENCES_MOD_N == 1) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
@@ -820,7 +819,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (condition && \
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
@@ -829,7 +828,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
if (LOG_OCCURRENCES_MOD_N == 1) \
google::ErrnoLogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
@@ -838,7 +837,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
++LOG_OCCURRENCES; \
if (LOG_OCCURRENCES <= n) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
namespace glog_internal_namespace_ {
@@ -852,7 +851,7 @@ struct CrashReason;
typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
#define LOG_EVERY_N(severity, n) \
- GOOGLE_GLOG_COMPILE_ASSERT(google::severity < \
+ GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \
google::NUM_SEVERITIES, \
INVALID_REQUESTED_LOG_SEVERITY); \
SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
@@ -872,6 +871,27 @@ struct CrashReason;
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
enum PRIVATE_Counter {COUNTER};
+#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
+// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
+// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
+// to keep using this syntax, we define this macro to do the same thing
+// as COMPACT_GOOGLE_LOG_ERROR.
+#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
+#define SYSLOG_0 SYSLOG_ERROR
+#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
+// Needed for LOG_IS_ON(ERROR).
+const LogSeverity GLOG_0 = GLOG_ERROR;
+#else
+// Users may include windows.h after logging.h without
+// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
+// For this case, we cannot detect if ERROR is defined before users
+// actually use ERROR. Let's make an undefined symbol to warn users.
+# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
+# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
+# define SYSLOG_0 GLOG_ERROR_MSG
+# define LOG_TO_STRING_0 GLOG_ERROR_MSG
+# define GLOG_0 GLOG_ERROR_MSG
+#endif
// Plus some debug-logging macros that get compiled to nothing for production
@@ -1016,14 +1036,14 @@ public:
# pragma warning(default: 4275)
#endif
public:
- LogStream(char *buf, int len, int ctr)
+ LogStream(char *buf, int len, int ctr_in)
: ostrstream(buf, len),
- ctr_(ctr) {
+ ctr_(ctr_in) {
self_ = this;
}
int ctr() const { return ctr_; }
- void set_ctr(int ctr) { ctr_ = ctr; }
+ void set_ctr(int ctr_in) { ctr_ = ctr_in; }
LogStream* self() const { return self_; }
private:
@@ -1465,7 +1485,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
// converted to LogStream and the message will be computed and then
// quietly discarded.
template<class T>
-inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
+inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// Similar to NullStream, but aborts the program (without stack
// trace), like LogMessageFatal.
diff --git a/extern/libmv/third_party/glog/src/glog/raw_logging.h b/extern/libmv/third_party/glog/src/glog/raw_logging.h
index 9e9b3772f3b..65278f62803 100644
--- a/extern/libmv/third_party/glog/src/glog/raw_logging.h
+++ b/extern/libmv/third_party/glog/src/glog/raw_logging.h
@@ -68,7 +68,7 @@ namespace google {
// I0821 211317 file.cc:142] RAW: status is 20
#define RAW_LOG(severity, ...) \
do { \
- switch (google::severity) { \
+ switch (google::GLOG_ ## severity) { \
case 0: \
RAW_LOG_INFO(__VA_ARGS__); \
break; \
@@ -100,28 +100,28 @@ namespace google {
#endif // STRIP_LOG == 0
#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
+#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG == 0
#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \
+#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 1
#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \
+#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 2
#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \
+#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_FATAL(...) \
@@ -162,7 +162,7 @@ namespace google {
// Stub log function used to work around for unused variable warnings when
// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int ignored, ...) {
+static inline void RawLogStub__(int /* ignored */, ...) {
}
// Helper function to implement RAW_LOG and RAW_VLOG
diff --git a/extern/libmv/third_party/glog/src/logging.cc b/extern/libmv/third_party/glog/src/logging.cc
index 1bb3867aa10..bf4d85be5b3 100644
--- a/extern/libmv/third_party/glog/src/logging.cc
+++ b/extern/libmv/third_party/glog/src/logging.cc
@@ -111,7 +111,7 @@ _END_GOOGLE_NAMESPACE_
// The default is ERROR instead of FATAL so that users can see problems
// when they run a program without having to look in another file.
DEFINE_int32(stderrthreshold,
- GOOGLE_NAMESPACE::ERROR,
+ GOOGLE_NAMESPACE::GLOG_ERROR,
"log messages at or above this level are copied to stderr in "
"addition to logfiles. This flag obsoletes --alsologtostderr.");
@@ -311,8 +311,10 @@ class LogDestination {
static const int kNetworkBytes = 1400;
static const string& hostname();
- private:
+ static void DeleteLogDestinations();
+
+ private:
LogDestination(LogSeverity severity, const char* base_filename);
~LogDestination() { }
@@ -503,7 +505,7 @@ inline void LogDestination::SetEmailLogging(LogSeverity min_severity,
static void WriteToStderr(const char* message, size_t len) {
// Avoid using cerr from this module since we may get called during
// exit code, and cerr may be partially or fully destroyed by then.
- write(STDERR_FILENO, message, len);
+ fwrite(message, len, 1, stderr);
}
inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
@@ -607,6 +609,13 @@ inline LogDestination* LogDestination::log_destination(LogSeverity severity) {
return log_destinations_[severity];
}
+void LogDestination::DeleteLogDestinations() {
+ for (int severity = 0; severity < NUM_SEVERITIES; ++severity) {
+ delete log_destinations_[severity];
+ log_destinations_[severity] = NULL;
+ }
+}
+
namespace {
LogFileObject::LogFileObject(LogSeverity severity,
@@ -719,14 +728,18 @@ bool LogFileObject::CreateLogfile(const char* time_pid_string) {
// Make the symlink be relative (in the same dir) so that if the
// entire log directory gets relocated the link is still valid.
const char *linkdest = slash ? (slash + 1) : filename;
- symlink(linkdest, linkpath.c_str()); // silently ignore failures
+ if (symlink(linkdest, linkpath.c_str()) != 0) {
+ // silently ignore failures
+ }
// Make an additional link to the log file in a place specified by
// FLAGS_log_link, if indicated
if (!FLAGS_log_link.empty()) {
linkpath = FLAGS_log_link + "/" + linkname;
unlink(linkpath.c_str()); // delete old one if it exists
- symlink(filename, linkpath.c_str()); // silently ignore failures
+ if (symlink(filename, linkpath.c_str()) != 0) {
+ // silently ignore failures
+ }
}
#endif
}
@@ -745,7 +758,8 @@ void LogFileObject::Write(bool force_flush,
return;
}
- if (static_cast<int>(file_length_ >> 20) >= MaxLogSize()) {
+ if (static_cast<int>(file_length_ >> 20) >= MaxLogSize() ||
+ PidHasChanged()) {
if (file_ != NULL) fclose(file_);
file_ = NULL;
file_length_ = bytes_since_flush_ = 0;
@@ -936,12 +950,12 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
LogMessage::LogMessage(const char* file, int line,
const CheckOpString& result) {
- Init(file, line, FATAL, &LogMessage::SendToLog);
+ Init(file, line, GLOG_FATAL, &LogMessage::SendToLog);
stream() << "Check failed: " << (*result.str_) << " ";
}
LogMessage::LogMessage(const char* file, int line) {
- Init(file, line, INFO, &LogMessage::SendToLog);
+ Init(file, line, GLOG_INFO, &LogMessage::SendToLog);
}
LogMessage::LogMessage(const char* file, int line, LogSeverity severity) {
@@ -972,7 +986,7 @@ void LogMessage::Init(const char* file,
LogSeverity severity,
void (LogMessage::*send_method)()) {
allocated_ = NULL;
- if (severity != FATAL || !exit_on_dfatal) {
+ if (severity != GLOG_FATAL || !exit_on_dfatal) {
allocated_ = new LogMessageData();
data_ = allocated_;
data_->buf_ = new char[kMaxLogMessageLen+1];
@@ -1123,7 +1137,7 @@ void ReprintFatalMessage() {
// Also write to stderr
WriteToStderr(fatal_message, n);
}
- LogDestination::LogToAllLogfiles(ERROR, fatal_time, fatal_message, n);
+ LogDestination::LogToAllLogfiles(GLOG_ERROR, fatal_time, fatal_message, n);
}
}
@@ -1181,7 +1195,7 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
// If we log a FATAL message, flush all the log destinations, then toss
// a signal for others to catch. We leave the logs in a state that
// someone else can use them (as long as they flush afterwards)
- if (data_->severity_ == FATAL && exit_on_dfatal) {
+ if (data_->severity_ == GLOG_FATAL && exit_on_dfatal) {
if (data_->first_fatal_) {
// Store crash information so that it is accessible from within signal
// handlers that may be invoked later.
@@ -1212,7 +1226,9 @@ void LogMessage::SendToLog() EXCLUSIVE_LOCKS_REQUIRED(log_mutex) {
LogDestination::WaitForSinks(data_);
const char* message = "*** Check failure stack trace: ***\n";
- write(STDERR_FILENO, message, strlen(message));
+ if (write(STDERR_FILENO, message, strlen(message)) < 0) {
+ // Ignore errors.
+ }
Fail();
}
}
@@ -1231,27 +1247,31 @@ void LogMessage::RecordCrashReason(
#endif
}
+#ifdef HAVE___ATTRIBUTE__
+# define ATTRIBUTE_NORETURN __attribute__((noreturn))
+#else
+# define ATTRIBUTE_NORETURN
+#endif
+
+static void logging_fail() ATTRIBUTE_NORETURN;
+
static void logging_fail() {
-// #if defined(_DEBUG) && defined(_MSC_VER)
-// doesn't work for my laptop (sergey)
-#if 0
+#if defined(_DEBUG) && defined(_MSC_VER)
// When debugging on windows, avoid the obnoxious dialog and make
// it possible to continue past a LOG(FATAL) in the debugger
- _asm int 3
+ __debugbreak();
#else
abort();
#endif
}
-#ifdef HAVE___ATTRIBUTE__
+typedef void (*logging_fail_func_t)() ATTRIBUTE_NORETURN;
+
GOOGLE_GLOG_DLL_DECL
-void (*g_logging_fail_func)() __attribute__((noreturn)) = &logging_fail;
-#else
-GOOGLE_GLOG_DLL_DECL void (*g_logging_fail_func)() = &logging_fail;
-#endif
+logging_fail_func_t g_logging_fail_func = &logging_fail;
void InstallFailureFunction(void (*fail_func)()) {
- g_logging_fail_func = fail_func;
+ g_logging_fail_func = (logging_fail_func_t)fail_func;
}
void LogMessage::Fail() {
@@ -1544,7 +1564,7 @@ static void GetTempDirectories(vector<string>* list) {
"/tmp",
};
- for (int i = 0; i < ARRAYSIZE(candidates); i++) {
+ for (size_t i = 0; i < ARRAYSIZE(candidates); i++) {
const char *d = candidates[i];
if (!d) continue; // Empty env var
@@ -1631,9 +1651,9 @@ void TruncateLogFile(const char *path, int64 limit, int64 keep) {
// rather scary.
// Instead just truncate the file to something we can manage
if (truncate(path, 0) == -1) {
- PLOG(ERROR) << "Unable to truncate " << path;
+ PLOG(ERROR) << "Unable to truncate " << path;
} else {
- LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
+ LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
}
} else {
PLOG(ERROR) << "Unable to open " << path;
@@ -1769,7 +1789,7 @@ int posix_strerror_r(int err, char *buf, size_t len) {
}
LogMessageFatal::LogMessageFatal(const char* file, int line) :
- LogMessage(file, line, FATAL) {}
+ LogMessage(file, line, GLOG_FATAL) {}
LogMessageFatal::LogMessageFatal(const char* file, int line,
const CheckOpString& result) :
@@ -1780,4 +1800,15 @@ LogMessageFatal::~LogMessageFatal() {
LogMessage::Fail();
}
+void InitGoogleLogging(const char* argv0) {
+ glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
+}
+
+void ShutdownGoogleLogging() {
+ glog_internal_namespace_::ShutdownGoogleLoggingUtilities();
+ LogDestination::DeleteLogDestinations();
+ delete logging_directories_list;
+ logging_directories_list = NULL;
+}
+
_END_GOOGLE_NAMESPACE_
diff --git a/extern/libmv/third_party/glog/src/raw_logging.cc b/extern/libmv/third_party/glog/src/raw_logging.cc
index b179a1eded4..42676cba5de 100644
--- a/extern/libmv/third_party/glog/src/raw_logging.cc
+++ b/extern/libmv/third_party/glog/src/raw_logging.cc
@@ -151,7 +151,7 @@ void RawLog__(LogSeverity severity, const char* file, int line,
// libc (to side-step any libc interception).
// We write just once to avoid races with other invocations of RawLog__.
safe_write(STDERR_FILENO, buffer, strlen(buffer));
- if (severity == FATAL) {
+ if (severity == GLOG_FATAL) {
if (!sync_val_compare_and_swap(&crashed, false, true)) {
crash_reason.filename = file;
crash_reason.line_number = line;
diff --git a/extern/libmv/third_party/glog/src/signalhandler.cc b/extern/libmv/third_party/glog/src/signalhandler.cc
index 9fc91b3390d..e95e9e97274 100644
--- a/extern/libmv/third_party/glog/src/signalhandler.cc
+++ b/extern/libmv/third_party/glog/src/signalhandler.cc
@@ -34,7 +34,7 @@
#include "utilities.h"
#include "stacktrace.h"
#include "symbolize.h"
-#include "glog/logging.h"
+#include <glog/logging.h>
#include <signal.h>
#include <time.h>
@@ -142,7 +142,9 @@ class MinimalFormatter {
// Writes the given data with the size to the standard error.
void WriteToStderr(const char* data, int size) {
- write(STDERR_FILENO, data, size);
+ if (write(STDERR_FILENO, data, size) < 0) {
+ // Ignore errors.
+ }
}
// The writer function can be changed by InstallFailureWriter().
@@ -167,7 +169,7 @@ void DumpTimeInfo() {
void DumpSignalInfo(int signal_number, siginfo_t *siginfo) {
// Get the signal name.
const char* signal_name = NULL;
- for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
+ for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
if (signal_number == kFailureSignals[i].number) {
signal_name = kFailureSignals[i].name;
}
@@ -336,7 +338,7 @@ void InstallFailureSignalHandler() {
sig_action.sa_flags |= SA_SIGINFO;
sig_action.sa_sigaction = &FailureSignalHandler;
- for (int i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
+ for (size_t i = 0; i < ARRAYSIZE(kFailureSignals); ++i) {
CHECK_ERR(sigaction(kFailureSignals[i].number, &sig_action, NULL));
}
}
diff --git a/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h b/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h
index 0dc14c6506e..46002c1b019 100644
--- a/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h
+++ b/extern/libmv/third_party/glog/src/stacktrace_libunwind-inl.h
@@ -37,7 +37,7 @@ extern "C" {
#define UNW_LOCAL_ONLY
#include <libunwind.h>
}
-#include "glog/raw_logging.h"
+#include <glog/raw_logging.h>
#include "stacktrace.h"
_START_GOOGLE_NAMESPACE_
diff --git a/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h b/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h
index e3729e1fd39..f7d1dca85bc 100644
--- a/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h
+++ b/extern/libmv/third_party/glog/src/stacktrace_x86_64-inl.h
@@ -33,10 +33,6 @@
extern "C" {
#include <stdlib.h> // for NULL
-#if defined(__FreeBSD__)
-/* devel/libunwind only includes _Unwind_Backtrace if this is set */
-#define _GNU_SOURCE 1
-#endif
#include <unwind.h> // ABI defined unwinder
}
#include "stacktrace.h"
diff --git a/extern/libmv/third_party/glog/src/symbolize.cc b/extern/libmv/third_party/glog/src/symbolize.cc
index 3465de6c6fe..d1831e4ea79 100644
--- a/extern/libmv/third_party/glog/src/symbolize.cc
+++ b/extern/libmv/third_party/glog/src/symbolize.cc
@@ -82,8 +82,8 @@ static ATTRIBUTE_NOINLINE void DemangleInplace(char *out, int out_size) {
char demangled[256]; // Big enough for sane demangled symbols.
if (Demangle(out, demangled, sizeof(demangled))) {
// Demangling succeeded. Copy to out if the space allows.
- int len = strlen(demangled);
- if (len + 1 <= out_size) { // +1 for '\0'.
+ size_t len = strlen(demangled);
+ if (len + 1 <= (size_t)out_size) { // +1 for '\0'.
SAFE_ASSERT(len < sizeof(demangled));
memmove(out, demangled, len + 1);
}
@@ -111,7 +111,7 @@ _END_GOOGLE_NAMESPACE_
#include "symbolize.h"
#include "config.h"
-#include "glog/raw_logging.h"
+#include <glog/raw_logging.h>
// Re-runs fn until it doesn't cause EINTR.
#define NO_INTR(fn) do {} while ((fn) < 0 && errno == EINTR)
@@ -637,7 +637,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
int out_size) {
Dl_info info;
if (dladdr(pc, &info)) {
- if (strlen(info.dli_sname) < out_size) {
+ if ((int)strlen(info.dli_sname) < out_size) {
strcpy(out, info.dli_sname);
// Symbolization succeeded. Now we try to demangle the symbol.
DemangleInplace(out, out_size);
diff --git a/extern/libmv/third_party/glog/src/symbolize.h b/extern/libmv/third_party/glog/src/symbolize.h
index 1ebe4dd94a2..04e482bc315 100644
--- a/extern/libmv/third_party/glog/src/symbolize.h
+++ b/extern/libmv/third_party/glog/src/symbolize.h
@@ -56,7 +56,7 @@
#include "utilities.h"
#include "config.h"
-#include "glog/logging.h"
+#include <glog/logging.h>
#ifdef HAVE_SYMBOLIZE
diff --git a/extern/libmv/third_party/glog/src/utilities.cc b/extern/libmv/third_party/glog/src/utilities.cc
index 6d64b923703..27b2a905055 100644
--- a/extern/libmv/third_party/glog/src/utilities.cc
+++ b/extern/libmv/third_party/glog/src/utilities.cc
@@ -77,9 +77,11 @@ typedef void DebugWriter(const char*, void*);
// For some environments, add two extra bytes for the leading "0x".
static const int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
-static void DebugWriteToStderr(const char* data, void *unused) {
+static void DebugWriteToStderr(const char* data, void *) {
// This one is signal-safe.
- write(STDERR_FILENO, data, strlen(data));
+ if (write(STDERR_FILENO, data, strlen(data)) < 0) {
+ // Ignore errors.
+ }
}
void DebugWriteToString(const char* data, void *arg) {
@@ -221,9 +223,18 @@ int32 GetMainThreadPid() {
return g_main_thread_pid;
}
+bool PidHasChanged() {
+ int32 pid = getpid();
+ if (g_main_thread_pid == pid) {
+ return false;
+ }
+ g_main_thread_pid = pid;
+ return true;
+}
+
pid_t GetTID() {
// On Linux and FreeBSD, we try to use gettid().
-#if defined OS_LINUX || defined OS_MACOSX
+#if defined OS_LINUX || defined OS_FREEBSD || defined OS_MACOSX
#ifndef __NR_gettid
#ifdef OS_MACOSX
#define __NR_gettid SYS_gettid
@@ -302,9 +313,7 @@ void SetCrashReason(const CrashReason* r) {
r);
}
-} // namespace glog_internal_namespace_
-
-void InitGoogleLogging(const char* argv0) {
+void InitGoogleLoggingUtilities(const char* argv0) {
CHECK(!IsGoogleLoggingInitialized())
<< "You called InitGoogleLogging() twice!";
const char* slash = strrchr(argv0, '/');
@@ -319,14 +328,16 @@ void InitGoogleLogging(const char* argv0) {
#endif
}
-void ShutdownGoogleLogging() {
+void ShutdownGoogleLoggingUtilities() {
CHECK(IsGoogleLoggingInitialized())
- << "You called ShutdownGoogleLogging() without InitGoogleLogging() first!";
+ << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!";
#ifdef HAVE_SYSLOG_H
closelog();
#endif
}
+} // namespace glog_internal_namespace_
+
_END_GOOGLE_NAMESPACE_
// Make an implementation of stacktrace compiled.
diff --git a/extern/libmv/third_party/glog/src/utilities.h b/extern/libmv/third_party/glog/src/utilities.h
index bbb0eb0746c..c8215b73f33 100644
--- a/extern/libmv/third_party/glog/src/utilities.h
+++ b/extern/libmv/third_party/glog/src/utilities.h
@@ -161,6 +161,7 @@ typedef double WallTime;
WallTime WallTime_Now();
int32 GetMainThreadPid();
+bool PidHasChanged();
pid_t GetTID();
@@ -215,6 +216,9 @@ struct CrashReason {
void SetCrashReason(const CrashReason* r);
+void InitGoogleLoggingUtilities(const char* argv0);
+void ShutdownGoogleLoggingUtilities();
+
} // namespace glog_internal_namespace_
_END_GOOGLE_NAMESPACE_
diff --git a/extern/libmv/third_party/glog/src/vlog_is_on.cc b/extern/libmv/third_party/glog/src/vlog_is_on.cc
index ed88514dce5..5eefc96324a 100644
--- a/extern/libmv/third_party/glog/src/vlog_is_on.cc
+++ b/extern/libmv/third_party/glog/src/vlog_is_on.cc
@@ -70,8 +70,8 @@ GOOGLE_GLOG_DLL_DECL bool SafeFNMatch_(const char* pattern,
size_t patt_len,
const char* str,
size_t str_len) {
- int p = 0;
- int s = 0;
+ size_t p = 0;
+ size_t s = 0;
while (1) {
if (p == patt_len && s == str_len) return true;
if (p == patt_len) return false;
@@ -211,7 +211,7 @@ bool InitVLOG3__(int32** site_flag, int32* site_default,
const char* base = strrchr(fname, '/');
base = base ? (base+1) : fname;
const char* base_end = strchr(base, '.');
- size_t base_length = base_end ? (base_end - base) : strlen(base);
+ size_t base_length = base_end ? size_t(base_end - base) : strlen(base);
// Trim out trailing "-inl" if any
if (base_length >= 4 && (memcmp(base+base_length-4, "-inl", 4) == 0)) {
diff --git a/extern/libmv/third_party/glog/src/windows/glog/log_severity.h b/extern/libmv/third_party/glog/src/windows/glog/log_severity.h
index 5e7d09effb2..22a4191ab8b 100644
--- a/extern/libmv/third_party/glog/src/windows/glog/log_severity.h
+++ b/extern/libmv/third_party/glog/src/windows/glog/log_severity.h
@@ -48,7 +48,15 @@
// you ever need to change their values or add a new severity.
typedef int LogSeverity;
-const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
+const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3,
+ NUM_SEVERITIES = 4;
+#ifndef GLOG_NO_ABBREVIATED_SEVERITIES
+# ifdef ERROR
+# error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail.
+# endif
+const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
+ ERROR = GLOG_ERROR, FATAL = GLOG_FATAL;
+#endif
// DFATAL is FATAL in debug mode, ERROR in normal mode
#ifdef NDEBUG
diff --git a/extern/libmv/third_party/glog/src/windows/glog/logging.h b/extern/libmv/third_party/glog/src/windows/glog/logging.h
index 2f41681edbe..f623cd9e793 100644
--- a/extern/libmv/third_party/glog/src/windows/glog/logging.h
+++ b/extern/libmv/third_party/glog/src/windows/glog/logging.h
@@ -83,7 +83,7 @@
#endif
#if 1
-#include "third_party/gflags/gflags.h"
+#include "third_party/gflags/gflags/gflags.h"
#endif
#ifdef __MINGW32__
@@ -170,21 +170,21 @@ typedef uint64_t uint64;
// You can also do occasional logging (log every n'th occurrence of an
// event):
//
-// LOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
+// LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
//
// The above will cause log messages to be output on the 1st, 11th, 21st, ...
-// times it is executed. Note that the special COUNTER value is used to
-// identify which repetition is happening.
+// times it is executed. Note that the special google::COUNTER value is used
+// to identify which repetition is happening.
//
// You can also do occasional conditional logging (log every n'th
// occurrence of an event, when condition is satisfied):
//
-// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << COUNTER
+// LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
// << "th big cookie";
//
// You can log messages the first N times your code executes a line. E.g.
//
-// LOG_FIRST_N(INFO, 20) << "Got the " << COUNTER << "th cookie";
+// LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
//
// Outputs log messages for the first 20 times it is executed.
//
@@ -201,7 +201,7 @@ typedef uint64_t uint64;
//
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
//
-// DLOG_EVERY_N(INFO, 10) << "Got the " << COUNTER << "th cookie";
+// DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
//
// All "debug mode" logging is compiled away to nothing for non-debug mode
// compiles.
@@ -245,11 +245,11 @@ typedef uint64_t uint64;
// "program with --v=1 or more";
// VLOG_EVERY_N(1, 10)
// << "I'm printed every 10th occurrence, and when you run the program "
-// "with --v=1 or more. Present occurence is " << COUNTER;
+// "with --v=1 or more. Present occurence is " << google::COUNTER;
// VLOG_IF_EVERY_N(1, (size > 1024), 10)
// << "I'm printed on every 10th occurence of case when size is more "
// " than 1024, when you run the program with --v=1 or more. ";
-// "Present occurence is " << COUNTER;
+// "Present occurence is " << google::COUNTER;
//
// The supported severity levels for macros that allow you to specify one
// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
@@ -386,7 +386,7 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_INFO google::LogMessage( \
__FILE__, __LINE__)
#define LOG_TO_STRING_INFO(message) google::LogMessage( \
- __FILE__, __LINE__, google::INFO, message)
+ __FILE__, __LINE__, google::GLOG_INFO, message)
#else
#define COMPACT_GOOGLE_LOG_INFO google::NullStream()
#define LOG_TO_STRING_INFO(message) google::NullStream()
@@ -394,9 +394,9 @@ DECLARE_bool(stop_logging_if_full_disk);
#if GOOGLE_STRIP_LOG <= 1
#define COMPACT_GOOGLE_LOG_WARNING google::LogMessage( \
- __FILE__, __LINE__, google::WARNING)
+ __FILE__, __LINE__, google::GLOG_WARNING)
#define LOG_TO_STRING_WARNING(message) google::LogMessage( \
- __FILE__, __LINE__, google::WARNING, message)
+ __FILE__, __LINE__, google::GLOG_WARNING, message)
#else
#define COMPACT_GOOGLE_LOG_WARNING google::NullStream()
#define LOG_TO_STRING_WARNING(message) google::NullStream()
@@ -404,9 +404,9 @@ DECLARE_bool(stop_logging_if_full_disk);
#if GOOGLE_STRIP_LOG <= 2
#define COMPACT_GOOGLE_LOG_ERROR google::LogMessage( \
- __FILE__, __LINE__, google::ERROR)
+ __FILE__, __LINE__, google::GLOG_ERROR)
#define LOG_TO_STRING_ERROR(message) google::LogMessage( \
- __FILE__, __LINE__, google::ERROR, message)
+ __FILE__, __LINE__, google::GLOG_ERROR, message)
#else
#define COMPACT_GOOGLE_LOG_ERROR google::NullStream()
#define LOG_TO_STRING_ERROR(message) google::NullStream()
@@ -416,7 +416,7 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_FATAL google::LogMessageFatal( \
__FILE__, __LINE__)
#define LOG_TO_STRING_FATAL(message) google::LogMessage( \
- __FILE__, __LINE__, google::FATAL, message)
+ __FILE__, __LINE__, google::GLOG_FATAL, message)
#else
#define COMPACT_GOOGLE_LOG_FATAL google::NullStreamFatal()
#define LOG_TO_STRING_FATAL(message) google::NullStreamFatal()
@@ -428,32 +428,32 @@ DECLARE_bool(stop_logging_if_full_disk);
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_ERROR
#elif GOOGLE_STRIP_LOG <= 3
#define COMPACT_GOOGLE_LOG_DFATAL google::LogMessage( \
- __FILE__, __LINE__, google::FATAL)
+ __FILE__, __LINE__, google::GLOG_FATAL)
#else
#define COMPACT_GOOGLE_LOG_DFATAL google::NullStreamFatal()
#endif
-#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::INFO, counter, &google::LogMessage::SendToLog)
+#define GOOGLE_LOG_INFO(counter) google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, &google::LogMessage::SendToLog)
#define SYSLOG_INFO(counter) \
- google::LogMessage(__FILE__, __LINE__, google::INFO, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_INFO, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_WARNING(counter) \
- google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_WARNING(counter) \
- google::LogMessage(__FILE__, __LINE__, google::WARNING, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_WARNING, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_ERROR(counter) \
- google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_ERROR(counter) \
- google::LogMessage(__FILE__, __LINE__, google::ERROR, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_FATAL(counter) \
- google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
&google::LogMessage::SendToLog)
#define SYSLOG_FATAL(counter) \
- google::LogMessage(__FILE__, __LINE__, google::FATAL, counter, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_FATAL, counter, \
&google::LogMessage::SendToSyslogAndLog)
#define GOOGLE_LOG_DFATAL(counter) \
google::LogMessage(__FILE__, __LINE__, google::DFATAL_LEVEL, counter, \
@@ -472,7 +472,7 @@ DECLARE_bool(stop_logging_if_full_disk);
FORMAT_MESSAGE_FROM_SYSTEM, \
0, result, 0, msg, 100, NULL); \
if (message_length > 0) { \
- google::LogMessage(__FILE__, __LINE__, ERROR, 0, \
+ google::LogMessage(__FILE__, __LINE__, google::GLOG_ERROR, 0, \
&google::LogMessage::SendToLog).stream() << message; \
LocalFree(message); \
} \
@@ -519,12 +519,12 @@ class LogSink; // defined below
#define LOG_TO_SINK(sink, severity) \
google::LogMessage( \
__FILE__, __LINE__, \
- google::severity, \
+ google::GLOG_ ## severity, \
static_cast<google::LogSink*>(sink), true).stream()
#define LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity) \
google::LogMessage( \
__FILE__, __LINE__, \
- google::severity, \
+ google::GLOG_ ## severity, \
static_cast<google::LogSink*>(sink), false).stream()
// If a non-NULL string pointer is given, we write this message to that string.
@@ -789,7 +789,7 @@ DECLARE_CHECK_STROP_IMPL(strcasecmp, false)
#define GOOGLE_PLOG(severity, counter) \
google::ErrnoLogMessage( \
- __FILE__, __LINE__, google::severity, counter, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, counter, \
&google::LogMessage::SendToLog)
#define PLOG_IF(severity, condition) \
@@ -828,7 +828,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
if (LOG_OCCURRENCES_MOD_N == 1) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \
@@ -837,7 +837,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (condition && \
((LOG_OCCURRENCES_MOD_N=(LOG_OCCURRENCES_MOD_N + 1) % n) == (1 % n))) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \
@@ -846,7 +846,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
if (++LOG_OCCURRENCES_MOD_N > n) LOG_OCCURRENCES_MOD_N -= n; \
if (LOG_OCCURRENCES_MOD_N == 1) \
google::ErrnoLogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
#define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \
@@ -855,7 +855,7 @@ PLOG_IF(FATAL, GOOGLE_PREDICT_BRANCH_NOT_TAKEN((invocation) == -1)) \
++LOG_OCCURRENCES; \
if (LOG_OCCURRENCES <= n) \
google::LogMessage( \
- __FILE__, __LINE__, google::severity, LOG_OCCURRENCES, \
+ __FILE__, __LINE__, google::GLOG_ ## severity, LOG_OCCURRENCES, \
&what_to_do).stream()
namespace glog_internal_namespace_ {
@@ -869,7 +869,7 @@ struct CrashReason;
typedef google::glog_internal_namespace_::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
#define LOG_EVERY_N(severity, n) \
- GOOGLE_GLOG_COMPILE_ASSERT(google::severity < \
+ GOOGLE_GLOG_COMPILE_ASSERT(google::GLOG_ ## severity < \
google::NUM_SEVERITIES, \
INVALID_REQUESTED_LOG_SEVERITY); \
SOME_KIND_OF_LOG_EVERY_N(severity, (n), google::LogMessage::SendToLog)
@@ -889,6 +889,27 @@ struct CrashReason;
// We want the special COUNTER value available for LOG_EVERY_X()'ed messages
enum PRIVATE_Counter {COUNTER};
+#ifdef GLOG_NO_ABBREVIATED_SEVERITIES
+// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
+// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us
+// to keep using this syntax, we define this macro to do the same thing
+// as COMPACT_GOOGLE_LOG_ERROR.
+#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
+#define SYSLOG_0 SYSLOG_ERROR
+#define LOG_TO_STRING_0 LOG_TO_STRING_ERROR
+// Needed for LOG_IS_ON(ERROR).
+const LogSeverity GLOG_0 = GLOG_ERROR;
+#else
+// Users may include windows.h after logging.h without
+// GLOG_NO_ABBREVIATED_SEVERITIES nor WIN32_LEAN_AND_MEAN.
+// For this case, we cannot detect if ERROR is defined before users
+// actually use ERROR. Let's make an undefined symbol to warn users.
+# define GLOG_ERROR_MSG ERROR_macro_is_defined_Define_GLOG_NO_ABBREVIATED_SEVERITIES_before_including_logging_h_See_the_document_for_detail
+# define COMPACT_GOOGLE_LOG_0 GLOG_ERROR_MSG
+# define SYSLOG_0 GLOG_ERROR_MSG
+# define LOG_TO_STRING_0 GLOG_ERROR_MSG
+# define GLOG_0 GLOG_ERROR_MSG
+#endif
// Plus some debug-logging macros that get compiled to nothing for production
@@ -1033,14 +1054,14 @@ public:
# pragma warning(default: 4275)
#endif
public:
- LogStream(char *buf, int len, int ctr)
+ LogStream(char *buf, int len, int ctr_in)
: ostrstream(buf, len),
- ctr_(ctr) {
+ ctr_(ctr_in) {
self_ = this;
}
int ctr() const { return ctr_; }
- void set_ctr(int ctr) { ctr_ = ctr; }
+ void set_ctr(int ctr_in) { ctr_ = ctr_in; }
LogStream* self() const { return self_; }
private:
@@ -1482,7 +1503,7 @@ class GOOGLE_GLOG_DLL_DECL NullStream : public LogMessage::LogStream {
// converted to LogStream and the message will be computed and then
// quietly discarded.
template<class T>
-inline NullStream& operator<<(NullStream &str, const T &value) { return str; }
+inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// Similar to NullStream, but aborts the program (without stack
// trace), like LogMessageFatal.
diff --git a/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h b/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h
index c81e67bf99c..4757a719db7 100644
--- a/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h
+++ b/extern/libmv/third_party/glog/src/windows/glog/raw_logging.h
@@ -72,7 +72,7 @@ namespace google {
// I0821 211317 file.cc:142] RAW: status is 20
#define RAW_LOG(severity, ...) \
do { \
- switch (google::severity) { \
+ switch (google::GLOG_ ## severity) { \
case 0: \
RAW_LOG_INFO(__VA_ARGS__); \
break; \
@@ -104,28 +104,28 @@ namespace google {
#endif // STRIP_LOG == 0
#if STRIP_LOG == 0
-#define RAW_LOG_INFO(...) google::RawLog__(google::INFO, \
+#define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG == 0
#if STRIP_LOG <= 1
-#define RAW_LOG_WARNING(...) google::RawLog__(google::WARNING, \
+#define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 1
#if STRIP_LOG <= 2
-#define RAW_LOG_ERROR(...) google::RawLog__(google::ERROR, \
+#define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__)
#endif // STRIP_LOG <= 2
#if STRIP_LOG <= 3
-#define RAW_LOG_FATAL(...) google::RawLog__(google::FATAL, \
+#define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \
__FILE__, __LINE__, __VA_ARGS__)
#else
#define RAW_LOG_FATAL(...) \
@@ -166,7 +166,7 @@ namespace google {
// Stub log function used to work around for unused variable warnings when
// building with STRIP_LOG > 0.
-static inline void RawLogStub__(int ignored, ...) {
+static inline void RawLogStub__(int /* ignored */, ...) {
}
// Helper function to implement RAW_LOG and RAW_VLOG
diff --git a/extern/libmv/third_party/glog/src/windows/port.h b/extern/libmv/third_party/glog/src/windows/port.h
index d5078120009..abfcf65384c 100644
--- a/extern/libmv/third_party/glog/src/windows/port.h
+++ b/extern/libmv/third_party/glog/src/windows/port.h
@@ -59,16 +59,14 @@
* used by both C and C++ code, so we put all the C++ together.
*/
-#if _MSC_VER
- /* 4244: otherwise we get problems when substracting two size_t's to an int
- * 4251: it's complaining about a private struct I've chosen not to dllexport
- * 4355: we use this in a constructor, but we do it safely
- * 4715: for some reason VC++ stopped realizing you can't return after abort()
- * 4800: we know we're casting ints/char*'s to bools, and we're ok with that
- * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
- */
-# pragma warning(disable:4244 4251 4355 4715 4800 4996)
-#endif
+/* 4244: otherwise we get problems when substracting two size_t's to an int
+ * 4251: it's complaining about a private struct I've chosen not to dllexport
+ * 4355: we use this in a constructor, but we do it safely
+ * 4715: for some reason VC++ stopped realizing you can't return after abort()
+ * 4800: we know we're casting ints/char*'s to bools, and we're ok with that
+ * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
+ */
+#pragma warning(disable:4244 4251 4355 4715 4800 4996)
/* file I/O */
#define PATH_MAX 1024
diff --git a/extern/libmv/third_party/glog/src/windows/preprocess.sh b/extern/libmv/third_party/glog/src/windows/preprocess.sh
index ea4352e8e3a..ea4352e8e3a 100755..100644
--- a/extern/libmv/third_party/glog/src/windows/preprocess.sh
+++ b/extern/libmv/third_party/glog/src/windows/preprocess.sh