summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dir-locals.el66
-rw-r--r--.gitignore3
-rw-r--r--.gitmodules3
-rw-r--r--.travis.yml4
-rw-r--r--CMakeLists.txt33
-rw-r--r--CONTRIBUTING.md110
-rw-r--r--INSTALL.md174
-rw-r--r--LICENSE.md (renamed from doc/LICENSE)0
-rw-r--r--README-1ST173
-rw-r--r--README.md169
-rwxr-xr-xacprep39
-rw-r--r--cmake/FindUtfcpp.cmake30
-rw-r--r--contrib/raw/dotemacs.el82
-rw-r--r--contrib/raw/ledger-matching.el92
-rw-r--r--doc/CMakeLists.txt4
-rw-r--r--doc/DEVELOP.md81
-rw-r--r--doc/DEVELOP.md.new0
-rw-r--r--doc/LICENSE.rtfbin1719 -> 0 bytes
-rw-r--r--doc/NEWS24
-rw-r--r--doc/ledger-mode.texi121
-rw-r--r--doc/ledger.11154
-rw-r--r--doc/ledger3.texi1497
-rw-r--r--doc/version.texi.in8
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-commodities.el8
-rw-r--r--lisp/ledger-complete.el4
-rw-r--r--lisp/ledger-context.el4
-rw-r--r--lisp/ledger-exec.el2
-rw-r--r--lisp/ledger-fontify.el241
-rw-r--r--lisp/ledger-init.el4
-rw-r--r--lisp/ledger-mode.el22
-rw-r--r--lisp/ledger-navigate.el162
-rw-r--r--lisp/ledger-occur.el30
-rw-r--r--lisp/ledger-post.el18
-rw-r--r--lisp/ledger-reconcile.el307
-rw-r--r--lisp/ledger-regex.el28
-rw-r--r--lisp/ledger-report.el76
-rw-r--r--lisp/ledger-schedule.el168
-rw-r--r--lisp/ledger-sort.el14
-rw-r--r--lisp/ledger-state.el4
-rw-r--r--lisp/ledger-xact.el5
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/account.h26
-rw-r--r--src/amount.cc79
-rw-r--r--src/amount.h10
-rw-r--r--src/annotate.h48
-rw-r--r--src/archive.cc295
-rw-r--r--src/archive.h92
-rw-r--r--src/balance.h12
-rw-r--r--src/commodity.h61
-rw-r--r--src/expr.h13
-rw-r--r--src/exprbase.h15
-rw-r--r--src/filters.cc2
-rw-r--r--src/flags.h22
-rw-r--r--src/global.cc21
-rw-r--r--src/global.h6
-rw-r--r--src/item.h42
-rw-r--r--src/iterators.cc2
-rw-r--r--src/journal.h35
-rw-r--r--src/lookup.cc2
-rw-r--r--src/mask.h19
-rw-r--r--src/op.h27
-rw-r--r--src/output.cc6
-rw-r--r--src/output.h10
-rw-r--r--src/parser.h2
-rw-r--r--src/pool.h20
-rw-r--r--src/post.h24
-rw-r--r--src/predicate.h13
-rw-r--r--src/py_item.cc14
-rw-r--r--src/report.cc5
-rw-r--r--src/report.h6
-rw-r--r--src/scope.h99
-rw-r--r--src/session.cc99
-rw-r--r--src/session.h2
-rw-r--r--src/system.hh.in80
-rw-r--r--src/times.h92
-rw-r--r--src/value.h28
-rw-r--r--src/xact.h72
-rw-r--r--test/CMakeLists.txt11
-rwxr-xr-xtest/CheckBaselineTests.py77
-rwxr-xr-xtest/CheckManpage.py45
-rwxr-xr-xtest/CheckOptions.py98
-rwxr-xr-xtest/CheckTests.py87
-rwxr-xr-xtest/CheckTexinfo.py116
-rwxr-xr-xtest/DocTests.py107
-rwxr-xr-xtest/GenerateTests.py4
-rwxr-xr-xtest/RegressTests.py3
-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/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-no-titles.test10
-rw-r--r--test/baseline/opt-permissive.test19
-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-values.test6
-rw-r--r--test/baseline/opt-verify-memory.test0
-rw-r--r--test/regress/1102.test8
-rw-r--r--test/regress/1106.test11
-rw-r--r--test/regress/25A099C9.test61
-rw-r--r--test/regress/25A099C9.test.disable43
-rw-r--r--test/regress/634AA589.test19
-rw-r--r--test/unit/CMakeLists.txt7
-rw-r--r--test/unit/t_balance.cc3
-rwxr-xr-xtools/prepare-commit-msg19
-rwxr-xr-xtools/travis-before_install.sh1
-rwxr-xr-xtools/travis-install.sh1
127 files changed, 5069 insertions, 3383 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 5f026e6c..06ead752 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,8 @@
# 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:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca82084e..e455ec02 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,9 +8,13 @@ PROJECT(ledger)
set(Ledger_VERSION_MAJOR 3)
set(Ledger_VERSION_MINOR 1)
-set(Ledger_VERSION_PATCH 0)
+set(Ledger_VERSION_PATCH 1)
+set(Ledger_VERSION_PRERELEASE "-alpha.1")
set(Ledger_VERSION_DATE 20141005)
+# Point CMake at any custom modules we may ship
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+
enable_testing()
add_definitions(-std=c++11)
@@ -224,7 +228,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()
@@ -236,13 +247,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(
@@ -267,11 +285,12 @@ add_subdirectory(test)
# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
-set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/doc/LICENSE.rtf")
+set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.md")
set (CPACK_PACKAGE_VERSION_MAJOR "${Ledger_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${Ledger_VERSION_MINOR}")
-set (CPACK_PACKAGE_VERSION_PATCH "${Ledger_VERSION_PATCH}")
+set (CPACK_PACKAGE_VERSION_PATCH "${Ledger_VERSION_PATCH}${Ledger_VERSION_PRERELEASE}")
+set (CPACK_GENERATOR "TBZ2")
set (CPACK_SOURCE_GENERATOR "TBZ2")
set (CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a4b8b14f..bab3f7c8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,115 @@ Tips for contributors
---------------------
* Please **make pull requests against `next`, not `master`**.
- Ledger follows a [git-flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model,
+ Ledger follows a [git-flow] branching model,
in which development happens on the `next` branch and is subsequently merged into `master` for releases.
* If you're making **changes to `ledger-mode`, or other files for which the Travis build is not
relevant**, please **add `[ci skip]` to the end of the commit message**.
+
+GLOSSARY
+----
+
+Developing the Ledger software uses a number different tools, not all of
+which will be familiar to all developers.
+
+**[Boost]**: a standard set of C++ libraries. Most
+Boost libraries consist of inline functions and templates in header files.
+
+**[Boost.Python]**: C++ library which enables seamless interoperability
+between C++ and the Python programming language.
+
+**[Cheetah]**: a Python templating engine, used by `./python/server.py`.
+
+**[CMake]**: A cross platform system for building from source code. It uses
+the `CMakeLists.txt` files.
+
+**[Doxygen]**: generates programming documentation from
+source code files. Primarily used on C++ sources, but works on all. Uses
+the `doc/Doxyfile.in` file.
+
+**[GCC]**: Gnu Compiler Collection, which includes the
+*gcc* compiler and *gcov* coverage/profiler tool.
+
+**[clang]**: C language family frontend for LLVM, which
+includes the *clang* compiler.
+
+**[GMP]**: Gnu Multiple Precision Arithmetic Library
+provides arbitrary precision math.
+
+**[MPFR]**: Gnu Multiple Precision Floating-point Library
+with correct rounding.
+
+**[Markdown]**: A typesetter
+format that produces *html* files from *.md* files. Note that GitHub
+automatically renders *.md* files.
+
+**[SHA1]**: a marginally secure cryptographic hash function, used only for
+signing the license file.
+
+**[Texinfo]**: Gnu documentation
+typesetter that produces *html* and *pdf* files from the `doc/\*.texi` files.
+
+**[Travis CI]**: a hosted continuous integration
+ service that builds and runs tests each commit posted to GitHub. Each
+ build creates a [log], updates a [small badge] at
+ the top left of the main project's
+ [README.md], and
+ emails the author of the commit if any tests fail.
+
+**[utfcpp]**: a library for handling utf-8 in a variety of C++ versions.
+
+
+Orientation
+---
+
+The source tree can be confusing to a new developer. Here is a selective
+orientation:
+
+**./acprep**: a custom thousand-line script to install dependencies, grab
+ updates, and build. It also creates `\*.cmake`,
+ `./CmakeFiles/` and other CMake temporary files. Use `./acprep --help`
+ for more information.
+
+**./README.md**: user readme file in markdown format, also used as the project
+ description on GitHub.
+
+**./contrib/**: contributed scripts of random quality and completion. They
+ usually require editing to run.
+
+**./doc/**: documentation, licenses, and
+ tools for generating documents such as the *pdf* manual.
+
+**./lib/**: a couple of libraries used in development.
+
+**./lisp/**: the [Emacs][] [ledger-mode] lisp code, under the [GPLv2] license.
+
+**./python/**: samples using the Python ledger module.
+
+**./src/**: the C++ header and source files in a flat directory.
+
+**./test/**: a testing harness with subdirectories full of tests
+
+**./tools/**: an accretion of tools, mostly small scripts, to aid development
+
+
+[Boost]: http://boost.org
+[Boost.Python]: http://www.boost.org/libs/python/
+[GMP]: http://gmplib.org/
+[MPFR]: http://www.mpfr.org/
+[Cheetah]: http://www.cheetahtemplate.org
+[CMake]: http://www.cmake.org
+[Doxygen]: http://doxygen.org
+[Markdown]: https://daringfireball.net/projects/markdown/
+[SHA1]: http://en.wikipedia.org/wiki/SHA-1
+[Texinfo]: http://www.gnu.org/software/texinfo/
+[Travis CI]: https://travis-ci.org
+[GCC]: http://gcc.gnu.org
+[utfcpp]: http://utfcpp.sourceforge.net
+[log]: https://travis-ci.org/ledger/ledger
+[small badge]: https://img.shields.io/travis/ledger/ledger/master.svg?&style=flat
+[git-flow]: http://nvie.com/posts/a-successful-git-branching-model/
+[README.md]: https://github.com/ledger/ledger/blob/master/README.md
+[Emacs]: http://www.gnu.org/software/emacs/
+[ledger-mode]: http://ledger-cli.org/3.0/doc/ledger-mode.html
+[GPLv2]: http://www.gnu.org/licenses/gpl-2.0.html
+[clang]: http://clang.llvm.org
diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 00000000..62de2a97
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,174 @@
+# INSTALL
+
+To build this code after doing a Git clone, run:
+
+ $ ./acprep update
+
+If anything goes wrong, see "COMMON CONFIGURE/BUILD PROBLEMS" below.
+
+If you try to configure and build without running acprep first, you are
+almost certainly going to run into problems. In future, you can run
+`acprep update` again and again, and it will keep you updated to the
+very latest version.
+
+Now install it:
+
+ $ sudo make install
+
+
+## COMMON CONFIGURE / BUILD PROBLEMS
+
+To build and install Ledger requires several dependencies on various
+platforms. You can install these dependencies very simply for most of them
+using:
+
+ $ ./acprep dependencies
+
+The first order of business if acprep update doesn't work is to find out where
+things went wrong. So follow these steps to produce a bug report I can track
+down easily:
+
+ $ ./acprep --debug update # shows what acprep was thinking
+ $ $EDITOR CMakeCache.txt # shows what cmake was thinking
+
+With the contents of config.log, and the output from acprep --debug update,
+it's usually fairly obvious where things have gone astray.
+
+
+## F.A.Q.
+
+
+Q: The build fails saying it can't find `utf8.h`
+
+A: You didn't run `./acprep update`.
+
+----------------------------------------------------------------------
+
+Q: `./acprep update` gives errors or `./acprep dependencies` fails
+
+A: You're probably missing some dependency libraries. If you tried
+ `./acprep dependencies` already and that didn't solve the problem,
+ then you may need to install dependencies by hand. On a Debian
+ GNU/Linux system (or Debian-based system such as Ubuntu), something
+ like this should work (as root):
+
+ $ sudo apt-get install build-essential cmake texinfo python-dev \
+ zlib1g-dev libbz2-dev libgmp3-dev gettext libmpfr-dev \
+ libboost-date-time-dev libboost-filesystem-dev \
+ libboost-graph-dev libboost-iostreams-dev \
+ libboost-python-dev libboost-regex-dev libboost-test-dev \
+ doxygen libedit-dev libmpc-dev
+
+----------------------------------------------------------------------
+
+Q: Configure fails saying it can't find boost_regex
+
+A: Look in config.log and search for "boost_regex", then scroll down a bit
+ until you see the exact compile error. Usually it's failing because
+ your include directory is different from anything acprep is expecting to
+ see. It could also be failing because your Boost libraries have a
+ custom "suffix" on them.
+
+ Let's say your Boost was installed in ~/boost, and every library has the
+ suffix `-xgcc42`. This is what you would run:
+
+ $ CPPFLAGS=-I$HOME/boost acprep --boost=xgcc42 update
+
+----------------------------------------------------------------------
+
+Q: Configure fails saying it can't find MPFR
+
+A: You need MPFR version 2.4.0 or higher. This version does not come with
+ most Debian distributions, so you will need to build it. The
+ relevant packages are `libmpfr-dev` and `libmpfr-dbg`. See also
+ the question above about what to do if `./acprep update` gives
+ errors or `./acprep dependencies` fails.
+
+----------------------------------------------------------------------
+
+Q: I'm seeing a segfault deep inside the boost_regex code!
+
+A: Actually, the real segfault is in libstdc++'s facet code. It's being
+ caused by using a debug Boost with a non-debug build of Ledger, or
+ vice-versa.
+
+----------------------------------------------------------------------
+
+Q: Something else fails, or Ledger crashes on startup
+
+A: This, I am most interested in hearing about. Please file a bug
+ at the Ledger Bugzilla, http://bugs.ledger-cli.org/. The more
+ details you can provide, the better. Also, if Ledger is crashing,
+ try running it under gdb like so:
+
+ $ gdb ledger
+ (gdb) run <ARGS TO LEDGER>
+ ... runs till crash ...
+ (gdb) bt
+
+ Put that backtrace output, and the output from `ledger --version`
+ in the bug report.
+
+----------------------------------------------------------------------
+
+Q: Whenever I try to use the Python support, I get a segfault
+
+A: Make sure that the boost_python library you linked against is using the
+ exact same Python as the Ledger executable. In particular I see this
+ bug on OS X systems where boost_python is linked against the default
+ Python, while Ledger is linked against the version provided by MacPorts.
+ Or vice versa.
+
+ Solution: Use one or the other. If you prefer the system Python, run
+ `port deactivate -f python26`, to get MacPorts' version out of the way.
+ You'll then need to delete the Ledger binary and run `make` to relink
+ it.
+
+----------------------------------------------------------------------
+
+Q: When I run `make check`, the Python unit tests always crash
+
+A: This can happen for the same reason as above. It can also happen if you
+ have ICU support enabled. This is a bug I'm still trying to track down.
+
+----------------------------------------------------------------------
+
+Q: My distribution has versions of Boost and/or CMake that are too old for
+ Ledger. How do I build my own Boost and/or CMake binaries that will
+ work properly with Ledger? Thereafter, how do I configure Ledger
+ properly to use those newly built verisons of Boost and/or CMake?
+
+A: Here's commands that one user used to make this work, for Boost 1.51.0
+ on Debian GNU/Linux 6.0.x (aka Debian squeeze). It's likely to work ok
+ for other versions of Boost as well. YMMV on other distributions and/or
+ other Debian distribution versions, though.
+
+ - Preparing and building Boos
+
+ $ export BOOST_VERSION=1.57.0
+ $ cd /somewhere/you/want/to/build/boost
+ $ wget -N http://iweb.dl.sourceforge.net/project/boost/boost/$BOOST_VERSION/boost_${BOOST_VERSION//./_}.tar.bz2
+ $ tar xvf boost_${BOOST_VERSION//./_}.tar.bz2
+ $ cd boost_${BOOST_VERSION//./_}
+ $ ./bootstrap.sh
+ $ ./b2 --build-type=complete --layout=tagged --prefix=/where/you/want/boost/installed
+ $ ./b2 --build-type=complete --layout=tagged --prefix=/where/you/want/boost/installed install
+
+ - Preparing and building CMake
+
+ $ export CMAKE_VERSION=3.1.0
+ $ cd /somewhere/you/want/to/build/cmake
+ $ wget -N http://www.cmake.org/files/v${CMAKE_VERSION:0:3}/cmake-${CMAKE_VERSION}.tar.gz
+ $ tar xvf cmake-${CMAKE_VERSION}.tar.gz
+ $ cd cmake-${CMAKE_VERSION}
+ $ ./configure --prefix=/where/you/want/cmake/installed/
+ $ make
+ $ make install
+
+ - Building Ledger using the CMake and/or Boost as installed above
+
+ $ cd /path/to/ledger/sources
+ $ env PATH=/where/you/want/cmake/installed/bin:$PATH BOOST_ROOT=/where/you/want/boost/installed PREFIX=/where/you/want/ledger/installed $SHELL
+ $ ./acprep --prefix=$PREFIX --debug --python config
+ $ ./acprep --prefix=$PREFIX --debug --python make
+ $ ./acprep --prefix=$PREFIX --debug --python install
diff --git a/doc/LICENSE b/LICENSE.md
index 92be3a1d..92be3a1d 100644
--- a/doc/LICENSE
+++ b/LICENSE.md
diff --git a/README-1ST b/README-1ST
deleted file mode 100644
index 64f69411..00000000
--- a/README-1ST
+++ /dev/null
@@ -1,173 +0,0 @@
- README FIRST!!!
-
-To build this code after doing a Git clone, run:
-
- $ ./acprep update
-
-If anything goes wrong, see "COMMON CONFIGURE/BUILD PROBLEMS" below.
-
-If you try to configure and build without running acprep first, you are
-almost certainly going to run into problems. In future, you can run
-'acprep update' again and again, and it will keep you updated to the
-very latest version.
-
-Now install it:
-
- $ sudo make install
-
-===============================================================================
- COMMON CONFIGURE/BUILD PROBLEMS
-===============================================================================
-
-To build and install Ledger requires several dependencies on various
-platforms. You can install these dependencies very simply for most of them
-using:
-
- $ ./acprep dependencies
-
-The first order of business if acprep update doesn't work is to find out where
-things went wrong. So follow these steps to produce a bug report I can track
-down easily:
-
- $ ./acprep --debug update # shows what acprep was thinking
- $ <edit config.log> # shows what configure was thinking
-
-With the contents of config.log, and the output from acprep --debug update,
-it's usually fairly obvious where things have gone astray.
-
-===============================================================================
- F.A.Q.
-===============================================================================
-
-
- - Q: The build fails saying it can't find utf8.h
-
- A: You didn't run ./acprep update.
-
- ----------------------------------------------------------------------
-
- - Q: './acprep update' gives errors or './acprep dependencies' fails
-
- A: You're probably missing some dependency libraries. If you tried
- './acprep dependencies' already and that didn't solve the problem,
- then you may need to install dependencies by hand. On a Debian
- GNU/Linux system (or Debian-based system such as Ubuntu), something
- like this should work (as root):
-
- sudo apt-get install build-essential cmake texinfo python-dev \
- zlib1g-dev libbz2-dev libgmp3-dev gettext libmpfr-dev \
- libboost-date-time-dev libboost-filesystem-dev \
- libboost-graph-dev libboost-iostreams-dev \
- libboost-python-dev libboost-regex-dev libboost-test-dev \
- doxygen libedit-dev libmpc-dev
-
- ----------------------------------------------------------------------
-
- - Q: Configure fails saying it can't find boost_regex
-
- A: Look in config.log and search for "boost_regex", then scroll down a bit
- until you see the exact compile error. Usually it's failing because
- your include directory is different from anything acprep is expecting to
- see. It could also be failing because your Boost libraries have a
- custom "suffix" on them.
-
- Let's say your Boost was installed in ~/boost, and every library has the
- suffix '-xgcc42'. This is what you would run:
-
- CPPFLAGS=-I$HOME/boost acprep --boost=xgcc42 update
-
- ----------------------------------------------------------------------
-
- - Q: Configure fails saying it can't find MPFR
-
- A: You need MPFR version 2.4.0 or higher. This version does not come with
- most Debian distributions, so you will need to build it. The
- relevant packages are 'libmpfr-dev' and 'libmpfr-dbg'. See also
- the question above about what to do if './acprep update' gives
- errors or './acprep dependencies' fails.
-
- ----------------------------------------------------------------------
-
- - Q: I'm seeing a segfault deep inside the boost_regex code!
-
- A: Actually, the real segfault is in libstdc++'s facet code. It's being
- caused by using a debug Boost with a non-debug build of Ledger, or
- vice-versa.
-
- ----------------------------------------------------------------------
-
- - Q: Something else fails, or Ledger crashes on startup
-
- A: This, I am most interested in hearing about. Please file a bug
- at the Ledger Bugzilla, http://bugs.ledger-cli.org/. The more
- details you can provide, the better. Also, if Ledger is crashing,
- try running it under gdb like so:
-
- $ gdb ledger
- (gdb) run <ARGS TO LEDGER>
- ... runs till crash ...
- (gdb) bt
-
- Put that backtrace output, and the output from "ledger
- --version" in the bug report.
-
- ----------------------------------------------------------------------
-
- - Q: Whenever I try to use the Python support, I get a segfault
-
- A: Make sure that the boost_python library you linked against is using the
- exact same Python as the Ledger executable. In particular I see this
- bug on OS X systems where boost_python is linked against the default
- Python, while Ledger is linked against the version provided by MacPorts.
- Or vice versa.
-
- Solution: Use one or the other. If you prefer the system Python, run
- "port deactivate -f python26", to get MacPorts' version out of the way.
- You'll then need to delete the Ledger binary and run "make" to relink
- it.
-
- ----------------------------------------------------------------------
-
- - Q: When I run "make check", the Python unit tests always crash
-
- A: This can happen for the same reason as above. It can also happen if you
- have ICU support enabled. This is a bug I'm still trying to track down.
-
- ----------------------------------------------------------------------
-
- - Q: My distribution has versions of Boost and/or CMake that are too old for
- Ledger. How do I build my own Boost and/or CMake binaries that will
- work properly with Ledger? Thereafter, how do I configure Ledger
- properly to use those newly built verisons of Boost and/or CMake?
-
- A: Here's commands that one user used to make this work, for Boost 1.51.0
- on Debian GNU/Linux 6.0.x (aka Debian squeeze). It's likely to work ok
- for other versions of Boost as well. YMMV on other distributions and/or
- other Debian distribution versions, though.
-
- # Preparing and building Boost 1.51.0
-
- $ cd /somewhere/you/want/to/build/boost
- $ wget -N http://iweb.dl.sourceforge.net/project/boost/boost/1.51.0/boost_1_51_0.tar.bz2
- $ tar xvf boost_1_51_0.tar.bz2
- $ cd boost_1_51_0
- $ ./bootstrap.sh
- $ ./b2 --build-type=complete --layout=tagged --prefix=/where/you/want/boost/installed
- $ ./b2 --build-type=complete --layout=tagged --prefix=/where/you/want/boost/installed install
-
- # Preparing and building CMake 2.8.8
-
- $ cd /somewhere/you/want/to/build/cmake
- $ wget -N http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
- $ tar xvf cmake-2.8.8.tar.gz
- $ cd cmake-2.8.8
- $ ./configure --prefix=/where/you/want/cmake/installed/
- $ make
- $ make install
-
- # Building Ledger using the CMake and/or Boost as installed above
-
- $ cd /path/to/ledger/sources
- $ env PATH=/where/you/want/cmake/installed/bin:$PATH BOOST_ROOT=/where/you/want/boost/installed ./acprep --prefix=/where/you/want/ledger/installed --debug --python config
- $ env PATH=/where/you/want/cmake/installed/bin:$PATH BOOST_ROOT=/where/you/want/boost/installed ./acprep --prefix=/where/you/want/ledger/installed --debug --python make
- $ env PATH=/where/you/want/cmake/installed/bin:$PATH BOOST_ROOT=/where/you/want/boost/installed ./acprep --prefix=/where/you/want/ledger/installed --debug --python install
diff --git a/README.md b/README.md
index e18792d6..759fa26a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,9 @@
-[![Build Status](https://travis-ci.org/ledger/ledger.svg?branch=master)](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 release](https://img.shields.io/github/release/ledger/ledger.svg?style=flat)](https://github.com/ledger/ledger/releases)
+
# Ledger: Command-Line Accounting
@@ -21,44 +26,36 @@ and easy to use.
I know, you just want to build and play. If you have all the dependencies
installed (see below), then simply do this:
- git clone git://github.com/ledger/ledger.git
- cd ledger && ./acprep update # Update to the latest, configure, make
+ $ git clone git://github.com/ledger/ledger.git
+ $ cd ledger && ./acprep update # Update to the latest, configure, make
Now try your first ledger command:
- ./ledger -f test/input/sample.dat reg
+ $ ./ledger -f test/input/sample.dat reg
For help on keeping your journal have a look at the
-[documentation](http://www.ledger-cli.org/docs.html) and the
-[wiki](http://wiki.ledger-cli.org/) (Also see the “Resources” section at the
+[documentation] and the [wiki][] (Also see the “Resources” section at the
end of this file). An emacs mode for ledger files can be found in the `lisp`
-directory and a vim plugin is located in the [ledger/vim-ledger
-repository](https://github.com/ledger/vim-ledger).
+directory and a vim plugin is located in the [ledger/vim-ledger repository].
## To the Rest
If you're reading this file, you have in your hands the Bleeding Edge. This
may very well *not* be what you want, since it's not guaranteed to be in a
functionally complete state. It's under active development, and may change in
-any way at any time.
-
-What you may prefer is the current stable release, or the current beta branch.
-The **BETA** is what I prefer people use, since I still have a chance to fix
-major bugs that you find. Just e-mail me, or post to the mailing list,
-they'll become a part of my work list.
+any way at any time. What you may prefer is the **CURRENT** stable release, or
+the **BETA** branch.
-<table>
-<tr><td><strong>RELEASE</strong></td><td><tt>git checkout v3.1</tt></td></tr>
-<tr><td><strong>CURRENT</strong></td><td><tt>git checkout maint</tt></td></tr>
-<tr><td><strong>BETA</strong></td><td><tt>git checkout -b master origin/master</tt></td></tr>
-<tr><td><strong>ALPHA</strong></td><td><tt>git checkout -b next origin/next</tt></td></tr>
-</table>
+Branch | Command
+-------|--------
+**RELEASE** | `git checkout -b stable v3.1` |
+**CURRENT** | `git checkout -b master origin/master` |
+**BETA** | `git checkout -b 3.1.1 release/3.1.1` |
+**ALPHA** | `git checkout -b next origin/next` |
There are also several topic branches which contain experimental features,
though none of these are guaranteed to compile. Best to chat with me on
-[IRC](irc://irc.freenode.net/ledger) or via the
-[mailing list](http://groups.google.com/group/ledger-cli) before going too
-much further with those.
+[IRC] or via the [mailing list] before going too much further with those.
## Dependencies
@@ -66,53 +63,53 @@ If you wish to proceed in this venture, you'll need a few dependencies. The
easiest way to get them for your platform is to run this handy Python
script:
- ./acprep dependencies
+ $ ./acprep dependencies
If that doesn't completely work, here are the dependencies for building the
current `master` branch:
-<table>
-<tr><td>Boost</td><td>1.35</td><td></td></tr>
-<tr><td>GMP</td><td>4.2.2</td><td></td></tr>
-<tr><td>MPFR</td><td>2.4.0</td><td></td></tr>
-<tr><td>utfcpp</td><td>2.3.4</td><td></td></tr>
-<tr><td>gettext</td><td>0.17</td><td><em>optional</em></td></tr>
-<tr><td>libedit</td><td>20090111-3.0</td><td><em>optional</em></td></tr>
-<tr><td>Python</td><td>2.4</td><td><em>optional</em></td></tr>
-<tr><td>doxygen</td><td>1.5.7.1</td><td><em>optional</em>, for <tt>make docs</tt></td></tr>
-<tr><td>graphviz</td><td>2.20.3</td><td><em>optional</em>, for <tt>make docs</tt></td></tr>
-<tr><td>texinfo</td><td>4.13</td><td><em>optional</em>, for <tt>make docs</tt></td></tr>
-<tr><td>lcov</td><td>1.6</td><td><em>optional</em>, for <tt>make report</tt>, used with <tt>/./acprep gcov</tt></td></tr>
-<tr><td>sloccount</td><td>2.26</td><td><em>optional</em>, for <tt>make sloc</tt></td></tr>
-</table>
-
-And for building the current `maint` branch:
-
-<table>
-<tr><td>GMP</td><td>4.2.2</td><td> </td></tr>
-<tr><td>pcre</td><td>7.7</td><td> </td></tr>
-<tr><td>libofx</td><td>0.8.3</td><td><em>optional</em></td></tr>
-<tr><td>expat</td><td>2.0.1</td><td><em>optional</em></td></tr>
-<tr><td>libxml2</td><td>2.7.2</td><td><em>optional</em></td></tr>
-</table>
-
-### OS X
-
-You can use [MacPorts](https://www.macports.org/) or [homebrew](http://brew.sh/) to install this very quickly on OS X.
+Dependency | Version (or greater)
+-----------|---------------------
+[Boost] | 1.49
+[GMP] | 4.2.2
+[MPFR] | 2.4.0
+[utfcpp] | 2.3.4
+[gettext] | 0.17 _optional_
+[libedit] | 20090111-3.0 _optional_
+[Python] | 2.4 _optional_
+[doxygen] | 1.5.7.1 _optional_, for `make docs`
+[graphviz] | 2.20.3 _optional_, for `make docs`
+[texinfo] | 4.13 _optional_, for `make docs`
+[lcov] | 1.6 _optional_, for `make report`, used with `/./acprep gcov`
+[sloccount] | 2.26 _optional_, for `make sloc`
+
+And for building the outdated `release/2.6.3` branch:
+
+Dependency | Version
+-----------|--------
+[GMP] | 4.2.2
+[pcre] | 7.7
+[libofx] | 0.8.3 _optional_
+[expat] | 2.0.1 _optional_
+[libxml2] | 2.7.2 _optional_
+
+### Mac OS X
+
+You can use [Homebrew] or [MacPorts] to install Ledger easily on OS X.
#### 1. Homebrew
You can see the parameters you can pass while installing with brew by the command `brew options ledger`. To install ledger, simply type the following command:
- brew install ledger
+ $ brew install ledger
If everything worked well, you should have ledger working now. If you want to install this with python bindings, you can use the following command:
- brew install ledger --with-python
+ $ brew install ledger --with-python
If you to want to startup python, use the following command:
- ledger python
+ $ ledger python
#### 2. MacPorts
@@ -120,7 +117,7 @@ If you to want to startup python, use the following command:
If you build stuff using MacPorts on OS X, as I do, here is what you would
run:
- sudo port install -f cmake python26 \
+ $ sudo port install -f cmake python26 \
libiconv +universal zlib +universal gmp +universal \
mpfr +universal ncurses +universal ncursesw +universal \
gettext +universal libedit +universal boost-jam \
@@ -132,7 +129,7 @@ run:
If you're going to build on Ubuntu, `sudo apt-get install ...` the
following packages (current as of Ubuntu 14.04):
- sudo apt-get install build-essential cmake doxygen \
+ $ sudo apt-get install build-essential cmake doxygen \
libboost-system-dev libboost-dev python-dev gettext git \
libboost-date-time-dev libboost-filesystem-dev \
libboost-iostreams-dev libboost-python-dev libboost-regex-dev \
@@ -140,7 +137,7 @@ following packages (current as of Ubuntu 14.04):
Or, for Ubuntu 12.04:
- sudo apt-get install build-essential cmake zlib1g-dev libbz2-dev \
+ $ sudo apt-get install build-essential cmake zlib1g-dev libbz2-dev \
python-dev gettext libgmp3-dev libmpfr-dev libboost-dev \
libboost-regex-dev libboost-date-time-dev \
libboost-filesystem-dev libboost-python-dev texinfo lcov \
@@ -151,11 +148,11 @@ 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 \
+ $ sudo apt-get install build-essential cmake autopoint texinfo python-dev \
zlib1g-dev libbz2-dev libgmp3-dev gettext libmpfr-dev \
libboost-date-time-dev libboost-filesystem-dev \
libboost-graph-dev libboost-iostreams-dev \
@@ -167,12 +164,13 @@ The next step is preparing your environment for building. While you can use
`cmake .` and make, I've prepared a script that does a lot more of the
footwork for you:
- ./acprep update
+ $ ./acprep update
# or, if you want to use the Boost libraries with suffix -mt, install in
# $HOME/local and build with 2 processes in parallel
- ./acprep update --boost-suffix=-mt --prefix=$HOME/local -j2
+ $ ./acprep update --boost-suffix=-mt --prefix=$HOME/local -j2
-Please read the contents of `config.log` if the configure step fails. Also,
+Please read the contents of `CMakeFiles/CMakeOutput.log` and
+`CMakeFiles/CMakeError.log` if the configure step fails. Also,
see the `help` subcommand to `acprep`, which explains some of its many
options. It's pretty much the only command I run for configuring, building
and testing Ledger.
@@ -183,14 +181,41 @@ You can run `make check` to confirm the result, and `make install` to install.
Now that you're up and running, here are a few resources to keep in mind:
- - [Home page](http://ledger-cli.org)
- - [Documentation](http://www.ledger-cli.org/docs.html)
- - [IRC channel](irc://irc.freenode.net/ledger)
- - [Mailing List / Forum](http://groups.google.com/group/ledger-cli)
- - [GitHub project page](http://github.com/ledger/ledger)
- - [Ohloh code analysis](http://www.ohloh.net/projects/ledger)
+ - [Homepage]
+ - [Documentation]
+ - [IRC channel][IRC]
+ - [Mailing List / Forum][mailing list]
+ - [GitHub project page][github]
+ - [Code analysis][openhub]
If you have ideas you'd like to share, the best way is either to e-mail me a
patch (I prefer attachments over pasted text), or to get an account on GitHub.
-Once you do, fork the [Ledger project](http://github.com/ledger/ledger),
+Once you do, fork the [Ledger project][github],
hack as much as you like, then send me a pull request via GitHub.
+
+[Homepage]: http://ledger-cli.org/
+[documentation]: http://www.ledger-cli.org/docs.html
+[mailing list]: http://list.ledger-cli.org/
+[wiki]: http://wiki.ledger-cli.org/
+[IRC]: irc://irc.freenode.net/ledger
+[github]: http://github.com/ledger/ledger
+[ledger/vim-ledger repository]: https://github.com/ledger/vim-ledger
+[Homebrew]: http://brew.sh/
+[MacPorts]: https://www.macports.org/
+[Boost]: http://boost.org
+[GMP]: http://gmplib.org/
+[MPFR]: http://www.mpfr.org/
+[utfcpp]: http://utfcpp.sourceforge.net
+[gettext]: https://www.gnu.org/software/gettext/
+[libedit]: http://thrysoee.dk/editline/
+[Python]: http://python.org
+[doxygen]: http://www.doxygen.org/
+[graphviz]: http://graphviz.org/
+[texinfo]: http://www.gnu.org/software/texinfo/
+[lcov]: http://ltp.sourceforge.net/coverage/lcov.php
+[sloccount]: http://www.dwheeler.com/sloccount/
+[pcre]: http://www.pcre.org/
+[libofx]: http://libofx.sourceforge.net
+[expat]: http://www.libexpat.org
+[libxml2]: http://xmlsoft.org
+[openhub]: https://www.openhub.net/p/ledger
diff --git a/acprep b/acprep
index 9e661aad..17436960 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()
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/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/CMakeLists.txt b/doc/CMakeLists.txt
index 46c3f73f..e463c721 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -5,6 +5,10 @@
########################################################################
+configure_file(
+ ${PROJECT_SOURCE_DIR}/doc/version.texi.in
+ ${PROJECT_BINARY_DIR}/doc/version.texi)
+
if (USE_DOXYGEN)
find_package(Doxygen)
if (NOT DOXYGEN_FOUND)
diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md
deleted file mode 100644
index ce897741..00000000
--- a/doc/DEVELOP.md
+++ /dev/null
@@ -1,81 +0,0 @@
-GLOSSARY
-----
-
-Developing the Ledger software uses a number different tools, not all of
-which will be familiar to all developers.
-
-[**Boost**](http://www.boost.org): a standard set of C++ libraries. Most
-Boost libraries consist of inline functions and templates in header files.
-
-[**Cheetah**](http://www.cheetahtemplate.org): a Python templating engine,
-used by *./python/server.py*.
-
-[**CMake**](http://www.cmake.org): A cross platform system for building
-from source code. It uses the *CMakeLists.txt* files.
-
-[**DOxygen**](http://doxygen.org): generates programming documentation from
-source code files. Primarily used on C++ sources, but works on all. Uses
-the *doc/Doxyfile.in* file.
-
-[**GCC**](http://gcc.gnu.org): Gnu Compiler Collection, which includes the
-*gcc* compiler and *gcov* coverage/profiler tool.
-
-[**GMP**](https://gmplib.org): Gnu Multiple Precision Arithmetic Library
-provides arbitrary precision math.
-
-[**Markdown**](https://daringfireball.net/projects/markdown/): A typesetter
-format that produces *html* files from *.md* files. Note that GitHub
-automatically renders *.md* files.
-
-[**sha1**](http://en.wikipedia.org/wiki/SHA-1): a marginally secure
-cryptographic hash function, used only for signing the license file.
-
-[**Texinfo**](http://www.gnu.org/software/texinfo/): Gnu documentation
-typesetter that produces *html* and *pdf* files from the *doc/\*.texi*
-files.
-
-[**Travis CI**](https://travis-ci.org): a hosted continuous integration
- service that builds and runs tests each commit posted to GitHub. Each
- build creates a [log](https://travis-ci.org/ledger/ledger), updates a
- [small graphic](https://travis-ci.org/ledger/ledger.png?branch=master) at
- the top left of the main project's
- [README.md](https://github.com/ledger/ledger/blob/master/README.md), and
- emails the author of the commit if any tests fail.
-
-[**utfcpp**](http://utfcpp.sourceforge.net): a library for handling utf-8
-in a variety of C++ versions.
-
-
-Orientation
----
-
-The source tree can be confusing to a new developer. Here is a selective
-orientation:
-
-**./acprep**: a custom thousand-line script to install dependencies, grab
- updates, and build. It also creates *\*.cmake*,
- *./CmakeFiles/* and other CMake temporary files. Use *./acprep --help*
- for more information.
-
-**./README.md**: user readme file in markdown format, also used as the project
- description on GitHub.
-
-**./contrib/**: contributed scripts of random quality and completion. They
- usually require editing to run.
-
-**./doc/**: documentation, licenses, and
- tools for generating documents such as the *pdf* manual.
-
-**./lib/**: a couple libraries used in development.
-
-**./lisp/**: the [Emacs](http://www.gnu.org/software/emacs/)
- [ledger-mode](http://ledger-cli.org/3.0/doc/ledger-mode.html) lisp code,
- under the [GPLv2](http://www.gnu.org/licenses/gpl-2.0.html) license.
-
-**./python/**: samples using the Python ledger module.
-
-**./src/**: the C++ header and source files in a flat directory.
-
-**./test/**: a testing harness with subdirectories full of tests
-
-**./tools/**: an accretion of tools, mostly small scripts, to aid development
diff --git a/doc/DEVELOP.md.new b/doc/DEVELOP.md.new
deleted file mode 100644
index e69de29b..00000000
--- a/doc/DEVELOP.md.new
+++ /dev/null
diff --git a/doc/LICENSE.rtf b/doc/LICENSE.rtf
deleted file mode 100644
index 471065fe..00000000
--- a/doc/LICENSE.rtf
+++ /dev/null
Binary files differ
diff --git a/doc/NEWS b/doc/NEWS
index 45596ddc..94c0946a 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -1,5 +1,29 @@
Ledger NEWS
+* 3.x.x
+
+- Added a --no-revalued option
+
+- Improved Embedded Python Support
+
+- 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.56
+
+- Build fix for Cygwin
+
+- Fixed Util and Math tests on Mac OS X
+
+- Various documentation improvements
+
* 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 b76cb309..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
@@ -367,7 +369,7 @@ some additional meaning to the states:
No state. This is equivalent to sticking a check in the mail. It has
been obligated, but not been cashed by the recipient. It could also
apply to credit/debit card transactions that have not been cleared into
-your account balance. You bank may call these transactions ``pending'',
+your account balance. You bank may call these transactions @emph{pending},
but Ledger-mode uses a slightly different meaning.
@item Pending.
@@ -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 @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
@@ -589,17 +601,23 @@ difference from your target is zero.
If you find errors during reconciliation. You can visit the transaction
under point in the @file{*Reconcile*} buffer by hitting the @kbd{RET}
key. This will take you to the transaction in the Ledger buffer. When
-you have finished editing the transaction saving the buffer will
+you have finished editing the transaction, saving the buffer will
automatically return you to the @file{*Reconcile*} buffer and you can
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 transaction as cleared and saves the ledger buffer.
+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
@@ -621,7 +639,7 @@ Typing @kbd{d} will delete the transaction under point in the
You can conveniently switch the account being reconciled by typing
@kbd{g}, and entering a new account to reconcile. This simply restarts
-the reconcile process. Any transactions that were marked `pending' in
+the reconcile process. Any transactions that were marked @emph{pending} in
the ledger buffer are left in that state when the account is switched.
@node Changing Reconciliation Target, , Changing Reconciliation Account, The Reconcile Buffer
@@ -795,7 +813,7 @@ maintain the proper mathematical sense.
@chapter Scheduling Transactions
The Ledger program provides for automating transactions but these
-transaction aren't ``real'', they only exist inside a ledger session and
+transaction aren't @emph{real}, they only exist inside a ledger session and
are not reflected in the actual data file. Many transactions are very
repetitive, but may vary slightly in the date they occur on, or the
amount. Some transactions are weekly, monthly, quarterly or annually.
@@ -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.
@@ -929,29 +947,66 @@ If non-nil, highlight transaction under point using
@ftable @option
-@item ledger-reconcile-default-commodity
-The default commodity for use in target calculations in ledger
-reconcile. Defaults to @samp{$} (USD).
-
@item ledger-recon-buffer-name
Name to use for reconciliation buffer. Defaults to @file{*Reconcile*}.
@item ledger-narrow-on-reconcile
-If non-nil, limit transactions shown in main buffer to those matching
+If t, limit transactions shown in main buffer to those matching
the reconcile regex.
@item ledger-buffer-tracks-reconcile-buffer
-If non-nil, then when the cursor is moved to a new transaction in the
-@file{*Reconcile*} window.
+If t, then when the cursor is moved to a new transaction in the
+@file{*Reconcile*} buffer. Then that transaction will be shown in its
+source buffer.
@item ledger-reconcile-force-window-bottom
-If non-nil, make the @file{*Reconcile*} window appear along the bottom
+If t, make the @file{*Reconcile*} window appear along the bottom
of the register window and resize.
@item ledger-reconcile-toggle-to-pending
-If non-nil, then toggle between uncleared and pending @samp{!}. If
+If t, then toggle between uncleared and pending @samp{!}. If
false toggle between uncleared and cleared @samp{*}.
+@item ledger-reconcile-default-date-format
+Date format for the reconcile buffer. Defaults to
+@option{ledger-default-date-format}.
+
+@item ledger-reconcile-target-prompt-string
+Prompt for recon target. Defaults to "Target amount for reconciliation ".
+
+@item ledger-reconcile-buffer-header
+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. 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 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
+@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
+If positive, truncate payee name right side to max number of characters.
+
+@item ledger-reconcile-buffer-account-max-chars
+If positive, truncate account name left side to max number of characters.
+
+@item ledger-reconcile-sort-key
+Key for sorting reconcile buffer. Possible values are '(date)',
+'(amount)', '(payee)' or '(0)' for no sorting, i.e. using
+ledger file order. Defaults to '(0)'.
+
+@item ledger-reconcile-insert-effective-date nil
+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 b4746eb9..0445c237 100644
--- a/doc/ledger.1
+++ b/doc/ledger.1
@@ -1,21 +1,23 @@
.Dd March 23, 2012
-.Dt ledger 1
+.Dt LEDGER 1
+.Os
.Sh NAME
.Nm ledger
.Nd Command-line, double-entry account reporting tool
.Sh SYNOPSIS
-ledger
+.Nm
.Op Ar command
.Op Ar options
.Op Ar arguments
.Sh DESCRIPTION
-Ledger is a command-line accounting tool based on the power and completeness
+.Nm
+is a command-line accounting tool based on the power and completeness
of double-entry accounting. It is only a reporting tool, which means it never
-modifies your data files, but it does offers a large selection of reports, and
-different ways to customize them to your liking.
-.Pp
+modifies your data files, but it does offer a large selection of reports, and
+different ways to customize them to your needs.
.Sh COMMANDS
-Ledger accepts several top-level commands, each of which generates a different
+.Nm
+accepts several top-level commands, each of which generates a different
kind of basic report. Most of them accept a
.Ar report-query
argument, in order to determine what should be reported. To understand the
@@ -26,48 +28,48 @@ see the section on
In its most basic form, simply specifying one or more strings produces a
report for all accounts containing those strings.
.Pp
-If no command is given, Ledger enters a
+If no command is given,
+.Nm
+enters a
.Tn REPL ,
-or command loop, allowing several commands to be executed against the same
+or command loop, allowing several commands to be executed on the same
dataset without reparsing.
.Pp
-The following is a complete list of reporting commands accepted by Ledger:
+The following is a complete list of accepted reporting commands:
.Bl -tag -width accounts
-.It Nm accounts Oo Ar report-query Oc
-Lists all accounts for postings matching the
+.It Ic accounts Oo Ar report-query Oc
+List all accounts for postings that match the
.Ar report-query .
.El
-.Pp
.Bl -tag -width balance
-.It Nm balance Oo Ar report-query Oc
-Produces a balance report showing totals for all matching accounts, and
-aggregate totals for parents of those accounts. Options most commonly used
+.It Ic balance Oo Ar report-query Oc
+Print a balance report showing totals for postings that match
+.Ar report-query ,
+and aggregate totals for parents of those accounts. Options most commonly used
with this command are:
-.Pp
.Bl -tag -compact -width "--collapse (-n)"
.It Fl \-basis Pq Fl B
Report in terms of cost basis, not amount or value. This is the only form of
report which is guaranteed to always balance to zero, when no
.Ar report-query
is specified.
-.It Fl \-collapse Pq Fl n
Only show totals for the top-most accounts.
.It Fl \-empty Pq Fl E
-Also show accounts whose total is zero.
+Show accounts whose total is zero.
.It Fl \-flat
Rather than display a hierarchical tree, flatten the report to show subtotals
for only accounts matching
.Ar report-query .
.It Fl \-no-total
-Suppress the summary total shown at the bottom of the report (when not zero).
+Suppress the summary total shown at the bottom of the report.
.El
.Pp
The synonyms
-.Nm bal
+.Ic bal
and
-.Nm b
+.Ic b
are also accepted.
-.It Nm budget Oo Ar report-query Oc
+.It Ic budget Oo Ar report-query Oc
A special balance report which includes three extra columns: the amount
budgeted during the reporting period, how spending differed from the budget,
and the percentage of budget spent (exceeds 100% if you go over budget).
@@ -76,24 +78,27 @@ Note that budgeting requires one or more
periodic transactions
.Dc
to be defined in your data file(s). See the manual for more information.
-.It Nm cleared Oo Ar report-query Oc
+.It Ic cleared Oo Ar report-query Oc
A special balance report which adds two extra columns: the cleared balance for
each account, and the date of the most recent cleared posting in that account.
For this accounting to be meaningful, the cleared flag must be set on at least
one posting. See the manual for more information.
-.It Nm commodities Oo Ar report-query Oc
-Lists all commodities for postings matching the
+.It Ic commodities Oo Ar report-query Oc
+List all commodities for postings matching the
.Ar report-query .
-.It Nm convert
-Reads data from a CSV (comma-separated values) file and generates Ledger
+.It Ic convert
+Reads data from a CSV (comma-separated values) file and generates
+.Nm
transactions.
-.It Nm csv Oo Ar report-query Oc
+.It Ic csv Oo Ar report-query Oc
Report of postings matching the
.Ar report-query
in CSV format (comma-separated values). Useful for exporting data to a
spreadsheet for further analysis or charting.
-.It Nm entry Oo Ar entry-template Oc
-Generate and display a new, properly formatted Ledger transaction by comparing
+.It Ic entry Oo Ar entry-template Oc
+Generate and display a new, properly formatted
+.Nm
+transaction by comparing
the
.Ar entry-template
to the transactions in your data file(s). For more information on draft
@@ -102,53 +107,63 @@ section
.Sx ENTRIES .
.Pp
The synonym
-.Nm xact
+.Ic xact
is also accepted.
-.It Nm emacs Oo Ar query Oc
-Outputs posting and transaction data in a format readily consumed by the Emacs
+.It Ic emacs Oo Ar query Oc
+Output posting and transaction data in a format readily consumed by the Emacs
editor, in a series of Lisp forms. This is used by the
-.Li ledger.el
-Emacs mode to process reporting data from Ledger.
-.It Nm equity Oo Ar report-query Oc
-Prints a series of transactions that balance current totals for
+.Pa ledger.el
+Emacs mode to process reporting data from
+.Nm .
+.It Ic equity Oo Ar report-query Oc
+Print a transaction with a series of postings that balance current totals for
accounts matching the
.Ar report-query
in a special account called
.Li Equity:Opening Balances .
The purpose of this report is to close the books for a prior year, while using
-these equity transactions to carry forward those balances.
-.It Nm org
-Produces a journal file suitable for use in the Emacs org mode.
-.It Nm payees Oo Ar report-query Oc
-Lists all payees for postings matching the
+these equity postings to carry forward those balances.
+.It Ic org
+Produce a journal file suitable for use in the Emacs org mode.
+.It Ic payees Oo Ar report-query Oc
+List all payees for postings matching the
.Ar report-query .
-.It Nm pricemap
-Produces a file which can be used to generate a graph with graphviz showing
-the relationship of commodities in the Ledger file.
-.It Nm prices Oo Ar report-query Oc
-Reports prices for all commodities in postings matching the
+.It Ic pricemap
+Produce a file which can be used to generate a graph with graphviz showing
+the relationship of commodities in the
+.Nm
+file.
+.It Ic prices Oo Ar report-query Oc
+Report prices for all commodities in postings matching the
.Ar report-query .
The prices are reported with the granularity of a single day.
-.It Nm pricedb Oo Ar report-query Oc
-Reports prices for all commodities in postings matching the
+.It Ic pricedb Oo Ar report-query Oc
+Report prices for all commodities in postings matching the
.Ar report-query .
Prices are reported down to the second, using the same format as the
-.Li ~/.pricedb
+.Pa ~/.pricedb
file.
-.It Nm print Oo Ar report-query Oc
-Prints out the full transactions of any matching postings using the same
+.It Ic print Oo Ar report-query Oc
+Print out the full transactions of any matching postings using the same
format as they would appear in a data file. This can be used to extract
-subsets from a Ledger file to transfer to other files.
-.It Nm push Oo Ar options Oc
+subsets from a
+.Nm
+file to transfer to other files.
+.It Ic push Oo Ar options Oc
In the
.Tn REPL ,
-this command pushes a set of command-line options, so that they will apply to
-all subsequent reports.
-.It Nm pop
+push a set of command-line
+.Ar options ,
+so that they will apply to all subsequent reports.
+.It Ic pop
In the
.Tn REPL ,
-pops any option settings that have been pushed.
-.It Nm register Oo Ar report-query Oc
+pop any option settings that have been
+.Sm off
+.Ic push
+ed.
+.Sm on
+.It Ic register Oo Ar report-query Oc
List all postings matching the
.Ar report-query .
This is one of the most common commands, and can be used to provide a variety
@@ -165,10 +180,10 @@ Render all values in the given
.Ar commodity ,
if a price conversion rate can be determined. Rates are always displayed
relative to the date of the posting they are calculated for. This means a
-.Nm register
+.Ic register
report is a historical value report. For current values, it may be preferable
to use the
-.Nm balance
+.Ic balance
report.
.It Fl \-gain Pq Fl G
Show any gains (or losses) in commodity values over time.
@@ -177,29 +192,29 @@ Only show the top
.Ar number
postings.
.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
Show current market values for all amounts. This is determined in a somewhat
magical fashion. It is probably more straightforward to use
-.Fl \-exchange Ar commodity Pq Fl X .
+.Fl \-exchange
+option.
.It Fl \-period Ar time-period Pq Fl p
Show postings only for the given
.Ar time-period .
.It Fl \-related Pq Fl r
Show postings that are related to those that would have been shown. It has
the effect of displaying the
-.Do
-other side
-.Dc
-of the values.
+.Qq other side
+of the postings.
.It Fl \-sort Ar value-expression Pq Fl S
Sort postings by evaluating the given
.Ar value-expression .
Note that a comma-separated list of expressions is allowed, in which case each
sorting term is used in order to determine the final ordering. For example,
to search by date and then amount, one would use:
-.Li -S 'date, amount' .
+.Dl ledger reg --sort 'date, amount'
.It Fl \-tail Ar number
Only show the last
.Ar number
@@ -217,42 +232,46 @@ Group postings by common payee names.
Group postings by day.
.It Fl \-weekly Pq Fl W
Group postings by week (starting on Sundays).
-.It Fl \-start-of-week Ar day-name
-Set the start of each grouped way to the given
-.Ar day-name .
+.It Fl \-start-of-week Ar day
+Set the start of each report grouped by week to the given
+.Ar day .
.It Fl \-monthly Pq Fl M
Group postings by month.
.It Fl \-quarterly
Group postings by fiscal quarter.
.It Fl \-yearly Pq Fl Y
Group postings by year.
-.It Fl \-dow
+.It Fl \-days-of-week
Group postings by the day of the week on which they took place.
.It Fl \-subtotal Pq Fl s
Group all postings together. This is very similar to the totals shown by the
-.Nm balance
+.Ic balance
report.
.El
.Pp
The synonyms
-.Nm reg
+.Ic reg
and
-.Nm r
+.Ic r
are also accepted.
-.It Nm server
+.It Ic server
This command requires that Python support be active. If so, it starts up an
-HTTP server listening for requests on port 9000. This provides an alternate
+.Tn HTTP
+server listening for requests on port 9000. This provides an alternate
interface to creating and viewing reports. Note that this is very much a
work-in-progress, and will not be fully functional until a later version.
-.It Nm select Oo Ar sql-query Oc
+.It Ic select Oo Ar sql-query Oc
List all postings matching the
.Ar sql-query .
-This command allows to generate SQL-like queries.
-.It Nm source
-Parses a journal file and checks it for errors. Ledger will return success
+This command allows to generate SQL-like queries, e.g.:
+.Dl Li ledger select date,amount from posts where account=~/Income/
+.It Ic source
+Parse a journal file and checks it for errors.
+.Nm
+will return success
if no errors are found.
-.It Nm stats Oo Ar report-query Oc
-Provides summary information about all the postings matching
+.It Ic stats Oo Ar report-query Oc
+Provide summary information about all the postings matching
.Ar report-query .
It provides information such as:
.Bl -bullet -offset indent -compact
@@ -269,43 +288,54 @@ Uncleared postings
.It
Days since last posting
.It
-More...
+Posts in the last 7 days
+.It
+Posts in the last 30 days
+.It
+Posts this month
.El
-.It Nm xml Oo Ar report-query Oc
-Outputs data relating to the current report in XML format. It includes all
+.It Ic xml Oo Ar report-query Oc
+Output data relating to the current report in
+.Tn XML
+format. It includes all
accounts and commodities involved in the report, plus the postings and the
transactions they are contained in. See the manual for more information.
.El
-.Pp
.Sh OPTIONS
-.Pp
.Bl -tag -width -indent
.It Fl \-abbrev-len Ar INT
Set the minimum length an account can be abbreviated to if it doesn't
fit inside the
-.Nm account-width .
+.Sy account-width .
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
-.Nm account-width
+.Sy 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.
-.It Fl \-account Ar STR
+.It Fl \-account Ar EXPR
Prepend
-.Ar STR
-to all accounts reported. That is, the option
-.Nm --account Personal
+.Ar EXPR
+to all accounts reported. That is, the option
+.Fl \-account Ar \*q'Personal'\*q
would tack
-.Nm Personal:
-to the beginning of every account reported in a balance report or register report.
+.Ar Personal:
+and
+.Fl \-account Ar \*qtag('VAT')\*q
+would tack the value of the VAT tag to the beginning of every account
+reported in a
+.Ic balance
+or
+.Ic register
+report.
.It Fl \-account-width Ar INT
Set the width of the account column in the
-.Nm register
+.Ic register
report
to
.Ar INT
@@ -316,8 +346,8 @@ 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
-.Nm --amount Ar EXPR
+Apply the given value expression to the posting amount. Using
+.Fl \-amount Ar EXPR
you can apply an
arbitrary transformation to the postings.
.It Fl \-amount-data Pq Fl j
@@ -325,24 +355,36 @@ On a register report print only the dates and amount of postings.
Useful for graphing and spreadsheet applications.
.It Fl \-amount-width Ar INT
Set the width in characters of the amount column in the
-.Nm register
+.Ic register
report.
.It Fl \-anon
Anonymize registry output, mostly for sending in bug reports.
+.It Fl \-ansi
+Use color if the terminal supports it.
+Alias for
+.Fl \-color
.It Fl \-args-only
+Ignore init files and environment variables for the
+.Nm
+run.
.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
+Alias for
.Fl \-effective
.It Fl \-average Pq Fl A
Print average values over the number of transactions instead of
running totals.
.It Fl \-balance-format Ar FMT
Specify the format to use for the
-.Nm balance
+.Ic balance
report.
.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
@@ -350,21 +392,21 @@ 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 register report this
-displays transaction in the budget, in a balance report this displays
-accounts in the budget.
+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.
.It Fl \-budget-format Ar FMT
Specify the format to use for the
-.Nm budget
+.Ic budget
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.
@@ -372,12 +414,10 @@ commodities and tags.
Display only cleared postings.
.It Fl \-cleared-format Ar FMT
Specify the format to use for the
-.Nm cleared
+.Ic cleared
report
.It Fl \-collapse Pq Fl n
-By default ledger prints all accounts in an account tree. With
-.Fl \-collapse
-it prints only the top level account specified.
+Print only the top level accounts.
.It Fl \-collapse-if-zero
Collapse the account display only if it has a zero balance.
.It Fl \-color
@@ -385,95 +425,136 @@ Use color if the terminal supports it.
Alias for
.Fl \-ansi
.It Fl \-columns Ar INT
-Specify the width of the
-.Nm register
-report in characters.
+Make the
+.Ic register
+report
+.Ar INT
+characters wide. By default
+.Nm
+will use all available columns in your terminal.
.It Fl \-cost
Report the cost basis on all posting.
Alias for
.Fl \-basis .
.It Fl \-count
-Direct ledger to report the number of items when appended to the
-.Nm commodities ,
-.Nm accounts
+Direct
+.Nm
+to report the number of items when appended to the
+.Ic commodities ,
+.Ic accounts
or
-.Nm payees
+.Ic payees
commands.
.It Fl \-csv-format Ar FMT
-Specify the format to use for the
-.Nm csv
+Format
+.Ic csv
report
+according to
+.Ar FMT .
.It Fl \-current Pq Fl c
Shorthand for
-.Nm --limit 'date <= today' .
+.Fl \-limit Ar "'date <= today'" .
.It Fl \-daily Pq Fl D
Shorthand for
-.Nm --period 'daily' .
+.Fl \-period Ar daily .
.It Fl \-date Ar EXPR
Transform the date of the transaction using
.Ar EXPR .
.It Fl \-date-format Ar DATEFMT Pq Fl y
-Specify the format ledger should use to print dates.
-.It Fl \-datetime-format Ar FMT
+Print dates using
+.Ar DATEFMT .
+Refer to
+.Xr strftime 3
+for details on the format string syntax.
+.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
-.Nm register
+.Ic register
report.
.It Fl \-day-break
+Break up
+.Ic register
+report of timelog entries that span multiple days by day.
+.It Fl \-days-of-week
+Group transactions by the days of the week.
+Alias for
+.Fl \-dow .
.It Fl \-dc
Display register or balance in debit/credit format If you use
.Fl \-dc
-with either the register (reg) or balance (bal) commands,
-you will now get separate columns for debits and credits.
+with either the
+.Ic register
+or
+.Ic balance
+commands, you will now get separate columns for debits and credits.
.It Fl \-debug Ar STR
-If Ledger has been built with debug options this will provide extra
+If
+.Nm
+has been built with debug options this will provide extra
data during the run.
.It Fl \-decimal-comma
-Direct Ledger to parse journals using the European standard comma as
+Direct
+.Nm
+to parse journals using the European standard comma as
decimal separator, vice a period.
.It Fl \-depth Ar INT
Limit the depth of the account tree. In a balance report, for example,
-a
-.Fl \-depth 2
-statement will print balances only for account with
-two levels, i.e.
-.Nm Expenses:Entertainment
+.Fl \-depth Ar 2
+will print balances only for accounts with two levels, i.e.
+.Sy Expenses:Entertainment
but not
-.Nm Expenses:entertainment:Dining .
-This is a display predicate, which
-means it only affects display, not the total calculations.
-.It Fl \-deviation Pq Fl D
-Report each posting’s deviation from the average. It is only meaningful
-in the register and prices reports.
+.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
+in the
+.Ic register No and Ic prices
+reports.
.It Fl \-display Ar EXPR Pq Fl d
Display lines that satisfy the expression
.Ar EXPR .
.It Fl \-display-amount Ar EXPR
Apply a transformation to the
-.Nm displayed
+.Em displayed
amount. This occurs after
calculations occur.
.It Fl \-display-total Ar EXPR
Apply a transformation to the
-.Nm displayed
+.Em displayed
total. This occurs after
calculations occur.
.It Fl \-dow
Group transactions by the days of the week.
Alias for
-.Fl \-days-of-week
+.Fl \-days-of-week .
.It Fl \-download
Cause quotes to be automagically downloaded, as needed, by running
a script named
-.Nm getquote
+.Em getquote
and expecting that script to return
-a value understood by ledger. A sample implementation of
-a
-.Nm getquote
+a value understood by
+.Nm .
+A sample implementation of a
+.Em getquote
script, implemented in Perl, is provided in the
distribution. Downloaded quote price are then appended to the price
database, usually specified using the environment variable
-.Nm LEDGER_PRICE_DB .
+.Ev LEDGER_PRICE_DB .
+.It Fl \-effective
+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
@@ -483,34 +564,42 @@ for a transaction to be considered in the
report.
.It Fl \-equity
Related to the
-.Nm equity
+.Ic equity
command. Gives current account balances in the form of a register
report.
.It Fl \-exact
-.It Fl \-exchange Ar COMMODITY Oo , COMM, ... Oc Pq Fl X
+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
+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
-.Ar FILE
-as a ledger file.
+Read journal data from
+.Ar FILE .
.It Fl \-first Ar INT
Print the first
.Ar INT
-entries. Opposite of
-.Fl \-tail Ar INT .
-Alias for
+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 Ledger to paginate its output.
+Force
+.Nm
+to paginate its output.
.It Fl \-forecast-while Ar EXPR
Continue forecasting while
.Ar VEXPR
@@ -533,15 +622,15 @@ transactions) in the report, in cases where you normally wouldn't want
them.
.It Fl \-group-by Ar EXPR
Group transaction together in the
-.Nm register
+.Ic register
report.
.Ar EXPR
can be anything, although most common would be
-.Nm payee
+.Ar payee
or
-.Nm commodity .
+.Ar commodity .
The
-.Nm tags()
+.Fn tag
function is also useful here.
.It Fl \-group-title-format Ar FMT
Set the format for the headers that separate reports section of
@@ -551,38 +640,48 @@ 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 ledger is run without a command.
+Print this man page.
.It Fl \-immediate
-Instruct ledger to evaluate calculations immediately rather than lazily.
-.It Fl \-init-file Ar FILE
-Causes
-.Nm FILE
-to be read by ledger before any other ledger file.
+Evaluate calculations immediately rather than lazily.
+.It Fl \-import Ar FILE
+Import
+.Ar FILE
+as Python module.
+.It Fl \-init-file Ar FILE Pq Fl i
+Read
+.Ar FILE
+before any other
+.Nm
+file.
This file may not contain any postings, but it may contain option
settings. To specify options in the init file, use the same syntax as
the command-line, but put each option on its own line.
.It Fl \-inject Ar STR
-TODO
+Use
+.Ar STR
+amounts in calculations. In case you know
+what amount a transaction should be, but the actual transaction has the
+wrong value you can use metadata
+.Ar STR
+to specify the expected amount.
.It Fl \-input-date-format Ar DATEFMT
Specify the input date format for journal entries.
.It Fl \-invert
Change the sign of all reported values.
-.It Fl \-last Ar INT
+.It Fl \-last Ar INT .
Report only the last
.Ar INT
-entries. Only useful on a register
-report.
-Alias for
+entries. Opposite of
+.Fl \-first Ar INT .
+Only useful on a register report. Alias for
.Fl \-tail .
.It Fl \-leeway Ar INT Pq Fl Z
-Alias for
+Alias for
.Fl \-price-expr .
.It Fl \-limit Ar EXPR Pq Fl l
Limit postings in calculations.
@@ -598,30 +697,41 @@ purchased.
Report the date and price at which each commodity was purchased in
a balance report.
.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
Prepend all account names with
.Ar STR
-.It Fl \-meta Ar EXPR
+.It Fl \-meta Ar STR
In the register report, prepend the transaction with the value of the given
-.Ar TAG .
+tag
+.Ar STR .
.It Fl \-meta-width Ar INT
Specify the width of the Meta column used for the
.Fl \-meta Ar TAG
options.
.It Fl \-monthly Pq Fl M
Shorthand for
-.Fl \-period 'monthly' .
+.Fl \-period Ar monthly .
.It Fl \-no-aliases
Aliases are completely ignored.
.It Fl \-no-color
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
-.Nm <Rounding>
+.Qq Li <Adjustment>
postings. Note that this will cause the
-running total to often not add up! It's main use is for
+running total to often not add up! Its main use is for
.Fl \-amount-data Pq Fl j
and
.Fl \-total-data Pq Fl J
@@ -631,24 +741,35 @@ Suppress the output of group titles.
.It Fl \-no-total
Suppress printing the final total line in a balance report.
.It Fl \-now Ar DATE
-Define the current date in case to you to do calculate in the past or
-future using
-.Fl \-current .
+Use
+.Ar DATE
+as the current date. This affects the output when using
+.Fl \-period ,
+.Fl \-begin ,
+.Fl \-end ,
+or
+.Fl \-current
+to decide which dates lie in the past or future.
.It Fl \-only Ar EXPR
This is a postings predicate that applies after certain transforms have
been executed, such as periodic gathering.
.It Fl \-options
-Display the options in effect for this Ledger invocation, along with
+Display the options in effect for this
+.Nm
+invocation, along with
their values and the source of those values.
.It Fl \-output Ar FILE Pq Fl o
-Redirect the output of ledger to the file defined in
+Redirect the output of
+.Nm
+to
.Ar FILE .
.It Fl \-pager Ar STR
-Specify the pager program to use as
-.Ar STR .
+Use
+.Ar STR
+as the pager program.
.It Fl \-payee
-Sets a value expression for formatting the payee. In the
-.Nm register
+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.
.It Fl \-payee-width Ar INT
@@ -659,13 +780,13 @@ report to
Accounts, tags or commodities not previously declared will cause errors.
.It Fl \-pending
Use only postings that are marked pending.
-.It Fl \-percent Pq Fl \b'%'
+.It Fl \-percent Pq Fl %
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
-.Nm register
+transactions are to be accounted. For a
+.Ic register
report only
the transactions that satisfy the period expression with be displayed.
For a balance report only those transactions will be accounted in the
@@ -673,9 +794,10 @@ final balances.
.It Fl \-period-sort
Sort the posting within transactions using the given value expression.
.It Fl \-permissive
-.It Fl \-pivot Ar STR
+Quiet balance assertions.
+.It Fl \-pivot Ar TAG
Produce a balance pivot report
-.Nm around
+.Qq around
the given
.Ar TAG .
.It Fl \-plot-amount-format Ar FMT
@@ -684,7 +806,7 @@ Define the output format for an amount data plot.
Define the output format for a total data plot.
.It Fl \-prepend-format Ar FMT
Prepend
-.Ar STR
+.Ar FMT
to every line of the output.
.It Fl \-prepend-width Ar INT
Reserve
@@ -696,28 +818,32 @@ 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 Ar INT Pq Fl Z
+.Fl \-leeway .
.It Fl \-prices-format Ar FMT
+Set the format for the
+.Ic prices
+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).
.It Fl \-quarterly
-Synonym for
-\Fl \-period 'quarterly' .
+Shorthand for
+.Fl \-period Ar quarterly .
.It Fl \-raw
In the
-.Nm print
+.Ic print
report, show transactions using the exact same syntax as
specified by the user in their data file. Don't do any massaging or
interpreting. Can be useful for minor cleanups, like just aligning
@@ -726,44 +852,70 @@ amounts.
Account using only real transactions ignoring virtual and automatic
transactions.
.It Fl \-recursive-aliases
-Causes ledger to try to expand aliases recursively, i.e. try to expand
+Causes
+.Nm
+to try to expand aliases recursively, i.e. try to expand
the result of an earlier expansion again, until no more expansions apply.
.It Fl \-register-format Ar FMT
Define the output format for the
-.Nm register
+.Ic register
report.
.It Fl \-related Pq Fl r
In a register report show the related account. This is the other
-.Nm side
+.Em side
of the transaction.
.It Fl \-related-all
Show all postings in a transaction, similar to
.Fl \-related
-but show
-.Nm both sides
-of each transaction.
+but show both sides of each transaction.
.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
-.It Fl \-revalued-total Ar EXPR
+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
for the
-.Nm generate
+.Ic generate
command. Used as part of development testing.
.It Fl \-script Ar FILE
-Execute a ledger script.
+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
-Tell ledger to use a particular day of the week to start its "weekly"
-summary.
-.Fl \-start-of-week=1
-specifies Monday as the start of the week.
+Use
+.Ar STR
+as the particular day of the week to start when using the
+.Fl \-weekly
+option.
+.Ar STR
+can be day names, their abbreviations like
+.Qq Mon ,
+or the weekday number
+starting at 0 for Sunday.
.It Fl \-strict
Accounts, tags or commodities not previously declared will cause warnings.
.It Fl \-subtotal Pq Fl s
@@ -771,9 +923,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
+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
@@ -781,18 +939,22 @@ 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 CODE
+.It Fl \-truncate Ar STR
Indicates how truncation should happen when the contents of columns
-exceed their width. Valid arguments are
-.Nm leading , Nm middle ,
+exceed their width. Valid arguments for
+.Ar STR
+are
+.Ar leading ,
+.Ar middle ,
and
-.Nm trailing .
+.Ar trailing .
The default is smarter than any of these three,
as it considers sub-names within the account name (that style is
-called "abbreviate").
+called
+.Qq abbreviate ) .
.It Fl \-unbudgeted
Show only un-budgeted postings.
.It Fl \-uncleared Pq Fl U
@@ -802,76 +964,97 @@ 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
-.Nm "Equity:Unrealized Gains" .
+unrealized gains. Defaults to
+.Sy "Equity:Unrealized Gains" .
Often set in one's
-.Nm ~/.ledgerrc
+.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
-.Nm "Equity:Unrealized Losses" .
+unrealized losses. Defaults to
+.Sy "Equity:Unrealized Losses" .
Often set in one's
-.Nm ~/.ledgerrc
+.Pa ~/.ledgerrc
file to change the default.
.It Fl \-unround
Perform all calculations without rounding and display results to full
precision.
.It Fl \-values
-Shows the values used by each tag when used in combination with the
-.Nm tags
+Show the values used by each tag when used in combination with the
+.Ic tags
command.
.It Fl \-value-expr Ar EXPR
+Set a global value expression annotation.
.It Fl \-verbose
-Print detailed information on the execution of Ledger.
+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
-ledger will produce memory trace information.
+.Nm
+will produce memory trace information.
.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
-Synonym for
-.Fl \-period 'weekly' .
+Shorthand for
+.Fl \-period Ar weekly .
.It Fl \-wide Pq Fl w
-Assume 132 columns instead of 80.
+Assume 132 columns instead of the TTY width.
.It Fl \-yearly Pq Fl Y
-Synonym for
-.Fl \-period 'yearly' .
+Shorthand for
+.Fl \-period Ar yearly .
.El
-.Pp
.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.
-.Pp
.Bl -tag -width -indent
-.It Nm args / query
-Evaluate the given arguments and report how Ledger interprets it against
-the following model transaction.
-.It Nm eval
+.It Ic args No / Ic query
+Evaluate the given arguments and report how
+.Nm
+interprets it against the following model transaction:
+.Bd -literal -offset indent
+2004/05/27 Book Store
+ ; This note applies to all postings. :SecondTag:
+ Expenses:Books 20 BOOK @ $10
+ ; Metadata: Some Value
+ ; Typed:: $100 + $200
+ ; :ExampleTag:
+ ; Here follows a note describing the posting.
+ Liabilities:MasterCard $-200.00
+.Ed
+.It Ic eval
Evaluate the given value expression against the model transaction.
-.It Nm format
-Print details of how ledger uses the given formatting description and
+.It Ic format
+Print details of how
+.Nm
+uses the given formatting description and
apply it against a model transaction.
-.It Nm parse / expr
-Print details of how ledger uses the given value expression description
+.It Ic parse No / Ic expr
+Print details of how
+.Nm
+uses the given value expression description
and apply it against a model transaction.
-.It Nm generate
-Randomly generates syntactically valid Ledger data from a seed. Used
+.It Ic generate
+Randomly generates syntactically valid
+.Nm
+data from a seed. Used
by the GenerateTests harness for development testing.
-.It Nm period
-Evaluate the given period and report how Ledger interprets it.
-.It Nm script
-.It Nm template
+.It Ic period
+Evaluate the given period and report how
+.Nm
+interprets it.
+.\".It Ic script
+.It Ic template
Shows the insertion template that the
-.Nm xact sub-command generates.
-This is a debugging command.
+.Ic xact
+command generates. This is a debugging command.
.El
-.Pp
.Sh QUERIES
The syntax for reporting queries can get somewhat complex. It is a series of
query terms with an implicit OR operator between them. The following terms
@@ -883,43 +1066,56 @@ Thus, to report the current balance for all assets and liabilities, you would
use:
.Pp
.Dl ledger bal asset liab
-.It Nm payee Ar regex Pq \&@ Ns Ar regex
+.It Ic payee Ar regex Pq Ic \&@ Ns Ar regex
Query on the payee, rather than the account.
-.It Nm tag Ar regex Pq \&% Ns Ar regex
-.It Nm note Ar regex Pq \&= Ns Ar regex
+.It Ic tag Ar regex Pq Ic \&% Ns Ar regex
+.It Ic note Ar regex Pq Ic \&= Ns Ar regex
Query on anything found in an item's note.
-.It Nm code Ar regex Pq \&# Ns Ar regex
+.It Ic code Ar regex Pq Ic \&# Ns Ar regex
Query on the xact's optional code (which can be any string the user wishes).
-.It Ar term Nm and Ar term
+.It Ar term Cm and Ar term
Query terms are joined by an implicit OR operator. You can change this to AND
-by using that keyword. For example, to show food expenditures occurring at
+by using the
+.Cm and
+keyword. For example, to show food expenditures occurring at
Shakee's Pizza, you could say:
.Pp
-.Dl ledger reg food and @Shakee
-.It Ar term Nm or Ar term
+.Dl Li ledger reg food and @Shakee
+.It Ar term Cm or Ar term
When you wish to be more explicit, use the OR operator.
-.It Nm show
-.It Nm not Ar term
+.It Ic show
+.It Cm not Ar term
Reverse the logical meaning of the following term. This can be used with
parentheses to great effect:
.Pp
-.Dl ledger reg food and @Shakee and not dining
+.Dl Li ledger reg food and @Shakee and not dining
.It \&( Ar term No \&)
If you wish to mix OR and AND operators, it is often helpful to surround
logical units with parentheses. \fBNOTE\fR: Because of the way some shells
interpret parentheses, you should always escape them:
.Pp
-.Dl ledger bal \e\\\&( assets or liab \e\\\&) and not food
+.Dl Li ledger bal \e( assets or liab \e) and not food
.El
-.Pp
.Sh EXPRESSIONS
.Bl -tag -width "partial_account"
-.It Nm account
-.It Nm account_base
-.It Nm account_amount
-.It Nm actual
-.It Nm amount
-.It Nm amount_expr
+.It Fn abs value
+Return the absolute value of the given
+.Ar value .
+.It Sy account
+Return the posting's account.
+.It Sy account_base
+Return the base account, i.e. everything after the last account delimiter ':'.
+.\".It Sy account_amount
+.It Sy actual
+.\" Is there a difference between real and actual?
+Return true if the transaction is real, i.e not a automated or virtual
+transaction, false otherwise.
+.It Sy amount
+Return the amount of the posting.
+.It Sy amount_expr
+Return the calculated amount of the posting according to the
+.Fl \-amount
+option.
.It Fn ansify_if value color bool
Render the given
.Ar value
@@ -928,112 +1124,330 @@ as a string, applying the proper ANSI escape codes to display it in the given
if
.Ar bool
is true. It typically checks the value of the option
-.Nm Fl \-color ,
+.Fl \-color ,
for example:
-.Dl ansify_if(amount, "blue", options.color)
-.It Nm beg_line
-.It Nm beg_pos
-.It Nm calculated
-.It Nm cleared
-.It Nm code
-.It Nm comment
-.It Nm commodity
-.It Nm cost
-.It Nm count
-.It Nm date
-.It Nm depth
-.It Nm depth_spacer
-.It Nm display_amount
-.It Nm display_total
-.It Nm end_line
-.It Nm end_pos
-.It Nm filename
-.It Nm format_date
-.It Nm get_at
-.It Nm has_meta
-.It Nm has_tag
-.It Nm is_seq
-.It Nm join
-.It Nm market
-.It Nm meta
-.It Nm note
-.It Nm null
-.It Nm options
-.It Nm partial_account
-.It Nm payee
-.It Nm pending
-.It Nm post
-.It Nm print
-.It Nm quantity
-.It Nm quoted
-.It Nm real
-.It Nm rounded
-.It Nm scrub
-.It Nm status
-.It Nm strip
-.It Nm subcount
-.It Nm tag
-.It Nm today
-.It Nm total
-.It Nm total_expr
-.It Nm truncate
-.It Nm uncleared
-.It Nm virtual
-.It Nm xact
+.Dl Li ansify_if(amount, "blue", options.color)
+.It Sy beg_line
+Line number where entry for posting begins.
+.It Sy beg_pos
+Character position where entry for posting begins.
+.\".It Sy calculated
+.It Fn ceiling value
+Return the next integer of
+.Ar value
+toward +infinity.
+.It Sy cleared
+Return true if the posting was cleared, false otherwise.
+.It Sy code
+Return the transaction code, the string between the parenthesis after the date.
+.\".It Sy comment
+.It Fn commodity value
+Return the commodity of
+.Ar value
+or the posting amount when
+.Ar value
+was not specified.
+.\".It Sy cost
+.\".It Sy count
+.It Sy date
+Return the date of the posting.
+.\".It Sy depth
+.\".It Sy depth_spacer
+.\".It Sy display_amount
+.\".It Sy display_total
+.It Sy end_line
+Line number where entry for posting ends.
+.It Sy end_pos
+Character position where entry for posting ends.
+.It Fn floor value
+Return the next integer of
+.Ar value
+toward -infinity.
+.It Sy filename
+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
+as a string using
+.Ar format .
+Refer to
+.Xr strftime 3
+for format string details.
+.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 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
+at
+.Ar datetime .
+Note that
+.Ar datetime
+must be surrounded by brackets in order to be parsed correctly, e.g.
+.Bq 2012/03/23 .
+.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
+using the long option names, e.g. to see whether
+.Fl \-daily Pq Fl D
+was given use
+.Sy option.daily .
+.\" .It Sy partial_account
+.It Sy payee
+Return the payee of the posting.
+.It Fn percent value_a value_b
+Return the percentage of
+.Ar value_a
+in relation to
+.Ar value_b
+(used as 100%).
+.It Sy pending
+Return true if the posting is marked as pending, false otherwise.
+.It Fn percent value_a value_b
+Return the percentage of
+.Ar value_a
+in relation to
+.Ar value_b .
+.\".It Sy post
+.\" A variable scope
+.It Fn print value
+Print
+.Ar value
+to stdout.
+Used internally for debugging.
+.It Fn quantity value
+Return the quantity of
+.Ar value
+for values that have a per-unit cost.
+.It Fn quoted expression
+Surround
+.Ar expression
+with double-quotes.
+.It Sy real
+.\" Is there a difference between real and actual?
+Return true if the transaction is real, i.e not a automated or virtual
+transaction, false otherwise.
+.\".It Sy rounded
+.It Fn roundto value n
+Return
+.Ar value
+rounded to
+.Ar n
+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 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
+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
+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.
+.It Sy total
+Return the total of the posting.
+.It Sy total_expr
+Return the calculated total of the posting according to the
+.Fl \-total
+option.
+.It Fn trim value
+Trim leading and trailing whitespace from
+.Ar value .
+.It Fn truncated string, total_len, account_len
+Truncate
+.Ar string
+to
+.Ar total_len
+enusring 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.
+.\".It Sy xact
+.\" A variable scope
.El
-.Pp
-.Sh ENTRIES
-.Pp
-.Sh FORMATS
-.Pp
+.\".Sh ENTRIES
+.\".Sh FORMATS
.Sh DEBUG COMMANDS
-In addition to the regular reporting commands, Ledger also accepts several
+In addition to the regular reporting commands,
+.Nm
+also accepts several
debug commands:
.Bl -tag -width balance
-.It Nm args Oo Ar report-query Oc
-Accepts a
-.Ar report-query
-as its argument and displays it back to the user along with a complete
-analysis of how Ledger interpreted it. Useful if you want to understand how
-report queries are translated into value expressions.
-.It Nm eval Oo Ar value-expression Oc
-Evaluates the given
+.It Ic args Oo Ar report-query Oc
+Display complete analysis of how
+.Nm
+interpreted the given
+.Ar report-query .
+Useful if you want to understand how report queries are translated into value
+expressions.
+.It Ic eval Oo Ar value-expression Oc
+Evaluate the given
.Ar value-expression
and prints the result. For more on value expressions, see the section
.Sx EXPRESSIONS .
-.It Nm format Oo Ar format-string Oc
-Accepts a
+.It Ic format Oo Ar format-string Oc
+Display an analysis of how
.Ar format-string
-and displays an analysis of how it was parsed, and what it would look like
-applied to a sample transaction. For more on format strings, see the section
+was parsed, and what it would look like applied to a sample transaction. For
+more on format strings, see the section
.Sx FORMATS .
-.It Nm generate
-Generates 50 randomly composed yet valid Ledger transactions.
-.It Nm parse Oo Ar value-expression Oc
-Parses the given
+.It Ic generate
+Generate 50 randomly composed yet valid
+.Nm
+transactions.
+.It Ic parse Oo Ar value-expression Oc
+Parse the given
.Ar value-expression
and display an analysis of the expression tree and its evaluated value. For
more on value expressions, see the section
.Sx EXPRESSIONS .
-.It Nm python Oo Ar file Oc
-Invokes a Python interpreter to read the given
+.It Ic python Oo Ar file Oc
+Invoke a Python interpreter to read the given
.Ar file .
-What is special about this is that the ledger module is builtin, not read from
-disk, so it doesn't require Ledger to be installed anywhere, or the shared
+What is special about this is that the
+.Nm
+module is builtin, not read from
+disk, so it doesn't require
+.Nm
+to be installed anywhere, or the shared
library variants to be built.
-.It Nm reload
-Used only in the
-.Tn REPL ,
-it causes an immediate reloading of all data files for the current session.
-.It Nm template Oo Ar draft-template Oc
-Accepts a
+.It Ic reload
+Reload all data files for the current session immediately.
+Can only be used in the
+.Tn REPL .
+.It Ic template Oo Ar draft-template Oc
+Display information about how
.Ar draft-template
-and displays information about how it was parsed. See the section on
+was parsed. See the section on
.Sx DRAFTS .
.El
-.Pp
+.Sh ENVIRONMENT
+Every option to
+.Nm
+may be set using an environment variable if the option has a long name.
+For example setting the environment variable
+.Ev LEDGER_DATE_FORMAT="%d.%m.%Y'
+will have the same effect as specifying
+.Fl \-date-format Ar '%d.%m.%Y'
+on the command-line. Options on the command-line always take precedence over
+environment variable settings, however.
+.Sh FILES
+.Bl -tag -width -indent
+.It Pa ~/.ledgerrc
+Your personal
+.Nm
+initializations.
+.El
.Sh SEE ALSO
-.Xr beancount 1,
+.Xr beancount 1 ,
.Xr hledger 1
.Sh AUTHORS
.An "John Wiegley"
diff --git a/doc/ledger3.texi b/doc/ledger3.texi
index 4dc3f48f..c4266c20 100644
--- a/doc/ledger3.texi
+++ b/doc/ledger3.texi
@@ -1,6 +1,8 @@
\input texinfo @c -*-texinfo-*-
@setfilename ledger3.info
+@include version.texi
+@set FIXME:UNDOCUMENTED @sc{undocumented}! Please help by contributing documentation for this feature.
@settitle Ledger: Command-Line Accounting
@c Before release, run C-u C-c C-u C-a (texinfo-all-menus-update with
@@ -56,7 +58,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
@@ -86,6 +88,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
@@ -146,7 +161,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@titlepage
@title Ledger: Command-Line Accounting
-@subtitle For Version 3.1 of Ledger
+@subtitle For Version @value{VERSION} of Ledger
@author John Wiegley
@page
@vskip 0pt plus 1filll
@@ -160,7 +175,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@node Top, Introduction to Ledger, (dir), (dir)
@top Overview
-Ledger is a command line accounting tool that provides double-entry
+Ledger is a command-line accounting tool that provides double-entry
accounting based on a text journal. It provides no bells or whistles,
and returns the user to the days before user interfaces were even a
twinkling in their father's CRT.
@@ -175,7 +190,7 @@ twinkling in their father's CRT.
* Transactions::
* Building Reports::
* Reporting Commands::
-* Command-line Syntax::
+* Command-Line Syntax::
* Budgeting and Forecasting::
* Time Keeping::
* Value Expressions::
@@ -286,7 +301,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
@@ -366,26 +381,33 @@ data, not for altering it.
@node Building the program, Getting help, Fat-free Accounting, Introduction to Ledger
@section Building the program
-Ledger is written in ANSI C++, and should compile on any platform. It
-depends on the GNU multiple precision arithmetic library (libgmp), and
-the Perl regular expression library (libpcre). It was developed using
-GNU make and gcc 3.3, on a PowerBook running OS/X.
-
-To build and install once you have these libraries on your system,
-enter these commands:
+Ledger is written in ANSI C++, and should compile on any unix platform.
+The easiest way to build and install ledger is to use the prepared
+acprep script, that does a lot of the footwork:
@smallexample
-$ ./configure && make install
+ # to install missing dependencies
+ ./acprep dependencies
+ # building ledger
+ ./acprep update
+ # to run the actual installation
+ make install
@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
+`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
@@ -423,17 +445,17 @@ If you would rather start with your own journal right away please
* Balance Report::
* Register Report::
* Cleared Report::
-* Using the Windows Command Line::
+* Using the Windows Command-Line::
@end menu
-Please note that as a command line program, Ledger is controlled from
+Please note that as a command-line program, Ledger is controlled from
your shell. There are several different command shells that all
behave slightly differently with respect to some special characters.
In particular, the ``bash'' shell will interpret @samp{$} signs
differently than ledger and they must be escaped to reach the actual
program. Another example is ``zsh'', which will interpret @samp{^}
differently than ledger expects. In all cases that follow you should
-take that into account when entering the command line arguments as given.
+take that into account when entering the command-line arguments as given.
There are too many variations between shells to give concrete examples
for each.
@@ -595,7 +617,7 @@ $ ledger -f drewr3.dat register payee "Organic"
Assets:Checking $ -225.00 0
@end smallexample
-@node Cleared Report, Using the Windows Command Line, Register Report, Run a Few Reports
+@node Cleared Report, Using the Windows Command-Line, Register Report, Run a Few Reports
@subsection Cleared Report
@cindex cleared report
@findex cleared
@@ -630,7 +652,7 @@ $ ledger -f drewr3.dat cleared
$ -20.00 0 MasterCard
$ 200.00 0 Mortgage:Principal
$ -243.60 0 Tithe
----------------- ---------------- ---------
+---------------- ---------------- ---------
$ -243.60 0
@end smallexample
@@ -638,8 +660,8 @@ $ ledger -f drewr3.dat cleared
The first column shows the outstanding balance, the second column
shows the ``cleared'' balance.
-@node Using the Windows Command Line, , Cleared Report, Run a Few Reports
-@subsection Using the Windows Command Line
+@node Using the Windows Command-Line, , Cleared Report, Run a Few Reports
+@subsection Using the Windows Command-Line
@cindex windows cmd.exe
@cindex currency symbol display on windows
@@ -1075,10 +1097,10 @@ the left value's commodity. The result of this command might be:
@menu
* Commodity price histories::
-* Commodity equivalencies::
+* Commodity equivalences::
@end menu
-@node Commodity price histories, Commodity equivalencies, Commodities and Currencies, Commodities and Currencies
+@node Commodity price histories, Commodity equivalences, Commodities and Currencies, Commodities and Currencies
@subsection Commodity price histories
Whenever a commodity is purchased using a different commodity (such as
@@ -1100,13 +1122,13 @@ its various reports. It will always report balances in terms of the
commodity total, rather than the current value of those commodities.
To enable pricing reports, use one of the commodity reporting options.
-@node Commodity equivalencies, , Commodity price histories, Commodities and Currencies
-@subsection Commodity equivalencies
+@node Commodity equivalences, , Commodity price histories, Commodities and Currencies
+@subsection Commodity equivalences
Sometimes a commodity has several forms which are all equivalent. An
example of this is time. Whether tracked in terms of minutes, hours
or days, it should be possible to convert between the various forms.
-Doing this requires the use of commodity equivalencies.
+Doing this requires the use of commodity equivalences.
For example, you might have the following two postings, one which
transfers an hour of time into a @samp{Billable} account, and another
@@ -1134,10 +1156,12 @@ $ 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 equivalencies is simple. The following is an example that
-creates data equivalencies, helpful for tracking bytes, kilobytes,
+other equivalences is simple. The following is an example that
+creates data equivalences, helpful for tracking bytes, kilobytes,
megabytes, and more:
@smallexample @c input:validate
@@ -1152,7 +1176,7 @@ and a default precision, with a certain quantity of another commodity.
In the above example, kilobytes are reported with two decimal places
of precision and each kilobyte is equal to 1024 bytes.
-Equivalency chains can be as long as desired. Whenever a commodity
+Equivalence chains can be as long as desired. Whenever a commodity
would report as a decimal amount (less than @samp{1.00}), the next
smallest commodity is used. If a commodity could be reported in terms
of a higher commodity without resulting to a partial fraction, then
@@ -1375,7 +1399,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
@@ -1522,7 +1546,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
@@ -1543,7 +1567,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:
@@ -1591,7 +1615,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
@@ -1652,7 +1676,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''
@@ -1683,7 +1707,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:
@@ -1740,7 +1764,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
@@ -1834,8 +1858,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:
@@ -1866,7 +1890,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
@@ -1875,16 +1899,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
@@ -1892,14 +1916,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
@@ -1907,7 +1931,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
@@ -1915,7 +1939,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
@@ -1998,10 +2022,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
@@ -2017,7 +2040,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
@@ -2081,6 +2104,7 @@ the syntax @code{[ACTUAL_DATE]} or @code{[=EFFECTIVE_DATE]} or
@item P
@findex --download
+@findex P
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:
@@ -2107,7 +2131,7 @@ postings, just as if it were a normal transaction.
@item ; # % | *
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 ;
@@ -2205,7 +2229,7 @@ until an @samp{end apply account} directive was found.
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:
-@smallexample @c input:validate
+@smallexample @c input:94A99E8
alias Dining=Expenses:Entertainment:Dining
alias Checking=Assets:Credit Union:Joint Checking Account
@@ -2218,11 +2242,11 @@ The aliases are only in effect for transactions read in after the alias
is defined and are affected by @code{account} directives that precede
them.
-@smallexample @c command:validate
+@smallexample @c command:94A99E8
$ ledger bal --no-total ^Exp
@end smallexample
-@smallexample
+@smallexample @c output:94A99E8
$10.00 Expenses:Entertainment:Dining
@end smallexample
@@ -2230,7 +2254,7 @@ With the option @option{--recursive-aliases}, aliases can refer to other
aliases, the following example produces exactly the same transactions
and account names as the preceding one:
-@smallexample @c input:validate
+@smallexample @c input:83E1FB3
alias Entertainment=Expenses:Entertainment
alias Dining=Entertainment:Dining
alias Checking=Assets:Credit Union:Joint Checking Account
@@ -2240,11 +2264,11 @@ alias Checking=Assets:Credit Union:Joint Checking Account
Checking
@end smallexample
-@smallexample @c command:validate
+@smallexample @c command:83E1FB3
$ ledger balance --no-total --recursive-aliases ^Exp
@end smallexample
-@smallexample
+@smallexample @c output:83E1FB3
$10.00 Expenses:Entertainment:Dining
@end smallexample
@@ -2261,6 +2285,7 @@ assert <VALUE EXPRESSION BOOLEAN RESULT>
@end smallexample
@item bucket
+@anchor{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
@@ -2290,7 +2315,7 @@ bucket Assets:Checking
@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
@@ -2351,7 +2376,7 @@ The @code{default} sub-directive marks this as the ``default'' commodity.
@item 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
@@ -2434,15 +2459,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
@@ -2503,7 +2527,7 @@ 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.
@@ -2539,6 +2563,7 @@ This is a synonym for @code{comment} and must be closed by an
@code{end} tag.
@item year
+@anchor{year}
@c instance_t::year_directive in textual.cc
Denotes the year used for all subsequent transactions that give a date
without a year. The year should appear immediately after the
@@ -2554,24 +2579,28 @@ alone, for backwards compatibility with older Ledger versions.
@table @code
@item A
-See @code{bucket}.
+@findex A
+@xref{bucket}.
@item Y
-See @code{year}.
+@findex Y
+@xref{year}.
@item N SYMBOL
+@findex N
Indicates that pricing information is to be ignored for a given
symbol, nor will quotes ever be downloaded for that symbol. Useful
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
@@ -2586,6 +2615,7 @@ D $1,000.00
@end smallexample
@item C AMOUNT1 = AMOUNT2
+@findex C
Specifies a commodity conversion, where the first amount is given to
be equivalent to the second amount. The first amount should use the
decimal precision desired during reporting:
@@ -2595,6 +2625,12 @@ C 1.00 Kb = 1024 bytes
@end smallexample
@item I, i, O, o, b, h
+@findex I
+@findex i
+@findex O
+@findex o
+@findex b
+@findex h
These four relate to timeclock support, which permits Ledger to read
timelog files. See timeclock's documentation for more info on the
syntax of its timelog files.
@@ -2826,7 +2862,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
@@ -2970,17 +3006,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
@@ -2989,14 +3025,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
@@ -3098,6 +3140,7 @@ the amount expression with parentheses:
@node Balance verification, Posting cost, Expression amounts, Transactions
@section Balance verification
+@findex --permissive
@menu
* Balance assertions::
@@ -3109,7 +3152,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.
+specified. See @option{--permissive} option to relax the balance assertions checks.
There are two forms of this features: balance assertions, and balance
assignments.
@@ -3389,7 +3432,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
@@ -3397,10 +3440,10 @@ double braces price form is a shorthand only.
Plus, it comes with dangers. This works fine:
-@smallexample
+@smallexample @c input:validate
2012-04-10 My Broker
Assets:Brokerage 10 AAPL @@ $50.00
- Assets:Brokerage:Cash $750.00
+ Assets:Brokerage:Cash $-500.00
2012-04-10 My Broker
Assets:Brokerage:Cash $375.00
@@ -3463,7 +3506,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
@@ -3549,13 +3592,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
@@ -3606,7 +3649,7 @@ after modifying them to suit your needs.
An automated transaction is a special kind of transaction which adds
its postings to other transactions any time one of that other
transactions' postings matches its predicate. The predicate uses the
-same query syntax as the Ledger command line.
+same query syntax as the Ledger command-line.
Consider this posting:
@@ -3811,7 +3854,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.
@@ -3859,7 +3902,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
@@ -3906,7 +3949,7 @@ $ ledger --effective register Groceries
A periodic transaction starts with a @samp{~} followed by a period
expression. 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
@@ -4020,7 +4063,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.
@@ -4158,7 +4201,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
@@ -4167,8 +4210,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
@@ -4260,11 +4302,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
@@ -4273,7 +4315,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
@@ -4284,12 +4326,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
@@ -4298,6 +4337,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
@@ -4316,23 +4367,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
@@ -4350,7 +4399,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.
@@ -4364,13 +4413,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
@@ -4393,7 +4442,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
@@ -4409,7 +4458,7 @@ transactions @emph{displayed} to just those since last February, even
though those transactions from before will be computed as part of the
balance.
-@node Reporting Commands, Command-line Syntax, Building Reports, Top
+@node Reporting Commands, Command-Line Syntax, Building Reports, Top
@chapter Reporting Commands
@menu
@@ -4548,9 +4597,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}.
@@ -4577,7 +4626,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:
@@ -4589,24 +4638,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
@@ -4617,7 +4711,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.
@@ -4664,7 +4758,7 @@ a very naive but still useful application of the Babel system:
The following are some entries and I have requested that ledger be run
to generate a balance on the accounts. I could have asked for
a register or, in fact, anything at all the ledger can do through
-command line options.
+command-line options.
#+begin_src ledger :cmdline bal :results value
2010/01/01 * Starting balance
@@ -4703,7 +4797,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:
@@ -4715,7 +4809,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
@@ -4754,7 +4848,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
@@ -4784,11 +4878,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:
@@ -4808,7 +4902,7 @@ evaluating this code block (@kbd{C-c C-c}) would be:
If, instead, you wished to generate a register of all the transactions,
you would change the @code{#+begin_src} line for the code block to
-include the required command line option:
+include the required command-line option:
@smallexample
#+begin_src ledger :cmdline reg
@@ -4818,16 +4912,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.
@@ -4838,9 +4932,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
@@ -4868,7 +4962,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
@@ -4888,8 +4982,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.
@@ -4899,7 +4993,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.
@@ -4945,7 +5039,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).
@@ -4971,7 +5065,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
@@ -4992,7 +5086,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.
@@ -5005,7 +5099,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
@@ -5200,7 +5294,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.
@@ -5210,11 +5304,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
@@ -5294,7 +5390,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
@@ -5302,28 +5398,28 @@ with Ledger 2.X.
@findex stats
@findex stat
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@node @command{select}, , @command{stats}, Reports about your Journals
@subsection @command{select}
@findex select
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
-@node Command-line Syntax, Budgeting and Forecasting, Reporting Commands, Top
-@chapter Command-line Syntax
+@node Command-Line Syntax, Budgeting and Forecasting, Reporting Commands, Top
+@chapter Command-Line Syntax
@menu
* Basic Usage::
-* Command Line Quick Reference::
+* Command-Line Quick Reference::
* Detailed Option Description::
* Period Expressions::
@end menu
-@node Basic Usage, Command Line Quick Reference, Command-line Syntax, Command-line Syntax
+@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.
@@ -5364,8 +5460,8 @@ There are many, many command options available with the @file{ledger}
program, and it takes a while to master them. However, none of them are
required to use the basic reporting commands.
-@node Command Line Quick Reference, Detailed Option Description, Basic Usage, Command-line Syntax
-@section Command Line Quick Reference
+@node Command-Line Quick Reference, Detailed Option Description, Basic Usage, Command-Line Syntax
+@section Command-Line Quick Reference
@menu
* Basic Reporting Commands::
@@ -5377,10 +5473,10 @@ required to use the basic reporting commands.
* Commodity Reporting::
@end menu
-@node Basic Reporting Commands, Basic Options, Command Line Quick Reference, Command Line Quick Reference
+@node Basic Reporting Commands, Basic Options, Command-Line Quick Reference, Command-Line Quick Reference
@subsection Basic Reporting Commands
-@ftable @code
+@ftable @command
@item balance
@itemx bal
@@ -5419,17 +5515,16 @@ Generate transactions based on previous postings.
@end ftable
-@node Basic Options, Report Filtering, Basic Reporting Commands, Command Line Quick Reference
+@node Basic Options, Report Filtering, Basic Reporting Commands, Command-Line Quick Reference
@subsection Basic Options
-@ftable @code
+@ftable @option
@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}
@@ -5444,16 +5539,19 @@ Redirect output to @file{FILE}.
@itemx -i @var{FILE}
Specify an options file.
+@item --import @var{FILE}
+Import @var{FILE} as Python module.
+
@item --account @var{STR}
@itemx -a @var{STR}
Specify default account @var{STR} for QIF file postings.
@end ftable
-@node Report Filtering, Error Checking and Calculation Options, Basic Options, Command Line Quick Reference
+@node Report Filtering, Error Checking and Calculation Options, Basic Options, Command-Line Quick Reference
@subsection Report Filtering
-@ftable @code
+@ftable @option
@item --current
@itemx -c
@@ -5506,7 +5604,8 @@ Show unbudgeted postings.
@item --unbudgeted
Show only unbudgeted postings.
-@item --forecast @var{VEXPR}
+@item --forecast-while @var{VEXPR}
+@itemx --forecast @var{VEXPR}
Project balances into the future.
@item --limit @var{EXPR}
@@ -5524,10 +5623,10 @@ Change the value expression used for ``totals'' column in
@end ftable
-@node Error Checking and Calculation Options, Output Customization, Report Filtering, Command Line Quick Reference
+@node Error Checking and Calculation Options, Output Customization, Report Filtering, Command-Line Quick Reference
@subsection Error Checking and Calculation Options
-@ftable @code
+@ftable @option
@item --strict
Accounts, tags or commodities not previously declared will cause
@@ -5538,7 +5637,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
@@ -5546,10 +5645,10 @@ Instruct ledger to evaluate calculations immediately rather than lazily.
@end ftable
-@node Output Customization, Grouping Options, Error Checking and Calculation Options, Command Line Quick Reference
+@node Output Customization, Grouping Options, Error Checking and Calculation Options, Command-Line Quick Reference
@subsection Output Customization
-@ftable @code
+@ftable @option
@item --collapse
@itemx -n
@@ -5598,6 +5697,9 @@ Report the last @var{INT} postings.
@item --pager @var{FILE}
Direct output to @var{FILE} pager program.
+@item --no-pager
+Direct output to stdout, avoiding pager program.
+
@item --average
@itemx -A
Report the average posting value.
@@ -5650,10 +5752,10 @@ for filing bug reports.
@end ftable
-@node Grouping Options, Commodity Reporting, Output Customization, Command Line Quick Reference
+@node Grouping Options, Commodity Reporting, Output Customization, Command-Line Quick Reference
@subsection Grouping Options
-@ftable @code
+@ftable @option
@item --by-payee
@itemx -P
@@ -5687,15 +5789,16 @@ Group postings together, similar to the balance report.
@end ftable
-@node Commodity Reporting, , Grouping Options, Command Line Quick Reference
+@node Commodity Reporting, , Grouping Options, Command-Line Quick Reference
@subsection Commodity Reporting
-@ftable @code
+@ftable @option
@item --price-db @var{FILE}
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.
@@ -5703,8 +5806,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
@@ -5724,7 +5828,7 @@ Report net gain or loss for commodities that have a price history.
@end ftable
-@node Detailed Option Description, Period Expressions, Command Line Quick Reference, Command-line Syntax
+@node Detailed Option Description, Period Expressions, Command-Line Quick Reference, Command-Line Syntax
@section Detailed Option Description
@menu
@@ -5748,7 +5852,7 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
+@ftable @option
@item --args-only
Ignore all environment and init-file settings and
@@ -5757,52 +5861,48 @@ or testing small journal files not associated with your main financial
database.
@item --debug @var{CODE}
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@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 @file{~/.ledgerrc}.
@item --options
Display the options in effect for this Ledger invocation, along with
their values and the source of those values, for example:
-@smallexample
-$ ledger --options bal --cleared -f ~/ledger/test/input/drewr3.dat
-===========================================================================
+@smallexample @c command:A9349E4,with_input:03ACB97
+$ ledger --options bal --cleared
+@end smallexample
+
+@smallexample @c output:A9349E4
+===============================================================================
[Global scope options]
+ --args-only --args-only
[Session scope options]
- --file = ~/ledger/test/input/drewr3.dat -f
- --price-db = ~/FinanceData/PriceDB $price-db
+ --file = A9349E4.dat --file
[Report scope options]
- --cleared --cleared
- --color ?normalize
- --date-format = %Y/%m/%d $date-format
- --limit = cleared --cleared
- --prepend-width = 0 ?normalize
- --meta-width = 0 ?normalize
- --date-width = 10 ?normalize
- --payee-width = 21 ?normalize
- --account-width = 21 ?normalize
- --amount-width = 12 ?normalize
- --total-width = 12 ?normalize
-===========================================================================
- $ 775.00 Assets:Checking
- $ -1,000.00 Equity:Opening Balances
- $ 225.00 Expenses:Food:Groceries
+ --cleared --cleared
+ --columns = 80 --columns
+ --limit = cleared --cleared
+===============================================================================
+ $15.00 Expenses
+ $12.45 Food
+ $2.55 Tips
+ $-15.00 Liabilities:MasterCard
--------------------
0
@end smallexample
@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
+indicated the source was a command-line argument. If the entry starts
+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}.
@@ -5810,20 +5910,22 @@ a function called @code{normalize_options}.
Execute a ledger script.
@item --trace @var{INT}
-FIX THIS ENTRY @c FIXME thdox
+Enable tracing. The @var{INT} specifies the level of trace desired.
@item --verbose
@itemx -v
-FIX THIS ENTRY @c FIXME thdox
+Print detailed information on the execution of Ledger.
@item --verify
-FIX THIS ENTRY @c FIXME thdox
+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
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@item --version
-FIX THIS ENTRY @c FIXME thdox
+Print version information and exit.
@end ftable
@@ -5837,16 +5939,25 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
-
-@item --cache @var{FIXME}
-FIX THIS ENTRY @c FIXME thdox
+@ftable @option
@item --check-payees
-FIX THIS ENTRY @c FIXME thdox
+Enable strict and pedantic checking for payees as well as accounts,
+commodities and tags. This only works in conjunction with
+@option{--strict} or @option{--pedantic}.
@item --day-break
-FIX THIS ENTRY @c FIXME thdox
+Break up @command{register} report of @ref{timelog} entries that span multiple
+days by day.
+@c see test/baseline/opt-day-break.dat
+@c @smallexample @c input:
+@c i 2015/
+@c @end smallexample
+@c @smallexample @c command:
+@c $ ledger reg --day-break
+@c @end smallexample
+@c @smallexample @c output:
+@c @end smallexample
@item --decimal-comma
Direct Ledger to parse journals using the European standard comma as
@@ -5854,24 +5965,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
-FIX THIS ENTRY @c FIXME thdox
+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"
@@ -5916,18 +6032,18 @@ Ledger does not expand any aliases if this option is specified.
Accounts, tags or commodities not previously declared will cause errors.
@item --permissive
-FIX THIS ENTRY @c FIXME thdox
+Quiet balance assertions.
@item --price-db @var{FILE}
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
@@ -5940,7 +6056,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.
@@ -5951,8 +6067,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}
-FIX THIS ENTRY @c FIXME thdox
+@item --value-expr @var{VEXPR}
+Set a global value expression annotation.
+@c needs example
@end ftable
@@ -5966,18 +6083,18 @@ GUIs, which would make use of the different scopes by keeping an
instance of Ledger running in the background and running multiple
sessions with multiple reports per session.
-@ftable @code
+@ftable @option
@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.
@@ -5996,7 +6113,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
@@ -6012,7 +6129,9 @@ Set the width in characters of the amount column in the
Anonymize registry output, mostly for sending in bug reports.
@item --auto-match
-FIX THIS ENTRY @c FIXME thdox
+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
@@ -6025,7 +6144,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))"
@@ -6036,7 +6155,9 @@ Strings}). The default is:
@end smallexample
@item --base
-FIX THIS ENTRY @c ASK JOHN
+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
@@ -6044,7 +6165,7 @@ FIX THIS ENTRY @c ASK JOHN
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}
@@ -6060,7 +6181,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}).
@@ -6086,9 +6207,9 @@ Consider only transactions that have been cleared for display and
calculation.
@item --cleared-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox: to keep?
+@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, "
@@ -6104,7 +6225,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
@@ -6155,8 +6276,8 @@ Specify the format ledger should use to read and print dates
Specify the width, in characters, of the date column in the
@command{register} report.
-@item --datetime-format @var{FIXME}
-FIX THIS ENTRY @c ASK JOHN
+@item --datetime-format @var{DATETIME_FORMAT}
+Specify the format ledger should use to print datetimes.
@item --dc
Display register or balance in debit/credit format If you use
@@ -6221,11 +6342,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}
@@ -6256,7 +6377,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}
@@ -6264,28 +6385,29 @@ command}). Gives current account balances in the form of a register
report.
@item --exact
-FIX THIS ENTRY @c ASK JOHN
+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
will not automatically covert any other commodities to
@var{COMMODITY2}. Multiple @option{-X} arguments may be used on a
-single command line (as in
+single command-line (as in
@option{-X COMMODITY1:COMMODITY2 -X COMMODITY3:COMMODITY2}),
which is particularly useful for situations where many prices are
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
@@ -6315,15 +6437,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
@@ -6331,21 +6455,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
-FIX THIS ENTRY @c FIXME thdox
+Value commodities at the time of their acquisition.
@item --immediate
-FIX THIS ENTRY @c FIXME thdox
+Evaluate calculations immediately rather than lazily.
@item --inject
Use @code{Expected} amounts in calculations. In case you know
@@ -6386,7 +6510,8 @@ Report the date and price at which each commodity was purchased in
a balance report.
@item --lots-actual
-FIX THIS ENTRY
+Preserve the uniqueness of commodities so they aren't merged during
+reporting without printing the lot annotations.
@item --market
@itemx -V
@@ -6410,8 +6535,15 @@ Aliases are completely ignored.
@item --no-color
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.
@@ -6433,10 +6565,10 @@ been executed, such as periodic gathering.
Redirect the output of ledger to the file defined in @file{FILE}.
@item --pager @var{FILE}
-Specify the pager program to use.
+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.
@@ -6454,20 +6586,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
@@ -6481,11 +6615,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}
@@ -6499,10 +6633,10 @@ Reserve @var{INT} spaces at the beginning of each line of the output.
Use the price of the commodity purchase for performing calculations.
@item --pricedb-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox
+Set the format expected for the historical price file.
@item --prices-format @var{FORMAT_STRING}
-FIX THIS ENTRY @c FIXME thdox
+Set the format for the @command{prices} report.
@item --primary-date
@itemx --actual-dates
@@ -6538,20 +6672,24 @@ Show all postings in a transaction, similar to @option{--related} but
show both @emph{sides} of each transaction.
@item --revalued
-FIX THIS ENTRY
+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
-FIX THIS ENTRY
+Show only @code{<Revalued>} postings.
@item --revalued-total @var{FIXME}
-FIX THIS ENTRY
+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
-FIX THIS ENTRY @c FIXME thdox
+When generating a ledger transaction from a CSV file using the
+@command{convert} command, add CSV, Imported, and UUID metadata.
-@item --seed @var{FIXME}
-Set the random seed to @var{FIXME} for the @code{generate} command.
+@item --seed @var{INT}
+Set the random seed to @var{INT} for the @code{generate} command.
Used as part of development testing.
@item --sort @var{VEXPR}
@@ -6560,7 +6698,7 @@ Sort the @command{register} report based on the value expression given
to sort.
@item --sort-all @var{FIXME}
-FIX THIS ENTRY
+@value{FIXME:UNDOCUMENTED}
@item --sort-xacts @var{VEXPR}
@itemx --period-sort @var{VEXPR}
@@ -6568,20 +6706,21 @@ 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
-FIX THIS ENTRY
+@value{FIXME:UNDOCUMENTED}
@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
-FIX THIS ENTRY @c FIXME thdox
+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}
@@ -6596,8 +6735,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'').
@@ -6614,12 +6753,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
@@ -6651,12 +6790,11 @@ These are the most basic command options. Most likely, the user will
want to set them using environment variables (see @ref{Environment
variables}), instead of using actual command-line options:
-@ftable @code
+@ftable @option
@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
@@ -6665,9 +6803,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}
@@ -6683,7 +6821,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
@@ -6705,7 +6843,7 @@ relate to.
These options change which postings affect the outcome of a
report, in ways other than just using regular expressions:
-@ftable @code
+@ftable @option
@item --current
@itemx -c
@@ -6870,7 +7008,7 @@ Set the value expression used for the ``totals'' column in the
These options affect only the output, but not which postings are
used to create it:
-@ftable @code
+@ftable @option
@item --collapse
@itemx -n
@@ -6922,7 +7060,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
@@ -6931,18 +7069,22 @@ 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).
@item --pager @var{FILE}
-Tell Ledger to pass its output to the given pager program; very useful
-when the output is especially long. This behavior can be made the
-default by setting the @env{LEDGER_PAGER} environment variable.
+Tell Ledger to pass its output to the given @var{FILE} pager program;
+very useful when the output is especially long. This behavior can be
+made the default by setting the @env{LEDGER_PAGER} environment variable.
+
+@item --no-pager
+Tell Ledger to @emph{not} pass its output to a pager program; useful
+when a pager is set by default.
@item --average
@itemx -A
@@ -6982,8 +7124,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
@@ -6991,8 +7132,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
@@ -7035,7 +7175,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),
@@ -7046,7 +7186,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}
@@ -7103,7 +7243,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"
@@ -7118,14 +7258,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,
@@ -7139,7 +7279,7 @@ Set the format for the @command{prices} report. The default is:
These options affect how commodity values are displayed:
-@ftable @code
+@ftable @option
@item --price-db @var{FILE}
Set the file that is used for recording downloaded commodity prices.
@@ -7148,7 +7288,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
@@ -7163,11 +7303,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
@@ -7189,7 +7330,7 @@ expressions, and the @option{--amount @var{EXPR} (-t)} and
several ``default'' reports, which will satisfy most users' basic
reporting needs:
-@ftable @code
+@ftable @option
@item --quantity
@itemx -O
@@ -7225,7 +7366,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.
@@ -7265,7 +7406,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
@@ -7377,21 +7518,20 @@ BTC:USD}.
@node Environment variables, , Commodity reporting, Detailed Option Description
@subsection Environment variables
-Every option to ledger may be set using an environment variable. If
-an option has a long name such @option{--this-option}, setting the
-environment variable @env{LEDGER_THIS_OPTION} will have the same
-effect as specifying that option on the command-line. Options on the
-command-line always take precedence over environment variable
-settings, however.
+Every option to ledger may be set using an environment variable if the
+option has a long name. For example setting the environment variable
+@samp{@env{LEDGER_DATE_FORMAT}="%d.%m.%Y"} will have the same effect as specifying
+@samp{@option{--date-format} '%d.%m.%Y'} on the command-line. Options on the
+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}, for example:
+option settings in the file @file{~/.ledgerrc} one option per line, for example:
-@smallexample
+@smallexample @c input:validate
--pager /bin/cat
@end smallexample
-@node Period Expressions, , Detailed Option Description, Command-line Syntax
+@node Period Expressions, , Detailed Option Description, Command-Line Syntax
@section Period Expressions
@c TODO use @var below
@@ -7479,7 +7619,7 @@ last oct
weekly last august
@end smallexample
-@node Budgeting and Forecasting, Time Keeping, Command-line Syntax, Top
+@node Budgeting and Forecasting, Time Keeping, Command-Line Syntax, Top
@chapter Budgeting and Forecasting
@menu
@@ -7525,7 +7665,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
@@ -7566,7 +7706,7 @@ makes this easy to do, using the same periodic transactions as are used
for budgeting. An example forecast report can be generated with:
@smallexample @c command:validate
-$ ledger --forecast "T>@{\$-500.00@}" register ^assets ^liabilities
+$ ledger --file drewr3.dat --forecast "T>@{\$-500.00@}" register ^assets ^liabilities
@end smallexample
This report continues outputting postings until the running total
@@ -7584,6 +7724,7 @@ $ ledger --forecast "d<[2010]" bal ^assets ^liabilities
@chapter Time Keeping
@findex --day-break
+@anchor{timelog}
Ledger directly supports ``timelog'' entries, which have this form:
@smallexample @c input:validate
@@ -7657,7 +7798,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
@@ -7666,7 +7807,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
@@ -7733,13 +7874,6 @@ 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 depth
The depth (``level'') of an account. If an account has one parent,
its depth is one.
@@ -7772,19 +7906,6 @@ and all its children.
The total count of postings affecting an account and all its
children.
-@item B
-The total cost of all postings seen so far; the total cost of an
-account and all its children.
-
-@item V
-The market value of all postings seen so far, or of an account and
-all its children.
-
-@item G
-The total net gain (market value minus cost basis), for a series of
-postings, or an account and its children. It is the same as
-@samp{V-B}.
-
@end table
@node Functions, Operators, Variables, Value Expressions
@@ -7803,10 +7924,6 @@ The absolute (unsigned) value of the argument.
@item S
Strips the commodity from the argument.
-@item A
-The arithmetic mean of the argument; @samp{Ax} is the same as
-@samp{x/n}.
-
@item P
The present market value of the argument. The syntax @samp{P(x,d)} is
supported, which yields the market value at time @samp{d}. If no date
@@ -7892,11 +8009,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
@@ -7904,7 +8021,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
@@ -7917,30 +8034,28 @@ 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
Expenses:Phone $-50.00
@end smallexample
-
-
@item (EXPR)
A sub-expression is nested in parenthesis. This can be useful passing
more complicated arguments to functions, or for overriding the natural
@@ -7968,61 +8083,337 @@ expect (@pxref{Pre-Commands}).
@node Miscellaneous, , Complex expressions, Complex expressions
@subsection Miscellaneous
-@table @code
-@item abs--> U
-@item amount_expr
-@item ansify_if
-@item ceiling
-Return the next integer toward +infinity
-@item code
-Return the transaction code, the string between the parenthesis after
-the date.
-@item commodity
-@item date
-@item display_amount --> t
-@item display_total --> T
-@item floor
-Return the next integer toward -infinity
-@item format
-@item format_date
-@item format_datetime
-@item get_at
-@item is_seq
-@item join
-@item justify
-@item market --> P
-@item nail_down
-@item now --> d m
-@item options
-@item percent
-@item print
-@item quantity
-@item quoted
-@item round
-@item rounded
-@item roundto
-Return value rounded to n digits. Does not affect formatting.
-@item scrub
-@item should_bold
-@item strip --> S
-@item to_amount
-@item to_balance
-@item to_boolean
-@item to_date
-@item to_datetime
-@item to_int
-@item to_mask
-@item to_sequence
-@item to_spring
-@item today
-@item top_amount
-@item total_expr
-@item trim
-@item truncated
-@item unround
-@item unrounded
-@item value_date
-@end table
+The following Ledger journal data (saved as @file{expr.dat}) is used to explain the behaviour of the
+functions and variables below:
+@anchor{expr.dat}
+@smallexample @c input:3406FC1
+2015/01/16 * (C0D3) Payee
+ Assets:Cash ¤ -123,45
+ ; Payee: PiggyBank
+ Expenses:Office Supplies
+@end smallexample
+
+@defun abs value
+@defunx U value
+Return the absolute value of the given @var{value}, e.g. @var{amount}.
+@smallexample @c command:3406FC1
+$ ledger -f expr.dat --format "%(account) %(abs(amount))\n" reg assets
+@end smallexample
+@smallexample @c output:3406FC1
+Assets:Cash ¤ 123,45
+@end smallexample
+@end defun
+
+@defun amount_expr
+@value{FIXME:UNDOCUMENTED}
+@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
+codes include non-printable character sequences, such as escape @kbd{^[}
+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
+@smallexample @c output:4D836EE
+Assets:Cash
+Expenses:Office Supplies
+@end smallexample
+@end defun
+
+@defun ceiling value
+Return the next integer of @var{value} toward @math{+}infinity.
+@smallexample @c command:FF9C18C,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(ceiling(amount))\n" reg
+@end smallexample
+@smallexample @c output:FF9C18C
+Assets:Cash ¤ -123,00
+Expenses:Office Supplies ¤ 124,00
+@end smallexample
+@end defun
+
+@defvar code
+Return the transaction code, the string between the parenthesis after the date.
+@smallexample @c command:46FCFD3,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(code)\n" reg assets
+@end smallexample
+@smallexample @c output:46FCFD3
+Assets:Cash C0D3
+@end smallexample
+@end defvar
+
+@defvar commodity
+Return the commodity of the posting amount.
+@end defvar
+@smallexample @c command:2CD27D7,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(commodity)\n" reg
+@end smallexample
+@smallexample @c output:2CD27D7
+Assets:Cash ¤
+Expenses:Office Supplies ¤
+@end smallexample
+
+@defvar date
+Return the date of the posting.
+@end defvar
+@smallexample @c command:67EBA45,with_input:3406FC1
+$ ledger -f expr.dat --format "%(date) %(account)\n" reg assets
+@end smallexample
+@smallexample @c output:67EBA45
+2015/01/16 Assets:Cash
+@end smallexample
+
+@defvar display_amount
+@defvarx t
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@c FIXME
+@defvar display_total
+@defvarx T
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@defun floor value
+Return the next integer of @var{value} toward @math{-}infinity.
+@smallexample @c command:4FDC7C5,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(floor(amount))\n" reg
+@end smallexample
+@smallexample @c output:4FDC7C5
+Assets:Cash ¤ -124,00
+Expenses:Office Supplies ¤ 123,00
+@end smallexample
+@end defun
+
+@defun format
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun format_date date format
+Return the @var{date} as a string using @var{format}. See 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
+@smallexample @c output:9605B13
+Friday, January 16. 2015
+@end smallexample
+@end defun
+
+@defun format_datetime
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun get_at
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun is_seq
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun join
+@value{FIXME:UNDOCUMENTED}
+@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 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
+$ ledger -f expr.dat --format "»%(justify(account, 30, 30, true))«\n" reg
+@end smallexample
+@smallexample @c output:082FB27
+» Assets:Cash«
+» Expenses:Office Supplies«
+@end smallexample
+@end defun
+
+@defun market
+@defunx P
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun nail_down
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defvar now
+@defvarx d
+@defvarx m
+@value{FIXME:UNDOCUMENTED}
+@end defvar
+
+@defvar options
+A variable that allows access to the values of the given command-line options
+using the long option names, e.g. to see whether @option{--daily} or @option{-D}
+was given use @code{option.daily}.
+@smallexample @c command:C1FC7A7,with_input:3406FC1
+$ ledger -f expr.dat -X $ -D --format "%(options.daily) %(options.exchange)\n" reg assets
+@end smallexample
+@smallexample @c output:C1FC7A7
+true $
+@end smallexample
+@end defvar
+
+@defun percent value_a value_b
+Return the percentage of @var{value_a} in relation to @var{value_b} (used as 100%)
+@smallexample @c command:04959BF,with_input:3406FC1
+$ ledger -f expr.dat --format "%(percent(amount, 200))\n" reg
+@end smallexample
+@smallexample @c output:04959BF
+-61.73%
+61.73%
+@end smallexample
+@end defun
+
+@defun print
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun quantity
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun quoted expression
+Surround @var{expression} with double-quotes.
+@smallexample @c command:EAD8AA7,with_input:3406FC1
+$ ledger -f expr.dat --format "%(quoted(account)) %(quoted(amount))\n" reg
+@end smallexample
+@smallexample @c output:EAD8AA7
+"Assets:Cash" "¤ -123,45"
+"Expenses:Office Supplies" "¤ 123,45"
+@end smallexample
+@end defun
+
+@defun round
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun rounded
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun roundto value n
+Return @var{value} rounded to @var{n} digits. Does not affect formatting.
+@smallexample @c command:B4DFB9F,with_input:3406FC1
+$ ledger -f expr.dat --format "%(account) %(roundto(amount, 1))\n" reg
+@end smallexample
+@smallexample @c output:B4DFB9F
+Assets:Cash ¤ -123,40
+Expenses:Office Supplies ¤ 123,50
+@end smallexample
+@end defun
+
+@defun scrub
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun should_bold
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun strip
+@defunx S
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_amount
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_balance
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_boolean
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_date
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_datetime
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_int value
+@defunx int value
+Return the integer value for @var{value}.
+@smallexample @c command:0B0CBA1,with_input:3406FC1
+$ ledger -f expr.dat --format "%(1 + to_int('1'))\n%(2,5 + int(2,5))\n" reg assets
+@end smallexample
+@smallexample @c output:0B0CBA1
+2
+4.5
+@end smallexample
+@end defun
+
+@defun to_mask
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_sequence
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun to_string value
+@defunx str value
+Convert @var{value} to a character string.
+@end defun
+
+@defvar today
+Return today's date.
+@end defvar
+@smallexample @c command:F2FDF4B,with_input:3406FC1
+$ ledger -f expr.dat --now 2015/01/01 --format "%(today)\n" reg assets
+@end smallexample
+@smallexample @c output:F2FDF4B
+2015/01/01
+@end smallexample
+
+@defun top_amount
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun total_expr
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun trim value
+Trim leading and trailing whitespace from @var{value}.
+@smallexample @c command:377BBAB,with_input:3406FC1
+$ ledger -f expr.dat --format "»%(trim(' Trimmed '))«\n" reg assets
+@end smallexample
+@smallexample @c output:377BBAB
+»Trimmed«
+@end smallexample
+@end defun
+
+@defun truncated
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun unround
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun unrounded
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
+@defun value_date
+@value{FIXME:UNDOCUMENTED}
+@end defun
+
@node Format Strings, Extending with Python, Value Expressions, Top
@chapter Format Strings
@@ -8050,13 +8441,13 @@ Return value rounded to n digits. Does not affect formatting.
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
-file and will allow you to run ledger reports from the command line
+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.
@itemize
@@ -8109,12 +8500,19 @@ or an expression enclosed in parentheses or brackets.
@findex --amount @var{EXPR}
@findex --total @var{VEXPR}
+For demonstration purposes the journal data from @ref{expr.dat} is used.
The allowable expressions are:
@table @code
@item %
Inserts a percent sign.
+@smallexample @c command:6F90EFC,with_input:3406FC1
+$ ledger -f expr.dat --format "%%\n" reg assets
+@end smallexample
+@smallexample @c output:6F90EFC
+%
+@end smallexample
@item t
Inserts the results of the value expression specified by
@@ -8132,6 +8530,12 @@ parentheses. To insert five times the total value of an account, for
example, one could say @samp{%12(5*O)}. Note: It's important to put the
five first in that expression, so that the commodity doesn't get
stripped from the total.
+@smallexample @c command:494256E,with_input:3406FC1
+$ ledger -f expr.dat --format "%12(5*O)\n" reg assets
+@end smallexample
+@smallexample @c output:494256E
+ ¤ -617,25
+@end smallexample
@item [DATEFMT]
Inserts the result of formatting a posting's date with a date
@@ -8141,20 +8545,52 @@ example: @samp{%[%Y/%m/%d %H:%M:%S]}.
@item S
Insert the path name of the file from which the transaction's data was
read. Only sensible in a @command{register} report.
+@c Note: Unable to test this properly since the output depends on
+@c where the ledger source tree resides in the filesystem.
+@smallexample
+$ ledger -f ~/journal.dat --format "%S\n" reg assets
+@end smallexample
+@smallexample
+/home/jwiegley/journal.dat
+@end smallexample
@item B
Inserts the beginning character position of that transaction within the
file.
+@smallexample @c command:2B669C9,with_input:3406FC1
+$ ledger -f expr.dat --format "%B\n" reg assets
+@end smallexample
+@smallexample @c output:2B669C9
+26
+@end smallexample
@item b
Inserts the beginning line of that transaction within the file.
+@smallexample @c command:F6E356F,with_input:3406FC1
+$ ledger -f expr.dat --format "%b\n" reg assets
+@end smallexample
+@smallexample @c output:F6E356F
+2
+@end smallexample
@item E
Inserts the ending character position of that transaction within the
file.
+@smallexample @c command:0E55246,with_input:3406FC1
+$ ledger -f expr.dat --format "%E\n" reg assets
+@end smallexample
+@smallexample @c output:0E55246
+90
+@end smallexample
@item e
Inserts the ending line of that transaction within the file.
+@smallexample @c command:A26F4C0,with_input:3406FC1
+$ ledger -f expr.dat --format "%e\n" reg assets
+@end smallexample
+@smallexample @c output:A26F4C0
+3
+@end smallexample
@item D
Returns the date according to the default format.
@@ -8173,9 +8609,23 @@ character if all of the member postings have the same state.
@item C
Inserts the transaction code. This is the value specified between
parentheses on the first line of the transaction.
+@smallexample @c command:C1CAAF3,with_input:3406FC1
+$ ledger -f expr.dat --format "%C\n" reg assets
+@end smallexample
+@c Note: The output needs a space character at the end
+@c for this test to pass
+@smallexample @c output:C1CAAF3
+(C0D3)
+@end smallexample
@item P
Inserts the payee related to a posting.
+@smallexample @c command:F41A9BB,with_input:3406FC1
+$ ledger -f expr.dat --format "%P\n" reg assets
+@end smallexample
+@smallexample @c output:F41A9BB
+PiggyBank
+@end smallexample
@c @item a
@c Inserts the optimal short name for an account. This is normally
@@ -8185,6 +8635,13 @@ Inserts the payee related to a posting.
@item A
Inserts the full name of an account.
+@smallexample @c command:29A70DD,with_input:3406FC1
+$ ledger -f expr.dat --format "%A\n" reg
+@end smallexample
+@smallexample @c output:29A70DD
+Assets:Cash
+Expenses:Office Supplies
+@end smallexample
@c @item W
@c This is the same as @code{%A}, except that it first displays the
@@ -8201,12 +8658,25 @@ Inserts the full name of an account.
@item N
Inserts the note associated with a posting, if one exists.
+@smallexample @c command:E6DC93A,with_input:3406FC1
+$ ledger -f expr.dat --format "%N\n" reg assets
+@end smallexample
+@smallexample @c output:E6DC93A
+ Payee: PiggyBank
+@end smallexample
@item /
The @samp{%/} construct is special. It separates a format string
between what is printed for the first posting of a transaction, and
what is printed for all subsequent postings. If not used, the
same format string is used for all postings.
+@smallexample @c command:E80897D,with_input:3406FC1
+$ ledger -f expr.dat --format "%P\n%/%A\n" reg
+@end smallexample
+@smallexample @c output:E80897D
+PiggyBank
+Expenses:Office Supplies
+@end smallexample
@end table
@@ -8244,7 +8714,7 @@ functions are described later):
@subsection Field Widths
The following codes return the width allocated for the specific fields.
-The defaults can be changed using the corresponding command line
+The defaults can be changed using the corresponding command-line
options:
@itemize
@@ -8314,7 +8784,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
@@ -8492,10 +8962,10 @@ Surrounds the string representing value with ANSI codes to give it
@item justify(value, first_width, latter_width, right_justify, colorize)
Right or left justify the string representing @code{value}. The width
of the field in the first line is given by @code{first_width}. For
-subsequent lines the width is given by @code{latterwidth}. If
+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.
@@ -8521,7 +8991,7 @@ generated the posting.
@table @code
@item filename
-the name of ledger the data file from whence the posting came,
+the name of the ledger data file from whence the posting came,
abbreviated @samp{S}.
@item beg_pos
@@ -8537,7 +9007,7 @@ line number in @code{filename} where entry for posting begins,
abbreviated @samp{b}.
@item end_line
-line number in @code{filename} where posting's entry for posting ends,
+line number in @code{filename} where entry for posting ends,
abbreviated @samp{e}.
@end table
@@ -8781,7 +9251,8 @@ and receive them from functions.
Expressions can be onerous to type at the command-line, so there's
a shorthand for reporting called ``query expressions''. These add no
functionality of their own, but are purely translated from the input
-string (cash) down to the corresponding value expression @samp{(account
+string down to the corresponding value expression, for example the
+input string @samp{cash} is translated to @samp{(account
=~ /cash/)}. This is a convenience layer.
@item Format strings
@@ -9232,7 +9703,7 @@ This command simply echoes its argument back to the output.
Forces ledger to reload any journal files. This function exists to
support external programs controlling a running ledger process and does
-nothing for a command line user.
+nothing for a command-line user.
@node @command{source}, Debug Options, @command{reload}, Developer Commands
@subsection @command{source}
@@ -9249,14 +9720,14 @@ are found.
These options are primarily for Ledger developers, but may be of some
use to a user trying something new.
-@ftable @code
+@ftable @option
@item --args-only
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
@@ -9289,7 +9760,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
@@ -9308,15 +9779,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
-FIX THIS ENTRY @c FIXME thdox
+Verify that every constructed object is properly destructed. This is for
+debugging purposes only.
@item --version
Print version information and exit.
@@ -9328,7 +9801,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.
@@ -9353,8 +9826,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
@@ -9377,8 +9852,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/")
@@ -9414,7 +9891,7 @@ true
@end smallexample
@item script
-FIX THIS ENTRY @c FIXME thdox
+@value{FIXME:UNDOCUMENTED}
@item template
Shows the insertion template that the @command{xact} sub-command
@@ -9472,6 +9949,90 @@ for example, issue @code{ctest -V -R "5FB"}.
@node Writing Tests, , Running Tests, Testing Framework
@subsubsection Writing Tests
+To write a new test first decide to which broad category the test belongs:
+baseline or regression. Depending on the category tests are named differently
+baseline tests are prefixed with their type, e.g. @samp{cmd}
+(@pxref{Baseline Test Types} for valid types), whereas regressions are either
+named after the bug id, e.g. @samp{1234.test} or uuid @samp{91416D62.test}.
+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}.
+
+@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
+
+A ledger test file contains three sections:
+
+@enumerate
+@item the journal data used for the test, this can be empty in certain
+scenarios
+@item the ledger command-line options used for the test
+@item the expected output
+@end enumerate
+
+Ledger has a special command directive for tests, everything between
+@code{test} and @code{end test} is treated like a comment, so every
+Ledger test is automatically a valid Ledger file.
+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 @c input:validate
+; This is the journal data
+year 2014
+12/24 (C0d3) Santa Claus
+ Assets:Bank ¤ -150,00
+ Expenses:Presents
+
+; The following line specifies the ledger command-line options for this test and
+; everything between the next line and `end test` specifies the expected output
+test reg --payee=code
+14-Dec-24 C0d3 Assets:Bank ¤ -150,00 ¤ -150,00
+14-Dec-24 C0d3 Expenses:Presents ¤ 150,00 0
+end test
+@end smallexample
+
+When it is necessary to test for errors printed to @code{stderr} redirect
+the test output by adding @code{->} to the @code{test} line and match the
+expected error text in an @code{__ERROR__} section:
+
+@smallexample
+2014/01/01 * Acme Corporation
+ Assets:Bank:Checking ¤ 1.000,00
+ [Fund:Vacation] ¤ 300,00
+ [Fund:Studies] ¤ 600,00
+ Income:Salary ¤ -2.000,00
+
+test reg ->
+__ERROR__
+While parsing file "$FILE", line 5:
+While balancing transaction from "$FILE", lines 1-5:
+> 2014/01/01 * Acme Corporation
+> Assets:Bank:Checking ¤ 1.000,00
+> [Fund:Vacation] ¤ 300,00
+> [Fund:Studies] ¤ 600,00
+> Income:Salary ¤ -2.000,00
+Unbalanced remainder is:
+ ¤ -100,00
+Amount to balance against:
+ ¤ 1.900,00
+Error: Transaction does not balance
+end test
+@end smallexample
+
+A special @code{$FILE} variable can be used to match the journal filename
+used during the test.
+
+To add new tests to the test suite use the rebuild_cache option for the
+build tool you use, for example @code{make rebuild_cache}, now the
+new tests can be run as documented in @ref{Running Tests}.
+
@node Major Changes from version 2.6, Example Journal File, Ledger for Developers, Top
@chapter Major Changes from version 2.6
@@ -9489,10 +10050,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
@@ -9615,11 +10176,23 @@ to the main body of the documentation.
@node Invoking Ledger, Ledger Files, Cookbook, Cookbook
@subsection Invoking Ledger
-@smallexample
+
+@smallexample @c command:validate
$ ledger --group-by "tag('trip')" bal
-$ ledger reg --sort "tag('foo')" %foo
+@end smallexample
+@c FIXME: The following example fails to validate due to:
+@c While applying is_realzero to :
+@c Error: Cannot determine if an uninitialized value is really zero
+@c @smallexample @c command:validate
+@c $ ledger reg --sort "tag('foo')" %foo
+@c @end smallexample
+@smallexample @c command:validate
$ ledger cleared VWCU NFCU Tithe Misentry
+@end smallexample
+@smallexample @c command:validate
$ ledger register Joint --uncleared
+@end smallexample
+@smallexample @c command:validate
$ ledger register Checking --sort d -d 'd>[2011/04/01]' until 2011/05/25
@end smallexample
diff --git a/doc/version.texi.in b/doc/version.texi.in
new file mode 100644
index 00000000..c477db70
--- /dev/null
+++ b/doc/version.texi.in
@@ -0,0 +1,8 @@
+@set Ledger_VERSION_MAJOR @Ledger_VERSION_MAJOR@
+@set Ledger_VERSION_MINOR @Ledger_VERSION_MINOR@
+@set Ledger_VERSION_PATCH @Ledger_VERSION_PATCH@
+@set Ledger_VERSION_PRERELEASE @Ledger_VERSION_PRERELEASE@
+@set Ledger_VERSION_DATE @Ledger_VERSION_DATE@
+
+@set VERSION @value{Ledger_VERSION_MAJOR}.@value{Ledger_VERSION_MINOR}.@value{Ledger_VERSION_PATCH}@value{Ledger_VERSION_PRERELEASE}
+
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-commodities.el b/lisp/ledger-commodities.el
index 5ffebf3b..ea6319ba 100644
--- a/lisp/ledger-commodities.el
+++ b/lisp/ledger-commodities.el
@@ -91,8 +91,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"
@@ -105,7 +105,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))
@@ -124,7 +124,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 2fae9911..2345fd02 100644
--- a/lisp/ledger-complete.el
+++ b/lisp/ledger-complete.el
@@ -157,7 +157,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.
@@ -235,7 +235,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..643ebdd3 100644
--- a/lisp/ledger-context.el
+++ b/lisp/ledger-context.el
@@ -32,9 +32,9 @@
;; `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-separator-string "\\s-\\s-+")
(defconst ledger-amount-string "\\(-?[0-9]+[\\.,][0-9]*\\)")
(defconst ledger-comment-string "[ \t]*;[ \t]*\\(.*?\\)")
(defconst ledger-nil-string "\\([ \t]\\)")
diff --git a/lisp/ledger-exec.el b/lisp/ledger-exec.el
index 8902d839..05bca776 100644
--- a/lisp/ledger-exec.el
+++ b/lisp/ledger-exec.el
@@ -53,7 +53,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 d307208f..2d4f850e 100644
--- a/lisp/ledger-fontify.el
+++ b/lisp/ledger-fontify.el
@@ -38,44 +38,45 @@
: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)))
- (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))
+ (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.
@@ -101,97 +102,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-init.el b/lisp/ledger-init.el
index 49d74098..04d5f656 100644
--- a/lisp/ledger-init.el
+++ b/lisp/ledger-init.el
@@ -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..f2eb4b21 100644
--- a/lisp/ledger-mode.el
+++ b/lisp/ledger-mode.el
@@ -63,7 +63,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 +78,7 @@
(defun ledger-mode-dump-configuration ()
"Dump all customizations."
- (interactive)
+ (interactive)
(find-file "ledger-mode-dump")
(ledger-mode-dump-group 'ledger))
@@ -99,11 +99,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."
@@ -159,7 +159,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 +222,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")))
@@ -338,10 +338,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..4da857a7 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)
diff --git a/lisp/ledger-occur.el b/lisp/ledger-occur.el
index a4fde2e1..2ee56e7b 100644
--- a/lisp/ledger-occur.el
+++ b/lisp/ledger-occur.el
@@ -118,7 +118,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)
@@ -143,25 +143,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 e0c7aaee..21e856db 100644
--- a/lisp/ledger-post.el
+++ b/lisp/ledger-post.el
@@ -95,28 +95,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)
diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el
index 80e27ae3..326266b7 100644
--- a/lisp/ledger-reconcile.el
+++ b/lisp/ledger-reconcile.el
@@ -40,7 +40,7 @@
:group 'ledger)
(defcustom ledger-recon-buffer-name "*Reconcile*"
- "Name to use for reconciliation window."
+ "Name to use for reconciliation buffer."
:group 'ledger-reconcile)
(defcustom ledger-narrow-on-reconcile t
@@ -49,54 +49,67 @@
:group 'ledger-reconcile)
(defcustom ledger-buffer-tracks-reconcile-buffer t
- "If t, then when the cursor is moved to a new xact in the recon window.
+ "If t, then when the cursor is moved to a new transaction in the reconcile buffer.
Then that transaction will be shown in its source buffer."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-force-window-bottom nil
- "If t make the reconcile window appear along the bottom of the register window and resize."
+ "If t, make the reconcile window appear along the bottom of the register window and resize."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-toggle-to-pending t
- "If true then toggle between uncleared and pending.
+ "If t, then toggle between uncleared and pending.
reconcile-finish will mark all pending posting cleared."
:type 'boolean
:group 'ledger-reconcile)
(defcustom ledger-reconcile-default-date-format ledger-default-date-format
- "Default date format for the reconcile buffer."
+ "Date format for the reconcile buffer.
+Default is ledger-default-date-format."
:type 'string
:group 'ledger-reconcile)
(defcustom ledger-reconcile-target-prompt-string "Target amount for reconciliation "
- "Default prompt for recon target prompt."
+ "Prompt for recon target."
:type 'string
: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 willbe displayed."
- :type 'string
- :group 'ledger-reconcile)
+ into the '%s'. If nil, no header will be displayed."
+ :type 'string
+ :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
-field."
- :type 'string
- :group 'ledger-reconcile)
+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."
+ :type 'string
+ :group 'ledger-reconcile)
+
+(defcustom ledger-reconcile-buffer-payee-max-chars -1
+ "If positive, truncate payee name right side to max number of characters."
+ :type 'integer
+ :group 'ledger-reconcile)
+
+(defcustom ledger-reconcile-buffer-account-max-chars -1
+ "If positive, truncate account name left side to max number of characters."
+ :type 'integer
+ :group 'ledger-reconcile)
(defcustom ledger-reconcile-sort-key "(0)"
- "Default key for sorting reconcile buffer.
+ "Key for sorting reconcile buffer.
-Possible values are '(date)', '(amount)', '(payee)'. For no sorting, i.e. using
-ledger file order, use '(0)'."
+Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e. using ledger file order."
:type 'string
:group 'ledger-reconcile)
@@ -105,6 +118,47 @@ ledger file order, use '(0)'."
: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)))
+(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)))))
+(defun ledger-reconcile-s-left (len s)
+ "Return up to the LEN first chars of S."
+ (if (> (length s) len)
+ (substring s 0 len)
+ s))
+(defun ledger-reconcile-s-right (len s)
+ "Return up to the LEN last chars of S."
+ (let ((l (length s)))
+ (if (> l len)
+ (substring s (- l len) l)
+ s)))
+
+(defun ledger-reconcile-truncate-right (str len)
+ "Truncate STR right side with max LEN characters, and pad with '…' if truncated."
+ (if (and (>= len 0) (> (length str) len))
+ (ledger-reconcile-s-pad-right len "…" (ledger-reconcile-s-left (- len 1) str))
+ str))
+
+(defun ledger-reconcile-truncate-left (str len)
+ "Truncate STR left side with max LEN characters, and pad with '…' if truncated."
+ (if (and (>= len 0) (> (length str) len))
+ (ledger-reconcile-s-pad-left len "…" (ledger-reconcile-s-right (- len 1) str))
+ str))
+
(defun ledger-reconcile-get-cleared-or-pending-balance (buffer account)
"Use BUFFER to Calculate the cleared or pending balance of the ACCOUNT."
@@ -204,9 +258,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."
@@ -232,40 +286,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))
@@ -278,7 +332,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 ()
@@ -320,51 +375,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
- (nth 4 xact) ; payee
- (nth 1 posting) ; account
- (nth 2 posting)))))) ; amount
+ "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)
+ (ledger-reconcile-truncate-left
+ (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.
@@ -384,10 +443,10 @@ 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))
+ (insert (format ledger-reconcile-buffer-header account))
(dolist (xact xacts)
(ledger-reconcile-format-xact xact fmt))
(goto-char (point-max))
@@ -440,11 +499,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."
@@ -453,38 +512,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)
@@ -495,7 +554,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..9d8394df 100644
--- a/lisp/ledger-regex.el
+++ b/lisp/ledger-regex.el
@@ -108,8 +108,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 +153,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
@@ -333,8 +333,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 +345,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 c477707f..e10e9672 100644
--- a/lisp/ledger-report.el
+++ b/lisp/ledger-report.el
@@ -57,7 +57,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.
@@ -67,14 +67,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*")
@@ -91,10 +91,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))
@@ -203,7 +203,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)
@@ -387,30 +387,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."
@@ -418,10 +418,10 @@ Optional EDIT the command."
(customize-variable 'ledger-reports))
(defun ledger-report-edit-report ()
- (interactive)
- "Edit the current report command in the mini buffer and re-run the report"
- (setq ledger-report-cmd (ledger-report-read-command ledger-report-cmd))
- (ledger-report-redo))
+ (interactive)
+ "Edit the current report command in the mini buffer and re-run the report"
+ (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 d66fdbab..1fbbcb59 100644
--- a/lisp/ledger-schedule.el
+++ b/lisp/ledger-schedule.el
@@ -60,21 +60,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.
@@ -86,8 +86,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
@@ -173,10 +173,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."
@@ -202,84 +202,84 @@ 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))))))
+ (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))))))
(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= 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= 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."
@@ -290,7 +290,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)))
@@ -311,15 +311,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 870e298c..23e93dc9 100644
--- a/lisp/ledger-sort.el
+++ b/lisp/ledger-sort.el
@@ -28,17 +28,17 @@
(defun ledger-sort-find-start ()
- "Find the beginning of a sort region"
+ "Find the beginning of a sort region"
(if (re-search-forward ";.*Ledger-mode:.*Start sort" nil t)
(match-end 0)))
(defun ledger-sort-find-end ()
- "Find the end of a sort region"
+ "Find the end of a sort region"
(if (re-search-forward ";.*Ledger-mode:.*End sort" nil t)
(match-end 0)))
(defun ledger-sort-insert-start-mark ()
- "Insert a marker to start a sort region"
+ "Insert a marker to start a sort region"
(interactive)
(save-excursion
(goto-char (point-min))
@@ -48,7 +48,7 @@
(insert "\n; Ledger-mode: Start sort\n\n"))
(defun ledger-sort-insert-end-mark ()
- "Insert a marker to end a sort region"
+ "Insert a marker to end a sort region"
(interactive)
(save-excursion
(goto-char (point-min))
@@ -64,7 +64,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
@@ -77,14 +77,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 47805f15..73e3c72c 100644
--- a/lisp/ledger-state.el
+++ b/lisp/ledger-state.el
@@ -114,8 +114,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-xact.el b/lisp/ledger-xact.el
index 0eb9386a..64f69cbe 100644
--- a/lisp/ledger-xact.el
+++ b/lisp/ledger-xact.el
@@ -139,6 +139,7 @@ MOMENT is an encoded date"
(string-to-number (match-string 2 date)))))
(ledger-xact-find-slot encoded-date)
(insert transaction "\n")
+ (beginning-of-line -1)
(ledger-navigate-beginning-of-xact)
(re-search-forward ledger-iso-date-regexp)
(replace-match date)
@@ -184,8 +185,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 7b10061f..8ed6e51a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(LEDGER_CLI_SOURCES
+ global.cc
+ main.cc)
+
set(LEDGER_SOURCES
stats.cc
generate.cc
@@ -24,7 +28,6 @@ set(LEDGER_SOURCES
textual.cc
temps.cc
journal.cc
- archive.cc
account.cc
xact.cc
post.cc
@@ -76,7 +79,6 @@ set(LEDGER_INCLUDES
account.h
amount.h
annotate.h
- archive.h
balance.h
chain.h
commodity.h
@@ -255,7 +257,7 @@ else()
endmacro(ADD_PCH_RULE _header_filename _src_list _other_srcs)
endif()
-add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES main.cc global.cc)
+add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES LEDGER_CLI_SOURCES)
include(GNUInstallDirs)
@@ -271,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}
@@ -292,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.h b/src/account.h
index 76e839eb..7de4e560 100644
--- a/src/account.h
+++ b/src/account.h
@@ -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..b0898bfb 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -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..4c959177 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -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.h b/src/annotate.h
index c0fbcd3d..c2b2ec9d 100644
--- a/src/annotate.h
+++ b/src/annotate.h
@@ -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.h b/src/balance.h
index 752bb4d6..c9ef9658 100644
--- a/src/balance.h
+++ b/src/balance.h
@@ -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/commodity.h b/src/commodity.h
index 3d1ddf04..53ed3a9f 100644
--- a/src/commodity.h
+++ b/src/commodity.h
@@ -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/expr.h b/src/expr.h
index 384cc661..041a5297 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -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..dcaa69ca 100644
--- a/src/exprbase.h
+++ b/src/exprbase.h
@@ -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 fd30c966..d9fb64b0 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -726,7 +726,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/flags.h b/src/flags.h
index f3593517..82ebaac1 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -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/global.cc b/src/global.cc
index 602e216c..e4ebe6f5 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -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,15 +122,15 @@ 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 is the file doesn't exist. If no init file was specified
+ // 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
// isn't one.
path init_file;
@@ -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,17 +319,11 @@ 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);
- else OPT(help_calc);
- else OPT(help_comm);
- else OPT(help_disp);
break;
case 'i':
- OPT(init_file_);
+ OPT_(init_file_);
break;
case 'o':
OPT(options);
@@ -505,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 f36dbe3d..5d849777 100644
--- a/src/global.h
+++ b/src/global.h
@@ -123,6 +123,8 @@ public:
out <<
"Ledger " << Ledger_VERSION_MAJOR << '.' << Ledger_VERSION_MINOR << '.'
<< Ledger_VERSION_PATCH;
+ if (Ledger_VERSION_PRERELEASE != 0)
+ out << Ledger_VERSION_PRERELEASE;
if (Ledger_VERSION_DATE != 0)
out << '-' << Ledger_VERSION_DATE;
out << _(", the command-line accounting tool");
@@ -145,11 +147,7 @@ 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_(global_scope_t, help_calc, DO() { parent->visit_man_page(); });
- OPTION_(global_scope_t, help_comm, DO() { parent->visit_man_page(); });
- OPTION_(global_scope_t, help_disp, DO() { parent->visit_man_page(); });
OPTION__
(global_scope_t, init_file_, // -i
diff --git a/src/item.h b/src/item.h
index 458cb378..dbba53a8 100644
--- a/src/item.h
+++ b/src/item.h
@@ -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..0225e210 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -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/journal.h b/src/journal.h
index 613b2b96..324315b1 100644
--- a/src/journal.h
+++ b/src/journal.h
@@ -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..3b6707e5 100644
--- a/src/lookup.cc
+++ b/src/lookup.cc
@@ -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/mask.h b/src/mask.h
index 2b579768..dce23440 100644
--- a/src/mask.h
+++ b/src/mask.h
@@ -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.h b/src/op.h
index c45ffb08..d94c2534 100644
--- a/src/op.h
+++ b/src/op.h
@@ -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/output.cc b/src/output.cc
index ffd144e1..92b71387 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -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..1305fa77 100644
--- a/src/output.h
+++ b/src/output.h
@@ -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.h b/src/parser.h
index e46fc719..25c4a7e3 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -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.h b/src/pool.h
index d24df78c..2e9d93f1 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -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.h b/src/post.h
index 1e5fc569..5f22fa3c 100644
--- a/src/post.h
+++ b/src/post.h
@@ -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/predicate.h b/src/predicate.h
index 30d07223..e8c5b31c 100644
--- a/src/predicate.h
+++ b/src/predicate.h
@@ -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/py_item.cc b/src/py_item.cc
index 473bbef8..4dd104c9 100644
--- a/src/py_item.cc
+++ b/src/py_item.cc
@@ -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/report.cc b/src/report.cc
index 4b240611..ac08c247 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -631,7 +631,7 @@ value_t report_t::fn_trim(call_scope_t& args)
while (*p && std::isspace(*p))
p++;
- const char * e = buf.get() + temp.length();
+ const char * e = buf.get() + temp.length() - 1;
while (e > p && std::isspace(*e))
e--;
@@ -643,7 +643,7 @@ value_t report_t::fn_trim(call_scope_t& args)
return string_value(empty_string);
}
else {
- return string_value(string(p, static_cast<std::string::size_type>(e - p)));
+ return string_value(string(p, static_cast<std::string::size_type>(e - p + 1)));
}
}
@@ -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..10afbe6f 100644
--- a/src/report.h
+++ b/src/report.h
@@ -496,7 +496,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 +764,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.h b/src/scope.h
index 8ad3afac..ba1144b2 100644
--- a/src/scope.h
+++ b/src/scope.h
@@ -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/session.cc b/src/session.cc
index b0d31be9..b4fb4eb8 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -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..f9aee389 100644
--- a/src/session.h
+++ b/src/session.h
@@ -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/system.hh.in b/src/system.hh.in
index 21417e09..8de27ad6 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -54,6 +54,7 @@
#define Ledger_VERSION_MAJOR @Ledger_VERSION_MAJOR@
#define Ledger_VERSION_MINOR @Ledger_VERSION_MINOR@
#define Ledger_VERSION_PATCH @Ledger_VERSION_PATCH@
+#define Ledger_VERSION_PRERELEASE "@Ledger_VERSION_PRERELEASE@"
#define Ledger_VERSION_DATE @Ledger_VERSION_DATE@
#define HAVE_EDIT @HAVE_EDIT@
@@ -70,7 +71,6 @@
#define HAVE_BOOST_PYTHON @HAVE_BOOST_PYTHON@
#define HAVE_BOOST_REGEX_UNICODE @HAVE_BOOST_REGEX_UNICODE@
-#define HAVE_BOOST_SERIALIZATION 0
#define DEBUG_MODE @DEBUG_MODE@
#define NO_ASSERTS @NO_ASSERTS@
@@ -238,86 +238,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>
diff --git a/src/times.h b/src/times.h
index c1bfb1cc..e1a9e847 100644
--- a/src/times.h
+++ b/src/times.h
@@ -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/value.h b/src/value.h
index c224ce04..810d34f9 100644
--- a/src/value.h
+++ b/src/value.h
@@ -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:
@@ -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/xact.h b/src/xact.h
index 3ca57953..37a20972 100644
--- a/src/xact.h
+++ b/src/xact.h
@@ -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 44db81fb..0e7d5f2c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -42,10 +42,19 @@ if (PYTHONINTERP_FOUND)
foreach(TestFile ${${_class}_TESTS})
get_filename_component(TestFile_Name ${TestFile} NAME_WE)
add_test(NAME ${_class}Test_${TestFile_Name}
- COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/DocTests.py
+ 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})
endforeach()
+
+ # 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})
+ endforeach()
endif()
### CMakeLists.txt ends here
diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py
new file mode 100755
index 00000000..570b93be
--- /dev/null
+++ b/test/CheckBaselineTests.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import sys
+import re
+import os
+import argparse
+
+from os.path import *
+from subprocess import Popen, PIPE
+
+from CheckOptions import CheckOptions
+
+class CheckBaselineTests (CheckOptions):
+ def __init__(self, args):
+ CheckOptions.__init__(self, args)
+ self.missing_baseline_tests = set()
+
+ self.untested_options = [
+ 'anon',
+ 'args-only',
+ 'debug',
+ 'download',
+ 'force-color',
+ 'force-pager',
+ 'generated',
+ 'help',
+ 'import',
+ 'no-color',
+ 'no-pager',
+ 'options',
+ 'price-exp',
+ 'seed',
+ 'trace',
+ 'verbose',
+ 'verify',
+ 'verify-memory',
+ 'version'
+ ]
+
+ def main(self):
+ for option in self.ledger_options():
+ if option in self.untested_options: continue
+ baseline_testpath = join(self.source, 'test', 'baseline', 'opt-%s.test' % option)
+ if exists(baseline_testpath) and getsize(baseline_testpath) > 0: continue
+ self.missing_baseline_tests.add(option)
+
+ if len(self.missing_baseline_tests):
+ print("Missing Baseline test for:%s%s\n" % (self.sep, self.sep.join(sorted(list(self.missing_baseline_tests)))))
+
+ errors = len(self.missing_baseline_tests)
+ return errors
+
+if __name__ == "__main__":
+ def getargs():
+ parser = argparse.ArgumentParser(prog='CheckBaselineTests',
+ description='Check that ledger options are tested')
+ parser.add_argument('-l', '--ledger',
+ dest='ledger',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the ledger executable to test with')
+ parser.add_argument('-s', '--source',
+ dest='source',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the top level ledger source directory')
+ return parser.parse_args()
+
+ args = getargs()
+ script = CheckBaselineTests(args)
+ status = script.main()
+ sys.exit(status)
diff --git a/test/CheckManpage.py b/test/CheckManpage.py
new file mode 100755
index 00000000..944f4e07
--- /dev/null
+++ b/test/CheckManpage.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import sys
+import re
+import os
+import argparse
+
+from os.path import *
+from subprocess import Popen, PIPE
+
+from CheckOptions import CheckOptions
+
+class CheckManpage (CheckOptions):
+ def __init__(self, args):
+ CheckOptions.__init__(self, args)
+ self.option_pattern = '\.It Fl \\\\-([-A-Za-z]+)'
+ self.function_pattern = '\.It Fn ([-A-Za-z_]+)'
+ self.source_file = join(self.source, 'doc', 'ledger.1')
+ self.source_type = 'manpage'
+
+if __name__ == "__main__":
+ def getargs():
+ parser = argparse.ArgumentParser(prog='CheckManpage',
+ description='Check that ledger options are documented in the manpage')
+ parser.add_argument('-l', '--ledger',
+ dest='ledger',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the ledger executable to test with')
+ parser.add_argument('-s', '--source',
+ dest='source',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the top level ledger source directory')
+ return parser.parse_args()
+
+ args = getargs()
+ script = CheckManpage(args)
+ status = script.main()
+ sys.exit(status)
diff --git a/test/CheckOptions.py b/test/CheckOptions.py
new file mode 100755
index 00000000..e4a1fdc3
--- /dev/null
+++ b/test/CheckOptions.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import re
+import os
+import sys
+import shlex
+import argparse
+import subprocess
+
+from os.path import *
+from subprocess import Popen, PIPE
+
+class CheckOptions (object):
+ def __init__(self, args):
+ self.option_pattern = None
+ self.source_file = None
+ self.sep = "\n --"
+
+ self.ledger = os.path.abspath(args.ledger)
+ self.source = os.path.abspath(args.source)
+
+ self.missing_options = set()
+ self.unknown_options = set()
+ self.missing_functions = set()
+ self.unknown_functions = set()
+
+ def find_pattern(self, filename, pattern):
+ regex = re.compile(pattern)
+ return {match.group(1) for match in {regex.match(line) for line in open(filename)} if match}
+
+ def find_options(self, filename):
+ return self.find_pattern(filename, self.option_pattern)
+
+ def find_functions(self, filename):
+ return self.find_pattern(filename, self.function_pattern)
+ def find_alternates(self):
+ command = shlex.split('grep --no-filename OPT_ALT')
+ for source_file in ['session', 'report']:
+ command.append(os.path.join(self.source, 'src', '%s.cc' % source_file))
+ try:
+ output = subprocess.check_output(command).split('\n');
+ except subprocess.CalledProcessError:
+ output = ''
+
+ regex = re.compile(r'OPT_ALT\([^,]*,\s*([^)]+?)_?\)');
+ alternates = {match.group(1).replace('_', '-') for match in {regex.search(line) for line in output} if match}
+ return alternates
+
+ def ledger_options(self):
+ pipe = Popen('%s --debug option.names parse true' %
+ self.ledger, shell=True, stdout=PIPE, stderr=PIPE)
+ regex = re.compile('\[DEBUG\]\s+Option:\s+(.*?)_?$')
+ ledger_options = {match.group(1).replace('_', '-') for match in {regex.search(line.decode()) for line in pipe.stderr} if match}
+ return ledger_options
+
+ def ledger_functions(self):
+ command = shlex.split('grep --no-filename fn_ %s' % (os.path.join(self.source, 'src', 'report.h')))
+ try:
+ output = subprocess.check_output(command).split('\n');
+ except subprocess.CalledProcessError:
+ output = ''
+
+ regex = re.compile(r'fn_([^(]+)\(');
+ functions = {match.group(1) for match in {regex.search(line) for line in output} if match}
+ return functions
+
+ def main(self):
+ options = self.find_options(self.source_file)
+ for option in self.ledger_options():
+ if option not in options:
+ self.missing_options.add(option)
+ else:
+ options.remove(option)
+ known_alternates = self.find_alternates()
+ self.unknown_options = {option for option in options if option not in known_alternates}
+
+ functions = self.find_functions(self.source_file)
+ for function in self.ledger_functions():
+ if function not in functions:
+ self.missing_functions.add(function)
+ else:
+ functions.remove(function)
+ 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):
+ print("Missing %s option entries for:%s%s\n" % (self.source_type, self.sep, self.sep.join(sorted(list(self.missing_options)))))
+ if len(self.unknown_options):
+ print("%s entry for unknown options:%s%s\n" % (self.source_type, self.sep, self.sep.join(sorted(list(self.unknown_options)))))
+ if len(self.missing_functions):
+ print("Missing %s function entries for:%s%s\n" % (self.source_type, '\n ', '\n '.join(sorted(list(self.missing_functions)))))
+ if len(self.unknown_functions):
+ print("%s entry for unknown functions:%s%s\n" % (self.source_type, '\n ', '\n '.join(sorted(list(self.unknown_functions)))))
+ errors = len(self.missing_options) + len(self.unknown_options) + len(self.missing_functions) + len(self.unknown_functions)
+ return errors
diff --git a/test/CheckTests.py b/test/CheckTests.py
deleted file mode 100755
index 1a364ff4..00000000
--- a/test/CheckTests.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import re
-import os
-
-from os.path import *
-from subprocess import Popen, PIPE
-
-ledger_binary = sys.argv[1]
-source_topdir = sys.argv[2]
-
-documented_options = []
-for line in open(join(source_topdir, 'doc', 'ledger.1')):
- match = re.match('\.It Fl \\\\-([-A-Za-z]+)', line)
- if match:
- option = match.group(1)
- if option not in documented_options:
- documented_options.append(option)
-
-pipe = Popen('%s --debug option.names parse true' % ledger_binary,
- shell=True, stdout=PIPE, stderr=PIPE)
-errors = 0
-
-untested_options = [
- 'anon',
- 'args-only',
- 'cache',
- 'debug',
- 'download',
- 'file',
- 'force-color',
- 'force-pager',
- 'full-help',
- 'help',
- 'help-calc',
- 'help-comm',
- 'help-disp',
- 'import',
- 'init-file',
- 'no-color',
- 'options',
- 'price-db',
- 'price-exp',
- 'revalued-total',
- 'script',
- 'seed',
- 'trace',
- 'verbose',
- 'verify',
- 'version'
-]
-
-for line in pipe.stderr:
- match = re.search('\[DEBUG\] Option: (.*)', line)
- if match:
- option = match.group(1)
-
- option = re.sub('_', '-', option)
- option = re.sub('-$', '', option)
-
- if option not in untested_options and \
- not exists(join(source_topdir, 'test', 'baseline',
- 'opt-%s.test' % option)):
- print "Baseline test missing for --%s" % option
- errors += 1
-
- if option not in documented_options:
- print "Man page entry missing for --%s" % option
- errors += 1
- else:
- documented_options.remove(option)
-
-known_alternates = [
- 'cost',
- 'first',
- 'import',
- 'last',
- 'leeway',
- 'period-sort'
-]
-
-for option in documented_options:
- if option not in known_alternates:
- print "Man page entry for unknown option --%s" % option
-
-sys.exit(errors)
diff --git a/test/CheckTexinfo.py b/test/CheckTexinfo.py
new file mode 100755
index 00000000..cd167eba
--- /dev/null
+++ b/test/CheckTexinfo.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+import sys
+import re
+import os
+import argparse
+
+from os.path import *
+from subprocess import Popen, PIPE
+
+from CheckOptions import CheckOptions
+
+class CheckTexinfo (CheckOptions):
+ def __init__(self, args):
+ CheckOptions.__init__(self, args)
+ self.option_pattern = '^@item\s+--([-A-Za-z]+)'
+ self.function_pattern = '^@defun\s+([-A-Za-z_]+)'
+ self.source_file = join(self.source, 'doc', 'ledger3.texi')
+ self.source_type = 'texinfo'
+
+
+ def find_functions(self, filename):
+ functions = set()
+ state_normal = 0
+ state_function = 1
+ state = state_normal
+ function = None
+ fun_doc = str()
+ fun_example = False
+ item_regex = re.compile(self.function_pattern)
+ itemx_regex = re.compile('^@defunx')
+ example_regex = re.compile('^@smallexample\s+@c\s+command:')
+ fix_regex = re.compile('FIX')
+ comment_regex = re.compile('^\s*@c')
+ for line in open(filename):
+ line = line.strip()
+ if state == state_normal:
+ match = item_regex.match(line)
+ if match:
+ state = state_function
+ function = match.group(1)
+ elif state == state_function:
+ if line == '@end defun':
+ if function and fun_example and len(fun_doc) and not fix_regex.search(fun_doc):
+ functions.add(function)
+ state = state_normal
+ fun_example = None
+ fun_doc = str()
+ elif itemx_regex.match(line):
+ continue
+ elif example_regex.match(line):
+ fun_example = True
+ elif not comment_regex.match(line):
+ fun_doc += line
+ return functions
+
+ def find_options(self, filename):
+ options = set()
+ state_normal = 0
+ state_option_table = 1
+ state = state_normal
+ option = None
+ opt_doc = str()
+ item_regex = re.compile(self.option_pattern)
+ itemx_regex = re.compile('^@itemx')
+ fix_regex = re.compile('FIX')
+ comment_regex = re.compile('^\s*@c')
+ for line in open(filename):
+ line = line.strip()
+ if state == state_normal:
+ if line == '@ftable @option':
+ state = state_option_table
+ elif state == state_option_table:
+ if line == '@end ftable':
+ if option and len(opt_doc) and not fix_regex.search(opt_doc):
+ options.add(option)
+ state = state_normal
+ option = None
+ continue
+ match = item_regex.match(line)
+ if match:
+ if option and len(opt_doc) and not fix_regex.search(opt_doc):
+ options.add(option)
+ option = match.group(1)
+ opt_doc = str()
+ elif itemx_regex.match(line):
+ continue
+ elif not comment_regex.match(line):
+ opt_doc += line
+ return options
+
+if __name__ == "__main__":
+ def getargs():
+ parser = argparse.ArgumentParser(prog='CheckTexinfo',
+ description='Check that ledger options are documented in the texinfo manual')
+ parser.add_argument('-l', '--ledger',
+ dest='ledger',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the ledger executable to test with')
+ parser.add_argument('-s', '--source',
+ dest='source',
+ type=str,
+ action='store',
+ required=True,
+ help='the path to the top level ledger source directory')
+ return parser.parse_args()
+
+ args = getargs()
+ script = CheckTexinfo(args)
+ status = script.main()
+ sys.exit(status)
diff --git a/test/DocTests.py b/test/DocTests.py
index ea32608e..7af7abc3 100755
--- a/test/DocTests.py
+++ b/test/DocTests.py
@@ -4,6 +4,7 @@
import os
import re
import sys
+import shlex
import hashlib
import argparse
import subprocess
@@ -18,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*$')
@@ -33,15 +38,16 @@ class DocTests:
line = self.file.readline()
self.current_line += 1
if len(line) <= 0 or endexample.match(line): break
- example += line.replace("@@","@").replace("@{","{").replace("@}","}")
+ # Replace special texinfo character sequences with their ASCII counterpart
+ 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
@@ -76,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:
@@ -102,20 +108,21 @@ 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 = command.rstrip().split()
+ command = filter(lambda x: x != '\n', shlex.split(command))
if command[0] == '$': command.remove('$')
index = command.index('ledger')
command[index] = self.ledger
- for i,argument in enumerate('--args-only --columns 80'.split()):
+ for i,argument in enumerate(shlex.split('--args-only --columns 80')):
command.insert(index+i+1, argument)
try:
@@ -143,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:
@@ -152,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:
- verify = subprocess.check_output(command)
- except:
- verify = str()
- error = True
- valid = (output == verify) or (not error and validation)
+ 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)
+ 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)
@@ -204,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:
@@ -221,7 +235,8 @@ class DocTests:
if __name__ == "__main__":
def getargs():
- parser = argparse.ArgumentParser(prog='DocTests', description='Test ledger examples from the documentation', prefix_chars='-')
+ parser = argparse.ArgumentParser(prog='DocTests',
+ description='Test and validate ledger examples from the texinfo manual')
parser.add_argument('-v', '--verbose',
dest='verbose',
action='count',
diff --git a/test/GenerateTests.py b/test/GenerateTests.py
index 2e956db0..1a9045a2 100755
--- a/test/GenerateTests.py
+++ b/test/GenerateTests.py
@@ -79,6 +79,8 @@ def generation_test(seed):
p_cout_bal.stdin.close()
cout_lines = harness.readlines(p_cout_bal.stdout)
+ if len(cout_lines) == 0:
+ return False
#norm_cout_lines = [normalize(line) for line in cout_lines]
if not harness.wait(p_cout_bal, msg=("Stdout balance for seed %d failed:" % seed)):
@@ -89,6 +91,8 @@ def generation_test(seed):
p_print_bal.stdin.close()
print_lines = harness.readlines(p_print_bal.stdout)
+ if len(print_lines) == 0:
+ return False
if not harness.wait(p_print_bal, msg=("Print balance for seed %d failed:" % seed)):
return False
diff --git a/test/RegressTests.py b/test/RegressTests.py
index 01e14191..0fef2127 100755
--- a/test/RegressTests.py
+++ b/test/RegressTests.py
@@ -57,6 +57,9 @@ 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 "):
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/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-no-titles.test b/test/baseline/opt-no-titles.test
index e69de29b..40a9b421 100644
--- a/test/baseline/opt-no-titles.test
+++ b/test/baseline/opt-no-titles.test
@@ -0,0 +1,10 @@
+test reg -f test/input/drewr3.dat --no-titles --group-by payee reg food
+11-Jan-02 Grocery Store Expense:Food:Groceries $ 65.00 $ 65.00
+11-Jan-19 Grocery Store Expense:Food:Groceries $ 44.00 $ 109.00
+10-Dec-20 Organic Co-op Expense:Food:Groceries $ 37.50 $ 37.50
+ Expense:Food:Groceries $ 37.50 $ 75.00
+ Expense:Food:Groceries $ 37.50 $ 112.50
+ Expense:Food:Groceries $ 37.50 $ 150.00
+ Expense:Food:Groceries $ 37.50 $ 187.50
+ Expense:Food:Groceries $ 37.50 $ 225.00
+end test
diff --git a/test/baseline/opt-permissive.test b/test/baseline/opt-permissive.test
index e69de29b..8f8ff031 100644
--- a/test/baseline/opt-permissive.test
+++ b/test/baseline/opt-permissive.test
@@ -0,0 +1,19 @@
+
+; The option --permissive quiets balance assertions
+
+2014-05-01 * Opening balance
+ Assets:Cash $100
+ Equity:Opening balance
+
+2014-05-10 * Spend money
+ Expenses:Foo $10
+ Assets:Cash -$10 = $80
+
+test bal --permissive
+ $90 Assets:Cash
+ $-100 Equity:Opening balance
+ $10 Expenses:Foo
+--------------------
+ 0
+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-values.test b/test/baseline/opt-values.test
new file mode 100644
index 00000000..35eeeaf6
--- /dev/null
+++ b/test/baseline/opt-values.test
@@ -0,0 +1,6 @@
+test tags -f test/input/drewr3.dat --values
+hastag: not block
+hastag: true
+nestedtag: true
+nobudget
+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/regress/1102.test b/test/regress/1102.test
new file mode 100644
index 00000000..259b2883
--- /dev/null
+++ b/test/regress/1102.test
@@ -0,0 +1,8 @@
+2015/01/15 * Grocery Store
+ Assets:Cash ¤ -5,00
+ Expenses:Food
+
+test -i /dev/null reg
+15-Jan-15 Grocery Store Assets:Cash ¤ -5,00 ¤ -5,00
+ Expenses:Food ¤ 5,00 0
+end test
diff --git a/test/regress/1106.test b/test/regress/1106.test
new file mode 100644
index 00000000..c6b41071
--- /dev/null
+++ b/test/regress/1106.test
@@ -0,0 +1,11 @@
+2015/01/20 Payee
+ Assets:Cash ¤ 12,34
+ Expenses:Food
+
+test -F "»%(trim(' Trimmed '))«\n" reg expenses
+»Trimmed«
+end test
+
+test -F "»%(trim('Trimmed'))«\n" reg expenses
+»Trimmed«
+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/634AA589.test b/test/regress/634AA589.test
deleted file mode 100644
index 8f8ff031..00000000
--- a/test/regress/634AA589.test
+++ /dev/null
@@ -1,19 +0,0 @@
-
-; The option --permissive quiets balance assertions
-
-2014-05-01 * Opening balance
- Assets:Cash $100
- Equity:Opening balance
-
-2014-05-10 * Spend money
- Expenses:Foo $10
- Assets:Cash -$10 = $80
-
-test bal --permissive
- $90 Assets:Cash
- $-100 Equity:Opening balance
- $10 Expenses:Foo
---------------------
- 0
-end test
-
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 8d13d2d6..de7fdd26 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -7,9 +7,16 @@ 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 t_value.cc)
+ set_source_files_properties(t_amount.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_balance.cc b/test/unit/t_balance.cc
index c4ec2f31..b503d02a 100644
--- a/test/unit/t_balance.cc
+++ b/test/unit/t_balance.cc
@@ -178,7 +178,10 @@ BOOST_AUTO_TEST_CASE(testEqaulity)
BOOST_CHECK(b4 == b5);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-value"
BOOST_CHECK_THROW(b0 == a0, balance_error);
+#pragma GCC diagnostic pop
BOOST_CHECK(b0.valid());
BOOST_CHECK(b1.valid());
diff --git a/tools/prepare-commit-msg b/tools/prepare-commit-msg
index e103888a..d2f927c0 100755
--- a/tools/prepare-commit-msg
+++ b/tools/prepare-commit-msg
@@ -5,11 +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" >/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
@@ -19,9 +25,14 @@ function add_ci_skip()
# comment or remove the next line.
[ci skip]
EOF
- mv "$tempfile" "$1"
+ mv "$tempfile" "$source"
fi
}
## MAIN
-add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$@"
+file="$1"
+source="$2"
+
+# Skip merge commits
+[ "$source" = "merge" ] && exit 0
+add_ci_skip '\(^src\|^test\|^doc/ledger3.texi\|^\.travis.yml\|CMakeLists.txt\)' "$file"
diff --git a/tools/travis-before_install.sh b/tools/travis-before_install.sh
index a1800021..fe010945 100755
--- a/tools/travis-before_install.sh
+++ b/tools/travis-before_install.sh
@@ -9,7 +9,6 @@ if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
fi
if [ -n "${BOOST_VERSION}" ]; then
- echo "Downloading boost ${BOOST_VERSION}"
mkdir -p $BOOST_ROOT
wget --no-verbose --output-document=- \
http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION//./_}.tar.bz2/download \
diff --git a/tools/travis-install.sh b/tools/travis-install.sh
index b5039d5c..4e8bdc48 100755
--- a/tools/travis-install.sh
+++ b/tools/travis-install.sh
@@ -15,7 +15,6 @@ if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
fi
if [ -d "${BOOST_ROOT}" ]; then
- echo "Installing boost ${BOOST_VERSION} in ${BOOST_ROOT}"
(cd "${BOOST_ROOT}"
./bootstrap.sh --with-libraries="${BOOST_LIBS}"
./b2 threading=multi --prefix="${BOOST_ROOT}" -d0 install