From fcd05632e0fa8798dc7d284609fc9ee88cabf4b8 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 27 Apr 2012 15:48:00 -0500 Subject: [PATCH 01/18] Fixes to the proofing process --- acprep | 48 +++++++++++++++++++++++++----------------------- tools/proof | 4 ++-- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/acprep b/acprep index baf63f6e..a7be68d6 100755 --- a/acprep +++ b/acprep @@ -1031,23 +1031,22 @@ class PrepareBuild(CommandLineApp): self.LDFLAGS.append('-stdlib=libc++') self.LDFLAGS.append('/usr/local/lib/libc++.dylib') - else: - global search_prefixes - search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] self.log.debug('Using Clang ident: %s/%s' % (self.boost_inc_ident, self.boost_lib_ident)) else: - match = re.search('gcc-mp-([0-9]+)\.([0-9]+)', self.envvars['CC']) - if match: - self.boost_inc_ident = "gcc" + match.group(1) + match.group(2) - self.boost_lib_ident = "x" + self.boost_inc_ident - else: - self.boost_inc_ident = "gcc42" - self.boost_lib_ident = "xgcc42" - - self.log.debug('Using Boost ident: %s/%s' % - (self.boost_inc_ident, self.boost_lib_ident)) + global search_prefixes + search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] + # match = re.search('gcc-mp-([0-9]+)\.([0-9]+)', self.envvars['CC']) + # if match: + # self.boost_inc_ident = "gcc" + match.group(1) + match.group(2) + # self.boost_lib_ident = "x" + self.boost_inc_ident + # else: + # self.boost_inc_ident = "gcc42" + # self.boost_lib_ident = "xgcc42" + # + # self.log.debug('Using Boost ident: %s/%s' % + # (self.boost_inc_ident, self.boost_lib_ident)) if self.current_flavor == 'debug': self.configure_args.append('--disable-shared') @@ -1327,7 +1326,7 @@ class PrepareBuild(CommandLineApp): def locate_darwin_libraries(self): if self.current_flavor == 'debug': - if (not self.options.use_clang or self.options.use_cpp11) and \ + if (self.options.use_clang or self.options.use_cpp11) and \ self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), @@ -1342,7 +1341,7 @@ class PrepareBuild(CommandLineApp): else: if self.boost_info.configure(): pass - elif (not self.options.use_clang or self.options.use_cpp11) and \ + elif (self.options.use_clang or self.options.use_cpp11) and \ self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), @@ -1706,8 +1705,9 @@ class PrepareBuild(CommandLineApp): source_copy_dir = join(self.ensure(self.products_directory()), proof_dir) - self.execute('rsync', '-a', '--delete', - '--exclude=.git/', '--exclude=b/', + self.execute('rsync', '-a', '--delete', '--exclude=/dist/', + '--exclude=.git/', '--exclude=b/', '--exclude=/lib/', + '--exclude=/archive/', '--exclude=/build/', '%s/' % self.source_dir, '%s/' % source_copy_dir) self.source_dir = source_copy_dir @@ -1724,9 +1724,10 @@ class PrepareBuild(CommandLineApp): self.log.info('=== Testing opt ===') self.phase_make('fullcheck') - self.configure_flavor('gcov', reset=False) - self.log.info('=== Testing gcov ===') - self.phase_make('check') + if not self.options.use_clang: + self.configure_flavor('gcov', reset=False) + self.log.info('=== Testing gcov ===') + self.phase_make('check') self.configure_flavor('debug', reset=False) self.log.info('=== Testing debug ===') @@ -1748,10 +1749,11 @@ class PrepareBuild(CommandLineApp): self.log.info('=== Building opt ===') self.phase_make(*args) - self.configure_flavor('gcov', reset) + if not self.options.use_clang: + self.configure_flavor('gcov', reset) - self.log.info('=== Building gcov ===') - self.phase_make(*args) + self.log.info('=== Building gcov ===') + self.phase_make(*args) self.log.info('=== Building default ===') self.phase_make(*args) diff --git a/tools/proof b/tools/proof index 00c7f7d1..c4d3c9f1 100755 --- a/tools/proof +++ b/tools/proof @@ -48,8 +48,8 @@ EOF else echo $VERSION > $DEST/last-proofed - cd $DEST/ledger-proof/debug; make docs - cd $DEST/ledger-proof/gcov; make report + cd $DEST/ledger-proof-python-gcc47/debug; make docs + cd $DEST/ledger-proof-python-gcc47/gcov; make report mutt -s '[ledger] Proof build succeeded' johnw@newartisans.com < Date: Sat, 28 Apr 2012 05:22:20 -0500 Subject: [PATCH 02/18] Don't rsync as much when preparing proof builds --- acprep | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acprep b/acprep index a7be68d6..e303ea61 100755 --- a/acprep +++ b/acprep @@ -1706,7 +1706,8 @@ class PrepareBuild(CommandLineApp): source_copy_dir = join(self.ensure(self.products_directory()), proof_dir) self.execute('rsync', '-a', '--delete', '--exclude=/dist/', - '--exclude=.git/', '--exclude=b/', '--exclude=/lib/', + '--exclude=.git/', '--exclude=b/', + '--exclude=/lib/boost-release/', '--exclude=/archive/', '--exclude=/build/', '%s/' % self.source_dir, '%s/' % source_copy_dir) From c8f58ea6860b1ce2d4f0d8d039fd3a58727743a5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Apr 2012 05:23:36 -0500 Subject: [PATCH 03/18] Added support for building with Clang and libc++ in C++11 --- acprep | 4 +--- src/pyutils.h | 2 ++ src/utils.cc | 4 ++-- src/utils.h | 8 ++++---- tools/configure.ac | 28 ++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/acprep b/acprep index e303ea61..463f028d 100755 --- a/acprep +++ b/acprep @@ -1022,14 +1022,11 @@ class PrepareBuild(CommandLineApp): self.boost_lib_ident = "clang-darwin" if self.options.use_cpp11: - self.CXXFLAGS.append('-std=c++11') - self.CXXFLAGS.append('-stdlib=libc++') self.CXXFLAGS.append('-nostdlibinc') self.CXXFLAGS.append('-isystem /usr/local/include') self.CXXFLAGS.append('-isystem /usr/local/include/c++/v1') self.CXXFLAGS.append('-isystem /usr/include') - self.LDFLAGS.append('-stdlib=libc++') self.LDFLAGS.append('/usr/local/lib/libc++.dylib') self.log.debug('Using Clang ident: %s/%s' % @@ -1231,6 +1228,7 @@ class PrepareBuild(CommandLineApp): self.CXXFLAGS.append('-Wno-missing-noreturn') self.CXXFLAGS.append('-Wno-disabled-macro-expansion') self.CXXFLAGS.append('-Wno-unused-parameter') + self.CXXFLAGS.append('-Wno-c++98-compat') self.CXXFLAGS.append('-fno-limit-debug-info') #self.CXXFLAGS.append('-Wold-style-cast') diff --git a/src/pyutils.h b/src/pyutils.h index 44bb6d90..2c7dfaeb 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -180,7 +180,9 @@ namespace boost { namespace python { BOOST_PYTHON_RETURN_TO_PYTHON_BY_VALUE(T,expr, pytype) \ BOOST_PYTHON_ARG_TO_PYTHON_BY_VALUE(T,expr) +#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) BOOST_PYTHON_TO_PYTHON_BY_VALUE(ledger::string, ::PyUnicode_FromEncodedObject(::PyString_FromString(x.c_str()), "UTF-8", NULL), &PyUnicode_Type) +#endif } } // namespace boost::python diff --git a/src/utils.cc b/src/utils.cc index 17118904..ada6b600 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -489,7 +489,7 @@ void report_memory(std::ostream& out, bool report_all) namespace ledger { -#if defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) string::string() : std::string() { TRACE_CTOR(string, ""); @@ -527,7 +527,7 @@ string::~string() throw() { TRACE_DTOR(string); } -#endif // defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#endif // !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) string empty_string(""); diff --git a/src/utils.h b/src/utils.h index 8f11f75a..34011e3f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -72,7 +72,7 @@ namespace ledger { using namespace boost; -#if defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) class string; #else typedef std::string string; @@ -93,7 +93,7 @@ namespace ledger { } #if BOOST_FILESYSTEM_VERSION == 3 -#if defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) namespace boost { namespace filesystem3 { namespace path_traits { template<> struct is_pathable { static const bool value = true; }; }}} @@ -193,7 +193,7 @@ void report_memory(std::ostream& out, bool report_all = false); namespace ledger { -#if defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#if !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) class string : public std::string { @@ -272,7 +272,7 @@ inline bool operator!=(const char* __lhs, const string& __rhs) inline bool operator!=(const string& __lhs, const char* __rhs) { return __lhs.compare(__rhs) != 0; } -#endif // defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON) +#endif // !defined(HAVE_CPP11) && (defined(VERIFY_ON) || defined(HAVE_BOOST_PYTHON)) extern string empty_string; diff --git a/tools/configure.ac b/tools/configure.ac index f7623f62..99eb7df5 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -527,6 +527,34 @@ AC_CACHE_CHECK( AM_CONDITIONAL(HAVE_BOOST_TEST, test x$boost_test_avail_cv_ = xtrue) +# check for C++11 and libc++ +AC_CACHE_CHECK( + [if C++11 and libc++ are available], + [cpp11_avail_cv_], + [cpp11_save_cxxflags=$CXXFLAGS + cpp11_save_ldflags=$LDFLAGS + CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" + LDFLAGS="-stdlib=libc++ $LDFLAGS" + AC_LANG_PUSH(C++) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include ]], + [[boost::regex foo_regexp("Hello, world!"); + for (auto i : "Hello, world") + std::cout << i << std::endl;]])], + [cpp11_avail_cv_=true], + [cpp11_avail_cv_=false]) + AC_LANG_POP + CXXFLAGS="$cpp11_save_cxxflags" + LDFLAGS="$cpp11_save_ldflags"]) + +if [test x$cpp11_avail_cv_ = xtrue]; then + AC_DEFINE([HAVE_CPP11], [1], [Whether C++11 and libc++ are available]) + CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" + LDFLAGS="-stdlib=libc++ $LDFLAGS" +fi + # Checks for header files. AC_HEADER_STDC AC_HEADER_STAT From 08a7f5ae0768af77c8e4be0a1094c90b6ce11092 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Apr 2012 05:23:49 -0500 Subject: [PATCH 04/18] Changed a const string map key to string --- src/account.h | 2 +- src/journal.h | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/account.h b/src/account.h index c0e3e1f7..2aa3f2eb 100644 --- a/src/account.h +++ b/src/account.h @@ -51,7 +51,7 @@ class xact_t; class post_t; typedef std::list posts_list; -typedef std::map accounts_map; +typedef std::map accounts_map; class account_t : public supports_flags<>, public scope_t { diff --git a/src/journal.h b/src/journal.h index a7a84447..1f9cf3af 100644 --- a/src/journal.h +++ b/src/journal.h @@ -58,17 +58,17 @@ class account_t; class parse_context_t; class parse_context_stack_t; -typedef std::list xacts_list; -typedef std::list auto_xacts_list; -typedef std::list period_xacts_list; -typedef std::pair payee_mapping_t; -typedef std::list payee_mappings_t; -typedef std::pair account_mapping_t; -typedef std::list account_mappings_t; -typedef std::map accounts_map; -typedef std::map checksum_map_t; -typedef std::multimap tag_check_exprs_map; +typedef std::list xacts_list; +typedef std::list auto_xacts_list; +typedef std::list period_xacts_list; +typedef std::pair payee_mapping_t; +typedef std::list payee_mappings_t; +typedef std::pair account_mapping_t; +typedef std::list account_mappings_t; +typedef std::map accounts_map; +typedef std::map checksum_map_t; + +typedef std::multimap tag_check_exprs_map; class journal_t : public noncopyable { From 7b406922e96189c0bdfbf40cd9cefd6a5a7c1f8a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Apr 2012 05:24:02 -0500 Subject: [PATCH 05/18] Silenced a warning in the very latest Clang --- src/pstream.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pstream.h b/src/pstream.h index 6e38158a..e9cddb4c 100644 --- a/src/pstream.h +++ b/src/pstream.h @@ -93,9 +93,6 @@ class ptristream : public std::istream case std::ios::end: setg(ptr, egptr()+off, ptr+len); break; - - default: - return pos_type(off_type(-1)); } return pos_type(gptr() - ptr); } From 95c44609a4d39e4fd70e74ba9d1d5c0bb8896188 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 28 Apr 2012 05:24:29 -0500 Subject: [PATCH 06/18] Made some of the value term parsing code more resilient --- src/token.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/token.cc b/src/token.cc index e5d6b218..afe48b08 100644 --- a/src/token.cc +++ b/src/token.cc @@ -417,16 +417,18 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags) if (! temp.parse(in, parse_flags.plus_flags(PARSE_SOFT_FAIL))) { in.clear(); in.seekg(pos, std::ios::beg); - if (in.fail()) + if (in.fail() || ! in.good()) throw_(parse_error, _("Failed to reset input stream")); c = static_cast(in.peek()); - if (! std::isalpha(c) && c != '_') - expected('\0', c); + if (c != -1) { + if (! std::isalpha(c) && c != '_') + expected('\0', c); - parse_ident(in); + parse_ident(in); + } - if (value.as_string().length() == 0) { + if (! value.is_string() || value.as_string().empty()) { kind = ERROR; symbol[0] = c; symbol[1] = '\0'; From 8f895fcda1fd3375f08bd29d3f975e6f112cee9a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 1 May 2012 13:45:46 -0500 Subject: [PATCH 07/18] Various changes to suit my environment --- acprep | 133 +++++++++------------------------------------------------ 1 file changed, 20 insertions(+), 113 deletions(-) diff --git a/acprep b/acprep index 463f028d..1d0b5bc5 100755 --- a/acprep +++ b/acprep @@ -46,6 +46,7 @@ class BoostInfo(object): include_path = "include" library_path = "lib" configured = False + no_includes = False def __init__(self, log): self.log = log @@ -970,8 +971,12 @@ class PrepareBuild(CommandLineApp): ######################################################################### def setup_system_directories(self): - boost_include = self.boost_info.include_directory() - boost_library = self.boost_info.library_directory() + if not self.boost_info.no_includes: + boost_include = self.boost_info.include_directory() + boost_library = self.boost_info.library_directory() + else: + boost_include = None + boost_library = None if re.match('/(usr|opt)/local', self.boost_info.home_path): self.log.debug("Setting Python home to /opt/local based on Boost's location") @@ -985,7 +990,7 @@ class PrepareBuild(CommandLineApp): self.envvars['PYTHON_VERSION'].strip()), '/opt/local/include', '/sw/include']: - if exists(path) and isdir(path) and \ + if path and exists(path) and isdir(path) and \ path != '/usr/include': self.log.info('Noticing include directory => ' + path) self.sys_include_dirs.append(path) @@ -1006,7 +1011,7 @@ class PrepareBuild(CommandLineApp): '/opt/local/lib', boost_library, '/sw/lib']: - if exists(path) and isdir(path) and \ + if path and exists(path) and isdir(path) and \ path not in self.sys_library_dirs: self.log.info('Noticing library directory => ' + path) self.sys_library_dirs.append(path) @@ -1014,36 +1019,17 @@ class PrepareBuild(CommandLineApp): def setup_for_johnw(self): self.envvars['PYTHON'] = '/opt/local/bin/python' self.envvars['PYTHON_HOME'] = '/opt/local' + self.envvars['CXX'] = '/Users/johnw/bin/cxx' + self.envvars['LD'] = '/Users/johnw/bin/cxx' - if self.options.use_clang: - self.log.info('Setting up for using Clang') + self.boost_info.configured = True # cxx does all this work for me + self.boost_info.no_includes = True - self.boost_inc_ident = "clang31" - self.boost_lib_ident = "clang-darwin" + if self.options.use_cpp11: + self.CXXFLAGS.append('-std=c++11') - if self.options.use_cpp11: - self.CXXFLAGS.append('-nostdlibinc') - self.CXXFLAGS.append('-isystem /usr/local/include') - self.CXXFLAGS.append('-isystem /usr/local/include/c++/v1') - self.CXXFLAGS.append('-isystem /usr/include') - - self.LDFLAGS.append('/usr/local/lib/libc++.dylib') - - self.log.debug('Using Clang ident: %s/%s' % - (self.boost_inc_ident, self.boost_lib_ident)) - else: - global search_prefixes - search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] - # match = re.search('gcc-mp-([0-9]+)\.([0-9]+)', self.envvars['CC']) - # if match: - # self.boost_inc_ident = "gcc" + match.group(1) + match.group(2) - # self.boost_lib_ident = "x" + self.boost_inc_ident - # else: - # self.boost_inc_ident = "gcc42" - # self.boost_lib_ident = "xgcc42" - # - # self.log.debug('Using Boost ident: %s/%s' % - # (self.boost_inc_ident, self.boost_lib_ident)) + if not self.options.use_clang: + self.CXXFLAGS.append('--gcc47') if self.current_flavor == 'debug': self.configure_args.append('--disable-shared') @@ -1055,8 +1041,6 @@ class PrepareBuild(CommandLineApp): self.CXXFLAGS.append('-DDOCUMENT_MODEL=1') - self.locate_darwin_libraries() - def setup_for_system(self): system = self.get_stdout('uname', '-s') @@ -1080,59 +1064,9 @@ class PrepareBuild(CommandLineApp): elif system == 'Darwin': if self.options.use_clang: - if exists('/usr/local/bin/clang++'): - self.envvars['CC'] = '/usr/local/bin/clang' - self.envvars['CXX'] = '/usr/local/bin/clang++' - self.envvars['LD'] = '/usr/local/bin/clang++' - elif exists('/opt/local/bin/clang++-mp-3.1'): - self.envvars['CC'] = '/opt/local/bin/clang-mp-3.1' - self.envvars['CXX'] = '/opt/local/bin/clang++-mp-3.1' - self.envvars['LD'] = '/opt/local/bin/clang++-mp-3.1' - else: - self.envvars['CC'] = 'clang' - self.envvars['CXX'] = 'clang++' - self.envvars['LD'] = 'llvm-ld' - elif (self.current_flavor == 'opt' or \ - self.current_flavor == 'default') and \ - not self.options.gcc45 and \ - not self.options.gcc46 and \ - not self.options.gcc47 and \ - not self.options.gcc48 and \ - exists('/usr/bin/g++-4.2'): - self.envvars['CC'] = '/usr/bin/gcc-4.2' - self.envvars['CXX'] = '/usr/bin/g++-4.2' - self.envvars['LD'] = '/usr/bin/g++-4.2' - self.darwin_gcc = True - elif exists('/usr/local/bin/g++-mp-4.8') and \ - self.options.gcc47: - self.envvars['CC'] = '/usr/local/bin/gcc-mp-4.8' - self.envvars['CXX'] = '/usr/local/bin/g++-mp-4.8' - self.envvars['LD'] = '/usr/local/bin/g++-mp-4.8' - elif exists('/usr/local/bin/g++-mp-4.7') and \ - self.options.gcc47: - self.envvars['CC'] = '/usr/local/bin/gcc-mp-4.7' - self.envvars['CXX'] = '/usr/local/bin/g++-mp-4.7' - self.envvars['LD'] = '/usr/local/bin/g++-mp-4.7' - elif exists('/opt/local/bin/g++-mp-4.7') and \ - self.options.gcc47: - self.envvars['CC'] = '/opt/local/bin/gcc-mp-4.7' - self.envvars['CXX'] = '/opt/local/bin/g++-mp-4.7' - self.envvars['LD'] = '/opt/local/bin/g++-mp-4.7' - elif exists('/opt/local/bin/g++-mp-4.6') and \ - self.options.gcc46: - self.envvars['CC'] = '/opt/local/bin/gcc-mp-4.6' - self.envvars['CXX'] = '/opt/local/bin/g++-mp-4.6' - self.envvars['LD'] = '/opt/local/bin/g++-mp-4.6' - elif exists('/opt/local/bin/g++-mp-4.5') and \ - self.options.gcc45: - self.envvars['CC'] = '/opt/local/bin/gcc-mp-4.5' - self.envvars['CXX'] = '/opt/local/bin/g++-mp-4.5' - self.envvars['LD'] = '/opt/local/bin/g++-mp-4.5' - elif exists('/usr/bin/g++-4.2'): - self.envvars['CC'] = '/usr/bin/gcc-4.2' - self.envvars['CXX'] = '/usr/bin/g++-4.2' - self.envvars['LD'] = '/usr/bin/g++-4.2' - self.darwin_gcc = True + self.envvars['CC'] = 'clang' + self.envvars['CXX'] = 'clang++' + self.envvars['LD'] = 'llvm-ld' else: # g++ 4.0.1 cannot use PCH headers on OS X 10.5 self.option_no_pch() @@ -1322,33 +1256,6 @@ class PrepareBuild(CommandLineApp): # The various build flavors # ######################################################################### - def locate_darwin_libraries(self): - if self.current_flavor == 'debug': - if (self.options.use_clang or self.options.use_cpp11) and \ - self.boost_info.configure( - home_path = '/usr/local/stow/boost_%s-%s' % \ - (self.boost_version, self.boost_inc_ident), - suffix = '-%s-d-%s' % \ - (self.boost_lib_ident, self.boost_major), - file_suffix = '.dylib', - include_path = 'include/boost-%s' % self.boost_major): - pass - elif self.boost_info.configure(suffix = '-d', file_suffix = '.dylib'): - pass - - else: - if self.boost_info.configure(): - pass - elif (self.options.use_clang or self.options.use_cpp11) and \ - self.boost_info.configure( - home_path = '/usr/local/stow/boost_%s-%s' % \ - (self.boost_version, self.boost_inc_ident), - suffix = '-%s-%s' % \ - (self.boost_lib_ident, self.boost_major), - file_suffix = '.dylib', - include_path = 'include/boost-%s' % self.boost_major): - pass - def setup_flavor_default(self): if self.darwin_gcc: self.option_no_pch() From 6a0daf634fa76ba61ea79e55e4d3f213aa27e306 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 1 May 2012 13:46:04 -0500 Subject: [PATCH 08/18] Added script for building Boost with GCC --- lib/build-gcc.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 lib/build-gcc.sh diff --git a/lib/build-gcc.sh b/lib/build-gcc.sh new file mode 100755 index 00000000..af3decb8 --- /dev/null +++ b/lib/build-gcc.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# This build script is for OS X Lion users who have compiled openmpi and +# clang-3.1 from MacPorts. I build my own Boost instead of using MacPorts' +# Boost in order to get better debugging support, and to link with libc++. + +export PATH=$PATH:/opt/local/lib/openmpi/bin + +cat > ~/user-config.jam <-std=c++11 /usr/local/include ; +EOF + +# jww (2012-04-24): This is still linking against /usr/lib/libc++.1.dylib +# instead of /usr/local/lib/libc++.1.dylib +make "$@" OPTJ=-j20 \ + BOOST_DEFINES="-sICU_PATH=/opt/local cxxflags=\"-I/opt/local/include\" linkflags=\"-L/opt/local/lib\"" From c0fa144ca586bfc3d48d7f2512bb90ebdde148df Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 7 May 2012 01:53:53 -0500 Subject: [PATCH 09/18] Added "last_checkout_cleared" valexpr variable --- src/account.cc | 10 +++++++++- src/account.h | 1 + src/textual.cc | 8 ++++---- src/timelog.cc | 2 +- src/timelog.h | 15 +++++++++------ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/account.cc b/src/account.cc index 206e2350..1ea13330 100644 --- a/src/account.cc +++ b/src/account.cc @@ -309,6 +309,10 @@ namespace { return (! account.self_details().latest_checkout.is_not_a_date_time() ? value_t(account.self_details().latest_checkout) : NULL_VALUE); } + value_t get_latest_checkout_cleared(account_t& account) + { + return account.self_details().latest_checkout_cleared; + } template value_t get_wrapper(call_scope_t& args) { @@ -405,6 +409,8 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind, return WRAP_FUNCTOR(get_wrapper<&get_latest>); else if (fn_name == "latest_checkout") return WRAP_FUNCTOR(get_wrapper<&get_latest_checkout>); + else if (fn_name == "latest_checkout_cleared") + return WRAP_FUNCTOR(get_wrapper<&get_latest_checkout_cleared>); break; case 'n': @@ -662,8 +668,10 @@ void account_t::xdata_t::details_t::update(post_t& post, earliest_checkin = *post.checkin; if (post.checkout && (latest_checkout.is_not_a_date_time() || - *post.checkout > latest_checkout)) + *post.checkout > latest_checkout)) { latest_checkout = *post.checkout; + latest_checkout_cleared = post.state() == item_t::CLEARED; + } if (post.state() == item_t::CLEARED) { posts_cleared_count++; diff --git a/src/account.h b/src/account.h index 2aa3f2eb..b751cb0b 100644 --- a/src/account.h +++ b/src/account.h @@ -183,6 +183,7 @@ public: datetime_t earliest_checkin; datetime_t latest_checkout; + bool latest_checkout_cleared; std::set filenames; std::set accounts_referenced; diff --git a/src/textual.cc b/src/textual.cc index d0e4dad2..011e45b7 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -431,7 +431,7 @@ void instance_t::read_next_directive(bool& error_flag) #if defined(TIMELOG_SUPPORT) -void instance_t::clock_in_directive(char * line, bool /*capitalized*/) +void instance_t::clock_in_directive(char * line, bool capitalized) { string datetime(line, 2, 19); @@ -452,7 +452,7 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/) position.end_line = context.linenum; position.sequence = context.sequence++; - time_xact_t event(position, parse_datetime(datetime), + time_xact_t event(position, parse_datetime(datetime), capitalized, p ? top_account()->find_account(p) : NULL, n ? n : "", end ? end : ""); @@ -460,7 +460,7 @@ void instance_t::clock_in_directive(char * line, bool /*capitalized*/) timelog.clock_in(event); } -void instance_t::clock_out_directive(char * line, bool /*capitalized*/) +void instance_t::clock_out_directive(char * line, bool capitalized) { string datetime(line, 2, 19); @@ -481,7 +481,7 @@ void instance_t::clock_out_directive(char * line, bool /*capitalized*/) position.end_line = context.linenum; position.sequence = context.sequence++; - time_xact_t event(position, parse_datetime(datetime), + time_xact_t event(position, parse_datetime(datetime), capitalized, p ? top_account()->find_account(p) : NULL, n ? n : "", end ? end : ""); diff --git a/src/timelog.cc b/src/timelog.cc index e84e4188..9516ba17 100644 --- a/src/timelog.cc +++ b/src/timelog.cc @@ -62,7 +62,7 @@ namespace { VERIFY(amt.valid()); post_t * post = new post_t(in_event.account, amt, POST_VIRTUAL); - post->set_state(item_t::CLEARED); + post->set_state(out_event.completed ? item_t::CLEARED : item_t::UNCLEARED); post->pos = in_event.position; post->checkin = in_event.checkin; post->checkout = out_event.checkin; diff --git a/src/timelog.h b/src/timelog.h index 857952ff..a902c084 100644 --- a/src/timelog.h +++ b/src/timelog.h @@ -56,6 +56,7 @@ class time_xact_t { public: datetime_t checkin; + bool completed; account_t * account; string desc; string note; @@ -66,16 +67,18 @@ public: } time_xact_t(const optional& _position, const datetime_t& _checkin, - account_t * _account = NULL, - const string& _desc = "", - const string& _note = "") - : checkin(_checkin), account(_account), desc(_desc), note(_note), + const bool _completed = false, + account_t * _account = NULL, + const string& _desc = "", + const string& _note = "") + : checkin(_checkin), completed(_completed), account(_account), + desc(_desc), note(_note), position(_position ? *_position : position_t()) { TRACE_CTOR(time_xact_t, - "position_t, datetime_t, account_t *, string, string"); + "position_t, datetime_t, bool, account_t *, string, string"); } time_xact_t(const time_xact_t& xact) - : checkin(xact.checkin), account(xact.account), + : checkin(xact.checkin), completed(xact.completed), account(xact.account), desc(xact.desc), note(xact.note), position(xact.position) { TRACE_CTOR(time_xact_t, "copy"); } From e5c4c20cbb29f0c73dde26ba71df33b400b1d9d4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 7 May 2012 01:54:20 -0500 Subject: [PATCH 10/18] Made some code in option.h a bit safer --- src/option.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/option.h b/src/option.h index 772f2b01..b0d4e0f0 100644 --- a/src/option.h +++ b/src/option.h @@ -68,7 +68,7 @@ public: option_t(const char * _name, const char _ch = '\0') : name(_name), name_len(std::strlen(name)), ch(_ch), handled(false), parent(NULL), value(), - wants_arg(name[name_len - 1] == '_') { + wants_arg(name_len > 0 ? name[name_len - 1] == '_' : false) { DEBUG("option.names", "Option: " << name); TRACE_CTOR(option_t, "const char *, const char"); } From 3122182c48f5fb3da437860440bb7ab1b64cc32b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 7 May 2012 01:55:52 -0500 Subject: [PATCH 11/18] Don't run the proof build against Clang for now --- tools/proof | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/proof b/tools/proof index c4d3c9f1..33f825de 100755 --- a/tools/proof +++ b/tools/proof @@ -20,19 +20,19 @@ ledger_proof() { time nice -n 20 \ ./acprep --debug --enable-doxygen --universal --gcc47 -j16 proof 2>&1 | \ - tee -a $LOGDIR/ledger-proof.log + tee -a $LOGDIR/ledger-proof-gcc47.log time nice -n 20 \ ./acprep --debug --enable-doxygen --universal --python --gcc47 -j16 proof 2>&1 | \ - tee -a $LOGDIR/ledger-proof.log + tee -a $LOGDIR/ledger-proof-gcc47-python.log - time nice -n 20 \ - ./acprep --debug --enable-doxygen --universal --clang -j16 proof 2>&1 | \ - tee -a $LOGDIR/ledger-proof.log - - time nice -n 20 \ - ./acprep --debug --enable-doxygen --universal --python --clang -j16 proof 2>&1 | \ - tee -a $LOGDIR/ledger-proof.log + #time nice -n 20 \ + # ./acprep --debug --enable-doxygen --universal --clang -j16 proof 2>&1 | \ + # tee -a $LOGDIR/ledger-proof-clang.log + # + #time nice -n 20 \ + # ./acprep --debug --enable-doxygen --universal --python --clang -j16 proof 2>&1 | \ + # tee -a $LOGDIR/ledger-proof-clang-python.log if egrep -q '(ERROR|CRITICAL)' $LOGDIR/ledger-proof.log; then mutt -a $LOGDIR/ledger-proof.log \ From 1cc618a95600d9908cda4975807b971f36440386 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 10 May 2012 04:03:32 -0500 Subject: [PATCH 12/18] Added a * for cleared entries in the time report --- src/report.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/report.h b/src/report.h index e7d68dda..d04b3e15 100644 --- a/src/report.h +++ b/src/report.h @@ -965,10 +965,13 @@ public: OPTION_(report_t, time_report, DO() { OTHER(balance_format_) .on(none, - "%(justify(earliest_checkin ? " - " format_datetime(earliest_checkin) : \"\", 19, -1, true)) " - "%(justify(latest_checkout ? " - " format_datetime(latest_checkout) : \"\", 19, -1, true)) " + "%(ansify_if(justify(earliest_checkin ? " + " format_datetime(earliest_checkin) : \"\", 19, -1, true)," + " bold if latest_checkout_cleared)) " + "%(ansify_if(justify(latest_checkout ? " + " format_datetime(latest_checkout) : \"\", 19, -1, true), " + " bold if latest_checkout_cleared)) " + "%(latest_checkout_cleared ? \"*\" : \" \") " "%(ansify_if(" " justify(scrub(display_total), 8," " 8 + 4 + 19 * 2, true, color), bold if should_bold))" From a53f5c1136a3f7ed7df5a74921ab05553a44fc7a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 10 May 2012 04:04:28 -0500 Subject: [PATCH 13/18] Bump version number to v3.0.0-20120510 --- version.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.m4 b/version.m4 index e70e96e3..b6e3b58f 100644 --- a/version.m4 +++ b/version.m4 @@ -1 +1 @@ -m4_define([VERSION_NUMBER], [3.0.0-20120426]) +m4_define([VERSION_NUMBER], [3.0.0-20120510]) From 6a18669aa0f623d7ae9fe867d739f3c9632fa22e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 10 May 2012 04:11:50 -0500 Subject: [PATCH 14/18] An acprep simplification --- acprep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acprep b/acprep index 1d0b5bc5..c0846488 100755 --- a/acprep +++ b/acprep @@ -1019,14 +1019,14 @@ class PrepareBuild(CommandLineApp): def setup_for_johnw(self): self.envvars['PYTHON'] = '/opt/local/bin/python' self.envvars['PYTHON_HOME'] = '/opt/local' - self.envvars['CXX'] = '/Users/johnw/bin/cxx' - self.envvars['LD'] = '/Users/johnw/bin/cxx' self.boost_info.configured = True # cxx does all this work for me self.boost_info.no_includes = True if self.options.use_cpp11: self.CXXFLAGS.append('-std=c++11') + self.envvars['CXX'] = '/Users/johnw/bin/cxx' + self.envvars['LD'] = '/Users/johnw/bin/cxx' if not self.options.use_clang: self.CXXFLAGS.append('--gcc47') From 8c0cb63dfd203a9c89fdad5bf2835c4f6dfa3c01 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 10 May 2012 04:25:18 -0500 Subject: [PATCH 15/18] Change the way I choose a default compiler --- acprep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acprep b/acprep index c0846488..b4e0b979 100755 --- a/acprep +++ b/acprep @@ -1028,8 +1028,8 @@ class PrepareBuild(CommandLineApp): self.envvars['CXX'] = '/Users/johnw/bin/cxx' self.envvars['LD'] = '/Users/johnw/bin/cxx' - if not self.options.use_clang: - self.CXXFLAGS.append('--gcc47') + #if not self.options.use_clang: + # self.CXXFLAGS.append('--gcc47') if self.current_flavor == 'debug': self.configure_args.append('--disable-shared') From b898d40a81167113b7c235b9458636b29f90fd86 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 10 May 2012 16:30:32 -0500 Subject: [PATCH 16/18] More configuration fixes --- acprep | 6 +++++- tools/configure.ac | 52 +++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/acprep b/acprep index b4e0b979..ea3583c4 100755 --- a/acprep +++ b/acprep @@ -539,6 +539,9 @@ class PrepareBuild(CommandLineApp): op.add_option('', '--cpp11', action='store_true', dest='use_cpp11', default=False, help='Use C++11 extensions (requires Clang or gcc 4.6/7/8)') + op.add_option('', '--plain', action='store_true', + dest='use_plain', default=False, + help="Don't customize for my private environment") op.add_option('', '--output', metavar='DIR', action="callback", callback=self.option_output, help='Build in the specified directory') @@ -1080,7 +1083,8 @@ class PrepareBuild(CommandLineApp): if self.options.no_python: self.configure_args.remove('--enable-python') - if exists('/Users/johnw/Projects/ledger/plan/TODO'): + if not self.options.use_plain and \ + exists('/Users/johnw/Projects/ledger/plan/TODO'): self.setup_for_johnw() self.setup_system_directories() diff --git a/tools/configure.ac b/tools/configure.ac index 99eb7df5..418ffd7d 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -528,32 +528,32 @@ AC_CACHE_CHECK( AM_CONDITIONAL(HAVE_BOOST_TEST, test x$boost_test_avail_cv_ = xtrue) # check for C++11 and libc++ -AC_CACHE_CHECK( - [if C++11 and libc++ are available], - [cpp11_avail_cv_], - [cpp11_save_cxxflags=$CXXFLAGS - cpp11_save_ldflags=$LDFLAGS - CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" - LDFLAGS="-stdlib=libc++ $LDFLAGS" - AC_LANG_PUSH(C++) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include - #include ]], - [[boost::regex foo_regexp("Hello, world!"); - for (auto i : "Hello, world") - std::cout << i << std::endl;]])], - [cpp11_avail_cv_=true], - [cpp11_avail_cv_=false]) - AC_LANG_POP - CXXFLAGS="$cpp11_save_cxxflags" - LDFLAGS="$cpp11_save_ldflags"]) - -if [test x$cpp11_avail_cv_ = xtrue]; then - AC_DEFINE([HAVE_CPP11], [1], [Whether C++11 and libc++ are available]) - CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" - LDFLAGS="-stdlib=libc++ $LDFLAGS" -fi +#AC_CACHE_CHECK( +# [if C++11 and libc++ are available], +# [cpp11_avail_cv_], +# [cpp11_save_cxxflags=$CXXFLAGS +# cpp11_save_ldflags=$LDFLAGS +# CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" +# LDFLAGS="-stdlib=libc++ $LDFLAGS" +# AC_LANG_PUSH(C++) +# AC_LINK_IFELSE( +# [AC_LANG_PROGRAM( +# [[#include +# #include ]], +# [[boost::regex foo_regexp("Hello, world!"); +# for (auto i : "Hello, world") +# std::cout << i << std::endl;]])], +# [cpp11_avail_cv_=true], +# [cpp11_avail_cv_=false]) +# AC_LANG_POP +# CXXFLAGS="$cpp11_save_cxxflags" +# LDFLAGS="$cpp11_save_ldflags"]) +# +#if [test x$cpp11_avail_cv_ = xtrue]; then +# AC_DEFINE([HAVE_CPP11], [1], [Whether C++11 and libc++ are available]) +# CXXFLAGS="-std=c++11 -stdlib=libc++ $CXXFLAGS" +# LDFLAGS="-stdlib=libc++ $LDFLAGS" +#fi # Checks for header files. AC_HEADER_STDC From 32eaa0346959188a030cd217ec02b02040efeb26 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 14 May 2012 21:37:13 -0600 Subject: [PATCH 17/18] Fixed a hidden memory corruption bug --- src/times.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/times.cc b/src/times.cc index 3c556a47..30da301f 100644 --- a/src/times.cc +++ b/src/times.cc @@ -48,7 +48,7 @@ namespace { template class temporal_io_t : public noncopyable { - const char * fmt_str; + string fmt_str; #if defined(USE_BOOST_FACETS) std::istringstream input_stream; std::ostringstream output_stream; @@ -104,7 +104,7 @@ namespace { #else // USE_BOOST_FACETS std::tm data(to_tm(when)); char buf[128]; - std::strftime(buf, 127, fmt_str, &data); + std::strftime(buf, 127, fmt_str.c_str(), &data); return buf; #endif // USE_BOOST_FACETS } @@ -138,7 +138,7 @@ namespace { #else // USE_BOOST_FACETS std::tm data; std::memset(&data, 0, sizeof(std::tm)); - if (strptime(str, fmt_str, &data)) + if (strptime(str, fmt_str.c_str(), &data)) return posix_time::ptime_from_tm(data); else return datetime_t(); @@ -175,7 +175,7 @@ namespace { std::memset(&data, 0, sizeof(std::tm)); data.tm_year = CURRENT_DATE().year() - 1900; data.tm_mday = 1; // some formats have no day - if (strptime(str, fmt_str, &data)) + if (strptime(str, fmt_str.c_str(), &data)) return gregorian::date_from_tm(data); else return date_t(); From 96172669053bbba7263a370f109f70615049a0c6 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 14 May 2012 21:37:36 -0600 Subject: [PATCH 18/18] Improved detection of iostream's eof() condition --- src/csv.cc | 2 +- src/token.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/csv.cc b/src/csv.cc index 1e55129e..71b6516a 100644 --- a/src/csv.cc +++ b/src/csv.cc @@ -87,7 +87,7 @@ char * csv_reader::next_line(std::istream& in) while (in.good() && ! in.eof() && in.peek() == '#') in.getline(context.linebuf, parse_context_t::MAX_LINE); - if (! in.good() || in.eof()) + if (! in.good() || in.eof() || in.peek() == -1) return NULL; in.getline(context.linebuf, parse_context_t::MAX_LINE); diff --git a/src/token.cc b/src/token.cc index afe48b08..1392c29f 100644 --- a/src/token.cc +++ b/src/token.cc @@ -148,7 +148,7 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags) char c = peek_next_nonws(in); - if (in.eof()) { + if (in.eof() || c == -1) { kind = TOK_EOF; return; } @@ -426,6 +426,8 @@ void expr_t::token_t::next(std::istream& in, const parse_flags_t& pflags) expected('\0', c); parse_ident(in); + } else { + throw_(parse_error, _("Unexpected EOF")); } if (! value.is_string() || value.as_string().empty()) {