Commit Graph

40 Commits

Author SHA1 Message Date
John Ralls
529a6cb067 Call setlocale(LC_ALL, "") exactly once.
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.
2019-04-30 14:56:43 -07:00
Christopher Lam
4d529c02cd [libgnucash-scm-utilities] remove unneeded section in CMakeLists 2019-04-27 17:04:02 +08:00
Christopher Lam
0cf49f1244 [test-libgnucash-scm-utilities] amend info to explain comment fix 2019-04-25 11:20:34 +08:00
Christopher Lam
7d15e6e4e7 [utilities] create general string-replace-substring
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."
2019-04-25 10:52:45 +08:00
John Ralls
a12bbaccd3 Create CMakeLists.txt in libgnucash/scm/test.
Amended by chris to add a working scm/test/CMakeLists.txt.
2019-04-25 10:51:20 +08:00
Christopher Lam
92a920c4e0 [test-libgnucash-scm-utilities] renamed from test-utilities.scm 2019-04-25 10:51:20 +08:00
Christopher Lam
d9623b0ad1 [test-utilities] initial commit
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".
2019-04-23 18:52:36 +08:00
Frank H. Ellenberger
833decc03e I18N: Review of price-quotes.scm
Mark "Found FQ version" translatable, but remove translation from log
file entries.
2019-04-08 17:37:33 +02:00
Christopher Lam
d64fb74b9e [utilities] add supporting functions for guile-json use
converts nested-list to nested-vector, and vice-versa
2019-04-04 19:44:00 +08:00
Mike Alexander
d4af5244d0 Bug 797106: Do a better job of converting decimal prices to rationals.
Use the Scheme rationalize method to convert the decimal numbers
from Finance::Quote to ratinal numbers.  This avoids rediculous
precision like 8515625000000001/3906250000000000 for 2.18.
2019-02-17 11:58:15 +08:00
Christopher Lam
a731c9ed9a [gnome-utils] add gnc:gui-warn/error/msg global functions
gnc:gui-[warn|error|msg] are new global functions.

