1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
Index: Build/source/texk/web2c/mplibdir/mp.w
===================================================================
--- Build/source/texk/web2c/mplibdir/mp.w (revision 30927)
+++ Build/source/texk/web2c/mplibdir/mp.w (revision 30928)
@@ -1,4 +1,4 @@
-% $Id: mp.w 1901 2013-05-22 14:42:19Z taco $
+% $Id: mp.w 1918 2013-06-13 12:47:55Z taco $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -73,12 +73,12 @@
@^extensions to \MP@>
@^system dependencies@>
-@d default_banner "This is MetaPost, Version 1.802" /* printed when \MP\ starts */
+@d default_banner "This is MetaPost, Version 1.803" /* printed when \MP\ starts */
@d true 1
@d false 0
@<Metapost version header@>=
-#define metapost_version "1.802"
+#define metapost_version "1.803"
@ The external library header for \MP\ is |mplib.h|. It contains a
few typedefs and the header defintions for the externally used
@@ -516,8 +516,8 @@
/* open the terminal for output */
t_open_out();
#if DEBUG
- setlinebuf(stdout);
- setlinebuf(mp->term_out);
+ setvbuf(stdout, (char *) NULL, _IONBF, 0);
+ setvbuf(mp->term_out, (char *) NULL, _IONBF, 0);
#endif
if (opt->math_mode == mp_math_scaled_mode) {
mp->math = mp_initialize_scaled_math(mp);
@@ -8330,8 +8330,8 @@
@ @c
void mp_curl_ratio (MP mp, mp_number *ret, mp_number gamma_orig, mp_number a_tension, mp_number b_tension) {
mp_number alpha, beta, gamma, num, denom, ff; /* registers */
- mp_number n1;
- new_number (n1);
+ mp_number arg1;
+ new_number (arg1);
new_fraction (alpha);
new_fraction (beta);
new_fraction (gamma);
@@ -8342,49 +8342,33 @@
make_fraction (beta, unity_t, b_tension);
number_clone (gamma, gamma_orig);
if (number_lessequal(alpha, beta)) {
- mp_number arg1;
- new_number (arg1);
make_fraction (ff, alpha, beta);
number_clone (arg1, ff);
take_fraction (ff, arg1, arg1);
number_clone (arg1, gamma);
take_fraction (gamma, arg1, ff);
convert_fraction_to_scaled (beta);
- set_number_from_addition (arg1, alpha, three_t);
- number_substract (arg1, beta);
- take_fraction (denom, gamma, arg1);
- set_number_from_substraction (arg1, fraction_three_t, alpha);
- number_add (arg1, beta);
- take_fraction (num, gamma, arg1);
- free_number (arg1);
+ take_fraction (denom, gamma, alpha);
+ number_add (denom, three_t);
} else {
- mp_number arg1, r1;
- new_number (arg1);
- new_number (r1);
make_fraction (ff, beta, alpha);
number_clone (arg1, ff);
take_fraction (ff, arg1, arg1);
take_fraction (arg1, beta, ff);
convert_fraction_to_scaled (arg1);
- number_clone (beta, arg1);
- take_fraction (arg1, gamma, alpha);
- new_number (denom);
- {
- set_number_from_div (n1, ff, twelvebits_3);
- number_clone (denom, arg1);
- number_add (denom, n1);
- number_substract (denom, beta);
- }
- set_number_from_substraction (arg1, fraction_three_t, alpha);
- take_fraction (num, gamma, arg1);
- number_add (num, beta);
- free_number (arg1);
- free_number (r1);
+ number_clone (beta, arg1);
+ take_fraction (denom, gamma, alpha);
+ set_number_from_div (arg1, ff, twelvebits_3);
+ number_add (denom, arg1);
}
- number_clone (n1, denom);
- number_double (n1);
- number_double (n1); /* n1 = 4*denom */
- if (number_greaterequal(num, n1)) {
+ number_substract (denom, beta);
+ set_number_from_substraction (arg1, fraction_three_t, alpha);
+ take_fraction (num, gamma, arg1);
+ number_add (num, beta);
+ number_clone (arg1, denom);
+ number_double (arg1);
+ number_double (arg1); /* arg1 = 4*denom */
+ if (number_greaterequal(num, arg1)) {
number_clone(*ret, fraction_four_t);
} else {
make_fraction (*ret, num, denom);
@@ -8395,7 +8379,7 @@
free_number (num);
free_number (denom);
free_number (ff);
- free_number (n1);
+ free_number (arg1);
}
Index: Build/source/texk/web2c/mplibdir/mpmathdouble.w
===================================================================
--- Build/source/texk/web2c/mplibdir/mpmathdouble.w (revision 30927)
+++ Build/source/texk/web2c/mplibdir/mpmathdouble.w (revision 30928)
@@ -1,4 +1,4 @@
-% $Id: mpmathdouble.w 1892 2013-03-22 10:21:05Z taco $
+% $Id: mpmathdouble.w 1915 2013-06-13 10:17:31Z taco $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -17,13 +17,13 @@
@ Introduction.
@c
-#define _ISOC99_SOURCE /* to get the round() prototype */
#include <w2c/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "mpmathdouble.h" /* internal header */
+#define ROUND(a) floor((a)+0.5)
@h
@ @c
@@ -402,11 +402,7 @@
}
void mp_number_angle_to_scaled (mp_number *A) {
A->type = mp_scaled_type;
- if (A->data.dval >= 0) {
- A->data.dval = round(A->data.dval) / angle_multiplier;
- } else {
- A->data.dval = -((-round(A->data.dval))/ angle_multiplier);
- }
+ A->data.dval = ROUND(A->data.dval) / angle_multiplier;
}
void mp_number_scaled_to_fraction (mp_number *A) {
A->type = mp_fraction_type;
@@ -422,7 +418,7 @@
@c
int mp_number_to_scaled(mp_number A) {
- return (int)round(A.data.dval * 65536.0);
+ return (int)ROUND(A.data.dval * 65536.0);
}
int mp_number_to_int(mp_number A) {
return (int)(A.data.dval);
@@ -434,7 +430,7 @@
return A.data.dval;
}
int mp_number_odd(mp_number A) {
- return odd((int)round(A.data.dval * 65536.0));
+ return odd((int)ROUND(A.data.dval * 65536.0));
}
int mp_number_equal(mp_number A, mp_number B) {
return (A.data.dval==B.data.dval);
@@ -962,7 +958,7 @@
@ |round_unscaled| rounds a |scaled| and converts it to |int|
@c
int mp_round_unscaled(mp_number x_orig) {
- int x = (int)round(x_orig.data.dval);
+ int x = (int)ROUND(x_orig.data.dval);
return x;
}
Index: Build/source/texk/web2c/mplibdir/ChangeLog
===================================================================
--- Build/source/texk/web2c/mplibdir/ChangeLog (revision 30927)
+++ Build/source/texk/web2c/mplibdir/ChangeLog (revision 30928)
@@ -1,3 +1,7 @@
+2013-06-16 Taco Hoekwater <taco@luatex.org>
+
+ Import metapost 1.803 (released version)
+
2013-05-22 Taco Hoekwater <taco@luatex.org>
* svgout.w: fix a problem with overly large characters in
Index: Build/source/texk/web2c/mplibdir/mpost.w
===================================================================
--- Build/source/texk/web2c/mplibdir/mpost.w (revision 30927)
+++ Build/source/texk/web2c/mplibdir/mpost.w (revision 30928)
@@ -1,4 +1,4 @@
-% $Id: mpost.w 1895 2013-03-27 11:17:17Z taco $
+% $Id: mpost.w 1916 2013-06-13 10:19:49Z taco $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -443,7 +443,7 @@
mpost_xfree(mpversion);
}
}
-
+
mpost_xfree (cnf_cmd);
return (int)(ret == 0);
}
@@ -1290,6 +1290,17 @@
@ Now this is really it: \MP\ starts and ends here.
@c
+static char *cleaned_invocation_name(char *arg)
+{
+ char *ret, *dot;
+ const char *start = xbasename(arg);
+ ret = xstrdup(start);
+ dot = strrchr(ret, '.');
+ if (dot != NULL) {
+ *dot = 0; /* chop */
+ }
+ return ret;
+}
int
#if defined(WIN32) && !defined(__MINGW32__) && defined(DLLPROC)
DLLPROC (int argc, char **argv)
@@ -1306,8 +1317,8 @@
options->ini_version = (int)false;
options->print_found_names = (int)true;
{
- const char *base = xbasename(argv[0]);
- if (!strcmp(base, "dvitomp") || !strcasecmp(base, "dvitomp.exe"))
+ const char *base = cleaned_invocation_name(argv[0]);
+ if (FILESTRCASEEQ(base, "dvitomp"))
dvitomp_only=1;
}
if (dvitomp_only) {
|