2005-05-26  John Wiegley  <johnw@newartisans.com>

	* qif.cc (qif_parser_t::parse): Propogate commodity flags when
	parsing amounts from a QIF file.

	* amount.cc (amount_t::parse): Only set the SUFFIXED flag if there
	is actually a commodity symbol.

	* acprep: Separate out the arguments, to be more compatible.

	* walk.cc (sort_transactions::post_accumulated_xacts): Created
	this function so that interval_transactions has a way to post
	sorted xacts without calling flush().

	* textual.cc (clock_out_from_timelog): If a timelog file is left
	"open", clock out at the present time.

	* datetime.cc (first): Use std::localtime instead of std::gmtime.
	(increment): Use std::localtime instead of std::gmtime.

	* config.cc: Use std::localtime instead of std::gmtime.

2005-05-25  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-do-reconcile): If no output at all is
	generated by the "emacs" command, do not trigger a Lisp error.

	* textual.cc (parse_transaction): If an account name matches an
	alias definition, use the aliased account.
	(parse): Added an "!alias ALIAS = ACCOUNT" directive, to make it
	easier to manage long account names in a textual ledger file.

2005-05-12  John Wiegley  <johnw@newartisans.com>

	* datetime.cc (quick_parse_date): Add 1900 to now_year, to counter
	the subtraction that will occur in parse_date.

2005-04-15  John Wiegley  <johnw@newartisans.com>

	* datetime.cc (quick_parse_date): [1178218] Fixed date problem by
	avoiding an optimization that was being used before for the sake
	of the textual parser.

	* main.py: [1160291] Added missing colons.

	* config.cc (config_t): Corrected a value in the register format.
	(process_options): [1173733] Show all register entries, even those
	with null value, if -E is used.

	* format.cc (format): [1178223] Don't truncate to max_width in the
	case of outputting balances.

	* ledger.el, emacs.cc (write_entry): Added filename to Emacs
	output, in preperation for multi-file support.

2005-03-31  John Wiegley  <johnw@newartisans.com>

	* textual.cc (test): Sense of an #ifdef test was reversed somehow.

2005-03-08  John Wiegley  <johnw@newartisans.com>

	* config.cc (show_version): In the version page output all of the
	modules which support has been compiled in for.  This will make
	tracking down certain problems much quicker.

	* textual.h, textual.cc (test): Added a test for the presence of
	<?xml... in the input stream; if it is there, report an error
	based on whether XML support was actually compiled in or not.