By default they mirror gnc:warn/error/msg. However then gnome is
available, they will display appropriate warn/error/info dialog in
addition to outputting to console.
2019-02-17 11:24:57 +08:00
Mike Alexander
62a4e73f7f Don't use GNC-DENOM-SIGFIGS when converting prices
to gnc-numeric values.
2019-01-28 19:25:50 -05:00
Potuz
e3e1464a01 Bug 794617 - Can't compile with -DWITH_GNUCASH=NO due to scm-gnome-utils
Pricedb.go doesn't need gnc-gnome-utils and we don't need WebKit or
gwenhywfar-gtk3 if we have no GUI.
2018-06-07 14:17:49 -07:00
Christopher Lam
dda6730c44 utilities.scm: centralize and modernize addto!
(define-macro) is discouraged in most scheme forms. Change
to (define-syntax), and centralize common macro to utilities.scm
2018-05-10 13:19:03 +08:00
Geert Janssens
a9f35ed7ae Lowercase cmake commands
A huge bikeshed fest but it distracted me enough to do it anyway.
2018-05-03 23:18:15 +02:00
John Ralls
36ad5064e4 Move gnc:substring-replace-from-to back to utilities.scm
It's used in report.scm as well as qif-imp.
2018-02-19 13:27:44 -08:00
John Ralls
5929bb3bf8 Move string.scm to qif-imp, the only place it's used. 2018-02-19 11:25:08 -08:00
John Ralls
4ad2359872 Remove unused functions from utilities.scm
moving safe-strcmp to aging.scm, it's sole use.
2018-02-19 11:10:14 -08:00
John Ralls
a5f46a5e45 More Scheme dependency additions. 2018-02-18 15:59:00 -08:00
John Ralls
48bdab38d4 Replace sprintf with Guile's built-in format. 2018-02-17 15:24:44 -08:00
Geert Janssens
07c3162a73 Fix a few leftovers from work on main.scm
- Load proper file in gnucash-bin.c
- Load string.scm (now in gnucash subdir) to make reports and qif-import work again
2018-02-17 21:09:07 +01:00
Geert Janssens
de4b72dc11 Drop install rule for previously removed (scm) config file 2018-02-17 20:09:36 +01:00
John Ralls
cd8f2b7c7e Rename libgnucash/scm/main.scm to utilities.scm
Because it hasn't been "main" since GnuCash became a C program.
2018-02-16 15:52:19 -08:00
John Ralls
32f6958ebb We're done modularizing. About 16 years ago. 2018-02-16 15:41:47 -08:00
John Ralls
8b0d9425e9 Remove some obsolete and unused Scheme files. 2018-02-16 15:37:46 -08:00
Geert Janssens
59fb8efaf9 Merge branch 'maint' into unstable 2018-02-02 18:57:24 +01:00
Geert Janssens
ec213360f3 Review which built files are really needed in the dist tarball
Several were only there because they used to be generated via autogen.sh
and hence had to be included because autogen.sh was not supposed to be run
in a tarball based build.
A few others aren't clear so I have left them in for now:
- gnucash.1 (man page)
- gnucash-design.info (because it's unclear what we want to do with that one)

These files should clearly be in the tarball:
- gnucash.pot -> for our translators
- ChangeLog -> can't be generated outside of a git repo
- gnc-vcs-info.h -> can't be generated outside of a git repo
- guile/python bindings -> to avoid a swig dependency when building from tarball
2018-01-29 19:46:44 +01:00
Geert Janssens
3dff4e5211 Fix make dist on a clean checkout
cmake with unix makefiles fails to resolve dist dependencies
added from COPY_FROM_BUILD if these dependencies aren't built yet.

This commit replaces the COPY_FROM_BUILD based logic with two new functions
'dist_add_configured' and 'dist_add_generated' to indicate which files should
be included in the dist tarball. The latter also adds a target level dependency
to the dist tarball custom command. Hence the former should
be used for files that get generated during a cmake run while the latter
should be used for files generated as the result of a 'make/ninja-build' run
(like files for which an add_custom_command rule exists).

Note: this commit also temporarily disables the dist target when building
from a tarball (and hence it won't be tested in distcheck either). This
will be handled in a future commit.
2018-01-29 19:46:44 +01:00
Geert Janssens
85bfbd8e82 Some minor cleanups after the autotools removal
This includes removal of the now unused make-gnucash-potfiles.in,
checking for CMakeLists.txt rather than Makefile.am in gnc-vcs-info,
upating the HACKING file,
and generally updating references to autotools.

I have kept "Makefile.*" exclude patterns in our CMakeLists.txt files
because they may still be lingering in the source directory from
previous autogen.sh runs. At some point these should probably be
removed as well still, together with the gitignore references to them.
2018-01-26 18:22:48 +01:00
Geert Janssens
52b0c06d30 Merge branch 'maint' into unstable
Conflicts:
- gnucash/gnome-utils/gnc-main-window.c
  I have chosen to ignore the changes pulled in from maint. The same change will
  be reimplemented in a followup commit.
- po/ru.po
  Same here. The translation conflicted too much and there's a
  translation update available for unstable I will pull in soon.
2018-01-25 10:24:53 +01:00
John Ralls
74ddb671e4 Merge Chris Lam's and Aaron Laws's branch 'time64-ftw' into unstable. 2018-01-20 12:40:32 -08:00
Rob Gowin
54ac7f23e0 Remove Autotools 2018-01-13 12:52:57 -06:00
Christopher Lam
fb2ed010e7 TP->T64: libgnucash/scm/price-quotes.scm 2018-01-08 22:56:49 +11:00
John Ralls
c0fd3b3165 Remove all references to the now-defunct Yahoo! quote retrieval
And make Alphavantage the default.
2018-01-02 10:43:49 -08:00
Geert Janssens
f11eab36d9 Replace GNC_CONFIGURE(2) with configure_file 2017-12-23 14:07:25 +01:00
Geert Janssens
3d910ad2b1 Drop guile 1.8 support
And with it all quirks we still had in the code to support that version.
2017-12-20 14:55:40 +01:00
Geert Janssens
a784dd5784 Add support for guile 2.2 2017-12-20 14:55:40 +01:00
John Ralls
5204100d53 Use GNUInstallDirs in CMake Builds
Provides correct file layout when building distribution tarballs.
Fixes Bugs 790840 and 790841.
2017-11-28 14:25:35 -08:00
John Ralls
f412795ef2 Remove extraneous parameters from GNC_ADD_SCHEME_TARGETS 2017-11-07 15:04:16 -08:00
Geert Janssens
83d14e1c1c Restructure the src directory
It is split into
- /libgnucash (for the non-gui bits)
- /gnucash (for the gui)
- /common (misc source files used by both)
- /bindings (currently only holds python bindings)

This is the first step in restructuring the code. It will need much
more fine tuning later on.
2017-08-10 18:45:00 +02:00