summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w6
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmathdecimal.w77
-rw-r--r--Build/source/texk/web2c/mplibdir/pngout.w35
-rw-r--r--Build/source/texk/web2c/mplibdir/psout.w5
-rw-r--r--Build/source/texk/web2c/mplibdir/svgout.w24
6 files changed, 82 insertions, 69 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index 904c875a335..9a164988904 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,3 +1,7 @@
+2014-04-09 Taco Hoekwater <taco@luatex.org>
+
+ Import metapost 1.901
+
2014-03-16 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* mp.w: An unimportant typo (1.890 --> 1.900).
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index 956d8b747fd..d9a0158e459 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -1,4 +1,4 @@
-% $Id: mp.w 1962 2014-03-11 13:18:08Z taco $
+% $Id: mp.w 1997 2014-04-09 07:36:31Z taco $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -73,12 +73,12 @@ undergoes any modifications, so that it will be clear which version of
@^extensions to \MP@>
@^system dependencies@>
-@d default_banner "This is MetaPost, Version 1.900" /* printed when \MP\ starts */
+@d default_banner "This is MetaPost, Version 1.901" /* printed when \MP\ starts */
@d true 1
@d false 0
@<Metapost version header@>=
-#define metapost_version "1.900"
+#define metapost_version "1.901"
@ The external library header for \MP\ is |mplib.h|. It contains a
few typedefs and the header defintions for the externally used
diff --git a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
index 89f1b7b7cea..f01dc4f39ce 100644
--- a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
+++ b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
@@ -127,8 +127,16 @@ static char * mp_decnumber_tostring (decNumber *n);
int decNumber_check (decNumber *dec, decContext *context)
{
int test = false;
+ if (context->status & DEC_Overflow) {
+ test = true;
+ context->status &= ~DEC_Overflow;
+ }
+ if (context->status & DEC_Underflow) {
+ test = true;
+ context->status &= ~DEC_Underflow;
+ }
if (context->status & DEC_Errors) {
- fprintf(stdout, "DEC_ERROR %x (%s)\n", context->status, decContextStatusToString(context));
+// fprintf(stdout, "DEC_ERROR %x (%s)\n", context->status, decContextStatusToString(context));
test = true;
decNumberZero(dec);
}
@@ -136,14 +144,12 @@ int decNumber_check (decNumber *dec, decContext *context)
if (decNumberIsSpecial(dec)) {
test = true;
if (decNumberIsInfinite(dec)) {
- fprintf(stdout, "INF\n");
if (decNumberIsNegative(dec)) {
decNumberCopyNegate(dec, &EL_GORDO_decNumber);
} else {
decNumberCopy(dec, &EL_GORDO_decNumber);
}
} else { // Nan
- fprintf(stdout, "NAN\n");
decNumberZero(dec);
}
}
@@ -330,11 +336,10 @@ void * mp_initialize_decimal_math (MP mp);
@d p_over_v_threshold 0x80000 /* TODO */
@d equation_threshold 0.001
@d tfm_warn_threshold 0.0625
-@d warning_limit pow(2.0,52.0) /* this is a large value that can just be expressed without loss of precision */
@d epsilon "1E-52"
@d epsilonf pow(2.0,-52.0)
-@d EL_GORDO "1E1000000" /* the largest value that \MP\ likes. */
-@d one_third_EL_GORDO (EL_GORDO/3.0)
+@d EL_GORDO "1E1000000" /* the largest value that \MP\ likes. */
+@d warning_limit "1E1000000" /* this is a large value that can just be expressed without loss of precision */
@d DECPRECISION_DEFAULT 34
@<Declarations@>=
@@ -398,7 +403,7 @@ void * mp_initialize_decimal_math (MP mp) {
mp_new_number (mp, &math->inf_t, mp_scaled_type);
decNumberCopy(math->inf_t.data.num, &EL_GORDO_decNumber);
mp_new_number (mp, &math->warning_limit_t, mp_scaled_type);
- decNumberFromDouble(math->warning_limit_t.data.num, warning_limit);
+ decNumberFromString(math->warning_limit_t.data.num, warning_limit, &set);
mp_new_number (mp, &math->one_third_inf_t, mp_scaled_type);
decNumberDivide(math->one_third_inf_t.data.num, math->inf_t.data.num, &three_decNumber, &set);
mp_new_number (mp, &math->unity_t, mp_scaled_type);
@@ -991,8 +996,9 @@ The definitions below are temporarily here
@<Declarations...@>=
static void mp_wrapup_numeric_token(MP mp, unsigned char *start, unsigned char *stop);
-@ Precision check is TODO
-@d too_precise(a) 0
+@
+@d too_precise(a) (a == (DEC_Inexact+DEC_Rounded))
+@d too_large(a) (a & DEC_Overflow)
@c
void mp_wrapup_numeric_token(MP mp, unsigned char *start, unsigned char *stop) {
decNumber result;
@@ -1005,30 +1011,35 @@ void mp_wrapup_numeric_token(MP mp, unsigned char *start, unsigned char *stop) {
free(buf);
if (set.status == 0) {
set_cur_mod(result);
- if (too_precise(l)) {
+ } else if (mp->scanner_status != tex_flushing) {
+ if (too_large(set.status)) {
+ const char *hlp[] = {"I could not handle this number specification",
+ "because it is out of range.",
+ NULL };
+ decNumber_check (&result, &set);
+ set_cur_mod(result);
+ mp_error (mp, "Enormous number has been reduced", hlp, false);
+ } else if (too_precise(set.status)) {
+ set_cur_mod(result);
if (decNumberIsPositive((decNumber *)internal_value (mp_warning_check).data.num) &&
(mp->scanner_status != tex_flushing)) {
char msg[256];
- const char *hlp[] = {"Continue and I'll try to cope",
- "with that big value; but it might be dangerous.",
+ const char *hlp[] = {"Continue and I'll round the value until it fits the current numberprecision",
"(Set warningcheck:=0 to suppress this message.)",
NULL };
- mp_snprintf (msg, 256, "Number is too large (%s)", mp_decimal_number_tostring(mp,mp->cur_mod_->data.n));
-@.Number is too large@>;
+ mp_snprintf (msg, 256, "Number is too precise (numberprecision = %d)", set.digits);
mp_error (mp, msg, hlp, true);
}
+ } else { // this also captures underflow
+ const char *hlp[] = {"I could not handle this number specification",
+ "Error:",
+ "",
+ NULL };
+ hlp[2] = decContextStatusToString(&set);
+ mp_error (mp, "Erroneous number specification changed to zero", hlp, false);
+ decNumberZero(&result);
+ set_cur_mod(result);
}
- } else if (mp->scanner_status != tex_flushing) {
- decNumber *el_gordo;
- const char *hlp[] = {"I could not handle this number specification",
- "probably because it is out of range. Error:",
- "",
- NULL };
- hlp[2] = strerror(errno);
- mp_error (mp, "Enormous number has been reduced.", hlp, false);
-@.Enormous number...@>;
- el_gordo = (decNumber *)(((math_data *)(mp->math))->inf_t.data.num);
- set_cur_mod(*el_gordo);
}
set_cur_cmd((mp_variable_type)mp_numeric_token);
}
@@ -1322,7 +1333,7 @@ static void mp_decimal_crossing_point (MP mp, mp_number *ret, mp_number aa, mp_n
decNumber a,b,c;
double d; /* recursive counter */
decNumber x, xx, x0, x1, x2; /* temporary registers for bisection */
- decNumber scratch;
+ decNumber scratch, scratch2;
decNumberCopy(&a, (decNumber *)aa.data.num);
decNumberCopy(&b, (decNumber *)bb.data.num);
decNumberCopy(&c, (decNumber *)cc.data.num);
@@ -1350,12 +1361,12 @@ static void mp_decimal_crossing_point (MP mp, mp_number *ret, mp_number aa, mp_n
decNumberCopy(&x0, &a);
decNumberSubtract(&x1,&a, &b, &set);
decNumberSubtract(&x2,&b, &c, &set);
+ /* not sure why the error correction has to be >= 1E-12 */
+ decNumberFromDouble(&scratch2, 1E-12);
do {
- /* not sure why the error correction has to be >= 1E-12 */
decNumberAdd(&x, &x1, &x2, &set);
decNumberDivide(&x, &x, &two_decNumber, &set);
- decNumberFromDouble(&scratch, 1E-12);
- decNumberAdd(&x, &x, &scratch, &set);
+ decNumberAdd(&x, &x, &scratch2, &set);
decNumberSubtract(&scratch, &x1, &x0, &set);
if (decNumberGreater(&scratch, &x0)) {
decNumberCopy(&x2, &x);
@@ -1431,7 +1442,7 @@ relying on |real| arithmetic or system subroutines for sines, cosines, etc.
@c
void mp_decimal_square_rt (MP mp, mp_number *ret, mp_number x_orig) { /* return, x: scaled */
decNumber x;
- decNumberCopyAbs(&x, x_orig.data.num);
+ decNumberCopy(&x, x_orig.data.num);
if (!decNumberIsPositive(&x)) {
@<Handle square root of zero or negative argument@>;
} else {
@@ -1629,12 +1640,14 @@ using the Taylor series. This function is fairly optimized.
@c
static void sinecosine(decNumber *theangle, decNumber *c, decNumber *s)
{
- int n, i;
+ int n, i, prec;
decNumber p, pxa, fac, cc;
decNumber n1, n2, p1;
decNumberZero(c);
decNumberZero(s);
- for (n=0;n<(set.digits/2);n++)
+ prec = (set.digits/2);
+ if (prec < DECPRECISION_DEFAULT) prec = DECPRECISION_DEFAULT;
+ for (n=0;n<prec;n++)
{
decNumberFromInt32(&p1, n);
decNumberFromInt32(&n1, 2*n);
diff --git a/Build/source/texk/web2c/mplibdir/pngout.w b/Build/source/texk/web2c/mplibdir/pngout.w
index 7255baec115..5e901c4f063 100644
--- a/Build/source/texk/web2c/mplibdir/pngout.w
+++ b/Build/source/texk/web2c/mplibdir/pngout.w
@@ -360,12 +360,16 @@ static void mp_png_path_out (MP mp, mp_gr_knot h) {
cairo_curve_to (mp->png->cr, gr_right_x(p),gr_right_y(p),
gr_left_x(q),gr_left_y(q),
gr_x_coord(q),gr_y_coord(q));
- } else if ( q!=h ){
+ } else {
cairo_line_to (mp->png->cr, gr_x_coord(q),gr_y_coord(q));
}
p=q;
steps++;
} while (p!=h);
+ if ((gr_x_coord(p) == gr_x_coord(h)) && (gr_y_coord(p) == gr_y_coord(h)) &&
+ gr_right_type(p)!=mp_endpoint) {
+ cairo_close_path(mp->png->cr);
+ }
}
@ Now for outputting the actual graphic objects.
@@ -432,9 +436,9 @@ void mp_png_text_out (MP mp, mp_text_object *p) {
double scf;
ds =(mp->font_dsize[fn]+8) / (16*65536.0);
scf = mp_png_choose_scale (mp,(mp_graphic_object *)p);
+ cairo_save(mp->png->cr);
if ( transformed ) {
cairo_matrix_t matrix = {0,0,0,0,0,0};
- cairo_save(mp->png->cr);
cairo_matrix_init(&matrix, (gr_txx_val(p)/scf), (gr_tyx_val(p)/scf),
(gr_txy_val(p)/scf), (gr_tyy_val(p)/scf),
gr_tx_val(p),gr_ty_val(p));
@@ -468,9 +472,7 @@ void mp_png_text_out (MP mp, mp_text_object *p) {
wd = mp_get_char_dimension (mp, mp->font_name[fn], k, 'w');
cairo_translate(mp->png->cr,wd,0);
}
- if ( transformed ) {
- cairo_restore(mp->png->cr);
- }
+ cairo_restore(mp->png->cr);
}
@ When stroking a path with an elliptical pen, it is necessary to transform
@@ -490,6 +492,14 @@ static void mp_png_stroke_out (MP mp, mp_graphic_object *h,
void mp_png_stroke_out (MP mp, mp_graphic_object *h,
mp_pen_info *pen, boolean fill_also) {
boolean transformed = false;
+ if (fill_also) {
+ cairo_save(mp->png->cr);
+ mp_png_path_out(mp, gr_path_p((mp_stroked_object *)h));
+ cairo_close_path (mp->png->cr);
+ cairo_fill (mp->png->cr);
+ cairo_restore(mp->png->cr);
+ }
+ cairo_save(mp->png->cr);
if (pen != NULL) {
transformed = true;
if ((pen->sx==unity) &&
@@ -530,23 +540,14 @@ void mp_png_stroke_out (MP mp, mp_graphic_object *h,
}
}
cairo_set_miter_limit(mp->png->cr,gr_miterlim_val((mp_stroked_object *)h));
- mp_png_path_out(mp, gr_path_p((mp_stroked_object *)h));
- if (fill_also) {
- cairo_save(mp->png->cr);
- cairo_close_path (mp->png->cr);
- cairo_fill (mp->png->cr);
- cairo_restore(mp->png->cr);
- }
if (transformed) {
cairo_matrix_t matrix = {0,0,0,0,0,0};
- cairo_save(mp->png->cr);
cairo_matrix_init(&matrix, pen->sx, pen->rx, pen->ry, pen->sy, pen->tx, pen->ty);
cairo_transform (mp->png->cr, &matrix);
}
+ mp_png_path_out(mp, gr_path_p((mp_stroked_object *)h));
cairo_stroke (mp->png->cr);
- if (transformed) {
- cairo_restore(mp->png->cr);
- }
+ cairo_restore(mp->png->cr);
}
@ Here is a simple routine that just fills a cycle.
@@ -556,9 +557,11 @@ static void mp_png_fill_out (MP mp, mp_gr_knot p, mp_graphic_object *h);
@ @c
void mp_png_fill_out (MP mp, mp_gr_knot p, mp_graphic_object *h) {
+ cairo_save(mp->png->cr);
mp_png_path_out(mp, p);
cairo_close_path (mp->png->cr);
cairo_fill (mp->png->cr);
+ cairo_restore(mp->png->cr);
}
@ The main output function
diff --git a/Build/source/texk/web2c/mplibdir/psout.w b/Build/source/texk/web2c/mplibdir/psout.w
index 0ab2945828c..7728a675c8f 100644
--- a/Build/source/texk/web2c/mplibdir/psout.w
+++ b/Build/source/texk/web2c/mplibdir/psout.w
@@ -1,4 +1,4 @@
-% $Id: psout.w 1892 2013-03-22 10:21:05Z taco $
+% $Id: psout.w 1996 2014-04-09 07:23:33Z taco $
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
% See the <Show version...> code in mpost.w for more info.
@@ -1205,8 +1205,9 @@ static int check_fm_entry (MP mp, fm_entry * fm, boolean warn) {
float d;
fm_entry *fm;
char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE];
- char *p, *q, *r, *s;
+ char *p, *q, *s;
char warn_s[128];
+ char *r = NULL;
switch (mp->ps->mitem->type) {
case MAPFILE:
p = fm_line;
diff --git a/Build/source/texk/web2c/mplibdir/svgout.w b/Build/source/texk/web2c/mplibdir/svgout.w
index 1d6b175ca42..a3760007305 100644
--- a/Build/source/texk/web2c/mplibdir/svgout.w
+++ b/Build/source/texk/web2c/mplibdir/svgout.w
@@ -1,4 +1,4 @@
-% $Id: svgout.w 1902 2013-05-22 14:44:36Z taco $
+% $Id: svgout.w 1999 2014-04-09 08:20:05Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -633,21 +633,13 @@ mp_pen_info *mp_svg_pen_info(MP mp, mp_gr_knot pp, mp_gr_knot p) {
wx = fabs(gr_left_x(p) - gr_x_coord(p));
wy = fabs(gr_right_y(p) - gr_y_coord(p));
} else {
- mp_number arg1, arg2, ret;
- new_number(ret);
- new_number(arg1);
- new_number(arg2);
- mp_set_number_from_double (&arg1, gr_left_x(p)-gr_x_coord(p));
- mp_set_number_from_double (&arg2, gr_right_x(p)-gr_x_coord(p));
- mp_pyth_add(mp, &ret, arg1, arg2);
- wx = mp_number_to_double(ret);
- mp_set_number_from_double (&arg1, gr_left_y(p)-gr_y_coord(p));
- mp_set_number_from_double (&arg2, gr_right_y(p)-gr_y_coord(p));
- mp_pyth_add(mp, &ret, arg1, arg2);
- wy = mp_number_to_double(ret);
- free_number(ret);
- free_number(arg1);
- free_number(arg2);
+ double a,b;
+ a = gr_left_x(p)-gr_x_coord(p);
+ b = gr_right_x(p)-gr_x_coord(p);
+ wx = sqrt(a*a + b*b);
+ a = gr_left_y(p)-gr_y_coord(p);
+ b = gr_right_y(p)-gr_y_coord(p);
+ wy = sqrt(a*a + b*b);
}
if ((wy/coord_range_x(pp, wx)) >= (wx/coord_range_y(pp, wy)))
pen->ww = wy;