From 82ac7ef313ae8a8d9251706d66345efed6bf90ab Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 11 Jan 2013 00:10:30 -0600 Subject: [PATCH 1/6] Guard against a possible NULL --- src/filters.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filters.cc b/src/filters.cc index 5e2bf983..7570809a 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -983,7 +983,8 @@ void interval_posts::flush() sort_posts_by_date()); // Determine the beginning interval by using the earliest post - if (! interval.find_period(all_posts.front()->date())) + if (all_posts.front() && + ! interval.find_period(all_posts.front()->date())) throw_(std::logic_error, _("Failed to find period for interval report")); // Walk the interval forward reporting all posts within each one From aba0a5ed2dc2dc91f61be32f4c12a5cf6bffd754 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 11 Jan 2013 07:08:51 -0600 Subject: [PATCH 2/6] Improvement to account alias expansion Aliases are now expanded not only if they occur by themselves, but also if they occur as the beginning of a multi-part account. Given the account should now be expanded to . --- src/journal.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/journal.cc b/src/journal.cc index e6c09125..f45b7527 100644 --- a/src/journal.cc +++ b/src/journal.cc @@ -127,8 +127,19 @@ account_t * journal_t::register_account(const string& name, post_t * post, // object. if (account_aliases.size() > 0) { accounts_map::const_iterator i = account_aliases.find(name); - if (i != account_aliases.end()) + if (i != account_aliases.end()) { result = (*i).second; + } else { + // only check the very first account for alias expansion, in case + // that can be expanded successfully + size_t colon = name.find(':'); + if(colon != string::npos) { + accounts_map::const_iterator i = account_aliases.find(name.substr(0, colon)); + if (i != account_aliases.end()) { + result = find_account((*i).second->fullname() + name.substr(colon)); + } + } + } } // Create the account object and associate it with the journal; this From ea09a8d50720f0ca42cee46d017e111a4349fa97 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 11 Jan 2013 10:07:58 -0800 Subject: [PATCH 3/6] escape @ characters properly so they show up --- doc/ledger3.texi | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/ledger3.texi b/doc/ledger3.texi index f99504f0..caec7667 100644 --- a/doc/ledger3.texi +++ b/doc/ledger3.texi @@ -1312,9 +1312,9 @@ your opening balance entry could look like this: Assets:Joint Checking $800.14 Assets:Other Checking $63.44 Assets:Savings $2805.54 - Assets:Investments:401K:Deferred 100.0000 VIFSX @ $80.5227 - Assets:Investments:401K:Matching 50.0000 VIFSX @ $83.7015 - Assets:Investments:IRA 250.0000 VTHRX @ $20.5324 + Assets:Investments:401K:Deferred 100.0000 VIFSX @@ $80.5227 + Assets:Investments:401K:Matching 50.0000 VIFSX @@ $83.7015 + Assets:Investments:IRA 250.0000 VTHRX @@ $20.5324 Liabilities:Mortgage $-175634.88 Liabilities:Car Loan $-3494.26 Liabilities:Visa -$1762.44 @@ -2970,12 +2970,12 @@ resulting posting cost is $50.00 per share. @node Explicit posting costs, Posting cost expressions, Posting cost, Transactions @section Explicit posting costs -You can make any posting's cost explicit using the @ symbol after the amount +You can make any posting's cost explicit using the @@ symbol after the amount or amount expression: @smallexample 2012-03-10 My Broker - Assets:Brokerage 10 AAPL @ $50.00 + Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash $-500.00 @end smallexample @@ -2984,7 +2984,7 @@ the first posting's cost, you can elide the other amount: @smallexample 2012-03-10 My Broker - Assets:Brokerage 10 AAPL @ $50.00 + Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash @end smallexample @@ -3029,7 +3029,7 @@ You can even have both: @node Total posting costs, Virtual posting costs, Posting cost expressions, Transactions @section Total posting costs -The cost figure following the @ character specifies the @emph{per-unit} price for +The cost figure following the @@ character specifies the @emph{per-unit} price for the commodity being transferred. If you'd like to specify the total cost instead, use @@@@: @@ -3149,7 +3149,7 @@ Plus, it comes with dangers. This works fine: @smallexample 2012-04-10 My Broker - Assets:Brokerage 10 AAPL @ $50.00 + Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash $750.00 2012-04-10 My Broker @@ -3167,7 +3167,7 @@ Plus, it comes with dangers. This works fine: @smallexample 2012-04-10 My Broker - Assets:Brokerage 10 AAPL @ $50.00 + Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash $750.00 2012-04-10 My Broker @@ -3192,7 +3192,7 @@ following two transactions are equivalent: @smallexample 2012-04-10 My Broker - Assets:Brokerage 10 AAPL @ $50.00 + Assets:Brokerage 10 AAPL @@ $50.00 Assets:Brokerage:Cash $750.00 2012-04-10 My Broker @@ -3257,7 +3257,7 @@ that dates are parsed in value expressions): You can also associate arbitrary notes for your own record keeping in parentheses, and reveal them with --lot-notes. One caveat is that the note -cannot begin with an @ character, as that would indicate a virtual cost: +cannot begin with an @@ character, as that would indicate a virtual cost: @smallexample 2012-04-10 My Broker @@ -4914,7 +4914,7 @@ model transaction: --- Context is first posting of the following transaction --- 2004/05/27 Book Store ; This note applies to all postings. :SecondTag: - Expenses:Books 20 BOOK @ $10 + Expenses:Books 20 BOOK @@ $10 ; Metadata: Some Value ; Typed:: $100 + $200 ; :ExampleTag: From c88862fd66489fa8c06d06d3876b2c0f59dff3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= Date: Mon, 14 Jan 2013 16:23:16 +0100 Subject: [PATCH 4/6] convert doc/Makefile to CMake CMake will build the pdf version of the manual if texi2pdf is installed. It will be installed to DOCDIR/ledger{,3}.pdf, for example /usr/local/share/ledger/ledger3.pdf. Also, the man page will be installed to MANDIR/man1/ledger.1 The option BUILD_DOCS is now on by default. A new option BUILD_WEB_DOCS is used to toggle the generation of the html version of the manual and the man page (off by default). All this is added to the 'doc' make target. --- CMakeLists.txt | 5 ++-- doc/CMakeLists.txt | 73 ++++++++++++++++++++++++++++++++++++++++++++++ doc/Makefile | 17 ----------- 3 files changed, 76 insertions(+), 19 deletions(-) delete mode 100644 doc/Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt index a4109a17..132d7c47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8.5) -project(Ledger) +PROJECT(ledger) set(Ledger_VERSION_MAJOR 3) set(Ledger_VERSION_MINOR 0) @@ -18,7 +18,8 @@ option(DISABLE_ASSERTS "Build without any internal consistency checks" OFF) option(BUILD_DEBUG "Build support for runtime debugging" OFF) option(BUILD_LIBRARY "Build and install Ledger as a library" ON) -option(BUILD_DOCS "Build and install documentation" OFF) +option(BUILD_DOCS "Build and install documentation" ON) +option(BUILD_WEB_DOCS "Build version of documentation suitable for viewing online" OFF) option(BUILD_EMACSLISP "Build and install ledger-mode for Emacs" OFF) if(BUILD_DEBUG) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index e69de29b..b50c8696 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -0,0 +1,73 @@ +set(info_files ledger.texi ledger3.texi) + +find_program(MAKEINFO makeinfo) +find_program(TEXI2PDF texi2pdf) +find_program(MAN2HTML man2html) + +######################################################################## + +foreach(file ${info_files}) + get_filename_component(file_base ${file} NAME_WE) + if(BUILD_WEB_DOCS) + if(NOT MAKEINFO) + message(FATAL_ERROR "Could not find makeinfo. HTML version of documentation cannot be built.") + endif() + + add_custom_command(OUTPUT ${file_base}.html + COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${file} + DEPENDS ${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.html) + endif(BUILD_WEB_DOCS) + + if(NOT TEXI2PDF) + mesage(WARNING "Could not find texi2pdf. PDF version of documentation will not be built.") + else() + get_filename_component(file_base ${file} NAME_WE) + add_custom_command(OUTPUT ${file_base}.pdf + COMMAND texi2pdf -b -q ${file} + COMMAND rm -f ${file_base}.aux ${file_base}.cp ${file_base}.fn ${file_base}.ky ${file_base}.log ${file_base}.pg ${file_base}.toc ${file_base}.tp ${file_base}.vr + DEPENDS ${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.pdf) + endif() +endforeach() + +######################################################################## + +if(BUILD_WEB_DOCS) + include(FindUnixCommands) + if(NOT BASH) + message(FATAL_ERROR "Could not find bash. Unable to build documentation.") + endif() + if(NOT MAN2HTML) + message(FATAL_ERROR "Could not find man2html. HTML version of man page cannot be built.") + endif() + + add_custom_command(OUTPUT ledger.1.html + COMMAND ${BASH} -c "man2html ledger.1 | tail -n+3 > ledger.1.html" + DEPENDS ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.html) +endif(BUILD_WEB_DOCS) + +######################################################################## + +add_custom_target(doc ALL DEPENDS ${ledger_doc_files}) + +######################################################################## + +include(GNUInstallDirs) + +if(CMAKE_INSTALL_MANDIR) + install(FILES ledger.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) +endif(CMAKE_INSTALL_MANDIR) + +if(CMAKE_INSTALL_DOCDIR) + foreach(file ${info_files}) + get_filename_component(file_base ${file} NAME_WE) + install(FILES ${file_base}.pdf + DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc OPTIONAL) + endforeach() +endif(CMAKE_INSTALL_DOCDIR) diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 64a271fa..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# quick doc-building makefile used by website -# requires: man2html, texinfo - -docs: ledger.1.html ledger.html ledger.pdf ledger3.html ledger3.pdf - -%.1.html: %.1 - -man2html $< | tail -n+3 >$@ - -%.html: %.texi - -makeinfo --force --html --no-split -o $@ $< - -%.pdf: %.texi - -texi2pdf -b -q $< - rm -f $*.aux $*.cp $*.fn $*.ky $*.log $*.pg $*.toc $*.tp $*.vr - -clean: - rm -rf ledger.1.html ledger.html ledger3.html ledger.pdf ledger3.pdf From dd105fecd79d1c7e6fb3e22ace19b1359dd7de3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= Date: Mon, 14 Jan 2013 22:38:30 +0100 Subject: [PATCH 5/6] fix issue for separate build dir --- doc/CMakeLists.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b50c8696..a817c151 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -14,8 +14,8 @@ foreach(file ${info_files}) endif() add_custom_command(OUTPUT ${file_base}.html - COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${file} - DEPENDS ${file} + COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.html) endif(BUILD_WEB_DOCS) @@ -23,11 +23,9 @@ foreach(file ${info_files}) if(NOT TEXI2PDF) mesage(WARNING "Could not find texi2pdf. PDF version of documentation will not be built.") else() - get_filename_component(file_base ${file} NAME_WE) add_custom_command(OUTPUT ${file_base}.pdf - COMMAND texi2pdf -b -q ${file} - COMMAND rm -f ${file_base}.aux ${file_base}.cp ${file_base}.fn ${file_base}.ky ${file_base}.log ${file_base}.pg ${file_base}.toc ${file_base}.tp ${file_base}.vr - DEPENDS ${file} + COMMAND texi2pdf -b -q --tidy -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.pdf) endif() @@ -45,8 +43,8 @@ if(BUILD_WEB_DOCS) endif() add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "man2html ledger.1 | tail -n+3 > ledger.1.html" - DEPENDS ledger.1 + COMMAND ${BASH} -c "man2html $<1:CMAKE_CURRENT_SOURCE_DIR>/ledger.1 | tail -n+3 > ledger.1.html" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) endif(BUILD_WEB_DOCS) @@ -60,14 +58,14 @@ add_custom_target(doc ALL DEPENDS ${ledger_doc_files}) include(GNUInstallDirs) if(CMAKE_INSTALL_MANDIR) - install(FILES ledger.1 + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) endif(CMAKE_INSTALL_MANDIR) if(CMAKE_INSTALL_DOCDIR) foreach(file ${info_files}) get_filename_component(file_base ${file} NAME_WE) - install(FILES ${file_base}.pdf + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file_base}.pdf DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc OPTIONAL) endforeach() endif(CMAKE_INSTALL_DOCDIR) From b13f0c33c3c9633ef370633817e35bb35c399b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johann=20Kl=C3=A4hn?= Date: Mon, 14 Jan 2013 22:24:56 +0100 Subject: [PATCH 6/6] repair doxygen support --- CMakeLists.txt | 4 +--- doc/CMakeLists.txt | 18 ++++++++++++++++++ doc/{Doxyfile => Doxyfile.in} | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) rename doc/{Doxyfile => Doxyfile.in} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 132d7c47..f18df69a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,9 +276,7 @@ elseif(CMAKE_CXX_COMPILER MATCHES "g\\+\\+") endif() add_subdirectory(src) -if(BUILD_DOCS) - add_subdirectory(doc) -endif() +add_subdirectory(doc) if(BUILD_EMACSLISP) add_subdirectory(lisp) endif() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index a817c151..54c58737 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,3 +1,21 @@ +if (USE_DOXYGEN) + find_package(Doxygen) + if(NOT DOXYGEN_FOUND) + message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.") + endif() + + configure_file(Doxyfile.in Doxyfile @ONLY) + add_custom_target(doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile + SOURCES Doxyfile) +endif(USE_DOXYGEN) + +######################################################################## + +if(NOT BUILD_DOCS) + return() +endif() + set(info_files ledger.texi ledger3.texi) find_program(MAKEINFO makeinfo) diff --git a/doc/Doxyfile b/doc/Doxyfile.in similarity index 99% rename from doc/Doxyfile rename to doc/Doxyfile.in index d59d3f82..734eb8df 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NUMBER = 3.0 # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = %builddir%/doc +OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@ # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -124,7 +124,7 @@ FULL_PATH_NAMES = NO # If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = %srcdir%/src/ +STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/src/ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells @@ -564,7 +564,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src +INPUT = @PROJECT_SOURCE_DIR@/src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is