Codebase list texlive-bin / 884f10a
Merge tag 'upstream/2014.20140912.35100' Upstream version 2014.20140912.35100 # gpg: Signature made Fri 12 Sep 2014 12:06:37 AM JST using RSA key ID 860CDC13 # gpg: Good signature from "Norbert Preining <preining@logic.at>" # gpg: aka "Norbert Preining <preining@debian.org>" # gpg: aka "Norbert Preining <norbert@preining.info>" # gpg: aka "Norbert Preining <preining@jaist.ac.jp>" Norbert Preining 9 years ago
14 changed file(s) with 362 addition(s) and 68 deletion(s). Raw diff Collapse all Expand all
0 2014-09-01 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
1
2 * vf.c: Add missing break in case X1: case X2: case X3: case X4:
3 in void vf_set_char(int32_t ch, int vf_font).
4
05 2014-08-24 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
16
27 * t1_char.c: Fix a bug in type1 handling reported by Bob Tennent
497497 break;
498498 case X1: case X2: case X3: case X4:
499499 dvi_x (sqxfw (ptsize, get_pkt_signed_num (&start, end, opcode-X1)));
500 break;
500501 case DOWN1: case DOWN2: case DOWN3: case DOWN4:
501502 dvi_down (sqxfw (ptsize, get_pkt_signed_num (&start, end, opcode-DOWN1)));
502503 break;
88
99 ########################################################################
1010 # arlatex #
11 # Copyright (C) 2011 Scott Pakin #
11 # Copyright (C) 2014 Scott Pakin #
1212 # #
1313 # This program may be distributed and/or modified under the conditions #
1414 # of the LaTeX Project Public License, either version 1.3c of this #
2626 ########################################################################
2727
2828 use 5.006; # Fail gracefully if we're not using Perl v5.6.0.
29 our $VERSION = "1.02"; # Specify the version of arlatex.
29 our $VERSION = "1.03"; # Specify the version of arlatex.
3030 use Getopt::Long;
3131 use Pod::Usage;
3232 use File::Basename;
3737 my $progname = basename($0); # Name of this program
3838 my $latexfile; # Main LaTeX document
3939 my $outfile = "-"; # Output file (default is standard output)
40 my $baseoutfile = "-"; # Base name of output file
4041
4142 ######################################################################
4243
4546 {
4647 my $filename = $_[0];
4748 my $basefilename = basename $filename;
49 next if $basefilename eq $baseoutfile; # Don't let a file overwrite itself.
50 $basefilename = "\"$basefilename\"" if $basefilename =~ /\s/ && substr($basefilename, 0, 1) ne '"';
4851 open (SOMEFILE, "<$filename") || die "${progname}: $! ($filename)\n";
4952 print OUTFILE "\\begin{filecontents*}{$basefilename}\n";
5053 print OUTFILE <SOMEFILE>;
7073 $latexfile = $newlatexfile;
7174 }
7275 }
76 $baseoutfile = basename $outfile if $outfile ne "-";
7377
7478 # Read the entire input file.
7579 open (LATEXFILE, "<$latexfile") || die "${progname}: $! ($latexfile)\n";
8387 while ($entirefile[0] =~ /^\s*(\%.*)?$/) {
8488 print OUTFILE (shift @entirefile);
8589 }
90 print OUTFILE "\\IfFileExists{filecontents.sty}{\\RequirePackage{filecontents}}{}\n";
8691 my @expandedARGV;
8792 foreach my $filename (@ARGV) {
8893 if (-f $filename) {
66
77 ########################################################################
88 # bundledoc #
9 # Copyright (C) 2011 Scott Pakin #
9 # Copyright (C) 2014 Scott Pakin #
1010 # #
1111 # This program may be distributed and/or modified under the conditions #
1212 # of the LaTeX Project Public License, either version 1.3c of this #
2424 ########################################################################
2525
2626 use 5.006; # Fail gracefully if we're not using Perl v5.6.0.
27 our $VERSION = "3.1"; # Specify the version of bundledoc.
27 our $VERSION = "3.2"; # Specify the version of bundledoc.
2828 use File::Basename;
2929 use File::Copy;
3030 use File::Spec::Functions qw(abs2rel catfile devnull rel2abs rootdir updir);
3838 ######################################################################
3939
4040 # Variables the user can override with a configuration file
41 # DEFAULTS: Unix + kpathsea
41 # DEFAULTS: Linux + kpathsea
4242 my %uservariable;
43 $uservariable{"bundle"} = '(tar -cvf - $BDINPUTS | compress > $BDBASE.tar.Z)';
43 $uservariable{"bundle"} = '(tar -cvf - $BDINPUTS | gzip --best > $BDBASE.tar.gz)';
4444 $uservariable{"find"} = 'kpsewhich -progname=latex $BDINPUTS';
4545 $uservariable{"sink"} = '> ' . devnull() . ' 2>&1';
4646
6565 # or abort if we can't.
6666 sub qualifyname ($)
6767 {
68 my $filename = $_[0];
69 $filename = "\"$filename\"" if $filename =~ /\s/ && substr($filename, 0, 1) ne '"';
6870 my $command = $uservariable{find};
69 $command =~ s/[\$\%]BDINPUTS\%?/$_[0]/g;
71 $command =~ s/[\$\%]BDINPUTS\%?/$filename/g;
7072 $command =~ s/[\$\%]BDBASE\%?/$ENV{"BDBASE"}/g;
7173 my $qualified = `$command` ||
7274 die "${progname}: \"$uservariable{find}\" (BDINPUTS=\"$_[0]\") failed to find $_[0]\n";
693695 Configuration file for MikTeX installations. MikTeX is a popular TeX
694696 distribution for Microsoft Windows. F<miktex.cfg> assumes you have
695697 B<zip> and uses it to produce a F<.zip> archive file. The
696 configuration file has B<bundledoc> use the rather nonstandard
697 B<initexmf> to find LaTeX files.
698 configuration file now has B<bundledoc> use B<kpsewhich> to find LaTeX
699 files; older version of MikTeX required the rather nonstandard
700 B<initexmf> for this purpose.
701
702 =item F<texlive-unix-arlatex.cfg>
703
704 This is a variant of F<texlive-unix.cfg> that uses B<arlatex> instead
705 of B<gzip> to archive files. B<arlatex> is a script included in the
706 B<bundledoc> distribution that generates a self-extracting F<.tex>
707 file based on LaTeX's C<filecontents> environment.
698708
699709 =back
700710
800810 I'd like B<bundledoc> to work on as wide a variety of TeX
801811 distributions as possible. If your platform is significantly
802812 different from the ones listed in L<"Testing Status"> (e.g., if you're
803 running MacOS) and you need to create a substantially different
813 running Z<OS X>) and you need to create a substantially different
804814 configuration file from F<texlive-unix.cfg> and F<miktex.cfg>, please
805815 send it to me at the address listed in L<"AUTHOR"> so I can include it
806816 in a future version of B<bundledoc>. (I make no promises, though).
825835
826836 =head1 SEE ALSO
827837
828 gzip(1), kpsewhich(1), latex(1), perl(1), zip(1), the B<snapshot>
829 documentation
838 arlatex(1), gzip(1), kpsewhich(1), latex(1), perl(1), zip(1),
839 the B<snapshot> documentation
830840
831841
832842 =head1 AUTHOR
0 2014-09-03 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
1
2 * lmplib.c, mp.w, mpmath.w, mpmathbinary.w, mpmathdecimal.w,
3 mpmathdouble.w, mpost.w, mpxout.w, psout.w: Sync with the trunk.
4
05 2014-07-15 Peter Breitenlohner <peb@mppmu.mpg.de>
16
27 * mpxout.w: Replace the deprecated spawnvp() by _spawnvp(),
3636 #define lua_objlen lua_rawlen
3737 #endif
3838
39 #ifndef luaL_reg
40 #define luaL_reg luaL_Reg
41 #endif
42
43
44 #ifndef lua_objlen
45 #define lua_objlen lua_rawlen
46 #endif
47
48
3949 #include "mplib.h"
4050 #include "mplibps.h"
4151 #include "mplibsvg.h"
4252 #include "mplibpng.h"
4353
4454 /*@unused@*/ static const char _svn_version[] =
45 "$Id: lmplib.c 1962 2014-03-11 13:18:08Z taco $";
55 "$Id: lmplib.c 2036 2014-06-26 18:44:57Z luigi $";
4656
4757 int luaopen_mplib(lua_State * L); /* forward */
4858
222232
223233 typedef enum {
224234 P_ERROR_LINE, P_MAX_LINE, P_RANDOM_SEED, P_MATH_MODE,
225 P_INTERACTION, P_INI_VERSION, P_MEM_NAME, P_JOB_NAME, P_FIND_FILE,
235 P_INTERACTION, P_INI_VERSION, P_MEM_NAME, P_JOB_NAME, P_FIND_FILE,
236 P_RUN_SCRIPT, P_SCRIPT_ERROR,
226237 P__SENTINEL } mplib_parm_idx;
227238
228239 typedef struct {
231242 } mplib_parm_struct;
232243
233244 static mplib_parm_struct mplib_parms[] = {
234 {"error_line", P_ERROR_LINE },
235 {"print_line", P_MAX_LINE },
236 {"random_seed", P_RANDOM_SEED },
237 {"interaction", P_INTERACTION },
238 {"job_name", P_JOB_NAME },
239 {"find_file", P_FIND_FILE },
240 {"math_mode", P_MATH_MODE },
241 {NULL, P__SENTINEL }
245 {"error_line", P_ERROR_LINE },
246 {"print_line", P_MAX_LINE },
247 {"random_seed", P_RANDOM_SEED },
248 {"interaction", P_INTERACTION },
249 {"job_name", P_JOB_NAME },
250 {"find_file", P_FIND_FILE },
251 {"run_script", P_RUN_SCRIPT },
252 {"script_error", P_SCRIPT_ERROR },
253 {"math_mode", P_MATH_MODE },
254 {NULL, P__SENTINEL }
242255 };
243256
244257
245258 /* Start by defining the needed callback routines for the library */
259
260 /* todo: make subtable in registry, beware, for all mp instances */
246261
247262 static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ftype)
248263 {
249264 lua_State *L = (lua_State *)mp_userdata(mp);
250265 lua_checkstack(L, 4);
251 lua_getfield(L, LUA_REGISTRYINDEX, "mplib_file_finder");
266 lua_getfield(L, LUA_REGISTRYINDEX, "mplib.file_finder");
252267 if (lua_isfunction(L, -1)) {
253268 char *s = NULL;
254269 const char *x = NULL;
282297 if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
283298 return 1; /* error */
284299 }
285 lua_pushstring(L, "mplib_file_finder");
300 lua_pushstring(L, "mplib.file_finder");
286301 lua_pushvalue(L, -2);
287302 lua_rawset(L, LUA_REGISTRYINDEX);
288303 return 0;
304 }
305
306 static void mplib_script_error(MP mp, const char *str)
307 {
308 lua_State *L = (lua_State *)mp_userdata(mp);
309 lua_checkstack(L, 1);
310 lua_getfield(L, LUA_REGISTRYINDEX, "mplib.script_error");
311 if (lua_isfunction(L, -1)) {
312 lua_pushstring(L, str);
313 lua_pcall(L, 1, 0, 0); /* assume the function is ok */
314 } else {
315 fprintf(stdout,"Error in script: %s\n",str);
316 lua_pop(L, 1);
317 }
318 }
319
320 static int mplib_script_error_function(lua_State * L)
321 {
322 if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
323 return 1; /* error */
324 }
325 lua_pushstring(L, "mplib.script_error");
326 lua_pushvalue(L, -2);
327 lua_rawset(L, LUA_REGISTRYINDEX);
328 return 0;
329 }
330
331 static char *mplib_run_script(MP mp, const char *str)
332 {
333 lua_State *L = (lua_State *)mp_userdata(mp);
334 lua_checkstack(L, 1);
335 lua_getfield(L, LUA_REGISTRYINDEX, "mplib.run_script");
336 if (lua_isfunction(L, -1)) {
337 char *s = NULL;
338 const char *x = NULL;
339 lua_pushstring(L, str);
340 if (lua_pcall(L, 1, 1, 0) != 0) {
341 mplib_script_error(mp, lua_tostring(L, -1));
342 return NULL;
343 }
344 x = lua_tostring(L, -1);
345 if (x != NULL)
346 s = strdup(x);
347 lua_pop(L, 1); /* pop the string */
348 return s;
349 } else {
350 lua_pop(L, 1);
351 }
352 return NULL;
353 }
354
355 static int mplib_run_script_function(lua_State * L)
356 {
357 if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) {
358 return 1; /* error */
359 }
360 lua_pushstring(L, "mplib.run_script");
361 lua_pushvalue(L, -2);
362 lua_rawset(L, LUA_REGISTRYINDEX);
363 return 0;
364 }
365
366 static int mplib_get_numeric(lua_State * L)
367 {
368 MP *mp = is_mp(L, 1);
369 if (*mp != NULL) {
370 size_t l;
371 const char *s = lua_tolstring(L, 2, &l);
372 if (s != NULL) {
373 lua_pushnumber(L, mp_get_numeric_value(*mp,s,l));
374 return 1;
375 }
376 }
377 lua_pushnumber(L,0);
378 return 1;
379 }
380
381 static int mplib_get_boolean(lua_State * L)
382 {
383 MP *mp = is_mp(L, 1);
384 if (*mp != NULL) {
385 size_t l;
386 const char *s = lua_tolstring(L, 2, &l);
387 if (s != NULL) {
388 lua_pushboolean(L, mp_get_boolean_value(*mp,s,l));
389 return 1;
390 }
391 }
392 lua_pushboolean(L,0);
393 return 1;
394 }
395
396 static int mplib_get_string(lua_State * L)
397 {
398 MP *mp = is_mp(L, 1);
399 if (*mp != NULL) {
400 size_t l;
401 const char *s = lua_tolstring(L, 2, &l);
402 if (s != NULL) {
403 char *r = mp_get_string_value(*mp,s,l) ;
404 if (r != NULL) {
405 lua_pushstring(L, r);
406 return 1;
407 }
408 }
409 }
410 lua_pushstring(L,"");
411 return 1;
289412 }
290413
291414 #define xfree(A) if ((A)!=NULL) { free((A)); A = NULL; }
300423 options->userdata = (void *) L;
301424 options->noninteractive = 1; /* required ! */
302425 options->find_file = mplib_find_file;
426 options->run_script = mplib_run_script;
427 /* options->script_error = mplib_script_error; */
303428 options->print_found_names = 1;
304429 options->ini_version = 1;
305430 if (lua_type(L, 1) == LUA_TTABLE) {
338463 break;
339464 case P_FIND_FILE:
340465 if (mplib_find_file_function(L)) { /* error here */
341 fprintf(stdout,
342 "Invalid arguments to mp.new({find_file=...})\n");
466 fprintf(stdout,"Invalid arguments to mp.new { find_file = ... }\n");
467 }
468 break;
469 case P_RUN_SCRIPT:
470 if (mplib_run_script_function(L)) { /* error here */
471 fprintf(stdout,"Invalid arguments to mp.new { run_script = ... }\n");
472 }
473 break;
474 case P_SCRIPT_ERROR:
475 if (mplib_script_error_function(L)) { /* error here */
476 fprintf(stdout,"Invalid arguments to mp.new { script_error = ... }\n");
343477 }
344478 break;
345479 default:
15661700 }
15671701
15681702
1703
15691704 static const struct luaL_reg mplib_meta[] = {
15701705 {"__gc", mplib_collect},
15711706 {"__tostring", mplib_tostring},
16051740 {"char_depth", mplib_chardepth},
16061741 {"statistics", mplib_statistics},
16071742 {"solve_path", mplib_solve_path},
1743 {"get_numeric", mplib_get_numeric},
1744 {"get_number", mplib_get_numeric},
1745 {"get_boolean", mplib_get_boolean},
1746 {"get_string", mplib_get_string},
16081747 {NULL, NULL} /* sentinel */
16091748 };
16101749
16141753 {"version", mplib_version},
16151754 {"fields", mplib_gr_fields},
16161755 {"pen_info", mplib_gr_peninfo},
1756 {"get_numeric", mplib_get_numeric},
1757 {"get_number", mplib_get_numeric},
1758 {"get_boolean", mplib_get_boolean},
1759 {"get_string", mplib_get_string},
16171760 {NULL, NULL} /* sentinel */
16181761 };
16191762
0 % $Id: mp.w 2005 2014-04-09 10:02:21Z taco $
0 % $Id: mp.w 2037 2014-09-02 14:59:07Z luigi $
11 %
22 % This file is part of MetaPost;
33 % the MetaPost program is in the public domain.
151151 # include <unistd.h> /* for access */
152152 #endif
153153 #include <time.h> /* for struct tm \& co */
154 #include <zlib.h> /* for ZLIB_VERSION, zlibVersion() */
155 #include <png.h> /* for PNG_LIBPNG_VER_STRING, png_libpng_ver */
156 #include <pixman.h> /* for PIXMAN_VERSION_STRING, pixman_version_string() */
157 #include <cairo.h> /* for CAIRO_VERSION_STRING, cairo_version_string() */
158 #include <gmp.h> /* for __GNU_MP_VERSION etc., gmp_version */
159 #include <mpfr.h> /* for MPFR_VERSION_STRING, mpfr_get_version() */
154 #include <zlib.h> /* for |ZLIB_VERSION|, zlibVersion() */
155 #include <png.h> /* for |PNG_LIBPNG_VER_STRING|, |png_libpng_ver| */
156 #include <pixman.h> /* for |PIXMAN_VERSION_STRING|, |pixman_version_string()| */
157 #include <cairo.h> /* for |CAIRO_VERSION_STRING|, |cairo_version_string()| */
158 #include <gmp.h> /* for |gmp_version| */
159 #include <mpfr.h> /* for |MPFR_VERSION_STRING|, |mpfr_get_version()| */
160160 #include "mplib.h"
161161 #include "mplibps.h" /* external header */
162162 #include "mplibsvg.h" /* external header */
516516 set_callback_option (write_ascii_file);
517517 set_callback_option (write_binary_file);
518518 set_callback_option (shipout_backend);
519 set_callback_option (run_script);
519520 if (opt->banner && *(opt->banner)) {
520521 mp->banner = xstrdup (opt->banner);
521522 } else {
702703 @d decr(A) (A)=(A)-1 /* decrease a variable by unity */
703704 @d negate(A) (A)=-(A) /* change the sign of a variable */
704705 @d double(A) (A)=(A)+(A)
705 @d odd(A) ((A)%2==1)
706 @d odd(A) (abs(A)%2==1)
706707
707708 @* The character set.
708709 In order to make \MP\ readily portable to a wide variety of
835836 mp_filetype_text /* first text file for readfrom and writeto primitives */
836837 };
837838 typedef char *(*mp_file_finder) (MP, const char *, const char *, int);
839 typedef char *(*mp_script_runner) (MP, const char *);
838840 typedef void *(*mp_file_opener) (MP, const char *, const char *, int);
839841 typedef char *(*mp_file_reader) (MP, void *, size_t *);
840842 typedef void (*mp_binfile_reader) (MP, void *, void **, size_t *);
847849 @ @<Option variables@>=
848850 mp_file_finder find_file;
849851 mp_file_opener open_file;
852 mp_script_runner run_script;
850853 mp_file_reader read_ascii_file;
851854 mp_binfile_reader read_binary_file;
852855 mp_file_closer close_file;
866869 return mp_strdup (fname);
867870 }
868871 return NULL;
872 }
873
874 @ @c
875 static char *mp_run_script (MP mp, const char *str) {
876 (void) mp;
877 return mp_strdup (str);
869878 }
870879
871880
884893 static void mp_flush_file (MP mp, void *f);
885894 static void mp_write_ascii_file (MP mp, void *f, const char *s);
886895 static void mp_write_binary_file (MP mp, void *f, void *s, size_t t);
896 static char *mp_run_script (MP mp, const char *str);
887897
888898 @ The function to open files can now be very short.
889899
31153125 mp_exit_test, /* premature exit from a loop (\&{exitif}) */
31163126 mp_relax, /* do nothing (\.{\char`\\}) */
31173127 mp_scan_tokens, /* put a string into the input buffer */
3128 mp_runscript, /* put a script result string into the input buffer */
31183129 mp_expand_after, /* look ahead one token */
31193130 mp_defined_macro, /* a macro defined by the user */
31203131 mp_save_command, /* save a list of tokens (\&{save}) */
46634674 return mp_do_id_lookup (mp, mp->frozen_symbols, j, l, insert_new);
46644675 }
46654676
4677 /* see mp_print_sym (mp_sym sym) */
4678
4679 double mp_get_numeric_value (MP mp, const char *s, size_t l) {
4680 char *ss = mp_xstrdup(mp,s);
4681 if (ss) {
4682 mp_sym sym = mp_id_lookup(mp,ss,l,false);
4683 if (sym != NULL) {
4684 if (mp_type(sym->v.data.node) == mp_known) {
4685 mp_xfree (ss);
4686 return number_to_double(sym->v.data.node->data.n) ;
4687 }
4688 }
4689 }
4690 mp_xfree (ss);
4691 return 0 ;
4692 }
4693
4694 int mp_get_boolean_value (MP mp, const char *s, size_t l) {
4695 char *ss = mp_xstrdup(mp,s);
4696 if (ss) {
4697 mp_sym sym = mp_id_lookup(mp,ss,l,false);
4698 if (sym != NULL) {
4699 if (mp_type(sym->v.data.node) == mp_boolean_type) {
4700 if (number_to_boolean (sym->v.data.node->data.n) == mp_true_code) {
4701 mp_xfree(ss);
4702 return 1 ;
4703 }
4704 }
4705 }
4706 }
4707 mp_xfree (ss);
4708 return 0;
4709 }
4710
4711 char *mp_get_string_value (MP mp, const char *s, size_t l) {
4712 char *ss = mp_xstrdup(mp,s);
4713 if (ss) {
4714 mp_sym sym = mp_id_lookup(mp,ss,l,false);
4715 if (sym != NULL) {
4716 if (mp_type(sym->v.data.node) == mp_string_type) {
4717 mp_xfree (ss);
4718 return (char *) sym->v.data.node->data.str->str;
4719 }
4720 }
4721 }
4722 mp_xfree (ss);
4723 return NULL;
4724 }
4725
4726 @ @<Exported function headers@>=
4727 double mp_get_numeric_value(MP mp,const char *s,size_t l);
4728 int mp_get_boolean_value(MP mp,const char *s,size_t l);
4729 char *mp_get_string_value(MP mp,const char *s,size_t l);
46664730
46674731 @ We need to put \MP's ``primitive'' symbolic tokens into the hash
46684732 table, together with their command code (which will be the |eq_type|)
47764840 @:save_}{\&{save} primitive@>;
47774841 mp_primitive (mp, "scantokens", mp_scan_tokens, 0);
47784842 @:scan_tokens_}{\&{scantokens} primitive@>;
4843
4844 mp_primitive (mp, "runscript", mp_runscript, 0);
4845 @:run_script_}{\&{runscript} primitive@>;
4846
47794847 mp_primitive (mp, "shipout", mp_ship_out_command, 0);
47804848 @:ship_out_}{\&{shipout} primitive@>;
47814849 mp_primitive (mp, "skipto", mp_skip_to, 0);
48934961 case mp_scan_tokens:
48944962 mp_print (mp, "scantokens");
48954963 break;
4964 case mp_runscript:
4965 mp_print (mp, "runscript");
4966 break;
48964967 case mp_semicolon:
48974968 mp_print_char (mp, xord (';'));
48984969 break;
49945065 @ @c
49955066 #if DEBUG
49965067 #define value_sym(A) do_get_value_sym(mp,(mp_token_node)(A))
4997 //#define value_number(A) do_get_value_number(mp,(mp_token_node)(A))
5068 /* |#define value_number(A) do_get_value_number(mp,(mp_token_node)(A))| */
49985069 #define value_number(A) ((mp_token_node)(A))->data.n
49995070 #define value_node(A) do_get_value_node(mp,(mp_token_node)(A))
50005071 #define value_str(A) do_get_value_str(mp,(mp_token_node)(A))
1001310084 number_clone (d1, inf_t); /* reuse d1 */
1001410085 number_clone (v1, n); /* v1 = n */
1001510086 number_add (v1, epsilon_t); /* v1 = n1+1 */
10016 set_number_from_div (d1, d1, v1); /* d1 = EL_GORDO / v1 */
10087 set_number_from_div (d1, d1, v1); /* |d1 = EL_GORDO / v1| */
1001710088 if (number_greater (t_tot, d1)) {
1001810089 mp->arith_error = true;
1001910090 check_arith();
1578115852 } else {
1578215853 if (number_greaterequal (absv, coef_bound_k) && mp->watch_coefs) {
1578315854 mp_type (qq) = independent_needing_fix;
15855 /* If we set this , then we can drop (mp_type(pp) == independent_needing_fix && mp->fix_needed) later */
15856 /* set_number_from_scaled (value_number (qq), indep_value(qq)); */
1578415857 mp->fix_needed = true;
1578515858 }
1578615859 set_mp_link (r, (mp_node) s);
1579515868 } else {
1579615869 if (pp == NULL)
1579715870 set_number_to_neg_inf(v);
15798 else if (mp_type(pp) == mp_independent)
15871 else if (mp_type(pp) == mp_independent || (mp_type(pp) == independent_needing_fix && mp->fix_needed))
1579915872 set_number_from_scaled(v, indep_value(pp));
1580015873 else
1580115874 number_clone (v, value_number (pp));
1580215875 if (qq == NULL)
1580315876 set_number_to_neg_inf(vv);
15804 else if (mp_type(qq) == mp_independent)
15877 else if (mp_type(qq) == mp_independent || (mp_type(qq) == independent_needing_fix && mp->fix_needed))
1580515878 set_number_from_scaled(vv, indep_value(qq));
1580615879 else
1580715880 number_clone (vv, value_number (qq));
1592415997 } else {
1592515998 if (number_greaterequal(test, coef_bound_k) && mp->watch_coefs) {
1592615999 mp_type (qq) = independent_needing_fix;
16000 /* If we set this , then we can drop (mp_type(pp) == independent_needing_fix && mp->fix_needed) later */
16001 /* set_number_from_scaled (value_number (qq), indep_value(qq)); */
1592716002 mp->fix_needed = true;
1592816003 }
1592916004 set_mp_link (r, (mp_node) s);
1593716012 } else {
1593816013 if (pp == NULL)
1593916014 set_number_to_zero (v);
15940 else if (mp_type(pp) == mp_independent)
16015 else if (mp_type(pp) == mp_independent || (mp_type(pp) == independent_needing_fix && mp->fix_needed))
1594116016 set_number_from_scaled (v, indep_value(pp));
1594216017 else
1594316018 number_clone (v, value_number (pp));
1594416019 if (qq == NULL)
1594516020 set_number_to_zero (vv);
15946 else if (mp_type(qq) == mp_independent)
16021 else if (mp_type(qq) == mp_independent || (mp_type(qq) == independent_needing_fix && mp->fix_needed))
1594716022 set_number_from_scaled (vv, indep_value(qq));
1594816023 else
1594916024 number_clone (vv, value_number (qq));
1882318898 n = 0;
1882418899 set_eq_type (mp->warning_info, mp_defined_macro);
1882518900 set_equiv_node (mp->warning_info, q);
18826 } else { /* var_def */
18901 } else { /* |var_def| */
1882718902 p = mp_scan_declared_variable (mp);
1882818903 mp_flush_variable (mp, equiv_node (mp_sym_sym (p)), mp_link (p), true);
1882918904 mp->warning_info_node = mp_find_variable (mp, p);
1897519050 Only a few command codes |<min_command| can possibly be returned by
1897619051 |get_t_next|; in increasing order, they are
1897719052 |if_test|, |fi_or_else|, |input|, |iteration|, |repeat_loop|,
18978 |exit_test|, |relax|, |scan_tokens|, |expand_after|, and |defined_macro|.
19053 |exit_test|, |relax|, |scan_tokens|, |run_script|, |expand_after|, and |defined_macro|.
1897919054
1898019055 \MP\ usually gets the next token of input by saying |get_x_next|. This is
1898119056 like |get_t_next| except that it keeps getting more tokens until
1909119166 case mp_scan_tokens:
1909219167 @<Put a string into the input buffer@>;
1909319168 break;
19169 case mp_runscript:
19170 @<Put a script result string into the input buffer@>;
19171 break;
1909419172 case mp_defined_macro:
1909519173 mp_macro_call (mp, cur_mod_node(), NULL, cur_sym());
1909619174 break;
1924719325 }
1924819326 }
1924919327
19328 @ @<Put a script result string into the input buffer@>=
19329 {
19330 mp_get_x_next (mp);
19331 mp_scan_primary (mp);
19332 if (mp->cur_exp.type != mp_string_type) {
19333 mp_value new_expr;
19334 const char *hlp[] = {
19335 "I'm going to flush this expression, since",
19336 "runscript should be followed by a known string.",
19337 NULL };
19338 memset(&new_expr,0,sizeof(mp_value));
19339 new_number(new_expr.data.n);
19340 mp_disp_err (mp, NULL);
19341 mp_back_error (mp, "Not a string", hlp, true);
19342 @.Not a string@>;
19343 mp_get_x_next (mp);
19344 mp_flush_cur_exp (mp, new_expr);
19345 } else {
19346 mp_back_input (mp);
19347 if (cur_exp_str ()->len > 0) {
19348 mp_value new_expr;
19349 char *s = mp->run_script(mp,(const char*) cur_exp_str()->str) ;
19350 if (s != NULL) {
19351 size_t size = strlen(s);
19352 memset(&new_expr,0,sizeof(mp_value));
19353 new_number(new_expr.data.n);
19354 mp_begin_file_reading (mp);
19355 name = is_scantok;
19356 mp->last = mp->first;
19357 k = mp->first + size;
19358 if (k >= mp->max_buf_stack) {
19359 while (k >= mp->buf_size) {
19360 mp_reallocate_buffer (mp, (mp->buf_size + (mp->buf_size / 4)));
19361 }
19362 mp->max_buf_stack = k + 1;
19363 }
19364 limit = (halfword) k;
19365 (void) memcpy ((mp->buffer + mp->first), s, size);
19366 free(s);
19367 mp->buffer[limit] = xord ('%');
19368 mp->first = (size_t) (limit + 1);
19369 loc = start;
19370 mp_flush_cur_exp (mp, new_expr);
19371 }
19372 }
19373 }
19374 }
1925019375
1925119376 @ @<Pretend we're reading a new one-line file@>=
1925219377 {
2094821073
2094921074 @<Allocate or ...@>=
2095021075 mp->job_name = mp_xstrdup (mp, opt->job_name);
20951 /*
21076 /*|
2095221077 if (mp->job_name != NULL) {
2095321078 char *s = mp->job_name + strlen (mp->job_name);
2095421079 while (s > mp->job_name) {
2095821083 s--;
2095921084 }
2096021085 }
20961 */
21086 |*/
2096221087 if (opt->noninteractive) {
2096321088 if (mp->job_name == NULL)
2096421089 mp->job_name = mp_xstrdup (mp, mp->mem_name);
2693227057 set_cur_exp_node ((mp_node) qq);
2693327058 mp->cur_exp.type = mp_type (p);
2693427059 mp_name_type (qq) = mp_capsule;
26935 /* clang: never read: q = (mp_node) qq; */
27060 /* clang: never read: |q = (mp_node) qq;| */
2693627061 }
2693727062 set_dep_list (qq, dep_list ((mp_value_node) p));
2693827063 mp_type (qq) = mp_type (p);
2827128396 if (mp_left_type (p) == mp_endpoint) {
2827228397 set_number_to_zero(v);
2827328398 } else {
28274 /* v = n - 1 - ((-v - 1) % n)
28275 == - ((-v - 1) % n) - 1 + n */
28399 /* |v = n - 1 - ((-v - 1) % n)
28400 == - ((-v - 1) % n) - 1 + n| */
2827628401 number_negate (v);
2827728402 number_add_scaled (v, -1);
2827828403 number_modulo (v, n);
2952629651 return s;
2952729652 }
2952829653 static void mp_append_string (MP mp, mp_stream * a, const char *b) {
29529 size_t l = strlen (b) + 1; /* don't forget the trailing '\0' */
29654 size_t l = strlen (b) + 1; /* don't forget the trailing |'\0'| */
2953029655 if ((a->used + l) >= a->size) {
2953129656 a->size += 256 + (a->size) / 5 + l;
2953229657 a->data = xrealloc (a->data, a->size, 1);
2980229927 return mp_strdup (metapost_version);
2980329928 }
2980429929 void mp_show_library_versions (void) {
29805 fprintf(stdout, "Compiled with mpfr %s; using %s\n", MPFR_VERSION_STRING, mpfr_get_version());
29806 fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n",
29807 __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL, gmp_version);
2980829930 fprintf(stdout, "Compiled with cairo %s; using %s\n", CAIRO_VERSION_STRING, cairo_version_string());
2980929931 fprintf(stdout, "Compiled with pixman %s; using %s\n", PIXMAN_VERSION_STRING, pixman_version_string());
2981029932 fprintf(stdout, "Compiled with libpng %s; using %s\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
29811 fprintf(stdout, "Compiled with zlib %s; using %s\n\n", ZLIB_VERSION, zlibVersion());
29933 fprintf(stdout, "Compiled with zlib %s; using %s\n", ZLIB_VERSION, zlibVersion());
29934 fprintf(stdout, "Compiled with mpfr %s; using %s\n", MPFR_VERSION_STRING, mpfr_get_version());
29935 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);
2981229936 }
2981329937
2981429938 @ @<Exported function headers@>=
3040130525 if (cur_sym() != NULL)
3040230526 if (cur_sym_mod() == 0)
3040330527 if (cur_cmd() == mp_tag_token)
30404 if (cur_mod() != 0) {
30528 if (cur_mod() != 0 || cur_mod_node()!=NULL) {
3040530529 mp_disp_var (mp, cur_mod_node());
3040630530 goto DONE;
3040730531 }
3275132875 mp->header_byte[6] = (char) ((dd / 16) % 256);
3275232876 mp->header_byte[7] = (char) ((dd % 16) * 16);
3275332877 }
32754 /* mp->max_tfm_dimen = 16 * internal_value (mp_design_size) - 1 - internal_value (mp_design_size) / 010000000 */
32878 /* |mp->max_tfm_dimen = 16 * internal_value (mp_design_size) - 1 - internal_value (mp_design_size) / 010000000| */
3275532879 {
3275632880 mp_number secondpart;
3275732881 new_number (secondpart);
3317033294 for (k = 0; k <= 255; k++) {
3317133295 /* These are disabled for now following a bug-report about double free
3317233296 errors. TO BE FIXED, bug tracker id 831 */
33173 /*
33297 /*|
3317433298 mp_free_value_node (mp, mp->tfm_width[k]);
3317533299 mp_free_value_node (mp, mp->tfm_height[k]);
3317633300 mp_free_value_node (mp, mp->tfm_depth[k]);
3317733301 mp_free_value_node (mp, mp->tfm_ital_corr[k]);
33178 */
33302 |*/
3317933303 }
3318033304
3318133305 xfree (mp->font_info);
3441434538 @c
3441534539 void mp_final_cleanup (MP mp) {
3441634540 /* -Wunused: integer c; */ /* 0 for \&{end}, 1 for \&{dump} */
34417 /* clang: never read: c = cur_mod(); */
34541 /* clang: never read: |c = cur_mod();| */
3441834542 if (mp->job_name == NULL)
3441934543 mp_open_log_file (mp);
3442034544 while (mp->input_ptr > 0) {
0 % $Id: mpmath.w 1959 2014-03-11 11:19:43Z taco $
0 % $Id: mpmath.w 2037 2014-09-02 14:59:07Z luigi $
11 %
22 % This file is part of MetaPost;
33 % the MetaPost program is in the public domain.
16801680 @d one_eighty_deg 01320000000 /* $180\cdot2^{20}$, represents $180^\circ$ */
16811681 @d three_sixty_deg 02640000000 /* $360\cdot2^{20}$, represents $360^\circ$ */
16821682
1683 @d odd(A) ((A)%2==1)
1683 @d odd(A) (abs(A)%2==1)
16841684
16851685 @ Compute a multiple of the sine and cosine
16861686
588588
589589 @
590590
591 @d odd(A) ((A)%2==1)
591 @d odd(A) (abs(A)%2==1)
592592
593593 @c
594594 int mp_number_to_int(mp_number A) {
758758
759759 @
760760
761 @d odd(A) ((A)%2==1)
761 @d odd(A) (abs(A)%2==1)
762762
763763 @c
764764 int mp_number_to_int(mp_number A) {
0 % $Id: mpmathdouble.w 1959 2014-03-11 11:19:43Z taco $
0 % $Id: mpmathdouble.w 2037 2014-09-02 14:59:07Z luigi $
11 %
22 % This file is part of MetaPost;
33 % the MetaPost program is in the public domain.
11951195 @d one_eighty_deg (180.0*angle_multiplier)
11961196 @d three_sixty_deg (360.0*angle_multiplier)
11971197
1198 @d odd(A) ((A)%2==1)
1198 @d odd(A) (abs(A)%2==1)
11991199
12001200 @ Compute a multiple of the sine and cosine
12011201
0 % $Id: mpost.w 1955 2014-03-10 10:30:30Z taco $
0 % $Id: mpost.w 2007 2014-04-10 11:13:03Z taco $
11 %
22 % This file is part of MetaPost;
33 % the MetaPost program is in the public domain.
10261026 "For more information about these matters, see the file\n"
10271027 "COPYING.LESSER or <http://gnu.org/licenses/lgpl.html>.\n"
10281028 "Original author of MetaPost: John Hobby.\n"
1029 "Author of the CWEB MetaPost: Taco Hoekwater.\n\n"
1029 "Author of the CWEB MetaPost: Taco Hoekwater.\n"
1030 "Current maintainer of MetaPost: Luigi Scarso.\n\n"
10301031 );
10311032 mpost_xfree(s);
10321033 if (!dvitomp_only) {
0 % $Id: mpxout.w 1808 2012-12-10 08:57:11Z taco $
0 % $Id: mpxout.w 2031 2014-06-24 13:38:58Z luigi $
11 % This file is part of MetaPost;
22 % the MetaPost program is in the public domain.
33 % See the <Show version...> code in mpost.w for more info.
0 % $Id: psout.w 2009 2014-04-23 07:09:51Z taco $
0 % $Id: psout.w 2037 2014-09-02 14:59:07Z luigi $
11 % This file is part of MetaPost;
22 % the MetaPost program is in the public domain.
33 % See the <Show version...> code in mpost.w for more info.
5151 @d incr(A) (A)=(A)+1 /* increase a variable by unity */
5252 @d decr(A) (A)=(A)-1 /* decrease a variable by unity */
5353 @d negate(A) (A)=-(A) /* change the sign of a variable */
54 @d odd(A) ((A)%2==1)
54 @d odd(A) (abs(A)%2==1)
5555 @d max_quarterword 0x3FFF /* largest allowable value in a |quarterword| */
5656
5757 @c