Commit 67914687 authored by Craig Silverstein's avatar Craig Silverstein

Tue Aug 19 16:15:48 2008 Google Inc. <opensource@google.com>

	* 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)


git-svn-id: https://gflags.googlecode.com/svn/trunk@25 6586e3c6-dcc4-952a-343f-ff74eb82781d
parent c79c32d9
Tue Aug 19 16:15:48 2008 Google Inc. <opensource@google.com>
* 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> Mon Jul 21 23:01:38 2008 Google Inc. <opensource@google.com>
* google-gflags: version 0.9 * google-gflags: version 0.9
......
## This is a boilerplate file for Google opensource projects.
## To make it useful, replace <<TEXT>> with actual text for your project.
## Also, look at comments with "## double hashes" to see if any are worth
## uncommenting or modifying.
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
# Make sure that when we re-make ./configure, we get the macros we need # Make sure that when we re-make ./configure, we get the macros we need
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
# This is so we can #include <google/foo> # This is so we can #include <gflags/foo>
AM_CPPFLAGS = -I$(top_srcdir)/src AM_CPPFLAGS = -I$(top_srcdir)/src
# This is mostly based on configure options # This is mostly based on configure options
...@@ -19,9 +14,13 @@ if GCC ...@@ -19,9 +14,13 @@ if GCC
AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
endif endif
googleincludedir = $(includedir)/google gflagsincludedir = $(includedir)/gflags
## The .h files you want to install (that is, .h files that people ## The .h files you want to install (that is, .h files that people
## who install this package can include in their own applications.) ## who install this package can include in their own applications.)
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_completions.h
# This is for backwards compatibility only.
googleincludedir = $(includedir)/google
googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h
bin_SCRIPTS = src/gflags_completions.sh bin_SCRIPTS = src/gflags_completions.sh
...@@ -51,30 +50,30 @@ CLEANFILES = ...@@ -51,30 +50,30 @@ CLEANFILES =
## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS ## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
lib_LTLIBRARIES += libgflags.la lib_LTLIBRARIES += libgflags.la
libgflags_la_SOURCES = $(googleinclude_HEADERS) src/config.h \ libgflags_la_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags.cc src/gflags_reporting.cc \ src/gflags.cc src/gflags_reporting.cc \
src/gflags_completions.cc src/gflags_completions.cc
libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG
libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS) libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS)
libgflags_la_LIBADD = $(PTHREAD_LIBS) libgflags_la_LIBADD = $(PTHREAD_LIBS)
TESTS += gflags_unittest TESTS += gflags_unittest$(EXEEXT)
gflags_unittest_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest.cc src/gflags_unittest.cc
gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS) gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS) gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS)
# Also make sure this works when we don't link in pthreads # Also make sure this works when we don't link in pthreads
TESTS += gflags_nothreads_unittest TESTS += gflags_nothreads_unittest$(EXEEXT)
gflags_nothreads_unittest_SOURCES = $(gflags_unittest_SOURCES) gflags_nothreads_unittest_SOURCES = $(gflags_unittest_SOURCES)
gflags_nothreads_unittest_LDADD = libgflags.la gflags_nothreads_unittest_LDADD = libgflags.la
# We also want to test that things work properly when the file that # We also want to test that things work properly when the file that
# holds main() has a name ending with -main or _main. To keep the # holds main() has a name ending with -main or _main. To keep the
# Makefile small :-), we test the no-threads version of these. # Makefile small :-), we test the no-threads version of these.
TESTS += gflags_unittest2 TESTS += gflags_unittest2$(EXEEXT)
gflags_unittest2_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest2_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest-main.cc src/gflags_unittest-main.cc
gflags_unittest2_LDADD = libgflags.la gflags_unittest2_LDADD = libgflags.la
src/gflags_unittest-main.cc: src/gflags_unittest.cc src/gflags_unittest-main.cc: src/gflags_unittest.cc
...@@ -82,8 +81,8 @@ src/gflags_unittest-main.cc: src/gflags_unittest.cc ...@@ -82,8 +81,8 @@ src/gflags_unittest-main.cc: src/gflags_unittest.cc
cp -p src/gflags_unittest.cc src/gflags_unittest-main.cc cp -p src/gflags_unittest.cc src/gflags_unittest-main.cc
CLEANFILES += src/gflags_unittest-main.cc CLEANFILES += src/gflags_unittest-main.cc
TESTS += gflags_unittest3 TESTS += gflags_unittest3$(EXEEXT)
gflags_unittest3_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest3_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest_main.cc src/gflags_unittest_main.cc
gflags_unittest3_LDADD = libgflags.la gflags_unittest3_LDADD = libgflags.la
src/gflags_unittest_main.cc: src/gflags_unittest.cc src/gflags_unittest_main.cc: src/gflags_unittest.cc
...@@ -91,12 +90,18 @@ src/gflags_unittest_main.cc: src/gflags_unittest.cc ...@@ -91,12 +90,18 @@ src/gflags_unittest_main.cc: src/gflags_unittest.cc
cp -p src/gflags_unittest.cc src/gflags_unittest_main.cc cp -p src/gflags_unittest.cc src/gflags_unittest_main.cc
CLEANFILES += src/gflags_unittest_main.cc CLEANFILES += src/gflags_unittest_main.cc
# Some buggy sh's ignore "" instead of treating it as a positional
# parameter. Since we use "" in this script, we prefer bash if we
# can. If there's no bash, we fall back to sh.
check_SCRIPTS += gflags_unittest_sh check_SCRIPTS += gflags_unittest_sh
noinst_SCRIPTS += src/gflags_unittest.sh noinst_SCRIPTS += src/gflags_unittest.sh
dist_noinst_DATA = $(top_srcdir)/src/gflags_unittest_flagfile dist_noinst_DATA = src/gflags_unittest_flagfile
gflags_unittest_sh: gflags_unittest gflags_unittest2 gflags_unittest3 gflags_unittest_sh: gflags_unittest$(EXEEXT) \
$(top_srcdir)/src/gflags_unittest.sh $(PWD)/$< $(top_srcdir) gflags_unittest2$(EXEEXT) \
gflags_unittest3$(EXEEXT)
bash --version >/dev/null && export SH=bash || export SH=sh; \
$$SH "$(top_srcdir)/src/gflags_unittest.sh" "$(PWD)/gflags_unittest" \
"$(top_srcdir)"
# These aren't part of the c++ source, but we want them to be distributed # These aren't part of the c++ source, but we want them to be distributed
PYTHON = python/setup.py \ PYTHON = python/setup.py \
......
...@@ -45,11 +45,12 @@ host_triplet = @host@ ...@@ -45,11 +45,12 @@ host_triplet = @host@
@GCC_TRUE@am__append_1 = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare @GCC_TRUE@am__append_1 = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
noinst_PROGRAMS = $(am__EXEEXT_1) noinst_PROGRAMS = $(am__EXEEXT_1)
DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(dist_noinst_DATA) $(googleinclude_HEADERS) \ $(dist_noinst_DATA) $(gflagsinclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(googleinclude_HEADERS) $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(top_srcdir)/src/config.h.in \ $(srcdir)/Makefile.in $(top_srcdir)/configure \
$(top_srcdir)/src/google/gflags.h.in \ $(top_srcdir)/src/config.h.in \
$(top_srcdir)/src/google/gflags_completions.h.in AUTHORS \ $(top_srcdir)/src/gflags/gflags.h.in \
$(top_srcdir)/src/gflags/gflags_completions.h.in AUTHORS \
COPYING ChangeLog INSTALL NEWS compile config.guess config.sub \ COPYING ChangeLog INSTALL NEWS compile config.guess config.sub \
depcomp install-sh ltmain.sh missing mkinstalldirs depcomp install-sh ltmain.sh missing mkinstalldirs
subdir = . subdir = .
...@@ -65,8 +66,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ ...@@ -65,8 +66,8 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES = src/google/gflags.h \ CONFIG_CLEAN_FILES = src/gflags/gflags.h \
src/google/gflags_completions.h src/gflags/gflags_completions.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \ am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
...@@ -74,7 +75,8 @@ am__vpath_adj = case $$p in \ ...@@ -74,7 +75,8 @@ am__vpath_adj = case $$p in \
esac; esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(docdir)" "$(DESTDIR)$(googleincludedir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(gflagsincludedir)" \
"$(DESTDIR)$(googleincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL) libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 = am__DEPENDENCIES_1 =
...@@ -135,8 +137,9 @@ DIST_SOURCES = $(libgflags_la_SOURCES) \ ...@@ -135,8 +137,9 @@ DIST_SOURCES = $(libgflags_la_SOURCES) \
$(gflags_unittest3_SOURCES) $(gflags_unittest3_SOURCES)
dist_docDATA_INSTALL = $(INSTALL_DATA) dist_docDATA_INSTALL = $(INSTALL_DATA)
DATA = $(dist_doc_DATA) $(dist_noinst_DATA) DATA = $(dist_doc_DATA) $(dist_noinst_DATA)
gflagsincludeHEADERS_INSTALL = $(INSTALL_HEADER)
googleincludeHEADERS_INSTALL = $(INSTALL_HEADER) googleincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(googleinclude_HEADERS) HEADERS = $(gflagsinclude_HEADERS) $(googleinclude_HEADERS)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
...@@ -216,7 +219,7 @@ ac_ct_F77 = @ac_ct_F77@ ...@@ -216,7 +219,7 @@ ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@ ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@ ac_ct_STRIP = @ac_ct_STRIP@
ac_cv___attribute__unused = @ac_cv___attribute__unused@ ac_cv___attribute__unused = @ac_cv___attribute__unused@
ac_cv_have___uint16 = @ac_cv_have___uint16@ ac_cv_have___int16 = @ac_cv_have___int16@
ac_cv_have_inttypes_h = @ac_cv_have_inttypes_h@ ac_cv_have_inttypes_h = @ac_cv_have_inttypes_h@
ac_cv_have_stdint_h = @ac_cv_have_stdint_h@ ac_cv_have_stdint_h = @ac_cv_have_stdint_h@
ac_cv_have_systypes_h = @ac_cv_have_systypes_h@ ac_cv_have_systypes_h = @ac_cv_have_systypes_h@
...@@ -267,11 +270,15 @@ target_alias = @target_alias@ ...@@ -267,11 +270,15 @@ target_alias = @target_alias@
# Make sure that when we re-make ./configure, we get the macros we need # Make sure that when we re-make ./configure, we get the macros we need
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
# This is so we can #include <google/foo> # This is so we can #include <gflags/foo>
AM_CPPFLAGS = -I$(top_srcdir)/src AM_CPPFLAGS = -I$(top_srcdir)/src
# This is mostly based on configure options # This is mostly based on configure options
AM_CXXFLAGS = $(am__append_1) AM_CXXFLAGS = $(am__append_1)
gflagsincludedir = $(includedir)/gflags
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_completions.h
# This is for backwards compatibility only.
googleincludedir = $(includedir)/google googleincludedir = $(includedir)/google
googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h
bin_SCRIPTS = src/gflags_completions.sh bin_SCRIPTS = src/gflags_completions.sh
...@@ -286,22 +293,26 @@ lib_LTLIBRARIES = libgflags.la ...@@ -286,22 +293,26 @@ lib_LTLIBRARIES = libgflags.la
# We also want to test that things work properly when the file that # We also want to test that things work properly when the file that
# holds main() has a name ending with -main or _main. To keep the # holds main() has a name ending with -main or _main. To keep the
# Makefile small :-), we test the no-threads version of these. # Makefile small :-), we test the no-threads version of these.
TESTS = gflags_unittest gflags_nothreads_unittest gflags_unittest2 \ TESTS = gflags_unittest$(EXEEXT) gflags_nothreads_unittest$(EXEEXT) \
gflags_unittest3 gflags_unittest2$(EXEEXT) gflags_unittest3$(EXEEXT)
TESTS_ENVIRONMENT = SRCDIR="$(top_srcdir)" TESTS_ENVIRONMENT = SRCDIR="$(top_srcdir)"
# Some buggy sh's ignore "" instead of treating it as a positional
# parameter. Since we use "" in this script, we prefer bash if we
# can. If there's no bash, we fall back to sh.
check_SCRIPTS = gflags_unittest_sh check_SCRIPTS = gflags_unittest_sh
# Every time you add a unittest to check_SCRIPTS, add it here too # Every time you add a unittest to check_SCRIPTS, add it here too
noinst_SCRIPTS = src/gflags_unittest.sh noinst_SCRIPTS = src/gflags_unittest.sh
# Used for auto-generated source files # Used for auto-generated source files
CLEANFILES = src/gflags_unittest-main.cc src/gflags_unittest_main.cc CLEANFILES = src/gflags_unittest-main.cc src/gflags_unittest_main.cc
libgflags_la_SOURCES = $(googleinclude_HEADERS) src/config.h \ libgflags_la_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags.cc src/gflags_reporting.cc \ src/gflags.cc src/gflags_reporting.cc \
src/gflags_completions.cc src/gflags_completions.cc
libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG
libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS) libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS)
libgflags_la_LIBADD = $(PTHREAD_LIBS) libgflags_la_LIBADD = $(PTHREAD_LIBS)
gflags_unittest_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest.cc src/gflags_unittest.cc
gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
...@@ -309,15 +320,15 @@ gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS) ...@@ -309,15 +320,15 @@ gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS) gflags_unittest_LDADD = libgflags.la $(PTHREAD_LIBS)
gflags_nothreads_unittest_SOURCES = $(gflags_unittest_SOURCES) gflags_nothreads_unittest_SOURCES = $(gflags_unittest_SOURCES)
gflags_nothreads_unittest_LDADD = libgflags.la gflags_nothreads_unittest_LDADD = libgflags.la
gflags_unittest2_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest2_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest-main.cc src/gflags_unittest-main.cc
gflags_unittest2_LDADD = libgflags.la gflags_unittest2_LDADD = libgflags.la
gflags_unittest3_SOURCES = $(googleinclude_HEADERS) src/config.h \ gflags_unittest3_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
src/gflags_unittest_main.cc src/gflags_unittest_main.cc
gflags_unittest3_LDADD = libgflags.la gflags_unittest3_LDADD = libgflags.la
dist_noinst_DATA = $(top_srcdir)/src/gflags_unittest_flagfile dist_noinst_DATA = src/gflags_unittest_flagfile
# These aren't part of the c++ source, but we want them to be distributed # These aren't part of the c++ source, but we want them to be distributed
PYTHON = python/setup.py \ PYTHON = python/setup.py \
...@@ -382,9 +393,9 @@ $(top_srcdir)/src/config.h.in: $(am__configure_deps) ...@@ -382,9 +393,9 @@ $(top_srcdir)/src/config.h.in: $(am__configure_deps)
distclean-hdr: distclean-hdr:
-rm -f src/config.h src/stamp-h1 -rm -f src/config.h src/stamp-h1
src/google/gflags.h: $(top_builddir)/config.status $(top_srcdir)/src/google/gflags.h.in src/gflags/gflags.h: $(top_builddir)/config.status $(top_srcdir)/src/gflags/gflags.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@ cd $(top_builddir) && $(SHELL) ./config.status $@
src/google/gflags_completions.h: $(top_builddir)/config.status $(top_srcdir)/src/google/gflags_completions.h.in src/gflags/gflags_completions.h: $(top_builddir)/config.status $(top_srcdir)/src/gflags/gflags_completions.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@ cd $(top_builddir) && $(SHELL) ./config.status $@
install-libLTLIBRARIES: $(lib_LTLIBRARIES) install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
...@@ -592,6 +603,23 @@ uninstall-dist_docDATA: ...@@ -592,6 +603,23 @@ uninstall-dist_docDATA:
echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \ echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \
rm -f "$(DESTDIR)$(docdir)/$$f"; \ rm -f "$(DESTDIR)$(docdir)/$$f"; \
done done
install-gflagsincludeHEADERS: $(gflagsinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(gflagsincludedir)" || $(mkdir_p) "$(DESTDIR)$(gflagsincludedir)"
@list='$(gflagsinclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(gflagsincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(gflagsincludedir)/$$f'"; \
$(gflagsincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(gflagsincludedir)/$$f"; \
done
uninstall-gflagsincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(gflagsinclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(gflagsincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(gflagsincludedir)/$$f"; \
done
install-googleincludeHEADERS: $(googleinclude_HEADERS) install-googleincludeHEADERS: $(googleinclude_HEADERS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
test -z "$(googleincludedir)" || $(mkdir_p) "$(DESTDIR)$(googleincludedir)" test -z "$(googleincludedir)" || $(mkdir_p) "$(DESTDIR)$(googleincludedir)"
...@@ -734,7 +762,7 @@ check-TESTS: $(TESTS) ...@@ -734,7 +762,7 @@ check-TESTS: $(TESTS)
distdir: $(DISTFILES) distdir: $(DISTFILES)
$(am__remove_distdir) $(am__remove_distdir)
mkdir $(distdir) mkdir $(distdir)
$(mkdir_p) $(distdir)/doc $(distdir)/m4 $(distdir)/packages $(distdir)/packages/rpm $(distdir)/python $(distdir)/src $(distdir)/src/google $(mkdir_p) $(distdir)/doc $(distdir)/m4 $(distdir)/packages $(distdir)/packages/rpm $(distdir)/python $(distdir)/src $(distdir)/src/gflags $(distdir)/src/google
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \ list='$(DISTFILES)'; for file in $$list; do \
...@@ -865,7 +893,7 @@ check: check-am ...@@ -865,7 +893,7 @@ check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \ all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \
$(HEADERS) $(HEADERS)
installdirs: installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(googleincludedir)"; do \ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(gflagsincludedir)" "$(DESTDIR)$(googleincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \ test -z "$$dir" || $(mkdir_p) "$$dir"; \
done done
install: install-am install: install-am
...@@ -915,7 +943,8 @@ info: info-am ...@@ -915,7 +943,8 @@ info: info-am
info-am: info-am:
install-data-am: install-dist_docDATA install-googleincludeHEADERS install-data-am: install-dist_docDATA install-gflagsincludeHEADERS \
install-googleincludeHEADERS
install-exec-am: install-binSCRIPTS install-libLTLIBRARIES install-exec-am: install-binSCRIPTS install-libLTLIBRARIES
...@@ -946,8 +975,8 @@ ps: ps-am ...@@ -946,8 +975,8 @@ ps: ps-am
ps-am: ps-am:
uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \ uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \
uninstall-googleincludeHEADERS uninstall-info-am \ uninstall-gflagsincludeHEADERS uninstall-googleincludeHEADERS \
uninstall-libLTLIBRARIES uninstall-info-am uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ .PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
clean clean-generic clean-libLTLIBRARIES clean-libtool \ clean clean-generic clean-libLTLIBRARIES clean-libtool \
...@@ -958,13 +987,14 @@ uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \ ...@@ -958,13 +987,14 @@ uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \
distuninstallcheck dvi dvi-am html html-am info info-am \ distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-binSCRIPTS install-data \ install install-am install-binSCRIPTS install-data \
install-data-am install-dist_docDATA install-exec \ install-data-am install-dist_docDATA install-exec \
install-exec-am install-googleincludeHEADERS install-info \ install-exec-am install-gflagsincludeHEADERS \
install-info-am install-libLTLIBRARIES install-man \ install-googleincludeHEADERS install-info install-info-am \
install-strip installcheck installcheck-am installdirs \ install-libLTLIBRARIES install-man install-strip installcheck \
maintainer-clean maintainer-clean-generic mostlyclean \ installcheck-am installdirs maintainer-clean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ maintainer-clean-generic mostlyclean mostlyclean-compile \
pdf pdf-am ps ps-am tags uninstall uninstall-am \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
uninstall-binSCRIPTS uninstall-dist_docDATA \ tags uninstall uninstall-am uninstall-binSCRIPTS \
uninstall-dist_docDATA uninstall-gflagsincludeHEADERS \
uninstall-googleincludeHEADERS uninstall-info-am \ uninstall-googleincludeHEADERS uninstall-info-am \
uninstall-libLTLIBRARIES uninstall-libLTLIBRARIES
...@@ -974,8 +1004,12 @@ src/gflags_unittest-main.cc: src/gflags_unittest.cc ...@@ -974,8 +1004,12 @@ src/gflags_unittest-main.cc: src/gflags_unittest.cc
src/gflags_unittest_main.cc: src/gflags_unittest.cc src/gflags_unittest_main.cc: src/gflags_unittest.cc
rm -f src/gflags_unittest_main.cc rm -f src/gflags_unittest_main.cc
cp -p src/gflags_unittest.cc src/gflags_unittest_main.cc cp -p src/gflags_unittest.cc src/gflags_unittest_main.cc
gflags_unittest_sh: gflags_unittest gflags_unittest2 gflags_unittest3 gflags_unittest_sh: gflags_unittest$(EXEEXT) \
$(top_srcdir)/src/gflags_unittest.sh $(PWD)/$< $(top_srcdir) gflags_unittest2$(EXEEXT) \
gflags_unittest3$(EXEEXT)
bash --version >/dev/null && export SH=bash || export SH=sh; \
$$SH "$(top_srcdir)/src/gflags_unittest.sh" "$(PWD)/gflags_unittest" \
"$(top_srcdir)"
rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
@cd packages && ./rpm.sh ${PACKAGE} ${VERSION} @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
......
...@@ -15,11 +15,41 @@ ...@@ -15,11 +15,41 @@
set -ex set -ex
rm -rf autom4te.cache rm -rf autom4te.cache
aclocal --force -I m4 trap 'rm -f aclocal.m4.tmp' EXIT
grep -q LIBTOOL configure.ac && libtoolize -c -f
# Use version 1.9 of aclocal and automake if available.
ACLOCAL=aclocal-1.9
if test -z `which "$ACLOCAL"`; then
ACLOCAL=aclocal
fi
AUTOMAKE=automake-1.9
if test -z `which "$AUTOMAKE"`; then
AUTOMAKE=automake
fi
# glibtoolize is used for Mac OS X
LIBTOOLIZE=libtoolize
if test -z `which "$LIBTOOLIZE"`; then
LIBTOOLIZE=glibtoolize
fi
# aclocal tries to overwrite aclocal.m4 even if the contents haven't
# changed, which is annoying when the file is not open for edit (in
# p4). We work around this by writing to a temp file and just
# updating the timestamp if the file hasn't change.
"$ACLOCAL" --force -I m4 --output=aclocal.m4.tmp
if cmp aclocal.m4.tmp aclocal.m4; then
touch aclocal.m4 # pretend that we regenerated the file
rm -f aclocal.m4.tmp
else
mv aclocal.m4.tmp aclocal.m4 # we did set -e above, so we die if this fails
fi
grep -q LIBTOOL configure.ac && "$LIBTOOLIZE" -c -f
autoconf -f -W all,no-obsolete autoconf -f -W all,no-obsolete
autoheader -f -W all autoheader -f -W all
automake -a -c -f -W all "$AUTOMAKE" -a -c -f -W all
rm -rf autom4te.cache rm -rf autom4te.cache
exit 0 exit 0
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for gflags 0.9. # Generated by GNU Autoconf 2.59 for gflags 1.0rc1.
# #
# Report bugs to <opensource@google.com>. # Report bugs to <opensource@google.com>.
# #
...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} ...@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package. # Identity of this package.
PACKAGE_NAME='gflags' PACKAGE_NAME='gflags'
PACKAGE_TARNAME='gflags' PACKAGE_TARNAME='gflags'
PACKAGE_VERSION='0.9' PACKAGE_VERSION='1.0rc1'
PACKAGE_STRING='gflags 0.9' PACKAGE_STRING='gflags 1.0rc1'
PACKAGE_BUGREPORT='opensource@google.com' PACKAGE_BUGREPORT='opensource@google.com'
ac_unique_file="README" ac_unique_file="README"
...@@ -465,7 +465,7 @@ ac_includes_default="\ ...@@ -465,7 +465,7 @@ ac_includes_default="\
# include <unistd.h> # include <unistd.h>
#endif" #endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE GCC_TRUE GCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS ac_google_start_namespace ac_google_end_namespace ac_google_namespace ac_cv___attribute__unused ac_cv_have_stdint_h ac_cv_have_systypes_h ac_cv_have_inttypes_h ac_cv_have_uint16_t ac_cv_have_u_int16_t ac_cv_have___uint16 LIBOBJS LTLIBOBJS' ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE GCC_TRUE GCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS ac_google_start_namespace ac_google_end_namespace ac_google_namespace ac_cv___attribute__unused ac_cv_have_stdint_h ac_cv_have_systypes_h ac_cv_have_inttypes_h ac_cv_have_uint16_t ac_cv_have_u_int16_t ac_cv_have___int16 LIBOBJS LTLIBOBJS'
ac_subst_files='' ac_subst_files=''
# Initialize some variables set by options. # Initialize some variables set by options.
...@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then ...@@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures gflags 0.9 to adapt to many kinds of systems. \`configure' configures gflags 1.0rc1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1020,7 +1020,7 @@ fi ...@@ -1020,7 +1020,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of gflags 0.9:";; short | recursive ) echo "Configuration of gflags 1.0rc1:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1163,7 +1163,7 @@ fi ...@@ -1163,7 +1163,7 @@ fi
test -n "$ac_init_help" && exit 0 test -n "$ac_init_help" && exit 0
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
gflags configure 0.9 gflags configure 1.0rc1
generated by GNU Autoconf 2.59 generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003 Free Software Foundation, Inc.
...@@ -1177,7 +1177,7 @@ cat >&5 <<_ACEOF ...@@ -1177,7 +1177,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by gflags $as_me 0.9, which was It was created by gflags $as_me 1.0rc1, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -1823,7 +1823,7 @@ fi ...@@ -1823,7 +1823,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='gflags' PACKAGE='gflags'
VERSION='0.9' VERSION='1.0rc1'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
...@@ -19185,6 +19185,156 @@ fi ...@@ -19185,6 +19185,156 @@ fi
for ac_header in fnmatch.h windows.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to opensource@google.com ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
# These are the types I need. We look for them in either stdint.h, # These are the types I need. We look for them in either stdint.h,
# sys/types.h, or inttypes.h, all of which are part of the default-includes. # sys/types.h, or inttypes.h, all of which are part of the default-includes.
echo "$as_me:$LINENO: checking for uint16_t" >&5 echo "$as_me:$LINENO: checking for uint16_t" >&5
...@@ -19309,9 +19459,9 @@ else ...@@ -19309,9 +19459,9 @@ else
ac_cv_have_u_int16_t=0 ac_cv_have_u_int16_t=0
fi fi
echo "$as_me:$LINENO: checking for __uint16" >&5 echo "$as_me:$LINENO: checking for __int16" >&5
echo $ECHO_N "checking for __uint16... $ECHO_C" >&6 echo $ECHO_N "checking for __int16... $ECHO_C" >&6
if test "${ac_cv_type___uint16+set}" = set; then if test "${ac_cv_type___int16+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6 echo $ECHO_N "(cached) $ECHO_C" >&6
else else
cat >conftest.$ac_ext <<_ACEOF cat >conftest.$ac_ext <<_ACEOF
...@@ -19324,9 +19474,9 @@ $ac_includes_default ...@@ -19324,9 +19474,9 @@ $ac_includes_default
int int
main () main ()
{ {
if ((__uint16 *) 0) if ((__int16 *) 0)
return 0; return 0;
if (sizeof (__uint16)) if (sizeof (__int16))
return 0; return 0;
; ;
return 0; return 0;
...@@ -19353,26 +19503,26 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ...@@ -19353,26 +19503,26 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$? ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
ac_cv_type___uint16=yes ac_cv_type___int16=yes
else else
echo "$as_me: failed program was:" >&5 echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type___uint16=no ac_cv_type___int16=no
fi fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi fi
echo "$as_me:$LINENO: result: $ac_cv_type___uint16" >&5 echo "$as_me:$LINENO: result: $ac_cv_type___int16" >&5
echo "${ECHO_T}$ac_cv_type___uint16" >&6 echo "${ECHO_T}$ac_cv_type___int16" >&6
if test $ac_cv_type___uint16 = yes; then if test $ac_cv_type___int16 = yes; then
ac_cv_have___uint16=1 ac_cv_have___int16=1
else else
ac_cv_have___uint16=0 ac_cv_have___int16=0
fi fi
for ac_func in strtoll for ac_func in InitializeCriticalSection
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5
...@@ -19473,7 +19623,109 @@ fi ...@@ -19473,7 +19623,109 @@ fi
done done
for ac_func in strtoq for ac_func in InterlockedCompareExchange
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $ac_func innocuous_$ac_func
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $ac_func
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in strtoll strtoq
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5
...@@ -20617,7 +20869,7 @@ _ACEOF ...@@ -20617,7 +20869,7 @@ _ACEOF
## Check out ../autoconf/ for other macros you can call to do useful stuff ## Check out ../autoconf/ for other macros you can call to do useful stuff
# Write generated configuration file, and also .h files # Write generated configuration file, and also .h files
ac_config_files="$ac_config_files Makefile src/google/gflags.h src/google/gflags_completions.h" ac_config_files="$ac_config_files Makefile src/gflags/gflags.h src/gflags/gflags_completions.h"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
...@@ -21009,7 +21261,7 @@ _ASBOX ...@@ -21009,7 +21261,7 @@ _ASBOX
} >&5 } >&5
cat >&5 <<_CSEOF cat >&5 <<_CSEOF
This file was extended by gflags $as_me 0.9, which was This file was extended by gflags $as_me 1.0rc1, which was
generated by GNU Autoconf 2.59. Invocation command line was generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -21072,7 +21324,7 @@ _ACEOF ...@@ -21072,7 +21324,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\ ac_cs_version="\\
gflags config.status 0.9 gflags config.status 1.0rc1
configured by $0, generated by GNU Autoconf 2.59, configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
...@@ -21183,8 +21435,8 @@ do ...@@ -21183,8 +21435,8 @@ do
case "$ac_config_target" in case "$ac_config_target" in
# Handling of arguments. # Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/google/gflags.h" ) CONFIG_FILES="$CONFIG_FILES src/google/gflags.h" ;; "src/gflags/gflags.h" ) CONFIG_FILES="$CONFIG_FILES src/gflags/gflags.h" ;;
"src/google/gflags_completions.h" ) CONFIG_FILES="$CONFIG_FILES src/google/gflags_completions.h" ;; "src/gflags/gflags_completions.h" ) CONFIG_FILES="$CONFIG_FILES src/gflags/gflags_completions.h" ;;
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"src/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "src/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
...@@ -21353,7 +21605,7 @@ s,@ac_cv_have_systypes_h@,$ac_cv_have_systypes_h,;t t ...@@ -21353,7 +21605,7 @@ s,@ac_cv_have_systypes_h@,$ac_cv_have_systypes_h,;t t
s,@ac_cv_have_inttypes_h@,$ac_cv_have_inttypes_h,;t t s,@ac_cv_have_inttypes_h@,$ac_cv_have_inttypes_h,;t t
s,@ac_cv_have_uint16_t@,$ac_cv_have_uint16_t,;t t s,@ac_cv_have_uint16_t@,$ac_cv_have_uint16_t,;t t
s,@ac_cv_have_u_int16_t@,$ac_cv_have_u_int16_t,;t t s,@ac_cv_have_u_int16_t@,$ac_cv_have_u_int16_t,;t t
s,@ac_cv_have___uint16@,$ac_cv_have___uint16,;t t s,@ac_cv_have___int16@,$ac_cv_have___int16,;t t
s,@LIBOBJS@,$LIBOBJS,;t t s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF CEOF
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# make sure we're interpreted by some minimal autoconf # make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT(gflags, 0.9, opensource@google.com) AC_INIT(gflags, 1.0rc1, opensource@google.com)
# The argument here is just something that should be in the current directory # The argument here is just something that should be in the current directory
# (for sanity checking) # (for sanity checking)
AC_CONFIG_SRCDIR(README) AC_CONFIG_SRCDIR(README)
...@@ -28,15 +28,17 @@ AC_HEADER_STDC ...@@ -28,15 +28,17 @@ AC_HEADER_STDC
AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0) AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0) AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0) AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
AC_CHECK_HEADERS([fnmatch.h windows.h])
# These are the types I need. We look for them in either stdint.h, # These are the types I need. We look for them in either stdint.h,
# sys/types.h, or inttypes.h, all of which are part of the default-includes. # sys/types.h, or inttypes.h, all of which are part of the default-includes.
AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0) AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0) AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
AC_CHECK_TYPE(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0) AC_CHECK_TYPE(__int16, ac_cv_have___int16=1, ac_cv_have___int16=0)
AC_CHECK_FUNCS(strtoll) AC_CHECK_FUNCS([InitializeCriticalSection])
AC_CHECK_FUNCS(strtoq) AC_CHECK_FUNCS([InterlockedCompareExchange])
AC_CHECK_FUNCS([strtoll strtoq])
AX_C___ATTRIBUTE__ AX_C___ATTRIBUTE__
# We only care about __attribute__ ((unused)) # We only care about __attribute__ ((unused))
...@@ -63,10 +65,10 @@ AC_SUBST(ac_cv_have_systypes_h) ...@@ -63,10 +65,10 @@ AC_SUBST(ac_cv_have_systypes_h)
AC_SUBST(ac_cv_have_inttypes_h) AC_SUBST(ac_cv_have_inttypes_h)
AC_SUBST(ac_cv_have_uint16_t) AC_SUBST(ac_cv_have_uint16_t)
AC_SUBST(ac_cv_have_u_int16_t) AC_SUBST(ac_cv_have_u_int16_t)
AC_SUBST(ac_cv_have___uint16) AC_SUBST(ac_cv_have___int16)
## Check out ../autoconf/ for other macros you can call to do useful stuff ## Check out ../autoconf/ for other macros you can call to do useful stuff
# Write generated configuration file, and also .h files # Write generated configuration file, and also .h files
AC_CONFIG_FILES([Makefile src/google/gflags.h src/google/gflags_completions.h]) AC_CONFIG_FILES([Makefile src/gflags/gflags.h src/gflags/gflags_completions.h])
AC_OUTPUT AC_OUTPUT
The list of files here isn't complete. For a step-by-step guide on
how to set this package up correctly, check out
http://www.debian.org/doc/maint-guide/
Most of the files that are in this directory are boilerplate.
However, you may need to change the list of binary-arch dependencies
in 'rules'.
google-gflags (1.0rc1-1) unstable; urgency=low
* New upstream release.
-- Google Inc. <opensource@google.com> Tue, 19 Aug 2008 16:15:48 -0700
google-gflags (0.9-1) unstable; urgency=low google-gflags (0.9-1) unstable; urgency=low
* New upstream release. * New upstream release.
......
usr/lib usr/lib
usr/include usr/include
usr/include/google usr/include/google
usr/include/gflags
usr/include/google/* usr/include/google/*
usr/include/gflags/*
usr/lib/lib*.so usr/lib/lib*.so
usr/lib/lib*.a usr/lib/lib*.a
usr/lib/*.la usr/lib/*.la
debian/tmp/usr/include/google/* debian/tmp/usr/include/google/*
debian/tmp/usr/include/gflags/*
debian/tmp/usr/lib/lib*.so debian/tmp/usr/lib/lib*.so
debian/tmp/usr/lib/lib*.a debian/tmp/usr/lib/lib*.a
debian/tmp/usr/lib/*.la debian/tmp/usr/lib/*.la
...@@ -52,7 +52,13 @@ rm -rf $RPM_BUILD_ROOT ...@@ -52,7 +52,13 @@ rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README doc/designstyle.css doc/gflags.html ## Mark all installed files within /usr/share/doc/{package name} as
## documentation. This depends on the following two lines appearing in
## Makefile.am:
## docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
## dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README
%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
%{prefix}/share/doc/%{NAME}-%{VERSION}/*
%{prefix}/lib/libgflags.so.0 %{prefix}/lib/libgflags.so.0
%{prefix}/lib/libgflags.so.0.0.0 %{prefix}/lib/libgflags.so.0.0.0
...@@ -62,6 +68,7 @@ rm -rf $RPM_BUILD_ROOT ...@@ -62,6 +68,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root) %defattr(-,root,root)
%{prefix}/include/google %{prefix}/include/google
%{prefix}/include/gflags
%{prefix}/lib/libgflags.a %{prefix}/lib/libgflags.a
%{prefix}/lib/libgflags.la %{prefix}/lib/libgflags.la
%{prefix}/lib/libgflags.so %{prefix}/lib/libgflags.so
...@@ -6,6 +6,15 @@ ...@@ -6,6 +6,15 @@
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #undef HAVE_DLFCN_H
/* Define to 1 if you have the <fnmatch.h> header file. */
#undef HAVE_FNMATCH_H
/* Define to 1 if you have the `InitializeCriticalSection' function. */
#undef HAVE_INITIALIZECRITICALSECTION
/* Define to 1 if you have the `InterlockedCompareExchange' function. */
#undef HAVE_INTERLOCKEDCOMPAREEXCHANGE
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H
...@@ -45,6 +54,9 @@ ...@@ -45,6 +54,9 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* define if your compiler has __attribute__ */ /* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__ #undef HAVE___ATTRIBUTE__
......
...@@ -89,20 +89,34 @@ ...@@ -89,20 +89,34 @@
// are, similarly, mostly hooks into the functionality described above. // are, similarly, mostly hooks into the functionality described above.
#include "config.h" #include "config.h"
// This comes first to ensure we define __STDC_FORMAT_MACROS in time.
#ifdef HAVE_INTTYPES_H
#ifndef __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 <stdio.h> // for snprintf
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h> #include <fnmatch.h>
#endif // HAVE_FNMATCH_H
#ifdef HAVE_PTHREAD
#include <pthread.h> #include <pthread.h>
#endif // HAVE_PTHREAD
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif // HAVE_WINDOWS_H
#include <iostream> // for cerr #include <iostream> // for cerr
#include <string> #include <string>
#include <map> #include <map>
#include <vector> #include <vector>
#include <utility> // for pair<> #include <utility> // for pair<>
#include <algorithm> #include <algorithm>
#include "google/gflags.h" #include "gflags/gflags.h"
#ifndef PATH_SEPARATOR #ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/' #define PATH_SEPARATOR '/'
...@@ -121,17 +135,31 @@ ...@@ -121,17 +135,31 @@
# define strtouint64 strtoul # define strtouint64 strtoul
#endif #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
using std::string; using std::string;
using std::map; using std::map;
using std::vector; using std::vector;
using std::pair; using std::pair;
using std::cerr; using std::cerr;
using std::sort;
// Special flags, type 1: the 'recursive' flags. They set another flag's val. // Special flags, type 1: the 'recursive' flags. They set another flag's val.
DEFINE_string(flagfile, "", DEFINE_string(flagfile, "",
"load flags from file"); "load flags from file");
DEFINE_string(fromenv, "", DEFINE_string(fromenv, "",
"set flags from the environment [use 'export FLAGS_flag1=value']"); "set flags from the environment"
" [use 'export FLAGS_flag1=value']");
DEFINE_string(tryfromenv, "", DEFINE_string(tryfromenv, "",
"set flags from the environment if present"); "set flags from the environment if present");
...@@ -147,7 +175,7 @@ _START_GOOGLE_NAMESPACE_ ...@@ -147,7 +175,7 @@ _START_GOOGLE_NAMESPACE_
// The help message indicating that the commandline flag has been // The help message indicating that the commandline flag has been
// 'stripped'. It will not show up when doing "-help" and its // 'stripped'. It will not show up when doing "-help" and its
// variants. The flag is stripped if STRIP_FLAG_HELP is set to 1 // variants. The flag is stripped if STRIP_FLAG_HELP is set to 1
// before including google/gflags.h. // before including gflags/gflags.h.
// This is used by this file, and also in commandlineflags_reporting.cc // This is used by this file, and also in commandlineflags_reporting.cc
const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001"; const char kStrippedFlagHelp[] = "\001\002\003\004 (unknown) \004\003\002\001";
...@@ -250,7 +278,7 @@ bool FlagValue::ParseFrom(const char* value) { ...@@ -250,7 +278,7 @@ bool FlagValue::ParseFrom(const char* value) {
if (type_ == FV_BOOL) { if (type_ == FV_BOOL) {
const char* kTrue[] = { "1", "t", "true", "y", "yes" }; const char* kTrue[] = { "1", "t", "true", "y", "yes" };
const char* kFalse[] = { "0", "f", "false", "n", "no" }; const char* kFalse[] = { "0", "f", "false", "n", "no" };
for (int i = 0; i < sizeof(kTrue)/sizeof(*kTrue); ++i) { for (size_t i = 0; i < sizeof(kTrue)/sizeof(*kTrue); ++i) {
if (strcasecmp(value, kTrue[i]) == 0) { if (strcasecmp(value, kTrue[i]) == 0) {
SET_VALUE_AS(bool, true); SET_VALUE_AS(bool, true);
return true; return true;
...@@ -319,13 +347,13 @@ string FlagValue::ToString() const { ...@@ -319,13 +347,13 @@ string FlagValue::ToString() const {
case FV_BOOL: case FV_BOOL:
return VALUE_AS(bool) ? "true" : "false"; return VALUE_AS(bool) ? "true" : "false";
case FV_INT32: case FV_INT32:
snprintf(intbuf, sizeof(intbuf), "%d", VALUE_AS(int32)); snprintf(intbuf, sizeof(intbuf), "%"PRId32, VALUE_AS(int32));
return intbuf; return intbuf;
case FV_INT64: case FV_INT64:
snprintf(intbuf, sizeof(intbuf), "%lld", VALUE_AS(int64)); snprintf(intbuf, sizeof(intbuf), "%"PRId64, VALUE_AS(int64));
return intbuf; return intbuf;
case FV_UINT64: case FV_UINT64:
snprintf(intbuf, sizeof(intbuf), "%llu", VALUE_AS(uint64)); snprintf(intbuf, sizeof(intbuf), "%"PRIu64, VALUE_AS(uint64));
return intbuf; return intbuf;
case FV_DOUBLE: case FV_DOUBLE:
snprintf(intbuf, sizeof(intbuf), "%.17g", VALUE_AS(double)); snprintf(intbuf, sizeof(intbuf), "%.17g", VALUE_AS(double));
...@@ -333,7 +361,8 @@ string FlagValue::ToString() const { ...@@ -333,7 +361,8 @@ string FlagValue::ToString() const {
case FV_STRING: case FV_STRING:
return VALUE_AS(string); return VALUE_AS(string);
default: default:
assert(false); return ""; // unknown type assert(false);
return ""; // unknown type
} }
} }
...@@ -392,13 +421,13 @@ bool FlagValue::Equal(const FlagValue& x) const { ...@@ -392,13 +421,13 @@ bool FlagValue::Equal(const FlagValue& x) const {
FlagValue* FlagValue::New() const { FlagValue* FlagValue::New() const {
switch (type_) { switch (type_) {
case FV_BOOL: return new FlagValue(new bool, "bool"); case FV_BOOL: return new FlagValue(new bool(false), "bool");
case FV_INT32: return new FlagValue(new int32, "int32"); case FV_INT32: return new FlagValue(new int32(0), "int32");
case FV_INT64: return new FlagValue(new int64, "int64"); case FV_INT64: return new FlagValue(new int64(0), "int64");
case FV_UINT64: return new FlagValue(new uint64, "uint64"); case FV_UINT64: return new FlagValue(new uint64(0), "uint64");
case FV_DOUBLE: return new FlagValue(new double, "double"); case FV_DOUBLE: return new FlagValue(new double(0.0), "double");
case FV_STRING: return new FlagValue(new string, "string"); case FV_STRING: return new FlagValue(new string, "string");
default: assert(false); return NULL; // assert false default: assert(false); return NULL; // unknown type
} }
} }
...@@ -449,10 +478,12 @@ class CommandLineFlag { ...@@ -449,10 +478,12 @@ class CommandLineFlag {
bool ValidateCurrent() const { return Validate(*current_); } bool ValidateCurrent() const { return Validate(*current_); }
private: private:
friend class FlagRegistry; // for SetFlagLocked() and setting flags_by_ptr_ // for SetFlagLocked() and setting flags_by_ptr_
friend class FlagRegistry;
friend class GOOGLE_NAMESPACE::FlagSaverImpl; // for cloning the values friend class GOOGLE_NAMESPACE::FlagSaverImpl; // for cloning the values
friend bool GetCommandLineOption(const char*, string*, bool*); friend bool GetCommandLineOption(const char*, string*, bool*);
friend bool AddFlagValidator(const void*, ValidateFnProto); // set validate_fn // set validate_fn
friend bool AddFlagValidator(const void*, ValidateFnProto);
// This copies all the non-const members: modified, processed, defvalue, etc. // This copies all the non-const members: modified, processed, defvalue, etc.
void CopyFrom(const CommandLineFlag& src); void CopyFrom(const CommandLineFlag& src);
...@@ -535,9 +566,10 @@ void CommandLineFlag::UpdateModifiedBit() { ...@@ -535,9 +566,10 @@ void CommandLineFlag::UpdateModifiedBit() {
void CommandLineFlag::CopyFrom(const CommandLineFlag& src) { void CommandLineFlag::CopyFrom(const CommandLineFlag& src) {
// Note we only copy the non-const members; others are fixed at construct time // Note we only copy the non-const members; others are fixed at construct time
modified_ = src.modified_; if (modified_ != src.modified_) modified_ = src.modified_;
current_->CopyFrom(*src.current_); if (!current_->Equal(*src.current_)) current_->CopyFrom(*src.current_);
defvalue_->CopyFrom(*src.defvalue_); if (!defvalue_->Equal(*src.defvalue_)) defvalue_->CopyFrom(*src.defvalue_);
if (validate_fn_proto_ != src.validate_fn_proto_)
validate_fn_proto_ = src.validate_fn_proto_; validate_fn_proto_ = src.validate_fn_proto_;
} }
...@@ -565,19 +597,17 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s ...@@ -565,19 +597,17 @@ struct StringCmp { // Used by the FlagRegistry map class to compare char*'s
} }
}; };
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
class FlagRegistry { class FlagRegistry {
public: public:
FlagRegistry() { SAFE_PTHREAD(pthread_mutex_init(&lock_, NULL)); } FlagRegistry();
~FlagRegistry() { SAFE_PTHREAD(pthread_mutex_destroy(&lock_)); } ~FlagRegistry();
void Lock();
void Unlock();
// Store a flag in this registry. Takes ownership of the given pointer. // Store a flag in this registry. Takes ownership of the given pointer.
void RegisterFlag(CommandLineFlag* flag); void RegisterFlag(CommandLineFlag* flag);
void Lock() { SAFE_PTHREAD(pthread_mutex_lock(&lock_)); }
void Unlock() { SAFE_PTHREAD(pthread_mutex_unlock(&lock_)); }
// Returns the flag object for the specified name, or NULL if not found. // Returns the flag object for the specified name, or NULL if not found.
CommandLineFlag* FindFlagLocked(const char* name); CommandLineFlag* FindFlagLocked(const char* name);
...@@ -618,12 +648,20 @@ class FlagRegistry { ...@@ -618,12 +648,20 @@ class FlagRegistry {
typedef map<const void*, CommandLineFlag*> FlagPtrMap; typedef map<const void*, CommandLineFlag*> FlagPtrMap;
FlagPtrMap flags_by_ptr_; FlagPtrMap flags_by_ptr_;
#if defined(HAVE_PTHREAD)
pthread_mutex_t lock_; pthread_mutex_t lock_;
#elif defined(HAVE_INITIALIZECRITICALSECTION)
CRITICAL_SECTION lock_;
#else
#error "Need to define a mutual-exclusion object for your system"
#endif
static FlagRegistry* global_registry_; // a singleton registry static FlagRegistry* global_registry_; // a singleton registry
static pthread_once_t global_registry_once_;
static int global_registry_once_nothreads_; // when we don't link pthreads
// If global_registry_ has not yet been initialized, this function allocates
// a new global registry. If InterlockedCompareExchange() is available, it
// does so in a thread-safe manner; otherwise, single-threaded execution (or
// serialization using pthread_once) is assumed.
static void InitGlobalRegistry(); static void InitGlobalRegistry();
// Disallow // Disallow
...@@ -631,14 +669,98 @@ class FlagRegistry { ...@@ -631,14 +669,98 @@ class FlagRegistry {
FlagRegistry& operator=(const FlagRegistry&); FlagRegistry& operator=(const FlagRegistry&);
}; };
class FlagRegistryLock { #if defined(HAVE_PTHREAD)
public: // The pthread.h header is available. The pthreads library may or may not be
explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); } // linked in with -lpthread. If that library is not linked in, then it is
~FlagRegistryLock() { fr_->Unlock(); } // assumed that all operations involving command-line flags will be
private: // single-threaded.
FlagRegistry *const fr_;
};
#define SAFE_PTHREAD(fncall) do { if ((fncall) != 0) abort(); } while (0)
inline FlagRegistry::FlagRegistry() {
SAFE_PTHREAD(pthread_mutex_init(&lock_, NULL));
}
inline FlagRegistry::~FlagRegistry() {
SAFE_PTHREAD(pthread_mutex_destroy(&lock_));
}
inline void FlagRegistry::Lock() {
SAFE_PTHREAD(pthread_mutex_lock(&lock_));
}
inline void FlagRegistry::Unlock() {
SAFE_PTHREAD(pthread_mutex_unlock(&lock_));
}
// We want to use pthread_once here, for safety, but have to worry about
// whether libpthread is linked in or not. We declare a weak version of
// the function, so we'll always compile (if the weak version is the only
// one that ends up existing, then pthread_once will be equal to NULL).
#ifdef HAVE___ATTRIBUTE__
// __THROW is defined in glibc systems. It means, counter-intuitively,
// "This function will never throw an exception." It's an optional
// optimization tool, but we may need to use it to match glibc prototypes.
# ifndef __THROW // I guess we're not on a glibc system
# define __THROW // __THROW is just an optimization, so ok to make it ""
# endif
extern "C" int pthread_once(pthread_once_t *, void (*)(void))
__THROW __attribute__((weak));
#endif
FlagRegistry* FlagRegistry::GlobalRegistry() {
if (pthread_once) { // means we're linked with -lpthread
static pthread_once_t global_registry_once = PTHREAD_ONCE_INIT;
pthread_once(&global_registry_once, &InitGlobalRegistry);
} else {
// Assume single-threaded execution.
InitGlobalRegistry();
}
return global_registry_;
}
#elif defined(HAVE_INITIALIZECRITICALSECTION)
// The Windows version of the thread-safe code uses EnterCriticalSection and
// LeaveCriticalSection to serialize access to the registry.
#ifndef HAVE_INTERLOCKEDCOMPAREEXCHANGE
// InitializeCriticalSection is available, but InterlockedCompareExchange
// is not. On a Windows system both should be available, and on Unix, neither
// one should be available.
#error "Please check settings for HAVE_INTERLOCKED... and HAVE_INITIALIZE..."
#endif // !HAVE_INTERLOCKEDCOMPAREEXCHANGE
inline FlagRegistry::FlagRegistry() { InitializeCriticalSection(&lock_); }
inline FlagRegistry::~FlagRegistry() { DeleteCriticalSection(&lock_); }
inline void FlagRegistry::Lock() { EnterCriticalSection(&lock_); }
inline void FlagRegistry::Unlock() { LeaveCriticalSection(&lock_); }
FlagRegistry* FlagRegistry::GlobalRegistry() {
InitGlobalRegistry();
return global_registry_;
}
#endif // !HAVE_PTHREAD && HAVE_INITIALIZECRITICALSECTION
// Get the singleton FlagRegistry object
FlagRegistry* FlagRegistry::global_registry_ = NULL;
void FlagRegistry::InitGlobalRegistry() {
if (!global_registry_) {
#ifdef HAVE_INTERLOCKEDCOMPAREEXCHANGE
FlagRegistry* new_global_registry = new FlagRegistry;
if (InterlockedCompareExchangePointer(
reinterpret_cast<void* volatile *>(&global_registry_),
new_global_registry,
NULL) != NULL) {
// Some other thread initialized global_registry_ first.
delete new_global_registry;
}
#else // !HAVE_INTERLOCKEDCOMPAREEXCHANGE
// Assume single-threaded execution, or else that this function call was
// serialized using pthread_once.
global_registry_ = new FlagRegistry;
#endif // HAVE_INTERLOCKEDCOMPAREEXCHANGE
}
}
void FlagRegistry::RegisterFlag(CommandLineFlag* flag) { void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
Lock(); Lock();
...@@ -756,7 +878,7 @@ bool TryParseLocked(const CommandLineFlag* flag, FlagValue* flag_value, ...@@ -756,7 +878,7 @@ bool TryParseLocked(const CommandLineFlag* flag, FlagValue* flag_value,
delete tentative_value; delete tentative_value;
return false; return false;
} else if (!flag->Validate(*tentative_value)) { } else if (!flag->Validate(*tentative_value)) {
if (msg){ if (msg) {
*msg += (string(kError) + "failed validation of new value " *msg += (string(kError) + "failed validation of new value "
+ "'" + tentative_value->ToString() + "' for flag '" + + "'" + tentative_value->ToString() + "' for flag '" +
+ flag->name() + "'\n"); + flag->name() + "'\n");
...@@ -810,46 +932,21 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag, ...@@ -810,46 +932,21 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
} }
default: { default: {
// unknown set_mode // unknown set_mode
assert(false); return false; assert(false);
return false;
} }
} }
return true; return true;
} }
// Get the singleton FlagRegistry object class FlagRegistryLock {
FlagRegistry* FlagRegistry::global_registry_ = NULL; public:
pthread_once_t FlagRegistry::global_registry_once_ = PTHREAD_ONCE_INIT; explicit FlagRegistryLock(FlagRegistry* fr) : fr_(fr) { fr_->Lock(); }
int FlagRegistry::global_registry_once_nothreads_ = 0; ~FlagRegistryLock() { fr_->Unlock(); }
private:
void FlagRegistry::InitGlobalRegistry() { FlagRegistry *const fr_;
global_registry_ = new FlagRegistry; };
}
// We want to use pthread_once here, for safety, but have to worry about
// whether libpthread is linked in or not. We declare a weak version of
// the function, so we'll always compile (if the weak version is the only
// one that ends up existing, then pthread_once will be equal to NULL).
#ifdef HAVE___ATTRIBUTE__
// __THROW is defined in glibc systems. It means, counter-intuitively,
// "This function will never throw an exception." It's an optional
// optimization tool, but we may need to use it to match glibc prototypes.
# ifndef __THROW // I guess we're not on a glibc system
# define __THROW // __THROW is just an optimization, so ok to make it ""
# endif
extern "C" int pthread_once(pthread_once_t *, void (*)(void))
__THROW __attribute__((weak));
#endif
FlagRegistry* FlagRegistry::GlobalRegistry() {
if (pthread_once) { // means we're running with pthreads
pthread_once(&global_registry_once_, &FlagRegistry::InitGlobalRegistry);
} else { // not running with pthreads: we're the only thread
if (global_registry_once_nothreads_++ == 0)
InitGlobalRegistry();
}
return global_registry_;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// CommandLineFlagParser // CommandLineFlagParser
...@@ -915,14 +1012,15 @@ class CommandLineFlagParser { ...@@ -915,14 +1012,15 @@ class CommandLineFlagParser {
// These are called by ProcessSingleOptionLocked and, similarly, return // These are called by ProcessSingleOptionLocked and, similarly, return
// new values if everything went ok, or the empty-string if not. // new values if everything went ok, or the empty-string if not.
string ProcessFlagfileLocked(const string& flagval, FlagSettingMode set_mode); string ProcessFlagfileLocked(const string& flagval, FlagSettingMode set_mode);
// diff fromenv/tryfromenv
string ProcessFromenvLocked(const string& flagval, FlagSettingMode set_mode, string ProcessFromenvLocked(const string& flagval, FlagSettingMode set_mode,
bool errors_are_fatal); // diff fromenv/tryfromenv bool errors_are_fatal);
private: private:
FlagRegistry* const registry_; FlagRegistry* const registry_;
map<string, string> error_flags_; // map from name to error message map<string, string> error_flags_; // map from name to error message
// This could be a set<string>, but we reuse the map to minimize the .o size // This could be a set<string>, but we reuse the map to minimize the .o size
map<string, string> undefined_names_; // --name for name that's not registered map<string, string> undefined_names_; // --[flag] name was not registered
}; };
...@@ -932,10 +1030,10 @@ static void ParseFlagList(const char* value, vector<string>* flags) { ...@@ -932,10 +1030,10 @@ static void ParseFlagList(const char* value, vector<string>* flags) {
p = strchr(value, ','); p = strchr(value, ',');
int len; int len;
if (p) { if (p) {
len = p - value; len = static_cast<int>(p - value);
p++; p++;
} else { } else {
len = strlen(value); len = static_cast<int>(strlen(value));
} }
if (len == 0) { if (len == 0) {
...@@ -958,13 +1056,13 @@ static void ParseFlagList(const char* value, vector<string>* flags) { ...@@ -958,13 +1056,13 @@ static void ParseFlagList(const char* value, vector<string>* flags) {
#define PFATAL(s) do { perror(s); commandlineflags_exitfunc(1); } while (0) #define PFATAL(s) do { perror(s); commandlineflags_exitfunc(1); } while (0)
static string ReadFileIntoString(const char* filename) { static string ReadFileIntoString(const char* filename) {
const int bufsize = 8092; const int kBufSize = 8092;
char buffer[bufsize]; char buffer[kBufSize];
string s; string s;
FILE* fp = fopen(filename, "r"); FILE* fp = fopen(filename, "r");
if (!fp) PFATAL(filename); if (!fp) PFATAL(filename);
int n; size_t n;
while ( (n=fread(buffer, 1, bufsize, fp)) > 0 ) { while ( (n=fread(buffer, 1, kBufSize, fp)) > 0 ) {
if (ferror(fp)) PFATAL(filename); if (ferror(fp)) PFATAL(filename);
s.append(buffer, n); s.append(buffer, n);
} }
...@@ -1019,8 +1117,13 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv, ...@@ -1019,8 +1117,13 @@ uint32 CommandLineFlagParser::ParseNewCommandLineFlags(int* argc, char*** argv,
assert(strcmp(flag->type_name(), "bool") != 0); assert(strcmp(flag->type_name(), "bool") != 0);
if (i+1 >= first_nonopt) { if (i+1 >= first_nonopt) {
// This flag needs a value, but there is nothing available // This flag needs a value, but there is nothing available
error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'" + error_flags_[key] = (string(kError) + "flag '" + (*argv)[i] + "'"
+ " is missing its argument\n"); + " is missing its argument");
if (flag->help() && flag->help()[0] > '\001') {
// Be useful in case we have a non-stripped description.
error_flags_[key] += string("; flag description: ") + flag->help();
}
error_flags_[key] += "\n";
break; // we treat this as an unrecoverable error break; // we treat this as an unrecoverable error
} else { } else {
value = (*argv)[++i]; // read next arg for value value = (*argv)[++i]; // read next arg for value
...@@ -1052,7 +1155,7 @@ string CommandLineFlagParser::ProcessFlagfileLocked(const string& flagval, ...@@ -1052,7 +1155,7 @@ string CommandLineFlagParser::ProcessFlagfileLocked(const string& flagval,
string msg; string msg;
vector<string> filename_list; vector<string> filename_list;
ParseFlagList(flagval.c_str(), &filename_list); // take a list of filenames ParseFlagList(flagval.c_str(), &filename_list); // take a list of filenames
for (int i = 0; i < filename_list.size(); ++i) { for (size_t i = 0; i < filename_list.size(); ++i) {
const char* file = filename_list[i].c_str(); const char* file = filename_list[i].c_str();
msg += ProcessOptionsFromStringLocked(ReadFileIntoString(file), set_mode); msg += ProcessOptionsFromStringLocked(ReadFileIntoString(file), set_mode);
} }
...@@ -1069,7 +1172,7 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval, ...@@ -1069,7 +1172,7 @@ string CommandLineFlagParser::ProcessFromenvLocked(const string& flagval,
vector<string> flaglist; vector<string> flaglist;
ParseFlagList(flagval.c_str(), &flaglist); ParseFlagList(flagval.c_str(), &flaglist);
for (int i = 0; i < flaglist.size(); ++i) { for (size_t i = 0; i < flaglist.size(); ++i) {
const char* flagname = flaglist[i].c_str(); const char* flagname = flaglist[i].c_str();
CommandLineFlag* flag = registry_->FindFlagLocked(flagname); CommandLineFlag* flag = registry_->FindFlagLocked(flagname);
if (flag == NULL) { if (flag == NULL) {
...@@ -1123,7 +1226,6 @@ string CommandLineFlagParser::ProcessSingleOptionLocked( ...@@ -1123,7 +1226,6 @@ string CommandLineFlagParser::ProcessSingleOptionLocked(
} else if (strcmp(flag->name(), "tryfromenv") == 0) { } else if (strcmp(flag->name(), "tryfromenv") == 0) {
msg += ProcessFromenvLocked(FLAGS_tryfromenv, set_mode, false); msg += ProcessFromenvLocked(FLAGS_tryfromenv, set_mode, false);
} }
return msg; return msg;
...@@ -1152,7 +1254,7 @@ bool CommandLineFlagParser::ReportErrors() { ...@@ -1152,7 +1254,7 @@ bool CommandLineFlagParser::ReportErrors() {
if (!FLAGS_undefok.empty()) { if (!FLAGS_undefok.empty()) {
vector<string> flaglist; vector<string> flaglist;
ParseFlagList(FLAGS_undefok.c_str(), &flaglist); ParseFlagList(FLAGS_undefok.c_str(), &flaglist);
for (int i = 0; i < flaglist.size(); ++i) for (size_t i = 0; i < flaglist.size(); ++i)
if (undefined_names_.find(flaglist[i]) != undefined_names_.end()) { if (undefined_names_.find(flaglist[i]) != undefined_names_.end()) {
error_flags_[flaglist[i]] = ""; // clear the error message error_flags_[flaglist[i]] = ""; // clear the error message
} }
...@@ -1161,13 +1263,13 @@ bool CommandLineFlagParser::ReportErrors() { ...@@ -1161,13 +1263,13 @@ bool CommandLineFlagParser::ReportErrors() {
// are ok; we just silently ignore them now, and hope that a future // are ok; we just silently ignore them now, and hope that a future
// parse will pick them up somehow. // parse will pick them up somehow.
if (allow_command_line_reparsing) { if (allow_command_line_reparsing) {
for (map<string,string>::const_iterator it = undefined_names_.begin(); for (map<string, string>::const_iterator it = undefined_names_.begin();
it != undefined_names_.end(); ++it) it != undefined_names_.end(); ++it)
error_flags_[it->first] = ""; // clear the error message error_flags_[it->first] = ""; // clear the error message
} }
bool found_error = false; bool found_error = false;
for (map<string,string>::const_iterator it = error_flags_.begin(); for (map<string, string>::const_iterator it = error_flags_.begin();
it != error_flags_.end(); ++it) { it != error_flags_.end(); ++it) {
if (!it->second.empty()) { if (!it->second.empty()) {
fprintf(stderr, "%s", it->second.c_str()); fprintf(stderr, "%s", it->second.c_str());
...@@ -1190,7 +1292,8 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( ...@@ -1190,7 +1292,8 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
while (*flagfile_contents && isspace(*flagfile_contents)) while (*flagfile_contents && isspace(*flagfile_contents))
++flagfile_contents; ++flagfile_contents;
line_end = strchr(flagfile_contents, '\n'); line_end = strchr(flagfile_contents, '\n');
int len = line_end ? line_end-flagfile_contents : strlen(flagfile_contents); size_t len = line_end ? static_cast<size_t>(line_end - flagfile_contents)
: strlen(flagfile_contents);
string line(flagfile_contents, len); string line(flagfile_contents, len);
// Each line can be one of four things: // Each line can be one of four things:
...@@ -1240,8 +1343,17 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked( ...@@ -1240,8 +1343,17 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
space = word + strlen(word); space = word + strlen(word);
const string glob(word, space - word); const string glob(word, space - word);
// We try matching both against the full argv0 and basename(argv0) // We try matching both against the full argv0 and basename(argv0)
if (fnmatch(glob.c_str(), ProgramInvocationName(), FNM_PATHNAME) == 0 || #ifdef HAVE_FNMATCH_H
fnmatch(glob.c_str(), ProgramInvocationShortName(), FNM_PATHNAME) == 0) { 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
flags_are_relevant = true; flags_are_relevant = true;
} }
} }
...@@ -1393,8 +1505,7 @@ static const char* argv0 = "UNKNOWN"; // just the program name ...@@ -1393,8 +1505,7 @@ static const char* argv0 = "UNKNOWN"; // just the program name
static const char* cmdline = ""; // the entire command-line static const char* cmdline = ""; // the entire command-line
static vector<string> argvs; static vector<string> argvs;
static uint32 argv_sum = 0; static uint32 argv_sum = 0;
static const char* program_usage = "Warning: SetUsageMessage() never called"; static const char* program_usage = NULL;
static bool program_usage_set = false;
void SetArgv(int argc, const char** argv) { void SetArgv(int argc, const char** argv) {
static bool called_set_argv = false; static bool called_set_argv = false;
...@@ -1407,11 +1518,11 @@ void SetArgv(int argc, const char** argv) { ...@@ -1407,11 +1518,11 @@ void SetArgv(int argc, const char** argv) {
argv0 = strdup(argv[0]); // small memory leak, but fn only called once argv0 = strdup(argv[0]); // small memory leak, but fn only called once
assert(argv0); assert(argv0);
string cmdline_string = string(""); // easier than doing strcats string cmdline_string; // easier than doing strcats
argvs.clear();
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
if (i != 0) if (i != 0) {
cmdline_string += " "; cmdline_string += " ";
}
cmdline_string += argv[i]; cmdline_string += argv[i];
argvs.push_back(argv[i]); argvs.push_back(argv[i]);
} }
...@@ -1419,7 +1530,6 @@ void SetArgv(int argc, const char** argv) { ...@@ -1419,7 +1530,6 @@ void SetArgv(int argc, const char** argv) {
assert(cmdline); assert(cmdline);
// Compute a simple sum of all the chars in argv // Compute a simple sum of all the chars in argv
argv_sum = 0;
for (const char* c = cmdline; *c; c++) for (const char* c = cmdline; *c; c++)
argv_sum += *c; argv_sum += *c;
} }
...@@ -1440,17 +1550,18 @@ const char* ProgramInvocationShortName() { // like the GNU libc fn ...@@ -1440,17 +1550,18 @@ const char* ProgramInvocationShortName() { // like the GNU libc fn
} }
void SetUsageMessage(const string& usage) { void SetUsageMessage(const string& usage) {
if (program_usage_set) { if (program_usage != NULL) {
fprintf(stderr, "ERROR: SetUsageMessage() called more than once\n"); fprintf(stderr, "ERROR: SetUsageMessage() called twice\n");
exit(1); exit(1);
} }
program_usage = strdup(usage.c_str()); // small memory leak program_usage = strdup(usage.c_str()); // small memory leak
program_usage_set = true;
} }
const char* ProgramUsage() { const char* ProgramUsage() {
if (program_usage) {
return program_usage; return program_usage;
}
return "Warning: SetUsageMessage() never called";
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -1600,7 +1711,8 @@ class FlagSaverImpl { ...@@ -1600,7 +1711,8 @@ class FlagSaverImpl {
void operator=(const FlagSaverImpl&); void operator=(const FlagSaverImpl&);
}; };
FlagSaver::FlagSaver() : impl_(new FlagSaverImpl(FlagRegistry::GlobalRegistry())) { FlagSaver::FlagSaver()
: impl_(new FlagSaverImpl(FlagRegistry::GlobalRegistry())) {
impl_->SaveFromRegistry(); impl_->SaveFromRegistry();
} }
...@@ -1629,7 +1741,7 @@ static string TheseCommandlineFlagsIntoString( ...@@ -1629,7 +1741,7 @@ static string TheseCommandlineFlagsIntoString(
const vector<CommandLineFlagInfo>& flags) { const vector<CommandLineFlagInfo>& flags) {
vector<CommandLineFlagInfo>::const_iterator i; vector<CommandLineFlagInfo>::const_iterator i;
int retval_space = 0; size_t retval_space = 0;
for (i = flags.begin(); i != flags.end(); ++i) { for (i = flags.begin(); i != flags.end(); ++i) {
// An (over)estimate of how much space it will take to print this flag // An (over)estimate of how much space it will take to print this flag
retval_space += i->name.length() + i->current_value.length() + 5; retval_space += i->name.length() + i->current_value.length() + 5;
...@@ -1654,7 +1766,7 @@ string CommandlineFlagsIntoString() { ...@@ -1654,7 +1766,7 @@ string CommandlineFlagsIntoString() {
} }
bool ReadFlagsFromString(const string& flagfilecontents, bool ReadFlagsFromString(const string& flagfilecontents,
const char* prog_name, // TODO(csilvers): nix this const char* /*prog_name*/, // TODO(csilvers): nix this
bool errors_are_fatal) { bool errors_are_fatal) {
FlagRegistry* const registry = FlagRegistry::GlobalRegistry(); FlagRegistry* const registry = FlagRegistry::GlobalRegistry();
FlagSaverImpl saved_states(registry); FlagSaverImpl saved_states(registry);
...@@ -1854,7 +1966,7 @@ void AllowCommandLineReparsing() { ...@@ -1854,7 +1966,7 @@ void AllowCommandLineReparsing() {
uint32 ReparseCommandLineNonHelpFlags() { uint32 ReparseCommandLineNonHelpFlags() {
// We make a copy of argc and argv to pass in // We make a copy of argc and argv to pass in
const vector<string>& argvs = GetArgvs(); const vector<string>& argvs = GetArgvs();
int tmp_argc = argvs.size(); int tmp_argc = static_cast<int>(argvs.size());
char** tmp_argv = new char* [tmp_argc + 1]; char** tmp_argv = new char* [tmp_argc + 1];
for (int i = 0; i < tmp_argc; ++i) for (int i = 0; i < tmp_argc; ++i)
tmp_argv[i] = strdup(argvs[i].c_str()); // TODO(csilvers): don't dup tmp_argv[i] = strdup(argvs[i].c_str()); // TODO(csilvers): don't dup
......
...@@ -103,11 +103,11 @@ typedef int32_t int32; ...@@ -103,11 +103,11 @@ typedef int32_t int32;
typedef u_int32_t uint32; typedef u_int32_t uint32;
typedef int64_t int64; typedef int64_t int64;
typedef u_int64_t uint64; typedef u_int64_t uint64;
#elif @ac_cv_have___uint16@ // the windows (vc7) format #elif @ac_cv_have___int16@ // the windows (vc7) format
typedef __int32 int32; typedef __int32 int32;
typedef __uint32 uint32; typedef unsigned __int32 uint32;
typedef __int64 int64; typedef __int64 int64;
typedef __uint64 uint64; typedef unsigned __int64 uint64;
#else #else
#error Do not know how to define a 32-bit integer quantity on your system #error Do not know how to define a 32-bit integer quantity on your system
#endif #endif
...@@ -504,7 +504,7 @@ extern bool FlagsTypeWarn(const char *name); ...@@ -504,7 +504,7 @@ extern bool FlagsTypeWarn(const char *name);
#define DEFINE_string(name, val, txt) \ #define DEFINE_string(name, val, txt) \
namespace fLS { \ namespace fLS { \
static union { void* align; char s[sizeof(std::string)]; } s_##name[2]; \ static union { void* align; char s[sizeof(std::string)]; } s_##name[2]; \
const string* const FLAGS_no##name = new (s_##name[0].s) std::string(val); \ const std::string* const FLAGS_no##name = new (s_##name[0].s) std::string(val); \
static @ac_google_namespace@::FlagRegisterer o_##name( \ static @ac_google_namespace@::FlagRegisterer o_##name( \
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \ #name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
s_##name[0].s, new (s_##name[1].s) std::string(*FLAGS_no##name)); \ s_##name[0].s, new (s_##name[1].s) std::string(*FLAGS_no##name)); \
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "google/gflags.h" #include "gflags/gflags.h"
using std::set; using std::set;
using std::string; using std::string;
...@@ -145,7 +145,7 @@ static void OutputSingleGroupWithLimit( ...@@ -145,7 +145,7 @@ static void OutputSingleGroupWithLimit(
const string &footer, const string &footer,
bool long_output_format, bool long_output_format,
int *remaining_line_limit, int *remaining_line_limit,
int *completion_elements_added, size_t *completion_elements_added,
vector<string> *completions); vector<string> *completions);
// (helpers for #5) // (helpers for #5)
...@@ -424,7 +424,7 @@ static void CategorizeAllMatchingFlags( ...@@ -424,7 +424,7 @@ static void CategorizeAllMatchingFlags(
all_matches.begin(); all_matches.begin();
it != all_matches.end(); it != all_matches.end();
++it) { ++it) {
//VLOG(2) << "Examinging match '" << (*it)->name << "'"; //VLOG(2) << "Examining match '" << (*it)->name << "'";
//VLOG(7) << " filename: '" << (*it)->filename << "'"; //VLOG(7) << " filename: '" << (*it)->filename << "'";
string::size_type pos = string::npos; string::size_type pos = string::npos;
if (!package_dir.empty()) if (!package_dir.empty())
...@@ -507,6 +507,17 @@ struct DisplayInfoGroup { ...@@ -507,6 +507,17 @@ struct DisplayInfoGroup {
string header; string header;
string footer; string footer;
set<const CommandLineFlagInfo *> *group; set<const CommandLineFlagInfo *> *group;
int SizeInLines() const {
int size_in_lines = static_cast<int>(group->size()) + 1;
if (!header.empty()) {
size_in_lines++;
}
if (!footer.empty()) {
size_in_lines++;
}
return size_in_lines;
}
}; };
// 4) Finalize and trim output flag set // 4) Finalize and trim output flag set
...@@ -533,45 +544,47 @@ static void FinalizeCompletionOutput( ...@@ -533,45 +544,47 @@ static void FinalizeCompletionOutput(
if (lines_so_far < max_desired_lines && if (lines_so_far < max_desired_lines &&
!notable_flags->perfect_match_flag.empty()) { !notable_flags->perfect_match_flag.empty()) {
perfect_match_found = true; perfect_match_found = true;
lines_so_far += notable_flags->perfect_match_flag.size() + 2; // no header
DisplayInfoGroup group = DisplayInfoGroup group =
{ "", "==========", &notable_flags->perfect_match_flag }; { string(),
"==========",
&notable_flags->perfect_match_flag };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
if (lines_so_far < max_desired_lines && if (lines_so_far < max_desired_lines &&
!notable_flags->module_flags.empty()) { !notable_flags->module_flags.empty()) {
lines_so_far += notable_flags->module_flags.size() + 3;
DisplayInfoGroup group = { DisplayInfoGroup group = {
"-* Matching module flags *-", "-* Matching module flags *-",
"===========================", "===========================",
&notable_flags->module_flags }; &notable_flags->module_flags };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
if (lines_so_far < max_desired_lines && if (lines_so_far < max_desired_lines &&
!notable_flags->package_flags.empty()) { !notable_flags->package_flags.empty()) {
lines_so_far += notable_flags->package_flags.size() + 3;
DisplayInfoGroup group = { DisplayInfoGroup group = {
"-* Matching package flags *-", "-* Matching package flags *-",
"============================", "============================",
&notable_flags->package_flags }; &notable_flags->package_flags };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
if (lines_so_far < max_desired_lines && if (lines_so_far < max_desired_lines &&
!notable_flags->most_common_flags.empty()) { !notable_flags->most_common_flags.empty()) {
lines_so_far += notable_flags->most_common_flags.size() + 3;
DisplayInfoGroup group = { DisplayInfoGroup group = {
"-* Commonly used flags *-", "-* Commonly used flags *-",
"=========================", "=========================",
&notable_flags->most_common_flags }; &notable_flags->most_common_flags };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
if (lines_so_far < max_desired_lines && if (lines_so_far < max_desired_lines &&
!notable_flags->subpackage_flags.empty()) { !notable_flags->subpackage_flags.empty()) {
lines_so_far += notable_flags->subpackage_flags.size() + 3;
DisplayInfoGroup group = { DisplayInfoGroup group = {
"-* Matching sub-package flags *-", "-* Matching sub-package flags *-",
"================================", "================================",
&notable_flags->subpackage_flags }; &notable_flags->subpackage_flags };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
...@@ -579,11 +592,11 @@ static void FinalizeCompletionOutput( ...@@ -579,11 +592,11 @@ static void FinalizeCompletionOutput(
if (lines_so_far < max_desired_lines) { if (lines_so_far < max_desired_lines) {
RetrieveUnusedFlags(matching_flags, *notable_flags, &obscure_flags); RetrieveUnusedFlags(matching_flags, *notable_flags, &obscure_flags);
if (!obscure_flags.empty()) { if (!obscure_flags.empty()) {
lines_so_far += obscure_flags.size() + 2; // no footer
DisplayInfoGroup group = { DisplayInfoGroup group = {
"-* Other flags *-", "-* Other flags *-",
"", string(),
&obscure_flags }; &obscure_flags };
lines_so_far += group.SizeInLines();
output_groups.push_back(group); output_groups.push_back(group);
} }
} }
...@@ -591,8 +604,8 @@ static void FinalizeCompletionOutput( ...@@ -591,8 +604,8 @@ static void FinalizeCompletionOutput(
// Second, go through each of the chosen output groups and output // Second, go through each of the chosen output groups and output
// as many of those flags as we can, while remaining below our limit // as many of those flags as we can, while remaining below our limit
int remaining_lines = max_desired_lines; int remaining_lines = max_desired_lines;
int completions_output = 0; size_t completions_output = 0;
int indent = output_groups.size() - 1; int indent = static_cast<int>(output_groups.size()) - 1;
for (vector<DisplayInfoGroup>::const_iterator it = for (vector<DisplayInfoGroup>::const_iterator it =
output_groups.begin(); output_groups.begin();
it != output_groups.end(); it != output_groups.end();
...@@ -646,7 +659,7 @@ static void OutputSingleGroupWithLimit( ...@@ -646,7 +659,7 @@ static void OutputSingleGroupWithLimit(
const string &footer, const string &footer,
bool long_output_format, bool long_output_format,
int *remaining_line_limit, int *remaining_line_limit,
int *completion_elements_output, size_t *completion_elements_output,
vector<string> *completions) { vector<string> *completions) {
if (group.empty()) return; if (group.empty()) return;
if (!header.empty()) { if (!header.empty()) {
...@@ -681,11 +694,12 @@ static string GetShortFlagLine( ...@@ -681,11 +694,12 @@ static string GetShortFlagLine(
("'" + info.default_value + "'") : ("'" + info.default_value + "'") :
info.default_value) info.default_value)
+ "] "; + "] ";
int remainder = FLAGS_tab_completion_columns - prefix.size(); int remainder =
string suffix = ""; FLAGS_tab_completion_columns - static_cast<int>(prefix.size());
string suffix;
if (remainder > 0) if (remainder > 0)
suffix = suffix =
(info.description.size() > remainder ? (static_cast<int>(info.description.size()) > remainder ?
(info.description.substr(0, remainder - 3) + "...").c_str() : (info.description.substr(0, remainder - 3) + "...").c_str() :
info.description.c_str()); info.description.c_str());
return prefix + suffix; return prefix + suffix;
...@@ -726,7 +740,7 @@ static string GetLongFlagLine( ...@@ -726,7 +740,7 @@ static string GetLongFlagLine(
for (string::size_type newline = output.find('\n'); for (string::size_type newline = output.find('\n');
newline != string::npos; newline != string::npos;
newline = output.find('\n')) { newline = output.find('\n')) {
int newline_pos = newline % FLAGS_tab_completion_columns; int newline_pos = static_cast<int>(newline) % FLAGS_tab_completion_columns;
int missing_spaces = FLAGS_tab_completion_columns - newline_pos; int missing_spaces = FLAGS_tab_completion_columns - newline_pos;
output.replace(newline, 1, line_of_spaces, 1, missing_spaces); output.replace(newline, 1, line_of_spaces, 1, missing_spaces);
} }
......
...@@ -55,8 +55,8 @@ ...@@ -55,8 +55,8 @@
#include <assert.h> #include <assert.h>
#include <string> #include <string>
#include <vector> #include <vector>
#include "google/gflags.h" #include "gflags/gflags.h"
#include "google/gflags_completions.h" #include "gflags/gflags_completions.h"
#ifndef PATH_SEPARATOR #ifndef PATH_SEPARATOR
#define PATH_SEPARATOR '/' #define PATH_SEPARATOR '/'
...@@ -97,7 +97,7 @@ static const int kLineLength = 80; ...@@ -97,7 +97,7 @@ static const int kLineLength = 80;
static void AddString(const string& s, static void AddString(const string& s,
string* final_string, int* chars_in_line) { string* final_string, int* chars_in_line) {
const int slen = s.length(); const int slen = static_cast<int>(s.length());
if (*chars_in_line + 1 + slen >= kLineLength) { // < 80 chars/line if (*chars_in_line + 1 + slen >= kLineLength) { // < 80 chars/line
*final_string += "\n "; *final_string += "\n ";
*chars_in_line = 6; *chars_in_line = 6;
...@@ -115,7 +115,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { ...@@ -115,7 +115,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
string main_part = (string(" -") + flag.name + string main_part = (string(" -") + flag.name +
" (" + flag.description + ')'); " (" + flag.description + ')');
const char* c_string = main_part.c_str(); const char* c_string = main_part.c_str();
int chars_left = main_part.length(); int chars_left = static_cast<int>(main_part.length());
string final_string = ""; string final_string = "";
int chars_in_line = 0; // how many chars in current line so far? int chars_in_line = 0; // how many chars in current line so far?
while (1) { while (1) {
...@@ -128,7 +128,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { ...@@ -128,7 +128,7 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
break; break;
} }
if (newline != NULL && newline - c_string < kLineLength - chars_in_line) { if (newline != NULL && newline - c_string < kLineLength - chars_in_line) {
int n = newline - c_string; int n = static_cast<int>(newline - c_string);
final_string.append(c_string, n); final_string.append(c_string, n);
chars_left -= n + 1; chars_left -= n + 1;
c_string += n + 1; c_string += n + 1;
...@@ -185,9 +185,9 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) { ...@@ -185,9 +185,9 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
// Simple routine to xml-escape a string: escape & and < only. // Simple routine to xml-escape a string: escape & and < only.
static string XMLText(const string& txt) { static string XMLText(const string& txt) {
string ans = txt; string ans = txt;
for (string::size_type pos = 0; (pos=ans.find("&", pos)) != string::npos; ) for (string::size_type pos = 0; (pos = ans.find("&", pos)) != string::npos; )
ans.replace(pos++, 1, "&amp;"); ans.replace(pos++, 1, "&amp;");
for (string::size_type pos = 0; (pos=ans.find("<", pos)) != string::npos; ) for (string::size_type pos = 0; (pos = ans.find("<", pos)) != string::npos; )
ans.replace(pos++, 1, "&lt;"); ans.replace(pos++, 1, "&lt;");
return ans; return ans;
} }
...@@ -244,7 +244,7 @@ static bool FileMatchesSubstring(const string& filename, ...@@ -244,7 +244,7 @@ static bool FileMatchesSubstring(const string& filename,
// Show help for every filename which matches any of the target substrings. // 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 // 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 // has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' before
// including google/gflags.h), then this flag will not be displayed by // including gflags/gflags.h), then this flag will not be displayed by
// '--help' and its variants. // '--help' and its variants.
static void ShowUsageWithFlagsMatching(const char *argv0, static void ShowUsageWithFlagsMatching(const char *argv0,
const vector<string> &substrings) { const vector<string> &substrings) {
...@@ -253,7 +253,7 @@ static void ShowUsageWithFlagsMatching(const char *argv0, ...@@ -253,7 +253,7 @@ static void ShowUsageWithFlagsMatching(const char *argv0,
vector<CommandLineFlagInfo> flags; vector<CommandLineFlagInfo> flags;
GetAllFlags(&flags); // flags are sorted by filename, then flagname GetAllFlags(&flags); // flags are sorted by filename, then flagname
string last_filename = ""; // so we know when we're at a new file string last_filename; // so we know when we're at a new file
bool first_directory = true; // controls blank lines between dirs bool first_directory = true; // controls blank lines between dirs
bool found_match = false; // stays false iff no dir matches restrict bool found_match = false; // stays false iff no dir matches restrict
for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin(); for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin();
...@@ -384,7 +384,7 @@ void HandleCommandLineHelpFlags() { ...@@ -384,7 +384,7 @@ void HandleCommandLineHelpFlags() {
substrings.push_back(string("/") + progname + "."); substrings.push_back(string("/") + progname + ".");
substrings.push_back(string("/") + progname + "-main."); substrings.push_back(string("/") + progname + "-main.");
substrings.push_back(string("/") + progname + "_main."); substrings.push_back(string("/") + progname + "_main.");
string last_package = ""; string last_package;
for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin(); for (vector<CommandLineFlagInfo>::const_iterator flag = flags.begin();
flag != flags.end(); flag != flags.end();
++flag) { ++flag) {
...@@ -393,14 +393,14 @@ void HandleCommandLineHelpFlags() { ...@@ -393,14 +393,14 @@ void HandleCommandLineHelpFlags() {
const string package = Dirname(flag->filename) + "/"; const string package = Dirname(flag->filename) + "/";
if (package != last_package) { if (package != last_package) {
ShowUsageWithFlagsRestrict(progname, package.c_str()); ShowUsageWithFlagsRestrict(progname, package.c_str());
if (last_package != "") { // means this isn't our first pkg if (!last_package.empty()) { // means this isn't our first pkg
fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n", fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n",
progname); progname);
} }
last_package = package; last_package = package;
} }
} }
if (last_package == "") { // never found a package to print if (last_package.empty()) { // never found a package to print
fprintf(stderr, "WARNING: Unable to find a package for file=%s\n", fprintf(stderr, "WARNING: Unable to find a package for file=%s\n",
progname); progname);
} }
......
...@@ -42,7 +42,12 @@ ...@@ -42,7 +42,12 @@
#include <math.h> // for isinf() and isnan() #include <math.h> // for isinf() and isnan()
#include <vector> #include <vector>
#include <string> #include <string>
#include "google/gflags.h" #include "gflags/gflags.h"
// I don't actually use this header file, but #include it under the
// old location to make sure that the include-header-forwarding
// works.
#include "google/gflags_completions.h"
void (*unused_fn)() = &GOOGLE_NAMESPACE::HandleCommandLineCompletions;
using std::vector; using std::vector;
using std::string; using std::string;
...@@ -151,6 +156,11 @@ _START_GOOGLE_NAMESPACE_ ...@@ -151,6 +156,11 @@ _START_GOOGLE_NAMESPACE_
#define EXPECT_GT(val1, val2) EXPECT_OP(>, val1, val2) #define EXPECT_GT(val1, val2) EXPECT_OP(>, val1, val2)
#define EXPECT_LT(val1, val2) EXPECT_OP(<, val1, val2) #define EXPECT_LT(val1, val2) EXPECT_OP(<, val1, val2)
// 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) \ #define EXPECT_NAN(arg) \
do { \ do { \
if (!isnan(arg)) { \ if (!isnan(arg)) { \
...@@ -158,7 +168,11 @@ _START_GOOGLE_NAMESPACE_ ...@@ -158,7 +168,11 @@ _START_GOOGLE_NAMESPACE_
exit(1); \ exit(1); \
} \ } \
} while (0) } 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) \ #define EXPECT_INF(arg) \
do { \ do { \
if (!isinf(arg)) { \ if (!isinf(arg)) { \
...@@ -166,6 +180,9 @@ _START_GOOGLE_NAMESPACE_ ...@@ -166,6 +180,9 @@ _START_GOOGLE_NAMESPACE_
exit(1); \ exit(1); \
} \ } \
} while (0) } while (0)
#else
#define EXPECT_INF(arg)
#endif
#define EXPECT_DOUBLE_EQ(val1, val2) \ #define EXPECT_DOUBLE_EQ(val1, val2) \
do { \ do { \
...@@ -497,6 +514,7 @@ TEST(SetFlagValueTest, OrdinaryValues) { ...@@ -497,6 +514,7 @@ TEST(SetFlagValueTest, OrdinaryValues) {
// Tests that flags can be set to exceptional values. // Tests that flags can be set to exceptional values.
TEST(SetFlagValueTest, ExceptionalValues) { TEST(SetFlagValueTest, ExceptionalValues) {
#ifdef isinf // on systems without isinf, inf stuff may not work at all
EXPECT_EQ("test_double set to inf\n", EXPECT_EQ("test_double set to inf\n",
SetCommandLineOption("test_double", "inf")); SetCommandLineOption("test_double", "inf"));
EXPECT_INF(FLAGS_test_double); EXPECT_INF(FLAGS_test_double);
...@@ -504,6 +522,7 @@ TEST(SetFlagValueTest, ExceptionalValues) { ...@@ -504,6 +522,7 @@ TEST(SetFlagValueTest, ExceptionalValues) {
EXPECT_EQ("test_double set to inf\n", EXPECT_EQ("test_double set to inf\n",
SetCommandLineOption("test_double", "INF")); SetCommandLineOption("test_double", "INF"));
EXPECT_INF(FLAGS_test_double); EXPECT_INF(FLAGS_test_double);
#endif
// set some bad values // set some bad values
EXPECT_EQ("", EXPECT_EQ("",
...@@ -512,14 +531,18 @@ TEST(SetFlagValueTest, ExceptionalValues) { ...@@ -512,14 +531,18 @@ TEST(SetFlagValueTest, ExceptionalValues) {
SetCommandLineOption("test_double", " ")); SetCommandLineOption("test_double", " "));
EXPECT_EQ("", EXPECT_EQ("",
SetCommandLineOption("test_double", "")); SetCommandLineOption("test_double", ""));
#ifdef isinf
EXPECT_EQ("test_double set to -inf\n", EXPECT_EQ("test_double set to -inf\n",
SetCommandLineOption("test_double", "-inf")); SetCommandLineOption("test_double", "-inf"));
EXPECT_INF(FLAGS_test_double); EXPECT_INF(FLAGS_test_double);
EXPECT_GT(0, FLAGS_test_double); EXPECT_GT(0, FLAGS_test_double);
#endif
#ifdef isnan
EXPECT_EQ("test_double set to nan\n", EXPECT_EQ("test_double set to nan\n",
SetCommandLineOption("test_double", "NaN")); SetCommandLineOption("test_double", "NaN"));
EXPECT_NAN(FLAGS_test_double); EXPECT_NAN(FLAGS_test_double);
#endif
} }
// Tests that integer flags can be specified in many ways // Tests that integer flags can be specified in many ways
......
...@@ -42,13 +42,13 @@ then ...@@ -42,13 +42,13 @@ then
exit 1 exit 1
fi fi
EXE=$1 EXE="$1"
SRCDIR=${2:-./} SRCDIR="${2:-./}"
TMPDIR=${3:-/tmp/gflags} TMPDIR="${3:-/tmp/gflags}"
# Executables built with the main source file suffixed with "-main" and "_main". # Executables built with the main source file suffixed with "-main" and "_main".
EXE2=${EXE}2 # eg, gflags_unittest2 EXE2="${EXE}2" # eg, gflags_unittest2
EXE3=${EXE}3 # eg, gflags_unittest3 EXE3="${EXE}3" # eg, gflags_unittest3
# $1: executable # $1: executable
# $2: line-number $3: expected return code. $4: substring of expected output. # $2: line-number $3: expected return code. $4: substring of expected output.
...@@ -66,7 +66,7 @@ ExpectExe() { ...@@ -66,7 +66,7 @@ ExpectExe() {
shift shift
# We always add --srcdir=$SRCDIR because it's needed for correctness # We always add --srcdir=$SRCDIR because it's needed for correctness
$executable --srcdir="$SRCDIR" "$@" > "$TMPDIR/test.$line_number" 2>&1 "$executable" --srcdir="$SRCDIR" "$@" > "$TMPDIR/test.$line_number" 2>&1
local actual_rc=$? local actual_rc=$?
if [ $actual_rc != $expected_rc ]; then if [ $actual_rc != $expected_rc ]; then
echo "Test on line $line_number failed:" \ echo "Test on line $line_number failed:" \
...@@ -74,13 +74,13 @@ ExpectExe() { ...@@ -74,13 +74,13 @@ ExpectExe() {
exit 1; exit 1;
fi fi
if [ -n "$expected_output" ] && if [ -n "$expected_output" ] &&
! fgrep -q -- "$expected_output" "$TMPDIR/test.$line_number"; then ! fgrep -e "$expected_output" "$TMPDIR/test.$line_number" >/dev/null; then
echo "Test on line $line_number failed:" \ echo "Test on line $line_number failed:" \
"did not find expected substring '$expected_output'" "did not find expected substring '$expected_output'"
exit 1; exit 1;
fi fi
if [ -n "$unexpected_output" ] && if [ -n "$unexpected_output" ] &&
fgrep -q -- "$unexpected_output" "$TMPDIR/test.$line_number"; then fgrep -e "$unexpected_output" "$TMPDIR/test.$line_number" >/dev/null; then
echo "Test line $line_number failed:" \ echo "Test line $line_number failed:" \
"found unexpected substring '$unexpected_output'" "found unexpected substring '$unexpected_output'"
exit 1; exit 1;
...@@ -90,17 +90,17 @@ ExpectExe() { ...@@ -90,17 +90,17 @@ ExpectExe() {
# $1: line-number $2: expected return code. $3: substring of expected output. # $1: line-number $2: expected return code. $3: substring of expected output.
# $4: a substring you *don't* expect to find in the output. $5+ flags # $4: a substring you *don't* expect to find in the output. $5+ flags
Expect() { Expect() {
ExpectExe $EXE "$@" ExpectExe "$EXE" "$@"
} }
rm -rf $TMPDIR rm -rf "$TMPDIR"
mkdir $TMPDIR || exit 2 mkdir "$TMPDIR" || exit 2
# Create a few flagfiles we can use later # Create a few flagfiles we can use later
echo "--version" > $TMPDIR/flagfile.1 echo "--version" > "$TMPDIR/flagfile.1"
echo "--foo=bar" > $TMPDIR/flagfile.2 echo "--foo=bar" > "$TMPDIR/flagfile.2"
echo "--nounused_bool" >> $TMPDIR/flagfile.2 echo "--nounused_bool" >> "$TMPDIR/flagfile.2"
echo "--flagfile=$TMPDIR/flagfile.2" > $TMPDIR/flagfile.3 echo "--flagfile=$TMPDIR/flagfile.2" > "$TMPDIR/flagfile.3"
# Set a few environment variables (useful for --tryfromenv) # Set a few environment variables (useful for --tryfromenv)
export FLAGS_undefok=foo,bar export FLAGS_undefok=foo,bar
...@@ -131,13 +131,15 @@ Expect $LINENO 1 "/gflags_reporting.cc" "" -helpfull ...@@ -131,13 +131,15 @@ Expect $LINENO 1 "/gflags_reporting.cc" "" -helpfull
Expect $LINENO 1 "/gflags_unittest.cc" "/gflags_reporting.cc" --helpshort Expect $LINENO 1 "/gflags_unittest.cc" "/gflags_reporting.cc" --helpshort
# --helpshort should work if the main source file is suffixed with [_-]main # --helpshort should work if the main source file is suffixed with [_-]main
ExpectExe $EXE2 $LINENO 1 "/gflags_unittest-main.cc" "/gflags_reporting.cc" \ ExpectExe "$EXE2" $LINENO 1 "/gflags_unittest-main.cc" "/gflags_reporting.cc" \
--helpshort --helpshort
ExpectExe $EXE3 $LINENO 1 "/gflags_unittest_main.cc" "/gflags_reporting.cc" \ ExpectExe "$EXE3" $LINENO 1 "/gflags_unittest_main.cc" "/gflags_reporting.cc" \
--helpshort --helpshort
# --helpon needs an argument # --helpon needs an argument
Expect $LINENO 1 "'--helpon' is missing its argument" "" --helpon Expect $LINENO 1 \
"'--helpon' is missing its argument; flag description: show help on" \
"" --helpon
# --helpon argument indicates what file we'll show args from # --helpon argument indicates what file we'll show args from
Expect $LINENO 1 "/gflags.cc" "/gflags_unittest.cc" --helpon=gflags Expect $LINENO 1 "/gflags.cc" "/gflags_unittest.cc" --helpon=gflags
...@@ -183,9 +185,9 @@ Expect $LINENO 1 "unknown command line flag 'foo'" "" --undefok=foot --foo --unu ...@@ -183,9 +185,9 @@ Expect $LINENO 1 "unknown command line flag 'foo'" "" --undefok=foot --foo --unu
# See if we can successfully load our flags from the flagfile # See if we can successfully load our flags from the flagfile
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" \ Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" \
--flagfile=$TMPDIR/flagfile.1 --flagfile="$TMPDIR/flagfile.1"
Expect $LINENO 0 "PASS" "" --flagfile=$TMPDIR/flagfile.2 Expect $LINENO 0 "PASS" "" --flagfile="$TMPDIR/flagfile.2"
Expect $LINENO 0 "PASS" "" --flagfile=$TMPDIR/flagfile.3 Expect $LINENO 0 "PASS" "" --flagfile="$TMPDIR/flagfile.3"
# Also try to load flags from the environment # Also try to load flags from the environment
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" --fromenv=version Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" --fromenv=version
......
// 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.
// Header files have moved from the google directory to the gflags
// directory. This forwarding file is provided only for backwards
// compatibility. Use gflags/gflags.h in all new code.
#include <gflags/gflags.h>
// Copyright (c) 2008, 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.
// Header files have moved from the google directory to the gflags
// directory. This forwarding file is provided only for backwards
// compatibility. Use gflags/gflags_completions.h in all new code.
#include <gflags/gflags_completions.h>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment