diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2009-05-27 13:36:42 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2009-05-27 13:36:42 +0000 |
commit | a26d67f7f3f19cd6cbc3d16a94bc75a4513f09df (patch) | |
tree | 3cc0fc448d632b6a70ef13c799bd30759a132f01 /Build/source/texk/web2c/mplibdir | |
parent | 548c801baf05f4a158b42c8de28378a2a44bfa89 (diff) |
Here are the sources for metapost 1.201
git-svn-id: svn://tug.org/texlive/trunk@13493 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/mplibdir')
-rw-r--r-- | Build/source/texk/web2c/mplibdir/avl.c | 1 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/lmplib.c | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/memio.w | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mp.w | 87 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mpost.w | 223 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/mpxout.w | 62 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/psout.w | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/svgout.w | 2 | ||||
-rw-r--r-- | Build/source/texk/web2c/mplibdir/tfmin.w | 2 |
9 files changed, 284 insertions, 105 deletions
diff --git a/Build/source/texk/web2c/mplibdir/avl.c b/Build/source/texk/web2c/mplibdir/avl.c index a8421d4c93d..4d05baacb4e 100644 --- a/Build/source/texk/web2c/mplibdir/avl.c +++ b/Build/source/texk/web2c/mplibdir/avl.c @@ -20,6 +20,7 @@ avl_default_item_copy (const void *item) void * avl_default_item_dispose (void *item) { + (void)item; /* for -Wall */ return (void *) NULL; } diff --git a/Build/source/texk/web2c/mplibdir/lmplib.c b/Build/source/texk/web2c/mplibdir/lmplib.c index b5e6959c3ea..40ca908448b 100644 --- a/Build/source/texk/web2c/mplibdir/lmplib.c +++ b/Build/source/texk/web2c/mplibdir/lmplib.c @@ -1,6 +1,6 @@ /* lmplib.c - Copyright 2006-2008 Taco Hoekwater <taco@luatex.org> + Copyright 2006-2009 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. diff --git a/Build/source/texk/web2c/mplibdir/memio.w b/Build/source/texk/web2c/mplibdir/memio.w index f5492f713b5..f487a4adc2b 100644 --- a/Build/source/texk/web2c/mplibdir/memio.w +++ b/Build/source/texk/web2c/mplibdir/memio.w @@ -1,6 +1,6 @@ % $Id: psout.w 616 2008-07-09 14:05:55Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w index d8a89517356..cd3e5ee75c0 100644 --- a/Build/source/texk/web2c/mplibdir/mp.w +++ b/Build/source/texk/web2c/mplibdir/mp.w @@ -1,6 +1,6 @@ -% $Id: mp.w 1016 2009-05-09 12:51:56Z taco $ +% $Id: mp.w 1061 2009-05-27 13:01:37Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by @@ -89,13 +89,13 @@ 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.200" /* printed when \MP\ starts */ +@d default_banner "This is MetaPost, Version 1.201" /* printed when \MP\ starts */ @d true 1 @d false 0 @(mpmp.h@>= -#define metapost_version "1.200" -#define metapost_magic (('M'*256) + 'P')*65536 + 1200 +#define metapost_version "1.201" +#define metapost_magic (('M'*256) + 'P')*65536 + 1201 #define metapost_old_magic (('M'*256) + 'P')*65536 + 1080 @ The external library header for \MP\ is |mplib.h|. It contains a @@ -877,7 +877,6 @@ static boolean mp_input_ln (MP mp, void *f ) { } } memcpy((mp->buffer+mp->first),s,size); - /* while ( mp->buffer[mp->last]==' ' ) mp->last--; */ } free(s); return true; @@ -13805,8 +13804,8 @@ actions. { mp->input_ptr=0; mp->max_in_stack=0; mp->in_open=0; mp->open_parens=0; mp->max_buf_stack=0; mp->param_ptr=0; mp->max_param_stack=0; - mp->first=1; - start=1; iindex=0; line=0; name=is_term; + mp->first=0; + start=0; iindex=0; line=0; name=is_term; mp->mpx_name[0]=absent; mp->force_eof=false; if ( ! mp_init_terminal(mp) ) mp_jump_out(mp); @@ -14926,6 +14925,36 @@ static void mp_begin_iteration (MP mp); static void mp_resume_iteration (MP mp); static void mp_stop_iteration (MP mp); +@ A recursion depth counter is used to discover infinite recursions. +(Near) infinite recursion is a problem because it translates into +C function calls that eat up the available call stack. A better solution +would be to depend on signal trapping, but that is problematic when +Metapost is used as a library. + +@<Global...@>= +int expand_depth_count; /* current expansion depth */ +int expand_depth; /* current expansion depth */ + +@ The limit is set at |10000|, which should be enough to allow +normal usages of metapost while preventing the most obvious +crashes on most all operating systems, but the value can be +raised if the runtime system allows a larger C stack. +@^system dependencies@> + +@<Set initial...@>= +mp->expand_depth=10000; + +@ Even better would be if the system allows +discovery of the amount of space available on the call stack. +@^system dependencies@> + +@c +static void mp_check_expansion_depth (MP mp ){ + if (mp->expand_depth_count>=mp->expand_depth) { + mp_overflow(mp, "expansion depth", mp->expand_depth); + } +} + @ An auxiliary subroutine called |expand| is used by |get_x_next| when it has to do exotic expansion commands. @@ -14934,6 +14963,8 @@ static void mp_expand (MP mp) { pointer p; /* for list manipulation */ size_t k; /* something that we hope is |<=buf_size| */ pool_pointer j; /* index into |str_pool| */ + mp->expand_depth_count++; + mp_check_expansion_depth(mp); if ( mp->internal[mp_tracing_commands]>unity ) if ( mp->cur_cmd!=defined_macro ) show_cur_cmd_mod; @@ -14972,6 +15003,7 @@ static void mp_expand (MP mp) { mp_macro_call(mp, mp->cur_mod,null,mp->cur_sym); break; }; /* there are no other cases */ + mp->expand_depth_count--; } @ @<Scold the user...@>= @@ -16528,6 +16560,8 @@ it catch up to what has previously been printed on the terminal. integer m; /* the current month */ const char *months="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"; /* abbreviations of month names */ + if (mp->log_opened) + return; old_setting=mp->selector; if ( mp->job_name==NULL ) { mp->job_name=xstrdup("mpout"); @@ -16546,7 +16580,7 @@ it catch up to what has previously been printed on the terminal. mp_print_nl(mp, "**"); @.**@> l=mp->input_stack[0].limit_field-1; /* last position of first line */ - for (k=1;k<=l;k++) mp_print_str(mp, mp->buffer[k]); + for (k=0;k<=l;k++) mp_print_str(mp, mp->buffer[k]); mp_print_ln(mp); /* now the transcript file contains the first line of input */ } mp->selector=old_setting+2; /* |log_only| or |term_and_log| */ @@ -16632,6 +16666,8 @@ when an `\.{input}' command is being processed. if ( mp->job_name==NULL ) { mp->job_name=xstrdup(mp->cur_name); @<Fix up |mp->internal[mp_job_name]|@>; + } + if (!mp->log_opened) { mp_open_log_file(mp); } /* |open_log_file| doesn't |show_context|, so |limit| and |loc| needn't be set to meaningful values yet */ @@ -16686,7 +16722,7 @@ with the current input file. @c void mp_start_mpx_input (MP mp) { char *origname = NULL; /* a copy of nameoffile */ - mp_pack_file_name(mp, in_name, in_area, ".mpx"); + mp_pack_file_name(mp, in_name, "", ".mpx"); @<Try to make sure |name_of_file| refers to a valid \.{MPX} file and |goto not_found| if there is a problem@>; mp_begin_file_reading(mp); @@ -19302,13 +19338,19 @@ static void mp_pair_to_path (MP mp) { mp->cur_type=mp_path_type; } -@ -@d pict_color_type(A) ((mp_link(dummy_loc(mp->cur_exp))!=null) && - (has_color(mp_link(dummy_loc(mp->cur_exp)))) && - ((mp_color_model(mp_link(dummy_loc(mp->cur_exp)))==A) - || - ((mp_color_model(mp_link(dummy_loc(mp->cur_exp)))==mp_uninitialized_model) && - (mp->internal[mp_default_color_model]/unity)==(A)))) +@ This complicated if test makes sure that any |bounds| or |clip| +picture objects that get passed into \&{within} do not raise an +error when queried using the color part primitives (this is needed +for backward compatibility) . + +@d cur_pic_item mp_link(dummy_loc(mp->cur_exp)) +@d pict_color_type(A) ((cur_pic_item!=null) && + ((!has_color(cur_pic_item)) + || + (((mp_color_model(cur_pic_item)==A) + || + ((mp_color_model(cur_pic_item)==mp_uninitialized_model) && + (mp->internal[mp_default_color_model]/unity)==(A)))))) @<Additional cases of unary operators@>= case x_part: @@ -25889,7 +25931,14 @@ static char *mp_set_output_file_name (MP mp, integer c) { if (text(p)>0 && length(text(p))==l && mp_str_eq_cstr(mp, text(p),id)) { if (eq_type(p)==internal_quantity) { - mp_append_to_template(mp,f,equiv(p)); + if (equiv(p)==mp_output_template) { + char err[256]; + mp_snprintf(err,256, + "The appearance of outputtemplate inside outputtemplate is ignored."); + mp_warn(mp,err); + } else { + mp_append_to_template(mp,f,equiv(p)); + } } else { char err[256]; mp_snprintf(err,256, @@ -26303,6 +26352,8 @@ pointer mp_gr_unexport(MP mp, struct mp_edge_object *hh) { } else { mp_link(pn) = mp_link(ph); mp_link(ph) = pn; + if (ph==pt) + pt=pn; } } break; diff --git a/Build/source/texk/web2c/mplibdir/mpost.w b/Build/source/texk/web2c/mplibdir/mpost.w index f0f19cf105a..395794dec16 100644 --- a/Build/source/texk/web2c/mplibdir/mpost.w +++ b/Build/source/texk/web2c/mplibdir/mpost.w @@ -1,6 +1,6 @@ -% $Id: mpost.w 941 2009-04-19 13:13:56Z taco $ +% $Id: mpost.w 1061 2009-05-27 13:01:37Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by @@ -44,6 +44,9 @@ have our customary command-line interface. #elif defined (HAVE_SYS_TIMEB_H) #include <sys/timeb.h> #endif +#if HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif #include <mplib.h> #include <mpxout.h> #ifdef WIN32 @@ -62,6 +65,7 @@ static boolean recorder_enabled = false; static string recorder_name = NULL; static FILE *recorder_file = NULL; static char *job_name = NULL; +static char *job_area = NULL; static int dvitomp_only = 0; @ Allocating a bit of memory, with error detection: @@ -206,9 +210,13 @@ static string normalize_quotes (const char *name, const char *mesg) { @c void recorder_start(char *jobname) { char cwd[1024]; - recorder_name = (string)xmalloc((unsigned int)(strlen(jobname)+5)); - strcpy(recorder_name, jobname); - strcat(recorder_name, ".fls"); + if (jobname==NULL) { + recorder_name = mpost_xstrdup("mpout.fls"); + } else { + recorder_name = (string)xmalloc((unsigned int)(strlen(jobname)+5)); + strcpy(recorder_name, jobname); + strcat(recorder_name, ".fls"); + } recorder_file = xfopen(recorder_name, FOPEN_W_MODE); if(GETCWD(cwd,1020) != NULL) { @@ -257,18 +265,52 @@ void recorder_start(char *jobname) { static int mpost_run_make_mpx (MP mp, char *mpname, char *mpxname) { int ret; char *cnf_cmd = kpse_var_value ("MPXCOMMAND"); - if (cnf_cmd != NULL && (strcmp (cnf_cmd, "0")==0)) { /* If they turned off this feature, just return success. */ ret = 0; - } else { /* We will invoke something. Compile-time default if nothing else. */ - char *cmd; - char *tmp = normalize_quotes(mpname, "mpname"); - char *qmpname = kpse_find_file (tmp,kpse_mp_format, true); - char *qmpxname = normalize_quotes(mpxname, "mpxname"); + char *cmd, *tmp, *qmpname, *qmpxname; + if (job_area != NULL) { + char *l = mpost_xmalloc(strlen(mpname)+strlen(job_area)+1); + strcpy(l, job_area); + strcat(l, mpname); + tmp = normalize_quotes(l, "mpname"); + mpost_xfree(l); + } else { + tmp = normalize_quotes(mpname, "mpname"); + } + qmpname = kpse_find_file (tmp,kpse_mp_format, true); mpost_xfree(tmp); + if (qmpname != NULL && job_area != NULL) { + /* if there is a usable mpx file in the source path already, + simply use that and return true */ + char *l = mpost_xmalloc(strlen(qmpname)+2); + strcpy(l, qmpname); + strcat(l, "x"); + qmpxname = l; + if (qmpxname) { +#if HAVE_SYS_STAT_H + struct stat source_stat, target_stat; + int nothingtodo = 0; + if ((stat(qmpxname, &target_stat) >= 0) && + (stat(qmpname, &source_stat) >= 0)) { +#if HAVE_ST_MTIM + if (source_stat.st_mtim.tv_sec <= target_stat.st_mtim.tv_sec || + (source_stat.st_mtim.tv_sec == target_stat.st_mtim.tv_sec && + source_stat.st_mtim.tv_nsec <= target_stat.st_mtim.tv_nsec)) + nothingtodo = 1; +#else + if (source_stat.st_mtime <= target_stat.st_mtime) + nothingtodo = 1; +#endif + } + if (nothingtodo == 1) + return 1; /* success ! */ +#endif + } + } + qmpxname = normalize_quotes(mpxname, "mpxname"); if (cnf_cmd!=NULL && (strcmp (cnf_cmd, "1")!=0)) { if (mp_troff_mode(mp)!=0) cmd = concatn (cnf_cmd, " -troff ", @@ -432,34 +474,74 @@ static char *mpost_find_file(MP mp, const char *fname, const char *fmode, int ft (void)mp; s = NULL; if (fmode[0]=='r') { + if ((job_area != NULL) && + (ftype>=mp_filetype_text || ftype==mp_filetype_program )) { + char *f = mpost_xmalloc(strlen(job_area)+strlen(fname)+1); + strcpy(f,job_area); + strcat(f,fname); + if (ftype>=mp_filetype_text) { + s = kpse_find_file (f, kpse_mp_format, 0); + } else { + l = strlen(f); + if (l>3 && strcmp(f+l-3,".mf")==0) { + s = kpse_find_file (f,kpse_mf_format, 0); +#if HAVE_SYS_STAT_H + } else if (l>4 && strcmp(f+l-4,".mpx")==0) { + struct stat source_stat, target_stat; + char *mpname = mpost_xstrdup(f); + *(mpname + strlen(mpname) -1 ) = '\0'; + printf("statting %s and %s\n", mpname, f); + if ((stat(f, &target_stat) >= 0) && + (stat(mpname, &source_stat) >= 0)) { +#if HAVE_ST_MTIM + if (source_stat.st_mtim.tv_sec <= target_stat.st_mtim.tv_sec || + (source_stat.st_mtim.tv_sec == target_stat.st_mtim.tv_sec && + source_stat.st_mtim.tv_nsec <= target_stat.st_mtim.tv_nsec)) + s = mpost_xstrdup(f); +#else + if (source_stat.st_mtime <= target_stat.st_mtime) + s = mpost_xstrdup(f); +#endif + } + mpost_xfree(mpname); +#endif + } else { + s = kpse_find_file (f,kpse_mp_format, 0); + } + } + mpost_xfree(f); + if (s!=NULL) { + return s; + } + } if (ftype>=mp_filetype_text) { s = kpse_find_file (fname, kpse_mp_format, 0); } else { - switch(ftype) { - case mp_filetype_program: - l = strlen(fname); - if (l>3 && strcmp(fname+l-3,".mf")==0) { - s = kpse_find_file (fname, kpse_mf_format, 0); - } else { - s = kpse_find_file (fname, kpse_mp_format, 0); + switch(ftype) { + case mp_filetype_program: + l = strlen(fname); + if (l>3 && strcmp(fname+l-3,".mf")==0) { + s = kpse_find_file (fname, kpse_mf_format, 0); + } else { + s = kpse_find_file (fname, kpse_mp_format, 0); + } + break; + case mp_filetype_memfile: + s = kpse_find_file (fname, kpse_mem_format, 1); + break; + case mp_filetype_metrics: + s = kpse_find_file (fname, kpse_tfm_format, 0); + break; + case mp_filetype_fontmap: + s = kpse_find_file (fname, kpse_fontmap_format, 0); + break; + case mp_filetype_font: + s = kpse_find_file (fname, kpse_type1_format, 0); + break; + case mp_filetype_encoding: + s = kpse_find_file (fname, kpse_enc_format, 0); + break; } - break; - case mp_filetype_memfile: - s = kpse_find_file (fname, kpse_mem_format, 1); - break; - case mp_filetype_metrics: - s = kpse_find_file (fname, kpse_tfm_format, 0); - break; - case mp_filetype_fontmap: - s = kpse_find_file (fname, kpse_fontmap_format, 0); - break; - case mp_filetype_font: - s = kpse_find_file (fname, kpse_type1_format, 0); - break; - case mp_filetype_encoding: - s = kpse_find_file (fname, kpse_enc_format, 0); - break; - } } } else { if (fname!=NULL) @@ -507,7 +589,7 @@ void internal_set_option(const char *opt) { struct set_list_item *itm; char *s, *v; int isstring = 0; - s = xstrdup(opt) ; + s = mpost_xstrdup(opt) ; v = strstr(s,"=") ; if (v==NULL) { v="1"; @@ -797,7 +879,7 @@ if (dvitomp_only) else fprintf(stdout, "\n" "MetaPost %s\n", s); fprintf(stdout, -"Copyright 2008 AT&T Bell Laboratories.\n" +"Copyright 2009 AT&T Bell Laboratories.\n" "There is NO warranty. Redistribution of this software is\n" "covered by the terms of both the MetaPost copyright and\n" "the Lesser GNU Lesser General Public License.\n" @@ -977,10 +1059,21 @@ if ( options->mem_name == NULL ) options->mem_name = mpost_xstrdup(kpse_program_name); -@ The jobname needs to be known for the recorder to work. +@ The job name needs to be known for the recorder to work, +so we have to fix up |job_name| and |job_area|. If there +was a \.{--jobname} on the command line, we have to reset +the options structure as well. + +@d IS_DIR_SEP(c) (c=='/' || c=='\\') @<Discover the job name@>= -if ( options->job_name == NULL ) { +{ +char *tmp_job = NULL; +if (options->job_name != NULL) { + tmp_job = mpost_xstrdup(options->job_name); + mpost_xfree(options->job_name); + options->job_name = NULL; +} else { char *m = NULL; /* head of potential |job_name| */ char *n = NULL; /* a moving pointer */ if (options->command_line != NULL){ @@ -990,7 +1083,7 @@ if ( options->job_name == NULL ) { while (*n != '\0' && *n != ' ') n++; if (n>m) { *n='\0'; - job_name = mpost_xstrdup(m); + tmp_job = mpost_xstrdup(m); } } else { /* this is still not perfect, but better */ char *mm = strstr(m,"input "); @@ -1000,32 +1093,54 @@ if ( options->job_name == NULL ) { while (*n != '\0' && *n != ' ' && *n!=';') n++; if (n>mm) { *n='\0'; - job_name = mpost_xstrdup(mm); + tmp_job = mpost_xstrdup(mm); } } } free(m); } - if (job_name == NULL) { + if (tmp_job == NULL) { if (options->ini_version == 1 && options->mem_name != NULL) { - job_name = mpost_xstrdup(options->mem_name); + tmp_job = mpost_xstrdup(options->mem_name); } } - if (job_name == NULL) { - job_name = mpost_xstrdup("mpout"); + if (tmp_job == NULL) { + tmp_job = mpost_xstrdup("mpout"); } else { - size_t i = strlen(job_name); + size_t i = strlen(tmp_job); if (i>3 - && *(job_name+i-3)=='.' - && *(job_name+i-2)=='m' - && *(job_name+i-1)=='p') - *(job_name+i-3)='\0'; + && *(tmp_job+i-3)=='.' + && *(tmp_job+i-2)=='m' + && *(tmp_job+i-1)=='p') + *(tmp_job+i-3)='\0'; } - options->job_name = job_name; -} else { - job_name = mpost_xstrdup(options->job_name); } +/* now split |tmp_job| into |job_area| and |job_name| */ +{ + char *s = tmp_job + strlen(tmp_job); + if (!IS_DIR_SEP(*s)) { /* just in case */ + while (s>tmp_job) { + if (IS_DIR_SEP(*s)) { + break; + } + s--; + } + if (s>tmp_job) { + /* there was a directory part */ + if (strlen(s)>1) { + job_name = mpost_xstrdup((s+1)); + *(s+1) = '\0'; + job_area = tmp_job; + } + } else { + job_name = tmp_job; + /* |job_area| stays NULL */ + } + } +} +} +options->job_name = job_name; @ Now this is really it: \MP\ starts and ends here. @@ -1071,7 +1186,7 @@ int main (int argc, char **argv) { /* |start_here| */ if (!nokpse) { kpse_set_program_enabled (kpse_mem_format, MAKE_TEX_FMT_BY_DEFAULT, kpse_src_compile); - kpse_set_program_name("mpost", user_progname); + kpse_set_program_name(argv[0], user_progname); } @= /*@@=nullpass@@*/ @> if(putenv((char *)"engine=metapost")) diff --git a/Build/source/texk/web2c/mplibdir/mpxout.w b/Build/source/texk/web2c/mplibdir/mpxout.w index 963237492d1..c8476685476 100644 --- a/Build/source/texk/web2c/mplibdir/mpxout.w +++ b/Build/source/texk/web2c/mplibdir/mpxout.w @@ -1,6 +1,6 @@ -% $Id: mpxout.w 1024 2009-05-11 08:22:49Z taco $
+% $Id: mpxout.w 1061 2009-05-27 13:01:37Z taco $
%
-% Copyright 2008 Taco Hoekwater.
+% Copyright 2008-2009 Taco Hoekwater.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License as published by
@@ -351,7 +351,7 @@ static int mpx_newer(char *source, char *target) { #if HAVE_ST_MTIM
if (source_stat.st_mtim.tv_sec > target_stat.st_mtim.tv_sec ||
(source_stat.st_mtim.tv_sec == target_stat.st_mtim.tv_sec &&
- source_stat.st_mtim.tv_nsec >+ target_stat.st_mtim.tv_nsec))
+ source_stat.st_mtim.tv_nsec >= target_stat.st_mtim.tv_nsec))
return 0;
#else
if (source_stat.st_mtime >= target_stat.st_mtime)
@@ -595,9 +595,12 @@ static void mpx_mpto(MPX mpx, char *tmpname, char *mptexpre) { if (mode==mpx_tex_mode) {
FILE *fr;
if ((fr = fopen(mptexpre, "r"))!= NULL) {
- while (mpx_getline(mpx, fr) != NULL)
- fputs(mpx->buf, outfile);
- mpx_fclose(mpx,fr);
+ size_t i;
+ char buf[512];
+ while ((i=fread((void *)buf, 1, 512 , fr))>0) {
+ fwrite((void *)buf,1, i, outfile);
+ }
+ mpx_fclose(mpx,fr);
}
}
mpx->mpfile = mpx_xfopen(mpx,mpname, "r");
@@ -3932,28 +3935,37 @@ static char *mpx_print_command (MPX mpx, int cmdlength, char **cmdline) { systems.
@c
-static int do_spawn (MPX mpx, char *cmd, char **options) {
+static int do_spawn (MPX mpx, char *icmd, char **options) {
#ifndef WIN32
- int retcode = -1;
- pid_t child;
- child = fork();
- if (child < 0)
- mpx_abort(mpx, "fork failed: %s", strerror(errno));
- if (child == 0) {
- if(execvp(cmd, options))
- mpx_abort(mpx, "exec failed: %s", strerror(errno));
- } else {
- if (wait(&retcode)==child) {
- retcode = (WIFEXITED(retcode) ? WEXITSTATUS(retcode) : -1);
- } else {
- mpx_abort(mpx, "wait failed: %s", strerror(errno));
- }
- }
- return retcode;
+ pid_t child;
+#endif
+ int retcode = -1;
+ char * cmd = xmalloc(strlen(icmd)+1,1);
+ if (icmd[0] != '"') {
+ strcpy(cmd,icmd);
+ } else {
+ strncpy(cmd,icmd+1,strlen(icmd)-2);
+ cmd[strlen(icmd)-2] = 0;
+ }
+#ifndef WIN32
+ child = fork();
+ if (child < 0)
+ mpx_abort(mpx, "fork failed: %s", strerror(errno));
+ if (child == 0) {
+ if(execvp(cmd, options))
+ mpx_abort(mpx, "exec failed: %s", strerror(errno));
+ } else {
+ if (wait(&retcode)==child) {
+ retcode = (WIFEXITED(retcode) ? WEXITSTATUS(retcode) : -1);
+ } else {
+ mpx_abort(mpx, "wait failed: %s", strerror(errno));
+ }
+ }
#else
- (void)mpx;
- return spawnvp(P_WAIT, cmd, (const char **)options);
+ retcode = spawnvp(P_WAIT, cmd, (const char **)options);
#endif
+ xfree(cmd);
+ return retcode;
}
@ @c
diff --git a/Build/source/texk/web2c/mplibdir/psout.w b/Build/source/texk/web2c/mplibdir/psout.w index 4f532c38846..9981a81dd0b 100644 --- a/Build/source/texk/web2c/mplibdir/psout.w +++ b/Build/source/texk/web2c/mplibdir/psout.w @@ -1,6 +1,6 @@ -% $Id: psout.w 1017 2009-05-09 16:40:50Z taco $ +% $Id: psout.w 1051 2009-05-25 08:31:54Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by @@ -4379,11 +4379,11 @@ static void mp_mark_string_chars (MP mp,font_number f, char *s, size_t l) ; void mp_mark_string_chars (MP mp,font_number f, char *s, size_t l) { integer b; /* |char_base[f]| */ int bc,ec; /* only characters between these bounds are marked */ - char *k; /* an index into string |s| */ + unsigned char *k; /* an index into string |s| */ b=mp->char_base[f]; bc=(int)mp->font_bc[f]; ec=(int)mp->font_ec[f]; - k=s; + k=(unsigned char *)s; while (l-->0){ if ( (*k>=bc)&&(*k<=ec) ) mp->font_info[b+*k].qqqq.b3=mp_used; diff --git a/Build/source/texk/web2c/mplibdir/svgout.w b/Build/source/texk/web2c/mplibdir/svgout.w index 4ce9b7dc0dd..948085a44fd 100644 --- a/Build/source/texk/web2c/mplibdir/svgout.w +++ b/Build/source/texk/web2c/mplibdir/svgout.w @@ -1,6 +1,6 @@ % $Id: svgout.w 657 2008-10-08 09:48:49Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by diff --git a/Build/source/texk/web2c/mplibdir/tfmin.w b/Build/source/texk/web2c/mplibdir/tfmin.w index d6361d767e7..075db665af4 100644 --- a/Build/source/texk/web2c/mplibdir/tfmin.w +++ b/Build/source/texk/web2c/mplibdir/tfmin.w @@ -1,6 +1,6 @@ % $Id: mp.w 597 2008-07-03 15:35:34Z taco $ % -% Copyright 2008 Taco Hoekwater. +% Copyright 2008-2009 Taco Hoekwater. % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU Lesser General Public License as published by |