diff options
-rwxr-xr-x | acprep | 162 | ||||
-rwxr-xr-x | lib/build-gcc.sh | 16 | ||||
-rw-r--r-- | src/account.cc | 10 | ||||
-rw-r--r-- | src/account.h | 3 | ||||
-rw-r--r-- | src/csv.cc | 2 | ||||
-rw-r--r-- | src/journal.h | 22 | ||||
-rw-r--r-- | src/option.h | 2 | ||||
-rw-r--r-- | src/pstream.h | 3 | ||||
-rw-r--r-- | src/pyutils.h | 2 | ||||
-rw-r--r-- | src/report.h | 11 | ||||
-rw-r--r-- | src/textual.cc | 8 | ||||
-rw-r--r-- | src/timelog.cc | 2 | ||||
-rw-r--r-- | src/timelog.h | 15 | ||||
-rw-r--r-- | src/times.cc | 8 | ||||
-rw-r--r-- | src/token.cc | 16 | ||||
-rw-r--r-- | src/utils.cc | 4 | ||||
-rw-r--r-- | src/utils.h | 8 | ||||
-rw-r--r-- | tools/configure.ac | 28 | ||||
-rwxr-xr-x | tools/proof | 22 | ||||
-rw-r--r-- | version.m4 | 2 |
20 files changed, 160 insertions, 186 deletions
@@ -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 @@ -538,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') @@ -970,8 +974,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 +993,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 +1014,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) @@ -1015,39 +1023,16 @@ class PrepareBuild(CommandLineApp): self.envvars['PYTHON'] = '/opt/local/bin/python' self.envvars['PYTHON_HOME'] = '/opt/local' - if self.options.use_clang: - self.log.info('Setting up for using Clang') - - self.boost_inc_ident = "clang31" - 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') - else: - global search_prefixes - search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] + self.boost_info.configured = True # cxx does all this work for me + self.boost_info.no_includes = True - 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" + 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' - 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') @@ -1059,8 +1044,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') @@ -1084,59 +1067,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() @@ -1150,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() @@ -1232,6 +1166,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') @@ -1325,33 +1260,6 @@ class PrepareBuild(CommandLineApp): # The various build flavors # ######################################################################### - def locate_darwin_libraries(self): - if self.current_flavor == 'debug': - if (not 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 (not 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() @@ -1706,8 +1614,10 @@ class PrepareBuild(CommandLineApp): source_copy_dir = join(self.ensure(self.products_directory()), proof_dir) - self.execute('rsync', '-a', '--delete', + self.execute('rsync', '-a', '--delete', '--exclude=/dist/', '--exclude=.git/', '--exclude=b/', + '--exclude=/lib/boost-release/', + '--exclude=/archive/', '--exclude=/build/', '%s/' % self.source_dir, '%s/' % source_copy_dir) self.source_dir = source_copy_dir @@ -1724,9 +1634,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 +1659,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/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 <<EOF +using clang-darwin : : "/usr/local/bin/clang++" : <cxxflags>-std=c++11 <include>/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\"" 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 (*Func)(account_t&)> 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 c0e3e1f7..b751cb0b 100644 --- a/src/account.h +++ b/src/account.h @@ -51,7 +51,7 @@ class xact_t; class post_t; typedef std::list<post_t *> posts_list; -typedef std::map<const string, account_t *> accounts_map; +typedef std::map<string, account_t *> accounts_map; class account_t : public supports_flags<>, public scope_t { @@ -183,6 +183,7 @@ public: datetime_t earliest_checkin; datetime_t latest_checkout; + bool latest_checkout_cleared; std::set<path> filenames; std::set<string> accounts_referenced; @@ -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/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<xact_t *> xacts_list; -typedef std::list<auto_xact_t *> auto_xacts_list; -typedef std::list<period_xact_t *> period_xacts_list; -typedef std::pair<mask_t, string> payee_mapping_t; -typedef std::list<payee_mapping_t> payee_mappings_t; -typedef std::pair<mask_t, account_t *> account_mapping_t; -typedef std::list<account_mapping_t> account_mappings_t; -typedef std::map<const string, account_t *> accounts_map; -typedef std::map<string, xact_t *> checksum_map_t; -typedef std::multimap<string, - expr_t::check_expr_pair> tag_check_exprs_map; +typedef std::list<xact_t *> xacts_list; +typedef std::list<auto_xact_t *> auto_xacts_list; +typedef std::list<period_xact_t *> period_xacts_list; +typedef std::pair<mask_t, string> payee_mapping_t; +typedef std::list<payee_mapping_t> payee_mappings_t; +typedef std::pair<mask_t, account_t *> account_mapping_t; +typedef std::list<account_mapping_t> account_mappings_t; +typedef std::map<string, account_t *> accounts_map; +typedef std::map<string, xact_t *> checksum_map_t; + +typedef std::multimap<string, expr_t::check_expr_pair> tag_check_exprs_map; class journal_t : public noncopyable { 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"); } 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); } 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/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))" 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_t>& _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"); } 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 <typename T, typename InputFacetType, typename OutputFacetType> 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(); diff --git a/src/token.cc b/src/token.cc index e5d6b218..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; } @@ -417,16 +417,20 @@ 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<char>(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); + } else { + throw_(parse_error, _("Unexpected EOF")); + } - if (value.as_string().length() == 0) { + if (! value.is_string() || value.as_string().empty()) { kind = ERROR; symbol[0] = c; symbol[1] = '\0'; 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<ledger::string> { 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..418ffd7d 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 <boost/regex.hpp> +# #include <iostream>]], +# [[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 diff --git a/tools/proof b/tools/proof index 00c7f7d1..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 \ @@ -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 <<EOF Ledger proof build succeeded! at commit $VERSION. @@ -1 +1 @@ -m4_define([VERSION_NUMBER], [3.0.0-20120426]) +m4_define([VERSION_NUMBER], [3.0.0-20120510]) |