This commit is contained in:
Craig Earls 2014-05-18 08:25:30 -07:00
commit 8e6cdcc1d1
24 changed files with 167 additions and 104 deletions

28
.gitignore vendored
View file

@ -1,4 +1,6 @@
*.[oa] *.[oa]
*.so
*.so.*
*.backup *.backup
*.elc *.elc
*.gcov *.gcov
@ -11,12 +13,9 @@
.deps/ .deps/
.libs/ .libs/
ABOUT-NLS ABOUT-NLS
BaselineTests
Makefile Makefile
Makefile.am Makefile.am
Makefile.in Makefile.in
PyUnitTests
RegressionTests
TAGS TAGS
acconf.h.in acconf.h.in
aclocal.m4 aclocal.m4
@ -31,12 +30,16 @@ config.status
config.sub config.sub
configure configure
configure.ac configure.ac
data_tests
depcomp depcomp
doc/Doxyfile doc/Doxyfile
doc/*.aux doc/*.aux
doc/*.cp doc/*.cp
doc/*.cps
doc/*.fn doc/*.fn
doc/*.fns
doc/*.html
doc/*.info
doc/*.info-*
doc/*.ky doc/*.ky
doc/*.log doc/*.log
doc/*.pdf doc/*.pdf
@ -47,12 +50,9 @@ doc/*.vr
doc/.dirstamp doc/.dirstamp
doc/html/ doc/html/
doc/latex/ doc/latex/
doc/ledger.info
doc/ledger3.info
doc/refman.pdf doc/refman.pdf
doc/report/ doc/report/
elisp-comp elisp-comp
expr_tests
install-sh install-sh
intl/ intl/
ledger ledger
@ -60,20 +60,16 @@ libtool
ltmain.sh ltmain.sh
m4/ m4/
make.sh make.sh
math_tests
missing missing
mkinstalldirs mkinstalldirs
po/ po/
py-compile py-compile
report_tests
shave shave
shave-libtool shave-libtool
src/system.hh.gch
stamp-h1 stamp-h1
texinfo.tex texinfo.tex
tmpcvs*/ tmpcvs*/
tmpwrk*/ tmpwrk*/
util_tests
dist/win/vc9/Debug/ dist/win/vc9/Debug/
dist/win/vc9/gen-mpir.exe dist/win/vc9/gen-mpir.exe
dist/win/vc9/gen-mpir.ilk dist/win/vc9/gen-mpir.ilk
@ -82,10 +78,6 @@ dist/win/vc9/ledger.ncb
dist/win/vc9/ledger.vcproj.*.user dist/win/vc9/ledger.vcproj.*.user
dist/win/vc9/ledger.suo dist/win/vc9/ledger.suo
dist/win/vc9/lib/Win32/Debug/ dist/win/vc9/lib/Win32/Debug/
dist/win/vc9/system.hh
doc/ledger.1.html
doc/ledger.html
doc/ledger3.html
src/TAGS src/TAGS
CMakeCache.txt CMakeCache.txt
CPackConfig.cmake CPackConfig.cmake
@ -107,14 +99,10 @@ contrib/non-profit-audit-reports/tests/general-ledger.txt
contrib/non-profit-audit-reports/tests/MANIFEST contrib/non-profit-audit-reports/tests/MANIFEST
contrib/non-profit-audit-reports/general-ledger.zip contrib/non-profit-audit-reports/general-ledger.zip
/wiki/ /wiki/
doc/ledger-mode.info
doc/ledger3.info-1
doc/ledger3.info-2
CTestTestfile.cmake
.ninja_deps .ninja_deps
.ninja_log .ninja_log
build.ninja build.ninja
rules.ninja rules.ninja
Testing/Temporary test/Testing
/MathTests /MathTests
/UtilTests /UtilTests

View file