2005-03-07  John Wiegley  <johnw@newartisans.com>

	* amount.cc (value): Use `std::map<>::lower_bound' to search for
	the nearest price item in a commodity's history list.  This is
	much more efficient than doing a reverse linear search.
	(parse_conversion): When defining a commodity conversion, always
	mark the larger unit as having no market value (the market price
	is determined by looking up the base commodity and then
	multiplying).

2005-02-19  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-auto-reconcile): Added a note to the
	auto-reconcile prompt, to remind people to use a negative amount
	for a liability.  Added missing `require' for eshell.

	* textual.cc (parse_entry): Parse the pending flag if a ! is used
	in place of *.

	* reconcile.h, reconcile.cc, config.cc, main.cc: Removed the
	--reconcilable option, since the pending flag is now being used.

	* ledger.el: Made several changes to the behavior of the
	reconciler: 1) Hitting space marks entries as pending; use C-c C-c
	when you have achieved the proper cleared balance, and all of the
	"pending" entries will be marked clear and saved; 2) Using C-x C-s
	in the ledger data buffer will refresh the currently open
	reconcile buffer; 3) C-l in the reconcile buffer will now refresh
	the view (in case you wish to refresh changes made in the ledger
	data buffer without saving that buffer).

	* emacs.cc (write_entry): If an entry is marked pending, output
	the `pending' symbol in the Emacs output.

2005-02-17  John Wiegley  <johnw@newartisans.com>

	* textual.cc (parse): Updated the "D" command to take a regular
	amount, from which the default flags and precision for its
	commodity are determined.

	* amount.cc (parse): A fix to the way commodity flags are applied
	to newly parsed commodities.  This was needing for an edge-case
	involving commodities that first appears as part of the cost (@
	SPEC) of a transaction.

	* main.cc (main): Do not sync I/O streams with stdio, since I do
	not use stdin, stdout or stderr.

2005-02-16  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-add-entry): Use Eshell to do argument parsing,
	since that's the easiest way to tell if '1 "2 3" 4' contains three
	arguments or four.

	* option.cc (process_environment): If the environment tag is
	NULL (which is really should never be), then don't use it.

	* main.cc (parse_and_report): If XML support was not compiled in,
	generate an error when the "xml" command is used.

2005-02-15  John Wiegley  <johnw@newartisans.com>

	* xml.h (format_xml_entries): Ledger's XML beginning tag now
	includes a version attribute.

	* main.py: Enabled the --reconcile option, since everything it
	relies on is now exposed through python.

	* ledger.el (ledger-auto-reconcile): If auto-reconciling fails,
	report an error in the minibuffer.

	* format.h, format.cc, xml.h, xml.cc: Moved `format_xml_entries'
	to xml.cc.

	* datetime.cc (export_datetime): Exposed "parse_date" function.

	* format.h (format_xml_entries): Moved the stream finalization to
	flush(), where it belongs.

	* main.py: Added code for using reconcile_transactions, but it
	still need som eporting.

	* main.cc (chain_xact_handlers): Chain the reconcile_transactions
	handler the same way as everything else.

	* config.cc (export_config): Added export entries for the
	reconcile_balance and reconcile_date options.

	* py_eval.cc (initialize_ledger_for_python): Added initialization
	call for the reconciler.

	* walk.h (transaction_xdata_t): Added a `ptr' void *, for general
	use.  The reconcile_transactions handler uses it.

	* reconcile.h, reconcile.cc: Converted the reconciler into an
	item_handler, so that it interacts with the core the same way as
	everything else.

	* py_eval.cc: Added calls for `export_emacs', to expose
	FormatEmacsTransactions.

	* main.py: Changed the script to rely upon the C++ output
	formatters, rather than the Python versions of before.

	* format.h: Added pystream_handler_wrap class, which wraps an
	item_handler taking a std::ostream so that it can take a PyObject*
	instead.  Relies on pyfstream.h, which allows Python file objects
	to be treating as I/O streams.

	* format.cc (truncated): Added "style" argument, so that at least
	Python users can choose which output style they want (truncation
	at beginning, middle or end of the string).
	(export_format): Expose following handlers to Python:
	FormatTransactions, FormatEntries, FormatXmlEntries,
	FormatAccount, FormatEquity.

	* emacs.cc: Expose FormatEmacsTransactions to Python.

2005-02-14  John Wiegley  <johnw@newartisans.com>

	* walk.cc (truncate_entries::flush): Fix so that --head and --tail
	can be used at the same time.
	(export_walk): Added TruncateEntries for Python.

	* setup.py: Added OFX library support.

	* main.py: Updated the Python driver to mostly match the C++
	driver again.

	* main.cc (parse_and_report): Rearranged some code for
	efficiency's sake.

	* configure.in: Added -lpython$PYTHON_VERSION to the LIBS line.
	The way things were, the boost test would always fail.

	* config.cc (export_config): Added missing config members for
	Python.

	* Makefile.am (HAVE_LIBOFX_VALUE): Added LIBOFX support to the
	Python build.

	* walk.h, walk.cc, main.cc: Changed truncate_entries so that
	--head and --tail can be used at the same time.

	* config.h, config.cc, main.cc: Added support for "--pager
	PROGRAM".  A likely way to define it in your login file would be:
	"export LEDGER_PAGER=$PAGER".

	* walk.h, walk.cc: Added the new transaction handler
	`truncate_entries' which can be used to trim a number of entries
	from the beginning or end of a transction stream.
	(push_to_transactions_list): Removed unneeded "handler" argument.

	* main.cc (chain_xact_handlers): Added head or tail handlers,
	using the transaction handler `truncate_entries'.

	* xml.cc (test), gnucash.cc (test): Check for <?xml only, not the
	full version string.

	* format.cc (truncated): Simplified this method, and added schemes
	for truncating at the beginning and middle of a string (neither of
	which seems better than truncating at the front).
	(output_xml_string): Change xml_string to output_xml_string, for
	simplicity's sake.  Also, < and > are now output as &lt; and &gt;.
	(format_last_entry): Use output_xml_string for the account name as
	well as the code, payee and note.

	* config.h, config.cc: Added new --head and --tail options, which
	control how many *entries* are displayed in a register report or
	print report.  The UNIX commands "head" and "tail" can be used to
	control how many transactions are displayed.

