summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-01-16 06:32:41 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-01-16 06:32:41 +0000
commit0dfaabcc545bc5b035756c3cd8365d946bf31529 (patch)
tree562f08d631add72621bba80848817bd54cb388f2 /Build/source/texk/web2c
parent300387da264e38757cf398d966fde495f7b9d4c1 (diff)
web2c/mplibdir: Sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@36070 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmathdecimal.w37
2 files changed, 24 insertions, 17 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index 2b91f635e35..f99a3f35b56 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,3 +1,7 @@
+2015-01-15 Luigi Scarso <luigi.scarso@gmail.com>
+ * mpmathdecimal.w: better management for static data in mpmathdecimal.w
+ (thanks to Philipp Gesang <phg@phi-gamma.net>)
+
2014-12-04 Luigi Scarso <luigi.scarso@gmail.com>
* mpost.w: fixed exit values to match metafont/old metapost behavior.
diff --git a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
index b530d0986d0..c65e2a5a420 100644
--- a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
+++ b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
@@ -358,7 +358,7 @@ static decNumber epsilon_decNumber;
static decNumber EL_GORDO_decNumber;
static decNumber **factorials = NULL;
static int last_cached_factorial = 0;
-
+static boolean initialized = false ;
@ @c
void * mp_initialize_decimal_math (MP mp) {
math_data *math = (math_data *)mp_xmalloc(mp,1,sizeof(math_data));
@@ -371,22 +371,25 @@ void * mp_initialize_decimal_math (MP mp) {
limitedset.emin = -999999;
set.digits = DECPRECISION_DEFAULT;
limitedset.digits = DECPRECISION_DEFAULT;
- decNumberFromInt32(&one, 1);
- decNumberFromInt32(&minusone, -1);
- decNumberFromInt32(&zero, 0);
- decNumberFromInt32(&two_decNumber, two);
- decNumberFromInt32(&three_decNumber, three);
- decNumberFromInt32(&four_decNumber, four);
- decNumberFromInt32(&fraction_multiplier_decNumber, fraction_multiplier);
- decNumberFromInt32(&fraction_one_decNumber, fraction_one);
- decNumberFromInt32(&fraction_one_plus_decNumber, (fraction_one+1));
- decNumberFromInt32(&angle_multiplier_decNumber, angle_multiplier);
- decNumberFromString(&PI_decNumber, PI_STRING, &set);
- decNumberFromString(&epsilon_decNumber, epsilon, &set);
- decNumberFromString(&EL_GORDO_decNumber, EL_GORDO, &set);
- factorials = (decNumber **)mp_xmalloc(mp,PRECALC_FACTORIALS_CACHESIZE,sizeof(decNumber *));
- factorials[0] = (decNumber *)mp_xmalloc(mp,1,sizeof(decNumber));
- decNumberCopy(factorials[0], &one);
+ if (!initialized) {
+ initialized = true ;
+ decNumberFromInt32(&one, 1);
+ decNumberFromInt32(&minusone, -1);
+ decNumberFromInt32(&zero, 0);
+ decNumberFromInt32(&two_decNumber, two);
+ decNumberFromInt32(&three_decNumber, three);
+ decNumberFromInt32(&four_decNumber, four);
+ decNumberFromInt32(&fraction_multiplier_decNumber, fraction_multiplier);
+ decNumberFromInt32(&fraction_one_decNumber, fraction_one);
+ decNumberFromInt32(&fraction_one_plus_decNumber, (fraction_one+1));
+ decNumberFromInt32(&angle_multiplier_decNumber, angle_multiplier);
+ decNumberFromString(&PI_decNumber, PI_STRING, &set);
+ decNumberFromString(&epsilon_decNumber, epsilon, &set);
+ decNumberFromString(&EL_GORDO_decNumber, EL_GORDO, &set);
+ factorials = (decNumber **)mp_xmalloc(mp,PRECALC_FACTORIALS_CACHESIZE,sizeof(decNumber *));
+ factorials[0] = (decNumber *)mp_xmalloc(mp,1,sizeof(decNumber));
+ decNumberCopy(factorials[0], &one);
+ }
/* alloc */
math->allocate = mp_new_number;