summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dir-locals.el66
-rw-r--r--.gitignore3
-rw-r--r--.gitmodules3
-rw-r--r--.travis.yml104
-rw-r--r--CMakeLists.txt59
-rw-r--r--LICENSE.md2
-rw-r--r--README.md11
-rwxr-xr-xacprep40
-rw-r--r--cmake/FindUtfcpp.cmake30
-rw-r--r--contrib/ParseCcStmt.cs2
-rwxr-xr-xcontrib/iso4127-commodities/iso4217ledger.sh2
-rw-r--r--contrib/raw/dotemacs.el82
-rw-r--r--contrib/raw/ledger-matching.el92
-rw-r--r--doc/NEWS30
-rw-r--r--doc/ledger-mode.texi67
-rw-r--r--doc/ledger.1292
-rw-r--r--doc/ledger3.texi875
m---------lib/utfcpp0
-rw-r--r--lib/utfcpp/v2_0/LICENSE (renamed from doc/LICENSE-utfcpp)2
-rwxr-xr-xlib/utfcpp/v2_0/buildrelease.pl18
-rw-r--r--lib/utfcpp/v2_0/samples/Makefile5
-rw-r--r--lib/utfcpp/v2_0/samples/docsample.cpp52
-rw-r--r--lib/utfcpp/v2_0/source/utf8.h34
-rw-r--r--lib/utfcpp/v2_0/source/utf8/checked.h327
-rw-r--r--lib/utfcpp/v2_0/source/utf8/core.h329
-rw-r--r--lib/utfcpp/v2_0/source/utf8/unchecked.h228
-rw-r--r--lisp/ledger-check.el136
-rw-r--r--lisp/ledger-commodities.el20
-rw-r--r--lisp/ledger-complete.el6
-rw-r--r--lisp/ledger-context.el8
-rw-r--r--lisp/ledger-exec.el4
-rw-r--r--lisp/ledger-fontify.el243
-rw-r--r--lisp/ledger-fonts.el2
-rw-r--r--lisp/ledger-init.el6
-rw-r--r--lisp/ledger-mode.el40
-rw-r--r--lisp/ledger-navigate.el164
-rw-r--r--lisp/ledger-occur.el32
-rw-r--r--lisp/ledger-post.el50
-rw-r--r--lisp/ledger-reconcile.el237
-rw-r--r--lisp/ledger-regex.el56
-rw-r--r--lisp/ledger-report.el78
-rw-r--r--lisp/ledger-schedule.el170
-rw-r--r--lisp/ledger-sort.el8
-rw-r--r--lisp/ledger-state.el6
-rw-r--r--lisp/ledger-test.el2
-rw-r--r--lisp/ledger-texi.el2
-rw-r--r--lisp/ledger-xact.el40
-rw-r--r--src/CMakeLists.txt15
-rw-r--r--src/account.cc2
-rw-r--r--src/account.h28
-rw-r--r--src/amount.cc81
-rw-r--r--src/amount.h12
-rw-r--r--src/annotate.cc2
-rw-r--r--src/annotate.h50
-rw-r--r--src/archive.cc295
-rw-r--r--src/archive.h92
-rw-r--r--src/balance.cc2
-rw-r--r--src/balance.h14
-rw-r--r--src/chain.cc2
-rw-r--r--src/chain.h2
-rw-r--r--src/commodity.cc2
-rw-r--r--src/commodity.h63
-rw-r--r--src/compare.cc2
-rw-r--r--src/compare.h2
-rw-r--r--src/context.h2
-rw-r--r--src/convert.cc2
-rw-r--r--src/convert.h2
-rw-r--r--src/csv.cc2
-rw-r--r--src/csv.h2
-rw-r--r--src/draft.cc2
-rw-r--r--src/draft.h2
-rw-r--r--src/emacs.cc2
-rw-r--r--src/emacs.h4
-rw-r--r--src/error.cc2
-rw-r--r--src/error.h2
-rw-r--r--src/expr.cc2
-rw-r--r--src/expr.h15
-rw-r--r--src/exprbase.h17
-rw-r--r--src/filters.cc4
-rw-r--r--src/filters.h2
-rw-r--r--src/flags.h24
-rw-r--r--src/format.cc2
-rw-r--r--src/format.h2
-rw-r--r--src/generate.cc2
-rw-r--r--src/generate.h2
-rw-r--r--src/global.cc16
-rw-r--r--src/global.h5
-rw-r--r--src/history.cc4
-rw-r--r--src/history.h2
-rw-r--r--src/item.cc2
-rw-r--r--src/item.h44
-rw-r--r--src/iterators.cc4
-rw-r--r--src/iterators.h2
-rw-r--r--src/journal.cc2
-rw-r--r--src/journal.h37
-rw-r--r--src/lookup.cc4
-rw-r--r--src/lookup.h2
-rw-r--r--src/main.cc2
-rw-r--r--src/mask.cc2
-rw-r--r--src/mask.h21
-rw-r--r--src/op.cc2
-rw-r--r--src/op.h29
-rw-r--r--src/option.cc2
-rw-r--r--src/option.h2
-rw-r--r--src/org.cc2
-rw-r--r--src/org.h2
-rw-r--r--src/output.cc8
-rw-r--r--src/output.h12
-rw-r--r--src/parser.cc2
-rw-r--r--src/parser.h4
-rw-r--r--src/pool.cc2
-rw-r--r--src/pool.h26
-rw-r--r--src/post.cc2
-rw-r--r--src/post.h26
-rw-r--r--src/precmd.cc2
-rw-r--r--src/precmd.h2
-rw-r--r--src/predicate.h15
-rw-r--r--src/print.cc2
-rw-r--r--src/print.h2
-rw-r--r--src/pstream.h2
-rw-r--r--src/ptree.cc2
-rw-r--r--src/ptree.h2
-rw-r--r--src/py_account.cc2
-rw-r--r--src/py_amount.cc2
-rw-r--r--src/py_balance.cc2
-rw-r--r--src/py_commodity.cc5
-rw-r--r--src/py_expr.cc2
-rw-r--r--src/py_format.cc2
-rw-r--r--src/py_item.cc16
-rw-r--r--src/py_journal.cc5
-rw-r--r--src/py_post.cc2
-rw-r--r--src/py_session.cc2
-rw-r--r--src/py_times.cc2
-rw-r--r--src/py_utils.cc2
-rw-r--r--src/py_value.cc2
-rw-r--r--src/py_xact.cc2
-rw-r--r--src/pyfstream.h2
-rw-r--r--src/pyinterp.cc2
-rw-r--r--src/pyinterp.h4
-rw-r--r--src/pyledger.cc2
-rw-r--r--src/pyutils.h2
-rw-r--r--src/query.cc2
-rw-r--r--src/query.h2
-rw-r--r--src/quotes.cc2
-rw-r--r--src/quotes.h2
-rw-r--r--src/report.cc3
-rw-r--r--src/report.h9
-rw-r--r--src/scope.cc2
-rw-r--r--src/scope.h101
-rw-r--r--src/select.cc4
-rw-r--r--src/select.h2
-rw-r--r--src/session.cc101
-rw-r--r--src/session.h4
-rw-r--r--src/stats.cc2
-rw-r--r--src/stats.h2
-rw-r--r--src/stream.cc2
-rw-r--r--src/stream.h2
-rw-r--r--src/strptime.cc2
-rw-r--r--src/system.hh.in93
-rw-r--r--src/temps.cc2
-rw-r--r--src/temps.h2
-rw-r--r--src/textual.cc2
-rw-r--r--src/timelog.cc2
-rw-r--r--src/timelog.h2
-rw-r--r--src/times.cc2
-rw-r--r--src/times.h94
-rw-r--r--src/token.cc2
-rw-r--r--src/token.h2
-rw-r--r--src/unistring.h2
-rw-r--r--src/utils.cc2
-rw-r--r--src/utils.h2
-rw-r--r--src/value.cc6
-rw-r--r--src/value.h32
-rw-r--r--src/views.cc2
-rw-r--r--src/views.h4
-rw-r--r--src/wcwidth.cc2
-rw-r--r--src/xact.cc2
-rw-r--r--src/xact.h74
-rw-r--r--test/CMakeLists.txt13
-rwxr-xr-xtest/CheckBaselineTests.py12
-rwxr-xr-xtest/CheckOptions.py2
-rwxr-xr-xtest/DocTests.py98
-rwxr-xr-xtest/RegressTests.py7
-rw-r--r--test/baseline/cmd-cleared.test2
-rw-r--r--test/baseline/cmd-convert.test (renamed from test/baseline/cmd-convert.test.disable)4
-rw-r--r--test/baseline/dir-fixed.test (renamed from test/baseline/feat-fixated-prices_2.test)0
-rw-r--r--test/baseline/opt-auto-match.test47
-rw-r--r--test/baseline/opt-cleared-format.test20
-rw-r--r--test/baseline/opt-explicit.test14
-rw-r--r--test/baseline/opt-file.test (renamed from test/baseline/opt-file.test.disable)0
-rw-r--r--test/baseline/opt-generated.test0
-rw-r--r--test/baseline/opt-init-file.dat1
-rw-r--r--test/baseline/opt-init-file.test10
-rw-r--r--test/baseline/opt-no-pager.test0
-rw-r--r--test/baseline/opt-no-revalued.test58
-rw-r--r--test/baseline/opt-no-rounding.test81
-rw-r--r--test/baseline/opt-price-db.dat2
-rw-r--r--test/baseline/opt-price-db.test8
-rw-r--r--test/baseline/opt-rich-data.test10
-rw-r--r--test/baseline/opt-script.dat3
-rw-r--r--test/baseline/opt-script.test15
-rw-r--r--test/baseline/opt-value-expr.test48
-rw-r--r--test/baseline/opt-verify-memory.test0
-rwxr-xr-xtest/convert.py2
-rw-r--r--test/regress/1057.test11
-rw-r--r--test/regress/25A099C9.test61
-rw-r--r--test/regress/25A099C9.test.disable43
-rw-r--r--test/regress/8EAF77C0.test2
-rw-r--r--test/regress/AEDE9734.test6
-rw-r--r--test/unit/CMakeLists.txt11
-rw-r--r--test/unit/t_value.cc711
-rwxr-xr-xtools/prepare-commit-msg6
-rwxr-xr-xtools/travis-before_install.sh16
-rwxr-xr-xtools/travis-install.sh22
-rwxr-xr-xtools/update_copyright_year.sh36
215 files changed, 4403 insertions, 2740 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
index edafaded..ca104fb0 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,30 +1,36 @@
-((nil . ((tab-width . 2)
- (sentence-end-double-space . t)
- (bug-reference-url-format
- . "http://bugs.ledger-cli.org/show_bug.cgi?id=%s")))
- (c-mode . ((c-file-style . "ledger")
- (c-style-alist
- ("ledger"
- (indent-tabs-mode)
- (c-basic-offset . 2)
- (c-comment-only-line-offset 0 . 0)
- (c-hanging-braces-alist
- (substatement-open before after)
- (arglist-cont-nonempty))
- (c-offsets-alist
- (statement-block-intro . +)
- (knr-argdecl-intro . 5)
- (substatement-open . 0)
- (substatement-label . 0)
- (label . 0)
- (case-label . 0)
- (statement-case-open . 0)
- (statement-cont . +)
- (arglist-intro . +)
- (arglist-close . +)
- (inline-open . 0)
- (brace-list-open . 0)
- (topmost-intro-cont first c-lineup-topmost-intro-cont
- c-lineup-gnu-DEFUN-intro-cont))
- (c-special-indent-hook . c-gnu-impose-minimum)
- (c-block-comment-prefix . ""))))))
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((nil
+ (tab-width . 2)
+ (sentence-end-double-space . t)
+ (bug-reference-url-format . "http://bugs.ledger-cli.org/show_bug.cgi?id=%s"))
+ (c-mode
+ (c-file-style . "ledger")
+ (c-style-alist
+ ("ledger"
+ (indent-tabs-mode)
+ (c-basic-offset . 2)
+ (c-comment-only-line-offset 0 . 0)
+ (c-hanging-braces-alist
+ (substatement-open before after)
+ (arglist-cont-nonempty))
+ (c-offsets-alist
+ (statement-block-intro . +)
+ (knr-argdecl-intro . 5)
+ (substatement-open . 0)
+ (substatement-label . 0)
+ (label . 0)
+ (case-label . 0)
+ (statement-case-open . 0)
+ (statement-cont . +)
+ (arglist-intro . +)
+ (arglist-close . +)
+ (inline-open . 0)
+ (brace-list-open . 0)
+ (topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont))
+ (c-special-indent-hook . c-gnu-impose-minimum)
+ (c-block-comment-prefix . ""))))
+ (emacs-lisp-mode
+ (indent-tabs-mode)))
+
diff --git a/.gitignore b/.gitignore
index 16ee2784..e0bba1a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,17 +43,20 @@ doc/*.html
doc/*.info
doc/*.info-*
doc/*.ky
+doc/*.kys
doc/*.log
doc/*.pdf
doc/*.pg
doc/*.toc
doc/*.tp
doc/*.vr
+doc/*.vrs
doc/.dirstamp
doc/html/
doc/latex/
doc/refman.pdf
doc/report/
+doc/version.texi
elisp-comp
install-sh
intl/
diff --git a/.gitmodules b/.gitmodules
index ff480831..e69de29b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "lib/utfcpp"]
- path = lib/utfcpp
- url = http://github.com/ledger/utfcpp.git
diff --git a/.travis.yml b/.travis.yml
index 9128c24e..dcd23312 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,34 +2,106 @@
# provides GNU GCC 4.6, which does not support -std=c++11 GNU GCC 4.8 is installed
# NOTE: Please validate this file after editing it using
-# Travis WebLint http://lint.travis-ci.org/
-# or travis-yaml https://github.com/travis-ci/travis-yaml
+# Travis WebLint https://lint.travis-ci.org/
+# or travis-lint https://github.com/travis-ci/travis-lint
language: cpp
compiler:
- - clang
- gcc
+ - clang
+os:
+ - linux
+ - osx
+sudo: false
+cache:
+ apt: true
+
+env:
+ global:
+ # Boost version to use:
+ # _MIN is used when building the master branch
+ # _MAX is used when building any other branch
+ - BOOST_VERSION_MIN="1.49.0"
+ - BOOST_VERSION_MAX="1.60.0"
+ # List of required boost libraries to build
+ - BOOST_LIBS="date_time,filesystem,iostreams,python,regex,system,test"
+ # List of required Homebrew formulae to install
+ - BREWS="gmp,mpfr"
+ # Encrypted COVERITY_SCAN_TOKEN
+ - secure: "mYNxD1B8WNSvUeKzInehZ7syi2g1jH2ymeSQxoeKKD2duq3pvNWPdZdc4o9MlWQcAqcz58rhFZRIpuEWCnP0LbbJaG+MyuemMn9uAmg9Y4gFpMsBPHuTdf8pO3rDex+tkrr9puEJFgL+QV/TehxO6NDDpx7UdYvJb+4aZD/auYI="
+
+matrix:
+ exclude:
+ - os: linux
+ compiler: clang
+ # Compiling ledger on Linux with clang
+ # either crashes clang or results in a ledger binary that crashes with SIGSEGV.
+ - os: osx
+ compiler: gcc
+ # On Mac OS X building ledger with GNU GCC 4.8 fails due to
+ # undefined symbols, maybe because boost was not being built with g++-4.8.
+ # Undefined symbols for architecture x86_64:
+ # "boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)", referenced from:
+ # boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, char const*) in main.cc.o
+ # boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::perl_matcher(char const*, char const*, boost::match_results<char const*, std::allocator<boost::sub_match<char const*> > >&, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags, char const*) in global.cc.o
+ # "boost::re_detail::perl_matcher<char const*, std::allocator<boost::sub_match<char const*> >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::find()", referenced from:
+ # bool boost::regex_search<char const*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) in main.cc.o
+ # bool boost::regex_search<char const*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(char const*, char const*, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags) in global.cc.o
+
+addons:
+ coverity_scan:
+ project:
+ name: "ledger/ledger"
+ description: "Build submitted via Travis CI"
+ build_command_prepend: "cmake . -DUSE_PYTHON=ON -DBUILD_DEBUG=ON -DCLANG_GCOV=ON"
+ build_command: "make"
+ branch_pattern: coverity
+ apt:
+ sources:
+ - ubuntu-toolchain-r-test
+ #- boost-latest
+ packages:
+ - gcc-4.8
+ - g++-4.8
+ - libgmp-dev
+ - libmpfr-dev
+ - libedit-dev
+ #- libboost1.55-dev
+ #- libboost-test1.55-dev
+ #- libboost-regex1.55-dev
+ #- libboost-python1.55-dev
+ #- libboost-system1.55-dev
+ #- libboost-date-time1.55-dev
+ #- libboost-iostreams1.55-dev
+ #- libboost-filesystem1.55-dev
+ #- libboost-serialization1.55-dev
before_install:
- # Add software package repositories with recent versions of gcc and boost
- - sudo add-apt-repository ppa:ubuntu-toolchain-r/test --yes
- - sudo add-apt-repository ppa:boost-latest/ppa --yes
- - sudo apt-get update -qq
-
-install:
- # Install GNU GCC 4.8 required by use of C++11
- - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8 gcc-4.8; fi
- - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
- # Install Ledger dependencies
- - sudo apt-get install -qq libboost1.55 libgmp-dev libmpfr-dev libeditline-dev
+ - if [ "${TRAVIS_BRANCH}" = "master" ]; then export BOOST_VERSION="${BOOST_VERSION_MIN}"; else export BOOST_VERSION="${BOOST_VERSION_MAX}"; fi
+ - if [ -n "${BOOST_VERSION}" ]; then export BOOST_ROOT="${TRAVIS_BUILD_DIR}/../boost-trunk"; export CMAKE_MODULE_PATH="${BOOST_ROOT}"; fi
+ - if [ "${CXX}" = "g++" ]; then export CXX="$(which g++-4.8)"; export CC="$(which gcc-4.8)"; fi
+ - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then export DYLD_LIBRARY_PATH="${BOOST_ROOT}/lib"; fi
+ # c++ is a symlink to clang++, but the compiler behaves differently when invoked as c++
+ - if [ "${TRAVIS_OS_NAME}" = "osx" -a "${CXX}" = "clang++" ]; then export CXX="$(which c++)"; export CC="$(which cc)"; fi
+ - tools/travis-before_install.sh
+
+install:
+ - tools/travis-install.sh
before_script:
- - ./acprep debug make --python
+ - cmake . -DUSE_PYTHON=ON -DBUILD_DEBUG=ON
+ - make
script:
- - ./acprep check --jobs $(nproc) -- --output-on-failure
+ - ctest --output-on-failure
- PYTHONPATH=. python python/demo.py
+after_script:
+ # These scripts are run for informational purposes and
+ # should be reintegrated into CTest once they reliably verify the documentation.
+ - python test/CheckTexinfo.py -l ledger -s .
+ - python test/CheckManpage.py -l ledger -s .
+
notifications:
email:
on_success: change
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da075cde..ad96b345 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,8 +9,13 @@ PROJECT(ledger)
set(Ledger_VERSION_MAJOR 3)
set(Ledger_VERSION_MINOR 1)
set(Ledger_VERSION_PATCH 1)
-set(Ledger_VERSION_PRERELEASE "-alpha.1")
-set(Ledger_VERSION_DATE 20141005)
+set(Ledger_VERSION_PRERELEASE "")
+set(Ledger_VERSION_DATE 20160111)
+
+set(Ledger_TEST_TIMEZONE "America/Chicago")
+
+# Point CMake at any custom modules we may ship
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
enable_testing()
@@ -159,6 +164,34 @@ endif()
cmake_pop_check_state()
+# Check if fix for https://github.com/boostorg/python/issues/39 is needed
+if (HAVE_BOOST_PYTHON)
+cmake_push_check_state()
+
+set(CMAKE_REQUIRED_INCLUDES
+ ${CMAKE_INCLUDE_PATH} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES
+ ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${PROFILE_LIBS})
+
+check_cxx_source_runs("
+#include <boost/python.hpp>
+
+struct X { int y; };
+
+int main()
+{
+ boost::python::make_setter(&X::y);
+}" BOOST_MAKE_SETTER_RUNS)
+
+if (BOOST_MAKE_SETTER_RUNS)
+ set(HAVE_BOOST_159_ISSUE_39 0)
+else()
+ set(HAVE_BOOST_159_ISSUE_39 1)
+endif()
+
+cmake_pop_check_state()
+endif()
+
########################################################################
include_directories(${CMAKE_INCLUDE_PATH})
@@ -225,7 +258,14 @@ macro(add_ledger_library_dependencies _target)
target_link_libraries(${_target} ${INTL_LIB})
endif()
if (HAVE_BOOST_PYTHON)
- target_link_libraries(${_target} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ # Don't link directly to a Python framework on OS X, to avoid segfaults
+ # when the module is imported from a different interpreter
+ target_link_libraries(${_target} ${Boost_LIBRARIES})
+ set_target_properties(${_target} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ else()
+ target_link_libraries(${_target} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+ endif()
else()
target_link_libraries(${_target} ${Boost_LIBRARIES})
endif()
@@ -237,13 +277,20 @@ endmacro(add_ledger_library_dependencies _target)
########################################################################
+include(FindUtfcpp)
+if (UTFCPP_FOUND)
+ include_directories("${UTFCPP_INCLUDE_DIR}")
+else()
+ message(FATAL_ERROR "Missing required header file: utf8.h\n"
+ "Define UTFCPP_PATH or install utfcpp locally into the source tree below lib/utfcpp/."
+ )
+endif()
+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
# add the binary tree to the search path for include files so that we will
-# find TutorialConfig.h
-include_directories("${PROJECT_SOURCE_DIR}/lib")
-include_directories("${PROJECT_SOURCE_DIR}/lib/utfcpp/source")
+# find system.hh
include_directories("${PROJECT_BINARY_DIR}")
configure_file(
diff --git a/LICENSE.md b/LICENSE.md
index 92be3a1d..c160fd1f 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,4 +1,4 @@
-Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+Copyright (c) 2003-2016, John Wiegley. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
diff --git a/README.md b/README.md
index 5e2c6a07..759fa26a 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
-[![Build Status](https://img.shields.io/travis/ledger/ledger/master.svg?&style=flat)](https://travis-ci.org/ledger/ledger)
+[![Build Status master](https://img.shields.io/travis/ledger/ledger/master.svg?label=master&style=flat)](https://travis-ci.org/ledger/ledger)
+[![Build Status next](https://img.shields.io/travis/ledger/ledger/next.svg?label=next&style=flat)](https://travis-ci.org/ledger/ledger)
[![Status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat)](https://github.com/ledger/ledger/pulse/monthly)
[![License](https://img.shields.io/badge/license-BSD-blue.svg?style=flat)](http://opensource.org/licenses/BSD-3-Clause)
-[![GitHub tag](https://img.shields.io/github/tag/ledger/ledger.svg?style=flat)](https://github.com/ledger/ledger/releases)
+[![GitHub release](https://img.shields.io/github/release/ledger/ledger.svg?style=flat)](https://github.com/ledger/ledger/releases)
# Ledger: Command-Line Accounting
@@ -147,9 +148,9 @@ Or, for Ubuntu 12.04:
Debian squeeze (6.0): the version of boost in squeeze is too old
for ledger and unfortunately no backport is available at the moment.
-Debian 7 (wheezy) and Debian 8 (jessie) contain all components needed to
-build ledger. You can install all required build dependencies using the
-following command:
+Debian 7 (wheezy), Debian 8 (jessie), Debian testing (stretch) and Debian
+unstable (sid) contain all components needed to build ledger. You can
+install all required build dependencies using the following command:
$ sudo apt-get install build-essential cmake autopoint texinfo python-dev \
zlib1g-dev libbz2-dev libgmp3-dev gettext libmpfr-dev \
diff --git a/acprep b/acprep
index 9e661aad..90b486ec 100755
--- a/acprep
+++ b/acprep
@@ -490,17 +490,10 @@ class PrepareBuild(CommandLineApp):
# Update local files with the latest information #
#########################################################################
- def phase_submodule(self, *args):
- self.log.info('Executing phase: submodule')
- if self.git_working_tree():
- self.execute('git', 'submodule', 'init')
- self.execute('git', 'submodule', 'update')
-
def phase_pull(self, *args):
self.log.info('Executing phase: pull')
if self.git_working_tree():
self.execute('git', 'pull')
- self.phase_submodule()
#########################################################################
# Automatic installation of build dependencies #
@@ -569,6 +562,7 @@ class PrepareBuild(CommandLineApp):
'libedit-dev',
'texinfo',
'lcov',
+ 'libutfcpp-dev',
'sloccount'
] + BoostInfo().dependencies('ubuntu-trusty')
elif re.search('saucy', info):
@@ -606,6 +600,7 @@ class PrepareBuild(CommandLineApp):
'libedit-dev',
'texinfo',
'lcov',
+ 'libutfcpp-dev',
'sloccount'
] + BoostInfo().dependencies('ubuntu-precise')
else:
@@ -616,8 +611,8 @@ class PrepareBuild(CommandLineApp):
self.execute(*packages)
if exists('/etc/redhat-release'):
- release = open('/etc/redhat-release')
- if release.readline().startswith('CentOS'):
+ release = open('/etc/redhat-release').readline()
+ if release.startswith('CentOS'):
self.log.info('Looks like you are using YUM on CentOS')
packages = [
'sudo', 'yum', 'install',
@@ -644,6 +639,31 @@ class PrepareBuild(CommandLineApp):
]
self.log.info('Executing: ' + ' '.join(packages))
self.execute(*packages)
+ elif release.startswith('Fedora release 20'):
+ self.log.info('Looks like you are using YUM on Fedora 20')
+ packages = [
+ 'sudo', 'yum', 'install',
+ 'boost-devel',
+ 'bzip2-devel',
+ 'cmake',
+ 'doxygen',
+ 'gcc',
+ 'gcc-c++',
+ 'gettext',
+ 'gettext-devel',
+ 'gmp-devel',
+ 'lcov',
+ 'libedit-devel',
+ 'mpfr-devel',
+ 'ninja-build',
+ 'python-devel',
+ 'sloccount',
+ 'texinfo',
+ 'zlib-devel'
+ ]
+ self.log.info('Executing: ' + ' '.join(packages))
+ self.execute(*packages)
+
elif system.startswith('CYGWIN'):
self.log.info('Looks like you are using Cygwin')
self.log.info('Please install the dependencies manually.')
@@ -860,7 +880,6 @@ class PrepareBuild(CommandLineApp):
def phase_config(self, *args):
self.log.info('Executing phase: config')
- self.phase_submodule()
self.phase_configure(*args)
if self.should_clean:
self.phase_clean()
@@ -1066,7 +1085,6 @@ typical user:
products Report the products directory path
rsync Rsync a copy of the source tree into Products
sloc Report total Source Lines Of Code
- submodule Updates Git submodules (better to use 'pull')
version Output current HEAD version to version.m4
NOTE: If you wish to pass options to CMake or make, add "--" followed by
diff --git a/cmake/FindUtfcpp.cmake b/cmake/FindUtfcpp.cmake
new file mode 100644
index 00000000..185a8d88
--- /dev/null
+++ b/cmake/FindUtfcpp.cmake
@@ -0,0 +1,30 @@
+# - Try to find utfcpp
+# Once done, this will define
+#
+# UTFCPP_FOUND - system has utfcpp's utf8.h
+# UTFCPP_PATH - the utfcpp include directories
+
+include(CheckCXXSourceCompiles)
+
+set(UTFCPP_FOUND FALSE)
+
+find_path(UTFCPP_INCLUDE_DIR
+ NAMES utf8.h
+ HINTS "${UTFCPP_PATH}" "${PROJECT_SOURCE_DIR}/lib/utfcpp/v2_0/source"
+)
+
+if (UTFCPP_INCLUDE_DIR)
+ set(CMAKE_REQUIRED_INCLUDES "${UTFCPP_INCLUDE_DIR}")
+ set(UTFCPP_FOUND TRUE)
+endif()
+
+check_cxx_source_compiles("
+#include <string>
+#include \"utf8.h\"
+
+int main(int argc, char** argv) {
+ std::string input = std::string(\"utfcpp\");
+ const char * p = input.c_str();
+ std::size_t len = input.length();
+ utf8::is_valid(p, p + len);
+}" HAVE_WORKING_UTFCPP)
diff --git a/contrib/ParseCcStmt.cs b/contrib/ParseCcStmt.cs
index 04e3dbb9..d5a42fbd 100644
--- a/contrib/ParseCcStmt.cs
+++ b/contrib/ParseCcStmt.cs
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/contrib/iso4127-commodities/iso4217ledger.sh b/contrib/iso4127-commodities/iso4217ledger.sh
index 1841abe8..a7815f4a 100755
--- a/contrib/iso4127-commodities/iso4217ledger.sh
+++ b/contrib/iso4127-commodities/iso4217ledger.sh
@@ -26,7 +26,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-xml_url="http://www.currency-iso.org/dam/downloads/table_a1.xml"
+xml_url="http://www.currency-iso.org/dam/downloads/lists/list_one.xml"
xsl_file="$(dirname $0)/iso4217ledger.xsl"
xsltproc="$(which xsltproc)"
diff --git a/contrib/raw/dotemacs.el b/contrib/raw/dotemacs.el
index b270042e..a4babed7 100644
--- a/contrib/raw/dotemacs.el
+++ b/contrib/raw/dotemacs.el
@@ -1,5 +1,5 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Ledger
+;; Ledger
;; Maybe later add this to the expense repo once it settles
(add-to-list 'load-path "/home/adamsrl/.emacs.d/addons/ledger")
@@ -104,19 +104,19 @@
(defun ledger-expense-shortcut ()
"Updates the ER and Project metadata with the current values of the shortcut variables."
- (interactive)
- (when (eq major-mode 'ledger-mode)
- (if (or (eql *ledger-expense-shortcut-ER* "")
- (eql *ledger-expense-shortcut-Proj* ""))
- (message "Run ledger-expense-shortcut-setup first.")
- (save-excursion
- (search-forward "; ER:")
- (kill-line nil)
- (insert " " *ledger-expense-shortcut-ER*))
- (save-excursion
- (search-forward "; PROJECT:")
- (kill-line nil)
- (insert " " *ledger-expense-shortcut-Proj*)))))
+ (interactive)
+ (when (eq major-mode 'ledger-mode)
+ (if (or (eql *ledger-expense-shortcut-ER* "")
+ (eql *ledger-expense-shortcut-Proj* ""))
+ (message "Run ledger-expense-shortcut-setup first.")
+ (save-excursion
+ (search-forward "; ER:")
+ (kill-line nil)
+ (insert " " *ledger-expense-shortcut-ER*))
+ (save-excursion
+ (search-forward "; PROJECT:")
+ (kill-line nil)
+ (insert " " *ledger-expense-shortcut-Proj*)))))
(defun ledger-expense-split ()
"Splits the current transaction between internal and projects."
@@ -158,33 +158,33 @@
(defun ledger-expense-personal ()
"Makes the expense an personal one, eliminating metadata and receipts."
- (interactive)
- (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
- (save-excursion
- (end-of-line)
- (re-search-backward "^[0-9]\\{4\\}/")
- (let ((begin (point))
- (end (save-excursion (re-search-forward "^$"))))
- (when (re-search-forward "^ Dest:Projects" end t)
- (replace-match " Other:Personal"))
- (goto-char begin)
- (save-excursion
- (when (re-search-forward "^ +; ER:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; PROJECT:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; CATEGORY:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; RECEIPT:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (ledger-toggle-current-entry)))))
+ (interactive)
+ (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
+ (save-excursion
+ (end-of-line)
+ (re-search-backward "^[0-9]\\{4\\}/")
+ (let ((begin (point))
+ (end (save-excursion (re-search-forward "^$"))))
+ (when (re-search-forward "^ Dest:Projects" end t)
+ (replace-match " Other:Personal"))
+ (goto-char begin)
+ (save-excursion
+ (when (re-search-forward "^ +; ER:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; PROJECT:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; CATEGORY:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; RECEIPT:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (ledger-toggle-current-entry)))))
(defun ledger-expense-show-receipt ()
"Uses the Receipt buffer to show the receipt of the txn we're on."
diff --git a/contrib/raw/ledger-matching.el b/contrib/raw/ledger-matching.el
index 7c568126..b8e62dd9 100644
--- a/contrib/raw/ledger-matching.el
+++ b/contrib/raw/ledger-matching.el
@@ -202,13 +202,13 @@
(defun ledger-receipt-skip ()
"Move the current image to the Skip directory because its not relevant."
- (rename-file (concat ledger-matching-sourcedir "/"
- ledger-matching-image-name)
- (concat ledger-matching-sourcedir "/Skip/"
- ledger-matching-image-name))
+ (rename-file (concat ledger-matching-sourcedir "/"
+ ledger-matching-image-name)
+ (concat ledger-matching-sourcedir "/Skip/"
+ ledger-matching-image-name))
- ;; Update the receipt screen at the same offset
- (ledger-matching-update-current-image))
+ ;; Update the receipt screen at the same offset
+ (ledger-matching-update-current-image))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Items below are speed entry macros, and should eventually migrate to their own file.
@@ -242,19 +242,19 @@
(defun ledger-expense-shortcut ()
"Updates the ER and Project metadata with the current values of the shortcut variables."
- (interactive)
- (when (eq major-mode 'ledger-mode)
- (if (or (eql *ledger-expense-shortcut-ER* "")
- (eql *ledger-expense-shortcut-Proj* ""))
- (message "Run ledger-expense-shortcut-setup first.")
- (save-excursion
- (search-forward "; ER:")
- (kill-line nil)
- (insert " " *ledger-expense-shortcut-ER*))
- (save-excursion
- (search-forward "; PROJECT:")
- (kill-line nil)
- (insert " " *ledger-expense-shortcut-Proj*)))))
+ (interactive)
+ (when (eq major-mode 'ledger-mode)
+ (if (or (eql *ledger-expense-shortcut-ER* "")
+ (eql *ledger-expense-shortcut-Proj* ""))
+ (message "Run ledger-expense-shortcut-setup first.")
+ (save-excursion
+ (search-forward "; ER:")
+ (kill-line nil)
+ (insert " " *ledger-expense-shortcut-ER*))
+ (save-excursion
+ (search-forward "; PROJECT:")
+ (kill-line nil)
+ (insert " " *ledger-expense-shortcut-Proj*)))))
(defun ledger-expense-split ()
"Splits the current transaction between internal and projects."
@@ -296,33 +296,33 @@
(defun ledger-expense-personal ()
"Makes the expense an personal one, eliminating metadata and receipts."
- (interactive)
- (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
- (save-excursion
- (end-of-line)
- (re-search-backward "^[0-9]\\{4\\}/")
- (let ((begin (point))
- (end (save-excursion (re-search-forward "^$"))))
- (when (re-search-forward "^ Dest:Projects" end t)
- (replace-match " Other:Personal"))
- (goto-char begin)
- (save-excursion
- (when (re-search-forward "^ +; ER:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; PROJECT:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; CATEGORY:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (save-excursion
- (when (re-search-forward "^ +; RECEIPT:" end t)
- (beginning-of-line)
- (kill-line 1)))
- (ledger-toggle-current-entry)))))
+ (interactive)
+ (when (eq major-mode 'ledger-mode) ; I made this local now, should only trigger in ldg-mode
+ (save-excursion
+ (end-of-line)
+ (re-search-backward "^[0-9]\\{4\\}/")
+ (let ((begin (point))
+ (end (save-excursion (re-search-forward "^$"))))
+ (when (re-search-forward "^ Dest:Projects" end t)
+ (replace-match " Other:Personal"))
+ (goto-char begin)
+ (save-excursion
+ (when (re-search-forward "^ +; ER:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; PROJECT:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; CATEGORY:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (save-excursion
+ (when (re-search-forward "^ +; RECEIPT:" end t)
+ (beginning-of-line)
+ (kill-line 1)))
+ (ledger-toggle-current-entry)))))
(defun ledger-expense-show-receipt ()
"Uses the Receipt buffer to show the receipt of the txn we're on."
diff --git a/doc/NEWS b/doc/NEWS
index 45596ddc..af89de0c 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -1,5 +1,35 @@
Ledger NEWS
+* 3.1.1
+
+- Added a --no-revalued option
+
+- Improved Embedded Python Support
+
+- Use ./.ledgerrc if ~/.ledgerrc doesn't exist
+
+- Fixed parsing of transactions with single-character payees and comments
+
+- Fixed crash when using -M with empty result
+
+- Fixed sorting for option --auto-match
+
+- Fixed treatment of "year 2015" and "Y2014" directives
+
+- Fixed crash when using --trace 10 or above
+
+- Build fix for boost 1.58, 1.59, 1.60
+
+- Build fix for Cygwin
+
+- Fixed Util and Math tests on Mac OS X
+
+- Various documentation improvements
+
+- Examples in the documentation are tested just like unit tests
+
+- Add continuous integration (https://travis-ci.org/ledger/ledger)
+
* 3.1
- Changed the definition of cost basis to preserve the original cost basis
diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi
index 4fe56d6b..8ff284b1 100644
--- a/doc/ledger-mode.texi
+++ b/doc/ledger-mode.texi
@@ -194,8 +194,10 @@ outside world. This process is called reconciliation (@pxref{Basics of
Reconciliation}) and can be quite onerous. Ledger-mode attempts to make
it as painless as possible.
-In the @file{demo.ledger} buffer type @kbd{C-c C-r}. Emacs will prompt
-for an account to reconcile in the Minibuffer. Enter @samp{Checking}.
+In the @file{demo.ledger} buffer type @kbd{C-c C-r}. If cursor is on an
+account, Ledger-mode will propose this account, or in the Minibuffer,
+will prompt for an account to reconcile. Hit @kbd{RET} if you are happy
+with proposed account, or enter @samp{Checking} as example.
Emacs will then prompt for a target value. The target value is the
amount you want the cleared transactions in the buffer to total.
Normally this would be the ending value from your bank statement, or the
@@ -383,13 +385,15 @@ transaction.
@end itemize
-@kindex C-c C-e
@kindex C-c C-c
+@kindex C-c C-e
-Clearing complete transactions is done by typing @kbd{C-c C-e} with
-point in a transaction. This places an asterisk @samp{*} after the
-date. Clearing individual postings is done by typing @kbd{C-c C-c}
-while in a posting. This places an asterisk prior to the posting.
+Typing @kbd{C-c C-c}, depending where is the point, will clear the
+complete transaction, or an individual posting. This places an asterisk
+@samp{*} prior to the payee for the complete transaction, or prior to
+the account for an individual posting. When point is inside
+a transaction, specifically on an individual posting, you can still
+clear the complete transaction by typing @kbd{C-c C-e}.
@node Formatting Transactions, Deleting Transactions, Marking Transactions, The Ledger Buffer
@section Formatting Transactions
@@ -550,17 +554,25 @@ about. You can get this from a monthly statement, or from checking your
on-line transaction history. It also helps immensely to know the final
cleared balance you are aiming for.
-Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} and enter the account
-you wish to reconcile in the Minibuffer. Ledger-mode is not particular
-about what you enter for the account. You can leave it blank and
-@file{*Reconcile*} buffer will show you @emph{all} uncleared
-transactions. After you enter the account enter the target amount.
-Ledger expects you to enter an amount with a commodity. It assumes
-initially that you are using @samp{$} (USD) as your default commodity.
-If you are working in a different currency you can change the default in
-variable @option{ledger-reconcile-default-commodity} to whatever you
-need. If you work in multiple commodities simply enter the commoditized
-amount (for example @samp{340 VSDX}, for 340 shares of VSDX).
+Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} to
+start reconciliation.
+
+If cursor is on an account, Ledger-mode will propose this account, or in
+the Minibuffer, will prompt for an account to reconcile. Hit @kbd{RET}
+if you are happy with proposed account, or enter @samp{Checking} as
+example. Ledger-mode is not particular about what you enter for the
+account. You can leave it blank and @file{*Reconcile*} buffer will show
+you @emph{all} uncleared transactions.
+
+After you enter the account enter the target amount. It is helpful to
+enter an amount with a commodity. You can also leave it blank, you will
+be able to clear transactions but not benefit from balance calculations.
+It assumes initially that you are using @samp{$} (USD) as your default
+commodity. If you are working in a different currency you can change
+the default in variable @option{ledger-reconcile-default-commodity} to
+whatever you need. If you work in multiple commodities simply enter the
+commoditized amount (for example @samp{340 VSDX}, for 340 shares of
+VSDX).
Ledger-mode reconcile cannot currently reconcile accounts that have
multiple commodities, such as brokerage accounts. You may use
@@ -596,11 +608,17 @@ mark the transaction if appropriate.
@node Finalize Reconciliation, Adding and Deleting Transactions during Reconciliation, Edit Transactions During Reconciliation, The Reconcile Buffer
@section Finalize Reconciliation
@cindex reconciliation, finalizing
+@kindex C-c C-c
+@kindex q
Once you have marked all transactions as pending and the cleared balance
is correct. Finish the reconciliation by typing @kbd{C-c C-c}. This
marks all pending transactions as cleared and saves the ledger buffer.
+Type @kbd{q} to close out the reconciliation buffer. If variable
+@var{ledger-reconcile-finish-force-quit} is set, the reconciliation
+buffer will be killed automatically after @kbd{C-c C-c}.
+
@node Adding and Deleting Transactions during Reconciliation, Changing Reconciliation Account, Finalize Reconciliation, The Reconcile Buffer
@section Adding and Deleting Transactions during Reconciliation
@kindex a
@@ -866,7 +884,7 @@ recurrence relation to be specified. The day names are two character
codes that default to Mo, Tu, We, Th, Fr, Sa, Su, for Monday, Tuesday,
Wednesday, Thursday, Friday, Saturday, Sunday respectively. You can
change the codes to something more convenient for your locale by
-customizing the ledger @var{ledger-schedule-week-days}. They must be two
+customizing the ledger @option{ledger-schedule-week-days}. They must be two
characters long.
@@ -951,7 +969,7 @@ false toggle between uncleared and cleared @samp{*}.
@item ledger-reconcile-default-date-format
Date format for the reconcile buffer. Defaults to
-ledger-default-date-format.
+@option{ledger-default-date-format}.
@item ledger-reconcile-target-prompt-string
Prompt for recon target. Defaults to "Target amount for reconciliation ".
@@ -964,11 +982,11 @@ header will be displayed. Defaults to "Reconciling account %s\n\n".
@item ledger-reconcile-buffer-line-format
Format string for the ledger reconcile posting format. Available fields
are date, status, code, payee, account, amount. The format for each
-field is %WIDTH(FIELD), WIDTH can be preced by a minus sign which mean
+field is %WIDTH(FIELD), WIDTH can be preceded by a minus sign which mean
to left justify and pad the field. WIDTH is the minimum number of
characters to display; if string is longer, it is not truncated unless
-ledger-reconcile-buffer-payee-max-chars or
-ledger-reconcile-buffer-account-max-chars is defined. Defaults to
+@option{ledger-reconcile-buffer-payee-max-chars} or
+@option{ledger-reconcile-buffer-account-max-chars} is defined. Defaults to
"%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n"
@item ledger-reconcile-buffer-payee-max-chars
@@ -986,6 +1004,9 @@ ledger file order. Defaults to '(0)'.
If t, prompt for effective date when clearing transactions during
reconciliation.
+@item ledger-reconcile-finish-force-quit nil
+If t, will force closing reconcile window after @kbd{C-c C-c}.
+
@end ftable
@node Ledger Report Customization Group, Ledger Faces Customization Group, Ledger Reconcile Customization Group, Customization Variables
diff --git a/doc/ledger.1 b/doc/ledger.1
index 67c24470..ffc7decf 100644
--- a/doc/ledger.1
+++ b/doc/ledger.1
@@ -191,7 +191,8 @@ Show any gains (or losses) in commodity values over time.
Only show the top
.Ar number
postings.
-.\".It Fl \-historical Pq Fl H
+.It Fl \-historical Pq Fl H
+Value commodities at the time of their acquisition.
.It Fl \-invert
Invert the value of amounts shown.
.It Fl \-market Pq Fl V
@@ -309,7 +310,7 @@ fit inside the
If
.Ar INT
is zero, then the
-account name will be truncated on the right. If
+account name will be truncated on the right. If
.Ar INT
is greater
than
@@ -320,7 +321,7 @@ desired width.
.It Fl \-account Ar EXPR
Prepend
.Ar EXPR
-to all accounts reported. That is, the option
+to all accounts reported. That is, the option
.Fl \-account Ar \*q'Personal'\*q
would tack
.Ar Personal:
@@ -345,7 +346,7 @@ transactions used.
.It Fl \-add-budget
Show only un-budgeted postings.
.It Fl \-amount Ar EXPR Pq Fl t
-Apply the given value expression to the posting amount. Using
+Apply the given value expression to the posting amount. Using
.Fl \-amount Ar EXPR
you can apply an
arbitrary transformation to the postings.
@@ -366,7 +367,10 @@ Alias for
Ignore init files and environment variables for the
.Nm
run.
-.\".It Fl \-auto-match
+.It Fl \-auto-match
+When generating a ledger transaction from a CSV file using the
+.Ic convert
+command, automatically match an account from the Ledger journal.
.It Fl \-aux-date
Show auxiliary dates for all calculations.
Alias for
@@ -378,7 +382,9 @@ running totals.
Specify the format to use for the
.Ic balance
report.
-.\".It Fl \-base
+.It Fl \-base
+Reduce convertible commodities down the bottom of the conversion, e.g.
+display time in seconds.
.It Fl \-basis Pq Fl B
Report the cost basis on all posting.
Alias for
@@ -386,12 +392,12 @@ Alias for
.It Fl \-begin Ar DATE Pq Fl b
Specify the start
.Ar DATE
-of all calculations. Transactions before
+of all calculations. Transactions before
that date will be ignored.
.It Fl \-bold-if Ar EXPR
Print the entire line in bold if the given value expression is true.
.It Fl \-budget
-Only display budgeted items. In a
+Only display budgeted items. In a
.Ic register
report this displays transaction in the budget, in a balance report this
displays accounts in the budget.
@@ -401,7 +407,6 @@ Specify the format to use for the
report.
.It Fl \-by-payee Pq Fl P
Group postings in the register report by common payee names.
-.\".It Fl \-cache Ar FILE
.It Fl \-check-payees
Enable strict and pedantic checking for payees as well as accounts,
commodities and tags.
@@ -424,7 +429,7 @@ Make the
.Ic register
report
.Ar INT
-characters wide. By default
+characters wide. By default
.Nm
will use all available columns in your terminal.
.It Fl \-cost
@@ -461,7 +466,12 @@ Print dates using
Refer to
.Xr strftime 3
for details on the format string syntax.
-.\" .It Fl \-datetime-format Ar FMT
+.It Fl \-datetime-format Ar DATETIMEFMT
+Print datetimes using
+.Ar DATETIMEFMT .
+Refer to
+.Xr strftime 3
+for details on the format string syntax.
.It Fl \-date-width Ar INT
Specify the width, in characters, of the date column in the
.Ic register
@@ -501,8 +511,14 @@ but not
.Sy Expenses:Entertainment:Dining .
This is a display predicate, which means it only affects display,
not the total calculations.
+.It Fl \-detail
+Related to
+.Ic convert
+command. Synonym to
+.Fl \-rich-data
+option.
.It Fl \-deviation
-Report each posting's deviation from the average. It is only meaningful
+Report each posting's deviation from the average. It is only meaningful
in the
.Ic register No and Ic prices
reports.
@@ -537,42 +553,47 @@ distribution. Downloaded quote price are then appended to the price
database, usually specified using the environment variable
.Ev LEDGER_PRICE_DB .
.It Fl \-effective
-Show auxiliary dates for all calculations. Alias for
+Show auxiliary dates for all calculations. Alias for
.Fl \-aux-date .
.It Fl \-empty Pq Fl E
Include empty accounts in report.
.It Fl \-end Ar DATE Pq Fl e
-Specify the end
+Constrain the report so that transactions on or after
.Ar DATE
-for a transaction to be considered in the
-report.
+are not considered.
.It Fl \-equity
Related to the
.Ic equity
command. Gives current account balances in the form of a register
report.
-.\".It Fl \-exact
+.It Fl \-exact
+Report beginning and ending of periods by the date of the first and last
+posting occurring in that period.
.It Fl \-exchange Ar COMMODITY Oo , Ar COMMODITY, ... Oc Pq Fl X
Display values in terms of the given
.Ar COMMODITY .
The latest available price is used.
-.\".It Fl \-explicit
+.It Fl \-explicit
+Direct
+.Nm
+to require pre-declarations for entities (such as accounts,
+commodities and tags) rather than taking entities from cleared
+transactions as defined.
.It Fl \-file Ar FILE
Read journal data from
.Ar FILE .
-.\".It Fl \-full-help
.It Fl \-first Ar INT
Print the first
.Ar INT
-entries. Opposite of
+entries. Opposite of
.Fl \-last Ar INT .
Alias for
.Fl \-head .
.It Fl \-flat
-Force the full names of accounts to be used in the balance report. The
+Force the full names of accounts to be used in the balance report. The
balance report will not use an indented tree.
.It Fl \-force-color
-Output TTY color codes even if the TTY doesn't support them. Useful
+Output TTY color codes even if the TTY doesn't support them. Useful
for TTYs that don't advertise their capabilities correctly.
.It Fl \-force-pager
Force
@@ -618,22 +639,18 @@ register report.
.It Fl \-head Ar INT
Print the first
.Ar INT
-entries. Opposite of
+entries. Opposite of
.Fl \-tail Ar INT .
Alias for
.Fl \-first
.It Fl \-help
-Print a summary of all the options, and what they are used for. This
-can be a handy way to remember which options do what. This help screen
-is also printed if
-.Nm
-is run without a command.
-.\".It Fl \-help-calc
-.\".It Fl \-help-comm
-.\".It Fl \-help-disp
+Print this man page.
.It Fl \-immediate
Evaluate calculations immediately rather than lazily.
-.\".It Fl \-import
+.It Fl \-import Ar FILE
+Import
+.Ar FILE
+as Python module.
.It Fl \-init-file Ar FILE Pq Fl i
Read
.Ar FILE
@@ -658,9 +675,9 @@ Change the sign of all reported values.
.It Fl \-last Ar INT .
Report only the last
.Ar INT
-entries. Opposite of
+entries. Opposite of
.Fl \-first Ar INT .
-Only useful on a register report. Alias for
+Only useful on a register report. Alias for
.Fl \-tail .
.It Fl \-leeway Ar INT Pq Fl Z
Alias for
@@ -678,7 +695,9 @@ purchased.
.It Fl \-lots
Report the date and price at which each commodity was purchased in
a balance report.
-.\".It Fl \-lots-actual
+.It Fl \-lots-actual
+Preserve the uniqueness of commodities so they aren't merged during
+reporting without printing the lot annotations.
.It Fl \-market Pq Fl V
Use the latest market value for all commodities.
.It Fl \-master-account Ar STR
@@ -701,9 +720,15 @@ Aliases are completely ignored.
Suppress any color TTY output.
.It Fl \-no-pager
Disables the pager on TTY output.
+.It Fl \-no-revalued
+Stop
+.Nm
+from showing
+<Revalued>
+postings.
.It Fl \-no-rounding
Don't output
-.Qq Li <Rounding>
+.Qq Li <Adjustment>
postings. Note that this will cause the
running total to often not add up! Its main use is for
.Fl \-amount-data Pq Fl j
@@ -717,7 +742,7 @@ Suppress printing the final total line in a balance report.
.It Fl \-now Ar DATE
Use
.Ar DATE
-as the current date. This affects the output when using
+as the current date. This affects the output when using
.Fl \-period ,
.Fl \-begin ,
.Fl \-end ,
@@ -742,7 +767,7 @@ Use
.Ar STR
as the pager program.
.It Fl \-payee
-Sets a value expression for formatting the payee. In the
+Sets a value expression for formatting the payee. In the
.Ic register
report this prevents the second entry from having
a date and payee for each transaction.
@@ -759,7 +784,7 @@ Calculate the percentage value of each account in a balance reports.
Only works for account that have a single commodity.
.It Fl \-period Ar PERIOD Pq Fl p
Define a period expression that sets the time period during which
-transactions are to be accounted. For a
+transactions are to be accounted. For a
.Ic register
report only
the transactions that satisfy the period expression with be displayed.
@@ -792,12 +817,12 @@ Use the price of the commodity purchase for performing calculations.
.It Fl \-price-exp Ar STR Pq Fl Z
Set the expected freshness of price quotes, in
.Ar INT
-minutes. That
+minutes. That
is, if the last known quote for any commodity is older than this value,
and if
.Fl \-download
is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
Alias for
.Fl \-leeway .
@@ -808,7 +833,7 @@ report.
.It Fl \-pricedb-format Ar FMT
Set the format expected for the historical price file.
.It Fl \-primary-date
-Show primary dates for all calculations. Alias for
+Show primary dates for all calculations. Alias for
.Fl \-actual-dates
.It Fl \-quantity Pq Fl O
Report commodity totals (this is the default).
@@ -842,10 +867,27 @@ of the transaction.
Show all postings in a transaction, similar to
.Fl \-related
but show both sides of each transaction.
-.\".It Fl \-revalued
-.\".It Fl \-revalued-only
-.\".It Fl \-revalued-total Ar EXPR
-.\".It Fl \-rich-data
+.It Fl \-revalued
+Report discrepancy in values for manual reports by inserting
+<Revalued>
+postings.
+This is implied when using
+the
+.Fl \-exchange Pq Fl X
+or
+.Fl \-market Pq Fl V
+option.
+.It Fl \-revalued-only
+Show only
+<Revalued>
+postings.
+.It Fl \-revalued-total
+Display the sum of the revalued postings as the running total, which serves
+to show unrealized capital in a gain/losses report.
+.It Fl \-rich-data
+When generating a ledger transaction from a CSV file using the
+.Ic convert
+command, add CSV, Imported, and UUID meta-data.
.It Fl \-seed Ar INT
Set the random seed to
.Ar INT
@@ -857,8 +899,9 @@ Execute a
.Nm
script.
.It Fl \-sort Ar EXPR Pq Fl S
-Sort the register report based on the value expression given to sort.
-.\".It Fl \-sort-all
+Sort the register report based on the value expression
+.Ar EXPR .
+.\".It Fl \-sort-all Ar EXPR
.It Fl \-sort-xacts
Sort the posting within transactions using the given value expression.
.It Fl \-start-of-week Ar STR
@@ -879,12 +922,15 @@ Report register as a single subtotal.
.It Fl \-tail Ar INT
Report only the last
.Ar INT
-entries. Only useful on a register report. Alias for
+entries. Only useful on a register report. Alias for
.Fl \-last Ar INT
.It Fl \-time-colon
Display the value for commodities based on seconds as hours and minutes.
Thus 8100s will be displayed as 2:15h instead of 2.25h.
-.\".It Fl \-time-report
+.It Fl \-time-report
+Add two columns to the
+.Ic balance
+report to show the earliest checkin and checkout times for timelog entries.
.It Fl \-total Ar EXPR Pq Fl T
Define a value expression used to calculate the total in reports.
.It Fl \-total-data Pq Fl J
@@ -892,12 +938,12 @@ Show only dates and totals to format the output for plots.
.It Fl \-total-width Ar INT
Set the width of the total field in the register report.
.It Fl \-trace Ar INT
-Enable tracing. The
+Enable tracing. The
.Ar INT
specifies the level of trace desired.
.It Fl \-truncate Ar STR
Indicates how truncation should happen when the contents of columns
-exceed their width. Valid arguments for
+exceed their width. Valid arguments for
.Ar STR
are
.Ar leading ,
@@ -917,14 +963,14 @@ Show generated unrealized gain and loss accounts in the balance
report.
.It Fl \-unrealized-gains
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to
+unrealized gains. Defaults to
.Sy "Equity:Unrealized Gains" .
Often set in one's
.Pa ~/.ledgerrc
file to change the default.
.It Fl \-unrealized-losses
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to
+unrealized losses. Defaults to
.Sy "Equity:Unrealized Losses" .
Often set in one's
.Pa ~/.ledgerrc
@@ -936,17 +982,20 @@ precision.
Show the values used by each tag when used in combination with the
.Ic tags
command.
-.\".It Fl \-value-expr Ar EXPR
+.It Fl \-value-expr Ar EXPR
+Set a global value expression annotation.
.It Fl \-verbose
Print detailed information on the execution of
.Nm .
.It Fl \-verify
-Enable additional assertions during run-time. This causes a significant
+Enable additional assertions during run-time. This causes a significant
slowdown. When combined with
.Fl \-debug Ar CODE
.Nm
will produce memory trace information.
-.\".It Fl \-verify-memory
+.It Fl \-verify-memory
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
.It Fl \-version
Print version information and exit.
.It Fl \-weekly Pq Fl W
@@ -960,7 +1009,7 @@ Shorthand for
.El
.Sh PRE-COMMANDS
Pre-commands are useful when you aren't sure how a command or option
-will work. The difference between a pre-command and a regular command
+will work. The difference between a pre-command and a regular command
is that pre-commands ignore the journal data file completely, nor is
the user's init file read.
.Bl -tag -width -indent
@@ -1117,6 +1166,12 @@ toward -infinity.
The name of the
.Nm
data file from whence the posting came.
+.It Fn format string
+Evaluate
+.Ar string
+as format just like the
+.Fl \-format
+option.
.It Fn format_date date format
Return the
.Ar date
@@ -1125,18 +1180,56 @@ as a string using
Refer to
.Xr strftime 3
for format string details.
-.\".It Fn get_at
-.\".It Fn has_meta
+.It Fn format_datetime datetime format
+Return the
+.Ar datetime
+as a string using
+.Ar format .
+Refer to
+.Xr strftime 3
+for format string details.
+.It Fn get_at seq index
+Return value at
+.Ar index
+from
+.Ar seq .
+Used internally to construct different reports.
+.It Fn has_meta
+Return true if the posting has metadata named
+.Ar tag ,
+false otherwise.
.It Fn has_tag tag
Return true if the posting has metadata named
.Ar tag ,
false otherwise.
-.\".It Fn is_seq
+.It Fn is_seq value
+Return true if
+.Ar value
+is a sequence. Used internally.
.It Fn join value
Replace all newlines in
.Ar value
with
.Li \en .
+.It Fn justify value first_width latter_width right_justify colorize
+Right or left justify the string representing
+.Ar value .
+The width of the field in the first line is given by
+.Ar first_width .
+For subsequent lines the width is given by
+.Ar latter_width .
+If
+.Ar latter_width
+is -1,
+.Ar first_width
+is used for all lines.
+If
+.Ar right_justify
+is true then the field is right justified within the width of the field. If it
+is false, then the field is left justified and padded to the full width of the
+field. If
+.Ar colorize
+is true, then ledger will honor color settings.
.It Fn market value datetime
Return the price of
.Ar value
@@ -1146,8 +1239,13 @@ Note that
.Ar datetime
must be surrounded by brackets in order to be parsed correctly, e.g.
.Bq 2012/03/23 .
-.\".It Sy meta
-.I.\"t Sy note
+.It Fn meta
+Return the value of metadata named
+.Ar name .
+.It Sy note
+Return the note for the posting.
+.It Sy now
+Return the current datetime.
.\".It Sy null
.It Sy options
A variable that allows access to the values of the given command-line options
@@ -1173,7 +1271,11 @@ in relation to
.Ar value_b .
.\".It Sy post
.\" A variable scope
-.\".It Sy print
+.It Fn print value
+Print
+.Ar value
+to stdout.
+Used internally for debugging.
.It Fn quantity value
Return the quantity of
.Ar value
@@ -1192,30 +1294,61 @@ Return
.Ar value
rounded to
.Ar n
-digits. Does not affect formatting.
-.\".It Sy scrub
+digits. Does not affect formatting.
+.It Sy should_bold
+Return true if expression given to
+.Fl \-bold-if
+evaluates to true. Internal use only!
+.It Fn scrub value
+Clean
+.Ar value
+using various transformations such as round,
+stripping value annotations, and more.
.\".It Sy status
-.\".It Sy strip
+.It Fn strip value
+Strip value annotation from
+.Ar value .
.\".It Sy subcount
.It Fn tag name
Return the value of tag named
.Ar name .
-.\".It Fn to_amount value
-.\".It Fn to_balance value
-.\".It Fn to_boolean value
-.\".It Fn to_date value
-.\".It Fn to_datetime value
+.It Fn to_amount value
+Convert
+.Ar value
+to an amount. Internal use only!
+.It Fn to_balance value
+Convert
+.Ar value
+to a balance. Internal use only!
+.It Fn to_boolean value
+Convert
+.Ar value
+to a boolean. Internal use only!
+.It Fn to_date value
+Convert
+.Ar value
+to a date. Internal use only!
+.It Fn to_datetime value
+Convert
+.Ar value
+to a datetime. Internal use only!
.It Fn to_int value
Return the integer value for
.Ar value .
-.\".It Fn to_mask value
-.\".It Fn to_sequence value
+.It Fn to_mask value
+Convert
+.Ar value
+to a mask. Internal use only!
+.It Fn to_sequence value
+Convert
+.Ar value
+to a sequence. Internal use only!
.It Fn to_string value
Convert
.Ar value
to a character string.
.It Sy today
-Return today’s date.
+Return today's date.
.It Sy total
Return the total of the posting.
.It Sy total_expr
@@ -1225,7 +1358,14 @@ option.
.It Fn trim value
Trim leading and trailing whitespace from
.Ar value .
-.\".It Fn truncate
+.It Fn truncated string total_len account_len
+Truncate
+.Ar string
+to
+.Ar total_len
+ensuring that each account is at least
+.Ar account_len
+long.
.\".It Sy uncleared
.It Sy virtual
Return true if the transaction is virtual, e.g automated, false otherwise.
diff --git a/doc/ledger3.texi b/doc/ledger3.texi
index 08d0d2db..5e266253 100644
--- a/doc/ledger3.texi
+++ b/doc/ledger3.texi
@@ -3,6 +3,7 @@
@setfilename ledger3.info
@include version.texi
@set FIXME:UNDOCUMENTED @sc{undocumented}! Please help by contributing documentation for this feature.
+@set InternalUseOnly For internal use only.
@settitle Ledger: Command-Line Accounting
@c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with
@@ -58,7 +59,7 @@
@c the documentation itself, in that case the journal example data
@c needs to be specially marked as well using @smallexample @c input:UUID,
@c again with the UUID being the UUID of the corresponding ledger example
-@c command. If multiple inputs with the same UUID are found they will be
+@c command. If multiple inputs with the same UUID are found they will be
@c concatenated together and given as one set of data to the example command.
@c
@c @smallexample @c input:35CB2A3
@@ -88,6 +89,19 @@
@c $ 36.84 Expenses:Food:Dining
@c @end smallexample
@c
+@c To pass additional input to ledger for certain commands, e.g. convert add
+@c with_file:filename to the example command and add a file:UUID to an example
+@c that holds the additional input, where UUID is the UUID of the command,
+@c e.g.:
+@c
+@c @smallexample @c file:download.csv
+@c 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+@c @end smallexample
+@c
+@c @smallexample @c command:94FD2B6,with_file:download.csv
+@c $ ledger -f sample.dat convert download.csv
+@c @end smallexample
+@c
@c Additionally DocTests.py will pass --args-only and --columns 80 to ledger
@c to ignore any default arguments from the environment or .ledgerrc.
@c
@@ -288,7 +302,7 @@ Here is a good place for an aside on the use of the word ``account''.
Most private people consider an account to be something that holds
money at an institution for them. Ledger uses a more general
definition of the word. An account is anywhere money can go. Other
-finance programs use ``categories'', Ledger uses accounts. So, for
+finance programs use ``categories'', Ledger uses accounts. So, for
example, if you buy some groceries at Trader Joe's, then more groceries
at Whole Food Market, you might assign the transactions like this
@@ -382,18 +396,19 @@ acprep script, that does a lot of the footwork:
@end smallexample
See the `help` subcommand to `acprep`, which explains some of its many
-options. You can run `make check` to confirm the result, and `make
-install` to install. If these intructions do not work for you can check the
+options. You can run `make check` to confirm the result, and `make
+install` to install. If these intructions do not work for you can check the
`INSTALL.md` in the source directory for more up do date build instructions.
@node Getting help, , Building the program, Introduction to Ledger
@section Getting help
@findex help
-Ledger has a complete online help system based on GNU Info. This
-manual can be searched directly from the command-line using the
-following options: @code{ledger --help} brings up this entire manual in
-your TTY.
+Ledger has a complete online help system based on GNU Info. This manual
+can be searched directly from the command-line using @code{info ledger},
+which will bring up this entire manual in your TTY. Alternatively, the
+shorter man page can be accessed from the command-line either via
+@code{man ledger} or @code{ledger --help}
If you need help on how to use Ledger, or run into problems, you can
join the Ledger mailing list at
@@ -638,7 +653,7 @@ $ ledger -f drewr3.dat cleared
$ -20.00 0 MasterCard
$ 200.00 0 Mortgage:Principal
$ -243.60 0 Tithe
----------------- ---------------- ---------
+---------------- ---------------- ---------
$ -243.60 0
@end smallexample
@@ -1142,6 +1157,8 @@ $ ledger --no-total balance Billable Project
-50.0m Project:XYZ
@end smallexample
+@findex C
+
This example works because ledger already knows how to handle seconds,
minutes and hours, as part of its time tracking support. Defining
other equivalences is simple. The following is an example that
@@ -1383,7 +1400,7 @@ $ ledger --real --no-total bal
If more asset accounts are needed as the source of a posting, just
list them as you would normally, for example:
-@smallexample
+@smallexample @c input:validate
2004/03/25 Payment for books (paid from Checking)
Expenses:Books $100.00
Assets:Checking $-50.00
@@ -1461,10 +1478,8 @@ you.
The Ledger program aims at making journal transactions as simple as
possible. Since it is a command-line tool, it does not provide a user
-interface for keeping a journal. If you like, you may use GnuCash to
-maintain your journal, in which case Ledger will read
-GnuCash's data files directly. In that case, read the GnuCash manual
-now, and skip to the next chapter.
+interface for keeping a journal. If you require an user interface to
+maintain journal transactions GnuCash is a good alternative.
If you are not using GnuCash, but a text editor to maintain your
journal, read on. Ledger has been designed to make data transactions
@@ -1530,7 +1545,7 @@ Accounts}).
@cindex posting format details
@strong{The format is very flexible and it isn't necessary that you
-indent and space out things exactly as shown. The only requirements
+indent and space out things exactly as shown. The only requirements
are that the start of the transaction (the date typically) is at the
beginning of the first line of the transaction, and the accounts are
indented by at least one space. If you omit the leading spaces in the
@@ -1551,7 +1566,7 @@ Ledger has a starting point.
At some convenient point in time you knew the balances and outstanding
obligation of every financial account you have. Those amounts form the
-basis of the opening entry for ledger. For example if you chose the
+basis of the opening entry for ledger. For example if you chose the
beginning of 2011 as the date to start tracking finances with ledger,
your opening balance entry could look like this:
@@ -1599,7 +1614,7 @@ Beneath these top level accounts you can have any level of detail you
desire. For example, if you want to keep specific track of how much
you spend on burgers and fries, you could have the following:
-@smallexample
+@smallexample @c input:validate
Expenses:Food:Hamburgers and Fries
@end smallexample
@@ -1660,7 +1675,7 @@ Dollars, Euros, Pounds, Francs, Shares etc. are all just ``commodities''.
Holdings in stocks, bonds, mutual funds and other financial
instruments can be labeled using whatever is convenient for you (stock
ticker symbols are suggested for publicly traded assets).@footnote{You
-can track @emph{anything}, even time or distance traveled. As long as
+can track @emph{anything}, even time or distance traveled. As long as
it cannot be created or destroyed inside your accounting system.}
For the rest of this manual, we will only use the word ``commodities''
@@ -1691,7 +1706,7 @@ business trip to Europe from the US:
@end smallexample
This says that $66.00 came out of checking and turned into 50
-Euros. The implied exchange rate was $1.32. Then 35.00 Euros were
+Euros. The implied exchange rate was $1.32. Then 35.00 Euros were
spent on Dinner in Munich.
Running a ledger balance report shows:
@@ -1748,7 +1763,7 @@ commodity name must be enclosed in double quotes @samp{"}:
Buying stock is a typical example that many will use that involves
multiple commodities in the same transaction. The type of the share
(AAPL for Apple Inc.) and the share purchase price in the currency
-unit you made the purchase in ($ for AAPL). Yes, the typical
+unit you made the purchase in ($ for AAPL). Yes, the typical
convention is as follows:
@smallexample @c input:validate
@@ -1842,8 +1857,8 @@ Assets:Checking because its amount is null.
@findex --exchange @var{COMMODITY}
Ledger allows you to have very detailed control over how your
-commodities are valued. You can fine tune the results given using the
-@option{--market} or @option{--exchange @var{COMMODITY}} options. There
+commodities are valued. You can fine tune the results given using the
+@option{--market} or @option{--exchange @var{COMMODITY}} options. There
are now several points of interception; you can specify the valuation
method:
@@ -1874,7 +1889,7 @@ The reference date the price should be relative.
@item target
A string identifying the ``target'' commodity, or the commodity the
-returned price should be in. This argument is null if @option{--market}
+returned price should be in. This argument is null if @option{--market}
was used instead of @option{--exchange @var{COMMODITY}}.
@end table
@@ -1883,16 +1898,16 @@ The valuation function should return an amount. If you've written
your function in Python, you can return something like
@samp{Amount("$100")}. If the function returns an explicit value,
that value is always used, regardless of the commodity, the date, or
-the desired target commodity. For example,
+the desired target commodity. For example,
-@smallexample
+@smallexample @c input:validate
define myfunc_seven(s, d, t) = 7 EUR
@end smallexample
In order to specify a fixed price, but still valuate that price into
the target commodity, use something like this:
-@smallexample
+@smallexample @c input:validate
define myfunc_five(s, d, t) = market(5 EUR, d, t)
@end smallexample
@@ -1900,14 +1915,14 @@ The @code{value} directive sets the valuation used for all commodities
used in the rest of the data stream. This is the fallback, if nothing
more specific is found.
-@smallexample
+@smallexample @c input:validate
value myfunc_seven
@end smallexample
You can set a specific valuation function on a per-commodity basis.
Instead of defining a function, you can also pass a lambda.
-@smallexample
+@smallexample @c input:validate
commodity $
value s, d, t -> 6 EUR
@end smallexample
@@ -1915,7 +1930,7 @@ commodity $
Each account can also provide a default valuation function for any
commodities transferred to that account.
-@smallexample
+@smallexample @c input:validate
account Expenses:Food5
value myfunc_five
@end smallexample
@@ -1923,7 +1938,7 @@ account Expenses:Food5
The metadata field @samp{Value}, if found, overrides the valuation
function on a transaction-wide or per-posting basis.
-@smallexample
+@smallexample @c input:validate
= @@XACT and Food
; Value:: 8 EUR
(Equity) $1
@@ -2006,10 +2021,9 @@ In order to combat inconsistency you can define allowable accounts and
payees. For simplicity, create a separate text file and define accounts
and payees like
-@smallexample
+@smallexample @c input:validate
account Expenses
account Expenses:Utilities
-...
@end smallexample
Using the @option{--strict} option will cause Ledger to complain if any
@@ -2025,7 +2039,7 @@ Warning: "FinanceData/Master.dat", line 15: Unknown account 'Allocation:Equities
If you have a large Ledger register already created use the
@command{accounts} command to get started:
-@smallexample
+@smallexample @c command:validate
$ ledger accounts >> Accounts.dat
@end smallexample
@@ -2090,6 +2104,7 @@ the syntax @code{[ACTUAL_DATE]} or @code{[=EFFECTIVE_DATE]} or
@item P
@findex --download
@findex P
+@cindex historical prices
Specifies a historical price for a commodity. These are usually found
in a pricing history file (see the @option{--download (-Q)} option).
The syntax is:
@@ -2099,6 +2114,9 @@ P DATE SYMBOL PRICE
@end smallexample
@item =
+@findex =
+@cindex automated transaction
+@cindex transaction, automated
An automated transaction. A value expression must appear after the
equal sign.
@@ -2109,17 +2127,23 @@ posting is matched by the value expression (@pxref{Automated
Transactions}).
@item ~
+@findex ~
+@cindex periodic transaction
+@cindex transaction, periodic
A periodic transaction. A period expression must appear after the tilde.
After this initial line there should be a set of one or more
postings, just as if it were a normal transaction.
@item ; # % | *
+@findex comment
+@cindex comments
A line beginning with a semicolon, pound, percent, bar or asterisk
-indicates a comment, and is ignored. Comments will not be returned in
+indicates a comment, and is ignored. Comments will not be returned in
a ``print'' response.
@item indented ;
+@cindex tags
If the semicolon is indented and occurs inside a transaction, it is
parsed as a persistent note for its preceding category. These notes or
tags can be used to augment the reporting and filtering capabilities of
@@ -2139,6 +2163,8 @@ Command directives must occur at the beginning of a line. Use of
@samp{!} and @samp{@@} is deprecated.
@item account
+@findex account
+@cindex pre-declare account
Pre-declare valid account names. This only has an effect if
@option{--strict} or @option{--pedantic} is used (see below). The
@code{account} directive supports several optional sub-directives, if
@@ -2188,6 +2214,7 @@ used as the ``balancing account'' for any future transactions that
contain only a single posting.
@item apply account
+@findex apply account
@c instance_t::master_account_directive
Sets the root for all accounts following this directive. Ledger
supports a hierarchical tree of accounts. It may be convenient to
@@ -2210,6 +2237,8 @@ Would result in all postings going into
until an @samp{end apply account} directive was found.
@item alias
+@findex alias
+@cindex account, alias
@c instance_t::alias_directive
Define an alias for an account name. If you have a deeply nested tree
of accounts, it may be convenient to define an alias, for example:
@@ -2261,6 +2290,8 @@ The option @option{--no-aliases} completely disables alias expansion.
All accounts are read verbatim as they are in the ledger file.
@item assert
+@findex assert
+@cindex assertions
@c instance_t::assert_directive
An assertion can throw an error if a condition is not met during
Ledger's run.
@@ -2271,6 +2302,8 @@ assert <VALUE EXPRESSION BOOLEAN RESULT>
@item bucket
@anchor{bucket}
+@findex bucket
+@cindex bucket
@c instance_t::default_account_directive
Defines the default account to use for balancing transactions.
Normally, each transaction has at least two postings, which must
@@ -2296,11 +2329,12 @@ bucket Assets:Checking
@item capture
@c instance_t::account_mapping_directive
+@findex capture
@findex print
@findex register
Directs Ledger to replace any account matching a regex with the given
-account. For example:
+account. For example:
@smallexample @c input:validate
capture Expenses:Deductible:Medical Medical
@@ -2313,6 +2347,8 @@ Ledger will display the mapped payees in @command{print} and
@command{register} reports.
@item check
+@findex check
+@cindex assertions
@c instance_t::check_directive in textual.cc
A check issues a warning if a condition is not met during Ledger's
run.
@@ -2322,10 +2358,14 @@ check <VALUE EXPRESSION BOOLEAN RESULT>
@end smallexample
@item comment
+@findex comment
+@cindex comments
@c instance_t::comment_directive in textual.cc
Start a block comment, closed by @code{end comment}.
@item commodity
+@findex commodity
+@cindex pre-declare commodity
Pre-declare commodity names. This only has an effect if
@option{--strict} or @option{--pedantic} is used (see below).
@@ -2360,8 +2400,9 @@ should never be auto-downloaded.
The @code{default} sub-directive marks this as the ``default'' commodity.
@item define
+@findex define
@c instance_t::define_directive in textual.cc
-Allows you to define value expressions for future use. For example:
+Allows you to define value expressions for future use. For example:
@smallexample @c input:validate
define var_name=$100
@@ -2374,13 +2415,17 @@ define var_name=$100
The posting will have a cost of $400.
@item end
+@findex end
@c instance_t::end_directive in textual.cc
Closes block commands like @code{tag} or @code{comment}.
@item expr
+@findex expr
@c instance_t::expr_directive in textual.cc
@item fixed
+@findex fixed
+@cindex fixated prices
@c instance_t::fixed_directive in textual.cc
A fixed block is used to set fixated prices (@pxref{Fixated prices and
@@ -2422,10 +2467,12 @@ For the moment, users may wish to study
before using the @code{fixed} directive in production.
@item include
+@findex include
@c instance_t::include_directive in textual.cc
Include the stated file as if it were part of the current file.
@item payee
+@findex payee
@c instance_t::payee_alias_mapping_directive in textual.cc
@c instance_t::payee_uuid_mapping_directive in textual.cc
@findex print
@@ -2444,15 +2491,14 @@ payee KFC
The @code{alias} sub-directive provides a regex which, if it matches
a parsed payee, the declared payee name is substituted:
-@smallexample
+@smallexample @c input:validate
2012-02-27 KENTUCKY FRIED CHICKEN ; will be read as being 'KFC'
-...
@end smallexample
The @code{uuid} sub-directive specifies that a transaction with exactly
the uuid given should have the declared payee name substituted:
-@smallexample
+@smallexample @c input:validate
2014-05-13 UNHELPFUL PAYEE ; will be read as being 'KFC'
; UUID: 2a2e21d434356f886c84371eebac6e44f1337fda
@end smallexample
@@ -2461,6 +2507,7 @@ Ledger will display the mapped payees in @command{print} and
@command{register} reports.
@item apply tag
+@findex apply tag
@c instance_t::tag_directive in textual.cc
Allows you to designate a block of transactions and assign the same
tag to all. Tags can have values and may be nested.
@@ -2513,11 +2560,13 @@ is the equivalent of:
@c TODO: the following paragraph seems to be false, the automated tests
@c fail, if anything appears after end apply tag.
-@c Note that anything following @code{end apply tag} is ignored. placing
+@c Note that anything following @code{end apply tag} is ignored. Placing
@c the name of the tag that is being closed is a simple way to keep
@c track.
@item tag
+@findex tag
+@cindex pre-declare tag
Pre-declares tag names. This only has an effect if @option{--strict} or
@option{--pedantic} is used (see below).
@@ -2544,11 +2593,14 @@ but a string if typed metadata is used!). Such checks or assertions are
not called if no value is given.
@item test
+@findex test
+@cindex comments
@c instance_t::comment_directive in textual.cc
This is a synonym for @code{comment} and must be closed by an
@code{end} tag.
@item year
+@findex year
@anchor{year}
@c instance_t::year_directive in textual.cc
Denotes the year used for all subsequent transactions that give a date
@@ -2566,10 +2618,12 @@ alone, for backwards compatibility with older Ledger versions.
@item A
@findex A
+@findex bucket
@xref{bucket}.
@item Y
@findex Y
+@findex year
@xref{year}.
@item N SYMBOL
@@ -2580,14 +2634,13 @@ with a home currency, such as the dollar @samp{$}. It is recommended
that these pricing options be set in the price database file, which
defaults to @file{~/.pricedb}. The syntax for this command is:
-@smallexample
+@smallexample @c input:validate
N SYMBOL
@end smallexample
@item D AMOUNT
@findex xact
@findex D
-
Specifies the default commodity to use, by specifying an amount in the
expected format. The @command{xact} command will use this commodity as
the default when none other can be determined. This command may be used
@@ -2848,7 +2901,7 @@ default is uncleared. To mark a transaction cleared, put an asterisk
@end smallexample
@noindent
-To mark it pending, use a !:
+To mark it pending, use a @samp{!}:
@smallexample @c input:validate
2012-03-10 ! KFC
@@ -2992,17 +3045,17 @@ You can gang up multiple tags by sharing colons:
@findex payees
@findex --by-payee
-``Payee'' is a special metadata field. If set on a posting, it will be
+``Payee'' is a special metadata field. If set on a posting, it will be
used as the payee name for that posting. This affects the
@command{register} report, the @command{payees} report, and the
@option{--by-payee} option.
This is useful when for example you deposit 4 checks at a time to the
-bank. On the bank statement, there is just one amount @samp{$400}, but
+bank. On the bank statement, there is just one amount @samp{$400}, but
you can specify from whom each check came from, as shown by example
below:
-@smallexample @c input:validate
+@smallexample @c input:9B43E57
2010-06-17 Sample
Assets:Bank $400.00
Income:Check1 $-100.00 ; Payee: Person One
@@ -3011,14 +3064,20 @@ below:
Income:Check4 $-100.00 ; Payee: Person Four
@end smallexample
-When reporting this, it appears as:
+When reporting with
-@smallexample
-10-Jun-17 Sample Assets:Bank $400.00 $400.00
- Person One Income:Check1 $-100.00 $300.00
- Person Two Income:Check2 $-100.00 $200.00
- Person Three Income:Check3 $-100.00 $100.00
- Person Four Income:Check4 $-100.00 0
+@smallexample @c command:9B43E57
+$ ledger reg
+@end smallexample
+
+it appears as:
+
+@smallexample @c output:9B43E57
+10-Jun-17 Sample Assets:Bank $400.00 $400.00
+ Person One Income:Check1 $-100.00 $300.00
+ Person Two Income:Check2 $-100.00 $200.00
+ Person Three Income:Check3 $-100.00 $100.00
+ Person Four Income:Check4 $-100.00 0
@end smallexample
This shows that they are all in the same transaction (which is why the
@@ -3132,7 +3191,7 @@ the amount expression with parentheses:
If at the end of a posting's amount (and after the cost too, if there
is one) there is an equals sign, then Ledger will verify that the
total value for that account as of that posting matches the amount
-specified. See @option{--permissive} option to relax the balance assertions checks.
+specified. See @option{--permissive} option to relax the balance assertions checks.
There are two forms of this features: balance assertions, and balance
assignments.
@@ -3412,7 +3471,7 @@ but is not required to be used with them:
It should be noted that this is a convenience only for cases where you
buy and sell whole lots. The @{@{$500.00@}@} is @emph{not} an attribute
-of the commodity, whereas @{$5.00@} is. In fact, when you write
+of the commodity, whereas @{$50.00@} is. In fact, when you write
@{@{$500.00@}@}, Ledger just divides that value by 10 and sees
@{$50.00@}. So if you use the print command to look at this
transaction, you'll see the single braces form in the output. The
@@ -3486,7 +3545,7 @@ sensitive to this difference.
If you buy a stock last year, and ask for its value today, Ledger will
consult its price database to see what the most recent price for that
stock is. You can short-circuit this lookup by ``fixing'' the price
-at the time of a transaction. This is done using @{=AMOUNT@}:
+at the time of a transaction. This is done using @samp{@{=AMOUNT@}}:
@smallexample
2012-04-10 My Broker
@@ -3572,13 +3631,13 @@ If you use the functional form, you can either specify a function
name, or a lambda expression. Here's a function that yields the price
as $10 in whatever commodity is being requested:
-@smallexample
+@smallexample @c input:validate
define ten_dollars(s, date, t) = market($10, date, t)
@end smallexample
I can now use that in a lot value expression as follows:
-@smallexample
+@smallexample @c input:validate
2012-04-10 My Broker
Assets:Brokerage:Cash $375.00
Assets:Brokerage -5 AAPL @{$50.00@} ((ten_dollars)) @@@@ $375.00
@@ -3834,7 +3893,7 @@ the generated posting.
@findex --effective
In the real world, transactions do not take place instantaneously.
-Purchases can take several days to post to a bank account. And you may
+Purchases can take several days to post to a bank account. And you may
pay ahead for something for which you want to distribute costs. With
Ledger you can control every aspect of the timing of a transaction.
@@ -3882,7 +3941,7 @@ $ ledger --effective --begin 2008/01/01 --end 2008/01/14 bal Income
@noindent
gives you your cash basis income in the same two weeks.
-Another use is distributing costs out in time. As an example, suppose
+Another use is distributing costs out in time. As an example, suppose
you just prepaid into a local vegetable co-op that sustains you
through the winter. It costs $225 to join the program, so you write
a check. You don't want your October grocery budget to be blown
@@ -3926,10 +3985,10 @@ $ ledger --effective register Groceries
@subsection Periodic Transactions
@findex --budget
-A periodic transaction starts with a @samp{~} followed by a period
-expression. Periodic transactions are used for budgeting and
+A periodic transaction starts with a tilde @samp{~} followed by a period
+expression (see @ref{Period Expressions}). Periodic transactions are used for budgeting and
forecasting only, they have no effect without the @option{--budget}
-option specified. For examples and details, @pxref{Budgeting and
+option specified. For examples and details, @pxref{Budgeting and
Forecasting}.
@node Concrete Example of Automated Transactions, , Periodic Transactions, Automated Transactions
@@ -4043,7 +4102,7 @@ may be excluded from reports by using @option{--real}.
The power of Ledger comes from the incredible flexibility in its
reporting commands, combined with formatting commands. Some options
control what is included in the calculations, and formatting controls
-how it is displayed. The combinations are infinite. This chapter will
+how it is displayed. The combinations are infinite. This chapter will
show you the basics of combining various options and commands. In the
next chapters you will find details about the specific commands and
options.
@@ -4165,7 +4224,7 @@ $ ledger balance --limit 'account=~/Fuel/' and 'payee=~/Chev/'
@noindent
will show you the amount expended on gasoline at Chevron. The second
-example is the first example of the very power expression language
+example is the first example of the very powerful expression language
available to shape reports. The first example may be easier to
remember, but learning to use the second will open up far more
possibilities.
@@ -4181,7 +4240,7 @@ $ ledger bal Expenses and not (Expenses:Drinks or Expenses:Candy or Expenses:Gif
@subsection Controlling Formatting
These examples all use the default formatting for the balance
-report. Customizing the formatting can easily allowing to see only what
+report. Customizing the formatting can easily allowing to see only what
you want, or interface Ledger with other programs.
@node Typical queries, Advanced Reports, Balance Reports, Building Reports
@@ -4190,8 +4249,7 @@ you want, or interface Ledger with other programs.
A query such as the following shows all expenses since last
October, sorted by total:
-@c TODO: does not validate with @c command:validate, because "last oct" is split at the space
-@smallexample
+@smallexample @c command:validate
$ ledger -b "last oct" -S T bal ^expenses
@end smallexample
@@ -4283,11 +4341,11 @@ invested in equities, and partially invested in bonds and cash. Below
is the asset allocation for each of the instruments listed above:
@multitable @columnfractions .2 .2 .3 .3
-@item @tab Domestic @tab Global @tab
-@item Symbol @tab Equity @tab Equity @tab bonds/cash
-@item VIFSX @tab 100% @tab @tab
-@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7%
-@item VSGBX @tab @tab @tab 100%
+@item @tab Domestic @tab Global @tab
+@item Symbol @tab Equity @tab Equity @tab bonds/cash
+@item VIFSX @tab 100% @tab @tab
+@item VTHRX @tab 24.0% @tab 56.3% @tab 19.7%
+@item VSGBX @tab @tab @tab 100%
@end multitable
These numbers are available from the prospectus of any publicly
@@ -4296,7 +4354,7 @@ and a single bond issue is 100% bonds.
We track purchases of specific investments using the symbol of that
investment as its commodity. How do we tell Ledger that a share of
-VTHRX is 24% Global equity etc.? Enter automatic transactions and
+VTHRX is 24% Domestic equity? Enter automatic transactions and
virtual accounts.
At the top of our ledger we enter automatic transactions that describe
@@ -4307,12 +4365,9 @@ actual balances.
For the three instruments listed above, those automatic transactions
would look like:
-@smallexample @c input:validate
-;
-; automatic calculations for asset allocation tracking
-;
+@smallexample @c input:582C8C2
= expr ( commodity == 'VIFSX' )
- (Allocation:Equities:Domestic) 1.000
+ (Allocation:Equities:Domestic) 1.000
= expr ( commodity == 'VTHRX' )
(Allocation:Equities:Global) 0.240
@@ -4321,6 +4376,18 @@ would look like:
= expr ( commodity == 'VBMFX')
(Allocation:Bonds/Cash) 1.000
+
+2015-01-01 Buy VIFSX
+ Assets:Broker 100 VIFSX
+ Assets:Cash $-10000
+
+2015-01-01 Buy VTHRX
+ Assets:Broker 10 VTHRX
+ Assets:Cash $-10000
+
+2015-01-01 Buy VBMFX
+ Assets:Broker 1 VBMFX
+ Assets:Cash $-10000
@end smallexample
How do these work? First the @samp{=} sign at the beginning of the
@@ -4339,23 +4406,21 @@ the various asset classes how do we get a report that tells us our
current allocation? Using the balance command and some tricky
formatting!
-@c TODO: does not @c command:validate due to multiple lines
-@smallexample
+@smallexample @c command:582C8C2
ledger bal Allocation --current --format "\
%-17((depth_spacer)+(partial_account))\
%10(percent(market(display_total), market(parent.total)))\
%16(market(display_total))\n%/"
@end smallexample
-@noindent
Which yields:
-@smallexample
-Allocation 100.00% $100000.00
- Bonds/Cash 38.94% $38940.00
- Equities 61.06% $61060.00
- Domestic 95.31% $58196.29
- Global 4.69% $2863.71
+@smallexample @c output:582C8C2
+ Allocation 100.00% $30000
+ Bonds/Cash 39.90% $11970
+ Equities 60.10% $18030
+ Domestic 86.69% $15630
+ Global 13.31% $2400
@end smallexample
Let's look at the Ledger invocation a bit closer. The command above is
@@ -4373,7 +4438,7 @@ third line is where we calculate and display the percentages. The
for the account in this line. The @code{parent.total} command gives
the total for the next level up in the tree. @code{percent} formats
their ratio as a percentage. The fourth line tells ledger to display
-the current market value of the line. The last two characters
+the current market value of the line. The last two characters
@samp{%/} tell Ledger what to do for the last line, in this case,
nothing.
@@ -4387,13 +4452,13 @@ nothing.
@findex --display @var{EXPR}
If you have the ``Gnuplot'' program installed, you can graph any of the
-above register reports. The script to do this is included in the ledger
-distribution, and is named @file{contrib/report}. Install @file{report}
+above register reports. The script to do this is included in the ledger
+distribution, and is named @file{contrib/report}. Install @file{report}
anywhere along your @env{PATH}, and then use @file{report} instead of
-@file{ledger} when doing a register report. The only thing to keep in
+@file{ledger} when doing a register report. The only thing to keep in
mind is that you must specify @option{--amount-data (-j)} or
@option{--total-data (-J)} to indicate whether ``Gnuplot'' should plot
-the amount, or the running total. For example, this command plots total
+the amount, or the running total. For example, this command plots total
monthly expenses made on your MasterCard.
@smallexample
@@ -4416,7 +4481,7 @@ report -J reg ^income ^expenses # cash flow report
report -J -l "Ua>=@{\$0.01@}" reg ^assets ^liab
-# net worth report starting last February. the use of a display
+# net worth report starting last February. the use of a display
# predicate (-d) is needed, otherwise the balance will start at
# zero, and thus the y-axis will not reflect the true balance
@@ -4571,9 +4636,9 @@ Transaction Number,Date,Description,Memo,Amount Debit,Amount Credit,Balance,Chec
1113648,12/12/2011,"Withdrawal","Tuscan IT #00037657",-29.73,,00001908.37,,
@end smallexample
-Unfortunately, as it stands Ledger cannot read it, but you can. Ledger
+Unfortunately, as it stands Ledger cannot read it, but you can. Ledger
expects the first line to contain a description of the fields on each
-line of the file. The fields ledger can recognize contain these
+line of the file. The fields ledger can recognize contain these
case-insensitive strings @code{date}, @code{posted}, @code{code},
@code{payee} or @code{desc} or @code{description}, @code{amount},
@code{cost}, @code{total}, and @code{note}.
@@ -4600,7 +4665,7 @@ scripting.
If there are columns in the bank data you would like to keep in your
ledger data, besides the primary fields described above, you can name
them in the field descriptor list and Ledger will include them in the
-transaction as meta data if it doesn't recognize the field name. For
+transaction as meta data if it doesn't recognize the field name. For
example, if you want to capture the bank transaction number and it
occurs in the first column of the data use:
@@ -4612,24 +4677,69 @@ Ledger will include @samp{; transid: 767718} in the first transaction
from the file above.
@findex --invert
+@findex --auto-match
@findex --account @var{STR}
@findex --rich-data
-The @command{convert} command accepts three options. They are
-@option{--invert} which inverts the amount field,
-@option{--account @var{STR}} which you can use to specify the account to
-balance against, and @option{--rich-data} which stores
-additional metadata as tags. There is, for example,
-a UUID field. If an entry with the same UUID tag is already included in
-the normal ledger file (specified via @option{--file @var{FILE} (-f)} or
-via the environment variable @env{LEDGER_FILE}) this entry will not be
+The @command{convert} command accepts four options. They are
+@option{--invert} which inverts the amount field, @option{--auto-match}
+which automatically matches an account from the Ledger journal for every
+CSV line, @option{--account @var{STR}} which you can use to specify the
+account to balance against, and @option{--rich-data} which stores
+additional tag/value pairs.
+
+Using the two first lines of the above csv file,
+
+@smallexample @c file:01B0350
+,date,payee,note,amount,,,code,
+767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,,
+@end smallexample
+
+and launching the below command,
+
+@smallexample @c command:01B0350,with_file:download.csv
+$ ledger convert download.csv --input-date-format "%m/%d/%Y" \
+ --invert --account Assets:MyBank --rich-data \
+ --file sample.dat --now=2012/01/13
+@end smallexample
+
+you will get the result:
+
+@smallexample @c output:01B0350
+2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD
+ ; CSV: 767718,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-8.80,,00001640.04,,
+ ; Imported: 2012/01/13
+ ; UUID: dfdc3c3d5c54c6967dd39d5b4e4fd1ea76e87233
+ Expenses:Unknown 8.8
+ Assets:MyBank
+
+2011/12/13 * Withdrawal ;ACE HARDWARE 16335 S HOUGHTON RD
+ ; CSV: 767406,12/13/2011,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON RD",-1.03,,00001648.84,,
+ ; Imported: 2012/01/13
+ ; UUID: 63086448b1f29f7fd6efb11ea40660185a213f9d
+ Expenses:Unknown 1.03
+ Assets:MyBank
+@end smallexample
+
+The three added metadata are: @samp{CSV} as the original line from csv
+file, @samp{Imported} as the date when the csv file was imported into
+Ledger, and @samp{UUID} as a checksum of original csv line.
+
+If an entry with the same @samp{UUID} tag is already included in the
+normal ledger file (specified via @option{--file @var{FILE} (-f)} or via
+the environment variable @env{LEDGER_FILE}) this entry will not be
printed again.
+In the output above, the account is @samp{Expenses:Unknown} for CSV
+lines. You can use the @option{--auto-match} option to automatically
+match an account from your Ledger journal.
+
You can also use @command{convert} with @code{payee} and @code{account}
-directives. First, you can use the @code{payee} and @code{alias}
-directive to rewrite the @code{payee} field based on some rules. Then
+directives. First, you can use the @code{payee} and @code{alias}
+directive to rewrite the @code{payee} field based on some rules. Then
you can use the account and its @code{payee} directive to specify the
-account. I use it like this, for example:
+account. I use it like this, for example:
@smallexample @c input:validate
payee Aldi
@@ -4640,7 +4750,7 @@ account Aufwand:Einkauf:Lebensmittel
Note that it may be necessary for the output of @samp{ledger convert}
to be passed through @code{ledger print} a second time if you want to
-match on the new payee field. During the @code{ledger convert} run,
+match on the new payee field. During the @code{ledger convert} run,
only the original payee name as specified in the csv data seems to be
used.
@@ -4726,7 +4836,7 @@ Using Babel, it is possible to record financial transactions
conveniently in an org file and subsequently generate the financial
reports required.
-As of Org mode 7.01, Ledger support is provided. Check the Babel
+As of Org mode 7.01, Ledger support is provided. Check the Babel
documentation on Worg for instructions on how to achieve this but
I currently do this directly as follows:
@@ -4738,7 +4848,7 @@ I currently do this directly as follows:
@end smallexample
Once Ledger support in Babel has been enabled, we can proceed to
-include Ledger entries within an org file. There are three ways (at
+include Ledger entries within an org file. There are three ways (at
least) in which these can be included:
@enumerate
@@ -4777,7 +4887,7 @@ The first two are described in more detail in this short tutorial.
The easiest, albeit possibly least useful, way in which to use Ledger
within an org file is to use a single source block to record all Ledger
-entries. The following is an example source block:
+entries. The following is an example source block:
@smallexample
#+name: allinone
@@ -4807,11 +4917,11 @@ entries. The following is an example source block:
@end smallexample
In this example, we have combined both expenses and income into one set
-of Ledger entries. We can now generate register and balance reports (as
+of Ledger entries. We can now generate register and balance reports (as
well as many other types of reports) using Babel to invoke Ledger with
-specific arguments. The arguments are passed to Ledger using the
-@code{:cmdline} header argument. In the code block above, there is no
-such argument so the system takes the default. For Ledger code blocks,
+specific arguments. The arguments are passed to Ledger using the
+@code{:cmdline} header argument. In the code block above, there is no
+such argument so the system takes the default. For Ledger code blocks,
the default @code{:cmdline} argument is @code{bal} and the result of
evaluating this code block (@kbd{C-c C-c}) would be:
@@ -4841,16 +4951,16 @@ Evaluating the code block again would generate a different report.
Having to change the actual directive on the code block and re-evaluate
makes it difficult to have more than one view of your transactions and
-financial state. Eventually, Babel will support passing arguments to
+financial state. Eventually, Babel will support passing arguments to
@code{#+call} evaluations of code blocks but this support is missing
-currently. Instead, we can use the concepts of literary programming, as
+currently. Instead, we can use the concepts of literary programming, as
implemented by the @code{noweb} features of Babel, to help us.
@node Multiple Ledger source blocks with @code{noweb}, Income Entries, Embedded Ledger example with single source block, Org mode with Babel
@subsubsection Multiple Ledger source blocks with @code{noweb}
The @code{noweb} feature of Babel allows us to expand references to
-other code blocks within a code block. For Ledger, this can be used to
+other code blocks within a code block. For Ledger, this can be used to
group transactions according to type, say, and then bring various sets
of transactions together to generate reports.
@@ -4861,9 +4971,9 @@ these into expenses and income, as follows:
@subsubsection Income Entries
The first set of entries relates to income, either monthly pay or
-interest, all typically going into one of my bank accounts. Here, I have
+interest, all typically going into one of my bank accounts. Here, I have
placed several entries, but we could have had each entry in a separate
-@code{src} block. Note that all code blocks you wish to refer to later
+@code{src} block. Note that all code blocks you wish to refer to later
must have the @code{:noweb yes} header argument specified.
@smallexample
@@ -4891,7 +5001,7 @@ must have the @code{:noweb yes} header argument specified.
@subsubsection Expenses
The following entries relate to personal expenses, such as rent and
-food. Again, these have all been placed in a single @code{src} block but
+food. Again, these have all been placed in a single @code{src} block but
could have been done individually.
@smallexample
@@ -4911,8 +5021,8 @@ could have been done individually.
Given the ledger entries defined above in the income and expenses code
blocks, we can now refer to these using the noweb expansion directives,
-@code{<<name>>}. We can now define different code blocks to generate
-specific reports for those transactions. Below are two examples, one to
+@code{<<name>>}. We can now define different code blocks to generate
+specific reports for those transactions. Below are two examples, one to
generate a balance report and one to generate a register report of all
transactions.
@@ -4922,7 +5032,7 @@ transactions.
The overall balance of your account and expenditure with a breakdown
according to category is specified by passing the @code{:cmdline bal}
-argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c})
+argument to Ledger. This code block can now be evaluated (@kbd{C-c C-c})
and the results generated by incorporating the transactions referred to
by the @code{<<income>>} and @code{<<expenses>>} lines.
@@ -4968,7 +5078,7 @@ to tell Ledger to exclude sub-accounts in the report.
@findex --monthly
You can also generate a monthly register (the @command{reg} command) by
-executing the following @code{src} block. This presents a summary of
+executing the following @code{src} block. This presents a summary of
transactions for each monthly period (the @option{--monthly (-M)}
argument) with a running total in the final column (which should be 0 at
the end if all the entries are correct).
@@ -4994,7 +5104,7 @@ the end if all the entries are correct).
@end smallexample
We could also generate a monthly report on our assets showing how these
-are increasing (or decreasing!). In this case, the final column will be
+are increasing (or decreasing!). In this case, the final column will be
the running total of the assets in our ledger.
@smallexample
@@ -5015,7 +5125,7 @@ the running total of the assets in our ledger.
@subsubsection Summary
This short tutorial shows how Ledger entries can be embedded in an org
-file and manipulated using Babel. However, only simple Ledger features
+file and manipulated using Babel. However, only simple Ledger features
have been illustrated; please refer to the Ledger documentation for
examples of more complex operations on a ledger.
@@ -5028,7 +5138,7 @@ ledger can generate a graph of the relationship between your various
commodities. The output file is in the ``dot'' format.
This is probably not very interesting, unless you have many different
-commodities valued in terms of each other. For example, multiple
+commodities valued in terms of each other. For example, multiple
currencies and multiple investments valued in those currencies.
@node The @command{xml} command, @command{prices} and @command{pricedb} commands, The @command{pricemap} command, Reports in other Formats
@@ -5223,7 +5333,7 @@ pricedb database files.
The @command{accounts} command reports all of the accounts in the
journal. Following the command with a regular expression will limit the
-output to accounts matching the regex. The output is sorted by name.
+output to accounts matching the regex. The output is sorted by name.
Using the @option{--count} option will tell you how many entries use
each account.
@@ -5233,11 +5343,13 @@ each account.
The @command{payees} command reports all of the unique payees in the
journal. Using the @option{--count} option will tell you how many
-entries use each payee. To filter the payees displayed you must use the
+entries use each payee. To filter the payees displayed you must use the
prefix @@:
-@smallexample
+@smallexample @c command:validate
$ ledger payees @@Nic
+@end smallexample
+@smallexample
Nicolas
Nicolas BOILABUS
Oudtshoorn Municipality
@@ -5317,7 +5429,7 @@ $ ledger xact 4/9 viva dining "DM 11.50"
@end smallexample
@command{draft} and @command{entry} are both synonyms of
-@command{xact}. @command{entry} is provided for backwards compatibility
+@command{xact}. @command{entry} is provided for backwards compatibility
with Ledger 2.X.
@node @command{stats}, @command{select}, @command{xact}, Reports about your Journals
@@ -5346,7 +5458,7 @@ with Ledger 2.X.
@node Basic Usage, Command-Line Quick Reference, Command-Line Syntax, Command-Line Syntax
@section Basic Usage
-This chapter describes Ledger's features and options. You may wish to
+This chapter describes Ledger's features and options. You may wish to
survey this to get an overview before diving into the @ref{Ledger
Tutorial} and more detailed examples that follow.
@@ -5449,10 +5561,9 @@ Generate transactions based on previous postings.
@item --help
@itemx -h
-Print summary of all options.
+Display the man page for @file{ledger}.
@item --version
-@itemx -v
Print version information and exit.
@item --file @var{FILE}
@@ -5468,7 +5579,7 @@ Redirect output to @file{FILE}.
Specify an options file.
@item --import @var{FILE}
-@value{FIXME:UNDOCUMENTED}
+Import @var{FILE} as Python module.
@item --account @var{STR}
@itemx -a @var{STR}
@@ -5565,7 +5676,7 @@ Accounts, tags or commodities not previously declared will cause errors.
@item --check-payees
Enable strict and pedantic checking for payees as well as accounts,
-commodities and tags. This only works in conjunction with
+commodities and tags. This only works in conjunction with
@option{--strict} or @option{--pedantic}.
@item --immediate
@@ -5726,6 +5837,7 @@ Group postings together, similar to the balance report.
Use @file{FILE} for retrieving stored commodity prices.
@item --price-exp @var{INT}
+@itemx --leeway @var{INT}
@itemx -Z @var{INT}
Set expected freshness of prices in @var{INT} minutes.
@@ -5733,8 +5845,9 @@ Set expected freshness of prices in @var{INT} minutes.
@itemx -Q
Download quotes using the script named @file{getquote}.
-@item --getquote @var{FILE}
-Sets the path to a user-defined script to download commodity prices.
+@c FIXME: The option doesn't exist currently.
+@c @item --getquote @var{FILE}
+@c Sets the path to a user-defined script to download commodity prices.
@item --quantity
@itemx -O
@@ -5788,13 +5901,17 @@ database.
@item --debug @var{CODE}
@value{FIXME:UNDOCUMENTED}
+If ledger has been built with debug options this will provide extra data during
+the run.
@item --help
@itemx -h
-Display the man page for ledger.
+Display the man page for @file{ledger}.
@item --init-file @var{FILE}
-Specify the location of the init file. The default is @file{~/.ledgerrc}.
+Specify the location of the init file. The default is home directory
+@file{~/.ledgerrc}, or current directory @file{./.ledgerrc} if not found
+in home directory.
@item --options
Display the options in effect for this Ledger invocation, along with
@@ -5828,7 +5945,7 @@ $ ledger --options bal --cleared
@noindent
For the source column, a value starting with a @samp{-} or @samp{--}
indicated the source was a command-line argument. If the entry starts
-with a @samp{$}, the source was an environment variable. If the source
+with a @samp{$}, the source was an environment variable. If the source
is @code{?normalize} the value was set internally by ledger, in
a function called @code{normalize_options}.
@@ -5836,22 +5953,23 @@ a function called @code{normalize_options}.
Execute a ledger script.
@item --trace @var{INT}
-Enable tracing. The @var{INT} specifies the level of trace desired.
+Enable tracing. The @var{INT} specifies the level of trace desired.
@item --verbose
@itemx -v
Print detailed information on the execution of Ledger.
@item --verify
-Enable additional assertions during run-time. This causes a significant
+Enable additional assertions during run-time. This causes a significant
slowdown. When combined with @option{--debug @var{CODE}} ledger will
produce memory trace information.
@item --verify-memory
-@value{FIXME:UNDOCUMENTED}
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
@item --version
-@value{FIXME:UNDOCUMENTED}
+Print version information and exit.
@end ftable
@@ -5867,12 +5985,9 @@ sessions with multiple reports per session.
@ftable @option
-@item --cache @var{FIXME}
-@value{FIXME:UNDOCUMENTED}
-
@item --check-payees
Enable strict and pedantic checking for payees as well as accounts,
-commodities and tags. This only works in conjunction with
+commodities and tags. This only works in conjunction with
@option{--strict} or @option{--pedantic}.
@item --day-break
@@ -5887,7 +6002,6 @@ days by day.
@c @end smallexample
@c @smallexample @c output:
@c @end smallexample
-@value{FIXME:UNDOCUMENTED}
@item --decimal-comma
Direct Ledger to parse journals using the European standard comma as
@@ -5895,25 +6009,29 @@ a decimal separator, not the usual period.
@item --download
@itemx -Q
-Direct Ledger to download prices using the script defined via the option
-@option{--getquote @var{FILE}}.
+Direct Ledger to download prices.
+@c using the script defined via the option
+@c @option{--getquote @var{FILE}}.
@item --explicit
-@c see test/baseline/opt-explicit.test
-@value{FIXME:UNDOCUMENTED}
+Direct Ledger to require pre-declarations for entities (such as accounts,
+commodities and tags) rather than taking entities from cleared
+transactions as defined. This option is useful in combination with
+@option{--strict} or @option{--pedantic}.
@item --file @var{FILE}
@itemx -f @var{FILE}
Specify the input @file{FILE} for this invocation.
-@item --getquote @var{FILE}
-@cindex getquote
-@cindex download prices
-Tell ledger where to find the user defined script to download prices
-information.
+@c FIXME: The option doesn't exist currently.
+@c @item --getquote @var{FILE}
+@c @cindex getquote
+@c @cindex download prices
+@c Tell ledger where to find the user defined script to download prices
+@c information.
@item --input-date-format @var{DATE_FORMAT}
-Specify the input date format for journal entries. For example,
+Specify the input date format for journal entries. For example,
@smallexample
$ ledger convert Export.csv --input-date-format "%m/%d/%Y"
@@ -5964,12 +6082,12 @@ Quiet balance assertions.
Specify the location of the price entry data file.
@item --price-exp @var{INT}
-@itemx -Z @var{INT}
@itemx --leeway @var{INT}
-Set the expected freshness of price quotes, in @var{INT} minutes. That
+@itemx -Z @var{INT}
+Set the expected freshness of price quotes, in @var{INT} minutes. That
is, if the last known quote for any commodity is older than this value,
and if @option{--download} is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
@item --strict
@@ -5982,7 +6100,7 @@ a misspelled commodity or account) it will issue a warning giving you
the file and line number of the problem.
@item --recursive-aliases
-Normally, ledger only expands aliases once. With this option, ledger
+Normally, ledger only expands aliases once. With this option, ledger
tries to expand the result of alias expansion recursively, until no more
expansions apply.
@@ -5993,8 +6111,9 @@ based commodity as real hours and minutes.
For example 8100 seconds by default will be displayed as 2.25 whereas
with the @option{--time-colon} option they will be displayed as 2:15.
-@item --value-expr @var{FIXME}
-@value{FIXME:UNDOCUMENTED}
+@item --value-expr @var{VEXPR}
+Set a global value expression annotation.
+@c needs example
@end ftable
@@ -6012,14 +6131,14 @@ sessions with multiple reports per session.
@item --abbrev-len @var{INT}
Set the minimum length an account can be abbreviated to if it doesn't
-fit inside the @code{account-width}. If @var{INT} is zero, then the
-account name will be truncated on the right. If @var{INT} is greater
+fit inside the @code{account-width}. If @var{INT} is zero, then the
+account name will be truncated on the right. If @var{INT} is greater
than @code{account-width} then the account will be truncated on the
left, with no shortening of the account names in order to fit into the
desired width.
@item --account @var{STR}
-Prepend @var{STR} to all accounts reported. That is, the option
+Prepend @var{STR} to all accounts reported. That is, the option
@samp{--account Personal} would tack @samp{Personal:} to the beginning
of every account reported in a balance report or register report.
@@ -6038,7 +6157,7 @@ Show only unbudgeted postings.
@item --amount @var{EXPR}
@itemx -t @var{EXPR}
Apply the given value expression to the posting amount (@pxref{Value
-Expressions}). Using @option{--amount @var{EXPR}} you can apply an
+Expressions}). Using @option{--amount @var{EXPR}} you can apply an
arbitrary transformation to the postings.
@item --amount-data
@@ -6054,9 +6173,9 @@ Set the width in characters of the amount column in the
Anonymize registry output, mostly for sending in bug reports.
@item --auto-match
-@c Automatically match accounts from ledger journal when using convert command
-@c see test/baseline/opt-auto-match.dat
-@value{FIXME:UNDOCUMENTED}
+When generating a ledger transaction from a CSV file using the
+@command{convert} command, automatically match an account from the
+Ledger journal.
@item --aux-date
@itemx --effective
@@ -6069,7 +6188,7 @@ running totals.
@item --balance-format @var{FORMAT_STRING}
Specify the format to use for the @command{balance} report (@pxref{Format
-Strings}). The default is:
+Strings}). The default is:
@smallexample
"%(justify(scrub(display_total), 20, -1, true, color))"
@@ -6080,10 +6199,9 @@ Strings}). The default is:
@end smallexample
@item --base
-@c Report commodity in the base commodity s instead of h
-@c Does this apply to other commodities too?
-@c see test/baseline/opt-base.test/
-@value{FIXME:UNDOCUMENTED}
+Reduce convertible commodities down the bottom of the conversion, e.g.
+display time in seconds. This also applies to custom commodity
+conversions (@pxref{Commodity equivalences}).
@item --basis
@itemx -B
@@ -6091,7 +6209,7 @@ Strings}). The default is:
Report the cost basis on all posting.
@item --begin @var{DATE}
-Specify the start @var{DATE} of all calculations. Transactions before
+Specify the start @var{DATE} of all calculations. Transactions before
that date will be ignored.
@item --bold-if @var{VEXPR}
@@ -6107,7 +6225,7 @@ list all transactions since the beginning of December and print in
bold any posting greater than $100.
@item --budget
-Only display budgeted items. In a register report this
+Only display budgeted items. In a register report this
displays transactions in the budget, in a balance report this displays
accounts in the budget (@pxref{Budgeting and Forecasting}).
@@ -6135,7 +6253,7 @@ calculation.
@item --cleared-format @var{FORMAT_STRING}
@c FIXME thdox: to keep?
Specify the format to use for the @command{cleared} report (@pxref{Format
-Strings}). The default is:
+Strings}). The default is:
@smallexample
"%(justify(scrub(get_at(total_expr, 0)), 16, 16 + prepend_width, "
@@ -6151,7 +6269,7 @@ Strings}). The default is:
@item --collapse
@itemx -n
-By default ledger prints all accounts in an account tree. With
+By default ledger prints all accounts in an account tree. With
@option{--collapse} it prints only the top level account specified.
@item --collapse-if-zero
@@ -6203,10 +6321,7 @@ Specify the width, in characters, of the date column in the
@command{register} report.
@item --datetime-format @var{DATETIME_FORMAT}
-@c Specify the format ledger should use to print datetimes in
-@c @command{balance} @option{--timelog-report} reports.
-@c see test/baseline/opt-datetime-format.test
-@value{FIXME:UNDOCUMENTED}
+Specify the format ledger should use to print datetimes.
@item --dc
Display register or balance in debit/credit format If you use
@@ -6271,11 +6386,11 @@ And with @option{--dc} it becomes this:
Limit the depth of the account tree. In a balance report, for example,
a @samp{--depth 2} statement will print balances only for accounts with
two levels, i.e. @samp{Expenses:Entertainment} but not
-@samp{Expenses:Entertainment:Dining}. This is a display predicate, which
+@samp{Expenses:Entertainment:Dining}. This is a display predicate, which
means it only affects display, not the total calculations.
@item --deviation
-Report each posting’s deviation from the average. It is only meaningful
+Report each posting’s deviation from the average. It is only meaningful
in the register and prices reports.
@item --display @var{EXPR}
@@ -6306,7 +6421,7 @@ Include empty accounts in the report and in average calculations.
@item --end @var{DATE}
Specify the end @var{DATE} for a transaction to be considered in the
-report. All transactions on or after this date are ignored.
+report. All transactions on or after this date are ignored.
@item --equity
Related to the @command{equity} command (@pxref{The @command{equity}
@@ -6314,11 +6429,12 @@ command}). Gives current account balances in the form of a register
report.
@item --exact
-@value{FIXME:UNDOCUMENTED}
+Report beginning and ending of periods by the date of the first and last
+posting occurring in that period.
@item --exchange @var{COMMODITY}
@itemx -X @var{COMMODITY}
-Display values in terms of the given @var{COMMODITY}. The latest
+Display values in terms of the given @var{COMMODITY}. The latest
available price is used. The syntax
@option{-X @var{COMMODITY1}:@var{COMMODITY2}} displays values in @var{COMMODITY1}
in terms of @var{COMMODITY2} using the latest available price, but
@@ -6331,11 +6447,11 @@ available for reporting in terms of @var{COMMODITY2}, but only a few
should be displayed that way.
@item --flat
-Force the full names of accounts to be used in the balance report. The
+Force the full names of accounts to be used in the balance report. The
balance report will not use an indented tree.
@item --force-color
-Output TTY color codes even if the TTY doesn't support them. Useful
+Output TTY color codes even if the TTY doesn't support them. Useful
for TTYs that don't advertise their capabilities correctly.
@item --force-pager
@@ -6365,15 +6481,17 @@ them.
@item --group-by @var{EXPR}
Group transactions together in the @command{register} report.
@var{EXPR} can be anything, although most common would be @code{payee}
-or @code{commodity}. The @code{tags()} function is also useful here.
+or @code{commodity}. The @code{tags()} function is also useful here.
@item --group-title-format @var{FORMAT_STRING}
Set the format for the headers that separates the report sections of
a grouped report. Only has an effect with a @option{--group-by
@var{EXPR}} register report.
-@smallexample
+@smallexample @c command:validate
$ ledger reg Expenses --group-by "payee" --group-title-format "------------------------ %-20(value) ---------------------\n"
+@end smallexample
+@smallexample
------------------------ 7-Eleven ---------------------
2011/08/13 7-Eleven Expenses:Auto:Misc $ 5.80 $ 5.80
@@ -6381,21 +6499,21 @@ $ ledger reg Expenses --group-by "payee" --group-title-format "-----------------
2011/06/02 AAA Dues Expenses:Auto:Misc $ 215.00 $ 215.00
------------------------ ABC Towing and Wrecking ---------------------
-2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20
+2011/03/17 ABC Towing and Wrec.. Expenses:Auto:Hobbies $ 48.20 $ 48.20
...
@end smallexample
@item --head @var{INT}
@itemx --first @var{INT}
-Print the first @var{INT} entries. Opposite of @option{--tail
+Print the first @var{INT} entries. Opposite of @option{--tail
@var{INT}}.
@item --historical
@itemx -H
-@value{FIXME:UNDOCUMENTED}
+Value commodities at the time of their acquisition.
@item --immediate
-@value{FIXME:UNDOCUMENTED}
+Evaluate calculations immediately rather than lazily.
@item --inject
Use @code{Expected} amounts in calculations. In case you know
@@ -6436,8 +6554,8 @@ Report the date and price at which each commodity was purchased in
a balance report.
@item --lots-actual
-@c see test/baseline/opt-lots-actual.test
-@value{FIXME:UNDOCUMENTED}
+Preserve the uniqueness of commodities so they aren't merged during
+reporting without printing the lot annotations.
@item --market
@itemx -V
@@ -6464,8 +6582,12 @@ Suppress any color TTY output.
@item --no-pager
Direct output to stdout, avoiding pager program.
+@item --no-revalued
+Stop Ledger from showing @code{<Revalued>} postings. This option is useful
+in combination with the @option{--exchange} or @option{--market} option.
+
@item --no-rounding
-Don't output @samp{<Rounding>} postings. Note that this will cause the
+Don't output @samp{<Adjustment>} postings. Note that this will cause the
running total to often not add up! Its main use is for
@option{--amount-data (-j)} and @option{--total-data (-J)} reports.
@@ -6490,7 +6612,7 @@ Redirect the output of ledger to the file defined in @file{FILE}.
Direct output to @var{FILE} pager program.
@item --payee @var{VEXPR}
-Sets a value expression for formatting the payee. In the
+Sets a value expression for formatting the payee. In the
@command{register} report this prevents the second entry from having
a date and payee for each transaction.
@@ -6508,20 +6630,22 @@ Only works for accounts that have a single commodity.
@item --period @var{PERIOD_EXPRESSION}
Define a period expression that sets the time period during which
-transactions are to be accounted. For a @command{register} report only
+transactions are to be accounted. For a @command{register} report only
the transactions that satisfy the period expression with be displayed.
For a @command{balance} report only those transactions will be accounted
in the final balances.
@item --pivot @var{TAG}
-Produce a balance pivot report @emph{around} the given @var{TAG}. For
+Produce a balance pivot report @emph{around} the given @var{TAG}. For
example, if you have multiple cars and track each fuel purchase in
@samp{Expenses:Auto:Fuel} and tag each fuel purchase with a tag
identifying which car the purchase was for @samp{; Car: Prius}, then the
command:
-@smallexample
+@smallexample @c command:validate
$ ledger bal Fuel --pivot "Car" --period "this year"
+@end smallexample
+@smallexample
$ 3491.26 Car
$ 1084.22 M3:Expenses:Auto:Fuel
$ 149.65 MG V11:Expenses:Auto:Fuel
@@ -6535,11 +6659,11 @@ $ ledger bal Fuel --pivot "Car" --period "this year"
@xref{Metadata values}.
@item --plot-amount-format @var{FORMAT_STRING}
-Define the output format for an amount data plot. @xref{Visualizing
+Define the output format for an amount data plot. @xref{Visualizing
with Gnuplot}.
@item --plot-total-format @var{FORMAT_STRING}
-Define the output format for a total data plot. @xref{Visualizing with
+Define the output format for a total data plot. @xref{Visualizing with
Gnuplot}.
@item --prepend-format @var{FORMAT_STRING}
@@ -6592,22 +6716,21 @@ Show all postings in a transaction, similar to @option{--related} but
show both @emph{sides} of each transaction.
@item --revalued
-@c see test/baeline/opt-revalued.test
-@value{FIXME:UNDOCUMENTED}
+Report discrepancy in values for manual reports by inserting @code{<Revalued>}
+postings. This is implied when using the @option{--exchange} or
+@option{--market} option.
@item --revalued-only
-@c see test/baeline/opt-revalued-only.test
-@value{FIXME:UNDOCUMENTED}
+Show only @code{<Revalued>} postings.
@item --revalued-total @var{FIXME}
-@value{FIXME:UNDOCUMENTED}
+Display the sum of the revalued postings as the running total, which serves
+to show unrealized capital in a gain/losses report.
@item --rich-data
@itemx --detail
-@c When generating ledger transaction from csv using the convert command
-@c add CSV, Imported, and UUID meta-data.
-@c see test/baeline/opt-rich-data.test
-@value{FIXME:UNDOCUMENTED}
+When generating a ledger transaction from a CSV file using the
+@command{convert} command, add CSV, Imported, and UUID metadata.
@item --seed @var{INT}
Set the random seed to @var{INT} for the @code{generate} command.
@@ -6627,22 +6750,22 @@ Sort the postings within transactions using the given value expression.
@item --start-of-week @var{INT}
Tell ledger to use a particular day of the week to start its ``weekly''
-summary. @samp{--start-of-week=1} specifies Monday as the start of the
+summary. @samp{--start-of-week=1} specifies Monday as the start of the
week.
@item --subtotal
@itemx -s
-@value{FIXME:UNDOCUMENTED}
+Cause all transactions in a @command{register} report to be collapsed
+into a single, subtotaled transaction.
@item --tail @var{INT}
@itemx --last @var{INT}
-Report only the last @var{INT} entries. Only useful in
+Report only the last @var{INT} entries. Only useful in
a @command{register} report.
@item --time-report
-@c Display begin and end time for each timelog entry in balance reports
-@c see test/baseline/opt-time-report.test
-@value{FIXME:UNDOCUMENTED}
+Add two columns to the balance report to show the earliest checkin and
+checkout times for timelog entries.
@item --total @var{VEXPR}
@itemx -T @var{VEXPR}
@@ -6657,8 +6780,8 @@ Set the width of the total field in the register report.
@item --truncate @var{CODE}
Indicates how truncation should happen when the contents of columns
-exceed their width. Valid arguments are @samp{leading}, @samp{middle},
-and @samp{trailing}. The default is smarter than any of these three,
+exceed their width. Valid arguments are @samp{leading}, @samp{middle},
+and @samp{trailing}. The default is smarter than any of these three,
as it considers sub-names within the account name (that style is
called ``abbreviate'').
@@ -6675,12 +6798,12 @@ report.
@item --unrealized-gains @var{STR}
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}.
+unrealized gains. Defaults to @samp{"Equity:Unrealized Gains"}.
Often set in one's @file{~/.ledgerrc} file to change the default.
@item --unrealized-losses @var{STR}
Allow the user to specify what account name should be used for
-unrealized gains. Defaults to @samp{"Equity:Unrealized Losses"}.
+unrealized losses. Defaults to @samp{"Equity:Unrealized Losses"}.
Often set in one's @file{~/.ledgerrc} file to change the default.
@item --unround
@@ -6716,8 +6839,7 @@ variables}), instead of using actual command-line options:
@item --help
@itemx -h
-Print a summary of all the options, and what they are used for. This
-can be a handy way to remember which options do what.
+Display the man page for @file{ledger}.
@item --version
Print the current version of ledger and exits. This is useful for
@@ -6726,9 +6848,9 @@ are using.
@item --file @var{FILE}
@itemx -f @var{FILE}
-Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is
-a synonym for @samp{/dev/stdin}. This command may be used multiple
-times. Typically, the environment variable @env{LEDGER_FILE} is set,
+Read @file{FILE} as a ledger file. @var{FILE} can be @samp{-} which is
+a synonym for @samp{/dev/stdin}. This command may be used multiple
+times. Typically, the environment variable @env{LEDGER_FILE} is set,
rather than using this command-line option.
@item --output @var{FILE}
@@ -6744,7 +6866,7 @@ settings. To specify options in the init file, use the same syntax as
on the command-line, but put each option on its own line. Here is an
example init file:
-@smallexample
+@smallexample @c input:validate
--price-db ~/finance/.pricedb
--wide
; ~/.ledgerrc ends here
@@ -6983,7 +7105,7 @@ least, using the absolute value of the total. For more on how to use
value expressions, see @ref{Value Expressions}.
@item --pivot @var{TAG}
-Produce a pivot table around the @var{TAG} provided. This requires
+Produce a pivot table around the @var{TAG} provided. This requires
meta data using valued tags.
@item --wide
@@ -6992,11 +7114,11 @@ Cause the default @command{register} report to assume 132 columns
instead of 80.
@item --head @var{INT}
-Cause only the first @var{INT} transactions to be printed. This is
+Cause only the first @var{INT} transactions to be printed. This is
different from using the command-line utility @file{head}, which would
-limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs
-only the last @var{INT} transactions. Both options may be used
-simultaneously. If a negative amount is given, it will invert the
+limit to the first @var{INT} postings. @option{--tail @var{INT}} outputs
+only the last @var{INT} transactions. Both options may be used
+simultaneously. If a negative amount is given, it will invert the
meaning of the flag (instead of the first five transactions being
printed, for example, it would print all but the first five).
@@ -7047,8 +7169,7 @@ register report, for example, but they will not be displayed. This is
useful for seeing last month's checking postings, against a running
balance which includes all posting values:
-@c TODO: does not @c command:validate due to space in "last month"
-@smallexample
+@smallexample @c command:validate
$ ledger -d "d>=[last month]" reg checking
@end smallexample
@@ -7056,8 +7177,7 @@ The output from this command is very different from the following,
whose running total includes only postings from the last month
onward:
-@c TODO: does not @c command:validate due to space in "last month"
-@smallexample
+@smallexample @c command:validate
$ ledger -p "last month" reg checking
@end smallexample
@@ -7100,7 +7220,7 @@ Define the output format for the @command{balance} report. The default
@end smallexample
@item --cleared-format @var{FORMAT_STRING}
-Define the format for the cleared report. The default is:
+Define the format for the cleared report. The default is:
@smallexample
"%(justify(scrub(get_at(display_total, 0)), 16, 16 + int(prepend_width),
@@ -7111,7 +7231,7 @@ Define the format for the cleared report. The default is:
%-(ansify_if(partial_account(options.flat), blue if color))\n%/
%$1 %$2 %$3\n%/
%(prepend_width ? \" \" * int(prepend_width) : \"\")
- ---------------- ---------------- ---------\n"
+ ---------------- ---------------- ---------\n"
@end smallexample
@item --register-format @var{FORMAT_STRING}
@@ -7168,7 +7288,7 @@ Set the format for @command{csv} reports. The default is:
@item --plot-amount-format @var{FORMAT_STRING}
Set the format for amount plots, using the @option{--amount-data (-j)}
-option. The default is:
+option. The default is:
@smallexample
"%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(display_amount)))\n"
@@ -7183,14 +7303,14 @@ option. The default is:
@end smallexample
@item --pricedb-format @var{FORMAT_STRING}
-Set the format expected for the historical price file. The default is:
+Set the format expected for the historical price file. The default is:
@smallexample
"P %(datetime) %(display_account) %(scrub(display_amount))\n"
@end smallexample
@item --prices-format @var{FORMAT_STRING}
-Set the format for the @command{prices} report. The default is:
+Set the format for the @command{prices} report. The default is:
@smallexample
"%(date) %-8(display_account) %(justify(scrub(display_amount), 12,
@@ -7213,7 +7333,7 @@ settings can be placed in this file manually, to prevent downloading
quotes for a specific commodity, for example. This is done by adding a
line like the following:
-@smallexample
+@smallexample @c input:validate
; Don't download quotes for the dollar, or timelog values
N $
N h
@@ -7228,11 +7348,12 @@ The format of the file can be changed by telling ledger to use the
@option{--pricedb-format @var{FORMAT_STRING}} you define.
@item --price-exp @var{INT}
+@itemx --leeway @var{INT}
@itemx -Z @var{INT}
-Set the expected freshness of price quotes, in @var{INT} minutes. That
+Set the expected freshness of price quotes, in @var{INT} minutes. That
is, if the last known quote for any commodity is older than this value,
and if @option{--download} is being used, then the Internet will be
-consulted again for a newer price. Otherwise, the old price is still
+consulted again for a newer price. Otherwise, the old price is still
considered to be fresh enough.
@item --download
@@ -7290,7 +7411,7 @@ etc.
When you specify @option{--market (-V)}, or @option{--exchange
@var{COMMODITY} (-X)}, you are requesting that some or all of the
commodities be valuated as of today (or whatever @option{--now
-@var{DATE}} is set to). But what does such a valuation mean? This
+@var{DATE}} is set to). But what does such a valuation mean? This
meaning is governed by the presence of a @var{VALUE} meta-data property,
whose content is an expression used to compute that value.
@@ -7330,7 +7451,7 @@ they cannot have a different future value:
@end smallexample
This says the future valuation is the same as the valuation at the time
-of posting. post.date equals the posting's date, while just 'date' is
+of posting. @code{post.date} equals the posting's date, while just 'date' is
the value of @option{--now @var{DATE}} (defaults to today).
Or how about valuating miles based on a reimbursement rate during a
@@ -7451,7 +7572,7 @@ command-line always take precedence over environment variable settings, however.
Note that you may also permanently specify option values by placing
option settings in the file @file{~/.ledgerrc} one option per line, for example:
-@smallexample
+@smallexample @c input:validate
--pager /bin/cat
@end smallexample
@@ -7589,7 +7710,7 @@ These two periodic transactions give the usual monthly expenses, as well
as one typical yearly expense. For help on finding out what your
average monthly expenses are for any category, use a command like:
-@smallexample
+@smallexample @c command:validate
$ ledger -p "this year" --monthly --average balance ^expenses
@end smallexample
@@ -7722,7 +7843,7 @@ constrain which transactions are printed. For example, the following
command shows only transactions from the beginning of the current month,
while still calculating the running balance based on all transactions:
-@smallexample
+@smallexample @c command:validate
$ ledger -d "d>[this month]" register checking
@end smallexample
@@ -7731,7 +7852,7 @@ running total in terms of all transactions in the register. The
following, simpler command is similar, but totals only the displayed
postings:
-@smallexample
+@smallexample @c command:validate
$ ledger -b "this month" register checking
@end smallexample
@@ -7798,6 +7919,13 @@ considering children.
The cost of a posting; the cost of an account, without its
children.
+@item v
+The market value of a posting or an account, without its children.
+
+@item g
+The net gain (market value minus cost basis), for a posting or an
+account, without its children. It is the same as @samp{v-b}.
+
@item l
The depth (``level'') of an account. If an account has one parent,
its depth is one.
@@ -7933,11 +8061,11 @@ Useful for specifying a date in plain terms. For example, you could say
@item expr comment =~ /REGEX/
A regular expression that matches against a posting's comment
-field. This searches only a posting's field, not the transaction's note
+field. This searches only a posting's field, not the transaction's note
or comment field. For example, @code{ledger reg "expr" "comment =~
/landline/"} will match:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
Assets:Checking $50.00
Expenses:Phone $-50.00 ; landline bill
@@ -7945,7 +8073,7 @@ or comment field. For example, @code{ledger reg "expr" "comment =~
but will not match:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill ; landline bill
; landline bill
Assets:Checking $50.00
@@ -7958,22 +8086,22 @@ instead.
@item expr note =~ /REGEX/
A regular expression that matches against a transaction's note field.
This searches all comments in the transaction, including comments on
-individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"}
+individual postings. Thus, @samp{ledger reg "expr" "note =~ /landline/"}
will match both all the three examples below:
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
Assets:Checking $50.00
Expenses:Phone $-50.00 ; landline bill
@end smallexample
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill ; landline bill
Assets:Checking $50.00
Expenses:Phone $-50.00
@end smallexample
-@smallexample
+@smallexample @c input:validate
2014/1/29 Phone bill
; landline bill
Assets:Checking $50.00
@@ -8029,15 +8157,16 @@ Assets:Cash ¤ 123,45
@end defun
@defun amount_expr
-@value{FIXME:UNDOCUMENTED}
+Return the calculated amount of the posting according to the @option{--amount}
+option.
@end defun
@defun ansify_if value color bool
Render the given @var{expression} as a string, applying the proper ANSI escape
codes to display it in the given @var{color} if @var{bool} is true. It
-typically checks the value of the option @option{--color}. Since ANSI escape
+typically checks the value of the option @option{--color}. Since ANSI escape
codes include non-printable character sequences, such as escape @kbd{^[}
-the following example may not appear as the final result on the commandline.
+the following example may not appear as the final result on the command-line.
@smallexample @c command:4D836EE,with_input:3406FC1
$ ledger -f expr.dat --format "%(ansify_if(account, blue, options.color))\n" reg
@end smallexample
@@ -8111,13 +8240,13 @@ Expenses:Office Supplies ¤ 123,00
@end smallexample
@end defun
-@defun format
-@value{FIXME:UNDOCUMENTED}
+@defun format string
+Evaluate @var{string} as format just like the @option{--format} option.
@end defun
@defun format_date date format
-Return the @var{date} as a string using @var{format}. See strftime (3)
-for format string details.
+Return the @var{date} as a string using @var{format}. See
+@code{strftime (3)} for format string details.
@smallexample @c command:9605B13,with_input:3406FC1
$ ledger -f expr.dat --format "%(format_date(date, '%A, %B %d. %Y'))\n" reg assets
@end smallexample
@@ -8126,29 +8255,31 @@ Friday, January 16. 2015
@end smallexample
@end defun
-@defun format_datetime
-@value{FIXME:UNDOCUMENTED}
+@defun format_datetime datetime format
+Return the @var{datetime} as a string using @var{format}. Refer to
+@code{strftime (3)} for format string details.
@end defun
-@defun get_at
-@value{FIXME:UNDOCUMENTED}
+@defun get_at sequence index
+Return the value in @var{sequence} at @var{index}. The first element is @var{index} 0.
+@value{InternalUseOnly}
@end defun
-@defun is_seq
-@value{FIXME:UNDOCUMENTED}
+@defun is_seq value
+Return true if @var{value} is a sequence. @value{InternalUseOnly}
@end defun
-@defun join
-@value{FIXME:UNDOCUMENTED}
+@defun join value
+Replace all newlines in @var{value} with @code{\n}.
@end defun
@defun justify value first_width latter_width right_justify colorize
Right or left justify the string representing @var{value}. The width
of the field in the first line is given by @var{first_width}. For
subsequent lines the width is given by @var{latter_width}. If
-@var{latter_width=-1}, then @var{first_width} is use for all lines.
-If @var{right_justify=true} then the field is right justify within
-the width of the field. If it is @var{false}, then the field is left
+@var{latter_width=-1}, then @var{first_width} is used for all lines.
+If @var{right_justify=true} then the field is right justified within
+the width of the field. If it is @var{false}, then the field is left
justified and padded to the full width of the field. If
@var{colorize} is true, then ledger will honor color settings.
@smallexample @c command:082FB27,with_input:3406FC1
@@ -8160,9 +8291,11 @@ $ ledger -f expr.dat --format "»%(justify(account, 30, 30, true))«\n" reg
@end smallexample
@end defun
-@defun market
+@defun market value datetime
@defunx P
-@value{FIXME:UNDOCUMENTED}
+Return the price of @var{value} at @var{datetime}. Note that @var{datetime}
+must be surrounded by brackets in order to be parsed correctly,
+e.g. @code{[2012/03/23]}.
@end defun
@defun nail_down
@@ -8172,7 +8305,7 @@ $ ledger -f expr.dat --format "»%(justify(account, 30, 30, true))«\n" reg
@defvar now
@defvarx d
@defvarx m
-@value{FIXME:UNDOCUMENTED}
+Return the current datetime.
@end defvar
@defvar options
@@ -8198,12 +8331,12 @@ $ ledger -f expr.dat --format "%(percent(amount, 200))\n" reg
@end smallexample
@end defun
-@defun print
-@value{FIXME:UNDOCUMENTED}
+@defun print value
+Print @var{value} to stdout. @value{InternalUseOnly}
@end defun
-@defun quantity
-@value{FIXME:UNDOCUMENTED}
+@defun quantity value
+Return the quantity of @var{value} for values that have a per-unit cost.
@end defun
@defun quoted expression
@@ -8236,37 +8369,38 @@ Expenses:Office Supplies ¤ 123,50
@end smallexample
@end defun
-@defun scrub
-@value{FIXME:UNDOCUMENTED}
+@defun scrub value
+Clean @var{value} using various transformations such as @code{round}, stripping
+value annotations, and more.
@end defun
@defun should_bold
-@value{FIXME:UNDOCUMENTED}
+Return true if expression given to @option{--bold-if} evaluates to true. @value{InternalUseOnly}
@end defun
-@defun strip
+@defun strip value
@defunx S
-@value{FIXME:UNDOCUMENTED}
+Strip value annotation from @var{value}.
@end defun
-@defun to_amount
-@value{FIXME:UNDOCUMENTED}
+@defun to_amount value
+Convert @var{value} to an amount. @value{InternalUseOnly}
@end defun
-@defun to_balance
-@value{FIXME:UNDOCUMENTED}
+@defun to_balance value
+Convert @var{value} to a balance. @value{InternalUseOnly}
@end defun
-@defun to_boolean
-@value{FIXME:UNDOCUMENTED}
+@defun to_boolean value
+Convert @var{value} to a boolean. @value{InternalUseOnly}
@end defun
-@defun to_date
-@value{FIXME:UNDOCUMENTED}
+@defun to_date value
+Convert @var{value} to a date. @value{InternalUseOnly}
@end defun
-@defun to_datetime
-@value{FIXME:UNDOCUMENTED}
+@defun to_datetime value
+Convert @var{value} to a datetime. @value{InternalUseOnly}
@end defun
@defun to_int value
@@ -8281,12 +8415,12 @@ $ ledger -f expr.dat --format "%(1 + to_int('1'))\n%(2,5 + int(2,5))\n" reg asse
@end smallexample
@end defun
-@defun to_mask
-@value{FIXME:UNDOCUMENTED}
+@defun to_mask value
+Convert @var{value} to a mask. @value{InternalUseOnly}
@end defun
-@defun to_sequence
-@value{FIXME:UNDOCUMENTED}
+@defun to_sequence value
+Convert @var{value} to a sequence. @value{InternalUseOnly}
@end defun
@defun to_string value
@@ -8309,7 +8443,8 @@ $ ledger -f expr.dat --now 2015/01/01 --format "%(today)\n" reg assets
@end defun
@defun total_expr
-@value{FIXME:UNDOCUMENTED}
+Return the calculated total of the posting according to the @option{--total}
+option.
@end defun
@defun trim value
@@ -8322,8 +8457,9 @@ $ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets
@end smallexample
@end defun
-@defun truncated
-@value{FIXME:UNDOCUMENTED}
+@defun truncatedstring total_len account_len
+Truncate @var{string} to @var{total_len} ensuring that each account is at least
+@var{account_len} long.
@end defun
@defun unround
@@ -8365,12 +8501,12 @@ $ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets
Format strings may be used to change the output format of reports. They
are specified by passing a formatting string to the @option{--format
-@var{FORMAT_STRING} (-F)} option. Within that string, constructs are
+@var{FORMAT_STRING} (-F)} option. Within that string, constructs are
allowed which make it possible to display the various parts of an
account or posting in custom ways.
There are several additional flags that allow you to define formats
-for specific reports. These are useful to define in your configuration
+for specific reports. These are useful to define in your configuration
file and will allow you to run ledger reports from the command-line
without having to enter a new format for each command.
@@ -8462,8 +8598,8 @@ $ ledger -f expr.dat --format "%12(5*O)\n" reg assets
@end smallexample
@item [DATEFMT]
-Inserts the result of formatting a posting's date with a date
-format string, exactly like those supported by @code{strftime}. For
+Inserts the result of formatting a posting's date with a date format
+string, exactly like those supported by @code{strftime (3)}. For
example: @samp{%[%Y/%m/%d %H:%M:%S]}.
@item S
@@ -8708,7 +8844,7 @@ Return the current date and time. If the @option{--now @var{DATE}}
option is defined it will return that value.
@item today
-Return the current date. If the @option{--now @var{DATE}} option is
+Return the current date. If the @option{--now @var{DATE}} option is
defined it will return that value.
@item to_datetime
@@ -8889,7 +9025,7 @@ of the field in the first line is given by @code{first_width}. For
subsequent lines the width is given by @code{latter_width}. If
@code{latter_width=-1}, then @code{first_width} is use for all lines.
If @code{right_justify=true} then the field is right justify within
-the width of the field. If it is @code{false}, then the field is left
+the width of the field. If it is @code{false}, then the field is left
justified and padded to the full width of the field. If
@code{colorize} is true, then ledger will honor color settings.
@@ -9651,7 +9787,7 @@ Ignore init files and environment variables for the ledger run.
@item --debug @var{CODE}
If Ledger has been built with debug options this will provide extra
-data during the run. The following are the available @var{CODES} to
+data during the run. The following are the available @var{CODES} to
debug:
@multitable @columnfractions .32 .43 .27
@@ -9684,7 +9820,7 @@ debug:
@
@item --trace @var{INT}
-Enable tracing. The @var{INT} specifies the level of trace desired:
+Enable tracing. The @var{INT} specifies the level of trace desired:
@multitable @columnfractions .3 .7
@item @code{LOG_OFF} @tab 0
@@ -9703,15 +9839,17 @@ Enable tracing. The @var{INT} specifies the level of trace desired:
@
@item --verbose
+@itemx -v
Print detailed information on the execution of Ledger.
@item --verify
-Enable additional assertions during run-time. This causes a significant
+Enable additional assertions during run-time. This causes a significant
slowdown. When combined with @option{--debug @var{CODE}} ledger will
produce memory trace information.
@item --verify-memory
-@value{FIXME:UNDOCUMENTED}
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
@item --version
Print version information and exit.
@@ -9723,7 +9861,7 @@ Print version information and exit.
@cindex pre-commands
Pre-commands are useful when you aren't sure how a command or option
-will work. The difference between a pre-command and a regular command
+will work. The difference between a pre-command and a regular command
is that pre-commands ignore the journal data file completely, nor is
the user's init file read.
@@ -9748,8 +9886,10 @@ and apply it against a model transaction.
@item period @var{PERIOD_EXPRESSION}
Evaluate the given period and report how Ledger interprets it:
-@smallexample
-$ ledger period "this year"
+@smallexample @c command:51F6A2C
+$ ledger period "this year" --now 2011-01-01
+@end smallexample
+@smallexample @c output:51F6A2C
--- Period expression tokens ---
TOK_THIS: this
TOK_YEAR: year
@@ -9772,8 +9912,10 @@ END_REACHED: <EOF>
Evaluate the given arguments and report how Ledger interprets it against
the following model transaction:
-@smallexample
+@smallexample @c command:validate
$ ledger query "/Book/"
+@end smallexample
+@smallexample
--- Input arguments ---
("/Book/")
@@ -9876,14 +10018,18 @@ In case several test files belong to the same bug number the files by appending
@code{_X} where @samp{X} is the number of the test, e.g. @samp{1234_1.test},
@samp{1234_2.test}.
+Baseline Test Types:
@anchor{Baseline Test Types}
-@multitable @columnfractions .3 .7
-@headitem Type @tab Use
-@item @code{cmd} @tab Ledger commands like @code{register} or @code{balance}
-@item @code{dir} @tab ?
-@item @code{feat} @tab ?
-@item @code{opt} @tab Ledger options such as @option{--period} or @option{--format}
-@end multitable
+@table @code
+@item cmd
+Ledger commands like @command{register} or @command{balance}
+@item dir
+Ledger directives like @code{account} or @code{alias}
+@item feat
+Ledger features such as balance assertions in journal file
+@item opt
+Ledger options such as @option{--period} or @option{--format}
+@end table
A ledger test file contains three sections:
@@ -9901,7 +10047,7 @@ The test scripts take the remainder of the @code{test} line and use
it as command-line arguments for ledger, the text enclosed in @code{test}
and @code{end test} is expected output, for example:
-@smallexample
+@smallexample @c input:validate
; This is the journal data
year 2014
12/24 (C0d3) Santa Claus
@@ -9968,10 +10114,10 @@ GnuCash file import.
The option @option{--performance (-g)}.
@item
-The balance report now defaults to showing all relevant accounts. This
-is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s
-bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)}
-option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option
+The balance report now defaults to showing all relevant accounts. This
+is the opposite of 2.x. That is, @command{bal} in 3.0 does what @samp{-s
+bal} did in 2.x. To see 2.6 behavior, use @option{--collapse (-n)}
+option in 3.0, like @samp{bal -n}. The @option{--subtotal (-s)} option
no longer has any effect on balance reports.
@end itemize
@@ -10004,7 +10150,7 @@ is now @env{LEDGER_PRICE_EXP}.
@appendix Example Journal File
The following journal file is included with the source distribution of
-ledger. It is called @file{drewr.dat} and exhibits many ledger
+ledger. It is called @file{drewr3.dat} and exhibits many ledger
features, include automatic and virtual transactions,
@smallexample @c input:validate
@@ -10013,64 +10159,71 @@ features, include automatic and virtual transactions,
= /^Income/
(Liabilities:Tithe) 0.12
-~ Monthly
- Assets:Checking $500.00
- Income:Salary
+;~ Monthly
+; Assets:Checking $500.00
+; Income:Salary
+
+;~ Monthly
+; Expenses:Food $100
+; Assets
-2003/12/01 * Checking balance
+2010/12/01 * Checking balance
Assets:Checking $1,000.00
Equity:Opening Balances
-2003/12/20 Organic Co-op
- Expenses:Food:Groceries $ 37.50 ; [=2004/01/01]
- Expenses:Food:Groceries $ 37.50 ; [=2004/02/01]
- Expenses:Food:Groceries $ 37.50 ; [=2004/03/01]
- Expenses:Food:Groceries $ 37.50 ; [=2004/04/01]
- Expenses:Food:Groceries $ 37.50 ; [=2004/05/01]
- Expenses:Food:Groceries $ 37.50 ; [=2004/06/01]
+2010/12/20 * Organic Co-op
+ Expenses:Food:Groceries $ 37.50 ; [=2011/01/01]
+ Expenses:Food:Groceries $ 37.50 ; [=2011/02/01]
+ Expenses:Food:Groceries $ 37.50 ; [=2011/03/01]
+ Expenses:Food:Groceries $ 37.50 ; [=2011/04/01]
+ Expenses:Food:Groceries $ 37.50 ; [=2011/05/01]
+ Expenses:Food:Groceries $ 37.50 ; [=2011/06/01]
Assets:Checking $ -225.00
-2003/12/28=2004/01/01 Acme Mortgage
+2010/12/28=2011/01/01 Acme Mortgage
Liabilities:Mortgage:Principal $ 200.00
Expenses:Interest:Mortgage $ 500.00
Expenses:Escrow $ 300.00
Assets:Checking $ -1000.00
-2004/01/02 Grocery Store
+2011/01/02 Grocery Store
Expenses:Food:Groceries $ 65.00
Assets:Checking
-2004/01/05 Employer
+2011/01/05 Employer
Assets:Checking $ 2000.00
Income:Salary
-2004/01/14 Bank
+2011/01/14 Bank
; Regular monthly savings transfer
Assets:Savings $ 300.00
Assets:Checking
-2004/01/19 Grocery Store
- Expenses:Food:Groceries $ 44.00
+2011/01/19 Grocery Store
+ Expenses:Food:Groceries $ 44.00 ; hastag: not block
Assets:Checking
-2004/01/25 Bank
+2011/01/25 Bank
; Transfer to cover car purchase
Assets:Checking $ 5,500.00
Assets:Savings
; :nobudget:
-2004/01/25 Tom's Used Cars
+apply tag hastag: true
+apply tag nestedtag: true
+2011/01/25 Tom's Used Cars
Expenses:Auto $ 5,500.00
; :nobudget:
Assets:Checking
-2004/01/27 Book Store
+2011/01/27 Book Store
Expenses:Books $20.00
Liabilities:MasterCard
-
-2004/02/01 Sale
+end tag
+2011/12/01 Sale
Assets:Checking:Business $ 30.00
Income:Sales
+end tag
@end smallexample
@node Miscellaneous Notes, Concepts Index, Example Journal File, Top
diff --git a/lib/utfcpp b/lib/utfcpp
deleted file mode 160000
-Subproject 2233ec933f5661c7050b94d3b14f5f9f51ae3d5
diff --git a/doc/LICENSE-utfcpp b/lib/utfcpp/v2_0/LICENSE
index 1751a003..36b7cd93 100644
--- a/doc/LICENSE-utfcpp
+++ b/lib/utfcpp/v2_0/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2006 Nemanja Trifunovic
+Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
diff --git a/lib/utfcpp/v2_0/buildrelease.pl b/lib/utfcpp/v2_0/buildrelease.pl
new file mode 100755
index 00000000..ed3a17bb
--- /dev/null
+++ b/lib/utfcpp/v2_0/buildrelease.pl
@@ -0,0 +1,18 @@
+#! /usr/bin/perl
+
+$release_files = 'source/utf8.h source/utf8/core.h source/utf8/checked.h source/utf8/unchecked.h doc/utf8cpp.html doc/ReleaseNotes';
+
+# First get the latest version
+`svn update`;
+
+# Then construct the name of the zip file
+$argc = @ARGV;
+if ($argc > 0) {
+ $zip_name = $ARGV[0];
+}
+else {
+ $zip_name = "utf8";
+}
+
+# Zip the files to an archive
+`zip $zip_name $release_files`;
diff --git a/lib/utfcpp/v2_0/samples/Makefile b/lib/utfcpp/v2_0/samples/Makefile
new file mode 100644
index 00000000..6cdd3c85
--- /dev/null
+++ b/lib/utfcpp/v2_0/samples/Makefile
@@ -0,0 +1,5 @@
+CC = g++
+CFLAGS = -g -Wall -pedantic
+
+docsample: docsample.cpp ../source/utf8.h
+ $(CC) $(CFLAGS) docsample.cpp -odocsample
diff --git a/lib/utfcpp/v2_0/samples/docsample.cpp b/lib/utfcpp/v2_0/samples/docsample.cpp
new file mode 100644
index 00000000..6f8953b9
--- /dev/null
+++ b/lib/utfcpp/v2_0/samples/docsample.cpp
@@ -0,0 +1,52 @@
+#include "../source/utf8.h"
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ if (argc != 2) {
+ cout << "\nUsage: docsample filename\n";
+ return 0;
+ }
+ const char* test_file_path = argv[1];
+ // Open the test file (must be UTF-8 encoded)
+ ifstream fs8(test_file_path);
+ if (!fs8.is_open()) {
+ cout << "Could not open " << test_file_path << endl;
+ return 0;
+ }
+
+ unsigned line_count = 1;
+ string line;
+ // Play with all the lines in the file
+ while (getline(fs8, line)) {
+ // check for invalid utf-8 (for a simple yes/no check, there is also utf8::is_valid function)
+ string::iterator end_it = utf8::find_invalid(line.begin(), line.end());
+ if (end_it != line.end()) {
+ cout << "Invalid UTF-8 encoding detected at line " << line_count << "\n";
+ cout << "This part is fine: " << string(line.begin(), end_it) << "\n";
+ }
+ // Get the line length (at least for the valid part)
+ int length = utf8::distance(line.begin(), end_it);
+ cout << "Length of line " << line_count << " is " << length << "\n";
+
+ // Convert it to utf-16
+ vector<unsigned short> utf16line;
+ utf8::utf8to16(line.begin(), end_it, back_inserter(utf16line));
+ // And back to utf-8;
+ string utf8line;
+ utf8::utf16to8(utf16line.begin(), utf16line.end(), back_inserter(utf8line));
+ // Confirm that the conversion went OK:
+ if (utf8line != string(line.begin(), end_it))
+ cout << "Error in UTF-16 conversion at line: " << line_count << "\n";
+
+ line_count++;
+ }
+
+ return 0;
+}
diff --git a/lib/utfcpp/v2_0/source/utf8.h b/lib/utfcpp/v2_0/source/utf8.h
new file mode 100644
index 00000000..4e445140
--- /dev/null
+++ b/lib/utfcpp/v2_0/source/utf8.h
@@ -0,0 +1,34 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include "utf8/checked.h"
+#include "utf8/unchecked.h"
+
+#endif // header guard
diff --git a/lib/utfcpp/v2_0/source/utf8/checked.h b/lib/utfcpp/v2_0/source/utf8/checked.h
new file mode 100644
index 00000000..13311551
--- /dev/null
+++ b/lib/utfcpp/v2_0/source/utf8/checked.h
@@ -0,0 +1,327 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include "core.h"
+#include <stdexcept>
+
+namespace utf8
+{
+ // Base for the exceptions that may be thrown from the library
+ class exception : public ::std::exception {
+ };
+
+ // Exceptions that may be thrown from the library functions.
+ class invalid_code_point : public exception {
+ uint32_t cp;
+ public:
+ invalid_code_point(uint32_t cp) : cp(cp) {}
+ virtual const char* what() const throw() { return "Invalid code point"; }
+ uint32_t code_point() const {return cp;}
+ };
+
+ class invalid_utf8 : public exception {
+ uint8_t u8;
+ public:
+ invalid_utf8 (uint8_t u) : u8(u) {}
+ virtual const char* what() const throw() { return "Invalid UTF-8"; }
+ uint8_t utf8_octet() const {return u8;}
+ };
+
+ class invalid_utf16 : public exception {
+ uint16_t u16;
+ public:
+ invalid_utf16 (uint16_t u) : u16(u) {}
+ virtual const char* what() const throw() { return "Invalid UTF-16"; }
+ uint16_t utf16_word() const {return u16;}
+ };
+
+ class not_enough_room : public exception {
+ public:
+ virtual const char* what() const throw() { return "Not enough space"; }
+ };
+
+ /// The library API - functions intended to be called by the users
+
+ template <typename octet_iterator>
+ octet_iterator append(uint32_t cp, octet_iterator result)
+ {
+ if (!utf8::internal::is_code_point_valid(cp))
+ throw invalid_code_point(cp);
+
+ if (cp < 0x80) // one octet
+ *(result++) = static_cast<uint8_t>(cp);
+ else if (cp < 0x800) { // two octets
+ *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else if (cp < 0x10000) { // three octets
+ *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else { // four octets
+ *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
+ *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator, typename output_iterator>
+ output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
+ {
+ while (start != end) {
+ octet_iterator sequence_start = start;
+ internal::utf_error err_code = utf8::internal::validate_next(start, end);
+ switch (err_code) {
+ case internal::UTF8_OK :
+ for (octet_iterator it = sequence_start; it != start; ++it)
+ *out++ = *it;
+ break;
+ case internal::NOT_ENOUGH_ROOM:
+ throw not_enough_room();
+ case internal::INVALID_LEAD:
+ out = utf8::append (replacement, out);
+ ++start;
+ break;
+ case internal::INCOMPLETE_SEQUENCE:
+ case internal::OVERLONG_SEQUENCE:
+ case internal::INVALID_CODE_POINT:
+ out = utf8::append (replacement, out);
+ ++start;
+ // just one replacement mark for the sequence
+ while (start != end && utf8::internal::is_trail(*start))
+ ++start;
+ break;
+ }
+ }
+ return out;
+ }
+
+ template <typename octet_iterator, typename output_iterator>
+ inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
+ {
+ static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
+ return utf8::replace_invalid(start, end, out, replacement_marker);
+ }
+
+ template <typename octet_iterator>
+ uint32_t next(octet_iterator& it, octet_iterator end)
+ {
+ uint32_t cp = 0;
+ internal::utf_error err_code = utf8::internal::validate_next(it, end, cp);
+ switch (err_code) {
+ case internal::UTF8_OK :
+ break;
+ case internal::NOT_ENOUGH_ROOM :
+ throw not_enough_room();
+ case internal::INVALID_LEAD :
+ case internal::INCOMPLETE_SEQUENCE :
+ case internal::OVERLONG_SEQUENCE :
+ throw invalid_utf8(*it);
+ case internal::INVALID_CODE_POINT :
+ throw invalid_code_point(cp);
+ }
+ return cp;
+ }
+
+ template <typename octet_iterator>
+ uint32_t peek_next(octet_iterator it, octet_iterator end)
+ {
+ return utf8::next(it, end);
+ }
+
+ template <typename octet_iterator>
+ uint32_t prior(octet_iterator& it, octet_iterator start)
+ {
+ // can't do much if it == start
+ if (it == start)
+ throw not_enough_room();
+
+ octet_iterator end = it;
+ // Go back until we hit either a lead octet or start
+ while (utf8::internal::is_trail(*(--it)))
+ if (it == start)
+ throw invalid_utf8(*it); // error - no lead byte in the sequence
+ return utf8::peek_next(it, end);
+ }
+
+ /// Deprecated in versions that include "prior"
+ template <typename octet_iterator>
+ uint32_t previous(octet_iterator& it, octet_iterator pass_start)
+ {
+ octet_iterator end = it;
+ while (utf8::internal::is_trail(*(--it)))
+ if (it == pass_start)
+ throw invalid_utf8(*it); // error - no lead byte in the sequence
+ octet_iterator temp = it;
+ return utf8::next(temp, end);
+ }
+
+ template <typename octet_iterator, typename distance_type>
+ void advance (octet_iterator& it, distance_type n, octet_iterator end)
+ {
+ for (distance_type i = 0; i < n; ++i)
+ utf8::next(it, end);
+ }
+
+ template <typename octet_iterator>
+ typename std::iterator_traits<octet_iterator>::difference_type
+ distance (octet_iterator first, octet_iterator last)
+ {
+ typename std::iterator_traits<octet_iterator>::difference_type dist;
+ for (dist = 0; first < last; ++dist)
+ utf8::next(first, last);
+ return dist;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = utf8::internal::mask16(*start++);
+ // Take care of surrogate pairs first
+ if (utf8::internal::is_lead_surrogate(cp)) {
+ if (start != end) {
+ uint32_t trail_surrogate = utf8::internal::mask16(*start++);
+ if (utf8::internal::is_trail_surrogate(trail_surrogate))
+ cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
+ else
+ throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
+ }
+ else
+ throw invalid_utf16(static_cast<uint16_t>(cp));
+
+ }
+ // Lone trail surrogate
+ else if (utf8::internal::is_trail_surrogate(cp))
+ throw invalid_utf16(static_cast<uint16_t>(cp));
+
+ result = utf8::append(cp, result);
+ }
+ return result;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = utf8::next(start, end);
+ if (cp > 0xffff) { //make a surrogate pair
+ *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
+ *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
+ }
+ else
+ *result++ = static_cast<uint16_t>(cp);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
+ {
+ while (start != end)
+ result = utf8::append(*(start++), result);
+
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
+ {
+ while (start != end)
+ (*result++) = utf8::next(start, end);
+
+ return result;
+ }
+
+ // The iterator class
+ template <typename octet_iterator>
+ class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
+ octet_iterator it;
+ octet_iterator range_start;
+ octet_iterator range_end;
+ public:
+ iterator () {}
+ explicit iterator (const octet_iterator& octet_it,
+ const octet_iterator& range_start,
+ const octet_iterator& range_end) :
+ it(octet_it), range_start(range_start), range_end(range_end)
+ {
+ if (it < range_start || it > range_end)
+ throw std::out_of_range("Invalid utf-8 iterator position");
+ }
+ // the default "big three" are OK
+ octet_iterator base () const { return it; }
+ uint32_t operator * () const
+ {
+ octet_iterator temp = it;
+ return utf8::next(temp, range_end);
+ }
+ bool operator == (const iterator& rhs) const
+ {
+ if (range_start != rhs.range_start || range_end != rhs.range_end)
+ throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
+ return (it == rhs.it);
+ }
+ bool operator != (const iterator& rhs) const
+ {
+ return !(operator == (rhs));
+ }
+ iterator& operator ++ ()
+ {
+ utf8::next(it, range_end);
+ return *this;
+ }
+ iterator operator ++ (int)
+ {
+ iterator temp = *this;
+ utf8::next(it, range_end);
+ return temp;
+ }
+ iterator& operator -- ()
+ {
+ utf8::prior(it, range_start);
+ return *this;
+ }
+ iterator operator -- (int)
+ {
+ iterator temp = *this;
+ utf8::prior(it, range_start);
+ return temp;
+ }
+ }; // class iterator
+
+} // namespace utf8
+
+#endif //header guard
+
+
diff --git a/lib/utfcpp/v2_0/source/utf8/core.h b/lib/utfcpp/v2_0/source/utf8/core.h
new file mode 100644
index 00000000..693d388c
--- /dev/null
+++ b/lib/utfcpp/v2_0/source/utf8/core.h
@@ -0,0 +1,329 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include <iterator>
+
+namespace utf8
+{
+ // The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
+ // You may need to change them to match your system.
+ // These typedefs have the same names as ones from cstdint, or boost/cstdint
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
+
+// Helper code - not intended to be directly called by the library users. May be changed at any time
+namespace internal
+{
+ // Unicode constants
+ // Leading (high) surrogates: 0xd800 - 0xdbff
+ // Trailing (low) surrogates: 0xdc00 - 0xdfff
+ const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
+ const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
+ const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
+ const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
+ const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10);
+ const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN;
+
+ // Maximum valid value for a Unicode code point
+ const uint32_t CODE_POINT_MAX = 0x0010ffffu;
+
+ template<typename octet_type>
+ inline uint8_t mask8(octet_type oc)
+ {
+ return static_cast<uint8_t>(0xff & oc);
+ }
+ template<typename u16_type>
+ inline uint16_t mask16(u16_type oc)
+ {
+ return static_cast<uint16_t>(0xffff & oc);
+ }
+ template<typename octet_type>
+ inline bool is_trail(octet_type oc)
+ {
+ return ((utf8::internal::mask8(oc) >> 6) == 0x2);
+ }
+
+ template <typename u16>
+ inline bool is_lead_surrogate(u16 cp)
+ {
+ return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX);
+ }
+
+ template <typename u16>
+ inline bool is_trail_surrogate(u16 cp)
+ {
+ return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
+ }
+
+ template <typename u16>
+ inline bool is_surrogate(u16 cp)
+ {
+ return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
+ }
+
+ template <typename u32>
+ inline bool is_code_point_valid(u32 cp)
+ {
+ return (cp <= CODE_POINT_MAX && !utf8::internal::is_surrogate(cp));
+ }
+
+ template <typename octet_iterator>
+ inline typename std::iterator_traits<octet_iterator>::difference_type
+ sequence_length(octet_iterator lead_it)
+ {
+ uint8_t lead = utf8::internal::mask8(*lead_it);
+ if (lead < 0x80)
+ return 1;
+ else if ((lead >> 5) == 0x6)
+ return 2;
+ else if ((lead >> 4) == 0xe)
+ return 3;
+ else if ((lead >> 3) == 0x1e)
+ return 4;
+ else
+ return 0;
+ }
+
+ template <typename octet_difference_type>
+ inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
+ {
+ if (cp < 0x80) {
+ if (length != 1)
+ return true;
+ }
+ else if (cp < 0x800) {
+ if (length != 2)
+ return true;
+ }
+ else if (cp < 0x10000) {
+ if (length != 3)
+ return true;
+ }
+
+ return false;
+ }
+
+ enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
+
+ /// Helper for get_sequence_x
+ template <typename octet_iterator>
+ utf_error increase_safely(octet_iterator& it, octet_iterator end)
+ {
+ if (++it == end)
+ return NOT_ENOUGH_ROOM;
+
+ if (!utf8::internal::is_trail(*it))
+ return INCOMPLETE_SEQUENCE;
+
+ return UTF8_OK;
+ }
+
+ #define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;}
+
+ /// get_sequence_x functions decode utf-8 sequences of the length x
+ template <typename octet_iterator>
+ utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point)
+ {
+ if (it == end)
+ return NOT_ENOUGH_ROOM;
+
+ code_point = utf8::internal::mask8(*it);
+
+ return UTF8_OK;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point)
+ {
+ if (it == end)
+ return NOT_ENOUGH_ROOM;
+
+ code_point = utf8::internal::mask8(*it);
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f);
+
+ return UTF8_OK;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point)
+ {
+ if (it == end)
+ return NOT_ENOUGH_ROOM;
+
+ code_point = utf8::internal::mask8(*it);
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point = ((code_point << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point += (*it) & 0x3f;
+
+ return UTF8_OK;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point)
+ {
+ if (it == end)
+ return NOT_ENOUGH_ROOM;
+
+ code_point = utf8::internal::mask8(*it);
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point = ((code_point << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point += (utf8::internal::mask8(*it) << 6) & 0xfff;
+
+ UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
+
+ code_point += (*it) & 0x3f;
+
+ return UTF8_OK;
+ }
+
+ #undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR
+
+ template <typename octet_iterator>
+ utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
+ {
+ // Save the original value of it so we can go back in case of failure
+ // Of course, it does not make much sense with i.e. stream iterators
+ octet_iterator original_it = it;
+
+ uint32_t cp = 0;
+ // Determine the sequence length based on the lead octet
+ typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
+ const octet_difference_type length = utf8::internal::sequence_length(it);
+
+ // Get trail octets and calculate the code point
+ utf_error err = UTF8_OK;
+ switch (length) {
+ case 0:
+ return INVALID_LEAD;
+ case 1:
+ err = utf8::internal::get_sequence_1(it, end, cp);
+ break;
+ case 2:
+ err = utf8::internal::get_sequence_2(it, end, cp);
+ break;
+ case 3:
+ err = utf8::internal::get_sequence_3(it, end, cp);
+ break;
+ case 4:
+ err = utf8::internal::get_sequence_4(it, end, cp);
+ break;
+ }
+
+ if (err == UTF8_OK) {
+ // Decoding succeeded. Now, security checks...
+ if (utf8::internal::is_code_point_valid(cp)) {
+ if (!utf8::internal::is_overlong_sequence(cp, length)){
+ // Passed! Return here.
+ code_point = cp;
+ ++it;
+ return UTF8_OK;
+ }
+ else
+ err = OVERLONG_SEQUENCE;
+ }
+ else
+ err = INVALID_CODE_POINT;
+ }
+
+ // Failure branch - restore the original value of the iterator
+ it = original_it;
+ return err;
+ }
+
+ template <typename octet_iterator>
+ inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
+ uint32_t ignored;
+ return utf8::internal::validate_next(it, end, ignored);
+ }
+
+} // namespace internal
+
+ /// The library API - functions intended to be called by the users
+
+ // Byte order mark
+ const uint8_t bom[] = {0xef, 0xbb, 0xbf};
+
+ template <typename octet_iterator>
+ octet_iterator find_invalid(octet_iterator start, octet_iterator end)
+ {
+ octet_iterator result = start;
+ while (result != end) {
+ utf8::internal::utf_error err_code = utf8::internal::validate_next(result, end);
+ if (err_code != internal::UTF8_OK)
+ return result;
+ }
+ return result;
+ }
+
+ template <typename octet_iterator>
+ inline bool is_valid(octet_iterator start, octet_iterator end)
+ {
+ return (utf8::find_invalid(start, end) == end);
+ }
+
+ template <typename octet_iterator>
+ inline bool starts_with_bom (octet_iterator it, octet_iterator end)
+ {
+ return (
+ ((it != end) && (utf8::internal::mask8(*it++)) == bom[0]) &&
+ ((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) &&
+ ((it != end) && (utf8::internal::mask8(*it)) == bom[2])
+ );
+ }
+
+ //Deprecated in release 2.3
+ template <typename octet_iterator>
+ inline bool is_bom (octet_iterator it)
+ {
+ return (
+ (utf8::internal::mask8(*it++)) == bom[0] &&
+ (utf8::internal::mask8(*it++)) == bom[1] &&
+ (utf8::internal::mask8(*it)) == bom[2]
+ );
+ }
+} // namespace utf8
+
+#endif // header guard
+
+
diff --git a/lib/utfcpp/v2_0/source/utf8/unchecked.h b/lib/utfcpp/v2_0/source/utf8/unchecked.h
new file mode 100644
index 00000000..cb242716
--- /dev/null
+++ b/lib/utfcpp/v2_0/source/utf8/unchecked.h
@@ -0,0 +1,228 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+#define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
+
+#include "core.h"
+
+namespace utf8
+{
+ namespace unchecked
+ {
+ template <typename octet_iterator>
+ octet_iterator append(uint32_t cp, octet_iterator result)
+ {
+ if (cp < 0x80) // one octet
+ *(result++) = static_cast<uint8_t>(cp);
+ else if (cp < 0x800) { // two octets
+ *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else if (cp < 0x10000) { // three octets
+ *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else { // four octets
+ *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
+ *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator>
+ uint32_t next(octet_iterator& it)
+ {
+ uint32_t cp = utf8::internal::mask8(*it);
+ typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
+ switch (length) {
+ case 1:
+ break;
+ case 2:
+ it++;
+ cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
+ break;
+ case 3:
+ ++it;
+ cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
+ ++it;
+ cp += (*it) & 0x3f;
+ break;
+ case 4:
+ ++it;
+ cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
+ ++it;
+ cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
+ ++it;
+ cp += (*it) & 0x3f;
+ break;
+ }
+ ++it;
+ return cp;
+ }
+
+ template <typename octet_iterator>
+ uint32_t peek_next(octet_iterator it)
+ {
+ return utf8::unchecked::next(it);
+ }
+
+ template <typename octet_iterator>
+ uint32_t prior(octet_iterator& it)
+ {
+ while (utf8::internal::is_trail(*(--it))) ;
+ octet_iterator temp = it;
+ return utf8::unchecked::next(temp);
+ }
+
+ // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
+ template <typename octet_iterator>
+ inline uint32_t previous(octet_iterator& it)
+ {
+ return utf8::unchecked::prior(it);
+ }
+
+ template <typename octet_iterator, typename distance_type>
+ void advance (octet_iterator& it, distance_type n)
+ {
+ for (distance_type i = 0; i < n; ++i)
+ utf8::unchecked::next(it);
+ }
+
+ template <typename octet_iterator>
+ typename std::iterator_traits<octet_iterator>::difference_type
+ distance (octet_iterator first, octet_iterator last)
+ {
+ typename std::iterator_traits<octet_iterator>::difference_type dist;
+ for (dist = 0; first < last; ++dist)
+ utf8::unchecked::next(first);
+ return dist;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = utf8::internal::mask16(*start++);
+ // Take care of surrogate pairs first
+ if (utf8::internal::is_lead_surrogate(cp)) {
+ uint32_t trail_surrogate = utf8::internal::mask16(*start++);
+ cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
+ }
+ result = utf8::unchecked::append(cp, result);
+ }
+ return result;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
+ {
+ while (start < end) {
+ uint32_t cp = utf8::unchecked::next(start);
+ if (cp > 0xffff) { //make a surrogate pair
+ *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
+ *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
+ }
+ else
+ *result++ = static_cast<uint16_t>(cp);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
+ {
+ while (start != end)
+ result = utf8::unchecked::append(*(start++), result);
+
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
+ {
+ while (start < end)
+ (*result++) = utf8::unchecked::next(start);
+
+ return result;
+ }
+
+ // The iterator class
+ template <typename octet_iterator>
+ class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
+ octet_iterator it;
+ public:
+ iterator () {}
+ explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
+ // the default "big three" are OK
+ octet_iterator base () const { return it; }
+ uint32_t operator * () const
+ {
+ octet_iterator temp = it;
+ return utf8::unchecked::next(temp);
+ }
+ bool operator == (const iterator& rhs) const
+ {
+ return (it == rhs.it);
+ }
+ bool operator != (const iterator& rhs) const
+ {
+ return !(operator == (rhs));
+ }
+ iterator& operator ++ ()
+ {
+ ::std::advance(it, utf8::internal::sequence_length(it));
+ return *this;
+ }
+ iterator operator ++ (int)
+ {
+ iterator temp = *this;
+ ::std::advance(it, utf8::internal::sequence_length(it));
+ return temp;
+ }
+ iterator& operator -- ()
+ {
+ utf8::unchecked::prior(it);
+ return *this;
+ }
+ iterator operator -- (int)
+ {
+ iterator temp = *this;
+ utf8::unchecked::prior(it);
+ return temp;
+ }
+ }; // class iterator
+
+ } // namespace utf8::unchecked
+} // namespace utf8
+
+
+#endif // header guard
+
diff --git a/lisp/ledger-check.el b/lisp/ledger-check.el
new file mode 100644
index 00000000..8eed34ed
--- /dev/null
+++ b/lisp/ledger-check.el
@@ -0,0 +1,136 @@
+;;; ledger-check.el --- Helper code for use with the "ledger" command-line tool
+
+;; Copyright (C) 2015 Craig Earls (enderw88 AT gmail DOT com)
+
+;; This file is not part of GNU Emacs.
+
+;; This is free software; you can redistribute it and/or modify it under
+;; the terms of the GNU General Public License as published by the Free
+;; Software Foundation; either version 2, or (at your option) any later
+;; version.
+;;
+;; This is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+;; for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
+
+;;; Commentary:
+;; Provide secial mode to correct errors in ledger when running with --strict and --explicit
+;;
+;; Adapted to ledger mode by Craig Earls <enderw88 at gmail dot com>
+
+;;; Code:
+
+(require 'easymenu)
+(eval-when-compile
+ (require 'cl))
+
+(defvar ledger-check-buffer-name "*Ledger Check*")
+
+
+
+
+(defvar ledger-check-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map [return] 'ledger-report-visit-source)
+ (define-key map [?q] 'ledger-check-quit)
+ map)
+ "Keymap for `ledger-check-mode'.")
+
+(easy-menu-define ledger-check-mode-menu ledger-check-mode-map
+ "Ledger check menu"
+ '("Check"
+; ["Re-run Check" ledger-check-redo]
+ "---"
+ ["Visit Source" ledger-report-visit-source]
+ "---"
+ ["Quit" ledger-check-quit]
+ ))
+
+(define-derived-mode ledger-check-mode text-mode "Ledger-Check"
+ "A mode for viewing ledger errors and warnings.")
+
+
+(defun ledger-do-check ()
+ "Run a check command ."
+ (goto-char (point-min))
+ (let ((data-pos (point))
+ (have-warnings nil))
+ (shell-command
+ ;; ledger balance command will just return empty if you give it
+ ;; an account name that doesn't exist. I will assume that no
+ ;; one will ever have an account named "e342asd2131". If
+ ;; someones does, this will probably still work for them.
+ ;; I should only highlight error and warning lines.
+ "ledger bal e342asd2131 --strict --explicit "
+ t nil)
+ (goto-char data-pos)
+
+ ;; format check report to make it navigate the file
+
+ (while (re-search-forward "^.*: \"\\(.*\\)\", line \\([0-9]+\\)" nil t)
+ (let ((file (match-string 1))
+ (line (string-to-number (match-string 2))))
+ (when file
+ (set-text-properties (line-beginning-position) (line-end-position)
+ (list 'ledger-source (cons file (save-window-excursion
+ (save-excursion
+ (find-file file)
+ (widen)
+ (ledger-navigate-to-line line)
+ (point-marker))))))
+ (add-text-properties (line-beginning-position) (line-end-position)
+ (list 'face 'ledger-font-report-clickable-face))
+ (setq have-warnings 'true)
+ (end-of-line))))
+ (if (not have-warnings)
+ (insert "No errors or warnings reported."))))
+
+(defun ledger-check-goto ()
+ "Goto the ledger check buffer."
+ (interactive)
+ (let ((rbuf (get-buffer ledger-check-buffer-name)))
+ (if (not rbuf)
+ (error "There is no ledger check buffer"))
+ (pop-to-buffer rbuf)
+ (shrink-window-if-larger-than-buffer)))
+
+(defun ledger-check-quit ()
+ "Quit the ledger check buffer."
+ (interactive)
+ (ledger-check-goto)
+ (set-window-configuration ledger-original-window-cfg)
+ (kill-buffer (get-buffer ledger-check-buffer-name)))
+
+(defun ledger-check-buffer ()
+ "Run a ledge with --explicit and --strict report errors and assist with fixing them.
+
+The output buffer will be in `ledger-check-mode', which defines
+commands for navigating the buffer to the errors found, etc."
+ (interactive
+ (progn
+ (when (and (buffer-modified-p)
+ (y-or-n-p "Buffer modified, save it? "))
+ (save-buffer))))
+ (let ((buf (current-buffer))
+ (cbuf (get-buffer ledger-check-buffer-name))
+ (wcfg (current-window-configuration)))
+ (if cbuf
+ (kill-buffer cbuf))
+ (with-current-buffer
+ (pop-to-buffer (get-buffer-create ledger-check-buffer-name))
+ (ledger-check-mode)
+ (set (make-local-variable 'ledger-original-window-cfg) wcfg)
+ (ledger-do-check)
+ (shrink-window-if-larger-than-buffer)
+ (set-buffer-modified-p nil)
+ (setq buffer-read-only t)
+ (message "q to quit; r to redo; k to kill"))))
+
+
+(provide 'ledger-check)
diff --git a/lisp/ledger-commodities.el b/lisp/ledger-commodities.el
index a0949c21..a6f2fdda 100644
--- a/lisp/ledger-commodities.el
+++ b/lisp/ledger-commodities.el
@@ -1,6 +1,6 @@
;;; ledger-commodities.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -37,6 +37,16 @@
:type 'string
:group 'ledger-reconcile)
+(defun ledger-read-commodity-with-prompt (prompt)
+ "Read commodity name after PROMPT.
+
+Default value is `ledger-reconcile-default-commodity'."
+ (let* ((buffer (current-buffer))
+ (commodities (with-temp-buffer
+ (ledger-exec-ledger buffer (current-buffer) "commodities")
+ (split-string (buffer-string) "\n" t))))
+ (completing-read prompt commodities nil t nil nil ledger-reconcile-default-commodity)))
+
(defun ledger-split-commodity-string (str)
"Split a commoditized string, STR, into two parts.
Returns a list with (value commodity)."
@@ -95,8 +105,8 @@ Returns a list with (value commodity)."
(error "Can't add different commodities, %S to %S" c1 c2)))
(defun ledger-strip (str char)
- "Return STR with CHAR removed."
- (replace-regexp-in-string char "" str))
+ "Return STR with CHAR removed."
+ (replace-regexp-in-string char "" str))
(defun ledger-string-to-number (str &optional decimal-comma)
"improve builtin string-to-number by handling internationalization, and return nil if number can't be parsed"
@@ -109,7 +119,7 @@ Returns a list with (value commodity)."
(string-to-number nstr)))
(defun ledger-number-to-string (n &optional decimal-comma)
- "number-to-string that handles comma as decimal."
+ "number-to-string that handles comma as decimal."
(let ((str (number-to-string n)))
(when (or decimal-comma
(assoc "decimal-comma" ledger-environment-alist))
@@ -128,7 +138,7 @@ longer ones are after the value."
(concat commodity " " str))))
(defun ledger-read-commodity-string (prompt)
- "Read an amount from mini-buffer using PROMPT."
+ "Read an amount from mini-buffer using PROMPT."
(let ((str (read-from-minibuffer
(concat prompt " (" ledger-reconcile-default-commodity "): ")))
comm)
diff --git a/lisp/ledger-complete.el b/lisp/ledger-complete.el
index 8c772b4b..5a4011b9 100644
--- a/lisp/ledger-complete.el
+++ b/lisp/ledger-complete.el
@@ -1,6 +1,6 @@
;;; ledger-complete.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -161,7 +161,7 @@
(ledger-accounts)))))
(defun ledger-trim-trailing-whitespace (str)
- (replace-regexp-in-string "[ \t]*$" "" str))
+ (replace-regexp-in-string "[ \t]*$" "" str))
(defun ledger-fully-complete-xact ()
"Completes a transaction if there is another matching payee in the buffer.
@@ -239,7 +239,7 @@ ledger-magic-tab would cycle properly"
pcomplete-seen pcomplete-norm-func
pcomplete-args pcomplete-last pcomplete-index
pcomplete-autolist
- (completions (pcomplete-completions))
+ (completions (pcomplete-completions))
(result (pcomplete-do-complete pcomplete-stub completions))
(pcomplete-termination-string ""))
(and result
diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el
index 0dfa4645..fb5f4c10 100644
--- a/lisp/ledger-context.el
+++ b/lisp/ledger-context.el
@@ -1,6 +1,6 @@
;;; ledger-context.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -32,10 +32,10 @@
;; `ledger-single-line-config' macro to form the regex and list of
;; elements
(defconst ledger-indent-string "\\(^[ \t]+\\)")
-(defconst ledger-status-string "\\([*! ]?\\)")
+(defconst ledger-status-string "\\(* \\|! \\)?")
(defconst ledger-account-string "[\\[(]?\\(.*?\\)[])]?")
-(defconst ledger-separator-string "\\s-\\s-")
-(defconst ledger-amount-string "\\(-?[0-9]+[\\.,][0-9]*\\)")
+(defconst ledger-separator-string "\\(\\s-\\s-+\\)")
+(defconst ledger-amount-string "\\(-?[0-9]+\\(?:[\\.,][0-9]*\\)?\\)")
(defconst ledger-comment-string "[ \t]*;[ \t]*\\(.*?\\)")
(defconst ledger-nil-string "\\([ \t]\\)")
(defconst ledger-commodity-string "\\(.+?\\)")
diff --git a/lisp/ledger-exec.el b/lisp/ledger-exec.el
index 07c36cac..5440e085 100644
--- a/lisp/ledger-exec.el
+++ b/lisp/ledger-exec.el
@@ -1,6 +1,6 @@
;;; ledger-exec.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -55,7 +55,7 @@
(setq buffer-read-only t)))
(defun ledger-exec-success-p (ledger-output-buffer)
- "Return t if the ledger output in LEDGER-OUTPUT-BUFFER is successful."
+ "Return t if the ledger output in LEDGER-OUTPUT-BUFFER is successful."
(with-current-buffer ledger-output-buffer
(goto-char (point-min))
(if (and (> (buffer-size) 1) (looking-at (regexp-quote "While")))
diff --git a/lisp/ledger-fontify.el b/lisp/ledger-fontify.el
index 8dbe1bd5..076e52b7 100644
--- a/lisp/ledger-fontify.el
+++ b/lisp/ledger-fontify.el
@@ -38,45 +38,46 @@
:group 'ledger)
(defun ledger-fontify-buffer-part (&optional beg end len)
-"Fontify buffer from BEG to END, length LEN."
- (save-excursion
- (unless beg (setq beg (point-min)))
- (unless end (setq end (point-max)))
- (goto-char beg)
- (beginning-of-line)
- (while (< (point) end)
- (cond ((or (looking-at ledger-xact-start-regex)
- (looking-at ledger-posting-regex))
- (ledger-fontify-xact-at (point)))
- ((looking-at ledger-directive-start-regex)
- (ledger-fontify-directive-at (point))))
- (ledger-navigate-next-xact-or-directive))))
+ "Fontify buffer from BEG to END, length LEN."
+ (save-excursion
+ (unless beg (setq beg (point-min)))
+ (unless end (setq end (point-max)))
+ (goto-char beg)
+ (beginning-of-line)
+ (while (< (point) end)
+ (cond ((or (looking-at ledger-xact-start-regex)
+ (looking-at ledger-posting-regex)
+ (looking-at ledger-recurring-line-regexp))
+ (ledger-fontify-xact-at (point)))
+ ((looking-at ledger-directive-start-regex)
+ (ledger-fontify-directive-at (point))))
+ (ledger-navigate-next-xact-or-directive))))
(defun ledger-fontify-xact-at (position)
"Fontify the xact at POSITION."
- (interactive "d")
- (save-excursion
- (goto-char position)
- (let ((extents (ledger-navigate-find-element-extents position))
- (state (ledger-transaction-state)))
- (if (and ledger-fontify-xact-state-overrides state)
- (cond ((eq state 'cleared)
- (ledger-fontify-set-face extents 'ledger-font-xact-cleared-face))
- ((eq state 'pending)
- (ledger-fontify-set-face extents 'ledger-font-xact-pending-face)))
- (ledger-fontify-xact-by-line extents)))))
+ (interactive "d")
+ (save-excursion
+ (goto-char position)
+ (let ((extents (ledger-navigate-find-element-extents position))
+ (state (ledger-transaction-state)))
+ (if (and ledger-fontify-xact-state-overrides state)
+ (cond ((eq state 'cleared)
+ (ledger-fontify-set-face extents 'ledger-font-xact-cleared-face))
+ ((eq state 'pending)
+ (ledger-fontify-set-face extents 'ledger-font-xact-pending-face)))
+ (ledger-fontify-xact-by-line extents)))))
(defun ledger-fontify-xact-by-line (extents)
- "Do line-by-line detailed fontification of xact in EXTENTS."
- (save-excursion
- (ledger-fontify-xact-start (car extents))
- (while (< (point) (cadr extents))
- (if (looking-at "[ \t]+;")
- (ledger-fontify-set-face (list (point) (progn
- (end-of-line)
- (point))) 'ledger-font-comment-face)
- (ledger-fontify-posting (point)))
- (forward-line))))
+ "Do line-by-line detailed fontification of xact in EXTENTS."
+ (save-excursion
+ (ledger-fontify-xact-start (car extents))
+ (while (< (point) (cadr extents))
+ (if (looking-at "[ \t]+;")
+ (ledger-fontify-set-face (list (point) (progn
+ (end-of-line)
+ (point))) 'ledger-font-comment-face)
+ (ledger-fontify-posting (point)))
+ (forward-line))))
(defun ledger-fontify-xact-start (pos)
"POS should be at the beginning of a line starting an xact.
@@ -102,97 +103,97 @@ Fontify the first line of an xact"
(forward-line)))
(defun ledger-fontify-posting (pos)
- "Fontify the posting at POS."
- (let* ((state nil)
- (end-of-line-comment nil)
- (end (progn (end-of-line)
- (point)))
- (start (progn (beginning-of-line)
- (point))))
-
- ;; Look for a posting status flag
- (set-match-data nil 'reseat)
- (re-search-forward " \\([*!]\\) " end t)
- (if (match-string 1)
- (setq state (ledger-state-from-string (match-string 1))))
- (beginning-of-line)
- (re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end) ;; find the end of the account, or end of line
-
- (when (<= (point) end) ;; we are still on the line
- (ledger-fontify-set-face (list start (point))
- (cond ((eq state 'cleared)
- 'ledger-font-posting-account-cleared-face)
- ((eq state 'pending)
- 'ledger-font-posting-account-pending-face)
- (t
- 'ledger-font-posting-account-face)))
-
-
- (when (< (point) end) ;; there is still more to fontify
- (setq start (point)) ;; update start of next font region
- (setq end-of-line-comment (re-search-forward ";" end 'end)) ;; find the end of the line, or start of a comment
- (ledger-fontify-set-face (list start (point) )
- (cond ((eq state 'cleared)
- 'ledger-font-posting-amount-cleared-face)
- ((eq state 'pending)
- 'ledger-font-posting-amount-pending-face)
- (t
- 'ledger-font-posting-amount-face)))
- (when end-of-line-comment
- (setq start (point))
- (end-of-line)
- (ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon
- 'ledger-font-comment-face))))))
+ "Fontify the posting at POS."
+ (let* ((state nil)
+ (end-of-line-comment nil)
+ (end (progn (end-of-line)
+ (point)))
+ (start (progn (beginning-of-line)
+ (point))))
+
+ ;; Look for a posting status flag
+ (set-match-data nil 'reseat)
+ (re-search-forward " \\([*!]\\) " end t)
+ (if (match-string 1)
+ (setq state (ledger-state-from-string (match-string 1))))
+ (beginning-of-line)
+ (re-search-forward "[[:graph:]]\\([ \t][ \t]\\)" end 'end) ;; find the end of the account, or end of line
+
+ (when (<= (point) end) ;; we are still on the line
+ (ledger-fontify-set-face (list start (point))
+ (cond ((eq state 'cleared)
+ 'ledger-font-posting-account-cleared-face)
+ ((eq state 'pending)
+ 'ledger-font-posting-account-pending-face)
+ (t
+ 'ledger-font-posting-account-face)))
+
+
+ (when (< (point) end) ;; there is still more to fontify
+ (setq start (point)) ;; update start of next font region
+ (setq end-of-line-comment (re-search-forward ";" end 'end)) ;; find the end of the line, or start of a comment
+ (ledger-fontify-set-face (list start (point) )
+ (cond ((eq state 'cleared)
+ 'ledger-font-posting-amount-cleared-face)
+ ((eq state 'pending)
+ 'ledger-font-posting-amount-pending-face)
+ (t
+ 'ledger-font-posting-amount-face)))
+ (when end-of-line-comment
+ (setq start (point))
+ (end-of-line)
+ (ledger-fontify-set-face (list (- start 1) (point)) ;; subtract 1 from start because we passed the semi-colon
+ 'ledger-font-comment-face))))))
(defun ledger-fontify-directive-at (pos)
- "Fontify the directive at POS."
- (let ((extents (ledger-navigate-find-element-extents pos))
- (face 'ledger-font-default-face))
- (cond ((looking-at "=")
- (setq face 'ledger-font-auto-xact-face))
- ((looking-at "~")
- (setq face 'ledger-font-periodic-xact-face))
- ((looking-at "[;#%|\\*]")
- (setq face 'ledger-font-comment-face))
- ((looking-at "\\(year\\)\\|Y")
- (setq face 'ledger-font-year-directive-face))
- ((looking-at "account")
- (setq face 'ledger-font-account-directive-face))
- ((looking-at "apply")
- (setq face 'ledger-font-apply-directive-face))
- ((looking-at "alias")
- (setq face 'ledger-font-alias-directive-face))
- ((looking-at "assert")
- (setq face 'ledger-font-assert-directive-face))
- ((looking-at "\\(bucket\\)\\|A")
- (setq face 'ledger-font-bucket-directive-face))
- ((looking-at "capture")
- (setq face 'ledger-font-capture-directive-face))
- ((looking-at "check")
- (setq face 'ledger-font-check-directive-face))
- ((looking-at "commodity")
- (setq face 'ledger-font-commodity-directive-face))
- ((looking-at "define")
- (setq face 'ledger-font-define-directive-face))
- ((looking-at "end")
- (setq face 'ledger-font-end-directive-face))
- ((looking-at "expr")
- (setq face 'ledger-font-expr-directive-face))
- ((looking-at "fixed")
- (setq face 'ledger-font-fixed-directive-face))
- ((looking-at "include")
- (setq face 'ledger-font-include-directive-face))
- ((looking-at "payee")
- (setq face 'ledger-font-payee-directive-face))
- ((looking-at "P")
- (setq face 'ledger-font-price-directive-face))
- ((looking-at "tag")
- (setq face 'ledger-font-tag-directive-face)))
- (ledger-fontify-set-face extents face)))
+ "Fontify the directive at POS."
+ (let ((extents (ledger-navigate-find-element-extents pos))
+ (face 'ledger-font-default-face))
+ (cond ((looking-at "=")
+ (setq face 'ledger-font-auto-xact-face))
+ ((looking-at "~")
+ (setq face 'ledger-font-periodic-xact-face))
+ ((looking-at "[;#%|\\*]")
+ (setq face 'ledger-font-comment-face))
+ ((looking-at "\\(year\\)\\|Y")
+ (setq face 'ledger-font-year-directive-face))
+ ((looking-at "account")
+ (setq face 'ledger-font-account-directive-face))
+ ((looking-at "apply")
+ (setq face 'ledger-font-apply-directive-face))
+ ((looking-at "alias")
+ (setq face 'ledger-font-alias-directive-face))
+ ((looking-at "assert")
+ (setq face 'ledger-font-assert-directive-face))
+ ((looking-at "\\(bucket\\)\\|A")
+ (setq face 'ledger-font-bucket-directive-face))
+ ((looking-at "capture")
+ (setq face 'ledger-font-capture-directive-face))
+ ((looking-at "check")
+ (setq face 'ledger-font-check-directive-face))
+ ((looking-at "commodity")
+ (setq face 'ledger-font-commodity-directive-face))
+ ((looking-at "define")
+ (setq face 'ledger-font-define-directive-face))
+ ((looking-at "end")
+ (setq face 'ledger-font-end-directive-face))
+ ((looking-at "expr")
+ (setq face 'ledger-font-expr-directive-face))
+ ((looking-at "fixed")
+ (setq face 'ledger-font-fixed-directive-face))
+ ((looking-at "include")
+ (setq face 'ledger-font-include-directive-face))
+ ((looking-at "payee")
+ (setq face 'ledger-font-payee-directive-face))
+ ((looking-at "P")
+ (setq face 'ledger-font-price-directive-face))
+ ((looking-at "tag")
+ (setq face 'ledger-font-tag-directive-face)))
+ (ledger-fontify-set-face extents face)))
(defun ledger-fontify-set-face (extents face)
- "Set the text in EXTENTS to FACE."
- (put-text-property (car extents) (cadr extents) 'face face))
+ "Set the text in EXTENTS to FACE."
+ (put-text-property (car extents) (cadr extents) 'face face))
(provide 'ledger-fontify)
diff --git a/lisp/ledger-fonts.el b/lisp/ledger-fonts.el
index 8bdecdb3..60450e20 100644
--- a/lisp/ledger-fonts.el
+++ b/lisp/ledger-fonts.el
@@ -1,6 +1,6 @@
;;; ledger-fonts.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
diff --git a/lisp/ledger-init.el b/lisp/ledger-init.el
index 49d74098..0141d2e7 100644
--- a/lisp/ledger-init.el
+++ b/lisp/ledger-init.el
@@ -1,6 +1,6 @@
;;; ledger-init.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -35,7 +35,7 @@
(defvar ledger-default-date-format "%Y/%m/%d")
(defun ledger-init-parse-initialization (buffer)
- "Parse the .ledgerrc file in BUFFER."
+ "Parse the .ledgerrc file in BUFFER."
(with-current-buffer buffer
(let (environment-alist)
(goto-char (point-min))
@@ -56,7 +56,7 @@
environment-alist)))
(defun ledger-init-load-init-file ()
- "Load and parse the .ledgerrc file."
+ "Load and parse the .ledgerrc file."
(interactive)
(let ((init-base-name (file-name-nondirectory ledger-init-file-name)))
(if (get-buffer init-base-name) ;; init file already loaded, parse it and leave it
diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el
index 4e2beff6..7e30c350 100644
--- a/lisp/ledger-mode.el
+++ b/lisp/ledger-mode.el
@@ -1,6 +1,6 @@
;;; ledger-mode.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -49,6 +49,7 @@
(require 'ledger-texi)
(require 'ledger-xact)
(require 'ledger-schedule)
+(require 'ledger-check)
;;; Code:
@@ -63,7 +64,7 @@
(defun ledger-mode-dump-variable (var)
"Format VAR for dump to buffer."
- (if var
+ (if var
(insert (format " %s: %S\n" (symbol-name var) (eval var)))))
(defun ledger-mode-dump-group (group)
@@ -78,7 +79,7 @@
(defun ledger-mode-dump-configuration ()
"Dump all customizations."
- (interactive)
+ (interactive)
(find-file "ledger-mode-dump")
(ledger-mode-dump-group 'ledger))
@@ -99,11 +100,11 @@
(defun ledger-read-account-with-prompt (prompt)
"Read an account from the minibuffer with PROMPT."
- (let ((context (ledger-context-at-point)))
+ (let ((context (ledger-context-at-point)))
(ledger-read-string-with-default prompt
- (if (eq (ledger-context-current-field context) 'account)
- (regexp-quote (ledger-context-field-value context 'account))
- nil))))
+ (if (eq (ledger-context-current-field context) 'account)
+ (regexp-quote (ledger-context-field-value context 'account))
+ nil))))
(defun ledger-read-date (prompt)
"Return user-supplied date after `PROMPT', defaults to today."
@@ -125,14 +126,19 @@
": "))
nil 'ledger-minibuffer-history default))
-(defun ledger-display-balance-at-point ()
+(defun ledger-display-balance-at-point (&optional arg)
"Display the cleared-or-pending balance.
-And calculate the target-delta of the account being reconciled."
- (interactive)
+And calculate the target-delta of the account being reconciled.
+
+With prefix argument \\[universal-argument] ask for the target commodity and convert
+the balance into that."
+ (interactive "P")
(let* ((account (ledger-read-account-with-prompt "Account balance to show"))
+ (target-commodity (when arg (ledger-read-commodity-with-prompt "Target commodity: ")))
(buffer (current-buffer))
(balance (with-temp-buffer
- (ledger-exec-ledger buffer (current-buffer) "cleared" account)
+ (apply 'ledger-exec-ledger buffer (current-buffer) "cleared" account
+ (when target-commodity (list "-X" target-commodity)))
(if (> (buffer-size) 0)
(buffer-substring-no-properties (point-min) (1- (point-max)))
(concat account " is empty.")))))
@@ -159,7 +165,7 @@ Can indent, complete or align depending on context."
(if (and (> (point) 1)
(looking-back "\\([^ \t]\\)" 1))
(ledger-pcomplete interactively)
- (ledger-post-align-postings))))
+ (ledger-post-align-postings (line-beginning-position) (line-end-position)))))
(defvar ledger-mode-abbrev-table)
@@ -222,7 +228,7 @@ With a prefix argument, remove the effective date."
(defun ledger-mode-remove-extra-lines ()
"Get rid of multiple empty lines."
- (goto-char (point-min))
+ (goto-char (point-min))
(while (re-search-forward "\n\n\\(\n\\)+" nil t)
(replace-match "\n\n")))
@@ -285,6 +291,7 @@ With a prefix argument, remove the effective date."
(define-key map [(meta ?p)] 'ledger-navigate-prev-xact-or-directive)
(define-key map [(meta ?n)] 'ledger-navigate-next-xact-or-directive)
+ (define-key map [(meta ?q)] 'ledger-post-align-dwim)
map)
"Keymap for `ledger-mode'.")
@@ -310,6 +317,7 @@ With a prefix argument, remove the effective date."
["Copy Trans at Point" ledger-copy-transaction-at-point]
"---"
["Clean-up Buffer" ledger-mode-clean-buffer]
+ ["Check Buffer" ledger-check-buffer ledger-works]
["Align Region" ledger-post-align-postings mark-active]
["Align Xact" ledger-post-align-xact]
["Sort Region" ledger-sort-region mark-active]
@@ -338,10 +346,10 @@ With a prefix argument, remove the effective date."
'(ledger-font-lock-keywords t t nil nil
(font-lock-fontify-region-function . ledger-fontify-buffer-part))))
- (set (make-local-variable 'pcomplete-parse-arguments-function) 'ledger-parse-arguments)
- (set (make-local-variable 'pcomplete-command-completion-function) 'ledger-complete-at-point)
+ (set (make-local-variable 'pcomplete-parse-arguments-function) 'ledger-parse-arguments)
+ (set (make-local-variable 'pcomplete-command-completion-function) 'ledger-complete-at-point)
(add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
- (add-hook 'after-save-hook 'ledger-report-redo)
+ (add-hook 'after-save-hook 'ledger-report-redo)
(add-hook 'post-command-hook 'ledger-highlight-xact-under-point nil t)
diff --git a/lisp/ledger-navigate.el b/lisp/ledger-navigate.el
index 904faf8c..7ac440f7 100644
--- a/lisp/ledger-navigate.el
+++ b/lisp/ledger-navigate.el
@@ -39,49 +39,49 @@
(goto-char (point-max))))
(defun ledger-navigate-start-xact-or-directive-p ()
- "Return t if at the beginning of an empty or all-whitespace line."
- (not (looking-at "[ \t]\\|\\(^$\\)")))
+ "Return t if at the beginning of an empty or all-whitespace line."
+ (not (looking-at "[ \t]\\|\\(^$\\)")))
(defun ledger-navigate-next-xact-or-directive ()
- "Move to the beginning of the next xact or directive."
- (interactive)
- (beginning-of-line)
- (if (ledger-navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact
- (progn
- (forward-line)
- (if (not (ledger-navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward
- (ledger-navigate-next-xact-or-directive)))
- (while (not (or (eobp) ; we didn't start off at the beginning of an xact
- (ledger-navigate-start-xact-or-directive-p)))
- (forward-line))))
+ "Move to the beginning of the next xact or directive."
+ (interactive)
+ (beginning-of-line)
+ (if (ledger-navigate-start-xact-or-directive-p) ; if we are the start of an xact, move forward to the next xact
+ (progn
+ (forward-line)
+ (if (not (ledger-navigate-start-xact-or-directive-p)) ; we have moved forward and are not at another xact, recurse forward
+ (ledger-navigate-next-xact-or-directive)))
+ (while (not (or (eobp) ; we didn't start off at the beginning of an xact
+ (ledger-navigate-start-xact-or-directive-p)))
+ (forward-line))))
(defun ledger-navigate-prev-xact-or-directive ()
"Move point to beginning of previous xact."
- (interactive)
- (let ((context (car (ledger-context-at-point))))
- (when (equal context 'acct-transaction)
- (ledger-navigate-beginning-of-xact))
- (beginning-of-line)
- (re-search-backward "^[[:graph:]]" nil t)))
+ (interactive)
+ (let ((context (car (ledger-context-at-point))))
+ (when (equal context 'acct-transaction)
+ (ledger-navigate-beginning-of-xact))
+ (beginning-of-line)
+ (re-search-backward "^[[:graph:]]" nil t)))
(defun ledger-navigate-beginning-of-xact ()
- "Move point to the beginning of the current xact."
- (interactive)
- ;; need to start at the beginning of a line incase we are in the first line of an xact already.
- (beginning-of-line)
- (let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)")))
- (unless (looking-at sreg)
- (re-search-backward sreg nil t)
- (beginning-of-line)))
- (point))
+ "Move point to the beginning of the current xact."
+ (interactive)
+ ;; need to start at the beginning of a line incase we are in the first line of an xact already.
+ (beginning-of-line)
+ (let ((sreg (concat "^\\(=\\|~\\|" ledger-iso-date-regexp "\\)")))
+ (unless (looking-at sreg)
+ (re-search-backward sreg nil t)
+ (beginning-of-line)))
+ (point))
(defun ledger-navigate-end-of-xact ()
"Move point to end of xact."
- (interactive)
+ (interactive)
(ledger-navigate-next-xact-or-directive)
- (re-search-backward ".$")
- (end-of-line)
- (point))
+ (re-search-backward ".$")
+ (end-of-line)
+ (point))
(defun ledger-navigate-to-line (line-number)
"Rapidly move point to line LINE-NUMBER."
@@ -95,61 +95,61 @@ Requires empty line separating xacts."
(save-excursion
(goto-char pos)
(list (ledger-navigate-beginning-of-xact)
- (ledger-navigate-end-of-xact))))
+ (ledger-navigate-end-of-xact))))
(defun ledger-navigate-find-directive-extents (pos)
"Return the extents of the directive at POS."
- (goto-char pos)
- (let ((begin (progn (beginning-of-line)
- (point)))
- (end (progn (end-of-line)
- (+ 1 (point)))))
- ;; handle block comments here
- (beginning-of-line)
- (if (looking-at " *;")
- (progn
- (while (and (looking-at " *;")
- (> (point) (point-min)))
- (forward-line -1))
- ;; We are either at the beginning of the buffer, or we found
- ;; a line outside the comment. If we are not at the
- ;; beginning of the buffer then we need to move forward a
- ;; line.
- (if (> (point) (point-min))
- (progn (forward-line 1)
- (beginning-of-line)))
- (setq begin (point))
- (goto-char pos)
- (beginning-of-line)
- (while (and (looking-at " *;")
- (< (point) (point-max)))
- (forward-line 1))
- (setq end (point))))
- (list begin end)))
+ (goto-char pos)
+ (let ((begin (progn (beginning-of-line)
+ (point)))
+ (end (progn (end-of-line)
+ (+ 1 (point)))))
+ ;; handle block comments here
+ (beginning-of-line)
+ (if (looking-at " *;")
+ (progn
+ (while (and (looking-at " *;")
+ (> (point) (point-min)))
+ (forward-line -1))
+ ;; We are either at the beginning of the buffer, or we found
+ ;; a line outside the comment. If we are not at the
+ ;; beginning of the buffer then we need to move forward a
+ ;; line.
+ (if (> (point) (point-min))
+ (progn (forward-line 1)
+ (beginning-of-line)))
+ (setq begin (point))
+ (goto-char pos)
+ (beginning-of-line)
+ (while (and (looking-at " *;")
+ (< (point) (point-max)))
+ (forward-line 1))
+ (setq end (point))))
+ (list begin end)))
(defun ledger-navigate-block-comment (pos)
"Move past the block comment at POS, and return its extents."
- (interactive "d")
- (goto-char pos)
- (let ((begin (progn (beginning-of-line)
- (point)))
- (end (progn (end-of-line)
- (point))))
- ;; handle block comments here
- (beginning-of-line)
- (if (looking-at " *;")
- (progn
- (while (and (looking-at " *;")
- (> (point) (point-min)))
- (forward-line -1))
- (setq begin (point))
- (goto-char pos)
- (beginning-of-line)
- (while (and (looking-at " *;")
- (< (point) (point-max)))
- (forward-line 1))
- (setq end (point))))
- (list begin end)))
+ (interactive "d")
+ (goto-char pos)
+ (let ((begin (progn (beginning-of-line)
+ (point)))
+ (end (progn (end-of-line)
+ (point))))
+ ;; handle block comments here
+ (beginning-of-line)
+ (if (looking-at " *;")
+ (progn
+ (while (and (looking-at " *;")
+ (> (point) (point-min)))
+ (forward-line -1))
+ (setq begin (point))
+ (goto-char pos)
+ (beginning-of-line)
+ (while (and (looking-at " *;")
+ (< (point) (point-max)))
+ (forward-line 1))
+ (setq end (point))))
+ (list begin end)))
(defun ledger-navigate-find-element-extents (pos)
@@ -158,7 +158,7 @@ Requires empty line separating xacts."
(save-excursion
(goto-char pos)
(beginning-of-line)
- (if (looking-at "[ =~0-9]")
+ (if (looking-at "[ =~0-9\\[]")
(ledger-navigate-find-xact-extents pos)
(ledger-navigate-find-directive-extents pos))))
diff --git a/lisp/ledger-occur.el b/lisp/ledger-occur.el
index 32a1bd96..0df2f1a9 100644
--- a/lisp/ledger-occur.el
+++ b/lisp/ledger-occur.el
@@ -1,6 +1,6 @@
;;; ledger-occur.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -120,7 +120,7 @@ currently active."
Argument OVL-BOUNDS contains bounds for the transactions to be left visible."
(let* ((beg (caar ovl-bounds))
(end (cadar ovl-bounds)))
- (ledger-occur-remove-overlays)
+ (ledger-occur-remove-overlays)
(ledger-occur-make-invisible-overlay (point-min) (1- beg))
(dolist (visible (cdr ovl-bounds))
(ledger-occur-make-visible-overlay beg end)
@@ -145,25 +145,25 @@ Argument OVL-BOUNDS contains bounds for the transactions to be left visible."
(while (not (eobp))
;; if something found
(when (setq endpoint (re-search-forward regex nil 'end))
- (setq bounds (ledger-navigate-find-element-extents endpoint))
- (push bounds lines)
- ;; move to the end of the xact, no need to search inside it more
+ (setq bounds (ledger-navigate-find-element-extents endpoint))
+ (push bounds lines)
+ ;; move to the end of the xact, no need to search inside it more
(goto-char (cadr bounds))))
(nreverse lines))))
(defun ledger-occur-compress-matches (buffer-matches)
"identify sequential xacts to reduce number of overlays required"
- (if buffer-matches
- (let ((points (list))
- (current-beginning (caar buffer-matches))
- (current-end (cadar buffer-matches)))
- (dolist (match (cdr buffer-matches))
- (if (< (- (car match) current-end) 2)
- (setq current-end (cadr match))
- (push (list current-beginning current-end) points)
- (setq current-beginning (car match))
- (setq current-end (cadr match))))
- (nreverse (push (list current-beginning current-end) points)))))
+ (if buffer-matches
+ (let ((points (list))
+ (current-beginning (caar buffer-matches))
+ (current-end (cadar buffer-matches)))
+ (dolist (match (cdr buffer-matches))
+ (if (< (- (car match) current-end) 2)
+ (setq current-end (cadr match))
+ (push (list current-beginning current-end) points)
+ (setq current-beginning (car match))
+ (setq current-end (cadr match))))
+ (nreverse (push (list current-beginning current-end) points)))))
(provide 'ledger-occur)
diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el
index 5665885b..973f2260 100644
--- a/lisp/ledger-post.el
+++ b/lisp/ledger-post.el
@@ -1,6 +1,6 @@
;;; ledger-post.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -43,6 +43,16 @@
:type 'integer
:group 'ledger-post)
+(defcustom ledger-post-amount-alignment-at :end
+ "Position at which the amount is ailgned.
+
+Can be :end to align on the last number of the amount (can be
+followed by unaligned commodity) or :decimal to align at the
+decimal separator."
+ :type '(radio (const :tag "align at the end of amount" :end)
+ (const :tag "align at the decimal separator" :decimal))
+ :group 'ledger-post)
+
(defcustom ledger-post-use-completion-engine :built-in
"Which completion engine to use, :iswitchb or :ido chose those engines.
:built-in uses built-in Ledger-mode completion"
@@ -81,8 +91,11 @@ point at beginning of the commodity."
(when (re-search-forward ledger-amount-regex end t)
(goto-char (match-beginning 0))
(skip-syntax-forward " ")
- (- (or (match-end 4)
- (match-end 3)) (point)))))
+ (cond
+ ((eq ledger-post-amount-alignment-at :end)
+ (- (or (match-end 4) (match-end 3)) (point)))
+ ((eq ledger-post-amount-alignment-at :decimal)
+ (- (match-end 3) (point)))))))
(defun ledger-next-account (&optional end)
"Move to the beginning of the posting, or status marker, limit to END.
@@ -97,28 +110,20 @@ at beginning of account"
(current-column))))
(defun ledger-post-align-xact (pos)
- "Align all the posting in the xact at POS."
- (interactive "d")
+ "Align all the posting in the xact at POS."
+ (interactive "d")
(let ((bounds (ledger-navigate-find-xact-extents pos)))
(ledger-post-align-postings (car bounds) (cadr bounds))))
-(defun ledger-post-align-postings (&optional beg end)
- "Align all accounts and amounts between BEG and END, or the current line."
- (interactive)
+(defun ledger-post-align-postings (beg end)
+ "Align all accounts and amounts between BEG and END, or the current region, or, if no region, the current line."
+ (interactive "r")
(save-excursion
- (if (or (not (mark))
- (not (use-region-p)))
- (set-mark (point)))
-
(let ((inhibit-modification-hooks t)
- (mark-first (< (mark) (point)))
acct-start-column acct-end-column acct-adjust amt-width amt-adjust
(lines-left 1))
- (unless beg (setq beg (if mark-first (mark) (point))))
- (unless end (setq end (if mark-first (mark) (point))))
-
;; Extend region to whole lines
(let ((start-marker (set-marker (make-marker) (save-excursion
(goto-char beg)
@@ -156,6 +161,19 @@ at beginning of account"
(setq lines-left (not (eobp)))))
(setq inhibit-modification-hooks nil))))
+(defun ledger-post-align-dwim ()
+ "Align all the posting of the current xact or the current region.
+
+If the point is in a comment, fill the comment paragraph as
+regular text."
+ (interactive)
+ (cond
+ ((nth 4 (syntax-ppss))
+ (call-interactively 'ledger-post-align-postings)
+ (fill-paragraph))
+ ((use-region-p) (call-interactively 'ledger-post-align-postings))
+ (t (call-interactively 'ledger-post-align-xact))))
+
(defun ledger-post-edit-amount ()
"Call 'calc-mode' and push the amount in the posting to the top of stack."
(interactive)
diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el
index b76700b0..7ac8f2c4 100644
--- a/lisp/ledger-reconcile.el
+++ b/lisp/ledger-reconcile.el
@@ -1,6 +1,6 @@
;;; ledger-reconcile.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -91,7 +91,7 @@ Default is ledger-default-date-format."
:group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-header "Reconciling account %s\n\n"
- "Default header string for the reconcile buffer.
+ "Default header string for the reconcile buffer.
If non-nil, the name of the account being reconciled will be substituted
into the '%s'. If nil, no header will be displayed."
@@ -99,7 +99,7 @@ If non-nil, the name of the account being reconciled will be substituted
:group 'ledger-reconcile)
(defcustom ledger-reconcile-buffer-line-format "%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n"
- "Format string for the ledger reconcile posting format.
+ "Format string for the ledger reconcile posting format.
Available fields are date, status, code, payee, account,
amount. The format for each field is %WIDTH(FIELD), WIDTH can be
preced by a minus sign which mean to left justify and pad the
@@ -132,18 +132,23 @@ Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e
:type 'boolean
:group 'ledger-reconcile)
+(defcustom ledger-reconcile-finish-force-quit nil
+ "If t, will force closing reconcile window after \\[ledger-reconcile-finish]."
+ :type 'boolean
+ :group 'ledger-reconcile)
+
;; s-functions below are copied from Magnars' s.el
;; prefix ledger-reconcile- is added to not conflict with s.el
(defun ledger-reconcile-s-pad-left (len padding s)
"If S is shorter than LEN, pad it with PADDING on the left."
(let ((extra (max 0 (- len (length s)))))
(concat (make-string extra (string-to-char padding))
- s)))
+ s)))
(defun ledger-reconcile-s-pad-right (len padding s)
"If S is shorter than LEN, pad it with PADDING on the right."
(let ((extra (max 0 (- len (length s)))))
(concat s
- (make-string extra (string-to-char padding)))))
+ (make-string extra (string-to-char padding)))))
(defun ledger-reconcile-s-left (len s)
"Return up to the LEN first chars of S."
(if (> (length s) len)
@@ -153,7 +158,7 @@ Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e
"Return up to the LEN last chars of S."
(let ((l (length s)))
(if (> l len)
- (substring s (- l len) l)
+ (substring s (- l len) l)
s)))
(defun ledger-reconcile-truncate-right (str len)
@@ -267,9 +272,9 @@ Return the number of uncleared xacts found."
(with-current-buffer recon-buf
(ledger-reconcile-refresh)
(set-buffer-modified-p nil))
- (when curbufwin
- (select-window curbufwin)
- (goto-char curpoint)))))
+ (when curbufwin
+ (select-window curbufwin)
+ (goto-char curpoint)))))
(defun ledger-reconcile-add ()
"Use ledger xact to add a new transaction."
@@ -295,40 +300,40 @@ Return the number of uncleared xacts found."
(defun ledger-reconcile-visit (&optional come-back)
"Recenter ledger buffer on transaction and COME-BACK if non-nil."
(interactive)
- (beginning-of-line)
- (let* ((where (get-text-property (1+ (point)) 'where))
- (target-buffer (if where
- (ledger-reconcile-get-buffer where)
- nil))
- (cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name))))
- (when target-buffer
- (switch-to-buffer-other-window target-buffer)
- (ledger-navigate-to-line (cdr where))
- (forward-char)
- (recenter)
- (ledger-highlight-xact-under-point)
- (forward-char -1)
- (when (and come-back cur-win)
- (select-window cur-win)
- (get-buffer ledger-recon-buffer-name)))))
+ (beginning-of-line)
+ (let* ((where (get-text-property (1+ (point)) 'where))
+ (target-buffer (if where
+ (ledger-reconcile-get-buffer where)
+ nil))
+ (cur-win (get-buffer-window (get-buffer ledger-recon-buffer-name))))
+ (when target-buffer
+ (switch-to-buffer-other-window target-buffer)
+ (ledger-navigate-to-line (cdr where))
+ (forward-char)
+ (recenter)
+ (ledger-highlight-xact-under-point)
+ (forward-char -1)
+ (when (and come-back cur-win)
+ (select-window cur-win)
+ (get-buffer ledger-recon-buffer-name)))))
(defun ledger-reconcile-save ()
"Save the ledger buffer."
(interactive)
- (let ((cur-buf (current-buffer))
- (cur-point (point)))
- (dolist (buf (cons ledger-buf ledger-bufs))
- (with-current-buffer buf
- (basic-save-buffer)))
- (switch-to-buffer-other-window cur-buf)
- (goto-char cur-point)))
+ (let ((cur-buf (current-buffer))
+ (cur-point (point)))
+ (dolist (buf (cons ledger-buf ledger-bufs))
+ (with-current-buffer buf
+ (basic-save-buffer)))
+ (switch-to-buffer-other-window cur-buf)
+ (goto-char cur-point)))
(defun ledger-reconcile-finish ()
"Mark all pending posting or transactions as cleared.
Depends on ledger-reconcile-clear-whole-transactions, save the buffers
-and exit reconcile mode"
+and exit reconcile mode if `ledger-reconcile-finish-force-quit'"
(interactive)
(save-excursion
(goto-char (point-min))
@@ -341,7 +346,8 @@ and exit reconcile mode"
(ledger-toggle-current 'cleared))))
(forward-line 1)))
(ledger-reconcile-save)
- (ledger-reconcile-quit))
+ (when ledger-reconcile-finish-force-quit
+ (ledger-reconcile-quit)))
(defun ledger-reconcile-quit ()
@@ -383,55 +389,55 @@ POSTING is used in `ledger-clear-whole-transactions' is nil."
(nth 0 posting))))) ;; return line-no of posting
(defun ledger-reconcile-compile-format-string (fstr)
- "Return a function that implements the format string in FSTR."
- (let (fields
- (start 0))
- (while (string-match "(\\(.*?\\))" fstr start)
- (setq fields (cons (intern (match-string 1 fstr)) fields))
- (setq start (match-end 0)))
- (setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields)))
- `(lambda (date code status payee account amount)
- ,fields)))
+ "Return a function that implements the format string in FSTR."
+ (let (fields
+ (start 0))
+ (while (string-match "(\\(.*?\\))" fstr start)
+ (setq fields (cons (intern (match-string 1 fstr)) fields))
+ (setq start (match-end 0)))
+ (setq fields (list* 'format (replace-regexp-in-string "(.*?)" "" fstr) (nreverse fields)))
+ `(lambda (date code status payee account amount)
+ ,fields)))
(defun ledger-reconcile-format-posting (beg where fmt date code status payee account amount)
- "Format posting for the reconcile buffer."
- (insert (funcall fmt date code status payee account amount))
-
- ; Set face depending on cleared status
- (if status
- (if (eq status 'pending)
- (set-text-properties beg (1- (point))
- (list 'face 'ledger-font-reconciler-pending-face
- 'where where))
- (set-text-properties beg (1- (point))
- (list 'face 'ledger-font-reconciler-cleared-face
- 'where where)))
- (set-text-properties beg (1- (point))
- (list 'face 'ledger-font-reconciler-uncleared-face
- 'where where))))
+ "Format posting for the reconcile buffer."
+ (insert (funcall fmt date code status payee account amount))
+
+ ; Set face depending on cleared status
+ (if status
+ (if (eq status 'pending)
+ (set-text-properties beg (1- (point))
+ (list 'face 'ledger-font-reconciler-pending-face
+ 'where where))
+ (set-text-properties beg (1- (point))
+ (list 'face 'ledger-font-reconciler-cleared-face
+ 'where where)))
+ (set-text-properties beg (1- (point))
+ (list 'face 'ledger-font-reconciler-uncleared-face
+ 'where where))))
(defun ledger-reconcile-format-xact (xact fmt)
- "Format XACT using FMT."
- (let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist))
- ledger-default-date-format)))
- (dolist (posting (nthcdr 5 xact))
- (let ((beg (point))
- (where (ledger-marker-where-xact-is xact posting)))
- (ledger-reconcile-format-posting beg
- where
- fmt
- (format-time-string date-format (nth 2 xact)) ; date
- (if (nth 3 xact) (nth 3 xact) "") ; code
- (nth 3 posting) ; status
+ "Format XACT using FMT."
+ (let ((date-format (or (cdr (assoc "date-format" ledger-environment-alist))
+ ledger-default-date-format)))
+ (dolist (posting (nthcdr 5 xact))
+ (let ((beg (point))
+ (where (ledger-marker-where-xact-is xact posting)))
+ (ledger-reconcile-format-posting beg
+ where
+ fmt
+ (format-time-string date-format (nth 2 xact)) ; date
+ (if (nth 3 xact) (nth 3 xact) "") ; code
+ (nth 3 posting) ; status
(ledger-reconcile-truncate-right
- (nth 4 xact) ; payee
- ledger-reconcile-buffer-payee-max-chars)
+ (nth 4 xact) ; payee
+ ledger-reconcile-buffer-payee-max-chars)
(ledger-reconcile-truncate-left
- (nth 1 posting) ; account
- ledger-reconcile-buffer-account-max-chars)
- (nth 2 posting)))))) ; amount
+ (nth 1 posting) ; account
+ ledger-reconcile-buffer-account-max-chars)
+ (nth 2 posting)))))) ; amount
(defun ledger-do-reconcile (&optional sort)
"SORT the uncleared transactions in the account and display them in the *Reconcile* buffer.
@@ -451,10 +457,11 @@ Return a count of the uncleared transactions."
(unless (eobp)
(if (looking-at "(")
(read (current-buffer))))))) ;current-buffer is the *temp* created above
- (fmt (ledger-reconcile-compile-format-string ledger-reconcile-buffer-line-format)))
+ (fmt (ledger-reconcile-compile-format-string ledger-reconcile-buffer-line-format)))
(if (and ledger-success (> (length xacts) 0))
(progn
- (insert (format ledger-reconcile-buffer-header account))
+ (if ledger-reconcile-buffer-header
+ (insert (format ledger-reconcile-buffer-header account)))
(dolist (xact xacts)
(ledger-reconcile-format-xact xact fmt))
(goto-char (point-max))
@@ -507,11 +514,11 @@ moved and recentered. If they aren't strange things happen."
(pop-to-buffer rbuf)))
(defun ledger-reconcile-check-valid-account (account)
- "Check to see if ACCOUNT exists in the ledger file"
- (if (> (length account) 0)
- (save-excursion
- (goto-char (point-min))
- (search-forward account nil t))))
+ "Check to see if ACCOUNT exists in the ledger file"
+ (if (> (length account) 0)
+ (save-excursion
+ (goto-char (point-min))
+ (search-forward account nil t))))
(defun ledger-reconcile ()
"Start reconciling, prompt for account."
@@ -520,38 +527,38 @@ moved and recentered. If they aren't strange things happen."
(buf (current-buffer))
(rbuf (get-buffer ledger-recon-buffer-name)))
- (when (ledger-reconcile-check-valid-account account)
- (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t)
-
- (if rbuf ;; *Reconcile* already exists
- (with-current-buffer rbuf
- (set 'ledger-acct account) ;; already buffer local
- (when (not (eq buf rbuf))
- ;; called from some other ledger-mode buffer
- (ledger-reconcile-quit-cleanup)
- (setq ledger-buf buf)) ;; should already be buffer-local
-
- (unless (get-buffer-window rbuf)
- (ledger-reconcile-open-windows buf rbuf)))
-
- ;; no recon-buffer, starting from scratch.
-
- (with-current-buffer (setq rbuf
- (get-buffer-create ledger-recon-buffer-name))
- (ledger-reconcile-open-windows buf rbuf)
- (ledger-reconcile-mode)
- (make-local-variable 'ledger-target)
- (set (make-local-variable 'ledger-buf) buf)
- (set (make-local-variable 'ledger-acct) account)))
-
- ;; Narrow the ledger buffer
- (with-current-buffer rbuf
- (save-excursion
- (if ledger-narrow-on-reconcile
- (ledger-occur account)))
- (if (> (ledger-reconcile-refresh) 0)
- (ledger-reconcile-change-target))
- (ledger-display-balance)))))
+ (when (ledger-reconcile-check-valid-account account)
+ (add-hook 'after-save-hook 'ledger-reconcile-refresh-after-save nil t)
+
+ (if rbuf ;; *Reconcile* already exists
+ (with-current-buffer rbuf
+ (set 'ledger-acct account) ;; already buffer local
+ (when (not (eq buf rbuf))
+ ;; called from some other ledger-mode buffer
+ (ledger-reconcile-quit-cleanup)
+ (setq ledger-buf buf)) ;; should already be buffer-local
+
+ (unless (get-buffer-window rbuf)
+ (ledger-reconcile-open-windows buf rbuf)))
+
+ ;; no recon-buffer, starting from scratch.
+
+ (with-current-buffer (setq rbuf
+ (get-buffer-create ledger-recon-buffer-name))
+ (ledger-reconcile-open-windows buf rbuf)
+ (ledger-reconcile-mode)
+ (make-local-variable 'ledger-target)
+ (set (make-local-variable 'ledger-buf) buf)
+ (set (make-local-variable 'ledger-acct) account)))
+
+ ;; Narrow the ledger buffer
+ (with-current-buffer rbuf
+ (save-excursion
+ (if ledger-narrow-on-reconcile
+ (ledger-occur account)))
+ (if (> (ledger-reconcile-refresh) 0)
+ (ledger-reconcile-change-target))
+ (ledger-display-balance)))))
(defvar ledger-reconcile-mode-abbrev-table)
@@ -562,7 +569,7 @@ moved and recentered. If they aren't strange things happen."
(defmacro ledger-reconcile-change-sort-key-and-refresh (sort-by)
"Set the sort-key to SORT-BY."
- `(lambda ()
+ `(lambda ()
(interactive)
(setq ledger-reconcile-sort-key ,sort-by)
diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
index 41231845..83c59feb 100644
--- a/lisp/ledger-regex.el
+++ b/lisp/ledger-regex.el
@@ -1,6 +1,6 @@
;;; ledger-regex.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -27,8 +27,14 @@
(defconst ledger-amount-regex
(concat "\\( \\|\t\\| \t\\)[ \t]*-?"
"\\([A-Z$€£₹_(]+ *\\)?"
- "\\(-?[0-9,\\.]+?\\)"
- "\\(.[0-9)]+\\)?"
+ ;; We either match just a number after the commodity with no
+ ;; decimal or thousand separators or a number with thousand
+ ;; separators. If we have a decimal part starting with `,'
+ ;; or `.', because the match is non-greedy, it must leave at
+ ;; least one of those symbols for the following capture
+ ;; group, which then finishes the decimal part.
+ "\\(-?\\(?:[0-9]+\\|[0-9,.]+?\\)\\)"
+ "\\([,.][0-9)]+\\)?"
"\\( *[[:word:]€£₹_\"]+\\)?"
"\\([ \t]*[@={]@?[^\n;]+?\\)?"
"\\([ \t]+;.+?\\|[ \t]*\\)?$"))
@@ -108,8 +114,8 @@
defs
(list
`(defmacro
- ,(intern (concat "ledger-regex-" (symbol-name name)))
- (&optional string)
+ ,(intern (concat "ledger-regex-" (symbol-name name)))
+ (&optional string)
,(format "Return the match string for the %s" name)
(match-string
,(intern (concat "ledger-regex-" (symbol-name name)
@@ -153,9 +159,9 @@
defs
(list
`(defmacro
- ,(intern (concat "ledger-regex-" (symbol-name name)
- "-" (symbol-name var)))
- (&optional string)
+ ,(intern (concat "ledger-regex-" (symbol-name name)
+ "-" (symbol-name var)))
+ (&optional string)
,(format "Return the sub-group match for the %s %s."
name var)
(match-string
@@ -238,6 +244,22 @@
code
(note end-note))
+(ledger-define-regexp recurring-line
+ (macroexpand
+ `(rx (and line-start
+ (regexp "\\[.+/.+/.+\\]")
+ (? (and (+ blank) (regexp ,ledger-state-regexp)))
+ (? (and (+ blank) (regexp ,ledger-code-regexp)))
+ (+ blank) (+? nonl)
+ (? (regexp ,ledger-end-note-regexp))
+ line-end)))
+ "Match a transaction's first line (and optional notes)."
+ (actual-date full-date actual)
+ (effective-date full-date effective)
+ state
+ code
+ (note end-note))
+
(ledger-define-regexp account
(rx (group (and (not (any blank ?\[ ?\( ?: ?\;)) (*? nonl))))
"")
@@ -333,8 +355,8 @@
"\\)"))
(defconst ledger-xact-start-regex
- (concat "^" ledger-iso-date-regexp ;; subexp 1
- "\\(=" ledger-iso-date-regexp "\\)?"
+ (concat "^" ledger-iso-date-regexp ;; subexp 1
+ "\\(=" ledger-iso-date-regexp "\\)?"
))
(defconst ledger-xact-after-date-regex
@@ -345,17 +367,17 @@
))
(defconst ledger-posting-regex
- (concat "^[ \t]+ ?" ;; initial white space
- "\\([*!]\\)? ?" ;; state, subexpr 1
- "\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2
- "\\([^;\n]*\\)" ;; amount, subexpr 4
- "\\(.*\\)" ;; comment, subexpr 5
- ))
+ (concat "^[ \t]+ ?" ;; initial white space
+ "\\([*!]\\)? ?" ;; state, subexpr 1
+ "\\([[:print:]]+\\([ \t][ \t]\\)\\)" ;; account, subexpr 2
+ "\\([^;\n]*\\)" ;; amount, subexpr 4
+ "\\(.*\\)" ;; comment, subexpr 5
+ ))
(defconst ledger-directive-start-regex
- "[=~;#%|\\*[A-Za-z]")
+ "[=~;#%|\\*[A-Za-z]")
(provide 'ledger-regex)
diff --git a/lisp/ledger-report.el b/lisp/ledger-report.el
index 4131b92a..83c287eb 100644
--- a/lisp/ledger-report.el
+++ b/lisp/ledger-report.el
@@ -1,6 +1,6 @@
;;; ledger-report.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -62,7 +62,7 @@ specifier."
'(("ledger-file" . ledger-report-ledger-file-format-specifier)
("payee" . ledger-report-payee-format-specifier)
("account" . ledger-report-account-format-specifier)
- ("tagname" . ledger-report-tagname-format-specifier)
+ ("tagname" . ledger-report-tagname-format-specifier)
("tagvalue" . ledger-report-tagvalue-format-specifier))
"An alist mapping ledger report format specifiers to implementing functions.
@@ -72,14 +72,14 @@ text that should replace the format specifier."
:group 'ledger-report)
(defcustom ledger-report-auto-refresh t
- "If t then automatically rerun the report when the ledger buffer is saved."
- :type 'boolean
- :group 'ledger-report)
+ "If t then automatically rerun the report when the ledger buffer is saved."
+ :type 'boolean
+ :group 'ledger-report)
(defcustom ledger-report-auto-refresh-sticky-cursor nil
- "If t then try to place cursor at same relative position as it was before auto-refresh."
- :type 'boolean
- :group 'ledger-report)
+ "If t then try to place cursor at same relative position as it was before auto-refresh."
+ :type 'boolean
+ :group 'ledger-report)
(defvar ledger-report-buffer-name "*Ledger Report*")
@@ -96,10 +96,10 @@ text that should replace the format specifier."
(defvar ledger-report-cursor-line-number nil)
(defun ledger-report-reverse-report ()
- "Reverse the order of the report."
- (interactive)
- (ledger-report-reverse-lines)
- (setq ledger-report-is-reversed (not ledger-report-is-reversed)))
+ "Reverse the order of the report."
+ (interactive)
+ (ledger-report-reverse-lines)
+ (setq ledger-report-is-reversed (not ledger-report-is-reversed)))
(defun ledger-report-reverse-lines ()
(goto-char (point-min))
@@ -208,7 +208,7 @@ used to generate the buffer, navigating the buffer, etc."
(set (make-local-variable 'ledger-buf) buf)
(set (make-local-variable 'ledger-report-name) report-name)
(set (make-local-variable 'ledger-original-window-cfg) wcfg)
- (set (make-local-variable 'ledger-report-is-reversed) nil)
+ (set (make-local-variable 'ledger-report-is-reversed) nil)
(ledger-do-report (ledger-report-cmd report-name edit))
(shrink-window-if-larger-than-buffer)
(set-buffer-modified-p nil)
@@ -392,30 +392,30 @@ Optional EDIT the command."
(defun ledger-report-redo ()
"Redo the report in the current ledger report buffer."
(interactive)
- (let ((cur-buf (current-buffer)))
- (if (and ledger-report-auto-refresh
- (or (string= (format-mode-line 'mode-name) "Ledger")
- (string= (format-mode-line 'mode-name) "Ledger-Report"))
- (get-buffer ledger-report-buffer-name))
- (progn
-
- (pop-to-buffer (get-buffer ledger-report-buffer-name))
- (shrink-window-if-larger-than-buffer)
- (setq buffer-read-only nil)
- (setq ledger-report-cursor-line-number (line-number-at-pos))
- (erase-buffer)
- (ledger-do-report ledger-report-cmd)
- (setq buffer-read-only nil)
- (if ledger-report-is-reversed (ledger-report-reverse-lines))
- (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5)))
- (pop-to-buffer cur-buf)))))
+ (let ((cur-buf (current-buffer)))
+ (if (and ledger-report-auto-refresh
+ (or (string= (format-mode-line 'mode-name) "Ledger")
+ (string= (format-mode-line 'mode-name) "Ledger-Report"))
+ (get-buffer ledger-report-buffer-name))
+ (progn
+
+ (pop-to-buffer (get-buffer ledger-report-buffer-name))
+ (shrink-window-if-larger-than-buffer)
+ (setq buffer-read-only nil)
+ (setq ledger-report-cursor-line-number (line-number-at-pos))
+ (erase-buffer)
+ (ledger-do-report ledger-report-cmd)
+ (setq buffer-read-only nil)
+ (if ledger-report-is-reversed (ledger-report-reverse-lines))
+ (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5)))
+ (pop-to-buffer cur-buf)))))
(defun ledger-report-quit ()
- "Quit the ledger report buffer."
- (interactive)
- (ledger-report-goto)
- (set-window-configuration ledger-original-window-cfg)
- (kill-buffer (get-buffer ledger-report-buffer-name)))
+ "Quit the ledger report buffer."
+ (interactive)
+ (ledger-report-goto)
+ (set-window-configuration ledger-original-window-cfg)
+ (kill-buffer (get-buffer ledger-report-buffer-name)))
(defun ledger-report-edit-reports ()
"Edit the defined ledger reports."
@@ -423,10 +423,10 @@ Optional EDIT the command."
(customize-variable 'ledger-reports))
(defun ledger-report-edit-report ()
- "Edit the current report command in the mini buffer and re-run the report."
- (interactive)
- (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd))
- (ledger-report-redo))
+ "Edit the current report command in the mini buffer and re-run the report."
+ (interactive)
+ (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd))
+ (ledger-report-redo))
(defun ledger-report-read-new-name ()
"Read the name for a new report from the minibuffer."
diff --git a/lisp/ledger-schedule.el b/lisp/ledger-schedule.el
index 39237ffb..ae08ad36 100644
--- a/lisp/ledger-schedule.el
+++ b/lisp/ledger-schedule.el
@@ -62,21 +62,21 @@
:group 'ledger-schedule)
(defcustom ledger-schedule-week-days '(("Mo" 1)
- ("Tu" 2)
- ("We" 3)
- ("Th" 4)
- ("Fr" 5)
- ("Sa" 6)
- ("Su" 7))
- "List of weekday abbreviations. There must be exactly seven
+ ("Tu" 2)
+ ("We" 3)
+ ("Th" 4)
+ ("Fr" 5)
+ ("Sa" 6)
+ ("Su" 7))
+ "List of weekday abbreviations. There must be exactly seven
entries each with a two character abbreviation for a day and the
number of that day in the week. "
- :type '(alist :value-type (group integer))
- :group 'ledger-schedule)
+ :type '(alist :value-type (group integer))
+ :group 'ledger-schedule)
(defsubst between (val low high)
- "Return TRUE if VAL > LOW and < HIGH."
- (and (>= val low) (<= val high)))
+ "Return TRUE if VAL > LOW and < HIGH."
+ (and (>= val low) (<= val high)))
(defun ledger-schedule-days-in-month (month year)
"Return number of days in the MONTH, MONTH is from 1 to 12.
@@ -88,8 +88,8 @@ If YEAR is nil, assume it is not a leap year"
(error "Month out of range, MONTH=%S" month)))
(defun ledger-schedule-encode-day-of-week (day-string)
- "Return the numerical day of week corresponding to DAY-STRING."
- (cadr (assoc day-string ledger-schedule-week-days)))
+ "Return the numerical day of week corresponding to DAY-STRING."
+ (cadr (assoc day-string ledger-schedule-week-days)))
;; Macros to handle date expressions
@@ -175,10 +175,10 @@ the transaction should be logged for that day."
xact-list)))
(defun ledger-schedule-read-descriptor-tree (descriptor-string)
- "Read DESCRIPTOR-STRING and return a form that evaluates dates."
- (ledger-schedule-transform-auto-tree
- (split-string
- (substring descriptor-string 1 (string-match "]" descriptor-string)) " ")))
+ "Read DESCRIPTOR-STRING and return a form that evaluates dates."
+ (ledger-schedule-transform-auto-tree
+ (split-string
+ (substring descriptor-string 1 (string-match "]" descriptor-string)) " ")))
(defun ledger-schedule-transform-auto-tree (descriptor-string-list)
"Take DESCRIPTOR-STRING-LIST, and return a string with a lambda function of date."
@@ -204,84 +204,86 @@ the transaction should be logged for that day."
(defun ledger-schedule-compile-constraints (descriptor-string)
"Return a list with the year, month and day fields split."
(let ((fields (split-string descriptor-string "[/\\-]" t)))
- (if (string-match "[A-Za-z]" descriptor-string)
- (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields))
- (list 'and
- (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields))
- (ledger-schedule-constrain-year (nth 0 fields) (nth 1 fields) (nth 2 fields))
- (ledger-schedule-constrain-month (nth 0 fields) (nth 1 fields) (nth 2 fields))))))
+ (list 'and
+ (ledger-schedule-constrain-day (nth 0 fields) (nth 1 fields) (nth 2 fields))
+ (ledger-schedule-constrain-year (nth 0 fields) (nth 1 fields) (nth 2 fields))
+ (ledger-schedule-constrain-month (nth 0 fields) (nth 1 fields) (nth 2 fields)))))
(defun ledger-schedule-constrain-year (year-desc month-desc day-desc)
- "Return a form that constrains the year.
+ "Return a form that constrains the year.
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor."
- (cond ((string= year-desc "*") t)
- ((/= 0 (string-to-number year-desc))
- `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ","))))
- (t
- (error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc))))
+ (cond
+ ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the year
+ ((string= year-desc "*") t)
+ ((/= 0 (string-to-number year-desc))
+ `(memq (nth 5 (decode-time date)) ',(mapcar 'string-to-number (split-string year-desc ","))))
+ (t
+ (error "Improperly specified year constraint: %s %s %s" year-desc month-desc day-desc))))
(defun ledger-schedule-constrain-month (year-desc month-desc day-desc)
- "Return a form that constrains the month.
+ "Return a form that constrains the month.
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor."
- (cond ((string= month-desc "*")
- t) ;; always match
- ((string= month-desc "E") ;; Even
- `(evenp (nth 4 (decode-time date))))
- ((string= month-desc "O") ;; Odd
- `(oddp (nth 4 (decode-time date))))
- ((/= 0 (string-to-number month-desc)) ;; Starts with number
- `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ","))))
- (t
- (error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc))))
+ (cond
+ ((string-match "[A-Za-z]" day-desc) t) ; there is an advanced day descriptor which overrides the month
+ ((string= month-desc "*")
+ t) ;; always match
+ ((string= month-desc "E") ;; Even
+ `(evenp (nth 4 (decode-time date))))
+ ((string= month-desc "O") ;; Odd
+ `(oddp (nth 4 (decode-time date))))
+ ((/= 0 (string-to-number month-desc)) ;; Starts with number
+ `(memq (nth 4 (decode-time date)) ',(mapcar 'string-to-number (split-string month-desc ","))))
+ (t
+ (error "Improperly specified month constraint: %s %s %s" year-desc month-desc day-desc))))
(defun ledger-schedule-constrain-day (year-desc month-desc day-desc)
- "Return a form that constrains the day.
+ "Return a form that constrains the day.
YEAR-DESC, MONT-DESC, and DAY-DESC are the string portions of the
date descriptor."
- (cond ((string= day-desc "*")
- t)
- ((string-match "[A-Za-z]" day-desc) ;; There is something other than digits and commas
- (ledger-schedule-parse-complex-date year-desc month-desc day-desc))
- ((/= 0 (string-to-number day-desc))
- `(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ","))))
- (t
- (error "Improperly specified day constraint: %s %s %s" year-desc month-desc day-desc))))
+ (cond ((string= day-desc "*")
+ t)
+ ((string-match "[A-Za-z]" day-desc) ;; There is something other than digits and commas
+ (ledger-schedule-parse-complex-date year-desc month-desc day-desc))
+ ((/= 0 (string-to-number day-desc))
+ `(memq (nth 3 (decode-time date)) ',(mapcar 'string-to-number (split-string day-desc ","))))
+ (t
+ (error "Improperly specified day constraint: %s %s %s" year-desc month-desc day-desc))))
(defun ledger-schedule-parse-complex-date (year-desc month-desc day-desc)
- "Parse day descriptors that have repeats."
- (let ((years (mapcar 'string-to-number (split-string year-desc ",")))
- (months (mapcar 'string-to-number (split-string month-desc ",")))
- (day-parts (split-string day-desc "+"))
- (every-nth (string-match "+" day-desc)))
- (if every-nth
- (let ((base-day (string-to-number (car day-parts)))
- (increment (string-to-number (substring (cadr day-parts) 0
- (string-match "[A-Za-z]" (cadr day-parts)))))
- (day-of-week (ledger-schedule-encode-day-of-week
- (substring (cadr day-parts) (string-match "[A-Za-z]" (cadr day-parts))))))
- (ledger-schedule-constrain-every-count-day day-of-week increment (encode-time 0 0 0 base-day (car months) (car years))))
- (let ((count (string-to-number (substring (car day-parts) 0 1)))
- (day-of-week (ledger-schedule-encode-day-of-week
- (substring (car day-parts) (string-match "[A-Za-z]" (car day-parts))))))
- (ledger-schedule-constrain-day-in-month count day-of-week)))))
+ "Parse day descriptors that have repeats."
+ (let ((years (mapcar 'string-to-number (split-string year-desc ",")))
+ (months (mapcar 'string-to-number (split-string month-desc ",")))
+ (day-parts (split-string day-desc "+"))
+ (every-nth (string-match "+" day-desc)))
+ (if every-nth
+ (let ((base-day (string-to-number (car day-parts)))
+ (increment (string-to-number (substring (cadr day-parts) 0
+ (string-match "[A-Za-z]" (cadr day-parts)))))
+ (day-of-week (ledger-schedule-encode-day-of-week
+ (substring (cadr day-parts) (string-match "[A-Za-z]" (cadr day-parts))))))
+ (ledger-schedule-constrain-every-count-day day-of-week increment (encode-time 0 0 0 base-day (car months) (car years))))
+ (let ((count (string-to-number (substring (car day-parts) 0 1)))
+ (day-of-week (ledger-schedule-encode-day-of-week
+ (substring (car day-parts) (string-match "[A-Za-z]" (car day-parts))))))
+ (ledger-schedule-constrain-day-in-month count day-of-week)))))
(defun ledger-schedule-list-upcoming-xacts (candidate-items early horizon)
- "Search CANDIDATE-ITEMS for xacts that occur within the period today - EARLY to today + HORIZON."
- (let ((start-date (time-subtract (current-time) (days-to-time early)))
- test-date items)
- (loop for day from 0 to (+ early horizon) by 1 do
- (setq test-date (time-add start-date (days-to-time day)))
- (dolist (candidate candidate-items items)
- (if (funcall (car candidate) test-date)
- (setq items (append items (list (list test-date (cadr candidate))))))))
- items))
+ "Search CANDIDATE-ITEMS for xacts that occur within the period today - EARLY to today + HORIZON."
+ (let ((start-date (time-subtract (current-time) (days-to-time early)))
+ test-date items)
+ (loop for day from 0 to (+ early horizon) by 1 do
+ (setq test-date (time-add start-date (days-to-time day)))
+ (dolist (candidate candidate-items items)
+ (if (funcall (car candidate) test-date)
+ (setq items (append items (list (list test-date (cadr candidate))))))))
+ items))
(defun ledger-schedule-create-auto-buffer (candidate-items early horizon ledger-buf)
"Format CANDIDATE-ITEMS for display."
@@ -292,7 +294,7 @@ date descriptor."
(with-current-buffer schedule-buf
(erase-buffer)
(dolist (candidate candidates)
- (insert (format-time-string date-format (car candidate) ) " " (cadr candidate) "\n"))
+ (insert (format-time-string date-format (car candidate) ) " " (cadr candidate) "\n"))
(ledger-mode))
(length candidates)))
@@ -313,15 +315,15 @@ Use a prefix arg to change the default value"
(read-number "Look forward: " ledger-schedule-look-forward))
(list ledger-schedule-file ledger-schedule-look-backward ledger-schedule-look-forward)))
(if (and file
- (file-exists-p file))
- (progn
- (ledger-schedule-create-auto-buffer
- (ledger-schedule-scan-transactions file)
- look-backward
- look-forward
- (current-buffer))
- (pop-to-buffer ledger-schedule-buffer-name))
- (error "Could not find ledger schedule file at %s" file)))
+ (file-exists-p file))
+ (progn
+ (ledger-schedule-create-auto-buffer
+ (ledger-schedule-scan-transactions file)
+ look-backward
+ look-forward
+ (current-buffer))
+ (pop-to-buffer ledger-schedule-buffer-name))
+ (error "Could not find ledger schedule file at %s" file)))
(provide 'ledger-schedule)
diff --git a/lisp/ledger-sort.el b/lisp/ledger-sort.el
index a8f0a0bd..6ed82830 100644
--- a/lisp/ledger-sort.el
+++ b/lisp/ledger-sort.el
@@ -1,6 +1,6 @@
;;; ledger-xact.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -66,7 +66,7 @@
(defun ledger-sort-region (beg end)
"Sort the region from BEG to END in chronological order."
(interactive "r") ;; load beg and end from point and mark
- ;; automagically
+ ;; automagically
(let ((new-beg beg)
(new-end end)
point-delta
@@ -79,14 +79,14 @@
(save-excursion
(save-restriction
(goto-char beg)
- ;; make sure point is at the beginning of a xact
+ ;; make sure point is at the beginning of a xact
(ledger-navigate-next-xact)
(unless (looking-at ledger-payee-any-status-regex)
(ledger-navigate-next-xact))
(setq new-beg (point))
(goto-char end)
(ledger-navigate-next-xact)
- ;; make sure end of region is at the beginning of next record
+ ;; make sure end of region is at the beginning of next record
;; after the region
(setq new-end (point))
(narrow-to-region new-beg new-end)
diff --git a/lisp/ledger-state.el b/lisp/ledger-state.el
index 1bc5974d..561df095 100644
--- a/lisp/ledger-state.el
+++ b/lisp/ledger-state.el
@@ -1,6 +1,6 @@
;;; ledger-state.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -116,8 +116,8 @@ dropped."
(when (not (eq (ledger-state-from-char (char-after)) 'comment))
(insert (ledger-char-from-state cur-status) " ")
(if (and (search-forward " " (line-end-position) t)
- (looking-at " "))
- (delete-char 2)))
+ (looking-at " "))
+ (delete-char 2)))
(forward-line))
(setq new-status nil)))
diff --git a/lisp/ledger-test.el b/lisp/ledger-test.el
index da120f63..26811bb3 100644
--- a/lisp/ledger-test.el
+++ b/lisp/ledger-test.el
@@ -1,6 +1,6 @@
;;; ledger-test.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
diff --git a/lisp/ledger-texi.el b/lisp/ledger-texi.el
index 75a018b8..5bf8d9a2 100644
--- a/lisp/ledger-texi.el
+++ b/lisp/ledger-texi.el
@@ -1,6 +1,6 @@
;;; ledger-texi.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el
index 52b89583..f3721e9e 100644
--- a/lisp/ledger-xact.el
+++ b/lisp/ledger-xact.el
@@ -1,6 +1,6 @@
;;; ledger-xact.el --- Helper code for use with the "ledger" command-line tool
-;; Copyright (C) 2003-2015 John Wiegley (johnw AT gnu DOT org)
+;; Copyright (C) 2003-2016 John Wiegley (johnw AT gnu DOT org)
;; This file is not part of GNU Emacs.
@@ -52,20 +52,25 @@
(defvar ledger-xact-highlight-overlay (list))
(make-variable-buffer-local 'ledger-xact-highlight-overlay)
+(defun ledger-highlight-make-overlay ()
+ (let ((ovl (make-overlay 1 1)))
+ (overlay-put ovl 'face 'ledger-font-xact-highlight-face)
+ (overlay-put ovl 'priority '(nil . 99))
+ ovl))
+
(defun ledger-highlight-xact-under-point ()
"Move the highlight overlay to the current transaction."
- (if ledger-highlight-xact-under-point
- (let ((exts (ledger-navigate-find-element-extents (point)))
- (ovl ledger-xact-highlight-overlay))
- (if (not ledger-xact-highlight-overlay)
- (setq ovl
- (setq ledger-xact-highlight-overlay
- (make-overlay (car exts)
- (cadr exts)
- (current-buffer) t nil)))
- (move-overlay ovl (car exts) (cadr exts)))
- (overlay-put ovl 'face 'ledger-font-xact-highlight-face)
- (overlay-put ovl 'priority '(nil . 99)))))
+ (when ledger-highlight-xact-under-point
+ (unless ledger-xact-highlight-overlay
+ (setq ledger-xact-highlight-overlay (ledger-highlight-make-overlay)))
+ (let ((exts (ledger-navigate-find-element-extents (point))))
+ (let ((b (car exts))
+ (e (cadr exts))
+ (p (point)))
+ (if (and (> (- e b) 1) ; not an empty line
+ (<= p e) (>= p b)) ; point is within the boundaries
+ (move-overlay ledger-xact-highlight-overlay b (+ 1 e))
+ (move-overlay ledger-xact-highlight-overlay 1 1))))))
(defun ledger-xact-payee ()
"Return the payee of the transaction containing point or nil."
@@ -97,9 +102,8 @@ MOMENT is an encoded date"
(when (and (eobp) last-xact-start)
(let ((end (cadr (ledger-navigate-find-xact-extents last-xact-start))))
(goto-char end)
- (if (eobp)
- (insert "\n")
- (forward-line))))))
+ (insert "\n")
+ (forward-line)))))
(defun ledger-xact-iterate-transactions (callback)
"Iterate through each transaction call CALLBACK for each."
@@ -194,8 +198,8 @@ correct chronological place in the buffer."
(goto-char (point-min))
(if (looking-at "Error: ")
(error (concat "Error in ledger-add-transaction: " (buffer-string)))
- (ledger-post-align-postings (point-min) (point-max))
- (buffer-string)))
+ (ledger-post-align-postings (point-min) (point-max))
+ (buffer-string)))
"\n"))
(progn
(insert (car args) " \n\n")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dc8b60fc..65e58edb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,7 +28,6 @@ set(LEDGER_SOURCES
textual.cc
temps.cc
journal.cc
- archive.cc
account.cc
xact.cc
post.cc
@@ -80,7 +79,6 @@ set(LEDGER_INCLUDES
account.h
amount.h
annotate.h
- archive.h
balance.h
chain.h
commodity.h
@@ -154,7 +152,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-Wno-unused-parameter
-Wno-c++98-compat
-fno-limit-debug-info)
-
+
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
set(_pch_filename "${_header_filename}.pch")
@@ -190,7 +188,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args}
DEPENDS ${_header_filename})
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
-
+
elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+")
set(GXX_WARNING_FLAGS
-pedantic
@@ -212,7 +210,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-Wno-strict-aliasing)
add_definitions(${GXX_WARNING_FLAGS})
-
+
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
set(_gch_filename "${_header_filename}.gch")
@@ -249,7 +247,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args}
DEPENDS ${_header_filename})
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
-
+
else()
macro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
@@ -275,6 +273,9 @@ if (BUILD_LIBRARY)
add_executable(ledger main.cc global.cc)
target_link_libraries(ledger libledger)
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
+ target_link_libraries(ledger ${PYTHON_LIBRARIES})
+ endif()
install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${LEDGER_INCLUDES}
@@ -296,7 +297,7 @@ print(s.get_python_lib(True, prefix=''))"
if (PYTHON_SITE_PACKAGES)
if (WIN32 AND NOT CYGWIN)
set(_ledger_python_module_name "ledger.pyd")
- elseif(CMAKE_HOST_APPLE)
+ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(_ledger_python_module_name "ledger.so")
else()
set(_ledger_python_module_name "ledger${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/src/account.cc b/src/account.cc
index 358aa09a..2a48eaf5 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/account.h b/src/account.h
index 76e839eb..4a4e859d 100644
--- a/src/account.h
+++ b/src/account.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -261,11 +261,7 @@ public:
mutable optional<xdata_t> xdata_;
bool has_xdata() const {
-#if BOOST_VERSION >= 105600
- return xdata_ != NULL;
-#else
- return xdata_;
-#endif
+ return static_cast<bool>(xdata_);
}
void clear_xdata();
xdata_t& xdata() {
@@ -289,26 +285,6 @@ public:
}
bool children_with_xdata() const;
std::size_t children_with_flags(xdata_t::flags_t flags) const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<supports_flags<> >(*this);
- ar & boost::serialization::base_object<scope_t>(*this);
- ar & parent;
- ar & name;
- ar & note;
- ar & depth;
- ar & accounts;
- ar & posts;
- ar & _fullname;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
std::ostream& operator<<(std::ostream& out, const account_t& account);
diff --git a/src/amount.cc b/src/amount.cc
index 6ddcdb4f..52ccbc88 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -93,20 +93,6 @@ struct amount_t::bigint_t : public supports_flags<>
}
return true;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */)
- {
- ar & boost::serialization::base_object<supports_flags<> >(*this);
- ar & val;
- ar & prec;
- ar & refc;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
bool amount_t::is_initialized = false;
@@ -1331,69 +1317,4 @@ void put_amount(property_tree::ptree& st, const amount_t& amt,
st.put("quantity", amt.quantity_string());
}
-#if HAVE_BOOST_SERIALIZATION
-
-template<class Archive>
-void amount_t::serialize(Archive& ar, const unsigned int /* version */)
-{
- ar & is_initialized;
- ar & quantity;
- ar & commodity_;
-}
-
-#endif // HAVE_BOOST_SERIALIZATION
-
} // namespace ledger
-
-#if HAVE_BOOST_SERIALIZATION
-namespace boost {
-namespace serialization {
-
-template <class Archive>
-void serialize(Archive& ar, MP_INT& mpz, const unsigned int /* version */)
-{
- ar & mpz._mp_alloc;
- ar & mpz._mp_size;
- ar & mpz._mp_d;
-}
-
-template <class Archive>
-void serialize(Archive& ar, MP_RAT& mpq, const unsigned int /* version */)
-{
- ar & mpq._mp_num;
- ar & mpq._mp_den;
-}
-
-template <class Archive>
-void serialize(Archive& ar, long unsigned int& integer,
- const unsigned int /* version */)
-{
- ar & make_binary_object(&integer, sizeof(long unsigned int));
-}
-
-} // namespace serialization
-} // namespace boost
-
-BOOST_CLASS_EXPORT(ledger::annotated_commodity_t)
-
-template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- MP_INT&, const unsigned int);
-template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- MP_INT&, const unsigned int);
-template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- MP_RAT&, const unsigned int);
-template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- MP_RAT&, const unsigned int);
-template void boost::serialization::serialize(boost::archive::binary_iarchive&,
- long unsigned int&,
- const unsigned int);
-template void boost::serialization::serialize(boost::archive::binary_oarchive&,
- long unsigned int&,
- const unsigned int);
-
-template void ledger::amount_t::serialize(boost::archive::binary_iarchive&,
- const unsigned int);
-template void ledger::amount_t::serialize(boost::archive::binary_oarchive&,
- const unsigned int);
-
-#endif // HAVE_BOOST_SERIALIZATION
diff --git a/src/amount.h b/src/amount.h
index ea5cadd6..8885a69d 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -743,16 +743,6 @@ public:
bool valid() const;
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */);
-#endif // HAVE_BOOST_SERIALIZATION
-
/*@}*/
};
diff --git a/src/annotate.cc b/src/annotate.cc
index 7c54edef..e953f441 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/annotate.h b/src/annotate.h
index c0fbcd3d..0ea2561b 100644
--- a/src/annotate.h
+++ b/src/annotate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -107,21 +107,6 @@ struct annotation_t : public supports_flags<>,
assert(*this);
return true;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<supports_flags<> >(*this);
- ar & price;
- ar & date;
- ar & tag;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
void put_annotation(property_tree::ptree& pt, const annotation_t& details);
@@ -162,21 +147,6 @@ struct keep_details_t
return keep_price || keep_date || keep_tag;
}
bool keep_any(const commodity_t& comm) const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & keep_price;
- ar & keep_date;
- ar & keep_tag;
- ar & only_actuals;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline std::ostream& operator<<(std::ostream& out,
@@ -250,24 +220,6 @@ public:
virtual void write_annotations(std::ostream& out,
bool no_computed_annotations = false) const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- explicit annotated_commodity_t() : ptr(NULL) {
- TRACE_CTOR(annotated_commodity_t, "");
- }
-
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<commodity_t>(*this);
- ar & ptr;
- ar & details;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline annotated_commodity_t&
diff --git a/src/archive.cc b/src/archive.cc
deleted file mode 100644
index 9ae04e85..00000000
--- a/src/archive.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 2003-2015, John Wiegley. 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 New Artisans LLC 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.
- */
-
-#include <system.hh>
-
-#if HAVE_BOOST_SERIALIZATION
-
-#include "archive.h"
-#include "amount.h"
-#include "commodity.h"
-#include "pool.h"
-#include "scope.h"
-#include "account.h"
-#include "post.h"
-#include "xact.h"
-
-#define LEDGER_MAGIC 0x4c454447
-#define ARCHIVE_VERSION 0x03000006
-
-//BOOST_IS_ABSTRACT(ledger::scope_t)
-BOOST_CLASS_EXPORT(ledger::scope_t)
-BOOST_CLASS_EXPORT(ledger::child_scope_t)
-BOOST_CLASS_EXPORT(ledger::symbol_scope_t)
-BOOST_CLASS_EXPORT(ledger::call_scope_t)
-BOOST_CLASS_EXPORT(ledger::account_t)
-BOOST_CLASS_EXPORT(ledger::item_t)
-BOOST_CLASS_EXPORT(ledger::post_t)
-BOOST_CLASS_EXPORT(ledger::xact_base_t)
-BOOST_CLASS_EXPORT(ledger::xact_t)
-BOOST_CLASS_EXPORT(ledger::auto_xact_t)
-BOOST_CLASS_EXPORT(ledger::period_xact_t)
-
-template void ledger::journal_t::serialize(boost::archive::binary_oarchive&,
- const unsigned int);
-template void ledger::journal_t::serialize(boost::archive::binary_iarchive&,
- const unsigned int);
-namespace ledger {
-
-namespace {
- bool read_header_bits(std::istream& in) {
- uint32_t bytes;
-
- assert(sizeof(uint32_t) == 4);
- in.read(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
- if (bytes != LEDGER_MAGIC) {
- DEBUG("archive.journal", "Magic bytes not present");
- return false;
- }
-
- in.read(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
- if (bytes != ARCHIVE_VERSION) {
- DEBUG("archive.journal", "Archive version mismatch");
- return false;
- }
-
- return true;
- }
-
- void write_header_bits(std::ostream& out) {
- uint32_t bytes;
-
- assert(sizeof(uint32_t) == 4);
- bytes = LEDGER_MAGIC;
- out.write(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
-
- bytes = ARCHIVE_VERSION;
- out.write(reinterpret_cast<char *>(&bytes), sizeof(uint32_t));
- }
-}
-
-bool archive_t::read_header()
-{
- uintmax_t size = file_size(file);
- if (size < 8)
- return false;
-
- // Open the stream, read the version number and the list of sources
- ifstream stream(file, std::ios::binary);
- if (! read_header_bits(stream))
- return false;
-
- boost::archive::binary_iarchive iarchive(stream);
-
- DEBUG("archive.journal", "Reading header from archive");
- iarchive >> *this;
-
- DEBUG("archive.journal",
- "Version number: " << std::hex << ARCHIVE_VERSION << std::dec);
- DEBUG("archive.journal", "Number of sources: " << sources.size());
-
-#if DEBUG_ON
- foreach (const journal_t::fileinfo_t& i, sources)
- DEBUG("archive.journal", "Loaded source: " << *i.filename);
-#endif
-
- return true;
-}
-
-bool archive_t::should_load(const std::list<path>& data_files)
-{
- std::size_t found = 0;
-
- DEBUG("archive.journal", "Should the archive be loaded?");
-
- if (! exists(file)) {
- DEBUG("archive.journal", "No, it does not exist");
- return false;
- }
-
- if (! read_header()) {
- DEBUG("archive.journal", "No, header failed to read");
- return false;
- }
-
- if (data_files.empty()) {
- DEBUG("archive.journal", "No, there were no data files!");
- return false;
- }
-
- if (sources.empty()) {
- DEBUG("archive.journal", "No, there were no sources!");
- return false;
- }
-
- if (data_files.size() != sources.size()) {
- DEBUG("archive.journal", "No, number of sources doesn't match: "
- << data_files.size() << " != " << sources.size());
- return false;
- }
-
- foreach (const path& p, data_files) {
- DEBUG("archive.journal", "Scanning for data file: " << p);
-
- if (! exists(p)) {
- DEBUG("archive.journal", "No, an input source no longer exists: " << p);
- return false;
- }
-
- foreach (const journal_t::fileinfo_t& i, sources) {
- assert(! i.from_stream);
- assert(i.filename);
-
- DEBUG("archive.journal", "Comparing against source file: " << *i.filename);
-
- if (*i.filename == p) {
- if (! exists(*i.filename)) {
- DEBUG("archive.journal",
- "No, a referent source no longer exists: " << *i.filename);
- return false;
- }
-
- if (i.modtime != posix_time::from_time_t(last_write_time(p))) {
- DEBUG("archive.journal", "No, a source's modtime has changed: " << p);
- return false;
- }
-
- if (i.size != file_size(p)) {
- DEBUG("archive.journal", "No, a source's size has changed: " << p);
- return false;
- }
-
- found++;
- }
- }
- }
-
- if (found != data_files.size()) {
- DEBUG("archive.journal", "No, not every source's name matched");
- return false;
- }
-
- DEBUG("archive.journal", "Yes, it should be loaded!");
- return true;
-}
-
-bool archive_t::should_save(journal_t& journal)
-{
- std::list<path> data_files;
-
- DEBUG("archive.journal", "Should the archive be saved?");
-
- if (journal.was_loaded) {
- DEBUG("archive.journal", "No, it's one we loaded before");
- return false;
- }
-
- if (journal.sources.empty()) {
- DEBUG("archive.journal", "No, there were no sources!");
- return false;
- }
-
- foreach (const journal_t::fileinfo_t& i, journal.sources) {
- if (i.from_stream) {
- DEBUG("archive.journal", "No, one source was from a stream");
- return false;
- }
-
- if (! exists(*i.filename)) {
- DEBUG("archive.journal",
- "No, a source no longer exists: " << *i.filename);
- return false;
- }
-
- data_files.push_back(*i.filename);
- }
-
- if (should_load(data_files)) {
- DEBUG("archive.journal", "No, because it's still loadable");
- return false;
- }
-
- DEBUG("archive.journal", "Yes, it should be saved!");
- return true;
-}
-
-void archive_t::save(journal_t& journal)
-{
- INFO_START(archive, "Saved journal file cache");
-
- ofstream stream(file, std::ios::binary);
-
- write_header_bits(stream);
- sources = journal.sources;
-
-#if DEBUG_ON
- foreach (const journal_t::fileinfo_t& i, sources)
- DEBUG("archive.journal", "Saving source: " << *i.filename);
-#endif
-
- boost::archive::binary_oarchive oa(stream);
-
- DEBUG("archive.journal", "Creating archive with version "
- << std::hex << ARCHIVE_VERSION << std::dec);
- oa << *this;
-
- DEBUG("archive.journal",
- "Archiving journal with " << sources.size() << " sources");
- oa << journal;
-
- INFO_FINISH(archive);
-}
-
-bool archive_t::load(journal_t& journal)
-{
- INFO_START(archive, "Read cached journal file");
-
- ifstream stream(file, std::ios::binary);
- if (! read_header_bits(stream))
- return false;
-
- boost::archive::binary_iarchive iarchive(stream);
-
- // Skip past the archive header, it was already read in before
- archive_t temp;
- iarchive >> temp;
-
- iarchive >> journal;
- journal.was_loaded = true;
-
- INFO_FINISH(archive);
-
- return true;
-}
-
-} // namespace ledger
-
-#endif // HAVE_BOOST_SERIALIZATION
diff --git a/src/archive.h b/src/archive.h
deleted file mode 100644
index 485f9606..00000000
--- a/src/archive.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2003-2015, John Wiegley. 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 New Artisans LLC 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.
- */
-
-/**
- * @defgroup report Reporting
- */
-
-/**
- * @file archive.h
- * @author John Wiegley
- *
- * @ingroup report
- */
-#ifndef _ARCHIVE_H
-#define _ARCHIVE_H
-
-#include "journal.h"
-
-namespace ledger {
-
-class archive_t
-{
- path file;
-
- std::list<journal_t::fileinfo_t> sources;
-
-public:
- archive_t() {
- TRACE_CTOR(archive_t, "");
- }
- archive_t(const path& _file) : file(_file) {
- TRACE_CTOR(archive_t, "const path&");
- }
- archive_t(const archive_t& ar) : file(ar.file) {
- TRACE_CTOR(archive_t, "copy");
- }
- ~archive_t() {
- TRACE_DTOR(archive_t);
- }
-
- bool read_header();
-
- bool should_load(const std::list<path>& data_files);
- bool should_save(journal_t& journal);
-
- void save(journal_t& journal);
- bool load(journal_t& journal);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & sources;
- }
-#endif // HAVE_BOOST_SERIALIZATION
-};
-
-} // namespace ledger
-
-#endif // _ARCHIVE_H
diff --git a/src/balance.cc b/src/balance.cc
index 36eab7d4..ca14c7ff 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/balance.h b/src/balance.h
index 752bb4d6..d68fccc8 100644
--- a/src/balance.h
+++ b/src/balance.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -594,18 +594,6 @@ public:
}
return true;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & amounts;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline std::ostream& operator<<(std::ostream& out, const balance_t& bal) {
diff --git a/src/chain.cc b/src/chain.cc
index 42f474c4..94afc0fa 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/chain.h b/src/chain.h
index 224bed21..16fb4400 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/commodity.cc b/src/commodity.cc
index 398245fb..1475f52e 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/commodity.h b/src/commodity.h
index 3d1ddf04..1741bfaf 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -68,19 +68,6 @@ struct price_point_t
bool operator==(const price_point_t& other) const {
return when == other.when && price == other.price;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & when;
- ar & price;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class commodity_t
@@ -138,28 +125,6 @@ protected:
virtual ~base_t() {
TRACE_DTOR(commodity_t::base_t);
}
-
-#if HAVE_BOOST_SERIALIZATION
- private:
- base_t() {
- TRACE_CTOR(base_t, "");
- }
-
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
- ar & symbol;
- ar & precision;
- ar & name;
- ar & note;
- ar & smaller;
- ar & larger;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
shared_ptr<base_t> base;
@@ -315,32 +280,6 @@ public:
struct compare_by_commodity {
bool operator()(const amount_t * left, const amount_t * right) const;
};
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- supports_flags<uint_least16_t> temp_flags;
-
-protected:
- explicit commodity_t()
- : delegates_flags<uint_least16_t>(temp_flags), parent_(NULL),
- annotated(false) {
- TRACE_CTOR(commodity_t, "");
- }
-
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<delegates_flags<uint_least16_t> >(*this);
- ar & base;
- ar & parent_;
- ar & qualified_symbol;
- ar & annotated;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) {
diff --git a/src/compare.cc b/src/compare.cc
index db169cfc..547acc18 100644
--- a/src/compare.cc
+++ b/src/compare.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/compare.h b/src/compare.h
index 554e84aa..baee6075 100644
--- a/src/compare.h
+++ b/src/compare.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/context.h b/src/context.h
index e787f335..61797dc4 100644
--- a/src/context.h
+++ b/src/context.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/convert.cc b/src/convert.cc
index a4454c14..d0a0dc39 100644
--- a/src/convert.cc
+++ b/src/convert.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/convert.h b/src/convert.h
index 020dfea2..cb6bcd71 100644
--- a/src/convert.h
+++ b/src/convert.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/csv.cc b/src/csv.cc
index b0a54f4e..85e41057 100644
--- a/src/csv.cc
+++ b/src/csv.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/csv.h b/src/csv.h
index cda15ea3..a294a865 100644
--- a/src/csv.h
+++ b/src/csv.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/draft.cc b/src/draft.cc
index 78e53ccd..f7557373 100644
--- a/src/draft.cc
+++ b/src/draft.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/draft.h b/src/draft.h
index 7ba40640..f4c24c26 100644
--- a/src/draft.h
+++ b/src/draft.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/emacs.cc b/src/emacs.cc
index dc16c002..9f2626a3 100644
--- a/src/emacs.cc
+++ b/src/emacs.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/emacs.h b/src/emacs.h
index fef7a882..52b7bd37 100644
--- a/src/emacs.h
+++ b/src/emacs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -72,7 +72,7 @@ public:
out.flush();
}
virtual void operator()(post_t& post);
- virtual string escape_string(string raw);
+ virtual string escape_string(string raw);
};
} // namespace ledger
diff --git a/src/error.cc b/src/error.cc
index 90697c5f..4b3565a3 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/error.h b/src/error.h
index 31fa76a3..73a0e395 100644
--- a/src/error.h
+++ b/src/error.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/expr.cc b/src/expr.cc
index e38d794f..bc877c1a 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/expr.h b/src/expr.h
index 384cc661..bbe4bf74 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -106,19 +106,6 @@ public:
virtual string context_to_str() const;
virtual void print(std::ostream& out) const;
virtual void dump(std::ostream& out) const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<base_type>(*this);
- ar & ptr;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
/**
diff --git a/src/exprbase.h b/src/exprbase.h
index b88fcd7d..6d13c429 100644
--- a/src/exprbase.h
+++ b/src/exprbase.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -231,21 +231,6 @@ public:
out << std::endl << _("--- Result value ---") << std::endl;
return calc();
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & context;
- ar & str;
- if (Archive::is_loading::value)
- compiled = false;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
template <typename ResultType>
diff --git a/src/filters.cc b/src/filters.cc
index 2f97a0e5..1d7832ca 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -707,7 +707,7 @@ namespace {
insert_prices_in_map(price_map_t& _all_prices)
: all_prices(_all_prices) {}
- void operator()(datetime_t& date, const amount_t& price) {
+ void operator()(const datetime_t& date, const amount_t& price) {
all_prices.insert(price_map_t::value_type(date, price));
}
};
diff --git a/src/filters.h b/src/filters.h
index 1404b38e..4aa8af7a 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/flags.h b/src/flags.h
index f3593517..e6b66470 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -90,17 +90,6 @@ public:
void drop_flags(const flags_t arg) {
_flags = static_cast<T>(static_cast<U>(_flags) & static_cast<U>(~arg));
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */)
- {
- ar & _flags;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
template <typename T = boost::uint_least8_t, typename U = T>
@@ -193,17 +182,6 @@ public:
void drop_flags(const flags_t arg) {
_flags.drop_flags(arg);
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */)
- {
- ar & _flags;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
#endif // _FLAGS_H
diff --git a/src/format.cc b/src/format.cc
index 2887a387..b6f0d5ae 100644
--- a/src/format.cc
+++ b/src/format.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/format.h b/src/format.h
index 6ac4075e..8856905d 100644
--- a/src/format.h
+++ b/src/format.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/generate.cc b/src/generate.cc
index 6503f414..c1ecb007 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/generate.h b/src/generate.h
index b17116fa..d4f13070 100644
--- a/src/generate.h
+++ b/src/generate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/global.cc b/src/global.cc
index c144e3be..6edc69ca 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -110,7 +110,7 @@ global_scope_t::~global_scope_t()
void global_scope_t::parse_init(path init_file)
{
TRACE_START(init, 1, "Read initialization file");
-
+
parse_context_stack_t parsing_context;
parsing_context.push(init_file);
parsing_context.get_current().journal = session().journal.get();
@@ -122,13 +122,13 @@ void global_scope_t::parse_init(path init_file)
throw_(parse_error, _f("Transactions found in initialization file '%1%'")
% init_file);
}
-
+
TRACE_FINISH(init, 1);
}
void global_scope_t::read_init()
{
- // if specified on the command line init_file_ is filled in
+ // if specified on the command line init_file_ is filled in
// global_scope_t::handle_debug_options. If it was specified on the command line
// fail if the file doesn't exist. If no init file was specified
// on the command-line then try the default values, but don't fail if there
@@ -144,6 +144,9 @@ void global_scope_t::read_init()
} else {
if (const char * home_var = std::getenv("HOME")) {
init_file = (path(home_var) / ".ledgerrc");
+ if (! exists(init_file)) {
+ init_file = ("./.ledgerrc");
+ }
} else {
init_file = ("./.ledgerrc");
}
@@ -316,9 +319,6 @@ option_t<global_scope_t> * global_scope_t::lookup_option(const char * p)
case 'd':
OPT(debug_);
break;
- case 'f':
- OPT(full_help);
- break;
case 'h':
OPT_(help);
break;
@@ -502,7 +502,7 @@ void handle_debug_options(int argc, char * argv[])
}
else if (i + 1 < argc && std::strcmp(argv[i], "--debug") == 0) {
#if DEBUG_ON
- _log_level = LOG_DEBUG;
+ _log_level = LOG_DEBUG;
_log_category = argv[i + 1];
i++;
#endif
diff --git a/src/global.h b/src/global.h
index 454fc64e..1a4a3076 100644
--- a/src/global.h
+++ b/src/global.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -129,7 +129,7 @@ public:
out << '-' << Ledger_VERSION_DATE;
out << _(", the command-line accounting tool");
out <<
- _("\n\nCopyright (c) 2003-2015, John Wiegley. All rights reserved.\n\n\
+ _("\n\nCopyright (c) 2003-2016, John Wiegley. All rights reserved.\n\n\
This program is made available under the terms of the BSD Public License.\n\
See LICENSE file included with the distribution for details and disclaimer.");
out << std::endl;
@@ -147,7 +147,6 @@ See LICENSE file included with the distribution for details and disclaimer.");
void visit_man_page() const;
- OPTION_(global_scope_t, full_help, DO() { parent->visit_man_page(); }); // -H
OPTION_(global_scope_t, help, DO() { parent->visit_man_page(); }); // -h
OPTION__
diff --git a/src/history.cc b/src/history.cc
index e3c459f3..25d42b06 100644
--- a/src/history.cc
+++ b/src/history.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -475,7 +475,7 @@ commodity_history_impl_t::find_price(const commodity_t& source,
#endif
vertex_descriptor v = tv;
- for (vertex_descriptor u = predecessorMap[v];
+ for (vertex_descriptor u = predecessorMap[v];
u != v;
v = u, u = predecessorMap[v])
{
diff --git a/src/history.h b/src/history.h
index dd776383..37efb068 100644
--- a/src/history.h
+++ b/src/history.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/item.cc b/src/item.cc
index 9effcd23..0402f467 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/item.h b/src/item.h
index 458cb378..ca16d87b 100644
--- a/src/item.h
+++ b/src/item.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -78,23 +78,6 @@ struct position_t
}
return *this;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & pathname;
- ar & beg_pos;
- ar & beg_line;
- ar & end_pos;
- ar & end_line;
- ar & sequence;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class item_t : public supports_flags<uint_least16_t>, public scope_t
@@ -191,11 +174,7 @@ public:
static bool use_aux_date;
virtual bool has_date() const {
-#if BOOST_VERSION >= 105600
- return _date != NULL;
-#else
- return _date;
-#endif
+ return static_cast<bool>(_date);
}
virtual date_t date() const {
@@ -226,25 +205,6 @@ public:
const string& name);
bool valid() const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
- ar & boost::serialization::base_object<scope_t>(*this);
- ar & _state;
- ar & _date;
- ar & _date_aux;
- ar & note;
- ar & pos;
- ar & metadata;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
value_t get_comment(item_t& item);
diff --git a/src/iterators.cc b/src/iterators.cc
index 21bec5d9..88233ea1 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -96,7 +96,7 @@ namespace {
TRACE_DTOR(create_price_xact);
}
- void operator()(datetime_t& date, const amount_t& price) {
+ void operator()(const datetime_t& date, const amount_t& price) {
xact_t * xact;
string symbol = price.commodity().symbol();
diff --git a/src/iterators.h b/src/iterators.h
index 86eb86ca..a3f535b1 100644
--- a/src/iterators.h
+++ b/src/iterators.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/journal.cc b/src/journal.cc
index ae545477..36fe5fc0 100644
--- a/src/journal.cc
+++ b/src/journal.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/journal.h b/src/journal.h
index 613b2b96..76e1735d 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -100,21 +100,6 @@ public:
~fileinfo_t() throw() {
TRACE_DTOR(journal_t::fileinfo_t);
}
-
-#if HAVE_BOOST_SERIALIZATION
- private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & filename;
- ar & size;
- ar & modtime;
- ar & from_stream;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
account_t * master;
@@ -215,26 +200,6 @@ public:
private:
std::size_t read_textual(parse_context_stack_t& context);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & master;
- ar & bucket;
- ar & xacts;
- ar & auto_xacts;
- ar & period_xacts;
- ar & sources;
- ar & payee_mappings;
- ar & account_mappings;
- ar & checksum_map;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
} // namespace ledger
diff --git a/src/lookup.cc b/src/lookup.cc
index 6dbeb502..11b7db61 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -54,7 +54,7 @@ namespace {
struct usage_sorter {
bool operator()(const account_use_pair& left,
const account_use_pair& right) const {
- return left.second > right.second;
+ return left.second < right.second;
}
};
}
diff --git a/src/lookup.h b/src/lookup.h
index fc7063ec..2c4e6575 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/main.cc b/src/main.cc
index c26a280a..3a36280a 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/mask.cc b/src/mask.cc
index 29b53781..c6868dde 100644
--- a/src/mask.cc
+++ b/src/mask.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/mask.h b/src/mask.h
index 2b579768..f416611f 100644
--- a/src/mask.h
+++ b/src/mask.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -124,25 +124,6 @@ public:
}
return true;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- string temp;
- if (Archive::is_loading::value) {
- ar & temp;
- *this = temp;
- } else {
- temp = str();
- ar & temp;
- }
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline std::ostream& operator<<(std::ostream& out, const mask_t& mask) {
diff --git a/src/op.cc b/src/op.cc
index ff707a14..97437ce3 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/op.h b/src/op.h
index c45ffb08..937b321d 100644
--- a/src/op.h
+++ b/src/op.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -314,33 +314,6 @@ private:
value_t calc_call(scope_t& scope, ptr_op_t * locus, const int depth);
value_t calc_cons(scope_t& scope, ptr_op_t * locus, const int depth);
value_t calc_seq(scope_t& scope, ptr_op_t * locus, const int depth);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & refc;
- ar & kind;
- if (Archive::is_loading::value || ! left_ || ! left_->is_function()) {
- ar & left_;
- } else {
- ptr_op_t temp_op;
- ar & temp_op;
- }
- if (Archive::is_loading::value || is_value() || is_ident() ||
- (kind > UNARY_OPERATORS &&
- (! has_right() || ! right()->is_function()))) {
- ar & data;
- } else {
- variant<ptr_op_t, value_t, string, expr_t::func_t> temp_data;
- ar & temp_data;
- }
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
inline expr_t::ptr_op_t
diff --git a/src/option.cc b/src/option.cc
index 8c003e08..7c5c5e07 100644
--- a/src/option.cc
+++ b/src/option.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/option.h b/src/option.h
index 4646121d..b06c1754 100644
--- a/src/option.h
+++ b/src/option.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/org.cc b/src/org.cc
index 7d11c36a..4d572415 100644
--- a/src/org.cc
+++ b/src/org.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/org.h b/src/org.h
index 40b7685d..da28c772 100644
--- a/src/org.h
+++ b/src/org.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/output.cc b/src/output.cc
index ffd144e1..77083450 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -291,7 +291,7 @@ void report_accounts::flush()
void report_accounts::operator()(post_t& post)
{
- std::map<account_t *, std::size_t>::iterator i = accounts.find(post.account);
+ accounts_report_map::iterator i = accounts.find(post.account);
if (i == accounts.end())
accounts.insert(accounts_pair(post.account, 1));
else
@@ -362,7 +362,7 @@ void report_commodities::operator()(post_t& post)
amount_t temp(post.amount.strip_annotations(report.what_to_keep()));
commodity_t& comm(temp.commodity());
- std::map<commodity_t *, std::size_t>::iterator i = commodities.find(&comm);
+ commodities_report_map::iterator i = commodities.find(&comm);
if (i == commodities.end())
commodities.insert(commodities_pair(&comm, 1));
else
@@ -371,7 +371,7 @@ void report_commodities::operator()(post_t& post)
if (comm.has_annotation()) {
annotated_commodity_t& ann_comm(as_annotated_commodity(comm));
if (ann_comm.details.price) {
- std::map<commodity_t *, std::size_t>::iterator ii =
+ commodities_report_map::iterator ii =
commodities.find(&ann_comm.details.price->commodity());
if (ii == commodities.end())
commodities.insert
diff --git a/src/output.h b/src/output.h
index ec7ec6c2..e8c45337 100644
--- a/src/output.h
+++ b/src/output.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -142,9 +142,10 @@ class report_accounts : public item_handler<post_t>
protected:
report_t& report;
- std::map<account_t *, std::size_t, account_compare> accounts;
-
typedef std::map<account_t *, std::size_t>::value_type accounts_pair;
+ typedef std::map<account_t *, std::size_t, account_compare> accounts_report_map;
+
+ accounts_report_map accounts;
public:
report_accounts(report_t& _report) : report(_report) {
@@ -221,9 +222,10 @@ class report_commodities : public item_handler<post_t>
protected:
report_t& report;
- std::map<commodity_t *, std::size_t, commodity_compare> commodities;
-
typedef std::map<commodity_t *, std::size_t>::value_type commodities_pair;
+ typedef std::map<commodity_t *, std::size_t, commodity_compare> commodities_report_map;
+
+ commodities_report_map commodities;
public:
report_commodities(report_t& _report) : report(_report) {
diff --git a/src/parser.cc b/src/parser.cc
index 8044338f..53b03a0c 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/parser.h b/src/parser.h
index e46fc719..913179a1 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -118,7 +118,7 @@ public:
ptr_op_t parse(std::istream& in,
const parse_flags_t& flags = PARSE_DEFAULT,
- const optional<string>& original_string = NULL);
+ const optional<string>& original_string = boost::none);
};
} // namespace ledger
diff --git a/src/pool.cc b/src/pool.cc
index 95c0f49d..dff02df8 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pool.h b/src/pool.h
index d24df78c..945fd083 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -78,8 +78,8 @@ public:
commodity_t * default_commodity;
bool keep_base; // --base
- optional<path> price_db; // --price-db=
- long quote_leeway; // --leeway=
+ optional<path> price_db; // --price-db=
+ long quote_leeway; // --leeway=
bool get_quotes; // --download
function<optional<price_point_t>
@@ -132,26 +132,6 @@ public:
parse_price_expression(const std::string& str,
const bool add_prices = true,
const optional<datetime_t>& moment = none);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & current_pool;
- ar & commodities;
- ar & annotated_commodities;
- ar & null_commodity;
- ar & default_commodity;
- ar & keep_base;
- ar & price_db;
- ar & quote_leeway;
- ar & get_quotes;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
} // namespace ledger
diff --git a/src/post.cc b/src/post.cc
index 269e2e6c..8d2693c7 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/post.h b/src/post.h
index 1e5fc569..d7d8f7c4 100644
--- a/src/post.h
+++ b/src/post.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -205,11 +205,7 @@ public:
mutable optional<xdata_t> xdata_;
bool has_xdata() const {
-#if BOOST_VERSION >= 105600
- return xdata_ != NULL;
-#else
- return xdata_;
-#endif
+ return static_cast<bool>(xdata_);
}
void clear_xdata() {
xdata_ = none;
@@ -255,24 +251,6 @@ public:
}
}
};
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<item_t>(*this);
- ar & xact;
- ar & account;
- ar & amount;
- ar & amount_expr;
- ar & cost;
- ar & assigned_amount;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class journal_t;
diff --git a/src/precmd.cc b/src/precmd.cc
index 2da6ba8e..af8c5ee0 100644
--- a/src/precmd.cc
+++ b/src/precmd.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/precmd.h b/src/precmd.h
index bf2732d7..365cc1ba 100644
--- a/src/precmd.h
+++ b/src/precmd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/predicate.h b/src/predicate.h
index 30d07223..aca44452 100644
--- a/src/predicate.h
+++ b/src/predicate.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -90,19 +90,6 @@ public:
.to_boolean() :
true);
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<expr_t>(*this);
- ar & what_to_keep;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
} // namespace ledger
diff --git a/src/print.cc b/src/print.cc
index 02e518f7..0cc23275 100644
--- a/src/print.cc
+++ b/src/print.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/print.h b/src/print.h
index c587b499..70b26d65 100644
--- a/src/print.h
+++ b/src/print.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pstream.h b/src/pstream.h
index 3b669aca..fc7fc8ca 100644
--- a/src/pstream.h
+++ b/src/pstream.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/ptree.cc b/src/ptree.cc
index 3efe4451..534db003 100644
--- a/src/ptree.cc
+++ b/src/ptree.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/ptree.h b/src/ptree.h
index 36708dcf..ca7b46e2 100644
--- a/src/ptree.h
+++ b/src/ptree.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_account.cc b/src/py_account.cc
index 1cc28b92..c4a9ae07 100644
--- a/src/py_account.cc
+++ b/src/py_account.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_amount.cc b/src/py_amount.cc
index 84558a29..8a8ea871 100644
--- a/src/py_amount.cc
+++ b/src/py_amount.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_balance.cc b/src/py_balance.cc
index 98ed8c60..6a6c59fb 100644
--- a/src/py_balance.cc
+++ b/src/py_balance.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_commodity.cc b/src/py_commodity.cc
index 27a0e105..5aafa6ce 100644
--- a/src/py_commodity.cc
+++ b/src/py_commodity.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -243,6 +243,9 @@ namespace {
void export_commodity()
{
+#if BOOST_VERSION >= 106000
+ python::register_ptr_to_python< shared_ptr<commodity_pool_t> >();
+#endif
class_< commodity_pool_t, shared_ptr<commodity_pool_t>,
boost::noncopyable > ("CommodityPool", no_init)
.add_property("null_commodity",
diff --git a/src/py_expr.cc b/src/py_expr.cc
index 803388f2..de3ac925 100644
--- a/src/py_expr.cc
+++ b/src/py_expr.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_format.cc b/src/py_format.cc
index 6086d6cb..4dcd4ba3 100644
--- a/src/py_format.cc
+++ b/src/py_format.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_item.cc b/src/py_item.cc
index 473bbef8..644b11f1 100644
--- a/src/py_item.cc
+++ b/src/py_item.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,6 +32,7 @@
#include <system.hh>
#include "pyinterp.h"
+#include "pyutils.h"
#include "scope.h"
#include "mask.h"
#include "item.h"
@@ -64,6 +65,13 @@ namespace {
return item.get_tag(tag_mask, value_mask);
}
+ std::string py_position_pathname(position_t const& pos) {
+ return pos.pathname.native();
+ }
+ void py_position_set_pathname(position_t& pos, string const& s) {
+ pos.pathname = s;
+ }
+
} // unnamed namespace
#if 0
@@ -79,8 +87,8 @@ void export_item()
{
class_< position_t > ("Position")
.add_property("pathname",
- make_getter(&position_t::pathname),
- make_setter(&position_t::pathname))
+ make_function(py_position_pathname),
+ make_function(py_position_set_pathname))
.add_property("beg_pos",
make_getter(&position_t::beg_pos),
make_setter(&position_t::beg_pos))
@@ -169,6 +177,8 @@ void export_item()
.def("valid", &item_t::valid)
;
+
+ register_optional_to_python<position_t>();
}
} // namespace ledger
diff --git a/src/py_journal.cc b/src/py_journal.cc
index abbcd866..c1c38a90 100644
--- a/src/py_journal.cc
+++ b/src/py_journal.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -232,6 +232,9 @@ void export_journal()
boost::noncopyable >("PostHandler")
;
+#if BOOST_VERSION >= 106000
+ python::register_ptr_to_python< shared_ptr<collector_wrapper> >();
+#endif
class_< collector_wrapper, shared_ptr<collector_wrapper>,
boost::noncopyable >("PostCollectorWrapper", no_init)
.def("__len__", &collector_wrapper::length)
diff --git a/src/py_post.cc b/src/py_post.cc
index 851828c7..85d4701a 100644
--- a/src/py_post.cc
+++ b/src/py_post.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_session.cc b/src/py_session.cc
index f6053180..0ddf66d2 100644
--- a/src/py_session.cc
+++ b/src/py_session.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_times.cc b/src/py_times.cc
index 906dcfaa..be3e4f31 100644
--- a/src/py_times.cc
+++ b/src/py_times.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_utils.cc b/src/py_utils.cc
index df87bded..731294b2 100644
--- a/src/py_utils.cc
+++ b/src/py_utils.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_value.cc b/src/py_value.cc
index 2828e3b8..60ba4cf2 100644
--- a/src/py_value.cc
+++ b/src/py_value.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/py_xact.cc b/src/py_xact.cc
index 5b4c14d4..f7283989 100644
--- a/src/py_xact.cc
+++ b/src/py_xact.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pyfstream.h b/src/pyfstream.h
index 11f514a2..a90b121c 100644
--- a/src/pyfstream.h
+++ b/src/pyfstream.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pyinterp.cc b/src/pyinterp.cc
index 54e62946..81924c86 100644
--- a/src/pyinterp.cc
+++ b/src/pyinterp.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pyinterp.h b/src/pyinterp.h
index 32becbf6..9c24b0cf 100644
--- a/src/pyinterp.h
+++ b/src/pyinterp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -77,7 +77,7 @@ public:
if (name != "__main__")
main_module->define_global(name, mod->module_object);
return mod;
- }
+ }
python_interpreter_t() : session_t(), is_initialized(false) {
TRACE_CTOR(python_interpreter_t, "");
diff --git a/src/pyledger.cc b/src/pyledger.cc
index 1f478dec..a516f66d 100644
--- a/src/pyledger.cc
+++ b/src/pyledger.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/pyutils.h b/src/pyutils.h
index 039b2605..07ce7bdd 100644
--- a/src/pyutils.h
+++ b/src/pyutils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/query.cc b/src/query.cc
index 04b18581..a2117cfe 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/query.h b/src/query.h
index b7608bc7..cbfac6bc 100644
--- a/src/query.h
+++ b/src/query.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/quotes.cc b/src/quotes.cc
index 6d179287..2777974e 100644
--- a/src/quotes.cc
+++ b/src/quotes.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/quotes.h b/src/quotes.h
index c14bc495..b3978171 100644
--- a/src/quotes.h
+++ b/src/quotes.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/report.cc b/src/report.cc
index 2ce70151..9e480ea5 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -1198,6 +1198,7 @@ option_t<report_t> * report_t::lookup_option(const char * p)
OPT_CH(collapse);
else OPT(no_color);
else OPT(no_pager);
+ else OPT(no_revalued);
else OPT(no_rounding);
else OPT(no_titles);
else OPT(no_total);
diff --git a/src/report.h b/src/report.h
index 67e95884..0873e64f 100644
--- a/src/report.h
+++ b/src/report.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -403,6 +403,7 @@ public:
OPTION(report_t, auto_match);
OPTION_(report_t, average, DO() { // -A
+ OTHER(empty).on(whence);
OTHER(display_total_)
.on(whence, "count>0?(display_total/count):0");
});
@@ -496,7 +497,7 @@ public:
"%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
"%$1 %$2 %$3\n%/"
"%(prepend_width ? \" \" * int(prepend_width) : \"\")"
- "---------------- ---------------- ---------\n");
+ "---------------- ---------------- ---------\n");
});
OPTION(report_t, color);
@@ -764,6 +765,10 @@ public:
OTHER(color).off();
});
+ OPTION_(report_t, no_revalued, DO() {
+ OTHER(revalued).off();
+ });
+
OPTION(report_t, no_rounding);
OPTION(report_t, no_titles);
OPTION(report_t, no_total);
diff --git a/src/scope.cc b/src/scope.cc
index 3ca9e0c0..03387549 100644
--- a/src/scope.cc
+++ b/src/scope.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/scope.h b/src/scope.h
index 8ad3afac..147b400f 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -83,20 +83,6 @@ struct symbol_t
bool operator==(const symbol_t& sym) const {
return kind == sym.kind || name == sym.name;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & kind;
- ar & name;
- ar & definition;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class empty_scope_t;
@@ -127,16 +113,6 @@ public:
virtual bool type_required() const {
return false;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive&, const unsigned int /* version */) {}
-#endif // HAVE_BOOST_SERIALIZATION
};
class empty_scope_t : public scope_t
@@ -184,19 +160,6 @@ public:
return parent->lookup(kind, name);
return NULL;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<scope_t>(*this);
- ar & parent;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class bind_scope_t : public child_scope_t
@@ -233,19 +196,6 @@ public:
return def;
return child_scope_t::lookup(kind, name);
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<child_scope_t>(*this);
- ar & grandchild;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
template <typename T>
@@ -323,19 +273,6 @@ public:
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
const string& name);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<child_scope_t>(*this);
- ar & symbols;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class context_scope_t : public child_scope_t
@@ -365,24 +302,6 @@ public:
virtual bool type_required() const {
return required;
}
-
-#if HAVE_BOOST_SERIALIZATION
-protected:
- explicit context_scope_t() {
- TRACE_CTOR(context_scope_t, "");
- }
-
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<child_scope_t>(*this);
- ar & value_type_context;
- ar & required;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class call_scope_t : public context_scope_t
@@ -480,24 +399,6 @@ public:
bool empty() const {
return args.size() == 0;
}
-
-#if HAVE_BOOST_SERIALIZATION
-protected:
- explicit call_scope_t() : depth(0) {
- TRACE_CTOR(call_scope_t, "");
- }
-
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<context_scope_t>(*this);
- ar & args;
- //ar & ptr;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
template <>
diff --git a/src/select.cc b/src/select.cc
index 81800f16..1c69b2bf 100644
--- a/src/select.cc
+++ b/src/select.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -396,7 +396,7 @@ value_t select_command(call_scope_t& args)
#if 0
query_t query;
keep_details_t keeper(true, true, true);
- expr_t::ptr_op_t expr =
+ expr_t::ptr_op_t expr =
query.parse_args(string_value(arg).to_sequence(), keeper, false, true);
report.HANDLER(limit_).on("#select", query.get_query(query_t::QUERY_LIMIT));
#else
diff --git a/src/select.h b/src/select.h
index c95e15f7..89d7c989 100644
--- a/src/select.h
+++ b/src/select.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/session.cc b/src/session.cc
index b0d31be9..8d03431f 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -37,7 +37,6 @@
#include "journal.h"
#include "iterators.h"
#include "filters.h"
-#include "archive.h"
namespace ledger {
@@ -129,56 +128,13 @@ std::size_t session_t::read_data(const string& master_account)
if (HANDLED(value_expr_))
journal->value_expr = HANDLER(value_expr_).str();
-#if HAVE_BOOST_SERIALIZATION
- optional<archive_t> cache;
- if (HANDLED(cache_) && master_account.empty())
- cache = archive_t(HANDLED(cache_).str());
-
- if (! (cache &&
- cache->should_load(HANDLER(file_).data_files) &&
- cache->load(*journal.get()))) {
-#endif // HAVE_BOOST_SERIALIZATION
- if (price_db_path) {
- if (exists(*price_db_path)) {
- parsing_context.push(*price_db_path);
- parsing_context.get_current().journal = journal.get();
- try {
- if (journal->read(parsing_context) > 0)
- throw_(parse_error, _("Transactions not allowed in price history file"));
- }
- catch (...) {
- parsing_context.pop();
- throw;
- }
- parsing_context.pop();
- }
- }
-
- foreach (const path& pathname, HANDLER(file_).data_files) {
- if (pathname == "-" || pathname == "/dev/stdin") {
- // To avoid problems with stdin and pipes, etc., we read the entire
- // file in beforehand into a memory buffer, and then parcel it out
- // from there.
- std::ostringstream buffer;
-
- while (std::cin.good() && ! std::cin.eof()) {
- char line[8192];
- std::cin.read(line, 8192);
- std::streamsize count = std::cin.gcount();
- buffer.write(line, count);
- }
- buffer.flush();
-
- shared_ptr<std::istream> stream(new std::istringstream(buffer.str()));
- parsing_context.push(stream);
- } else {
- parsing_context.push(pathname);
- }
-
+ if (price_db_path) {
+ if (exists(*price_db_path)) {
+ parsing_context.push(*price_db_path);
parsing_context.get_current().journal = journal.get();
- parsing_context.get_current().master = acct;
try {
- xact_count += journal->read(parsing_context);
+ if (journal->read(parsing_context) > 0)
+ throw_(parse_error, _("Transactions not allowed in price history file"));
}
catch (...) {
parsing_context.pop();
@@ -186,16 +142,44 @@ std::size_t session_t::read_data(const string& master_account)
}
parsing_context.pop();
}
+ }
+
+ foreach (const path& pathname, HANDLER(file_).data_files) {
+ if (pathname == "-" || pathname == "/dev/stdin") {
+ // To avoid problems with stdin and pipes, etc., we read the entire
+ // file in beforehand into a memory buffer, and then parcel it out
+ // from there.
+ std::ostringstream buffer;
+
+ while (std::cin.good() && ! std::cin.eof()) {
+ char line[8192];
+ std::cin.read(line, 8192);
+ std::streamsize count = std::cin.gcount();
+ buffer.write(line, count);
+ }
+ buffer.flush();
- DEBUG("ledger.read", "xact_count [" << xact_count
- << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
- assert(xact_count == journal->xacts.size());
+ shared_ptr<std::istream> stream(new std::istringstream(buffer.str()));
+ parsing_context.push(stream);
+ } else {
+ parsing_context.push(pathname);
+ }
-#if HAVE_BOOST_SERIALIZATION
- if (cache && cache->should_save(*journal.get()))
- cache->save(*journal.get());
+ parsing_context.get_current().journal = journal.get();
+ parsing_context.get_current().master = acct;
+ try {
+ xact_count += journal->read(parsing_context);
+ }
+ catch (...) {
+ parsing_context.pop();
+ throw;
+ }
+ parsing_context.pop();
}
-#endif // HAVE_BOOST_SERIALIZATION
+
+ DEBUG("ledger.read", "xact_count [" << xact_count
+ << "] == journal->xacts.size() [" << journal->xacts.size() << "]");
+ assert(xact_count == journal->xacts.size());
if (populated_data_files)
HANDLER(file_).data_files.clear();
@@ -333,8 +317,7 @@ option_t<session_t> * session_t::lookup_option(const char * p)
OPT_CH(price_exp_);
break;
case 'c':
- OPT(cache_);
- else OPT(check_payees);
+ OPT(check_payees);
break;
case 'd':
OPT(download); // -Q
diff --git a/src/session.h b/src/session.h
index b287b19e..3d35a93e 100644
--- a/src/session.h
+++ b/src/session.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -97,7 +97,6 @@ public:
void report_options(std::ostream& out)
{
- HANDLER(cache_).report(out);
HANDLER(check_payees).report(out);
HANDLER(day_break).report(out);
HANDLER(download).report(out);
@@ -126,7 +125,6 @@ public:
* Option handlers
*/
- OPTION(session_t, cache_);
OPTION(session_t, check_payees);
OPTION(session_t, day_break);
OPTION(session_t, download); // -Q
diff --git a/src/stats.cc b/src/stats.cc
index 406ecd3b..2d1f8dc7 100644
--- a/src/stats.cc
+++ b/src/stats.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/stats.h b/src/stats.h
index f0408591..dfb9e796 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/stream.cc b/src/stream.cc
index c5a40e87..60b0dc55 100644
--- a/src/stream.cc
+++ b/src/stream.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/stream.h b/src/stream.h
index 05572cb4..996cffb1 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/strptime.cc b/src/strptime.cc
index b64af96b..b31954f4 100644
--- a/src/strptime.cc
+++ b/src/strptime.cc
@@ -85,7 +85,7 @@ static char* _strptime(const char *s, const char *format, struct tm *tm) {
if (tm->tm_wday == -1) return NULL;
s += len;
break;
-
+
// month name.
case 'b':
case 'B':
diff --git a/src/system.hh.in b/src/system.hh.in
index eaf4b1ac..54bcf7a9 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -71,7 +71,7 @@
#define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@
#define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@
-#define HAVE_BOOST_SERIALIZATION 0
+#define HAVE_BOOST_159_ISSUE_39 @HAVE_BOOST_159_ISSUE_39@
#define DEBUG_MODE @DEBUG_MODE@
#define NO_ASSERTS @NO_ASSERTS@
@@ -239,86 +239,8 @@ typedef std::ostream::pos_type ostream_pos_type;
#endif
#define _f(str) boost::format(_(str))
-#if HAVE_BOOST_SERIALIZATION
-
-#include <boost/archive/binary_iarchive.hpp>
-#include <boost/archive/binary_oarchive.hpp>
-
-#include <boost/serialization/base_object.hpp>
-#include <boost/serialization/binary_object.hpp>
-#include <boost/serialization/optional.hpp>
-#include <boost/serialization/shared_ptr.hpp>
-#include <boost/serialization/variant.hpp>
-#include <boost/serialization/utility.hpp>
-#include <boost/serialization/export.hpp>
-#include <boost/serialization/level.hpp>
-#include <boost/serialization/string.hpp>
-#include <boost/serialization/vector.hpp>
-#include <boost/serialization/deque.hpp>
-#include <boost/serialization/list.hpp>
-#include <boost/serialization/map.hpp>
-
-#include <boost/date_time/posix_time/time_serialize.hpp>
-#include <boost/date_time/gregorian/greg_serialize.hpp>
-#include <boost/ptr_container/serialize_ptr_deque.hpp>
-
-namespace boost {
-namespace serialization {
-
-template <class Archive>
-void serialize(Archive& ar, boost::filesystem::path& p, const unsigned int)
-{
- std::string s;
- if (Archive::is_saving::value)
- s = p.string();
-
- ar & s;
-
- if (Archive::is_loading::value)
- p = s;
-}
-
-template <class Archive, class T>
-void serialize(Archive& ar, boost::intrusive_ptr<T>& ptr, const unsigned int)
-{
- if (Archive::is_saving::value) {
- T * p = ptr.get();
- ar & p;
- }
- else if (Archive::is_loading::value) {
- T * p;
- ar & p;
- ptr.reset(p);
- }
-}
-
-template <class Archive>
-void serialize(Archive&, boost::any&, const unsigned int) {
- // jww (2012-03-29): Should we really ignore any fields entirely?
- // These occur inside value_t::storage_t::data's variant.
-}
-
-template <class Archive>
-void serialize(Archive&, boost::blank&, const unsigned int) {}
-
-template <class Archive, class T>
-void serialize(Archive&, boost::function<T>&, const unsigned int) {}
-
-template <class Archive>
-void serialize(Archive& ar, istream_pos_type& pos, const unsigned int)
-{
- ar & make_binary_object(&pos, sizeof(istream_pos_type));
-}
-
-} // namespace serialization
-} // namespace boost
-
-#else // HAVE_BOOST_SERIALIZATION
-
#include <boost/ptr_container/ptr_deque.hpp>
-#endif // HAVE_BOOST_SERIALIZATION
-
#if HAVE_BOOST_PYTHON
#include <boost/python.hpp>
@@ -332,6 +254,17 @@ void serialize(Archive& ar, istream_pos_type& pos, const unsigned int)
#include <boost/iterator/indirect_iterator.hpp>
+#if BOOST_VERSION == 105900 && HAVE_BOOST_159_ISSUE_39
+// Fix for https://github.com/boostorg/python/issues/39
+namespace boost { namespace python {
+template <class D>
+inline object make_setter(D const& x)
+{
+ return detail::make_setter(x, default_call_policies(), is_member_pointer<D>(), 0);
+}
+}}
+#endif
+
#endif // HAVE_BOOST_PYTHON
#endif // _SYSTEM_HH
diff --git a/src/temps.cc b/src/temps.cc
index 15ccbc3a..b8e7bfb6 100644
--- a/src/temps.cc
+++ b/src/temps.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/temps.h b/src/temps.h
index 77a7824e..eb2b9b23 100644
--- a/src/temps.h
+++ b/src/temps.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/textual.cc b/src/textual.cc
index 8007ca0d..ccd87ca0 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/timelog.cc b/src/timelog.cc
index 91ee2697..870a4b4b 100644
--- a/src/timelog.cc
+++ b/src/timelog.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/timelog.h b/src/timelog.h
index af621ee6..95a87eae 100644
--- a/src/timelog.h
+++ b/src/timelog.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/times.cc b/src/times.cc
index b6c15dc3..b9c8fc01 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/times.h b/src/times.h
index c1bfb1cc..df833958 100644
--- a/src/times.h
+++ b/src/times.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -153,20 +153,6 @@ struct date_traits_t
has_month == traits.has_month &&
has_day == traits.has_day);
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & has_year;
- ar & has_month;
- ar & has_day;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
struct date_duration_t
@@ -247,19 +233,6 @@ struct date_duration_t
}
static date_t find_nearest(const date_t& date, skip_quantum_t skip);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & quantum;
- ar & length;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class date_specifier_t
@@ -343,21 +316,6 @@ public:
return out.str();
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & year;
- ar & month;
- ar & day;
- ar & wday;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class date_range_t
@@ -420,20 +378,6 @@ public:
return out.str();
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & range_begin;
- ar & range_end;
- ar & end_inclusive;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class date_specifier_or_range_t
@@ -490,18 +434,6 @@ public:
return out.str();
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & specifier_or_range;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class date_interval_t : public equality_comparable<date_interval_t>
@@ -568,11 +500,7 @@ public:
void stabilize(const optional<date_t>& date = none);
bool is_valid() const {
-#if BOOST_VERSION >= 105600
- return start != NULL;
-#else
- return start;
-#endif
+ return static_cast<bool>(start);
}
/** Find the current or next period containing date. Returns false if
@@ -594,24 +522,6 @@ public:
date_interval_t& operator++();
void dump(std::ostream& out);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & range;
- ar & start;
- ar & finish;
- ar & aligned;
- ar & next;
- ar & duration;
- ar & end_of_duration;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
void times_initialize();
diff --git a/src/token.cc b/src/token.cc
index 9fe7873f..0bbff6ea 100644
--- a/src/token.cc
+++ b/src/token.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/token.h b/src/token.h
index 3fe249aa..b9ccde86 100644
--- a/src/token.h
+++ b/src/token.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/unistring.h b/src/unistring.h
index 3f459d83..fc37c9f2 100644
--- a/src/unistring.h
+++ b/src/unistring.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/utils.cc b/src/utils.cc
index 9b528f54..947f2408 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/utils.h b/src/utils.h
index b92a6f49..42ea2ae9 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/value.cc b/src/value.cc
index 2737add9..878d7349 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -341,6 +341,10 @@ value_t& value_t::operator+=(const value_t& val)
}
switch (type()) {
+ case VOID:
+ *this = value_t(val);
+ return *this;
+
case DATETIME:
switch (val.type()) {
case INTEGER:
diff --git a/src/value.h b/src/value.h
index c224ce04..eb0c7c76 100644
--- a/src/value.h
+++ b/src/value.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -227,20 +227,6 @@ public:
data = false;
type = VOID;
}
-
-#if HAVE_BOOST_SERIALIZATION
- private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & data;
- ar & type;
- ar & refc;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
private:
@@ -449,7 +435,7 @@ public:
return temp;
}
void in_place_roundto(int places);
-
+
value_t truncated() const {
value_t temp(*this);
temp.in_place_truncate();
@@ -965,20 +951,6 @@ public:
* Debugging methods.
*/
bool valid() const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & true_value;
- ar & false_value;
- ar & storage;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
#define NULL_VALUE (value_t())
diff --git a/src/views.cc b/src/views.cc
index 61b824cd..65d21a9a 100644
--- a/src/views.cc
+++ b/src/views.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/views.h b/src/views.h
index 2be3d978..070ac22d 100644
--- a/src/views.h
+++ b/src/views.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -235,7 +235,7 @@ public:
optional<string> note() const {
return ptr()->note;
}
-
+
bool has_tag(const string& tag) const {
return ptr()->has_tag(tag);
}
diff --git a/src/wcwidth.cc b/src/wcwidth.cc
index c23f83d7..75cd76be 100644
--- a/src/wcwidth.cc
+++ b/src/wcwidth.cc
@@ -195,7 +195,7 @@ int mk_wcwidth(boost::uint32_t ucs)
/* if we arrive here, ucs is not a combining or C0/C1 control character */
- return 1 +
+ return 1 +
(ucs >= 0x1100 &&
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
ucs == 0x2329 || ucs == 0x232a ||
diff --git a/src/xact.cc b/src/xact.cc
index 5369c138..2524889d 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/src/xact.h b/src/xact.h
index 3ca57953..a43246ee 100644
--- a/src/xact.h
+++ b/src/xact.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2016, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -87,20 +87,6 @@ public:
virtual bool valid() const {
return true;
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<item_t>(*this);
- ar & journal;
- ar & posts;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class xact_t : public xact_base_t
@@ -142,20 +128,6 @@ public:
const string& name);
virtual bool valid() const;
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<xact_base_t>(*this);
- ar & code;
- ar & payee;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class auto_xact_t : public xact_base_t
@@ -176,21 +148,6 @@ public:
bool _overwrite_existing)
: tag_data(_tag_data), overwrite_existing(_overwrite_existing),
apply_to_post(NULL) {}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
- deferred_tag_data_t() : apply_to_post(NULL) {}
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & tag_data;
- ar & overwrite_existing;
- ar & apply_to_post;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
typedef std::list<deferred_tag_data_t> deferred_notes_list;
@@ -236,21 +193,6 @@ private:
}
virtual void extend_xact(xact_base_t& xact, parse_context_t& context);
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<xact_base_t>(*this);
- ar & predicate;
- ar & check_exprs;
- ar & deferred_notes;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
class period_xact_t : public xact_base_t
@@ -284,20 +226,6 @@ class period_xact_t : public xact_base_t
return string(_("generated periodic transaction"));
}
}
-
-#if HAVE_BOOST_SERIALIZATION
-private:
- /** Serialization. */
-
- friend class boost::serialization::access;
-
- template<class Archive>
- void serialize(Archive& ar, const unsigned int /* version */) {
- ar & boost::serialization::base_object<xact_base_t>(*this);
- ar & period;
- ar & period_string;
- }
-#endif // HAVE_BOOST_SERIALIZATION
};
typedef std::list<xact_t *> xacts_list;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6eb9f956..d0b62f6e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -25,6 +25,8 @@ macro(add_ledger_harness_tests _class)
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py
$<TARGET_FILE:ledger> ${PROJECT_SOURCE_DIR}
${TestFile} ${TEST_PYTHON_FLAGS})
+ set_tests_properties(${_class}Test_${TestFile_Name}
+ PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
set_target_properties(check
PROPERTIES DEPENDS ${_class}Test_${TestFile_Name})
endif()
@@ -44,14 +46,21 @@ if (PYTHONINTERP_FOUND)
add_test(NAME ${_class}Test_${TestFile_Name}
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
--ledger $<TARGET_FILE:ledger> --file ${TestFile})
- set_target_properties(check PROPERTIES DEPENDS ${_class}Test_${TestFile_Name})
+ set_tests_properties(${_class}Test_${TestFile_Name}
+ PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
+ set_target_properties(check
+ PROPERTIES DEPENDS ${_class}Test_${TestFile_Name})
endforeach()
- list(APPEND CheckOptions CheckManpage CheckTexinfo CheckBaselineTests)
+ # CheckManpage and CheckTexinfo are disabled, since they do not work
+ # reliably yet, instead they are being run as a Travis CI report.
+ list(APPEND CheckOptions CheckBaselineTests) #CheckManpage CheckTexinfo
foreach(_class ${CheckOptions})
add_test(NAME ${_class}
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/${_class}.py
--ledger $<TARGET_FILE:ledger> --source ${PROJECT_SOURCE_DIR})
+ set_tests_properties(${_class}
+ PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
endforeach()
endif()
diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py
index 3c3e590b..8659d1b5 100755
--- a/test/CheckBaselineTests.py
+++ b/test/CheckBaselineTests.py
@@ -21,29 +21,23 @@ class CheckBaselineTests (CheckOptions):
self.untested_options = [
'anon',
'args-only',
- 'cache',
'debug',
'download',
- 'file',
'force-color',
'force-pager',
- 'full-help',
+ 'generated',
'help',
- 'help-calc',
- 'help-comm',
- 'help-disp',
'import',
- 'init-file',
'no-color',
+ 'no-pager',
'options',
- 'price-db',
'price-exp',
'revalued-total',
- 'script',
'seed',
'trace',
'verbose',
'verify',
+ 'verify-memory',
'version'
]
diff --git a/test/CheckOptions.py b/test/CheckOptions.py
index 5059a289..e4a1fdc3 100755
--- a/test/CheckOptions.py
+++ b/test/CheckOptions.py
@@ -83,7 +83,7 @@ class CheckOptions (object):
self.missing_functions.add(function)
else:
functions.remove(function)
- known_functions = ['tag', 'has_tag']
+ known_functions = ['tag', 'has_tag', 'meta', 'has_meta']
self.unknown_functions = {function for function in functions if function not in known_functions}
if len(self.missing_options):
diff --git a/test/DocTests.py b/test/DocTests.py
index cbad9ca7..7af7abc3 100755
--- a/test/DocTests.py
+++ b/test/DocTests.py
@@ -19,13 +19,17 @@ class DocTests:
self.verbose = args.verbose
self.tests = args.examples
- self.examples = dict()
- self.test_files = list()
- self.testin_token = 'command'
- self.testout_token = 'output'
- self.testdat_token = 'input'
+ self.examples = dict()
+ self.test_files = list()
+ self.testin_token = 'command'
+ self.testout_token = 'output'
+ self.testdat_token = 'input'
+ self.testfile_token = 'file'
self.validate_token = 'validate'
- self.testwithdat_token = 'with_input'
+ self.validate_cmd_token = 'validate-command'
+ self.validate_dat_token = 'validate-data'
+ self.testwithdat_token = 'with_input'
+ self.testwithfile_token = 'with_file'
def read_example(self):
endexample = re.compile(r'^@end\s+smallexample\s*$')
@@ -35,15 +39,15 @@ class DocTests:
self.current_line += 1
if len(line) <= 0 or endexample.match(line): break
# Replace special texinfo character sequences with their ASCII counterpart
- example += line.replace("@@","@").replace("@{","{").replace("@}","}")
+ example += re.sub(r'@([@{}])', r'\1', line)
return example
def test_id(self, example):
return hashlib.sha1(example.rstrip()).hexdigest()[0:7].upper()
def find_examples(self):
- startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?'
- % (self.testin_token, self.testout_token, self.testdat_token))
+ startexample = re.compile(r'^@smallexample\s+@c\s+(%s|%s|%s|%s)(?::([\dA-Fa-f]+|validate))?(?:,(.*))?'
+ % (self.testin_token, self.testout_token, self.testdat_token, self.testfile_token))
while True:
line = self.file.readline()
self.current_line += 1
@@ -78,9 +82,9 @@ class DocTests:
if test_id == self.validate_token:
test_id = "Val-" + str(test_begin_line)
if test_kind == self.testin_token:
- test_kind = "validate-command"
+ test_kind = self.validate_cmd_token
elif test_kind == self.testdat_token:
- test_kind = "validate-data"
+ test_kind = self.validate_dat_token
try:
self.examples[test_id]
except KeyError:
@@ -104,16 +108,17 @@ class DocTests:
validate_command = False
try:
command = example[self.testin_token][self.testin_token]
+ command = re.sub(r'\\\n', '', command)
except KeyError:
- if 'validate-data' in example:
+ if self.validate_dat_token in example:
command = '$ ledger bal'
- elif 'validate-command' in example:
+ elif self.validate_cmd_token in example:
validate_command = True
- command = example['validate-command']['validate-command']
+ command = example[self.validate_cmd_token][self.validate_cmd_token]
else:
return None
- command = shlex.split(command)
+ command = filter(lambda x: x != '\n', shlex.split(command))
if command[0] == '$': command.remove('$')
index = command.index('ledger')
command[index] = self.ledger
@@ -145,7 +150,7 @@ class DocTests:
for test_id in tests:
validation = False
- if "validate-data" in self.examples[test_id] or "validate-command" in self.examples[test_id]:
+ if self.validate_dat_token in self.examples[test_id] or self.validate_cmd_token in self.examples[test_id]:
validation = True
example = self.examples[test_id]
try:
@@ -154,51 +159,52 @@ class DocTests:
failed.add(test_id)
continue
- try:
- output = example[self.testout_token][self.testout_token]
- except KeyError:
- output = None
-
- try:
- input = example[self.testdat_token][self.testdat_token]
- except KeyError:
- try:
- with_input = example[self.testin_token]['opts'][self.testwithdat_token]
- input = self.examples[with_input][self.testdat_token][self.testdat_token]
- except KeyError:
- try:
- input = example['validate-data']['validate-data']
- except KeyError:
- input = None
+ output = example.get(self.testout_token, {}).get(self.testout_token)
+ input = example.get(self.testdat_token, {}).get(self.testdat_token)
+ if not input:
+ with_input = example.get(self.testin_token, {}).get('opts', {}).get(self.testwithdat_token)
+ input = self.examples.get(with_input, {}).get(self.testdat_token, {}).get(self.testdat_token)
+ if not input:
+ input = example.get(self.validate_dat_token, {}).get(self.validate_dat_token)
- if command and (output or validation):
+ if command and (output != None or validation):
test_file_created = False
if findex:
scriptpath = os.path.dirname(os.path.realpath(__file__))
- test_input_dir = scriptpath + '/../test/input/'
+ test_input_dir = os.path.join(scriptpath, '..', 'test', 'input')
test_file = command[findex]
if not os.path.exists(test_file):
if input:
test_file_created = True
with open(test_file, 'w') as f:
f.write(input)
- elif os.path.exists(test_input_dir + test_file):
- command[findex] = test_input_dir + test_file
- error = False
+ elif os.path.exists(os.path.join(test_input_dir, test_file)):
+ command[findex] = os.path.join(test_input_dir, test_file)
+ try:
+ convert_idx = command.index('convert')
+ convert_file = command[convert_idx+1]
+ convert_data = example[self.testfile_token][self.testfile_token]
+ if not os.path.exists(convert_file):
+ with open(convert_file, 'w') as f:
+ f.write(convert_data)
+ except ValueError:
+ pass
+ error = None
try:
verify = subprocess.check_output(command, stderr=subprocess.STDOUT)
- except:
- verify = str()
- error = True
- valid = (output == verify) or (not error and validation)
+ valid = (output == verify) or (not error and validation)
+ except subprocess.CalledProcessError, e:
+ error = e.output
+ valid = False
+ failed.add(test_id)
if valid and test_file_created:
os.remove(test_file)
if self.verbose > 0:
- print test_id, ':', 'Passed' if valid else 'FAILED'
+ print test_id, ':', 'Passed' if valid else 'FAILED: {}'.format(error) if error else 'FAILED'
else:
sys.stdout.write('.' if valid else 'E')
- if not valid:
+ if not (valid or error):
failed.add(test_id)
if self.verbose > 1:
print ' '.join(command)
@@ -206,6 +212,12 @@ class DocTests:
for line in unified_diff(output.split('\n'), verify.split('\n'), fromfile='generated', tofile='expected'):
print(line)
print
+ else:
+ if self.verbose > 0:
+ print test_id, ':', 'Skipped'
+ else:
+ sys.stdout.write('X')
+
if not self.verbose:
print
if len(failed) > 0:
diff --git a/test/RegressTests.py b/test/RegressTests.py
index 0fef2127..a5bab42d 100755
--- a/test/RegressTests.py
+++ b/test/RegressTests.py
@@ -57,9 +57,6 @@ class RegressFile(object):
in_error = False
line = self.fd.readline()
- if not line:
- print >>sys.stderr, "WARNING: Empty testfile detected: %s" % (self.filename)
- return False
#print "line =", line
while line:
if line.startswith("test "):
@@ -167,6 +164,10 @@ class RegressFile(object):
harness.failure(os.path.basename(self.filename))
def run_tests(self):
+ if os.path.getsize(self.filename) == 0:
+ print >>sys.stderr, "WARNING: Empty testfile detected: %s" % (self.filename)
+ harness.failure(os.path.basename(self.filename))
+ return False
test = self.read_test()
while test:
self.run_test(test)
diff --git a/test/baseline/cmd-cleared.test b/test/baseline/cmd-cleared.test
index 501d207f..91219a40 100644
--- a/test/baseline/cmd-cleared.test
+++ b/test/baseline/cmd-cleared.test
@@ -30,7 +30,7 @@ test cleared
-20 0 F
-30 -30 12-Feb-26 G
-40 0 H
----------------- ---------------- ---------
+---------------- ---------------- ---------
0 0
end test
diff --git a/test/baseline/cmd-convert.test.disable b/test/baseline/cmd-convert.test
index d444da52..8ee5bb2e 100644
--- a/test/baseline/cmd-convert.test.disable
+++ b/test/baseline/cmd-convert.test
@@ -17,7 +17,7 @@ end test
test -f /dev/null --input-date-format "%m/%d/%Y" convert test/baseline/cmd-convert3.dat -> 1
__ERROR__
-While parsing file "$sourcepath/test/baseline/cmd-convert3.dat", line 1:
+While parsing file "$sourcepath/test/baseline/cmd-convert3.dat", line 1:
While parsing CSV line:
01/01/2011,,
@@ -26,7 +26,7 @@ end test
test -f /dev/null convert test/baseline/cmd-convert4.dat -> 1
__ERROR__
-While parsing file "$sourcepath/test/baseline/cmd-convert4.dat", line 1:
+While parsing file "$sourcepath/test/baseline/cmd-convert4.dat", line 1:
While parsing CSV line:
bogus,$10,
diff --git a/test/baseline/feat-fixated-prices_2.test b/test/baseline/dir-fixed.test
index ecbdfe9a..ecbdfe9a 100644
--- a/test/baseline/feat-fixated-prices_2.test
+++ b/test/baseline/dir-fixed.test
diff --git a/test/baseline/opt-auto-match.test b/test/baseline/opt-auto-match.test
index 7c3fb40a..54a1053b 100644
--- a/test/baseline/opt-auto-match.test
+++ b/test/baseline/opt-auto-match.test
@@ -14,17 +14,58 @@
Expenses:Food 20.00 EUR
Liabilities:CC -20.00 EUR
+test --input-date-format "%Y-%m-%d" convert test/baseline/opt-auto-match.dat
+2012/03/01 * Food
+ Expenses:Unknown 10
+ Equity:Unknown
+
+2012/03/02 * Phone
+ Expenses:Unknown 10
+ Equity:Unknown
+
+2012/03/02 * Dining
+ Expenses:Unknown 10
+ Equity:Unknown
+end test
+
test --input-date-format "%Y-%m-%d" --auto-match convert test/baseline/opt-auto-match.dat
2012/03/01 * Food
- Assets:Cash 10
+ Expenses:Food 10
Equity:Unknown
2012/03/02 * Phone
- Assets:Cash 10
+ Expenses:Phone 10
Equity:Unknown
2012/03/02 * Dining
- Liabilities:CC 10
+ Expenses:Food 10
Equity:Unknown
end test
+test --input-date-format "%Y-%m-%d" --account Assets:Bank convert test/baseline/opt-auto-match.dat
+2012/03/01 * Food
+ Expenses:Unknown 10
+ Assets:Bank
+
+2012/03/02 * Phone
+ Expenses:Unknown 10
+ Assets:Bank
+
+2012/03/02 * Dining
+ Expenses:Unknown 10
+ Assets:Bank
+end test
+
+test --input-date-format "%Y-%m-%d" --auto-match --account Assets:Bank convert test/baseline/opt-auto-match.dat
+2012/03/01 * Food
+ Expenses:Food 10
+ Assets:Bank
+
+2012/03/02 * Phone
+ Expenses:Phone 10
+ Assets:Bank
+
+2012/03/02 * Dining
+ Expenses:Food 10
+ Assets:Bank
+end test
diff --git a/test/baseline/opt-cleared-format.test b/test/baseline/opt-cleared-format.test
index e69de29b..4d3ea267 100644
--- a/test/baseline/opt-cleared-format.test
+++ b/test/baseline/opt-cleared-format.test
@@ -0,0 +1,20 @@
+test cleared --file test/input/drewr3.dat --cleared-format "%-30(account) %15(get_at(total_expr, 0)) %15(get_at(total_expr, 1))\n%/"
+Assets $ -3,804.00 $ 775.00
+Assets:Checking $ 1,396.00 $ 775.00
+Assets:Checking:Business $ 30.00 0
+Assets:Savings $ -5,200.00 0
+Equity:Opening Balances $ -1,000.00 $ -1,000.00
+Expenses $ 6,654.00 $ 225.00
+Expenses:Auto $ 5,500.00 0
+Expenses:Books $ 20.00 0
+Expenses:Escrow $ 300.00 0
+Expenses:Food:Groceries $ 334.00 $ 225.00
+Expenses:Interest:Mortgage $ 500.00 0
+Income $ -2,030.00 0
+Income:Salary $ -2,000.00 0
+Income:Sales $ -30.00 0
+Liabilities $ -63.60 0
+Liabilities:MasterCard $ -20.00 0
+Liabilities:Mortgage:Principal $ 200.00 0
+Liabilities:Tithe $ -243.60 0
+end test
diff --git a/test/baseline/opt-explicit.test b/test/baseline/opt-explicit.test
index defae179..20b74913 100644
--- a/test/baseline/opt-explicit.test
+++ b/test/baseline/opt-explicit.test
@@ -2,16 +2,18 @@ account Assets:Cash
account Expenses:Phone
account Expenses:Rent
commodity GBP
+tag bar
-2012-03-20 Phone
+2012-03-20 * Phone
+ ; :bar:
Expenses:Phone 20.00 GBP
Assets:Cash
-2012-03-21 Rent
+2012-03-21 * Rent
Expenses:Rent 550.00 GBP
Assets:Cash
-2012-03-22 Food
+2012-03-22 * Food
; :food:
Expenses:Food 20.00 EUR
Assets:Cash
@@ -27,8 +29,8 @@ test bal --explicit --strict
--------------------
0
__ERROR__
-Warning: "$FILE", line 16: Unknown account 'Expenses:Food'
-Warning: "$FILE", line 16: Unknown commodity 'EUR'
-Warning: "$FILE", line 17: Unknown metadata tag 'food'
+Warning: "$FILE", line 18: Unknown account 'Expenses:Food'
+Warning: "$FILE", line 18: Unknown commodity 'EUR'
+Warning: "$FILE", line 19: Unknown metadata tag 'food'
end test
diff --git a/test/baseline/opt-file.test.disable b/test/baseline/opt-file.test
index 66d0ab1b..66d0ab1b 100644
--- a/test/baseline/opt-file.test.disable
+++ b/test/baseline/opt-file.test
diff --git a/test/baseline/opt-generated.test b/test/baseline/opt-generated.test
deleted file mode 100644
index e69de29b..00000000
--- a/test/baseline/opt-generated.test
+++ /dev/null
diff --git a/test/baseline/opt-init-file.dat b/test/baseline/opt-init-file.dat
new file mode 100644
index 00000000..92c5307a
--- /dev/null
+++ b/test/baseline/opt-init-file.dat
@@ -0,0 +1 @@
+--decimal-comma
diff --git a/test/baseline/opt-init-file.test b/test/baseline/opt-init-file.test
new file mode 100644
index 00000000..128814e1
--- /dev/null
+++ b/test/baseline/opt-init-file.test
@@ -0,0 +1,10 @@
+2012-03-17 Quick
+ Expenses:Food 12,50 €
+ Assets:Cash
+
+test --init-file test/baseline/opt-init-file.dat bal
+ -12,50 € Assets:Cash
+ 12,50 € Expenses:Food
+--------------------
+ 0
+end test
diff --git a/test/baseline/opt-no-pager.test b/test/baseline/opt-no-pager.test
deleted file mode 100644
index e69de29b..00000000
--- a/test/baseline/opt-no-pager.test
+++ /dev/null
diff --git a/test/baseline/opt-no-revalued.test b/test/baseline/opt-no-revalued.test
new file mode 100644
index 00000000..487ffa30
--- /dev/null
+++ b/test/baseline/opt-no-revalued.test
@@ -0,0 +1,58 @@
+2009/01/01 Sample 1a
+ Assets:Brokerage:Stocks 100 S
+ Assets:Brokerage:Cash -100 P
+
+P 2009/01/01 00:00:00 S 2 P
+
+2009/02/01 Sample 2a
+ Assets:Brokerage:Stocks 100 S @ 1 P
+ Assets:Brokerage:Cash
+
+P 2009/02/01 00:00:00 S 4 P
+
+2009/03/01 Sample 3a
+ Assets:Brokerage:Stocks 100 S @@ 100 P
+ Assets:Brokerage:Cash
+
+P 2009/03/01 00:00:00 S 8 P
+
+2009/04/01 Sample 4a
+ Assets:Brokerage:Cash 100 P
+ Assets:Brokerage:Stocks -100 S {1 P}
+
+P 2009/04/01 00:00:00 S 16 P
+
+; In this usage case, the top amount is always secondary
+; 2010/01/01 Sample 1b
+; Assets:Brokerage:Cash -100 P
+; Assets:Brokerage:Stocks 100 S
+;
+; P 2010/01/01 00:00:00 S 2 P
+
+2010/02/01 Sample 2b
+ Assets:Brokerage:Cash
+ Assets:Brokerage:Stocks 100 S @ 1 P
+
+P 2010/02/01 00:00:00 S 4 P
+
+2010/03/01 Sample 3b
+ Assets:Brokerage:Cash
+ Assets:Brokerage:Stocks 100 S @@ 100 P
+
+P 2010/03/01 00:00:00 S 8 P
+
+2010/04/01 Sample 4b
+ Assets:Brokerage:Stocks -100 S {1 P}
+ Assets:Brokerage:Cash 100 P
+
+P 2010/04/01 00:00:00 S 16 P
+
+test reg --market --no-revalued stocks
+09-Jan-01 Sample 1a Asset:Brokerage:Stocks 200 P 200 P
+09-Feb-01 Sample 2a Asset:Brokerage:Stocks 400 P 800 P
+09-Mar-01 Sample 3a Asset:Brokerage:Stocks 800 P 2400 P
+09-Apr-01 Sample 4a Asset:Brokerage:Stocks -1600 P 3200 P
+10-Feb-01 Sample 2b Asset:Brokerage:Stocks 400 P 1200 P
+10-Mar-01 Sample 3b Asset:Brokerage:Stocks 800 P 3200 P
+10-Apr-01 Sample 4b Asset:Brokerage:Stocks -1600 P 4800 P
+end test
diff --git a/test/baseline/opt-no-rounding.test b/test/baseline/opt-no-rounding.test
index e69de29b..5d0758c6 100644
--- a/test/baseline/opt-no-rounding.test
+++ b/test/baseline/opt-no-rounding.test
@@ -0,0 +1,81 @@
+2012-01-01 * Opening balance
+ Assets:Current 17.43 EUR
+ Assets:Investments 200 "LU02" @ 24.77 EUR
+ Assets:Investments 58 "LU02" @ 24.79900855 EUR
+ Equity:Opening balance
+
+2012-01-01 * Opening balance
+ Assets:Pension 785.44 GBP
+ Assets:Pension 97.0017 "H2" @ 5.342999720204 GBP
+ Assets:Pension 4.3441 "H1" @ 5.289999915108 GBP
+ Equity:Opening balance
+
+2012-01-01 * Opening balance: misc
+ Assets:Piggy bank 3.51 GBP
+ Equity:Opening balance
+
+2012-01-01 * Opening balance
+ Assets:Rewards 9836 AAdvantage
+ Equity:Opening balance
+
+2012-01-03 * Receivable
+ Assets:Current
+ Assets:Receivable -161.06 EUR
+ Assets:Receivable -9.99 GBP @@ 11.65 EUR
+
+2012-01-27 * Test
+ Income:Test -2759.50 GBP
+ Income:Test -110.76 GBP
+ Assets:Foo 345.57 GBP
+ Expenses:Test 16.47 GBP
+ Expenses:Test 6.33 GBP
+ Expenses:Test 261.39 GBP
+ Assets:Current
+
+test reg -X EUR -H --no-rounding
+12-Jan-01 Opening balance Assets:Current 17.43 EUR 17.43 EUR
+ Assets:Investments 4959.80 EUR 4977.23 EUR
+ Assets:Investments 1438.34 EUR 6415.57 EUR
+ Equity:Opening balance -6409.77 EUR 5.80 EUR
+12-Jan-01 Opening balance Assets:Pension 785.44 GBP 5.80 EUR
+ 785.44 GBP
+ Assets:Pension 97.0017 H2 5.80 EUR
+ 785.44 GBP
+ 97.0017 H2
+ Assets:Pension 4.3441 H1 5.80 EUR
+ 785.44 GBP
+ 4.3441 H1
+ 97.0017 H2
+ Equity:Opening balance -1326.70 GBP 5.80 EUR
+ -541.26 GBP
+ 4.3441 H1
+ 97.0017 H2
+12-Jan-01 Opening balance: misc Assets:Piggy bank 3.51 GBP 5.80 EUR
+ -537.75 GBP
+ 4.3441 H1
+ 97.0017 H2
+ Equity:Opening balance -3.51 GBP 5.80 EUR
+ -541.26 GBP
+ 4.3441 H1
+ 97.0017 H2
+12-Jan-01 Opening balance Assets:Rewards 9836 AAdvantage 9836 AAdvantage
+ 5.80 EUR
+ -541.26 GBP
+ 4.3441 H1
+ 97.0017 H2
+ Equity:Opening balance -9836 AAdvantage 5.80 EUR
+ -541.26 GBP
+ 4.3441 H1
+ 97.0017 H2
+12-Jan-03 Commodities revalued <Revalued> 0 5.80 EUR
+12-Jan-03 Receivable Assets:Current 172.71 EUR 178.51 EUR
+ Assets:Receivable -161.06 EUR 17.45 EUR
+ Assets:Receivable -11.65 EUR 5.80 EUR
+12-Jan-27 Test Income:Test -3218.04 EUR -3212.23 EUR
+ Income:Test -129.16 EUR -3341.40 EUR
+ Assets:Foo 402.99 EUR -2938.41 EUR
+ Expenses:Test 19.21 EUR -2919.20 EUR
+ Expenses:Test 7.38 EUR -2911.82 EUR
+ Expenses:Test 304.82 EUR -2606.99 EUR
+ Assets:Current 2612.80 EUR 5.80 EUR
+end test
diff --git a/test/baseline/opt-price-db.dat b/test/baseline/opt-price-db.dat
new file mode 100644
index 00000000..abc51a0a
--- /dev/null
+++ b/test/baseline/opt-price-db.dat
@@ -0,0 +1,2 @@
+P 2012-03-16 06:47:12 CAD $2.50
+P 2012-03-17 06:47:12 CAD $3.50
diff --git a/test/baseline/opt-price-db.test b/test/baseline/opt-price-db.test
new file mode 100644
index 00000000..06021e4a
--- /dev/null
+++ b/test/baseline/opt-price-db.test
@@ -0,0 +1,8 @@
+2012-03-17 KFC
+ Expenses:Food 20 CAD
+ Assets:Cash
+
+test pricedb --price-db test/baseline/opt-price-db.dat
+P 2012/03/16 06:47:12 CAD $2.5
+P 2012/03/17 06:47:12 CAD $3.5
+end test
diff --git a/test/baseline/opt-rich-data.test b/test/baseline/opt-rich-data.test
index fbb73ebe..265af531 100644
--- a/test/baseline/opt-rich-data.test
+++ b/test/baseline/opt-rich-data.test
@@ -1,3 +1,13 @@
+test -f /dev/null convert test/baseline/feat-convert-with-directives.dat --now '2014/08/01'
+2012/01/01 * KFC
+ Expenses:Unknown $10
+ Equity:Unknown
+
+2012/01/02 * REWE SAGT DANKE 123454321
+ Expenses:Unknown 10€
+ Equity:Unknown
+end test
+
test -f /dev/null convert test/baseline/feat-convert-with-directives.dat --detail --now '2014/08/01'
2012/01/01 * KFC
; CSV: 2012/01/01,KFC,$10
diff --git a/test/baseline/opt-script.dat b/test/baseline/opt-script.dat
new file mode 100644
index 00000000..ac6085d5
--- /dev/null
+++ b/test/baseline/opt-script.dat
@@ -0,0 +1,3 @@
+--no-pager --columns=80 bal
+--no-pager --columns=80 reg
+--no-pager --columns=80 print
diff --git a/test/baseline/opt-script.test b/test/baseline/opt-script.test
new file mode 100644
index 00000000..041c15ee
--- /dev/null
+++ b/test/baseline/opt-script.test
@@ -0,0 +1,15 @@
+2012-03-17 KFC
+ Expenses:Food 20 CAD
+ Assets:Cash
+
+test --script test/baseline/opt-script.dat
+ -20 CAD Assets:Cash
+ 20 CAD Expenses:Food
+--------------------
+ 0
+12-Mar-17 KFC Expenses:Food 20 CAD 20 CAD
+ Assets:Cash -20 CAD 0
+2012/03/17 KFC
+ Expenses:Food 20 CAD
+ Assets:Cash
+end test
diff --git a/test/baseline/opt-value-expr.test b/test/baseline/opt-value-expr.test
index e69de29b..8b68a80e 100644
--- a/test/baseline/opt-value-expr.test
+++ b/test/baseline/opt-value-expr.test
@@ -0,0 +1,48 @@
+
+D 1000.00 EUR
+D 1000.00 USD
+D 1000.00 DM
+
+2015-01-01 * Buy 2 FOO
+ Assets:Investments 2 FOO @@ 20.00 EUR
+ Assets:Cash -20.00 EUR
+
+2015-05-01 * Spend on food
+ Expenses:Food 20.00 USD
+ ; Just to be silly, always valuate *these* $20 as 30 DM, no matter what
+ ; the user asks for with -V or -X
+ ; VALUE:: 30 DM
+ Assets:Cash -20.00 USD
+
+P 2015-05-01 USD 20 DM
+
+P 2015-06-01 USD 22 DM
+
+test bal assets:investments -V --value-expr "25.00 EUR"
+ 50.00 EUR Assets:Investments
+end test
+
+test bal assets:investments -G --value-expr "date < [March 2015] ? 22.00 EUR : 25.00 EUR" --now "2015-02-20"
+ 24.00 EUR Assets:Investments
+end test
+
+test bal assets:investments -G --value-expr "date < [March 2015] ? 22.00 EUR : 25.00 EUR" --now "2015-03-20"
+ 30.00 EUR Assets:Investments
+end test
+
+test bal expenses:food
+ 20.00 USD Expenses:Food
+end test
+
+test bal expenses:food -V
+ 600.00 DM Expenses:Food
+end test
+
+test bal expenses:food -X "DM" --now "2015-05-02"
+ 600.00 DM Expenses:Food
+end test
+
+test bal expenses:food -X "DM" --now "2015-06-02"
+ 600.00 DM Expenses:Food
+end test
+
diff --git a/test/baseline/opt-verify-memory.test b/test/baseline/opt-verify-memory.test
deleted file mode 100644
index e69de29b..00000000
--- a/test/baseline/opt-verify-memory.test
+++ /dev/null
diff --git a/test/convert.py b/test/convert.py
index 5328c4ae..857d4d30 100755
--- a/test/convert.py
+++ b/test/convert.py
@@ -3,7 +3,7 @@
# convert.py: This script converts a Boost.Test unit test into an
# equivalent Python unit test.
#
-# Copyright (c) 2003-2015, John Wiegley. All rights reserved.
+# Copyright (c) 2003-2016, John Wiegley. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
diff --git a/test/regress/1057.test b/test/regress/1057.test
new file mode 100644
index 00000000..1cd91ee7
--- /dev/null
+++ b/test/regress/1057.test
@@ -0,0 +1,11 @@
+2014/04/03 www.amazon.fr
+ Dépense:Loisir:Ordi:Matériel 101,50 € ; disque dur portable 2,5" 2000 Go
+ Dépense:Maison:Service:Poste
+ * Passif:Crédit:BanqueAccord -171,63 €
+
+test -f test/regress/1057.test --now=2014/06/27 emacs
+(("$sourcepath/test/regress/1057.test" 1 (21308 60112 0) nil "www.amazon.fr"
+ (2 "Dépense:Loisir:Ordi:Matériel" "101,50 €" nil " disque dur portable 2,5\" 2000 Go")
+ (3 "Dépense:Maison:Service:Poste" "70,13 €" nil)
+ (4 "Passif:Crédit:BanqueAccord" "-171,63 €" t)))
+end test
diff --git a/test/regress/25A099C9.test b/test/regress/25A099C9.test
new file mode 100644
index 00000000..cfc0eabd
--- /dev/null
+++ b/test/regress/25A099C9.test
@@ -0,0 +1,61 @@
+test -f test/garbage-input.dat reg -> 29
+__ERROR__
+While parsing file "$sourcepath/test/garbage-input.dat", line 1:
+Error: Directive '/*' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 32:
+Error: Directive '/**' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 36:
+Error: Directive '/**' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 66:
+Error: No quantity specified for amount
+While parsing file "$sourcepath/test/garbage-input.dat", line 69:
+Error: Unexpected whitespace at beginning of line
+While parsing file "$sourcepath/test/garbage-input.dat", line 78:
+Error: Directive '};' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 82:
+Error: Directive '/**' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 93:
+Error: Unexpected whitespace at beginning of line
+While parsing file "$sourcepath/test/garbage-input.dat", line 97:
+Error: Directive '{' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 98:
+Error: Directive 'public:' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 120:
+Error: Directive 'protected:' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 131:
+Error: Directive 'public:' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 711:
+Error: Unexpected whitespace at beginning of line
+While parsing file "$sourcepath/test/garbage-input.dat", line 740:
+Error: Directive 'private:' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 749:
+Error: Unexpected whitespace at beginning of line
+While parsing file "$sourcepath/test/garbage-input.dat", line 750:
+Error: Directive '};' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 752:
+Error: Invalid date/time: line amount_t amoun
+While parsing file "$sourcepath/test/garbage-input.dat", line 756:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 758:
+Error: Invalid date/time: line string amount_
+While parsing file "$sourcepath/test/garbage-input.dat", line 762:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 764:
+Error: Invalid date/time: line string amount_
+While parsing file "$sourcepath/test/garbage-input.dat", line 768:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 770:
+Error: Invalid date/time: line string amount_
+While parsing file "$sourcepath/test/garbage-input.dat", line 774:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 776:
+Error: Invalid date/time: line std::ostream&
+While parsing file "$sourcepath/test/garbage-input.dat", line 782:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 783:
+Error: Invalid date/time: line std::istream&
+While parsing file "$sourcepath/test/garbage-input.dat", line 786:
+Error: Directive '}' requires an argument
+While parsing file "$sourcepath/test/garbage-input.dat", line 789:
+Error: Unexpected whitespace at beginning of line
+end test
diff --git a/test/regress/25A099C9.test.disable b/test/regress/25A099C9.test.disable
deleted file mode 100644
index e511c799..00000000
--- a/test/regress/25A099C9.test.disable
+++ /dev/null
@@ -1,43 +0,0 @@
-test -f test/garbage-input.dat reg -> 20
-__ERROR__
-While parsing file "$sourcepath/test/garbage-input.dat", line 2:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 33:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 37:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 66:
-Error: No quantity specified for amount
-While parsing file "$sourcepath/test/garbage-input.dat", line 69:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 83:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 93:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 99:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 121:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 132:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 711:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 741:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 749:
-Error: Unexpected whitespace at beginning of line
-While parsing file "$sourcepath/test/garbage-input.dat", line 752:
-Error: Invalid date/time: line amount_t amoun
-While parsing file "$sourcepath/test/garbage-input.dat", line 758:
-Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/test/garbage-input.dat", line 764:
-Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/test/garbage-input.dat", line 770:
-Error: Invalid date/time: line string amount_
-While parsing file "$sourcepath/test/garbage-input.dat", line 776:
-Error: Invalid date/time: line std::ostream&
-While parsing file "$sourcepath/test/garbage-input.dat", line 783:
-Error: Invalid date/time: line std::istream&
-While parsing file "$sourcepath/test/garbage-input.dat", line 789:
-Error: Unexpected whitespace at beginning of line
-end test
diff --git a/test/regress/8EAF77C0.test b/test/regress/8EAF77C0.test
index 9d63951d..074160cc 100644
--- a/test/regress/8EAF77C0.test
+++ b/test/regress/8EAF77C0.test
@@ -1,6 +1,6 @@
2011/08/05 Rehab Donation
Asset:Bank:Boi:Current:Dk 10
- Expense:Misc:Charity
+ Expenses:Misc:Charity
2011/08/07 Net Salary
Asset:Bank:Boi:Savings:Dk -3016.24
diff --git a/test/regress/AEDE9734.test b/test/regress/AEDE9734.test
index cd2245b8..81315779 100644
--- a/test/regress/AEDE9734.test
+++ b/test/regress/AEDE9734.test
@@ -1,12 +1,12 @@
2011-02-23 Rocket Fuel
- Expense:Travel $100000000.00 ; trip: Moon
+ Expenses:Travel $100000000.00 ; trip: Moon
Asset:NASA
2011-02-23 Liquid Oxygen
- Expense:Travel $232233223.00 ; trip: Moon
+ Expenses:Travel $232233223.00 ; trip: Moon
Asset:NASA
test bal --group-by "tag('trip')"
Moon
- $332233223.00 Expense:Travel
+ $332233223.00 Expenses:Travel
end test
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 23bb0ea4..9cacb4e7 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -1,15 +1,24 @@
macro(add_ledger_test _name)
target_link_libraries(${_name} libledger)
add_test(Ledger${_name} ${PROJECT_BINARY_DIR}/${_name})
+ set_tests_properties(Ledger${_name}
+ PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}")
endmacro(add_ledger_test _name)
include_directories(${PROJECT_SOURCE_DIR}/src)
if (BUILD_LIBRARY)
add_executable(UtilTests t_times.cc)
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
+ target_link_libraries(UtilTests ${PYTHON_LIBRARIES})
+ endif()
add_ledger_test(UtilTests)
- add_executable(MathTests t_amount.cc t_commodity.cc t_balance.cc t_expr.cc)
+ add_executable(MathTests t_amount.cc t_commodity.cc t_balance.cc t_expr.cc t_value.cc)
+ set_source_files_properties(t_amount.cc t_value.cc PROPERTIES COMPILE_FLAGS "-Wno-unused-comparison")
+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin AND HAVE_BOOST_PYTHON)
+ target_link_libraries(MathTests ${PYTHON_LIBRARIES})
+ endif()
add_ledger_test(MathTests)
set_target_properties(check PROPERTIES DEPENDS LedgerUtilTests)
diff --git a/test/unit/t_value.cc b/test/unit/t_value.cc
new file mode 100644
index 00000000..2daedcb1
--- /dev/null
+++ b/test/unit/t_value.cc
@@ -0,0 +1,711 @@
+#define BOOST_TEST_DYN_LINK
+
+#include <boost/test/unit_test.hpp>
+
+#include <system.hh>
+
+#include "value.h"
+
+using namespace ledger;
+
+struct value_fixture {
+ value_fixture() {
+ times_initialize();
+ amount_t::initialize();
+ value_t::initialize();
+
+
+ // Cause the display precision for dollars to be initialized to 2.
+ amount_t x1("$1.00");
+ BOOST_CHECK(x1);
+
+ amount_t::stream_fullstrings = true; // make reports from UnitTests accurate
+ }
+
+ ~value_fixture()
+ {
+ amount_t::stream_fullstrings = false;
+ amount_t::shutdown();
+ times_shutdown();
+ value_t::shutdown();
+ }
+};
+
+BOOST_FIXTURE_TEST_SUITE(value, value_fixture)
+
+BOOST_AUTO_TEST_CASE(testConstructors)
+{
+ value_t::sequence_t s1;
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::from_time_t(time_t(NULL)));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(2L);
+ value_t v6(4UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("3 EUR"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("tag"), true);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testAssignment)
+{
+ value_t::sequence_t s1;
+ value_t v1;
+ value_t v2 = true;
+ value_t v3 = boost::posix_time::from_time_t(time_t(NULL));
+ value_t v4 = date_t(parse_date("2014/08/14"));
+ value_t v5 = -2L;
+ value_t v6 = 4UL;
+ value_t v7 = 1.00;
+ value_t v8 = amount_t("4 GBP");
+ value_t v9 = balance_t("3 EUR");
+ value_t v10 = mask_t("regex");
+ value_t v11 = s1;
+ value_t v12 = value_t(string("$1"));
+ value_t v13 = value_t("2 CAD");
+ value_t v14 = value_t("comment", true);
+ value_t v15 = value_t(string("tag"), true);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testEquality)
+{
+ struct tm localtime;
+ strptime("10 February 2010", "%d %b %Y", &localtime);
+ value_t::sequence_t s1;
+
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::ptime_from_tm(localtime));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(2L);
+ value_t v6(2UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+ value_t v16;
+
+ BOOST_CHECK_EQUAL(v1, value_t());
+ BOOST_CHECK_EQUAL(v2, value_t(true));
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+ BOOST_CHECK(!(v4 == value_t(date_t(parse_date("2014/08/15")))));
+
+ value_t v19(amount_t("2"));
+ value_t v20(balance_t("2"));
+ BOOST_CHECK_EQUAL(v5, v6);
+ BOOST_CHECK_EQUAL(v5, v19);
+ BOOST_CHECK_EQUAL(v5, v20);
+ BOOST_CHECK(v19 == v5);
+ BOOST_CHECK(v19 == v20);
+ BOOST_CHECK(v19 == value_t(amount_t("2")));
+ BOOST_CHECK(v20 == v5);
+ BOOST_CHECK(v20 == v19);
+ BOOST_CHECK(v20 == value_t(balance_t(2L)));
+ BOOST_CHECK(v14 == v15);
+ BOOST_CHECK(v10 == value_t(mask_t("regex")));
+ BOOST_CHECK(v11 == value_t(s1));
+
+ BOOST_CHECK_THROW(v8 == v10, value_error);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+ BOOST_CHECK(v19.valid());
+ BOOST_CHECK(v20.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testSequence)
+{
+ value_t::sequence_t s1;
+ value_t v1(s1);
+ BOOST_CHECK(v1.is_sequence());
+ v1.push_back(value_t(2L));
+ v1.push_back(value_t("3 GBP"));
+
+ value_t v2("3 GBP");
+ value_t seq(v1);
+ const value_t v3(seq);
+
+ value_t::sequence_t::iterator i = std::find(seq.begin(), seq.end(), v2);
+ if (i != seq.end())
+ BOOST_CHECK(v2 == *i);
+
+ value_t::sequence_t::const_iterator j = std::find(v3.begin(), v3.end(), v2);
+ if (j != v3.end())
+ BOOST_CHECK(v2 == *j);
+
+ BOOST_CHECK(v2 == seq[1]);
+ BOOST_CHECK(v2 == v3[1]);
+ v1.pop_back();
+ v1.pop_back();
+ v1.push_front(v2);
+ v1.push_front(value_t(2L));
+ BOOST_CHECK(v2 == v1[1]);
+ BOOST_CHECK(seq == v1);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(seq.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testAddition)
+{
+ struct tm localtime;
+ strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime);
+ value_t::sequence_t s1;
+
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::ptime_from_tm(localtime));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(2L);
+ value_t v6(2UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+ value_t v16(amount_t("2"));
+
+ v14 += v15;
+ BOOST_CHECK_EQUAL(v14, value_t(string("commentcomment"), true));
+ v14 += v12;
+ BOOST_CHECK_EQUAL(v14, value_t(string("commentcomment$1.00"), true));
+
+ strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime);
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+ v3 += value_t(2L);
+ strptime("10 February 2010 00:00:02", "%d %b %Y %H:%M:%S", &localtime);
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+ v3 += value_t(amount_t("2"));
+ strptime("10 February 2010 00:00:04", "%d %b %Y %H:%M:%S", &localtime);
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+
+ v4 += value_t(2L);
+ BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/16"))));
+ v4 += value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/18"))));
+
+ v5 += value_t(2L);
+ BOOST_CHECK_EQUAL(v5, value_t(4L));
+ v5 += value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v5, value_t(amount_t("6")));
+ v5 += v8;
+
+ v16 += value_t(2L);
+ v16 += value_t(amount_t("2"));
+ v16 += v8;
+ BOOST_CHECK_EQUAL(v5, v16);
+
+ v8 += value_t("6");
+ BOOST_CHECK_EQUAL(v8, v16);
+
+ value_t v17(6L);
+ v17 += value_t(amount_t("4 GBP"));
+ BOOST_CHECK_EQUAL(v8, v17);
+
+ value_t v18(6L);
+ v18 += v9;
+ value_t v19(amount_t("6"));
+ v19 += v9;
+ BOOST_CHECK_EQUAL(v18, v19);
+
+ v9 += value_t(2L);
+ v9 += value_t(amount_t("4"));
+ v9 += v19;
+ v18 += v19;
+ BOOST_CHECK_EQUAL(v9, v18);
+
+ value_t v20(s1);
+ v11 += value_t(2L);
+ v11 += value_t("4 GBP");
+ BOOST_CHECK_THROW(v11 += v20,value_error);
+ BOOST_CHECK_THROW(v10 += v8, value_error);
+
+ v20 += value_t(2L);
+ v20 += value_t("4 GBP");
+ BOOST_CHECK_EQUAL(v11, v20);
+ v11 += v20;
+ v20 += v20;
+ BOOST_CHECK_EQUAL(v11, v20);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+ BOOST_CHECK(v16.valid());
+ BOOST_CHECK(v17.valid());
+ BOOST_CHECK(v18.valid());
+ BOOST_CHECK(v19.valid());
+ BOOST_CHECK(v20.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testSubtraction)
+{
+ struct tm localtime;
+ strptime("10 February 2010 00:00:04", "%d %b %Y %H:%M:%S", &localtime);
+ value_t::sequence_t s1;
+
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::ptime_from_tm(localtime));
+ value_t v4(date_t(parse_date("2014/08/18")));
+ value_t v5(6L);
+ value_t v6(6UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+ value_t v16(amount_t("6"));
+
+ v3 -= value_t(2L);
+ strptime("10 February 2010 00:00:02", "%d %b %Y %H:%M:%S", &localtime);
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+ v3 -= value_t(amount_t("2"));
+ strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime);
+ BOOST_CHECK_EQUAL(v3, value_t(boost::posix_time::ptime_from_tm(localtime)));
+
+ v4 -= value_t(2L);
+ BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/16"))));
+ v4 -= value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v4, value_t(date_t(parse_date("2014/08/14"))));
+
+ v5 -= value_t(2L);
+ BOOST_CHECK_EQUAL(v5, value_t(4L));
+ v5 -= value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v5, value_t(amount_t("2")));
+ v5 -= v8;
+
+ v16 -= value_t(2L);
+ v16 -= value_t(amount_t("2"));
+ v16 -= v8;
+ BOOST_CHECK_EQUAL(v5, v16);
+
+ v8 -= value_t("2");
+ BOOST_CHECK_EQUAL(-v8, v16);
+
+ value_t v18(6L);
+ v18 -= v9;
+ value_t v19(amount_t("6"));
+ v19 -= v9;
+ BOOST_CHECK_EQUAL(v18, v19);
+
+ v9 -= value_t(-2L);
+ v9 -= value_t(amount_t("-10"));
+ v9 -= value_t(amount_t("12 GBP"));
+ v9 -= v19;
+ BOOST_CHECK_EQUAL(v9, v18);
+ v18 -=v19;
+ BOOST_CHECK_EQUAL(v18, value_t("0"));
+
+ value_t v20(s1);
+ value_t v21(2L);
+ value_t v22("4 GBP");
+ v11.push_back(v21);
+ v11.push_back(v22);
+ BOOST_CHECK_THROW(v11 -= v20,value_error);
+ BOOST_CHECK_THROW(v10 -= v8, value_error);
+
+ v20.push_back(v21);
+ v20.push_back(v22);
+ v11 -= v20;
+ value_t v23(s1);
+ v23.push_back(value_t(0L));
+ v23.push_back(value_t("0"));
+ BOOST_CHECK_EQUAL(v11, v23);
+ v20 -= v21;
+ v20 -= v22;
+ BOOST_CHECK_EQUAL(v20, value_t(s1));
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+ BOOST_CHECK(v16.valid());
+ BOOST_CHECK(v18.valid());
+ BOOST_CHECK(v19.valid());
+ BOOST_CHECK(v20.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testMultiplication)
+{
+ struct tm localtime;
+ strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime);
+ value_t::sequence_t s1;
+
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::ptime_from_tm(localtime));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(2L);
+ value_t v6(2UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+ value_t v16(amount_t("2"));
+
+ v14 *= value_t(2L);
+ BOOST_CHECK_EQUAL(v14, value_t(string("commentcomment"), true));
+
+ v5 *= value_t(2L);
+ BOOST_CHECK_EQUAL(v5, value_t(4L));
+ v5 *= value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v5, value_t(amount_t("8")));
+
+ v16 *= value_t(2L);
+ v16 *= value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v5, v16);
+
+ v8 *= v9;
+ BOOST_CHECK_EQUAL(v8, value_t("16 GBP"));
+
+ value_t v17(v9);
+ v9 *= value_t(2L);
+ BOOST_CHECK_EQUAL(v9, value_t("8 GBP"));
+ v17 += value_t(2L);
+ v17 *= value_t(2L);
+ value_t v18("8 GBP");
+ v18 += value_t(4L);
+ BOOST_CHECK_EQUAL(v17, v18);
+
+ value_t v20(s1);
+ v11.push_back(value_t(2L));
+ v11.push_back(value_t("2 GBP"));
+ v20.push_back(value_t(4L));
+ v20.push_back(value_t("4 GBP"));
+ v11 *= value_t(2L);
+ BOOST_CHECK_EQUAL(v11 ,v20);
+
+ BOOST_CHECK_THROW(v10 *= v8, value_error);
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+ BOOST_CHECK(v16.valid());
+ BOOST_CHECK(v17.valid());
+ BOOST_CHECK(v18.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testDivision)
+{
+ struct tm localtime;
+ strptime("10 February 2010 00:00:00", "%d %b %Y %H:%M:%S", &localtime);
+ value_t::sequence_t s1;
+
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::ptime_from_tm(localtime));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(8L);
+ value_t v6(2UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+ value_t v16(amount_t("8"));
+
+ v5 /= value_t(2L);
+ BOOST_CHECK_EQUAL(v5, value_t(4L));
+ v5 /= value_t(amount_t("8"));
+ BOOST_CHECK_EQUAL(v5, value_t(amount_t("2")));
+
+ v16 /= value_t(2L);
+ v16 /= value_t(amount_t("2"));
+ BOOST_CHECK_EQUAL(v5, v16);
+
+ v8 /= v9;
+ v8 /= value_t(balance_t(2L));
+ BOOST_CHECK_EQUAL(v8, value_t("0.5 GBP"));
+
+ value_t v17(v9);
+ v9 /= value_t(2L);
+ BOOST_CHECK_EQUAL(v9, value_t("2 GBP"));
+ v17 /= value_t("2 GBP");
+ v17 /= value_t("2");
+ BOOST_CHECK_EQUAL(v17, value_t(balance_t("1 GBP")));
+
+ BOOST_CHECK_THROW(v10 /= v8, value_error);
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+ BOOST_CHECK(v16.valid());
+ BOOST_CHECK(v17.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testType)
+{
+ value_t::sequence_t s1;
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::from_time_t(time_t(NULL)));
+ value_t v4(date_t(parse_date("2014/08/14")));
+ value_t v5(2L);
+ value_t v6(4UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("3 EUR"));
+ value_t v10(mask_t("regex"));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string("tag"), true);
+
+ BOOST_CHECK(v1.is_null());
+ BOOST_CHECK(v2.is_boolean());
+ BOOST_CHECK(v3.is_datetime());
+ BOOST_CHECK(v4.is_date());
+ BOOST_CHECK(v5.is_long());
+ BOOST_CHECK(v6.is_amount());
+ BOOST_CHECK(v7.is_amount());
+ BOOST_CHECK(v8.is_amount());
+ BOOST_CHECK(v9.is_balance());
+ BOOST_CHECK(v10.is_mask());
+ BOOST_CHECK(v11.is_sequence());
+ BOOST_CHECK(v12.is_amount());
+ BOOST_CHECK(v13.is_amount());
+ BOOST_CHECK(v14.is_string());
+ BOOST_CHECK(v15.is_string());
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testForZero)
+{
+ value_t::sequence_t s1;
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::from_time_t(time_t(NULL)));
+ value_t v4(date_t(0));
+ value_t v5(2L);
+ value_t v6(0UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("0"));
+ value_t v10(mask_t(""));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("2 CAD");
+ value_t v14("comment", true);
+ value_t v15(string(""), true);
+
+ BOOST_CHECK(v1.is_null());
+ BOOST_CHECK(v2.is_nonzero());
+ BOOST_CHECK(!v3.is_zero());
+ BOOST_CHECK(v4.is_nonzero());
+ BOOST_CHECK(v5.is_nonzero());
+ BOOST_CHECK(v6.is_realzero());
+ BOOST_CHECK(v7.is_nonzero());
+ BOOST_CHECK(v8.is_nonzero());
+ BOOST_CHECK(v9.is_zero());
+ BOOST_CHECK_THROW(v10.is_zero(), value_error);
+ BOOST_CHECK(v11.is_zero());
+ BOOST_CHECK(v12.is_nonzero());
+ BOOST_CHECK(v13.is_nonzero());
+ BOOST_CHECK(v14.is_nonzero());
+ BOOST_CHECK(v15.is_zero());
+
+ v11.push_back(v6);
+ BOOST_CHECK(v11.is_nonzero());
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+}
+
+BOOST_AUTO_TEST_CASE(testNegation)
+{
+ value_t::sequence_t s1;
+ value_t v1;
+ value_t v2(true);
+ value_t v3(boost::posix_time::from_time_t(time_t(NULL)));
+ value_t v4(date_t(parse_date("2014/08/09")));
+ value_t v5(2L);
+ value_t v6(0UL);
+ value_t v7(1.00);
+ value_t v8(amount_t("4 GBP"));
+ value_t v9(balance_t("4 GBP"));
+ value_t v10(mask_t(""));
+ value_t v11(s1);
+ value_t v12(string("$1"));
+ value_t v13("$-1");
+ value_t v14("comment", true);
+ value_t v15(string("comment"), true);
+
+ BOOST_CHECK_THROW(v1.negated(), value_error);
+ BOOST_CHECK_EQUAL(v2.negated(), value_t(false));
+ v5.in_place_negate();
+ BOOST_CHECK_EQUAL(v5, value_t(-2L));
+ v8.in_place_negate();
+ v9.in_place_negate();
+ BOOST_CHECK_EQUAL(v8, v9);
+ BOOST_CHECK_THROW(v10.negated(), value_error);
+ BOOST_CHECK_EQUAL(-v12, v13);
+ BOOST_CHECK_THROW(-v14, value_error);
+
+ BOOST_CHECK(v1.valid());
+ BOOST_CHECK(v2.valid());
+ BOOST_CHECK(v3.valid());
+ BOOST_CHECK(v4.valid());
+ BOOST_CHECK(v5.valid());
+ BOOST_CHECK(v6.valid());
+ BOOST_CHECK(v7.valid());
+ BOOST_CHECK(v8.valid());
+ BOOST_CHECK(v9.valid());
+ BOOST_CHECK(v10.valid());
+ BOOST_CHECK(v11.valid());
+ BOOST_CHECK(v12.valid());
+ BOOST_CHECK(v13.valid());
+ BOOST_CHECK(v14.valid());
+ BOOST_CHECK(v15.valid());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg
index ab351760..d2f927c0 100755
--- a/tools/prepare-commit-msg
+++ b/tools/prepare-commit-msg
@@ -5,17 +5,17 @@
# Add [ci skip] to the commit message unless there are changes to files
# that are relevant for testing such as src/*, test/*, ledger3.texi, ...
-function add_ci_skip()
+add_ci_skip ()
{
pattern="$1"; shift
source="$1"
# Don't add [ci skip] if it's already in the commit message source
- grep '\[ci skip\]' "$source" 2>&1 >/dev/null
+ grep '\[ci skip\]' "$source" >/dev/null 2>&1
[ $? -eq 0 ] && return
if [ $(git diff --cached --name-only | grep --count "$pattern") -eq 0 ]; then
- tempfile=$(mktemp $0.XXXXXX)
+ tempfile=$(mktemp "${0}.XXXXXX")
cat - "$1" <<EOF > "$tempfile"
# It seems the changes to be committed are irrelevant for the continuous
diff --git a/tools/travis-before_install.sh b/tools/travis-before_install.sh
new file mode 100755
index 00000000..fe010945
--- /dev/null
+++ b/tools/travis-before_install.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+#set -x
+set -e
+set -o pipefail
+
+if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
+ brew update
+fi
+
+if [ -n "${BOOST_VERSION}" ]; then
+ mkdir -p $BOOST_ROOT
+ wget --no-verbose --output-document=- \
+ http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION//./_}.tar.bz2/download \
+ | tar jxf - --strip-components=1 -C "${BOOST_ROOT}"
+fi
diff --git a/tools/travis-install.sh b/tools/travis-install.sh
new file mode 100755
index 00000000..4e8bdc48
--- /dev/null
+++ b/tools/travis-install.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+#set -x
+set -e
+set -o pipefail
+
+if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
+ for formula in $(echo "${BREWS//,/ }"); do
+ echo "Checking ${formula} formula"
+ brew outdated "${formula}" \
+ || (brew unlink "${formula}"
+ brew install "${formula}"
+ )
+ done
+fi
+
+if [ -d "${BOOST_ROOT}" ]; then
+ (cd "${BOOST_ROOT}"
+ ./bootstrap.sh --with-libraries="${BOOST_LIBS}"
+ ./b2 threading=multi --prefix="${BOOST_ROOT}" -d0 install
+ )
+fi
diff --git a/tools/update_copyright_year.sh b/tools/update_copyright_year.sh
new file mode 100755
index 00000000..ea0a5d35
--- /dev/null
+++ b/tools/update_copyright_year.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# update_copyright_year - Update the year of the Copyright statement in files
+#
+# This script will replace the last year of Copyright statements with the first
+# argument of this script (defaulting to the current year).
+
+# Copyright (c) 2016 Alexis Hildebrandt
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+YEAR=${1:-$(date +%Y)}
+# egrep is rather slow, but the much faster ag (the-silver-searcher)
+# is not generally installed
+GREP=${2:-egrep}
+
+${GREP} -Rl 'Copyright.*Wiegley' . \
+ | ${GREP} -v "(test/garbage-input.dat|$(basename $0))" \
+ | xargs sed -i '' -e "s/\(Copyright.*\)-20[0-9]\{2\}/\1-${YEAR}/"
+