Commit Graph

19 Commits

Author SHA1 Message Date
Christopher Lam
a259ba4a3e [utilities] move gnc:html-string-sanitize to utilities.scm 2019-09-22 22:48:07 +08:00
Christopher Lam
24393b6f5c [utilities] fix comment use official gnu mail archive 2019-09-21 19:33:21 +08:00
Christopher Lam
0511ce723e [API] gnc:list-flatten flattens lists recursively
and is a schemey algorithm rather than a report algorithm, so, belongs
centrally.
2019-09-21 11:18:26 +08:00
Christopher Lam
70cb3a0b97 [utilities] compact sort-and-delete-duplicates
This is still readable IMHO. kons is the result constructor, and adds
item to result iff different from previous add.
2019-09-11 20:30:13 +08:00
Christopher Lam
bd9edbbbf6 Bug 797279 - Reports RTL do not support RTL - fix string
fix guile-2.0 string handling to prevent munging unicode in
report-titles etc. while loading/saving reports
2019-08-19 08:06:27 +08:00
Christopher Lam
273ae720cc [scm-utilities][API] add sort-and-delete-duplicates
this can be used instead of delete-duplicates when the list must also
be sorted.

the main reason for this function will be for the upcoming aging.scm
report which will use it heavily to slice APAR splits into owner list.
2019-07-20 21:10:08 +08:00
Christopher Lam
b3a4cd6277 completion redefine gnc:debug 2019-07-07 09:04:04 +08:00
Christopher Lam
42b6fb993b call strify only if debugging enabled 2019-07-06 11:15:18 +08:00
Christopher Lam
039b84871e [utilities] warn against using guile's strftime
strftime has been banished from code; warning for custom-reports

https://www.mail-archive.com/bug-guile@gnu.org/msg09778.html
2019-06-19 22:10:23 +08:00
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
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
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
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
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
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
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
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