Commit Graph

12 Commits

Author SHA1 Message Date
Craig
04aab7cea3 Correctly parse decimals between 0 and -1.
The negative sign was being lost because stoll("-0") is 0.
Also permits parsing decimals between -1 and 1 without the leading 0.
2019-08-25 15:50:29 -07:00
Adrian Panella
f905467a44 [numeric] Fix constructor from strings in range (0 ,1)
Fix error that caused strings in the form 0.nnn to be
converted to negative numerics.
2019-05-13 23:05:11 -05:00
John Ralls
87533fe4bc Catch std::underflow_error as well as std::overflow_error.
Any operation that can overflow will throw an underflow if it's a
negative number. The C interface needs to catch both to prevent
unhandled exception crashes,
2018-09-21 14:28:49 -07:00
John Ralls
867fdce4e4 Gcc-4.8 doesn't have std::codecvt.
Use boost::locale::conv::utf_to_utf instead.
2018-03-09 16:28:00 -08:00
John Ralls
c3180ab374 Operator << fix. 2018-03-09 13:07:29 -08:00
John Ralls
4be826055a Revert "Partial fix to exception crashes on Windows."
This reverts commit 4746054635.
a300384 is the correct fix for this problem.
2017-10-26 13:08:36 -07:00
John Ralls
4746054635 Partial fix to exception crashes on Windows.
There seems to be more than one problem that causes the exception handler ("catch") to
get lost on Windows:
* Throwing from a constructor called from a member function of another object of the same
class. That's fixed here for the GncNumeric string constructor, but there's at least one other
instance I'm still working on in GncNumeric::to_decimal.
* Hidden memory allocation in a stack-allocated object like std::string, std::istringstream,
or boost::smatch: The throw causes the object to go out of scope which calls its destructor
and in that case the catch reference is either lost or never compiled in.

This change ifdefs out the creation of detailed exception messages on Windows to avoid
the destruction of the std::istringstream and its attached std::string, creates a series of
helper functions to ensure that the boost::smatch is in a non-throwing scope, and puts the
computed values directly into the member variables instead of delegating the construction
to a temporary and then copying out the values. The last item is more correct anyway, as
C++ constructor delegation is supposed to happen in the member initialization part rather
than the function body.
With these changes the exceptions from the GncNumeric string constructor are handled
correctly.
2017-10-26 11:33:50 -07:00
Geert Janssens
1238b9d8cd Prevent gcc from searching config.h in the current directory
This will avoid a ninja-build from picking up a config.h generated by the autotools build
(in the root build directory). Picking up the wrong config.h may lead to all kinds of
subtle issues if the autotools run was done with different options than the cmake run.
2017-10-26 14:05:17 +02:00
Geert Janssens
444eb1c28e Improve gnc_numeric_boxed_copy_func based on discussion in PR#145
In essence
- guard against nullptr dereferencing
- free returned values
2017-10-23 23:05:49 +02:00
Mike Alexander
29a92431cb Fix sigfigs(n) rounding to work when the input is bigger tnan 10**n.
For example rounding 1234567/1 to 6 significant figures would fail.
2017-08-22 00:47:08 -04:00
Mike Alexander
57638161f2 Fix numerator overflow constructing GncNumeric from 96.16 2017-08-22 00:35:10 -04: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