2005-02-13  John Wiegley  <johnw@newartisans.com>

	* valexpr.h, valexpr.cc: Added the capability for value expression
	regexps targetted at specific parts of a transaction: c// (entry
	code), p// (payee), w// (short account name), W// (full account
	name), and e// (transaction note).

	* util.h: Added a fix for FreeBSD, so that Ledger can compile
	there.

	* ledger.el (ledger-reconcile-save): Call `save-buffer', instead
	of trying to write the file directly.

	* textual.cc (parse): When an entry does not balance, print the
	entry so the user can see what Ledger saw.

	* format.cc (format_equity::flush): If the equity balance uses
	multiple commodities, then multiple "Equity" lines need to be
	printed, one for each.
	(format_equity::operator()): Same, but for individual accounts.

2005-02-11  John Wiegley  <johnw@newartisans.com>

	* reconcile.cc (reconcile_transactions): Added an error message,
	to make it easier to know when the commodity is wrong to
	--reconcile (such as using $ instead of \$ in the UNIX shell).

2005-02-09  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-do-reconcile): Fixed a marker problem that was
	causing entries to not be reconciled.

	* amount.cc, amount.h, balance.cc, binary.cc, configure.in,
	datetime.cc, format.cc, journal.h, mask.cc, quotes.cc, textual.cc,
	util.h: Changes to support building with gcc 2.95.

2005-02-09  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-reconcile): Added back the feature that C-u
	C-c C-r will assume that an auto-reconcile is to be attempted.

	* walk.h (push_to_transactions_list): Added a new transaction
	handler, which adds received transactions to a transctions_list
	container.

	* walk.cc (clear_transactions_xdata): Clear the transaction xdata
	pointers once they have been freed.
	(clear_accounts_xdata): Clear the account xdata pointers once they
	have been freed.

	* ledger.el: Updated the Emacs interface to use the ledger
	executable more fully (it doesn't do its own parsing anymore, for
	example).  Many things should be faster, and things should work
	for users of earlier Emacsen.

	* format.cc (format_transactions::operator): Corrected a bad
	memory access.

	* config.h, config.cc: Added new options --reconcile,
	--reconcilable and --reconcile-date.

	* Makefile.am, ledger.h, emacs.h, emacs.cc, main.cc: Added an
	Emacs formatter, accessible with the new "emacs" command.

	* reconcile.h, reconcile.cc (search_for_balance): Sped things up
	by a factor of ten.  Still won't help for uncleared lists >~27
	items (2^27), but it helps.

2005-02-09  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-reconcile): If a prefix argument is passed to
	C-c C-r (ledger-reconcile), then it will attempt to use the
	auto-reconciler to pre-mark the uncleared transactions.  Note that
	if it fails, and the uncleared list is long, it might appear to
	hang.  It's far from fool-proof, but when it does work, it's like
	magic!

	* reconcile.cc (reconcile_account): The reconciler now works,
	though it may take a very long time if there are a large number of
	unreconciled entries, and if the search is bound to fail.  This is
	a perfect case where a GUI could try in the background, and just
	abort the search if the user gets impatient.

	* amount.cc (AMOUNT_CMP_AMOUNT): Fixed a very serious error in
	basic amount math, when lhs is zero.

	* main.cc (parse_and_report): Added "pricesdb" command, which is
	much like "prices", but output data in the same format as a prices
	database.

	* config.h, config.cc: Added pricesdb_format, for the "pricesdb"
	command.

	* ofx.cc, ofx.h, main.cc: Added preliminary support for OFX, using
	libofx.  Needs much real-world testing.

2005-02-08  John Wiegley  <johnw@newartisans.com>

	* ledger.el (ledger-update-balance-display): Fix to the reconcile
	function, for the case when there are spaces in an account name.

	* walk.cc (related_transactions::flush): Handle the case where an
	auto_entry or period_entry passes through the related_transactions
	handler.

	* reconcile.h, reconcile.cc, textual.h, textual.cc,
	main.cc (parse_and_report): Added new "reconcile" and "output"
	commands.  Likely not to be documented, as these are intended
	primarily for future GUI development.

	* ledger.h: #include'd reconcile.h.

	* format.h, format.cc (parse_elements): Added %S, %B and %E
	elements, for printing the source path, beginning and ending
	positions of an entry.

	* config.h, config.cc: Added write_hdr_format and
	write_xact_format, which are used by the "output" command.

	* journal.h, journal.cc, binary.cc, textual.cc: Added support for
	each entry to remember: the file it came from, and the beginning
	and ending character positions of that entry within the file.
	This makes it possible to reproduce the input exactly, with only
	the changed entries updated.
	(read_binary_journal, write_binary_journal): All accounts and
	entries now know which journal they are a member of, and have a
	`journal' member pointing to it.

	* configure.in: Check for `realpath' function, used by the new
	"output" command.  If it's not available, filename matching must
	be exact.

	* Makefile.am, reconcile.h, reconcile.cc: Added framework for an
	auto-reconcile command.  Useful primarily for GUI developers.

2005-02-02  John Wiegley  <johnw@newartisans.com>

	* config.cc (parse_ledger_data): Don't auto-create equivalencies
	for bytes, kilobytes, etc., since people may want to use "b" for
	something else.

	* xml.cc (endElement): Handle the <tr:virtual> and <tr:generated>
	tags, which were being ignored.
	(parse): Corrected error reporting when it is a Ledger error.

	* gnucash.cc (parse): Corrected error reporting lines when it is a
	Ledger error.

	* format.cc (format_last_entry): Output tr:cost as an amount, not
	as an amount string.

2005-01-31  John Wiegley  <johnw@newartisans.com>

	* configure.in: Fixed check for libxmlparse.

	* main.cc (parse_and_report): Removed "files" argument.

	* journal.h (class journal_t): Added `price_db' member, which is
	the price database used to read in historical prices for a given
	journal.

	* journal.cc (export_journal): Added `price_db' property to
	ledger.Journal type.

	* gnucash.cc (convert_number): If the denominator is zero, report
	an error instead of crashing.

	* config.cc (parse_ledger_data): Set journal->price_db if a price
	database is successfully read in.

	* binary.h (write_binary_journal): Removed unused "files"
	parameter.

	* binary.cc: Updated binary cache version, for good measure.
	(read_binary_journal): Read in the price_db, in order to throw
	away the cache if it has changed.
	(write_binary_journal): Removed unused "files" parameter.  Changed
	logic for writing out files list.  Also, write out the prices
	database that was used.
	(py_write_binary_journal): Removed "files" argument.

	* amount.cc (operator/): Added a more complete divide-by-zero
	check.

	* configure.in: Changed all of the library tests into actual
	compile/link tests, to ensure that the compilation environment is
	what it needs to be.  Also, added a test to make sure the C++
	compiler has some basic features, since gcc2.95 will not work.

	* balance.cc, walk.cc: Added #include <alogrithm>.

2005-01-28  John Wiegley  <johnw@newartisans.com>

	* ledger.el: Changed the reconciling feature so that it doesn't
	need to ask for the "number of days".

2005-01-27  John Wiegley  <johnw@newartisans.com>

	* format.cc (format): Pay attention to the max_width setting for
	each formatting element.  This means that "%.20N" can no longer
	exceed 20 characters of width.

2005-01-14  John Wiegley  <johnw@newartisans.com>

	* config.cc: Set cache_file to "<none>" if --no-cache is used.

	* main.cc (parse_and_report): If cache_file is "<none>", blank it
	out.  This steps around the logic that sets the default name.

	* configure.in: Check for libxmlparse.a using a compile test
	instead of a link test.  This is much less ambiguous.

	* config.cc (option_full_help): Added docs for --no-cache.
	(option_help): Added docs for --no-cache.
	Added --no-cache option.

	* Makefile.am (libledger_a_CXXFLAGS): Define -DHAVE_XMLPARSE=1 if
	the configure file did.

2005-01-14  John Wiegley  <johnw@newartisans.com>

	* textual.cc (parse): Added "D" directive to ledger files, which
	allows the user to specify which commodity is used for the default
	when none is specified or calculated by the "entry" command.

	* derive.cc (derive_new_entry): Simplified some code.
	(derive_new_entry): If no commodity was specified for an amount,
	and none was figured out from previous transactions, then use the
	default commodity (which is specified using "D <SYMBOL>" in the
	ledger file).

	* binary.cc: Updated binary file version.
	(read_binary_journal): Read in the default commodity.
	(write_binary_journal): Write out the default commodity.

	* amount.h (class commodity_t): Added
	commodity_t::default_commodity.

	* amount.cc: Added commodity_t::default_commodity.
	Initialize the same.

	* ledger.el: Added code for setting the default year/month given
	in the prompt to C-c C-a.  This is helpful for people with lots of
	receipts in a past month.

2005-01-06  John Wiegley  <johnw@newartisans.com>

	* binary.cc (read_binary_amount): If the commodity ident is zero,
	it is an explicit reference to commodity_t::null_commodity.
	(write_binary_journal): Initialize account_index and
	commodity_index to zero before writing.
	(write_binary_journal): Set the "ident" field of the
	null_commodity to 0, so that read_binary_amount can recognize it.

2004-12-07  John Wiegley  <johnw@newartisans.com>

	* binary.cc: Increased binary number, so that all caches are
	invalidated, just in case the fix below might affect things.

	* textual.cc (parse_transaction): Remove trailing whitespace from
	account names.  This can happen if a transaction line has no
	amount, and a single space after the account name.

2004-11-15  John Wiegley  <johnw@newartisans.com>

	* scripts/bal, scripts/bal-huquq: Fixed an incorrect value
	expression.

	* quotes.cc: If popen returns NULL, it should indicate failure.

	* amount.cc (value): Fixed a bug which caused commodities without
	a history never to be queried from the Net.

2004-11-11  John Wiegley  <johnw@newartisans.com>

	* mask.cc: Added a missing #include.

2004-10-30  John Wiegley  <johnw@newartisans.com>

	* config.cc (regexps_to_predicate): Don't use fancy account names
	regexps if any special regexp characters were seen.

	* amount.cc (operator<<): Check for outputting zero; it should
	always be reported as just "0".

2004-10-19  John Wiegley  <johnw@newartisans.com>

	* walk.cc (forecast_transactions::add_transaction): Set the
	initial time period to the period following the present moment.

	* textual.cc: Fixed problems that were causing blank lines to fail
	to parse.

2004-10-18  John Wiegley  <johnw@newartisans.com>

	* config.cc (parse_ledger_data): Don't call the XML parser unless
	one was passed in.

	* walk.cc (forecast_transactions::flush): Corrected an infinite
	loop that occurred when no forecast transactions were applicable.
	(forecast_transactions::flush): Fixed another infinite loop bug.

2004-10-17  John Wiegley  <johnw@newartisans.com>

	* gnucash.cc (parse): Fixed a long-standing problem that cause a
	double delete in the gnucash parser (at the end of ledger's run).

2004-10-15  John Wiegley  <johnw@newartisans.com>

	* walk.cc (changed_value_transactions::operator()): Fixed a
	problem with calculation of changed value transactions when the
	transaction has a specialized date (which occurs regularly when
	subtotaling (-s) is in use).

	* valexpr.cc (compute): Fixed a rather serious problem with
	transaction cost and composite amounts.

	* main.cc (chain_formatters): There are many formatters which now
	participate even in the balance report.  This lets "ledger -MA
	bal food" work as expected.

	* walk.cc (subtotal_transactions::operator()): Removed some code
	that was prevented "ledger -MA bal food" from working.  I cannot
	figure out what it was doing there...

	* amount.cc (AMOUNT_CMP_AMOUNT): fixed a rather serious problems
	with amounts and comparison with zero.

2004-10-14  John Wiegley  <johnw@newartisans.com>

	* journal.cc (extend_entry): If $account is used in an automated
	entry, it refers to the account of whatever transaction matched
	the value expression.

	* Revised the way automated and period entries are handled
	internally, so as to be more coherent with regular entries.

2004-10-14  John Wiegley  <johnw@newartisans.com>

	* config.cc (process_options): Added some debugging code.

	* journal.cc (valid): Fixes.

	* gnucash.cc: Many bug fixes.

	* format.cc (print_entry): Added this method for displaying
	entries to the user (typically after an error message).

	* amount.h (class amount_t): Added `null' method, for
	distingushing "no amount specified" from zero.

