diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/gflags.cc | 12 | ||||
-rw-r--r-- | src/gflags.h.in | 23 | ||||
-rw-r--r-- | src/gflags_completions.cc | 10 | ||||
-rw-r--r-- | src/gflags_declare.h.in | 4 | ||||
-rw-r--r-- | src/gflags_reporting.cc | 10 | ||||
-rw-r--r-- | src/windows_port.h | 2 |
7 files changed, 47 insertions, 16 deletions
diff --git a/src/config.h b/src/config.h index b90b7e6..c33d207 100644 --- a/src/config.h +++ b/src/config.h @@ -36,6 +36,8 @@ #ifndef GFLAGS_DLL_DECL # if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DECL __declspec(dllexport) +# elif defined(__GNUC__) && __GNUC__ >= 4 +# define GFLAGS_DLL_DECL __attribute__((visibility("default"))) # else # define GFLAGS_DLL_DECL # endif diff --git a/src/gflags.cc b/src/gflags.cc index 9869782..8f5aa0b 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -1036,17 +1036,15 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, char* arg = (*argv)[i]; // Like getopt(), we permute non-option flags to be at the end. - if (arg[0] != '-' || // must be a program argument - (arg[0] == '-' && arg[1] == '\0')) { // "-" is an argument, not a flag + if (arg[0] != '-' || arg[1] == '\0') { // must be a program argument: "-" is an argument, not a flag memmove((*argv) + i, (*argv) + i+1, (*argc - (i+1)) * sizeof((*argv)[i])); (*argv)[*argc-1] = arg; // we go last first_nonopt--; // we've been pushed onto the stack i--; // to undo the i++ in the loop continue; } - - if (arg[0] == '-') arg++; // allow leading '-' - if (arg[0] == '-') arg++; // or leading '--' + arg++; // skip leading '-' + if (arg[0] == '-') arg++; // or leading '--' // -- alone means what it does for GNU: stop options parsing if (*arg == '\0') { @@ -1343,8 +1341,8 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( || fnmatch(glob.c_str(), ProgramInvocationName(), FNM_PATHNAME) == 0 || fnmatch(glob.c_str(), ProgramInvocationShortName(), FNM_PATHNAME) == 0 #elif defined(HAVE_SHLWAPI_H) - || PathMatchSpec(glob.c_str(), ProgramInvocationName()) - || PathMatchSpec(glob.c_str(), ProgramInvocationShortName()) + || PathMatchSpecA(glob.c_str(), ProgramInvocationName()) + || PathMatchSpecA(glob.c_str(), ProgramInvocationShortName()) #endif ) { flags_are_relevant = true; diff --git a/src/gflags.h.in b/src/gflags.h.in index 82e640f..7b218b9 100644 --- a/src/gflags.h.in +++ b/src/gflags.h.in @@ -441,6 +441,27 @@ class GFLAGS_DLL_DECL FlagRegisterer { FlagType* current_storage, FlagType* defvalue_storage); }; +// Force compiler to not generate code for the given template specialization. +#if defined(_MSC_VER) && _MSC_VER < 1800 // Visual Studio 2013 version 12.0 + #define GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(type) +#else + #define GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(type) \ + extern template GFLAGS_DLL_DECL FlagRegisterer::FlagRegisterer( \ + const char* name, const char* help, const char* filename, \ + type* current_storage, type* defvalue_storage) +#endif + +// Do this for all supported flag types. +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(bool); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int32); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint32); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int64); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint64); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(double); +GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(std::string); + +#undef GFLAGS_DECLARE_FLAG_REGISTERER_CTOR + // 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 @@ -478,7 +499,7 @@ extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[]; 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 type FLAGS_no##name = FLAGS_nono##name; \ static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \ #name, MAYBE_STRIPPED_HELP(help), __FILE__, \ &FLAGS_##name, &FLAGS_no##name); \ diff --git a/src/gflags_completions.cc b/src/gflags_completions.cc index f772486..c53a128 100644 --- a/src/gflags_completions.cc +++ b/src/gflags_completions.cc @@ -179,6 +179,11 @@ struct CompletionOptions { bool flag_description_substring_search; bool return_all_matching_flags; bool force_no_update; + CompletionOptions(): flag_name_substring_search(false), + flag_location_substring_search(false), + flag_description_substring_search(false), + return_all_matching_flags(false), + force_no_update(false) { } }; // Notable flags are flags that are special or preferred for some @@ -202,7 +207,7 @@ struct NotableFlags { static void PrintFlagCompletionInfo(void) { string cursor_word = FLAGS_tab_completion_word; string canonical_token; - CompletionOptions options = { }; + CompletionOptions options = CompletionOptions(); CanonicalizeCursorWordAndSearchOptions( cursor_word, &canonical_token, @@ -545,8 +550,7 @@ static void FinalizeCompletionOutput( vector<DisplayInfoGroup> output_groups; bool perfect_match_found = false; - if (lines_so_far < max_desired_lines && - !notable_flags->perfect_match_flag.empty()) { + if (!notable_flags->perfect_match_flag.empty()) { perfect_match_found = true; DisplayInfoGroup group = { "", diff --git a/src/gflags_declare.h.in b/src/gflags_declare.h.in index 752a34d..ab7bd24 100644 --- a/src/gflags_declare.h.in +++ b/src/gflags_declare.h.in @@ -58,6 +58,8 @@ #ifndef GFLAGS_DLL_DECL # if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DECL __declspec(dllimport) +# elif defined(__GNUC__) && __GNUC__ >= 4 +# define GFLAGS_DLL_DECL __attribute__((visibility("default"))) # else # define GFLAGS_DLL_DECL # endif @@ -67,6 +69,8 @@ #ifndef GFLAGS_DLL_DECLARE_FLAG # if GFLAGS_IS_A_DLL && defined(_MSC_VER) # define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport) +# elif defined(__GNUC__) && __GNUC__ >= 4 +# define GFLAGS_DLL_DECLARE_FLAG __attribute__((visibility("default"))) # else # define GFLAGS_DLL_DECLARE_FLAG # endif diff --git a/src/gflags_reporting.cc b/src/gflags_reporting.cc index 7cc6691..29be922 100644 --- a/src/gflags_reporting.cc +++ b/src/gflags_reporting.cc @@ -296,10 +296,10 @@ static void ShowUsageWithFlagsMatching(const char *argv0, } } -void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict) { +void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict_) { vector<string> substrings; - if (restrict != NULL && *restrict != '\0') { - substrings.push_back(restrict); + if (restrict_ != NULL && *restrict_ != '\0') { + substrings.push_back(restrict_); } ShowUsageWithFlagsMatching(argv0, substrings); } @@ -389,8 +389,8 @@ void HandleCommandLineHelpFlags() { gflags_exitfunc(1); } else if (!FLAGS_helpon.empty()) { - string restrict = PATH_SEPARATOR + FLAGS_helpon + "."; - ShowUsageWithFlagsRestrict(progname, restrict.c_str()); + string restrict_ = PATH_SEPARATOR + FLAGS_helpon + "."; + ShowUsageWithFlagsRestrict(progname, restrict_.c_str()); gflags_exitfunc(1); } else if (!FLAGS_helpmatch.empty()) { diff --git a/src/windows_port.h b/src/windows_port.h index 61cf5b7..59a310e 100644 --- a/src/windows_port.h +++ b/src/windows_port.h @@ -77,6 +77,7 @@ extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size, # pragma warning(push) # pragma warning(disable: 4996) // ignore getenv security warning #endif +#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L inline void setenv(const char* name, const char* value, int) { // In windows, it's impossible to set a variable to the empty string. // We handle this by setting it to "0" and the NUL-ing out the \0. @@ -98,6 +99,7 @@ inline void setenv(const char* name, const char* value, int) { *getenv(name) = '\0'; // works when putenv() copies nameval } } +#endif #ifdef _MSC_VER # pragma warning(pop) #endif |