This version is available for all supported platforms and distros
(CentOS can have a version via EPEL, which is required anyway)
Advantages:
- one cmake version for all platforms
- we can drop all conditions based on cmake version
In the Preferences/Accounting Period, there is an option to specify
absolute dates but the end date was being set to start of day instead
of end of day, changed this.
crash when involving foreign currency stocks.
Scheme's inexact->exact function just converts the floating-point
representation of a number into an exact rational (documented in the
API Reference, Simple Generic Data Types, Numerical data types, Exact
and Inexact Numbers), which isn't what we want.
We want the number converted to exact directly from the string and to do
that we have gnc-fq-helper preface it with #e.
And in Windows only with the value from the environment if there is one.
Calling it with "" in Windows ignores the environment and sets it to the
system settings.
Ensure that all includes of swig-runtime.h are *followed* by
including guile-mappings.h so that the defines masking
scm_to_utf8_string and scm_from_utf8_string are undone.
When you have multiple loggers enabled, the log file indentations are
partly based on logger name length and so you can have false
indentations which can cause confusion. This change gets the maximum
name logger length and uses this for all with a minimum default length
of 12 characters.
Caused by the introduction of caching used in gnc_pricedb_nth_price,
when prices were deleted, the cached list was never updated and so the
tree model could reference a deleted price and hence crash. This also
affected adding prices as the new prices would not show due to the
cache not being updated. To fix this a function was added to reset the
cache when prices are updated from the model.
This reverts commit aa53c23239, reversing
changes made to 3c946a8449, because
aa53c23 was based on master and so undid other changes made to maint
since the last merge-to-master.
copied function created by Mark Weaver, core guile dev and augmented
to selectively replace substring indices
This is a much more efficient function than the previous
gnc:substring-replace which will constantly split lists using
substring, and create new strings using string-append.
It also does tail call optimization properly, unlike the previous
functions.
https://lists.gnu.org/archive/html/guile-devel/2013-09/msg00029.html -
original
"Here's an implementation that does this benchmark about 80 times
faster on my machine: (20 milliseconds vs 1.69 seconds)
--8<---------------cut here---------------start------------->8---
(define* (string-replace-substring s substr replacement
#:optional
(start 0)
(end (string-length s)))
(let ((substr-length (string-length substr)))
(if (zero? substr-length)
(error "string-replace-substring: empty substr")
(let loop ((start start)
(pieces (list (substring s 0 start))))
(let ((idx (string-contains s substr start end)))
(if idx
(loop (+ idx substr-length)
(cons* replacement
(substring s start idx)
pieces))
(string-concatenate-reverse (cons (substring s start)
pieces))))))))
--8<---------------cut here---------------end--------------->8---
The reason this is so much faster is because it avoids needless
generation of intermediate strings."
Add tests for libgnucash/scm/utilities.scm functions
- tests for list<->vec
- tests for gnc:substring-replace
- tests for gnc:substring-replace-from-to
The latter confirms that the comment before the function definition
is *incorrect* - it describes that substring-replace-from-to will
start from the 2nd substring for the first substitution, and
performs 2 substitutions. However the comment illustrates only 1
substitution. The test suite performs the test according to code
behaviour, rather than the comment. This issue is moot in practice
because the end-after is always called with negative in the code
base.
original comment:
;; gnc:substring-replace-from-to
;; same as gnc:substring-replace extended by:
;; start: from which occurrence onwards the replacement shall start
;; end-after: max. number times the replacement should executed
;;
;; Example: (gnc:substring-replace-from-to "foobarfoobarfoobar" "bar" "xyz" 2 2)
;; returns "foobarfooxyzfoobar".
When testing for a MS Windows path which has a ":", a gvfs path with the
format '/run/user/1000/gvfs/smb-share:server=192.168.1.11,share=public/
test-xml-file.gnucash' is recognised as a Windows path. To avoid this
expand the test to ":/" and also ":\"
On Windows boost::filesystem::path's string() produces a string
that goes out of scope with the function in which it's called, so
returning its c_str() ptr yields freed memory, usually full of garbage.
This has an interesting side effect in gnc-file.c's check_file_path():
Since the memory is freed, g_path_get_dirname() reuses it after an
iteration or two, writing its result into the same address. The
following strcmp naturally returns 0 because it's comparing two
instances of the same ptr, so check_file_path falsely reports that
the proposed save path is in GNC_USERDATA_DIR.
Windows file uri's can be of the form 'file:///N:/bob.txt' so change
the gnc_uri_get_components to remove a left over '/' at the start so
gnc_resolve_file_path gets the absolute path correctly. Also change
gnc_uri_create_uri to add an extra '/' for Windows file uri's.
Add function to create an absolute file path from a prefix path and a
relative one. If the prefix is null, then the root directory of the
current path is used.