2004-10-13  John Wiegley  <johnw@newartisans.com>

	* Added support for parsing the output of the "xml" report.

	* config.cc: Allow "-" as the input filename again.

2004-10-11  John Wiegley  <johnw@newartisans.com>

	* Added an "xml" command, for generating report data in XML.

2004-10-09  John Wiegley  <johnw@newartisans.com>

	* Added support for budgeting, using --budget, --unbudgeted, and
	--only-unbudgeted.  Needs more thorough testing.

	* walk.cc (forecast_transactions): Invert the meaning of the
	transactions that are read in, so that the user can specify them
	in a more intuitive fashion.

	* walk.h (subtotal_transactions): Added an assert in the copy
	constructor, to ensure that it never fires.  However, Boost.Python
	does need to reference the function for some reason.

	* walk.cc (by_payee_transactions): Added a destructor so that the
	child `subtotal_transactions' objects are allocated with new.
	Otherwise, the copy constructor for `subtotal_transactions' gets
	invoked, and it does not do the right thing.

	* main.cc (chain_formatters): Corrected an error message.
	(parse_and_report): Don't use the binary cache if a pricing file
	is explicitly given.

	* util.h (READ_INTO): Stop reading if \n or -1 is read.  This
	finds errors closer to their occurence.

	* textual.cc (parse): Added an error check if the commodity does
	not parse in a historical price entry.
