summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2014-09-03 04:00:23 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2014-09-03 04:00:23 +0000
commitf5e933e45879c199590030a7c9d29ea3f8eaced4 (patch)
treef49b6913dcf5ed183f8217f71c3c5195f12d5c59 /Build
parentd2e4b84647b69841aa0aa10a8c87db342e85aa59 (diff)
web2c/mplibdir: Sync with the trunk
git-svn-id: svn://tug.org/texlive/trunk@35099 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog5
-rw-r--r--Build/source/texk/web2c/mplibdir/lmplib.c171
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w186
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmath.w4
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmathbinary.w2
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmathdecimal.w2
-rw-r--r--Build/source/texk/web2c/mplibdir/mpmathdouble.w4
-rw-r--r--Build/source/texk/web2c/mplibdir/mpost.w5
-rw-r--r--Build/source/texk/web2c/mplibdir/mpxout.w2
-rw-r--r--Build/source/texk/web2c/mplibdir/psout.w4
10 files changed, 329 insertions, 56 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index 0f4621c055d..597bb82aaac 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-03 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+
+ * lmplib.c, mp.w, mpmath.w, mpmathbinary.w, mpmathdecimal.w,
+ mpmathdouble.w, mpost.w, mpxout.w, psout.w: Sync with the trunk.
+
2014-07-15 Peter Breitenlohner <peb@mppmu.mpg.de>
* mpxout.w: Replace the deprecated spawnvp() by _spawnvp(),
diff --git a/Build/source/texk/web2c/mplibdir/lmplib.c b/Build/source/texk/web2c/mplibdir/lmplib.c
index ae287fe5b12..e61535ef9fa 100644
--- a/Build/source/texk/web2c/mplibdir/lmplib.c
+++ b/Build/source/texk/web2c/mplibdir/lmplib.c
@@ -37,13 +37,23 @@
#define lua_objlen lua_rawlen
#endif
+#ifndef luaL_reg
+#define luaL_reg luaL_Reg
+#endif
+
+
+#ifndef lua_objlen
+#define lua_objlen lua_rawlen
+#endif
+
+
#include "mplib.h"
#include "mplibps.h"
#include "mplibsvg.h"
#include "mplibpng.h"
/*@unused@*/ static const char _svn_version[] =
- "$Id: lmplib.c 1962 2014-03-11 13:18:08Z taco $";
+ "$Id: lmplib.c 2036 2014-06-26 18:44:57Z luigi $";
int luaopen_mplib(lua_State * L); /* forward */
@@ -223,7 +233,8 @@ static const char *no_fields[] =
typedef enum {
P_ERROR_LINE, P_MAX_LINE, P_RANDOM_SEED, P_MATH_MODE,
- P_INTERACTION, P_INI_VERSION, P_MEM_NAME, P_JOB_NAME, P_FIND_FILE,
+ P_INTERACTION, P_INI_VERSION, P_MEM_NAME, P_JOB_NAME, P_FIND_FILE,
+ P_RUN_SCRIPT, P_SCRIPT_ERROR,
P__SENTINEL } mplib_parm_idx;
typedef struct {
@@ -232,24 +243,28 @@ typedef struct {
} mplib_parm_struct;
static mplib_parm_struct mplib_parms[] = {
- {"error_line", P_ERROR_LINE },
- {"print_line", P_MAX_LINE },
- {"random_seed", P_RANDOM_SEED },
- {"interaction", P_INTERACTION },
- {"job_name", P_JOB_NAME },
- {"find_file", P_FIND_FILE },
- {"math_mode", P_MATH_MODE },
- {NULL, P__SENTINEL }
+ {"error_line", P_ERROR_LINE },
+ {"print_line", P_MAX_LINE },
+ {"random_seed", P_RANDOM_SEED },
+ {"interaction", P_INTERACTION },
+ {"job_name", P_JOB_NAME },
+ {"find_file", P_FIND_FILE },
+ {"run_script", P_RUN_SCRIPT },
+ {"script_error", P_SCRIPT_ERROR },
+ {"math_mode", P_MATH_MODE },
+ {NULL, P__SENTINEL }
};
/* Start by defining the needed callback routines for the library */
+/* todo: make subtable in registry, beware, for all mp instances */
+
static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ftype)
{
lua_State *L = (lua_State *)mp_userdata(mp);
lua_checkstack(L, 4);
- lua_getfield(L, LUA_REGISTRYINDEX, "mplib_file_finder");
+ lua_getfield(L, LUA_REGISTRYINDEX, "mplib.file_finder");
if (lua_isfunction(L, -1)) {
char *s = NULL;
const char *x = NULL;
@@ -283,12 +298,120 @@ static int mplib_find_file_function(lua_State * L)
if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
return 1; /* error */
}
- lua_pushstring(L, "mplib_file_finder");
+ lua_pushstring(L, "mplib.file_finder");
+ lua_pushvalue(L, -2);
+ lua_rawset(L, LUA_REGISTRYINDEX);
+ return 0;
+}
+
+static void mplib_script_error(MP mp, const char *str)
+{
+ lua_State *L = (lua_State *)mp_userdata(mp);
+ lua_checkstack(L, 1);
+ lua_getfield(L, LUA_REGISTRYINDEX, "mplib.script_error");
+ if (lua_isfunction(L, -1)) {
+ lua_pushstring(L, str);
+ lua_pcall(L, 1, 0, 0); /* assume the function is ok */
+ } else {
+ fprintf(stdout,"Error in script: %s\n",str);
+ lua_pop(L, 1);
+ }
+}
+
+static int mplib_script_error_function(lua_State * L)
+{
+ if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
+ return 1; /* error */
+ }
+ lua_pushstring(L, "mplib.script_error");
+ lua_pushvalue(L, -2);
+ lua_rawset(L, LUA_REGISTRYINDEX);
+ return 0;
+}
+
+static char *mplib_run_script(MP mp, const char *str)
+{
+ lua_State *L = (lua_State *)mp_userdata(mp);
+ lua_checkstack(L, 1);
+ lua_getfield(L, LUA_REGISTRYINDEX, "mplib.run_script");
+ if (lua_isfunction(L, -1)) {
+ char *s = NULL;
+ const char *x = NULL;
+ lua_pushstring(L, str);
+ if (lua_pcall(L, 1, 1, 0) != 0) {
+ mplib_script_error(mp, lua_tostring(L, -1));
+ return NULL;
+ }
+ x = lua_tostring(L, -1);
+ if (x != NULL)
+ s = strdup(x);
+ lua_pop(L, 1); /* pop the string */
+ return s;
+ } else {
+ lua_pop(L, 1);
+ }
+ return NULL;
+}
+
+static int mplib_run_script_function(lua_State * L)
+{
+ if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
+ return 1; /* error */
+ }
+ lua_pushstring(L, "mplib.run_script");
lua_pushvalue(L, -2);
lua_rawset(L, LUA_REGISTRYINDEX);
return 0;
}
+static int mplib_get_numeric(lua_State * L)
+{
+ MP *mp = is_mp(L, 1);
+ if (*mp != NULL) {
+ size_t l;
+ const char *s = lua_tolstring(L, 2, &l);
+ if (s != NULL) {
+ lua_pushnumber(L, mp_get_numeric_value(*mp,s,l));
+ return 1;
+ }
+ }
+ lua_pushnumber(L,0);
+ return 1;
+}
+
+static int mplib_get_boolean(lua_State * L)
+{
+ MP *mp = is_mp(L, 1);
+ if (*mp != NULL) {
+ size_t l;
+ const char *s = lua_tolstring(L, 2, &l);
+ if (s != NULL) {
+ lua_pushboolean(L, mp_get_boolean_value(*mp,s,l));
+ return 1;
+ }
+ }
+ lua_pushboolean(L,0);
+ return 1;
+}
+
+static int mplib_get_string(lua_State * L)
+{
+ MP *mp = is_mp(L, 1);
+ if (*mp != NULL) {
+ size_t l;
+ const char *s = lua_tolstring(L, 2, &l);
+ if (s != NULL) {
+ char *r = mp_get_string_value(*mp,s,l) ;
+ if (r != NULL) {
+ lua_pushstring(L, r);
+ return 1;
+ }
+ }
+ }
+ lua_pushstring(L,"");
+ return 1;
+}
+
#define xfree(A) if ((A)!=NULL) { free((A)); A = NULL; }
static int mplib_new(lua_State * L)
@@ -301,6 +424,8 @@ static int mplib_new(lua_State * L)
options->userdata = (void *) L;
options->noninteractive = 1; /* required ! */
options->find_file = mplib_find_file;
+ options->run_script = mplib_run_script;
+ // options->script_error = mplib_script_error;
options->print_found_names = 1;
options->ini_version = 1;
if (lua_type(L, 1) == LUA_TTABLE) {
@@ -339,8 +464,17 @@ static int mplib_new(lua_State * L)
break;
case P_FIND_FILE:
if (mplib_find_file_function(L)) { /* error here */
- fprintf(stdout,
- "Invalid arguments to mp.new({find_file=...})\n");
+ fprintf(stdout,"Invalid arguments to mp.new { find_file = ... }\n");
+ }
+ break;
+ case P_RUN_SCRIPT:
+ if (mplib_run_script_function(L)) { /* error here */
+ fprintf(stdout,"Invalid arguments to mp.new { run_script = ... }\n");
+ }
+ break;
+ case P_SCRIPT_ERROR:
+ if (mplib_script_error_function(L)) { /* error here */
+ fprintf(stdout,"Invalid arguments to mp.new { script_error = ... }\n");
}
break;
default:
@@ -1567,6 +1701,7 @@ static int mplib_gr_index(lua_State * L)
}
+
static const struct luaL_reg mplib_meta[] = {
{"__gc", mplib_collect},
{"__tostring", mplib_tostring},
@@ -1606,6 +1741,10 @@ static const struct luaL_reg mplib_d[] = {
{"char_depth", mplib_chardepth},
{"statistics", mplib_statistics},
{"solve_path", mplib_solve_path},
+ {"get_numeric", mplib_get_numeric},
+ {"get_number", mplib_get_numeric},
+ {"get_boolean", mplib_get_boolean},
+ {"get_string", mplib_get_string},
{NULL, NULL} /* sentinel */
};
@@ -1615,6 +1754,10 @@ static const struct luaL_reg mplib_m[] = {
{"version", mplib_version},
{"fields", mplib_gr_fields},
{"pen_info", mplib_gr_peninfo},
+ {"get_numeric", mplib_get_numeric},
+ {"get_number", mplib_get_numeric},
+ {"get_boolean", mplib_get_boolean},
+ {"get_string", mplib_get_string},
{NULL, NULL} /* sentinel */
};
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index 54904fd4157..e4a27a370c5 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -1,4 +1,4 @@
-% $Id: mp.w 2005 2014-04-09 10:02:21Z taco $
+% $Id: mp.w 2037 2014-09-02 14:59:07Z luigi $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -152,12 +152,12 @@ typedef struct MP_instance {
# include <unistd.h> /* for access */
#endif
#include <time.h> /* for struct tm \& co */
-#include <zlib.h> /* for ZLIB_VERSION, zlibVersion() */
-#include <png.h> /* for PNG_LIBPNG_VER_STRING, png_libpng_ver */
-#include <pixman.h> /* for PIXMAN_VERSION_STRING, pixman_version_string() */
-#include <cairo.h> /* for CAIRO_VERSION_STRING, cairo_version_string() */
-#include <gmp.h> /* for __GNU_MP_VERSION etc., gmp_version */
-#include <mpfr.h> /* for MPFR_VERSION_STRING, mpfr_get_version() */
+#include <zlib.h> /* for |ZLIB_VERSION|, zlibVersion() */
+#include <png.h> /* for |PNG_LIBPNG_VER_STRING|, |png_libpng_ver| */
+#include <pixman.h> /* for |PIXMAN_VERSION_STRING|, |pixman_version_string()| */
+#include <cairo.h> /* for |CAIRO_VERSION_STRING|, |cairo_version_string()| */
+#include <gmp.h> /* for |gmp_version| */
+#include <mpfr.h> /* for |MPFR_VERSION_STRING|, |mpfr_get_version()| */
#include "mplib.h"
#include "mplibps.h" /* external header */
#include "mplibsvg.h" /* external header */
@@ -517,6 +517,7 @@ MP mp_initialize (MP_options * opt) {
set_callback_option (write_ascii_file);
set_callback_option (write_binary_file);
set_callback_option (shipout_backend);
+ set_callback_option (run_script);
if (opt->banner && *(opt->banner)) {
mp->banner = xstrdup (opt->banner);
} else {
@@ -703,7 +704,7 @@ mp->bad = 0;
@d decr(A) (A)=(A)-1 /* decrease a variable by unity */
@d negate(A) (A)=-(A) /* change the sign of a variable */
@d double(A) (A)=(A)+(A)
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@* The character set.
In order to make \MP\ readily portable to a wide variety of
@@ -836,6 +837,7 @@ enum mp_filetype {
mp_filetype_text /* first text file for readfrom and writeto primitives */
};
typedef char *(*mp_file_finder) (MP, const char *, const char *, int);
+typedef char *(*mp_script_runner) (MP, const char *);
typedef void *(*mp_file_opener) (MP, const char *, const char *, int);
typedef char *(*mp_file_reader) (MP, void *, size_t *);
typedef void (*mp_binfile_reader) (MP, void *, void **, size_t *);
@@ -848,6 +850,7 @@ typedef void (*mp_binfile_writer) (MP, void *, void *, size_t);
@ @<Option variables@>=
mp_file_finder find_file;
mp_file_opener open_file;
+mp_script_runner run_script;
mp_file_reader read_ascii_file;
mp_binfile_reader read_binary_file;
mp_file_closer close_file;
@@ -869,6 +872,12 @@ static char *mp_find_file (MP mp, const char *fname, const char *fmode,
return NULL;
}
+@ @c
+static char *mp_run_script (MP mp, const char *str) {
+ (void) mp;
+ return mp_strdup (str);
+}
+
@ Because |mp_find_file| is used so early, it has to be in the helpers
section.
@@ -885,6 +894,7 @@ static int mp_eof_file (MP mp, void *f);
static void mp_flush_file (MP mp, void *f);
static void mp_write_ascii_file (MP mp, void *f, const char *s);
static void mp_write_binary_file (MP mp, void *f, void *s, size_t t);
+static char *mp_run_script (MP mp, const char *str);
@ The function to open files can now be very short.
@@ -3116,6 +3126,7 @@ mp_repeat_loop, /* special command substituted for \&{endfor} */
mp_exit_test, /* premature exit from a loop (\&{exitif}) */
mp_relax, /* do nothing (\.{\char`\\}) */
mp_scan_tokens, /* put a string into the input buffer */
+mp_runscript, /* put a script result string into the input buffer */
mp_expand_after, /* look ahead one token */
mp_defined_macro, /* a macro defined by the user */
mp_save_command, /* save a list of tokens (\&{save}) */
@@ -4664,6 +4675,59 @@ static mp_sym mp_frozen_id_lookup (MP mp, char *j, size_t l,
return mp_do_id_lookup (mp, mp->frozen_symbols, j, l, insert_new);
}
+/* see mp_print_sym (mp_sym sym) */
+
+double mp_get_numeric_value (MP mp, const char *s, size_t l) {
+ char *ss = mp_xstrdup(mp,s);
+ if (ss) {
+ mp_sym sym = mp_id_lookup(mp,ss,l,false);
+ if (sym != NULL) {
+ if (mp_type(sym->v.data.node) == mp_known) {
+ mp_xfree (ss);
+ return number_to_double(sym->v.data.node->data.n) ;
+ }
+ }
+ }
+ mp_xfree (ss);
+ return 0 ;
+}
+
+int mp_get_boolean_value (MP mp, const char *s, size_t l) {
+ char *ss = mp_xstrdup(mp,s);
+ if (ss) {
+ mp_sym sym = mp_id_lookup(mp,ss,l,false);
+ if (sym != NULL) {
+ if (mp_type(sym->v.data.node) == mp_boolean_type) {
+ if (number_to_boolean (sym->v.data.node->data.n) == mp_true_code) {
+ mp_xfree(ss);
+ return 1 ;
+ }
+ }
+ }
+ }
+ mp_xfree (ss);
+ return 0;
+}
+
+char *mp_get_string_value (MP mp, const char *s, size_t l) {
+ char *ss = mp_xstrdup(mp,s);
+ if (ss) {
+ mp_sym sym = mp_id_lookup(mp,ss,l,false);
+ if (sym != NULL) {
+ if (mp_type(sym->v.data.node) == mp_string_type) {
+ mp_xfree (ss);
+ return (char *) sym->v.data.node->data.str->str;
+ }
+ }
+ }
+ mp_xfree (ss);
+ return NULL;
+}
+
+@ @<Exported function headers@>=
+double mp_get_numeric_value(MP mp,const char *s,size_t l);
+int mp_get_boolean_value(MP mp,const char *s,size_t l);
+char *mp_get_string_value(MP mp,const char *s,size_t l);
@ We need to put \MP's ``primitive'' symbolic tokens into the hash
table, together with their command code (which will be the |eq_type|)
@@ -4777,6 +4841,10 @@ mp_primitive (mp, "save", mp_save_command, 0);
@:save_}{\&{save} primitive@>;
mp_primitive (mp, "scantokens", mp_scan_tokens, 0);
@:scan_tokens_}{\&{scantokens} primitive@>;
+
+mp_primitive (mp, "runscript", mp_runscript, 0);
+@:run_script_}{\&{runscript} primitive@>;
+
mp_primitive (mp, "shipout", mp_ship_out_command, 0);
@:ship_out_}{\&{shipout} primitive@>;
mp_primitive (mp, "skipto", mp_skip_to, 0);
@@ -4894,6 +4962,9 @@ break;
case mp_scan_tokens:
mp_print (mp, "scantokens");
break;
+case mp_runscript:
+mp_print (mp, "runscript");
+break;
case mp_semicolon:
mp_print_char (mp, xord (';'));
break;
@@ -4995,7 +5066,7 @@ typedef struct mp_node_data *mp_token_node;
@ @c
#if DEBUG
#define value_sym(A) do_get_value_sym(mp,(mp_token_node)(A))
-//#define value_number(A) do_get_value_number(mp,(mp_token_node)(A))
+/* |#define value_number(A) do_get_value_number(mp,(mp_token_node)(A))| */
#define value_number(A) ((mp_token_node)(A))->data.n
#define value_node(A) do_get_value_node(mp,(mp_token_node)(A))
#define value_str(A) do_get_value_str(mp,(mp_token_node)(A))
@@ -10014,7 +10085,7 @@ if (number_positive(arc)) {
number_clone (d1, inf_t); /* reuse d1 */
number_clone (v1, n); /* v1 = n */
number_add (v1, epsilon_t); /* v1 = n1+1 */
- set_number_from_div (d1, d1, v1); /* d1 = EL_GORDO / v1 */
+ set_number_from_div (d1, d1, v1); /* |d1 = EL_GORDO / v1| */
if (number_greater (t_tot, d1)) {
mp->arith_error = true;
check_arith();
@@ -15782,6 +15853,8 @@ static mp_value_node mp_p_plus_fq (MP mp, mp_value_node p, mp_number f,
} else {
if (number_greaterequal (absv, coef_bound_k) && mp->watch_coefs) {
mp_type (qq) = independent_needing_fix;
+ /* If we set this , then we can drop (mp_type(pp) == independent_needing_fix && mp->fix_needed) later */
+ /* set_number_from_scaled (value_number (qq), indep_value(qq)); */
mp->fix_needed = true;
}
set_mp_link (r, (mp_node) s);
@@ -15796,13 +15869,13 @@ static mp_value_node mp_p_plus_fq (MP mp, mp_value_node p, mp_number f,
} else {
if (pp == NULL)
set_number_to_neg_inf(v);
- else if (mp_type(pp) == mp_independent)
+ else if (mp_type(pp) == mp_independent || (mp_type(pp) == independent_needing_fix && mp->fix_needed))
set_number_from_scaled(v, indep_value(pp));
else
number_clone (v, value_number (pp));
if (qq == NULL)
set_number_to_neg_inf(vv);
- else if (mp_type(qq) == mp_independent)
+ else if (mp_type(qq) == mp_independent || (mp_type(qq) == independent_needing_fix && mp->fix_needed))
set_number_from_scaled(vv, indep_value(qq));
else
number_clone (vv, value_number (qq));
@@ -15925,6 +15998,8 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q,
} else {
if (number_greaterequal(test, coef_bound_k) && mp->watch_coefs) {
mp_type (qq) = independent_needing_fix;
+ /* If we set this , then we can drop (mp_type(pp) == independent_needing_fix && mp->fix_needed) later */
+ /* set_number_from_scaled (value_number (qq), indep_value(qq)); */
mp->fix_needed = true;
}
set_mp_link (r, (mp_node) s);
@@ -15938,13 +16013,13 @@ static mp_value_node mp_p_plus_q (MP mp, mp_value_node p, mp_value_node q,
} else {
if (pp == NULL)
set_number_to_zero (v);
- else if (mp_type(pp) == mp_independent)
+ else if (mp_type(pp) == mp_independent || (mp_type(pp) == independent_needing_fix && mp->fix_needed))
set_number_from_scaled (v, indep_value(pp));
else
number_clone (v, value_number (pp));
if (qq == NULL)
set_number_to_zero (vv);
- else if (mp_type(qq) == mp_independent)
+ else if (mp_type(qq) == mp_independent || (mp_type(qq) == independent_needing_fix && mp->fix_needed))
set_number_from_scaled (vv, indep_value(qq));
else
number_clone (vv, value_number (qq));
@@ -18824,7 +18899,7 @@ static void mp_scan_def (MP mp) {
n = 0;
set_eq_type (mp->warning_info, mp_defined_macro);
set_equiv_node (mp->warning_info, q);
- } else { /* var_def */
+ } else { /* |var_def| */
p = mp_scan_declared_variable (mp);
mp_flush_variable (mp, equiv_node (mp_sym_sym (p)), mp_link (p), true);
mp->warning_info_node = mp_find_variable (mp, p);
@@ -18976,7 +19051,7 @@ mp_free_value_node (mp, mp->bad_vardef);
Only a few command codes |<min_command| can possibly be returned by
|get_t_next|; in increasing order, they are
|if_test|, |fi_or_else|, |input|, |iteration|, |repeat_loop|,
-|exit_test|, |relax|, |scan_tokens|, |expand_after|, and |defined_macro|.
+|exit_test|, |relax|, |scan_tokens|, |run_script|, |expand_after|, and |defined_macro|.
\MP\ usually gets the next token of input by saying |get_x_next|. This is
like |get_t_next| except that it keeps getting more tokens until
@@ -19092,6 +19167,9 @@ static void mp_expand (MP mp) {
case mp_scan_tokens:
@<Put a string into the input buffer@>;
break;
+ case mp_runscript:
+ @<Put a script result string into the input buffer@>;
+ break;
case mp_defined_macro:
mp_macro_call (mp, cur_mod_node(), NULL, cur_sym());
break;
@@ -19248,6 +19326,53 @@ is less than |loop_text|.
}
}
+@ @<Put a script result string into the input buffer@>=
+{
+ mp_get_x_next (mp);
+ mp_scan_primary (mp);
+ if (mp->cur_exp.type != mp_string_type) {
+ mp_value new_expr;
+ const char *hlp[] = {
+ "I'm going to flush this expression, since",
+ "runscript should be followed by a known string.",
+ NULL };
+ memset(&new_expr,0,sizeof(mp_value));
+ new_number(new_expr.data.n);
+ mp_disp_err (mp, NULL);
+ mp_back_error (mp, "Not a string", hlp, true);
+@.Not a string@>;
+ mp_get_x_next (mp);
+ mp_flush_cur_exp (mp, new_expr);
+ } else {
+ mp_back_input (mp);
+ if (cur_exp_str ()->len > 0) {
+ mp_value new_expr;
+ char *s = mp->run_script(mp,(const char*) cur_exp_str()->str) ;
+ if (s != NULL) {
+ size_t size = strlen(s);
+ memset(&new_expr,0,sizeof(mp_value));
+ new_number(new_expr.data.n);
+ mp_begin_file_reading (mp);
+ name = is_scantok;
+ mp->last = mp->first;
+ k = mp->first + size;
+ if (k >= mp->max_buf_stack) {
+ while (k >= mp->buf_size) {
+ mp_reallocate_buffer (mp, (mp->buf_size + (mp->buf_size / 4)));
+ }
+ mp->max_buf_stack = k + 1;
+ }
+ limit = (halfword) k;
+ (void) memcpy ((mp->buffer + mp->first), s, size);
+ free(s);
+ mp->buffer[limit] = xord ('%');
+ mp->first = (size_t) (limit + 1);
+ loc = start;
+ mp_flush_cur_exp (mp, new_expr);
+ }
+ }
+ }
+}
@ @<Pretend we're reading a new one-line file@>=
{
@@ -20949,7 +21074,7 @@ except of course for a short time just after |job_name| has become nonzero.
@<Allocate or ...@>=
mp->job_name = mp_xstrdup (mp, opt->job_name);
-/*
+/*|
if (mp->job_name != NULL) {
char *s = mp->job_name + strlen (mp->job_name);
while (s > mp->job_name) {
@@ -20959,7 +21084,7 @@ if (mp->job_name != NULL) {
s--;
}
}
-*/
+|*/
if (opt->noninteractive) {
if (mp->job_name == NULL)
mp->job_name = mp_xstrdup (mp, mp->mem_name);
@@ -26933,7 +27058,7 @@ static void mp_add_or_subtract (MP mp, mp_node p, mp_node q, quarterword c) {
set_cur_exp_node ((mp_node) qq);
mp->cur_exp.type = mp_type (p);
mp_name_type (qq) = mp_capsule;
- /* clang: never read: q = (mp_node) qq; */
+ /* clang: never read: |q = (mp_node) qq;| */
}
set_dep_list (qq, dep_list ((mp_value_node) p));
mp_type (qq) = mp_type (p);
@@ -28272,8 +28397,8 @@ static void mp_find_point (MP mp, mp_number v_orig, quarterword c) {
if (mp_left_type (p) == mp_endpoint) {
set_number_to_zero(v);
} else {
- /* v = n - 1 - ((-v - 1) % n)
- == - ((-v - 1) % n) - 1 + n */
+ /* |v = n - 1 - ((-v - 1) % n)
+ == - ((-v - 1) % n) - 1 + n| */
number_negate (v);
number_add_scaled (v, -1);
number_modulo (v, n);
@@ -29527,7 +29652,7 @@ static char *mplib_read_ascii_file (MP mp, void *ff, size_t * size) {
return s;
}
static void mp_append_string (MP mp, mp_stream * a, const char *b) {
- size_t l = strlen (b) + 1; /* don't forget the trailing '\0' */
+ size_t l = strlen (b) + 1; /* don't forget the trailing |'\0'| */
if ((a->used + l) >= a->size) {
a->size += 256 + (a->size) / 5 + l;
a->data = xrealloc (a->data, a->size, 1);
@@ -29803,13 +29928,12 @@ char *mp_metapost_version (void) {
return mp_strdup (metapost_version);
}
void mp_show_library_versions (void) {
- fprintf(stdout, "Compiled with mpfr %s; using %s\n", MPFR_VERSION_STRING, mpfr_get_version());
- fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n",
- __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL, gmp_version);
fprintf(stdout, "Compiled with cairo %s; using %s\n", CAIRO_VERSION_STRING, cairo_version_string());
fprintf(stdout, "Compiled with pixman %s; using %s\n", PIXMAN_VERSION_STRING, pixman_version_string());
fprintf(stdout, "Compiled with libpng %s; using %s\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
- fprintf(stdout, "Compiled with zlib %s; using %s\n\n", ZLIB_VERSION, zlibVersion());
+ fprintf(stdout, "Compiled with zlib %s; using %s\n", ZLIB_VERSION, zlibVersion());
+ fprintf(stdout, "Compiled with mpfr %s; using %s\n", MPFR_VERSION_STRING, mpfr_get_version());
+ fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n\n", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL, gmp_version);
}
@ @<Exported function headers@>=
@@ -30402,7 +30526,7 @@ void mp_do_show_var (MP mp) {
if (cur_sym() != NULL)
if (cur_sym_mod() == 0)
if (cur_cmd() == mp_tag_token)
- if (cur_mod() != 0) {
+ if (cur_mod() != 0 || cur_mod_node()!=NULL) {
mp_disp_var (mp, cur_mod_node());
goto DONE;
}
@@ -32752,7 +32876,7 @@ static void mp_fix_design_size (MP mp) {
mp->header_byte[6] = (char) ((dd / 16) % 256);
mp->header_byte[7] = (char) ((dd % 16) * 16);
}
- /* mp->max_tfm_dimen = 16 * internal_value (mp_design_size) - 1 - internal_value (mp_design_size) / 010000000 */
+ /* |mp->max_tfm_dimen = 16 * internal_value (mp_design_size) - 1 - internal_value (mp_design_size) / 010000000| */
{
mp_number secondpart;
new_number (secondpart);
@@ -33171,12 +33295,12 @@ for (k = 1; k <= (int) mp->last_fnum; k++) {
for (k = 0; k <= 255; k++) {
/* These are disabled for now following a bug-report about double free
errors. TO BE FIXED, bug tracker id 831 */
-/*
+/*|
mp_free_value_node (mp, mp->tfm_width[k]);
mp_free_value_node (mp, mp->tfm_height[k]);
mp_free_value_node (mp, mp->tfm_depth[k]);
mp_free_value_node (mp, mp->tfm_ital_corr[k]);
-*/
+|*/
}
xfree (mp->font_info);
@@ -34415,7 +34539,7 @@ been scanned.
@c
void mp_final_cleanup (MP mp) {
/* -Wunused: integer c; */ /* 0 for \&{end}, 1 for \&{dump} */
- /* clang: never read: c = cur_mod(); */
+ /* clang: never read: |c = cur_mod();| */
if (mp->job_name == NULL)
mp_open_log_file (mp);
while (mp->input_ptr > 0) {
diff --git a/Build/source/texk/web2c/mplibdir/mpmath.w b/Build/source/texk/web2c/mplibdir/mpmath.w
index 9b6bcb6995a..82d41746c72 100644
--- a/Build/source/texk/web2c/mplibdir/mpmath.w
+++ b/Build/source/texk/web2c/mplibdir/mpmath.w
@@ -1,4 +1,4 @@
-% $Id: mpmath.w 1959 2014-03-11 11:19:43Z taco $
+% $Id: mpmath.w 2037 2014-09-02 14:59:07Z luigi $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -1681,7 +1681,7 @@ any loss of accuracy. Then |x| and~|y| are divided by~|r|.
@d one_eighty_deg 01320000000 /* $180\cdot2^{20}$, represents $180^\circ$ */
@d three_sixty_deg 02640000000 /* $360\cdot2^{20}$, represents $360^\circ$ */
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@ Compute a multiple of the sine and cosine
diff --git a/Build/source/texk/web2c/mplibdir/mpmathbinary.w b/Build/source/texk/web2c/mplibdir/mpmathbinary.w
index a33fe54808b..ca223c6e353 100644
--- a/Build/source/texk/web2c/mplibdir/mpmathbinary.w
+++ b/Build/source/texk/web2c/mplibdir/mpmathbinary.w
@@ -589,7 +589,7 @@ int mp_number_to_scaled(mp_number A) {
@
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@c
int mp_number_to_int(mp_number A) {
diff --git a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
index f01dc4f39ce..b530d0986d0 100644
--- a/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
+++ b/Build/source/texk/web2c/mplibdir/mpmathdecimal.w
@@ -759,7 +759,7 @@ int mp_number_to_scaled(mp_number A) {
@
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@c
int mp_number_to_int(mp_number A) {
diff --git a/Build/source/texk/web2c/mplibdir/mpmathdouble.w b/Build/source/texk/web2c/mplibdir/mpmathdouble.w
index 2abd838f1ad..a6203d0e601 100644
--- a/Build/source/texk/web2c/mplibdir/mpmathdouble.w
+++ b/Build/source/texk/web2c/mplibdir/mpmathdouble.w
@@ -1,4 +1,4 @@
-% $Id: mpmathdouble.w 1959 2014-03-11 11:19:43Z taco $
+% $Id: mpmathdouble.w 2037 2014-09-02 14:59:07Z luigi $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -1196,7 +1196,7 @@ any loss of accuracy. Then |x| and~|y| are divided by~|r|.
@d one_eighty_deg (180.0*angle_multiplier)
@d three_sixty_deg (360.0*angle_multiplier)
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@ Compute a multiple of the sine and cosine
diff --git a/Build/source/texk/web2c/mplibdir/mpost.w b/Build/source/texk/web2c/mplibdir/mpost.w
index f2165b529e5..c5fedb477cd 100644
--- a/Build/source/texk/web2c/mplibdir/mpost.w
+++ b/Build/source/texk/web2c/mplibdir/mpost.w
@@ -1,4 +1,4 @@
-% $Id: mpost.w 1955 2014-03-10 10:30:30Z taco $
+% $Id: mpost.w 2007 2014-04-10 11:13:03Z taco $
%
% This file is part of MetaPost;
% the MetaPost program is in the public domain.
@@ -1027,7 +1027,8 @@ fprintf(stdout,
"For more information about these matters, see the file\n"
"COPYING.LESSER or <http://gnu.org/licenses/lgpl.html>.\n"
"Original author of MetaPost: John Hobby.\n"
-"Author of the CWEB MetaPost: Taco Hoekwater.\n\n"
+"Author of the CWEB MetaPost: Taco Hoekwater.\n"
+"Current maintainer of MetaPost: Luigi Scarso.\n\n"
);
mpost_xfree(s);
if (!dvitomp_only) {
diff --git a/Build/source/texk/web2c/mplibdir/mpxout.w b/Build/source/texk/web2c/mplibdir/mpxout.w
index 186d904939d..b52b24dd7b5 100644
--- a/Build/source/texk/web2c/mplibdir/mpxout.w
+++ b/Build/source/texk/web2c/mplibdir/mpxout.w
@@ -1,4 +1,4 @@
-% $Id: mpxout.w 1808 2012-12-10 08:57:11Z taco $
+% $Id: mpxout.w 2031 2014-06-24 13:38:58Z luigi $
% 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.
diff --git a/Build/source/texk/web2c/mplibdir/psout.w b/Build/source/texk/web2c/mplibdir/psout.w
index 9ed61aac1b4..2186487c551 100644
--- a/Build/source/texk/web2c/mplibdir/psout.w
+++ b/Build/source/texk/web2c/mplibdir/psout.w
@@ -1,4 +1,4 @@
-% $Id: psout.w 2009 2014-04-23 07:09:51Z taco $
+% $Id: psout.w 2037 2014-09-02 14:59:07Z luigi $
% 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.
@@ -52,7 +52,7 @@
@d incr(A) (A)=(A)+1 /* increase a variable by unity */
@d decr(A) (A)=(A)-1 /* decrease a variable by unity */
@d negate(A) (A)=-(A) /* change the sign of a variable */
-@d odd(A) ((A)%2==1)
+@d odd(A) (abs(A)%2==1)
@d max_quarterword 0x3FFF /* largest allowable value in a |quarterword| */
@c