@ -24,7 +24,7 @@ option(BUILD_DOCS "Build and install documentation" OFF)
option(BUILD_WEB_DOCS "Build version of documentation suitable for viewing online" OFF) option(BUILD_WEB_DOCS "Build version of documentation suitable for viewing online" OFF)
option(BUILD_EMACSLISP "Build and install ledger-mode for Emacs" OFF) option(BUILD_EMACSLISP "Build and install ledger-mode for Emacs" OFF)
if(BUILD_DEBUG) if (BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
set(DEBUG_MODE 1) set(DEBUG_MODE 1)
else() else()
@ -32,13 +32,13 @@ else()
set(DEBUG_MODE 0) set(DEBUG_MODE 0)
endif() endif()
if(DISABLE_ASSERTS) if (DISABLE_ASSERTS)
set(NO_ASSERTS 1) set(NO_ASSERTS 1)
else() else()
set(NO_ASSERTS 0) set(NO_ASSERTS 0)
endif() endif()
if(CLANG_GCOV) if (CLANG_GCOV)
set(PROFILE_LIBS profile_rt) set(PROFILE_LIBS profile_rt)
set(CMAKE_REQUIRED_LIBRARIES ${PROFILE_LIBS}) set(CMAKE_REQUIRED_LIBRARIES ${PROFILE_LIBS})
endif() endif()
@ -47,14 +47,14 @@ endif()
find_package(PythonInterp) # Used for running tests find_package(PythonInterp) # Used for running tests
if(USE_PYTHON) if (USE_PYTHON)
if(NOT BUILD_LIBRARY) if (NOT BUILD_LIBRARY)
message(ERROR "Building the python module requires BUILD_LIBRARY=ON.") message(ERROR "Building the python module requires BUILD_LIBRARY=ON.")
endif() endif()
set(Python_ADDITIONAL_VERSIONS 2.7 2.6) set(Python_ADDITIONAL_VERSIONS 2.7 2.6)
find_package(PythonLibs) find_package(PythonLibs)
if(PYTHONLIBS_FOUND) if (PYTHONLIBS_FOUND)
set(BOOST_PYTHON python) set(BOOST_PYTHON python)
set(HAVE_BOOST_PYTHON 1) set(HAVE_BOOST_PYTHON 1)
include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS}) include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
@ -120,7 +120,7 @@ int main() {
return 0; return 0;
}" UNIX_PIPES_COMPILES) }" UNIX_PIPES_COMPILES)
if(UNIX_PIPES_COMPILES) if (UNIX_PIPES_COMPILES)
set(HAVE_UNIX_PIPES 1) set(HAVE_UNIX_PIPES 1)
else() else()
set(HAVE_UNIX_PIPES 0) set(HAVE_UNIX_PIPES 0)
@ -142,7 +142,7 @@ int main() {
return u32regex_search(text, r) ? 0 : 1; return u32regex_search(text, r) ? 0 : 1;
}" BOOST_REGEX_UNICODE_RUNS) }" BOOST_REGEX_UNICODE_RUNS)
if(BOOST_REGEX_UNICODE_RUNS) if (BOOST_REGEX_UNICODE_RUNS)
set(HAVE_BOOST_REGEX_UNICODE 1) set(HAVE_BOOST_REGEX_UNICODE 1)
else() else()
set(HAVE_BOOST_REGEX_UNICODE 0) set(HAVE_BOOST_REGEX_UNICODE 0)
@ -155,13 +155,13 @@ cmake_pop_check_state()
include_directories(${CMAKE_INCLUDE_PATH}) include_directories(${CMAKE_INCLUDE_PATH})
macro(find_opt_library_and_header _header_var _header _lib_var _lib _have_var) macro(find_opt_library_and_header _header_var _header _lib_var _lib _have_var)
if(${_have_var}) if (${_have_var})
find_path(${_header_var} ${_header}) find_path(${_header_var} ${_header})
if(NOT ${_header_var}) if (NOT ${_header_var})
set(${_have_var} 0) set(${_have_var} 0)
else() else()
find_library(${_lib_var} ${_lib}) find_library(${_lib_var} ${_lib})
if(NOT ${_lib_var}) if (NOT ${_lib_var})
set(${_have_var} 0) set(${_have_var} 0)
else() else()
include_directories(SYSTEM "${${_header_var}}") include_directories(SYSTEM "${${_header_var}}")
@ -175,12 +175,12 @@ endmacro(find_opt_library_and_header _header_var _header _lib_var _lib _have_var
macro(find_req_library_and_header _header_var _header _lib_var _lib) macro(find_req_library_and_header _header_var _header _lib_var _lib)
find_path(${_header_var} ${_header}) find_path(${_header_var} ${_header})
if(NOT ${_header_var}) if (NOT ${_header_var})
message(SEND_ERROR "Could not find ${_header} on your system") message(SEND_ERROR "Could not find ${_header} on your system")
else() else()
include_directories(SYSTEM "${${_header_var}}") include_directories(SYSTEM "${${_header_var}}")
find_library(${_lib_var} ${_lib}) find_library(${_lib_var} ${_lib})
if(NOT ${_lib_var}) if (NOT ${_lib_var})
message(SEND_ERROR "Could not find library ${_lib} on your system") message(SEND_ERROR "Could not find library ${_lib} on your system")
endif() endif()
endif() endif()
@ -194,7 +194,7 @@ find_opt_library_and_header(EDIT_PATH histedit.h EDIT_LIB edit HAVE_EDIT)
#find_package(Gettext) # Used for running tests #find_package(Gettext) # Used for running tests
#if(GETTEXT_FOUND) #if (GETTEXT_FOUND)
# set(HAVE_GETTEXT 1) # set(HAVE_GETTEXT 1)
#else() #else()
set(HAVE_GETTEXT 0) set(HAVE_GETTEXT 0)
@ -209,18 +209,18 @@ find_opt_library_and_header(EDIT_PATH histedit.h EDIT_LIB edit HAVE_EDIT)
macro(add_ledger_library_dependencies _target) macro(add_ledger_library_dependencies _target)
target_link_libraries(${_target} ${MPFR_LIB}) target_link_libraries(${_target} ${MPFR_LIB})
target_link_libraries(${_target} ${GMP_LIB}) target_link_libraries(${_target} ${GMP_LIB})
if(HAVE_EDIT) if (HAVE_EDIT)
target_link_libraries(${_target} ${EDIT_LIB}) target_link_libraries(${_target} ${EDIT_LIB})
endif() endif()
if(HAVE_GETTEXT) if (HAVE_GETTEXT)
target_link_libraries(${_target} ${INTL_LIB}) target_link_libraries(${_target} ${INTL_LIB})
endif() endif()
if(HAVE_BOOST_PYTHON) if (HAVE_BOOST_PYTHON)
target_link_libraries(${_target} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries(${_target} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
else() else()
target_link_libraries(${_target} ${Boost_LIBRARIES}) target_link_libraries(${_target} ${Boost_LIBRARIES})
endif() endif()
if(HAVE_BOOST_REGEX_UNICODE) if (HAVE_BOOST_REGEX_UNICODE)
target_link_libraries(${_target} icuuc) target_link_libraries(${_target} icuuc)
endif() endif()
target_link_libraries(${_target} ${PROFILE_LIBS}) target_link_libraries(${_target} ${PROFILE_LIBS})
@ -241,7 +241,7 @@ configure_file(
${PROJECT_SOURCE_DIR}/src/system.hh.in ${PROJECT_SOURCE_DIR}/src/system.hh.in
${PROJECT_BINARY_DIR}/system.hh) ${PROJECT_BINARY_DIR}/system.hh)
if(CMAKE_CXX_COMPILER MATCHES "clang") if (CMAKE_CXX_COMPILER MATCHES "clang")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+") elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
@ -249,7 +249,7 @@ endif()
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(doc) add_subdirectory(doc)
if(BUILD_EMACSLISP) if (BUILD_EMACSLISP)
add_subdirectory(lisp) add_subdirectory(lisp)
endif() endif()
add_subdirectory(test) add_subdirectory(test)

View file

@ -101,30 +101,30 @@ And for building the current `maint` branch:
If you build stuff using MacPorts on OS X, as I do, here is what you would If you build stuff using MacPorts on OS X, as I do, here is what you would
run: run:
sudo port install -f cmake python26 sudo port install -f cmake python26 \
libiconv +universal zlib +universal gmp +universal libiconv +universal zlib +universal gmp +universal \
mpfr +universal ncurses +universal ncursesw +universal mpfr +universal ncurses +universal ncursesw +universal \
gettext +universal libedit +universal boost-jam gettext +universal libedit +universal boost-jam \
boost +st+python26+icu texlive doxygen graphviz boost +st+python26+icu texlive doxygen graphviz \
texinfo lcov sloccount texinfo lcov sloccount
### Ubuntu ### Ubuntu
If you're going to build on Ubuntu, `sudo apt-get install ...` the If you're going to build on Ubuntu, `sudo apt-get install ...` the
following packages (current as of Ubuntu 14.04): 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-system-dev libboost-dev python-dev gettext git \
libboost-date-time-dev libboost-filesystem-dev libboost-date-time-dev libboost-filesystem-dev \
libboost-iostreams-dev libboost-python-dev libboost-regex-dev libboost-iostreams-dev libboost-python-dev libboost-regex-dev \
libboost-test-dev libedit-dev libgmp3-dev libmpfr-dev texinfo libboost-test-dev libedit-dev libgmp3-dev libmpfr-dev texinfo
Or, for Ubuntu 12.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 python-dev gettext libgmp3-dev libmpfr-dev libboost-dev \
libboost-regex-dev libboost-date-time-dev libboost-regex-dev libboost-date-time-dev \
libboost-filesystem-dev libboost-python-dev texinfo lcov libboost-filesystem-dev libboost-python-dev texinfo lcov \
sloccount libboost-iostreams-dev libboost-test-dev sloccount libboost-iostreams-dev libboost-test-dev
### Debian ### Debian

View file

@ -7,7 +7,7 @@
if (USE_DOXYGEN) if (USE_DOXYGEN)
find_package(Doxygen) find_package(Doxygen)
if(NOT DOXYGEN_FOUND) if (NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.") message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.")
endif() endif()
@ -27,7 +27,7 @@ endif()
######################################################################## ########################################################################
if(NOT BUILD_DOCS) if (NOT BUILD_DOCS)
add_custom_target(doc DEPENDS doc.doxygen) add_custom_target(doc DEPENDS doc.doxygen)
return() return()
endif() endif()
@ -45,7 +45,7 @@ find_program(GROFF groff)
foreach(file ${info_files}) foreach(file ${info_files})
get_filename_component(file_base ${file} NAME_WE) get_filename_component(file_base ${file} NAME_WE)
if(NOT MAKEINFO) if (NOT MAKEINFO)
message(WARNING "Could not find makeinfo. Info version of documentation cannot be built.") message(WARNING "Could not find makeinfo. Info version of documentation cannot be built.")
else() else()
add_custom_command(OUTPUT ${file_base}.info add_custom_command(OUTPUT ${file_base}.info
@ -55,8 +55,8 @@ foreach(file ${info_files})
list(APPEND ledger_doc_files ${file_base}.info) list(APPEND ledger_doc_files ${file_base}.info)
endif() endif()
if(BUILD_WEB_DOCS) if (BUILD_WEB_DOCS)
if(NOT MAKEINFO) if (NOT MAKEINFO)
message(WARNING "Could not find makeinfo. HTML version of documentation cannot be built.") message(WARNING "Could not find makeinfo. HTML version of documentation cannot be built.")
endif() endif()
add_custom_command(OUTPUT ${file_base}.html add_custom_command(OUTPUT ${file_base}.html
@ -66,10 +66,10 @@ foreach(file ${info_files})
list(APPEND ledger_doc_files ${file_base}.html) list(APPEND ledger_doc_files ${file_base}.html)
endif(BUILD_WEB_DOCS) endif(BUILD_WEB_DOCS)
if(NOT TEXI2PDF OR NOT TEX) if (NOT TEXI2PDF OR NOT TEX)
message(WARNING "Could not find texi2pdf or tex. PDF version of documentation will not be built.") message(WARNING "Could not find texi2pdf or tex. PDF version of documentation will not be built.")
else() else()
if(BUILD_A4_PDF) if (BUILD_A4_PDF)
set(papersize --texinfo=@afourpaper) set(papersize --texinfo=@afourpaper)
endif() endif()
add_custom_command(OUTPUT ${file_base}.pdf add_custom_command(OUTPUT ${file_base}.pdf
@ -82,12 +82,12 @@ endforeach()
######################################################################## ########################################################################
if(BUILD_WEB_DOCS) if (BUILD_WEB_DOCS)
include(FindUnixCommands) include(FindUnixCommands)
if(NOT BASH) if (NOT BASH)
message(FATAL_ERROR "Could not find bash. Unable to build documentation.") message(FATAL_ERROR "Could not find bash. Unable to build documentation.")
endif() endif()
if(MAN2HTML) if (MAN2HTML)
add_custom_command(OUTPUT ledger.1.html add_custom_command(OUTPUT ledger.1.html
COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
@ -112,7 +112,7 @@ add_custom_target(doc DEPENDS ${ledger_doc_files} doc.doxygen)
include(GNUInstallDirs) include(GNUInstallDirs)
if(CMAKE_INSTALL_MANDIR) if (CMAKE_INSTALL_MANDIR)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
endif(CMAKE_INSTALL_MANDIR) endif(CMAKE_INSTALL_MANDIR)

View file

@ -39,7 +39,7 @@ macro(add_emacs_lisp_target el)
COMMENT "Creating byte-compiled Emacs lisp ${CMAKE_CURRENT_BINARY_DIR}/${el}c") COMMENT "Creating byte-compiled Emacs lisp ${CMAKE_CURRENT_BINARY_DIR}/${el}c")
endmacro(add_emacs_lisp_target el) endmacro(add_emacs_lisp_target el)
if(EMACS_EXECUTABLE) if (EMACS_EXECUTABLE)
# uncompilable .el files # uncompilable .el files
foreach(el ${EMACS_LISP_SOURCES_UNCOMPILABLE}) foreach(el ${EMACS_LISP_SOURCES_UNCOMPILABLE})
configure_file(${el} ${CMAKE_CURRENT_BINARY_DIR}/${el}) configure_file(${el} ${CMAKE_CURRENT_BINARY_DIR}/${el})

View file

@ -75,8 +75,8 @@ reconcile-finish will mark all pending posting cleared."
:type 'string :type 'string
:group 'ledger-reconcile) :group 'ledger-reconcile)
(defcustom ledger-reconcile-sort-key "(date)" (defcustom ledger-reconcile-sort-key "(0)"
"Default key for sorting reconcile buffer. For no sorting by default, use '(0)'." "Default key for sorting reconcile buffer. Possible values are '(date)', '(amount)', '(payee)'. For no sorting, i.e. using ledger file order, use '(0)'."
:type 'string :type 'string
:group 'ledger-reconcile) :group 'ledger-reconcile)

View file

@ -52,7 +52,7 @@ set(LEDGER_SOURCES
strptime.cc strptime.cc
wcwidth.cc) wcwidth.cc)
if(HAVE_BOOST_PYTHON) if (HAVE_BOOST_PYTHON)
list(APPEND LEDGER_SOURCES list(APPEND LEDGER_SOURCES
py_account.cc py_account.cc
py_amount.cc py_amount.cc
@ -135,8 +135,8 @@ set(LEDGER_INCLUDES
strptime.h strptime.h
${PROJECT_BINARY_DIR}/system.hh) ${PROJECT_BINARY_DIR}/system.hh)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
if((CMAKE_CXX_COMPILER MATCHES "clang") OR (CMAKE_CXX_COMPILER MATCHES "cxx")) if ((CMAKE_CXX_COMPILER MATCHES "clang") OR (CMAKE_CXX_COMPILER MATCHES "cxx"))
add_definitions( add_definitions(
-Weverything -Weverything
-Wno-disabled-macro-expansion -Wno-disabled-macro-expansion
@ -156,7 +156,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set_source_files_properties( set_source_files_properties(
${${_src_list}} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}") ${${_src_list}} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}")
if(_other_srcs) if (_other_srcs)
set_source_files_properties( set_source_files_properties(
${_other_srcs} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}") ${_other_srcs} PROPERTIES COMPILE_FLAGS "-include ${_header_filename}")
endif() endif()
@ -164,7 +164,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(_args ${CMAKE_CXX_FLAGS}) set(_args ${CMAKE_CXX_FLAGS})
list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG}) list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG})
if(BUILD_LIBRARY) if (BUILD_LIBRARY)
list(APPEND _args ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) list(APPEND _args ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
endif() endif()
list(APPEND _args "-std=c++11 ") list(APPEND _args "-std=c++11 ")
@ -211,7 +211,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set_source_files_properties( set_source_files_properties(
${${_src_list}} PROPERTIES COMPILE_FLAGS "-Winvalid-pch") ${${_src_list}} PROPERTIES COMPILE_FLAGS "-Winvalid-pch")
if(_other_srcs) if (_other_srcs)
set_source_files_properties( set_source_files_properties(
${_other_srcs} PROPERTIES COMPILE_FLAGS "-Winvalid-pch") ${_other_srcs} PROPERTIES COMPILE_FLAGS "-Winvalid-pch")
endif() endif()
@ -219,7 +219,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(_args ${CMAKE_CXX_FLAGS}) set(_args ${CMAKE_CXX_FLAGS})
list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG}) list(APPEND _args ${CMAKE_CXX_FLAGS_DEBUG})
if(BUILD_LIBRARY) if (BUILD_LIBRARY)
list(APPEND _args ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) list(APPEND _args ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
endif() endif()
list(APPEND _args ${GXX_WARNING_FLAGS}) list(APPEND _args ${GXX_WARNING_FLAGS})
@ -253,7 +253,7 @@ add_pch_rule(${PROJECT_BINARY_DIR}/system.hh LEDGER_SOURCES main.cc global.cc)
include(GNUInstallDirs) include(GNUInstallDirs)
if(BUILD_LIBRARY) if (BUILD_LIBRARY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
add_library(libledger SHARED ${LEDGER_SOURCES}) add_library(libledger SHARED ${LEDGER_SOURCES})
add_ledger_library_dependencies(libledger) add_ledger_library_dependencies(libledger)
@ -274,7 +274,7 @@ else()
add_ledger_library_dependencies(ledger) add_ledger_library_dependencies(ledger)
endif() endif()
if(USE_PYTHON) if (USE_PYTHON)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
"from __future__ import print_function "from __future__ import print_function
import distutils.sysconfig as s import distutils.sysconfig as s
@ -284,7 +284,7 @@ print(s.get_python_lib(True, prefix=''))"
CACHE PATH "python module directory (${_TMP_PYTHON_SITE_PACKAGES})") CACHE PATH "python module directory (${_TMP_PYTHON_SITE_PACKAGES})")
if (PYTHON_SITE_PACKAGES) if (PYTHON_SITE_PACKAGES)
if(WIN32 AND NOT CYGWIN) if (WIN32 AND NOT CYGWIN)
set(_ledger_python_module_name "ledger.pyd") set(_ledger_python_module_name "ledger.pyd")
elseif(CMAKE_HOST_APPLE) elseif(CMAKE_HOST_APPLE)
set(_ledger_python_module_name "ledger.so") set(_ledger_python_module_name "ledger.so")

View file

@ -206,7 +206,7 @@ format_t::element_t * format_t::parse_elements(const string& fmt,
sizeof(format_mapping_t)); i++) { sizeof(format_mapping_t)); i++) {
if (*p == single_letter_mappings[i].letter) { if (*p == single_letter_mappings[i].letter) {
std::ostringstream expr; std::ostringstream expr;
for (const char * ptr = single_letter_mappings[i].expr; *ptr; ){ for (const char * ptr = single_letter_mappings[i].expr; *ptr;) {
if (*ptr == '$') { if (*ptr == '$') {
const char * beg = ++ptr; const char * beg = ++ptr;
while (*ptr && std::isalpha(*ptr)) while (*ptr && std::isalpha(*ptr))

View file

@ -142,13 +142,13 @@ void global_scope_t::read_init()
throw_(parse_error, _f("Could not find specified init file %1%") % init_file); throw_(parse_error, _f("Could not find specified init file %1%") % init_file);
} }
} else { } else {
if (const char * home_var = std::getenv("HOME")){ if (const char * home_var = std::getenv("HOME")) {
init_file = (path(home_var) / ".ledgerrc"); init_file = (path(home_var) / ".ledgerrc");
} else { } else {
init_file = ("./.ledgerrc"); init_file = ("./.ledgerrc");
} }
} }
if(exists(init_file)){ if (exists(init_file)) {
parse_init(init_file); parse_init(init_file);
} }
} }

View file

@ -174,7 +174,7 @@ account_t * journal_t::expand_aliases(string name) {
// prevent infinite excursion. Each alias may only be expanded at most once. // prevent infinite excursion. Each alias may only be expanded at most once.
account_t * result = NULL; account_t * result = NULL;
if(no_aliases) if (no_aliases)
return result; return result;
bool keep_expanding = true; bool keep_expanding = true;
@ -184,7 +184,7 @@ account_t * journal_t::expand_aliases(string name) {
if (account_aliases.size() > 0) { if (account_aliases.size() > 0) {
accounts_map::const_iterator i = account_aliases.find(name); accounts_map::const_iterator i = account_aliases.find(name);
if (i != account_aliases.end()) { if (i != account_aliases.end()) {
if(std::find(already_seen.begin(), already_seen.end(), name) != already_seen.end()) { if (std::find(already_seen.begin(), already_seen.end(), name) != already_seen.end()) {
throw_(std::runtime_error, throw_(std::runtime_error,
_f("Infinite recursion on alias expansion for %1%") _f("Infinite recursion on alias expansion for %1%")
% name); % name);
@ -197,11 +197,11 @@ account_t * journal_t::expand_aliases(string name) {
// only check the very first account for alias expansion, in case // only check the very first account for alias expansion, in case
// that can be expanded successfully // that can be expanded successfully
size_t colon = name.find(':'); size_t colon = name.find(':');
if(colon != string::npos) { if (colon != string::npos) {
string first_account_name = name.substr(0, colon); string first_account_name = name.substr(0, colon);
accounts_map::const_iterator j = account_aliases.find(first_account_name); accounts_map::const_iterator j = account_aliases.find(first_account_name);
if (j != account_aliases.end()) { if (j != account_aliases.end()) {
if(std::find(already_seen.begin(), already_seen.end(), first_account_name) != already_seen.end()) { if (std::find(already_seen.begin(), already_seen.end(), first_account_name) != already_seen.end()) {
throw_(std::runtime_error, throw_(std::runtime_error,
_f("Infinite recursion on alias expansion for %1%") _f("Infinite recursion on alias expansion for %1%")
% first_account_name); % first_account_name);

View file

@ -229,7 +229,7 @@ public:
inline bool is_eq(const char * p, const char * n) { inline bool is_eq(const char * p, const char * n) {
// Test whether p matches n, substituting - in p for _ in n. // Test whether p matches n, substituting - in p for _ in n.
for (; *p && *n; p++, n++) { for (; *p && *n; p++, n++) {
if (! (*p == '-' && *n == '_' ) && *p != *n) if (! (*p == '-' && *n == '_') && *p != *n)
return false; return false;
} }
// Ignore any trailing underscore // Ignore any trailing underscore

View file

@ -331,10 +331,10 @@ void report_tags::flush()
void report_tags::operator()(post_t& post) void report_tags::operator()(post_t& post)
{ {
if(post.metadata){ if (post.metadata) {
foreach (const item_t::string_map::value_type& data, *post.metadata){ foreach (const item_t::string_map::value_type& data, *post.metadata) {
string tag=data.first; string tag=data.first;
if(report.HANDLED(values) && (data.second).first){ if (report.HANDLED(values) && (data.second).first) {
tag+=": "+ (data.second).first.get().to_string(); tag+=": "+ (data.second).first.get().to_string();
} }
std::map<string, std::size_t>::iterator i = tags.find(tag); std::map<string, std::size_t>::iterator i = tags.find(tag);

View file

@ -108,7 +108,7 @@ struct datetime_from_python
static void* convertible(PyObject* obj_ptr) static void* convertible(PyObject* obj_ptr)
{ {
MY_PyDateTime_IMPORT; MY_PyDateTime_IMPORT;
if(PyDateTime_Check(obj_ptr)) return obj_ptr; if (PyDateTime_Check(obj_ptr)) return obj_ptr;
return 0; return 0;
} }

View file

@ -93,13 +93,13 @@ std::size_t session_t::read_data(const string& master_account)
acct = journal->find_account(master_account); acct = journal->find_account(master_account);
optional<path> price_db_path; optional<path> price_db_path;
if (HANDLED(price_db_)){ if (HANDLED(price_db_)) {
price_db_path = resolve_path(HANDLER(price_db_).str()); price_db_path = resolve_path(HANDLER(price_db_).str());
if (!exists(price_db_path.get())){ if (!exists(price_db_path.get())) {
throw_(parse_error, _f("Could not find specified price-db file %1%") % price_db_path); throw_(parse_error, _f("Could not find specified price-db file %1%") % price_db_path);
} }
} else { } else {
if (const char * home_var = std::getenv("HOME")){ if (const char * home_var = std::getenv("HOME")) {
price_db_path = (path(home_var) / ".pricedb"); price_db_path = (path(home_var) / ".pricedb");
} else { } else {
price_db_path = ("./.ledgerrc"); price_db_path = ("./.ledgerrc");

View file

@ -1638,24 +1638,23 @@ post_t * instance_t::parse_post(char * line,
"line " << context.linenum << ": " << "post amount = " << amt); "line " << context.linenum << ": " << "post amount = " << amt);
amount_t diff = amt; amount_t diff = amt;
amount_t tot;
switch (account_total.type()) { switch (account_total.type()) {
case value_t::AMOUNT: case value_t::AMOUNT:
tot = account_total.as_amount(); diff -= account_total.as_amount();
break; break;
case value_t::BALANCE: case value_t::BALANCE:
if (optional<amount_t> comm_bal = if (optional<amount_t> comm_bal =
account_total.as_balance().commodity_amount(amt.commodity())) account_total.as_balance().commodity_amount(amt.commodity()))
tot = *comm_bal; diff -= *comm_bal;
break; break;
default: default:
break; break;
} }
diff -= tot; amount_t tot = amt - diff;
DEBUG("post.assign", DEBUG("post.assign",
"line " << context.linenum << ": " << "diff = " << diff); "line " << context.linenum << ": " << "diff = " << diff);

View file

@ -1,7 +1,7 @@
include(ProcessorCount) include(ProcessorCount)
ProcessorCount(PROCESSORS) ProcessorCount(PROCESSORS)
if(NOT PROCESSORS EQUAL 0) if (NOT PROCESSORS EQUAL 0)
math(EXPR JOBS "${PROCESSORS} * 2") math(EXPR JOBS "${PROCESSORS} * 2")
set(CTEST_BUILD_FLAGS -j${JOBS}) set(CTEST_BUILD_FLAGS -j${JOBS})
endif() endif()
@ -12,17 +12,17 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_BUILD_FLAGS})
add_subdirectory(unit) add_subdirectory(unit)
if(HAVE_BOOST_PYTHON) if (HAVE_BOOST_PYTHON)
set(TEST_PYTHON_FLAGS "--python") set(TEST_PYTHON_FLAGS "--python")
endif() endif()
macro(add_ledger_harness_tests _class) macro(add_ledger_harness_tests _class)
if(PYTHONINTERP_FOUND) if (PYTHONINTERP_FOUND)
file(GLOB ${_class}_TESTS *.test) file(GLOB ${_class}_TESTS *.test)
foreach(TestFile ${${_class}_TESTS}) foreach(TestFile ${${_class}_TESTS})
get_filename_component(TestFile_Name ${TestFile} NAME_WE) get_filename_component(TestFile_Name ${TestFile} NAME_WE)
string(FIND ${TestFile_Name} "_py" TestFile_IsPythonTest) string(FIND ${TestFile_Name} "_py" TestFile_IsPythonTest)
if((TestFile_IsPythonTest EQUAL -1) OR HAVE_BOOST_PYTHON) if ((TestFile_IsPythonTest EQUAL -1) OR HAVE_BOOST_PYTHON)
add_test(${_class}Test_${TestFile_Name} add_test(${_class}Test_${TestFile_Name}
${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py
${LEDGER_LOCATION} ${PROJECT_SOURCE_DIR} ${LEDGER_LOCATION} ${PROJECT_SOURCE_DIR}
@ -39,7 +39,7 @@ add_subdirectory(baseline)
add_subdirectory(regress) add_subdirectory(regress)
# jww (2014-04-17): This is temporary until we find a fix. # jww (2014-04-17): This is temporary until we find a fix.
#if(PYTHONINTERP_FOUND) #if (PYTHONINTERP_FOUND)
# set(_class DocTests) # set(_class DocTests)
# file(GLOB ${_class}_TESTS ${PROJECT_SOURCE_DIR}/doc/*.texi) # file(GLOB ${_class}_TESTS ${PROJECT_SOURCE_DIR}/doc/*.texi)
# foreach(TestFile ${${_class}_TESTS}) # foreach(TestFile ${${_class}_TESTS})

View file

@ -2,12 +2,21 @@ alias A=B:A
alias B=C:B alias B=C:B
alias C=D:C alias C=D:C
account Delta
alias D
2001-01-01 Test 2001-01-01 Test
A 10 EUR A 10 EUR
Foo Foo
2001-01-01 Test
D 20 EUR
Foo
test reg test reg
01-Jan-01 Test B:A 10 EUR 10 EUR 01-Jan-01 Test B:A 10 EUR 10 EUR
Foo -10 EUR 0 Foo -10 EUR 0
01-Jan-01 Test Delta 20 EUR 20 EUR
Foo -20 EUR 0
end test end test

View file

@ -0,0 +1,18 @@
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 -> 1
__ERROR__
While parsing file "$FILE", line 8:
While parsing posting:
Assets:Cash -$10 = $80
^^^
Error: Balance assertion off by $-10 (expected to see $100)
end test

View file

@ -0,0 +1,20 @@
alias A=Foo
account Bar
alias B
2001-01-01 * Test
A 10 EUR
B
test reg
01-Jan-01 Test Foo 10 EUR 10 EUR
Bar -10 EUR 0
end test
test reg --no-aliases
01-Jan-01 Test A 10 EUR 10 EUR
B -10 EUR 0
end test

View file

@ -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

10
test/regress/AA2FF2B.test Normal file
View file

@ -0,0 +1,10 @@
2008/01/20 * La Poste
Revenu:Invest:Exonéré
Actif:Courant:LaPosteLivretA 25,24 € = 25,24 €
test --args-only --decimal-comma bal
25,24 € Actif:Courant:LaPosteLivretA
-25,24 € Revenu:Invest:Exonéré
--------------------
0
end test

View file

@ -5,7 +5,7 @@ endmacro(add_ledger_test _name)
include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/src)
if(BUILD_LIBRARY) if (BUILD_LIBRARY)
add_executable(UtilTests t_times.cc) add_executable(UtilTests t_times.cc)
add_ledger_test(UtilTests) add_ledger_test(UtilTests)

View file

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
aspell check --mode=texinfo $(dirname $0)/../doc/ledger3.texi aspell --lang=en_US.UTF-8 check --mode=texinfo $(dirname $0)/../doc/ledger3.texi