summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-04-01 09:45:59 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-04-01 09:45:59 +0000
commita70bac8e552ba0a1dd94fde08771e9f63388e632 (patch)
treef14f4f2cd4b0fcc30171ac0adde983b1a1c5249d
parent794fada92e1b6f6b42e9a379fe6f1024af92c6d0 (diff)
the sources for metapost 1.211
git-svn-id: svn://tug.org/texlive/trunk@17649 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/web2c/mplibdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/mplibdir/lmplib.c17
-rw-r--r--Build/source/texk/web2c/mplibdir/memio.w107
-rw-r--r--Build/source/texk/web2c/mplibdir/mp.w325
-rw-r--r--Build/source/texk/web2c/mplibdir/mpost.w282
-rw-r--r--Build/source/texk/web2c/mplibdir/mpxout.w199
-rw-r--r--Build/source/texk/web2c/mplibdir/psout.w300
-rw-r--r--Build/source/texk/web2c/mplibdir/svgout.w33
-rw-r--r--Build/source/texk/web2c/mplibdir/tfmin.w6
9 files changed, 738 insertions, 535 deletions
diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog
index ca704943248..6f390dae5a0 100644
--- a/Build/source/texk/web2c/mplibdir/ChangeLog
+++ b/Build/source/texk/web2c/mplibdir/ChangeLog
@@ -1,3 +1,7 @@
+2010-04-01 Taco Hoekwater <taco@elvenkind.com>
+
+ * Released version of MPLib 1.211
+
2010-03-04 Peter Breitenlohner <peb@mppmu.mpg.de>
* am/mplib.am (TRIPTRAP): Add mptrap.diffs.
diff --git a/Build/source/texk/web2c/mplibdir/lmplib.c b/Build/source/texk/web2c/mplibdir/lmplib.c
index a4fe02dcee8..c5996936a19 100644
--- a/Build/source/texk/web2c/mplibdir/lmplib.c
+++ b/Build/source/texk/web2c/mplibdir/lmplib.c
@@ -32,7 +32,7 @@
# include <../lua51/lauxlib.h>
# include <../lua51/lualib.h>
#endif
-#include "../luatex-api.h"
+# include "../luatex-api.h"
#include "mplib.h"
#include "mplibps.h"
@@ -237,7 +237,7 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft
lua_getfield(L, LUA_REGISTRYINDEX, "mplib_file_finder");
if (lua_isfunction(L, -1)) {
char *s = NULL;
- const char *x = NULL;
+ const char *x = NULL;
lua_pushstring(L, fname);
lua_pushstring(L, fmode);
if (ftype >= mp_filetype_text) {
@@ -421,12 +421,18 @@ static int mplib_wrapresults(lua_State * L, mp_run_data *res, int status)
static int mplib_execute(lua_State * L)
{
- MP *mp_ptr = is_mp(L, 1);
+ MP *mp_ptr;
+ if (lua_gettop(L)!=2) {
+ lua_pushnil(L);
+ return 1;
+ }
+ mp_ptr = is_mp(L, 1);
if (*mp_ptr != NULL && lua_isstring(L, 2)) {
size_t l;
- const char *s = lua_tolstring(L, 2, &l);
+ char *s = xstrdup(lua_tolstring(L, 2, &l));
int h = mp_execute(*mp_ptr, s, l);
mp_run_data *res = mp_rundata(*mp_ptr);
+ xfree(s);
return mplib_wrapresults(L, res, h);
} else {
lua_pushnil(L);
@@ -455,13 +461,14 @@ static int mplib_char_dimension(lua_State * L, int t)
{
MP *mp_ptr = is_mp(L, 1);
if (*mp_ptr != NULL) {
- const char *fname = luaL_checkstring(L,2);
+ char *fname = xstrdup(luaL_checkstring(L,2));
int charnum = (int)luaL_checkinteger(L,3);
if (charnum<0 || charnum>255) {
lua_pushnumber(L, (lua_Number)0);
} else {
lua_pushnumber(L,(lua_Number)mp_get_char_dimension(*mp_ptr,fname,charnum,t));
}
+ xfree(fname);
} else {
lua_pushnumber(L, (lua_Number)0);
}
diff --git a/Build/source/texk/web2c/mplibdir/memio.w b/Build/source/texk/web2c/mplibdir/memio.w
index d08df1be02a..d9598b7a2b3 100644
--- a/Build/source/texk/web2c/mplibdir/memio.w
+++ b/Build/source/texk/web2c/mplibdir/memio.w
@@ -53,6 +53,26 @@
#include <string.h>
#include "mplib.h"
#include "mpmp.h"
+static void swap_items (char *p, int nitems, size_t size);
+/* If we have these macros, use them, as they provide a better guide to
+ the endianess when cross-compiling. */
+#if defined (BYTE_ORDER) && defined (BIG_ENDIAN) && defined (LITTLE_ENDIAN)
+#ifdef WORDS_BIGENDIAN
+#undef WORDS_BIGENDIAN
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+#define WORDS_BIGENDIAN
+#endif
+#endif
+/* More of the same, but now NeXT-specific. */
+#ifdef NeXT
+#ifdef WORDS_BIGENDIAN
+#undef WORDS_BIGENDIAN
+#endif
+#ifdef __BIG_ENDIAN__
+#define WORDS_BIGENDIAN
+#endif
+#endif
#include "mpmemio.h" /* internal header */
@ @(mpmemio.h@>=
@@ -87,7 +107,7 @@ incompatible with the present \MP\ table sizes, etc.
@(mpmemio.h@>=
extern boolean mp_load_mem_file (MP mp);
-@ @c
+@ @c
boolean mp_load_mem_file (MP mp) {
integer k; /* all-purpose index */
pointer p,q; /* all-purpose pointers */
@@ -107,13 +127,88 @@ OFF_BASE:
return false;
}
+@ If we want mem files to be shareable between different endianness architectures,
+we have to swap some of the items so that everything turns out right.
+Code borrowed from |texmfmp.c|.
+
+Make the NITEMS items pointed at by P, each of size SIZE, be the
+ opposite-endianness of whatever they are now. */
+
+@d SWAP(x, y) temp = (x); (x) = (y); (y) = temp
+
+@c
+static void
+swap_items (char *p, int nitems, size_t size)
+{
+ char temp;
+#if !defined (WORDS_BIGENDIAN)
+ /* Since `size' does not change, we can write a while loop for each
+ case, and avoid testing `size' for each time. */
+ switch (size)
+ {
+ /* 16-byte items happen on the DEC Alpha machine when we are not
+ doing sharable memory dumps. */
+ case 16:
+ while (nitems--)
+ {
+ SWAP (p[0], p[15]);
+ SWAP (p[1], p[14]);
+ SWAP (p[2], p[13]);
+ SWAP (p[3], p[12]);
+ SWAP (p[4], p[11]);
+ SWAP (p[5], p[10]);
+ SWAP (p[6], p[9]);
+ SWAP (p[7], p[8]);
+ p += size;
+ }
+ break;
+
+ case 8:
+ while (nitems--)
+ {
+ SWAP (p[0], p[7]);
+ SWAP (p[1], p[6]);
+ SWAP (p[2], p[5]);
+ SWAP (p[3], p[4]);
+ p += size;
+ }
+ break;
+
+ case 4:
+ while (nitems--)
+ {
+ SWAP (p[0], p[3]);
+ SWAP (p[1], p[2]);
+ p += size;
+ }
+ break;
+
+ case 2:
+ while (nitems--)
+ {
+ SWAP (p[0], p[1]);
+ p += size;
+ }
+ break;
+
+ case 1:
+ /* Nothing to do. */
+ break;
+
+ default:
+ fprintf (stderr, "Can't swap a %d-byte item for (un)dumping", (int)size);
+ exit(1);
+ }
+#endif
+}
+
@ Mem files consist of |memory_word| items, and we use the following
macros to dump words of different types:
-@d dump_wd(A) { WW=(A); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
-@d dump_int(A) { int cint=(A); (mp->write_binary_file)(mp,mp->mem_file,&cint,sizeof(cint)); }
-@d dump_hh(A) { WW.hh=(A); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
-@d dump_qqqq(A) { WW.qqqq=(A); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
+@d dump_wd(A) { WW=(A); swap_items((char *)&WW,1,sizeof(WW)); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
+@d dump_int(A) { int cint=(A); swap_items((char *)&cint,1,sizeof(cint)); (mp->write_binary_file)(mp,mp->mem_file,&cint,sizeof(cint)); }
+@d dump_hh(A) { WW.hh=(A); swap_items((char *)&WW,1,sizeof(WW)); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
+@d dump_qqqq(A) { WW.qqqq=(A); swap_items((char *)&WW,1,sizeof(WW)); (mp->write_binary_file)(mp,mp->mem_file,&WW,sizeof(WW)); }
@d dump_string(A) { dump_int((int)(strlen(A)+1));
(mp->write_binary_file)(mp,mp->mem_file,A,strlen(A)+1); }
@@ -126,6 +221,7 @@ read an integer value |x| that is supposed to be in the range |a<=x<=b|.
void *A_ptr = &A;
(mp->read_binary_file)(mp, mp->mem_file,&A_ptr,&wanted);
if (wanted!=sizeof(A)) goto OFF_BASE;
+ swap_items(A_ptr,1,wanted);
} while (0)
@d mgetw(A) do {
@@ -133,6 +229,7 @@ read an integer value |x| that is supposed to be in the range |a<=x<=b|.
void *A_ptr = &A;
(mp->read_binary_file)(mp, mp->mem_file,&A_ptr,&wanted);
if (wanted!=sizeof(A)) goto OFF_BASE;
+ swap_items(A_ptr,1,wanted);
} while (0)
@d undump_wd(A) { mgetw(WW); A=WW; }
diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w
index ab6f770aaf3..43229db5864 100644
--- a/Build/source/texk/web2c/mplibdir/mp.w
+++ b/Build/source/texk/web2c/mplibdir/mp.w
@@ -1,4 +1,4 @@
- $Id: mp.w 1118 2009-10-02 08:23:52Z taco $
+% $Id: mp.w 1219 2010-04-01 09:05:51Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -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.208" /* printed when \MP\ starts */
+@d default_banner "This is MetaPost, Version 1.211" /* printed when \MP\ starts */
@d true 1
@d false 0
@(mpmp.h@>=
-#define metapost_version "1.208"
-#define metapost_magic (('M'*256) + 'P')*65536 + 1208
+#define metapost_version "1.211"
+#define metapost_magic (('M'*256) + 'P')*65536 + 1211
#define metapost_old_magic (('M'*256) + 'P')*65536 + 1080
@ The external library header for \MP\ is |mplib.h|. It contains a
@@ -701,7 +701,7 @@ static boolean mp_a_open_in (MP mp, void **f, int ftype) {
OPEN_FILE("r");
}
@#
-#if 0 /* unused */
+#if 0
boolean mp_w_open_in (MP mp, void **f) {
/* open a word file for input */
*f = (mp->open_file)(mp,mp->name_of_file,"r",mp_filetype_memfile);
@@ -749,7 +749,7 @@ static char *mp_read_ascii_file (MP mp, void *ff, size_t *size) {
if (s==NULL) return NULL;
lim+=(lim>>2);
}
- s[len++] = c;
+ s[len++] = (char)c;
c =fgetc(f);
}
if (c=='\r') {
@@ -1788,9 +1788,9 @@ void mp_print_char (MP mp, ASCII_code k) { /* prints a single character */
} else if ( @<Character |k| cannot be printed@> ) {
mp_print(mp, "^^");
if ( k<0100 ) {
- mp_print_visible_char(mp, k+0100);
+ mp_print_visible_char(mp, (ASCII_code)(k+0100));
} else if ( k<0200 ) {
- mp_print_visible_char(mp, k-0100);
+ mp_print_visible_char(mp, (ASCII_code)(k-0100));
} else {
int l; /* small index or counter */
l = (k / 16);
@@ -1845,7 +1845,7 @@ void mp_print_str (MP mp, str_number s) {
@.???@>
}
j=mp->str_start[s];
- len = (str_stop(s)-j);
+ len = (size_t)(str_stop(s)-j);
ss = xmalloc(len+1, sizeof(char));
if (len > 0) {
/* the man page doesnt say whether 0 is allowed */
@@ -2206,7 +2206,7 @@ CONTINUE:
@.?\relax@>
if ( mp->last==mp->first ) return;
c=mp->buffer[mp->first];
- if ( c>='a' ) c=c+'A'-'a'; /* convert to uppercase */
+ if ( c>='a' ) c=(ASCII_code)(c+'A'-'a'); /* convert to uppercase */
@<Interpret code |c| and |return| if done@>;
}
@@ -2333,11 +2333,11 @@ to be familiar with \MP's input stacks.
if ( (mp->last>mp->first+1) && (mp->buffer[mp->first+1]>='0')&&(mp->buffer[mp->first+1]<='9') )
c=xord(c*10+mp->buffer[mp->first+1]-'0'*11);
else
- c=c-'0';
+ c = (ASCII_code) (c - '0');
while ( c>0 ) {
mp_get_next(mp); /* one-level recursive call of |error| is possible */
@<Decrease the string reference count, if the current token is a string@>;
- decr(c);
+ c--;
};
mp->cur_cmd=s1; mp->cur_mod=s2; mp->cur_sym=s3; mp->OK_to_interrupt=true;
help2("I have just deleted some text, as you asked.",
@@ -2633,7 +2633,7 @@ static scaled mp_round_decimals (MP mp,quarterword k) {
/* converts a decimal fraction */
unsigned a = 0; /* the accumulator */
while ( k-->0 ) {
- a=(a+mp->dig[k]*two) / 10;
+ a=(a+(unsigned)mp->dig[k]*two) / 10;
}
return (scaled)halfp(a+1);
}
@@ -3198,13 +3198,13 @@ static scaled mp_square_rt (MP mp,scaled x) ;
scaled mp_square_rt (MP mp,scaled x) {
quarterword k; /* iteration control counter */
integer y; /* register for intermediate calculations */
- unsigned q; /* register for intermediate calculations */
+ integer q; /* register for intermediate calculations */
if ( x<=0 ) {
@<Handle square root of zero or negative argument@>;
} else {
k=23; q=2;
while ( x<fraction_two ) { /* i.e., |while x<@t$2^{29}$@>|\unskip */
- decr(k); x=x+x+x+x;
+ k--; x=x+x+x+x;
}
if ( x<fraction_four ) y=0;
else { x=x-fraction_four; y=1; };
@@ -3236,9 +3236,9 @@ if ( x>=fraction_four ) { /* note that |fraction_four=@t$2^{30}$@>| */
};
x+=x; y=y+y-q; q+=q;
if ( x>=fraction_four ) { x=x-fraction_four; y++; };
-if ( y>(int)q ){ y=y-q; q=q+2; }
-else if ( y<=0 ) { q=q-2; y=y+q; };
-decr(k)
+if ( y>(int)q ){ y-=q; q+=2; }
+else if ( y<=0 ) { q-=2; y+=q; };
+k--
@ Pythagorean addition $\psqrt{a^2+b^2}$ is implemented by an elegant
iterative scheme due to Cleve Moler and Donald Morrison [{\sl IBM Journal
@@ -3840,7 +3840,7 @@ what type it is; so we print it in all modes.
@^debugging@>
@c
-#if 0 /* unused */
+#if 0
void mp_print_word (MP mp,memory_word w) {
/* prints |w| in all ways */
mp_print_int(mp, w.cint); mp_print_char(mp, xord(' '));
@@ -3857,7 +3857,6 @@ void mp_print_word (MP mp,memory_word w) {
}
#endif
-
@* \[10] Dynamic memory allocation.
The \MP\ system does nearly all of its own memory allocation, so that it
@@ -4010,9 +4009,9 @@ static char *mp_itoa (int i) {
while (v>=10) {
char d = (char)(v % 10);
v = v / 10;
- res[idx--] = (char)d + '0';
+ res[idx--] = (char)(d + '0');
}
- res[idx--] = (char)v + '0';
+ res[idx--] = (char)(v + '0');
if (i<0) {
res[idx--] = '-';
}
@@ -4025,9 +4024,9 @@ static char *mp_utoa (unsigned v) {
while (v>=10) {
char d = (char)(v % 10);
v = v / 10;
- res[idx--] = d + '0';
+ res[idx--] = (char)(d + '0');
}
- res[idx--] = (char)v + '0';
+ res[idx--] = (char)(v + '0');
return mp_strdup((res+idx+1));
}
void mp_do_snprintf (char *str, int size, const char *format, ...) {
@@ -4073,7 +4072,7 @@ void mp_do_snprintf (char *str, int size, const char *format, ...) {
case 'c':
{
int s = va_arg(ap, int);
- *res = s;
+ *res = (char)s;
if (size-->0) res++;
}
break;
@@ -4083,9 +4082,9 @@ void mp_do_snprintf (char *str, int size, const char *format, ...) {
char *sstart, *s = mp_itoa(va_arg(ap, int));
sstart = s;
if (fw) {
- int ffw = fw-strlen(s);
+ int ffw = fw-(int)strlen(s);
while (ffw-->0) {
- *res = (pad ? '0' : ' ');
+ *res = (char)(pad ? '0' : ' ');
if (size-->0) res++;
}
}
@@ -4103,9 +4102,9 @@ void mp_do_snprintf (char *str, int size, const char *format, ...) {
char *sstart, *s = mp_utoa(va_arg(ap, unsigned));
sstart = s;
if (fw) {
- int ffw = fw-strlen(s);
+ int ffw = fw-(int)strlen(s);
while (ffw-->0) {
- *res = (pad ? '0' : ' ');
+ *res = (char)(pad ? '0' : ' ');
if (size-->0) res++;
}
}
@@ -4142,7 +4141,7 @@ void mp_do_snprintf (char *str, int size, const char *format, ...) {
@
@<Allocate or initialize ...@>=
mp->mem = xmalloc ((mp->mem_max+1),sizeof (memory_word));
-memset(mp->mem,0,(mp->mem_max+1)*sizeof (memory_word));
+memset(mp->mem,0,(size_t)(mp->mem_max+1)*sizeof (memory_word));
@ @<Dealloc variables@>=
xfree(mp->mem);
@@ -4496,10 +4495,10 @@ static void mp_reallocate_memory(MP mp, int l) {
if (mp->mem) {
int newarea = l-mp->mem_max;
XREALLOC(mp->mem, l, memory_word);
- memset (mp->mem+(mp->mem_max+1),0,sizeof(memory_word)*(newarea));
+ memset (mp->mem+(mp->mem_max+1),0,(size_t)(sizeof(memory_word)*((unsigned)newarea)));
} else {
XREALLOC(mp->mem, l, memory_word);
- memset(mp->mem,0,sizeof(memory_word)*(l+1));
+ memset(mp->mem,0,(size_t)(sizeof(memory_word)*(unsigned)(l+1)));
}
mp->mem_max = l;
if (mp->ini_version)
@@ -4513,6 +4512,7 @@ static void mp_reallocate_memory(MP mp, int l) {
that are reserved now but were free the last time this procedure was called.
@c
+#if 0
static void mp_check_mem (MP mp,boolean print_locs ) {
pointer p,q,r; /* current locations of interest in |mem| */
boolean clobbered; /* is something amiss? */
@@ -4529,11 +4529,12 @@ static void mp_check_mem (MP mp,boolean print_locs ) {
if ( print_locs ) {
@<Print newly busy locations@>;
}
- (void)memcpy(mp->was_free,mp->free, sizeof(char)*(mp->mem_end+1));
+ (void)memcpy(mp->was_free, mp->free, (size_t)(sizeof(char)*(unsigned)(mp->mem_end+1)));
mp->was_mem_end=mp->mem_end;
mp->was_lo_max=mp->lo_mem_max;
mp->was_hi_min=mp->hi_mem_min;
}
+#endif
@ @<Check single-word...@>=
p=mp->avail; q=null; clobbered=false;
@@ -4635,7 +4636,7 @@ to rule out the places that do {\sl not\/} point to |p|, so a few false
drops are tolerable.
@c
-#if 0 /* unused */
+#if 0
void mp_search_mem (MP mp, pointer p) { /* look for pointers to |p| */
integer q; /* current position being searched */
for (q=0;q<=mp->lo_mem_max;q++) {
@@ -5230,11 +5231,11 @@ int troff_mode;
@ @<Allocate or initialize ...@>=
mp->max_internal=2*max_given_internal;
mp->internal = xmalloc ((mp->max_internal+1), sizeof(scaled));
-memset(mp->internal,0,(mp->max_internal+1)* sizeof(scaled));
+memset(mp->internal,0,(size_t)(mp->max_internal+1)* sizeof(scaled));
mp->int_name = xmalloc ((mp->max_internal+1), sizeof(char *));
-memset(mp->int_name,0,(mp->max_internal+1) * sizeof(char *));
+memset(mp->int_name,0,(size_t)(mp->max_internal+1) * sizeof(char *));
mp->int_type = xmalloc ((mp->max_internal+1), sizeof(int));
-memset(mp->int_type,0,(mp->max_internal+1) * sizeof(int));
+memset(mp->int_type,0,(size_t)(mp->max_internal+1) * sizeof(int));
{
int i;
for (i=1;i<=max_given_internal;i++)
@@ -5762,7 +5763,7 @@ static void mp_primitive (MP mp, const char *ss, halfword c, halfword o) {
quarterword l; /* length of the string */
str_number s;
s = intern(ss);
- k=mp->str_start[s]; l=str_stop(s)-k;
+ k=mp->str_start[s]; l=(quarterword)(str_stop(s)-k);
/* we will move |s| into the (empty) |buffer| */
for (j=0;j<=l-1;j++) {
mp->buffer[j]=mp->str_pool[k+j];
@@ -6152,7 +6153,7 @@ mp_print_int(mp, r); mp_print_char(mp, xord(')')); c=right_paren_class;
@ @<Print string |r| as a symbolic token...@>=
{
-c=mp->char_class[mp->str_pool[mp->str_start[r]]];
+c=(quarterword)mp->char_class[mp->str_pool[mp->str_start[r]]];
if ( c==class ) {
switch (c) {
case letter_class:mp_print_char(mp, xord('.')); break;
@@ -6432,13 +6433,13 @@ mp->sector0[mp_pair_type]=mp_x_part_sector;
mp->sector0[mp_color_type]=mp_red_part_sector;
mp->sector0[mp_cmykcolor_type]=mp_cyan_part_sector;
for (k=mp_x_part_sector;k<= mp_yy_part_sector;k++ ) {
- mp->sector_offset[k]=2*(k-mp_x_part_sector);
+ mp->sector_offset[k]=(quarterword)(2*(k-mp_x_part_sector));
}
for (k=mp_red_part_sector;k<= mp_blue_part_sector ; k++) {
- mp->sector_offset[k]=2*(k-mp_red_part_sector);
+ mp->sector_offset[k]=(quarterword)(2*(k-mp_red_part_sector));
}
for (k=mp_cyan_part_sector;k<= mp_black_part_sector;k++ ) {
- mp->sector_offset[k]=2*(k-mp_cyan_part_sector);
+ mp->sector_offset[k]=(quarterword)(2*(k-mp_cyan_part_sector));
}
@ If |type(p)=mp_pair_type| or |mp_transform_type| and if |value(p)=null|, the
@@ -6452,9 +6453,9 @@ static void mp_init_big_node (MP mp,pointer p) {
quarterword s; /* its size */
s=mp->big_node_size[mp_type(p)]; q=mp_get_node(mp, s);
do {
- s=s-2;
+ s=(quarterword)(s-2);
@<Make variable |q+s| newly independent@>;
- mp_name_type(q+s)=halfp(s)+mp->sector0[mp_type(p)];
+ mp_name_type(q+s)=(quarterword)(halfp(s)+mp->sector0[mp_type(p)]);
mp_link(q+s)=null;
} while (s!=0);
mp_link(q)=p; value(p)=q;
@@ -7039,7 +7040,7 @@ $$\eqalign{z(t)&=B(z_k,z_k^+,z_{k+1}^-,z_{k+1};t)\cr
&=(1-t)^3z_k+3(1-t)^2tz_k^++3(1-t)t^2z_{k+1}^-+t^3z_{k+1}\cr}$$
for |0<=t<=1|.
-There is a 8-word node for each knot $z_k$, containing one word of
+There is an 8-word node for each knot $z_k$, containing one word of
control information and six words for the |x| and |y| coordinates of
$z_k^-$ and $z_k$ and~$z_k^+$. The control information appears in the
|mp_left_type| and |mp_right_type| fields, which each occupy a quarter of
@@ -7361,8 +7362,8 @@ static pointer mp_import_knot (MP mp, mp_knot *q) {
if (q==NULL)
return null;
p=mp_get_node(mp, knot_node_size);
- mp_left_type(p) = gr_left_type(q);
- mp_right_type(p) = gr_right_type(q);
+ mp_left_type(p) = (quarterword)gr_left_type(q);
+ mp_right_type(p) = (quarterword)gr_right_type(q);
mp_x_coord(p) = gr_x_coord(q);
mp_y_coord(p) = gr_y_coord(q);
mp_left_x(p) = gr_left_x(q);
@@ -9491,7 +9492,7 @@ scaled mp_sqrt_det (MP mp,scaled a, scaled b, scaled c, scaled d) {
a+=a; b+=b; c+=c; d+=d;
maxabs+=maxabs; s=(unsigned)(halfp(s));
}
- return (scaled)(s*mp_square_rt(mp, abs(mp_take_fraction(mp, a,d)-mp_take_fraction(mp, b,c))));
+ return (scaled)(s*(unsigned)mp_square_rt(mp, abs(mp_take_fraction(mp, a,d)-mp_take_fraction(mp, b,c))));
}
@#
static scaled mp_get_pen_scale (MP mp,pointer p) {
@@ -9902,7 +9903,7 @@ pointer mp_copy_objects (MP mp, pointer p, pointer q) {
{ k=mp->gr_object_size[mp_type(p)];
mp_link(pp)=mp_get_node(mp, k);
pp=mp_link(pp);
- while ( (k>0) ) { decr(k); mp->mem[pp+k]=mp->mem[p+k]; };
+ while ( (k>0) ) { k--; mp->mem[pp+k]=mp->mem[p+k]; };
@<Fix anything in graphical object |pp| that should differ from the
corresponding field in |p|@>;
p=mp_link(p);
@@ -12114,9 +12115,9 @@ y2r=half(y3r+stack_2(y_packet(mp->xy)));
y3l=half(y2l+y2r); y1r=y3l;
set_min_max(yl_packet); set_min_max(yr_packet);
mp->uv=l_packets; mp->xy=l_packets;
-mp->delx+=mp->delx; mp->dely+=mp->dely;
-mp->tol=mp->tol-mp->three_l+mp->tol_step;
-mp->tol+=mp->tol; mp->three_l=mp->three_l+mp->tol_step
+mp->delx += mp->delx; mp->dely+=mp->dely;
+mp->tol = mp->tol- mp->three_l+(integer)mp->tol_step;
+mp->tol += mp->tol; mp->three_l=mp->three_l+(integer)mp->tol_step
@ @<Advance to the next pair |(cur_t,cur_tt)|@>=
NOT_FOUND:
@@ -12150,8 +12151,8 @@ if ( odd(mp->cur_tt) ) {
{
mp->cur_t=halfp(mp->cur_t); mp->cur_tt=halfp(mp->cur_tt);
if ( mp->cur_t==0 ) return;
- mp->bisect_ptr=mp->bisect_ptr-int_increment;
- mp->three_l=mp->three_l-mp->tol_step;
+ mp->bisect_ptr -= int_increment;
+ mp->three_l -= (integer)mp->tol_step;
mp->delx=stack_dx; mp->dely=stack_dy; mp->tol=stack_tol;
mp->uv=stack_uv; mp->xy=stack_xy;
goto NOT_FOUND;
@@ -12995,7 +12996,7 @@ value, it will soon be recycled.
static void mp_nonlinear_eq (MP mp,integer v, pointer p, boolean flush_p) {
quarterword t; /* the type of ring |p| */
pointer q,r; /* link manipulation registers */
- t=mp_type(p)-unknown_tag; q=value(p);
+ t=(quarterword)(mp_type(p)-unknown_tag); q=value(p);
if ( flush_p ) mp_type(p)=mp_vacuous; else p=q;
do {
r=value(q); mp_type(q)=t;
@@ -13640,7 +13641,7 @@ new level (having, initially, the same properties as the old).
a token list |p| and its type |t|. If |t=macro|, the calling routine should
set |name|, reset~|loc|, and increase the macro's reference count.
-@d back_list(A) mp_begin_token_list(mp, (A),backed_up) /* backs up a simple token list */
+@d back_list(A) mp_begin_token_list(mp, (A), (quarterword)backed_up) /* backs up a simple token list */
@c
static void mp_begin_token_list (MP mp,pointer p, quarterword t) {
@@ -13730,7 +13731,7 @@ during the call of |back_input| so that the help message won't be lost.
}
static void mp_ins_error (MP mp) { /* back up one inserted token and call |error| */
mp->OK_to_interrupt=false;
- mp_back_input(mp); token_type=inserted;
+ mp_back_input(mp); token_type=(quarterword)inserted;
mp->OK_to_interrupt=true; mp_error(mp);
}
@@ -13746,7 +13747,7 @@ or |limit| or |line|.
@:MetaPost capacity exceeded text input levels}{\quad text input levels@>
if ( mp->first==mp->buf_size )
mp_reallocate_buffer(mp,(mp->buf_size+(mp->buf_size/4)));
- incr(mp->in_open); push_input; iindex=mp->in_open;
+ mp->in_open++; push_input; iindex=(quarterword)mp->in_open;
if (mp->in_open_max<mp->in_open)
mp->in_open_max=mp->in_open;
mp->mpx_name[iindex]=absent;
@@ -13793,7 +13794,7 @@ work.
@:this can't happen mpx}{\quad mpx@>
if ( mp->first==mp->buf_size )
mp_reallocate_buffer(mp,(mp->buf_size+(mp->buf_size/4)));
- push_input; iindex=mp->in_open;
+ push_input; iindex=(quarterword)mp->in_open;
start=(halfword)mp->first;
name=mp->mpx_name[mp->in_open]; add_str_ref(name);
@<Put an empty line in the input buffer@>;
@@ -14213,11 +14214,11 @@ DONE: incr(loc)
k=0;
do {
if ( k<17 ) { /* digits for |k>=17| cannot affect the result */
- mp->dig[k]=mp->buffer[loc]-'0'; incr(k);
+ mp->dig[k]=(unsigned char)(mp->buffer[loc]-'0'); incr(k);
}
incr(loc);
} while (mp->char_class[mp->buffer[loc]]==digit_class);
-f=mp_round_decimals(mp, k);
+f=mp_round_decimals(mp, (quarterword)k);
if ( f==unity ) {
incr(n); f=0;
}
@@ -14279,7 +14280,7 @@ if ( loc>=mp->hi_mem_min ) { /* one-word token */
/* |param_size=text_base-suffix_base| */
mp_begin_token_list(mp,
mp->param_stack[param_start+mp->cur_sym-(suffix_base)],
- parameter);
+ (quarterword)parameter);
goto RESTART;
}
@@ -14414,9 +14415,9 @@ used instead of the line in the file.
@.=>@>
if ( mp->last>mp->first ) {
for (k=mp->first;k<mp->last;k++) { /* move line down in buffer */
- mp->buffer[k+start-mp->first]=mp->buffer[k];
+ mp->buffer[k+(size_t)start-mp->first]=mp->buffer[k];
}
- limit=(halfword)(start+mp->last-mp->first);
+ limit=(halfword)((size_t)start+mp->last-mp->first);
}
}
}
@@ -14806,6 +14807,11 @@ case param_type:
and \&{vardef}. When the following procedure is called, |cur_mod|
should be either |start_def| or |var_def|.
+Note that although the macro scanner allows |def = := enddef| and
+|def := = enddef|; |def = = enddef| and |def := := enddef| will generate
+an error because by the time the second of the two identical tokens is
+seen, its meaning has already become undefined.
+
@c
static void mp_scan_def (MP mp) {
int m; /* the type of definition */
@@ -14839,11 +14845,11 @@ a \&{vardef}, because the user may want to redefine `\.{endgroup}'.
@<Attach the replacement text to the tail of node |p|@>=
if ( m==start_def ) {
- mp_link(p)=mp_scan_toks(mp, macro_def,r,null,n);
+ mp_link(p)=mp_scan_toks(mp, macro_def,r,null, (quarterword)n);
} else {
q=mp_get_avail(mp); mp_info(q)=mp->bg_loc; mp_link(p)=q;
p=mp_get_avail(mp); mp_info(p)=mp->eg_loc;
- mp_link(q)=mp_scan_toks(mp, macro_def,r,p,n);
+ mp_link(q)=mp_scan_toks(mp, macro_def,r,p, (quarterword)n);
}
if ( mp->warning_info==bad_vardef )
mp_flush_token_list(mp, value(bad_vardef))
@@ -14866,7 +14872,8 @@ if ( m==start_def ) {
if ( mp->cur_cmd==macro_special ) if ( mp->cur_mod==macro_suffix ) {/* \.{\AT!\#} */
n=3; get_t_next;
}
- mp_type(mp->warning_info)=mp_unsuffixed_macro-2+n; value(mp->warning_info)=q;
+ mp_type(mp->warning_info)=(quarterword)(mp_unsuffixed_macro-2+n);
+ value(mp->warning_info)=q;
} /* |mp_suffixed_macro=mp_unsuffixed_macro+1| */
@ @<Change to `\.{a bad variable}'@>=
@@ -15156,7 +15163,7 @@ is less than |loop_text|.
@ @<Pretend we're reading a new one-line file@>=
{ mp_begin_file_reading(mp); name=is_scantok;
- k=mp->first+length(mp->cur_exp);
+ k=mp->first+(size_t)length(mp->cur_exp);
if ( k>=mp->max_buf_stack ) {
while ( k>=mp->buf_size ) {
mp_reallocate_buffer(mp,(mp->buf_size+(mp->buf_size/4)));
@@ -15540,7 +15547,7 @@ if ( mp->param_ptr+n>mp->max_param_stack ) {
mp_overflow(mp, "parameter stack size",mp->param_size);
@:MetaPost capacity exceeded parameter stack size}{\quad parameter stack size@>
}
-mp_begin_token_list(mp, def_ref,macro); name=macro_name; loc=r;
+mp_begin_token_list(mp, def_ref, (quarterword)macro); name=macro_name; loc=r;
if ( n>0 ) {
p=arg_list;
do {
@@ -15657,7 +15664,7 @@ condition has been evaluated, a colon will be inserted.
A construction like `\.{if fi}' would otherwise get \MP\ confused.
@<Push the condition stack@>=
-{ p=mp_get_node(mp, if_node_size); mp_link(p)=mp->cond_ptr; mp_type(p)=mp->if_limit;
+{ p=mp_get_node(mp, if_node_size); mp_link(p)=mp->cond_ptr; mp_type(p)=(quarterword)mp->if_limit;
mp_name_type(p)=mp->cur_if; if_line_field(p)=mp->if_line;
mp->cond_ptr=p; mp->if_limit=if_code; mp->if_line=mp_true_line(mp);
mp->cur_if=if_code;
@@ -15724,12 +15731,12 @@ RESWITCH:
FOUND:
mp_check_colon(mp);
if ( mp->cur_exp==true_code ) {
- mp_change_if_limit(mp, new_if_limit,save_cond_ptr);
+ mp_change_if_limit(mp, (quarterword)new_if_limit, save_cond_ptr);
return; /* wait for \&{elseif}, \&{else}, or \&{fi} */
};
@<Skip to \&{elseif} or \&{else} or \&{fi}, then |goto done|@>;
DONE:
- mp->cur_if=mp->cur_mod; mp->if_line=mp_true_line(mp);
+ mp->cur_if=(quarterword)mp->cur_mod; mp->if_line=mp_true_line(mp);
if ( mp->cur_mod==fi_code ) {
@<Pop the condition stack@>
} else if ( mp->cur_mod==else_if_code ) {
@@ -15958,12 +15965,12 @@ text(frozen_repeat_loop)=intern(" ENDFOR");
}
loop_list(mp->loop_ptr)=mp_link(p); q=mp_info(p); free_avail(p);
} else if ( p==mp_void ) {
- mp_begin_token_list(mp, mp_info(mp->loop_ptr),forever_text); return;
+ mp_begin_token_list(mp, mp_info(mp->loop_ptr), (quarterword)forever_text); return;
} else {
@<Make |q| a capsule containing the next picture component from
|loop_list(loop_ptr)| or |goto not_found|@>;
}
- mp_begin_token_list(mp, mp_info(mp->loop_ptr),loop_text);
+ mp_begin_token_list(mp, mp_info(mp->loop_ptr), (quarterword)loop_text);
mp_stack_argument(mp, q);
if ( mp->internal[mp_tracing_commands]>unity ) {
@<Trace the start of a loop@>;
@@ -16261,7 +16268,7 @@ void mp_end_name (MP mp) {
} else {
len = (unsigned)(mp->area_delimiter-s+1);
copy_pool_segment(mp->cur_area,s,len);
- s += len;
+ s += (pool_pointer)len;
}
if ( mp->ext_delimiter<0 ) {
mp->cur_ext=xstrdup("");
@@ -16795,9 +16802,9 @@ 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_ext);
+ mp_pack_file_name(mp, in_name, in_area, in_ext);
origname = xstrdup(mp->name_of_file);
- mp_pack_file_name(mp, in_name, "", ".mpx");
+ mp_pack_file_name(mp, in_name, in_area, ".mpx");
if (!(mp->run_make_mpx)(mp, origname, mp->name_of_file))
goto NOT_FOUND;
mp_begin_file_reading(mp);
@@ -17469,7 +17476,7 @@ pointer max_link[mp_proto_dependent+1]; /* other occurrences of |p| */
t=mp_proto_dependent;
@<Determine the dependency list |s| to substitute for the independent
variable~|p|@>;
- t=mp_dependent+mp_proto_dependent-t; /* complement |t| */
+ t=(quarterword)(mp_dependent+mp_proto_dependent-t); /* complement |t| */
if ( mp->max_c[t]>0 ) { /* we need to pick up an unchosen dependency */
mp_link(mp->max_ptr[t])=mp->max_link[t]; mp->max_link[t]=mp->max_ptr[t];
}
@@ -17871,11 +17878,11 @@ suspense won't be too bad:
|do_binary(p,c)| applies a primitive operation to the capsule~|p|
and the current expression.
-@<Scan a nullary operation@>=mp_do_nullary(mp, mp->cur_mod)
+@<Scan a nullary operation@>=mp_do_nullary(mp, (quarterword)mp->cur_mod)
@ @<Scan a unary operation@>=
{
- c=mp->cur_mod; mp_get_x_next(mp); mp_scan_primary(mp);
+ c=(quarterword)mp->cur_mod; mp_get_x_next(mp); mp_scan_primary(mp);
mp_do_unary(mp, c); goto DONE;
}
@@ -17931,7 +17938,7 @@ scaled num,denom; /* for primaries that are fractions, like `1/2' */
@ @<Scan a binary operation with `\&{of}' between its operands@>=
{
- c=mp->cur_mod; mp_get_x_next(mp); mp_scan_expression(mp);
+ c=(quarterword)mp->cur_mod; mp_get_x_next(mp); mp_scan_expression(mp);
if ( mp->cur_cmd!=of_token ) {
mp_missing_err(mp, "of"); mp_print(mp, " for ");
mp_print_cmd_mod(mp, primary_binary,c);
@@ -17974,7 +17981,7 @@ of the save stack, as described earlier.)
mp->cur_exp=mp->internal[q];
if (mp->int_type[q]==mp_string_type)
add_str_ref(mp->cur_exp);
- mp->cur_type=mp->int_type[q];
+ mp->cur_type=(quarterword)mp->int_type[q];
}
@ The most difficult part of |scan_primary| has been saved for last, since
@@ -18656,7 +18663,7 @@ static quarterword mp_scan_direction (MP mp) {
mp_back_error(mp);
}
mp_get_x_next(mp);
- return t;
+ return (quarterword)t;
}
@ @<Scan a curl specification@>=
@@ -18724,9 +18731,9 @@ the value of |mp_right_type(q)| in cases such as
{
t=mp_scan_direction(mp);
if ( t!=mp_open ) {
- mp_right_type(q)=t; right_given(q)=mp->cur_exp;
+ mp_right_type(q)=(quarterword)t; right_given(q)=mp->cur_exp;
if ( mp_left_type(q)==mp_open ) {
- mp_left_type(q)=t; left_given(q)=mp->cur_exp;
+ mp_left_type(q)=(quarterword)t; left_given(q)=mp->cur_exp;
} /* note that |left_given(q)=left_curl(q)| */
}
}
@@ -18846,7 +18853,7 @@ if ( d==ampersand ) {
} else {
@<Plug an opening in |mp_right_type(q)|, if possible@>;
mp_link(q)=pp; mp_left_y(pp)=y;
- if ( t!=mp_open ) { mp_left_x(pp)=x; mp_left_type(pp)=t; };
+ if ( t!=mp_open ) { mp_left_x(pp)=x; mp_left_type(pp)=(quarterword)t; };
}
q=qq;
}
@@ -18861,7 +18868,7 @@ if ( mp_right_type(q)==mp_open ) {
@ @<Plug an opening in |mp_right_type(pp)|...@>=
if ( mp_right_type(pp)==mp_open ) {
if ( (t==mp_curl)||(t==mp_given) ) {
- mp_right_type(pp)=t; right_given(pp)=x;
+ mp_right_type(pp)=(quarterword)t; right_given(pp)=x;
}
}
@@ -19144,7 +19151,7 @@ case slash:
case ampersand:
case equals:
case and_command:
- mp_print_op(mp, m);
+ mp_print_op(mp, (quarterword)m);
break;
@ OK, let's look at the simplest \\{do} procedure first.
@@ -19707,9 +19714,9 @@ static void mp_str_to_num (MP mp,quarterword c) { /* converts a string to a numb
n=0; bad_char=false;
for (k=mp->str_start[mp->cur_exp];k<str_stop(mp->cur_exp);k++) {
m=mp->str_pool[k];
- if ( (m>='0')&&(m<='9') ) m=m-'0';
- else if ( (m>='A')&&(m<='F') ) m=m-'A'+10;
- else if ( (m>='a')&&(m<='f') ) m=m-'a'+10;
+ if ( (m>='0')&&(m<='9') ) m=(ASCII_code)(m-'0');
+ else if ( (m>='A')&&(m<='F') ) m=(ASCII_code)(m-'A'+10);
+ else if ( (m>='a')&&(m<='f') ) m=(ASCII_code)(m-'a'+10);
else { bad_char=true; m=0; };
if ( (int)m>=b ) { bad_char=true; m=0; };
if ( n<32768 / b ) n=n*b+m; else n=32767;
@@ -20367,7 +20374,7 @@ static void mp_finish_binary (MP mp, pointer old_p, pointer old_exp ){
check_arith;
@<Recycle any sidestepped |independent| capsules@>;
}
-static void mp_do_binary (MP mp,pointer p, quarterword c) {
+static void mp_do_binary (MP mp,pointer p, integer c) {
pointer q,r,rr; /* for list manipulation */
pointer old_p,old_exp; /* capsules to recycle */
integer v; /* for numeric manipulation */
@@ -20416,7 +20423,8 @@ static void mp_bad_envelope_pen (MP mp) {
{
mp_begin_diagnostic(mp); mp_print_nl(mp, "{(");
mp_print_exp(mp,p,0); /* show the operand, but not verbosely */
- mp_print_char(mp,xord(')')); mp_print_op(mp,c); mp_print_char(mp,xord('('));
+ mp_print_char(mp,xord(')')); mp_print_op(mp, (quarterword)c);
+ mp_print_char(mp,xord('('));
mp_print_exp(mp,null,0); mp_print(mp,")}");
mp_end_diagnostic(mp, false);
}
@@ -20487,18 +20495,18 @@ static pointer mp_tarnished (MP mp,pointer p) {
@ @<Add or subtract the current expression from |p|@>=
if ( (mp->cur_type<mp_color_type)||(mp_type(p)<mp_color_type) ) {
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
} else {
if ((mp->cur_type>mp_pair_type)&&(mp_type(p)>mp_pair_type) ) {
- mp_add_or_subtract(mp, p,null,c);
+ mp_add_or_subtract(mp, p,null, (quarterword)c);
} else {
if ( mp->cur_type!=mp_type(p) ) {
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
} else {
q=value(p); r=value(mp->cur_exp);
rr=r+mp->big_node_size[mp->cur_type];
while ( r<rr ) {
- mp_add_or_subtract(mp, q,r,c);
+ mp_add_or_subtract(mp, q, r, (quarterword)c);
q=q+2; r=r+2;
}
}
@@ -20623,7 +20631,7 @@ case greater_or_equal: case equal_to: case unequal_to:
if ( (mp->cur_type>mp_pair_type)&&(mp_type(p)>mp_pair_type) ) {
mp_add_or_subtract(mp, p,null,minus); /* |cur_exp:=(p)-cur_exp| */
} else if ( mp->cur_type!=mp_type(p) ) {
- mp_bad_binary(mp, p,c); goto DONE;
+ mp_bad_binary(mp, p, (quarterword)c); goto DONE;
} else if ( mp->cur_type==mp_string_type ) {
mp_flush_cur_exp(mp, mp_str_vs_str(mp, value(p),mp->cur_exp));
} else if ((mp->cur_type==mp_unknown_string)||
@@ -20634,7 +20642,7 @@ case greater_or_equal: case equal_to: case unequal_to:
} else if ( mp->cur_type==mp_boolean_type ) {
mp_flush_cur_exp(mp, mp->cur_exp-value(p));
} else {
- mp_bad_binary(mp, p,c); goto DONE;
+ mp_bad_binary(mp, p, (quarterword)c); goto DONE;
}
@<Compare the current expression with zero@>;
DONE:
@@ -20686,7 +20694,7 @@ make no change.
if ( r==rr ) break;
q=q+2; r=r+2;
}
- mp_take_part(mp, mp_name_type(r)+x_part-mp_x_part_sector);
+ mp_take_part(mp, (quarterword)(mp_name_type(r)+x_part-mp_x_part_sector));
}
@ Here we use the sneaky fact that |and_op-false_code=or_op-true_code|.
@@ -20695,14 +20703,14 @@ make no change.
case and_op:
case or_op:
if ( (mp_type(p)!=mp_boolean_type)||(mp->cur_type!=mp_boolean_type) )
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
else if ( value(p)==c+false_code-and_op ) mp->cur_exp=value(p);
break;
@ @<Additional cases of binary operators@>=
case times:
if ( (mp->cur_type<mp_color_type)||(mp_type(p)<mp_color_type) ) {
- mp_bad_binary(mp, p,times);
+ mp_bad_binary(mp, p, times);
} else if ( (mp->cur_type==mp_known)||(mp_type(p)==mp_known) ) {
@<Multiply when at least one operand is known@>;
} else if ( (mp_nice_color_or_pair(mp, p,mp_type(p))&&(mp->cur_type>mp_pair_type))
@@ -20891,7 +20899,7 @@ case pythag_sub:
if ( (mp->cur_type==mp_known)&&(mp_type(p)==mp_known) ) {
if ( c==pythag_add ) mp->cur_exp=mp_pyth_add(mp, value(p),mp->cur_exp);
else mp->cur_exp=mp_pyth_sub(mp, value(p),mp->cur_exp);
- } else mp_bad_binary(mp, p,c);
+ } else mp_bad_binary(mp, p, (quarterword)c);
break;
@ The next few sections of the program deal with affine transformations
@@ -20902,18 +20910,18 @@ case rotated_by: case slanted_by:
case scaled_by: case shifted_by: case transformed_by:
case x_scaled: case y_scaled: case z_scaled:
if ( mp_type(p)==mp_path_type ) {
- path_trans(c,p); binary_return;
+ path_trans((quarterword)c, p); binary_return;
} else if ( mp_type(p)==mp_pen_type ) {
- pen_trans(c,p);
+ pen_trans((quarterword)c, p);
mp->cur_exp=mp_convex_hull(mp, mp->cur_exp);
/* rounding error could destroy convexity */
binary_return;
} else if ( (mp_type(p)==mp_pair_type)||(mp_type(p)==mp_transform_type) ) {
- mp_big_trans(mp, p,c);
+ mp_big_trans(mp, p, (quarterword)c);
} else if ( mp_type(p)==mp_picture_type ) {
- mp_do_edges_trans(mp, p,c); binary_return;
+ mp_do_edges_trans(mp, p, (quarterword)c); binary_return;
} else {
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
}
break;
@@ -21599,9 +21607,9 @@ case point_of: case precontrol_of: case postcontrol_of:
if ( mp->cur_type==mp_pair_type )
mp_pair_to_path(mp);
if ( (mp->cur_type==mp_path_type)&&(mp_type(p)==mp_known) )
- mp_find_point(mp, value(p),c);
+ mp_find_point(mp, value(p), (quarterword)c);
else
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
break;
case pen_offset_of:
if ( (mp->cur_type==mp_pen_type)&& mp_nice_pair(mp, p,mp_type(p)) )
@@ -21674,13 +21682,13 @@ static void mp_set_up_glyph_infont (MP mp, pointer p) {
mp_edge_object *h = NULL;
mp_ps_font *f = NULL;
char *n = mp_str(mp, mp->cur_exp);
- f = mp_ps_font_parse(mp, mp_find_font(mp, n));
+ f = mp_ps_font_parse(mp, (int)mp_find_font(mp, n));
if (f!=NULL) {
if (mp_type(p) == mp_known) {
int v = mp_round_unscaled(mp,value(p));
if (v<0 || v>255) {
print_err ("glyph index too high (");
- mp_print_int(mp,v);
+ mp_print_int(mp, v);
mp_print(mp,")");
mp_error(mp);
} else {
@@ -21688,7 +21696,6 @@ static void mp_set_up_glyph_infont (MP mp, pointer p) {
}
} else {
n = mp_str(mp, value(p));
- delete_str_ref(value(p));
h = mp_ps_do_font_charstring (mp,f,n);
free(n);
}
@@ -21752,7 +21759,7 @@ case arc_time_of:
if ( (mp->cur_type==mp_path_type)&&(mp_type(p)==mp_known) )
mp_flush_cur_exp(mp, mp_get_arc_time(mp, mp->cur_exp,value(p)));
else
- mp_bad_binary(mp, p,c);
+ mp_bad_binary(mp, p, (quarterword)c);
break;
@ @<Additional cases of bin...@>=
@@ -22190,7 +22197,7 @@ static void mp_try_eq (MP mp,pointer l, pointer r) ;
if ( mp_info(p)==null ) {
@<Deal with redundant or inconsistent equation@>;
} else {
- mp_linear_eq(mp, p,t);
+ mp_linear_eq(mp, p, (quarterword)t);
if ( r==null ) if ( mp->cur_type!=mp_known ) {
if ( mp_type(mp->cur_exp)==mp_known ) {
pp=mp->cur_exp; mp->cur_exp=value(mp->cur_exp); mp->cur_type=mp_known;
@@ -22261,7 +22268,7 @@ DONE1:
@ @<Add dependency list |pp| of type |tt| to dependency list~|p| of type~|t|@>=
mp->watch_coefs=false;
if ( t==tt ) {
- p=mp_p_plus_q(mp, p,pp,t);
+ p=mp_p_plus_q(mp, p,pp, (quarterword)t);
} else if ( t==mp_proto_dependent ) {
p=mp_p_plus_fq(mp, p,unity,pp,mp_proto_dependent,mp_dependent);
} else {
@@ -22269,7 +22276,7 @@ if ( t==tt ) {
while ( mp_info(q)!=null ) {
value(q)=mp_round_fraction(mp, value(q)); q=mp_link(q);
}
- t=mp_proto_dependent; p=mp_p_plus_q(mp, p,pp,t);
+ t=mp_proto_dependent; p=mp_p_plus_q(mp, p, pp, (quarterword)t);
}
mp->watch_coefs=true;
@@ -22348,7 +22355,7 @@ mp_primitive(mp, "pair",type_name,mp_pair_type);
@:pair_}{\&{pair} primitive@>
@ @<Cases of |print_cmd...@>=
-case type_name: mp_print_type(mp, m); break;
+case type_name: mp_print_type(mp, (quarterword)m); break;
@ Now we are ready to handle type declarations, assuming that a
|type_name| has just been scanned.
@@ -22362,9 +22369,9 @@ void mp_do_type_declaration (MP mp) {
pointer p; /* token list for a declared variable */
pointer q; /* value node for the variable */
if ( mp->cur_mod>=mp_transform_type )
- t=mp->cur_mod;
+ t=(quarterword)mp->cur_mod;
else
- t=mp->cur_mod+unknown_tag;
+ t=(quarterword)(mp->cur_mod+unknown_tag);
do {
p=mp_scan_declared_variable(mp);
mp_flush_variable(mp, equiv(mp_info(p)),mp_link(p),false);
@@ -22443,14 +22450,14 @@ it calls |atoi| to get an integer from the start of the string.
@c
void mp_set_internal (MP mp, char *n, char *v, int isstring) {
- integer l = strlen(n);
+ size_t l = strlen(n);
char err[256];
const char *errid = NULL;
if (l>0) {
- integer h = mp_compute_hash(mp, n,l);
+ integer h = mp_compute_hash(mp, n, (int)l);
pointer p = h+hash_base; /* we start searching here */
while (true) {
- if (text(p)>0 && length(text(p))==l &&
+ if (text(p)>0 && length(text(p))==(int)l &&
mp_str_eq_cstr(mp, text(p),n)) {
if (eq_type(p)==internal_quantity) {
if ((mp->int_type[equiv(p)]==mp_string_type) && (isstring)) {
@@ -22684,7 +22691,7 @@ static char *mplib_read_ascii_file(MP mp, void *ff, size_t * size)
return NULL;
lim += (lim >> 2);
}
- s[len++] = c;
+ s[len++] = (char)c;
c = mplib_get_char(f, run);
}
if (c == '\r') {
@@ -23461,7 +23468,7 @@ static void mp_disp_var (MP mp,pointer p) ;
mp_print(mp, "@@#"); /* |suffixed_macro| */
mp_print(mp, "=macro:");
if ( (int)mp->file_offset>=mp->max_print_line-20 ) n=5;
- else n=mp->max_print_line-mp->file_offset-15;
+ else n=mp->max_print_line-(int)mp->file_offset-15;
mp_show_macro(mp, value(p),null,n);
}
@@ -23604,7 +23611,7 @@ static void mp_scan_with_list (MP mp,pointer p) ;
cp=mp_void; pp=mp_void; dp=mp_void; ap=mp_void; bp=mp_void;
k=0;
while ( mp->cur_cmd==with_option ){
- t=mp->cur_mod;
+ t=(quarterword)mp->cur_mod;
mp_get_x_next(mp);
if ( t!=mp_no_model ) mp_scan_expression(mp);
if (((t==with_mp_pre_script)&&(mp->cur_type!=mp_string_type))||
@@ -23956,7 +23963,7 @@ static pointer mp_start_draw_cmd (MP mp,quarterword sep) ;
if ( mp->cur_type!=mp_token_list ) {
@<Abandon edges command because there's no variable@>;
} else {
- lhv=mp->cur_exp; add_type=mp->cur_mod;
+ lhv=mp->cur_exp; add_type=(quarterword)mp->cur_mod;
mp->cur_type=mp_vacuous; mp_get_x_next(mp); mp_scan_expression(mp);
}
mp->last_add_type=add_type;
@@ -24010,12 +24017,12 @@ static void mp_do_bounds (MP mp) ;
}
@ @<Make |cur_exp| into a \&{setbounds} or clipping path and add...@>=
-{ p=mp_new_bounds_node(mp, mp->cur_exp,m);
+{ p=mp_new_bounds_node(mp, mp->cur_exp, (quarterword)m);
mp_link(p)=mp_link(dummy_loc(lhe));
mp_link(dummy_loc(lhe))=p;
if ( obj_tail(lhe)==dummy_loc(lhe) ) obj_tail(lhe)=p;
p=mp_get_node(mp, mp->gr_object_size[stop_type(m)]);
- mp_type(p)=stop_type(m);
+ mp_type(p)=(quarterword)stop_type(m);
mp_link(obj_tail(lhe))=p;
obj_tail(lhe)=p;
mp_init_bbox(mp, lhe);
@@ -24797,7 +24804,7 @@ static void mp_set_tag (MP mp,halfword c, quarterword t, halfword r) ;
if ( mp->char_tag[c]==no_tag ) {
mp->char_tag[c]=t; mp->char_remainder[c]=r;
if ( t==lig_tag ){
- incr(mp->label_ptr); mp->label_loc[mp->label_ptr]=r;
+ mp->label_ptr++; mp->label_loc[mp->label_ptr]=(short)r;
mp->label_char[mp->label_ptr]=(eight_bits)c;
}
} else {
@@ -24901,7 +24908,7 @@ CONTINUE:
skip_byte(mp->nl)=stop_flag+1; /* this specifies an unconditional stop */
}
if ( mp->nl==max_tfm_int) mp_fatal_error(mp, "ligtable too large");
- incr(mp->nl);
+ mp->nl++;
if ( mp->cur_cmd==comma ) goto CONTINUE;
if ( skip_byte(mp->nl-1)<stop_flag ) skip_byte(mp->nl-1)=stop_flag;
}
@@ -24954,7 +24961,7 @@ We may need to cancel skips that span more than 127 lig/kern steps.
@d cancel_skips(A) mp->ll=(A);
do {
mp->lll=qo(skip_byte(mp->ll));
- skip_byte(mp->ll)=stop_flag; mp->ll=mp->ll-mp->lll;
+ skip_byte(mp->ll)=stop_flag; mp->ll=(short)(mp->ll-mp->lll);
} while (mp->lll!=0)
@d skip_error(A) { print_err("Too far to skip");
@.Too far to skip@>
@@ -24966,11 +24973,11 @@ We may need to cancel skips that span more than 127 lig/kern steps.
{
c=mp_get_code(mp);
if ( mp->nl-mp->skip_table[c]>128 ) {
- skip_error(mp->skip_table[c]); mp->skip_table[c]=undefined_label;
+ skip_error(mp->skip_table[c]); mp->skip_table[c]=(short)undefined_label;
}
if ( mp->skip_table[c]==undefined_label ) skip_byte(mp->nl-1)=qi(0);
else skip_byte(mp->nl-1)=qi(mp->nl-mp->skip_table[c]-1);
- mp->skip_table[c]=mp->nl-1; goto DONE;
+ mp->skip_table[c]=(short)(mp->nl-1); goto DONE;
}
@ @<Record a label in a lig/kern subprogram and |goto continue|@>=
@@ -24985,7 +24992,7 @@ We may need to cancel skips that span more than 127 lig/kern steps.
if ( mp->nl-mp->ll>128 ) {
skip_error(mp->ll); goto CONTINUE;
}
- skip_byte(mp->ll)=qi(mp->nl-mp->ll-1); mp->ll=mp->ll-mp->lll;
+ skip_byte(mp->ll)=qi(mp->nl-mp->ll-1); mp->ll=(short)(mp->ll-mp->lll);
} while (mp->lll!=0);
}
goto CONTINUE;
@@ -25010,9 +25017,9 @@ We may need to cancel skips that span more than 127 lig/kern steps.
while ( mp->kern[k]!=mp->cur_exp ) incr(k);
if ( k==mp->nk ) {
if ( mp->nk==max_tfm_int ) mp_fatal_error(mp, "too many TFM kerns");
- incr(mp->nk);
+ mp->nk++;
}
- op_byte(mp->nl)=kern_flag+(k / 256);
+ op_byte(mp->nl)=qi(kern_flag+(k / 256));
rem_byte(mp->nl)=qi((k % 256));
}
mp->lk_started=true;
@@ -25036,7 +25043,7 @@ We may need to cancel skips that span more than 127 lig/kern steps.
ext_bot(mp->ne)=qi(mp_get_code(mp));
if ( mp->cur_cmd!=comma ) missing_extensible_punctuation(",");
ext_rep(mp->ne)=qi(mp_get_code(mp));
- incr(mp->ne);
+ mp->ne++;
}
@ The header could contain ASCII zeroes, so can't use |strdup|.
@@ -25060,7 +25067,7 @@ do {
@ @<Store a list of font dimensions@>=
do {
if ( j>max_tfm_int ) mp_fatal_error(mp, "too many fontdimens");
- while ( j>mp->np ) { incr(mp->np); mp->param[mp->np]=0; };
+ while ( j>mp->np ) { mp->np++; mp->param[mp->np]=0; };
mp_get_x_next(mp); mp_scan_expression(mp);
if ( mp->cur_type!=mp_known ){
exp_err("Improper font parameter");
@@ -25243,7 +25250,7 @@ for (k=mp->bc;k<=mp->ec;k++) {
if ( mp->char_exists[k] )
mp->tfm_width[k]=mp_sort_in(mp, mp->tfm_width[k]);
}
-mp->nw=mp_skimp(mp, 255)+1; mp->dimen_head[1]=mp_link(temp_head);
+mp->nw=(short)(mp_skimp(mp, 255)+1); mp->dimen_head[1]=mp_link(temp_head);
if ( mp->perturbation>=010000 ) mp_tfm_warning(mp, mp_char_wd)
@ @<Glob...@>=
@@ -25261,7 +25268,7 @@ for (k=mp->bc;k<=mp->ec;k++) {
else mp->tfm_height[k]=mp_sort_in(mp, mp->tfm_height[k]);
}
}
-mp->nh=mp_skimp(mp, 15)+1; mp->dimen_head[2]=mp_link(temp_head);
+mp->nh=(short)(mp_skimp(mp, 15)+1); mp->dimen_head[2]=mp_link(temp_head);
if ( mp->perturbation>=010000 ) mp_tfm_warning(mp, mp_char_ht);
clear_the_list;
for (k=mp->bc;k<=mp->ec;k++) {
@@ -25270,7 +25277,7 @@ for (k=mp->bc;k<=mp->ec;k++) {
else mp->tfm_depth[k]=mp_sort_in(mp, mp->tfm_depth[k]);
}
}
-mp->nd=mp_skimp(mp, 15)+1; mp->dimen_head[3]=mp_link(temp_head);
+mp->nd=(short)(mp_skimp(mp, 15)+1); mp->dimen_head[3]=mp_link(temp_head);
if ( mp->perturbation>=010000 ) mp_tfm_warning(mp, mp_char_dp);
clear_the_list;
for (k=mp->bc;k<=mp->ec;k++) {
@@ -25279,7 +25286,7 @@ for (k=mp->bc;k<=mp->ec;k++) {
else mp->tfm_ital_corr[k]=mp_sort_in(mp, mp->tfm_ital_corr[k]);
}
}
-mp->ni=mp_skimp(mp, 63)+1; mp->dimen_head[4]=mp_link(temp_head);
+mp->ni=(short)(mp_skimp(mp, 63)+1); mp->dimen_head[4]=mp_link(temp_head);
if ( mp->perturbation>=010000 ) mp_tfm_warning(mp, mp_char_ic)
@ @<Initialize table entries...@>=
@@ -25310,10 +25317,10 @@ static void mp_fix_design_size (MP mp) {
}
if ( mp->header_byte[4]==0 && mp->header_byte[5]==0 &&
mp->header_byte[6]==0 && mp->header_byte[7]==0 ) {
- mp->header_byte[4]=d / 04000000;
- mp->header_byte[5]=(d / 4096) % 256;
- mp->header_byte[6]=(d / 16) % 256;
- mp->header_byte[7]=(d % 16)*16;
+ mp->header_byte[4]=(char)(d / 04000000);
+ mp->header_byte[5]=(char)((d / 4096) % 256);
+ mp->header_byte[6]=(char)((d / 16) % 256);
+ mp->header_byte[7]=(char)((d % 16)*16);
}
mp->max_tfm_dimen=16*mp->internal[mp_design_size]-1-mp->internal[mp_design_size] / 010000000;
if ( mp->max_tfm_dimen>=fraction_half ) mp->max_tfm_dimen=fraction_half-1;
@@ -25475,7 +25482,7 @@ if ( mp->bch_label<undefined_label )
{ skip_byte(mp->nl)=qi(255); next_char(mp->nl)=qi(0);
op_byte(mp->nl)=qi(((mp->bch_label+lk_offset)/ 256));
rem_byte(mp->nl)=qi(((mp->bch_label+lk_offset)% 256));
- incr(mp->nl); /* possibly |nl=lig_table_size+1| */
+ mp->nl++; /* possibly |nl=lig_table_size+1| */
}
@ @<Find the minimum |lk_offset|...@>=
@@ -25516,7 +25523,7 @@ if ( mp->lk_started ) { /* |lk_offset=1| for the special |bchar| */
else { tfm_out(255); tfm_out(mp->bchar); };
mp_tfm_two(mp, mp->ll+lk_offset);
do {
- decr(mp->label_ptr);
+ mp->label_ptr--;
} while (! (mp->label_loc[mp->label_ptr]<mp->ll));
}
}
@@ -25554,9 +25561,9 @@ if ( mp->tfm_changed>0 ) {
{
char s[200];
wlog_ln(" ");
- if ( mp->bch_label<undefined_label ) decr(mp->nl);
+ if ( mp->bch_label<undefined_label ) mp->nl--;
mp_snprintf(s,128,"(You used %iw,%ih,%id,%ii,%il,%ik,%ie,%ip metric file positions)",
- mp->nw, mp->nh, mp->nd, mp->ni, mp->nl, mp->nk, mp->ne,mp->np);
+ mp->nw, mp->nh, mp->nd, mp->ni, mp->nl, mp->nk, mp->ne, mp->np);
wlog_ln(s);
}
@@ -25676,8 +25683,8 @@ mp->depth_base[null_font]=0;
mp->next_fmem=0;
mp->last_fnum=null_font;
mp->last_ps_fnum=null_font;
-mp->font_name[null_font]=(char *)"nullfont";
-mp->font_ps_name[null_font]=(char *)"";
+mp->font_name[null_font]=mp_xstrdup(mp,"nullfont");
+mp->font_ps_name[null_font]=mp_xstrdup(mp,"");
mp->font_ps_name_fixed[null_font] = false;
mp->font_enc_name[null_font]=NULL;
mp->font_sizes[null_font]=null;
@@ -25889,8 +25896,8 @@ for (i = 1;i<= 9; i++ ) {
@ The following function divides |s| by |m|. |dd| is number of decimal digits.
-@c
-#if 0 /* unused */
+@c
+#if 0
scaled mp_divide_scaled (MP mp,scaled s, scaled m, integer dd) {
scaled q,r;
integer sign,i;
@@ -26019,8 +26026,8 @@ static char *mp_set_output_file_name (MP mp, integer c) {
if (l>0) {
integer h = mp_compute_hash(mp, (char *)(mp->str_pool+frst),l);
pointer p=h+hash_base; /* we start searching here */
- char *id = xmalloc(mp, (l+1));
- (void)memcpy(id,(char *)(mp->str_pool+frst),l);
+ char *id = xmalloc(mp, (size_t)(l+1));
+ (void)memcpy(id,(char *)(mp->str_pool+frst),(size_t)l);
*(id+l)=0;
while (true) {
if (text(p)>0 && length(text(p))==l &&
@@ -26366,7 +26373,7 @@ struct mp_edge_object *mp_gr_export(MP mp, pointer h) {
pc=mp_link(pc);
t=1;
}
- pc=mp_make_envelope(mp,pc,mp_pen_p(p),ljoin_val(p),t,miterlim_val(p));
+ pc=mp_make_envelope(mp,pc,mp_pen_p(p),ljoin_val(p),(quarterword)t,miterlim_val(p));
gr_path_p(ts) = mp_export_knot_list(mp,pc);
mp_toss_knot_list(mp, pc);
}
@@ -26833,7 +26840,7 @@ been scanned.
@c
void mp_final_cleanup (MP mp) {
- quarterword c; /* 0 for \&{end}, 1 for \&{dump} */
+ integer c; /* 0 for \&{end}, 1 for \&{dump} */
c=mp->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/mpost.w b/Build/source/texk/web2c/mplibdir/mpost.w
index c33531b85ca..d8b87b10523 100644
--- a/Build/source/texk/web2c/mplibdir/mpost.w
+++ b/Build/source/texk/web2c/mplibdir/mpost.w
@@ -1,4 +1,4 @@
-% $Id: mpost.w 1061 2009-05-27 13:01:37Z taco $
+% $Id: mpost.w 1219 2010-04-01 09:05:51Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -55,6 +55,7 @@ have our customary command-line interface.
#include <kpathsea/kpathsea.h>
@= /*@@null@@*/ @> static char *mpost_tex_program = NULL;
static int debug = 0; /* debugging for makempx */
+static int nokpse = 0;
#ifdef WIN32
#define GETCWD _getcwd
#else
@@ -66,6 +67,8 @@ static FILE *recorder_file = NULL;
static char *job_name = NULL;
static char *job_area = NULL;
static int dvitomp_only = 0;
+static int ini_version_test = false;
+@<getopt structures@>;
@ Allocating a bit of memory, with error detection:
@@ -379,7 +382,8 @@ static int mpost_run_make_mpx (MP mp, char *mpname, char *mpxname) {
}
static int mpost_run_dvitomp (char *dviname, char *mpxname) {
- int i, ret;
+ int ret;
+ size_t i;
char *m, *d;
mpx_options * mpxopt;
char *mpversion = mp_metapost_version () ;
@@ -433,6 +437,7 @@ static int mpost_run_dvitomp (char *dviname, char *mpxname) {
mpost_xfree(mpxopt->banner);
mpost_xfree(mpxopt);
mpost_xfree(mpversion);
+ puts(""); /* nicer in case of error */
return ret;
}
@@ -449,7 +454,7 @@ static int get_random_seed (void) {
#if defined (HAVE_GETTIMEOFDAY)
struct timeval tv;
gettimeofday(&tv, NULL);
- ret = (tv.tv_usec + 1000000 * tv.tv_usec);
+ ret = (int)(tv.tv_usec + 1000000 * tv.tv_usec);
#elif defined (HAVE_FTIME)
struct timeb tb;
ftime(&tb);
@@ -591,7 +596,7 @@ static void internal_set_option(const char *opt) {
s = mpost_xstrdup(opt) ;
v = strstr(s,"=") ;
if (v==NULL) {
- v="1";
+ v = xstrdup("1");
} else {
*v='\0'; /* terminates |s| */
v++;
@@ -669,149 +674,182 @@ static void *mpost_open_file(MP mp, const char *fname, const char *fmode, int ft
if (!nokpse)
options->open_file = mpost_open_file;
+@
+@<getopt structures@>=
+#define ARGUMENT_IS(a) STREQ (mpost_options[optionid].name, a)
+
+/* SunOS cc can't initialize automatic structs, so make this static. */
+static struct option mpost_options[]
+ = { { "mem", 1, 0, 0 },
+ { "help", 0, 0, 0 },
+ { "debug", 0, &debug, 1 },
+ { "no-kpathsea", 0, &nokpse, 1 },
+ { "dvitomp", 0, &dvitomp_only, 1 },
+ { "ini", 0, &ini_version_test, 1 },
+ { "interaction", 1, 0, 0 },
+ { "halt-on-error", 0, 0, 0 },
+ { "kpathsea-debug", 1, 0, 0 },
+ { "progname", 1, 0, 0 },
+ { "version", 0, 0, 0 },
+ { "recorder", 0, &recorder_enabled, 1 },
+ { "file-line-error-style", 0, 0, 0 },
+ { "no-file-line-error-style", 0, 0, 0 },
+ { "file-line-error", 0, 0, 0 },
+ { "no-file-line-error", 0, 0, 0 },
+ { "jobname", 1, 0, 0 },
+ { "output-directory", 1, 0, 0 },
+ { "s", 1, 0, 0 },
+ { "parse-first-line", 0, 0, 0 },
+ { "no-parse-first-line", 0, 0, 0 },
+ { "8bit", 0, 0, 0 },
+ { "T", 0, 0, 0 },
+ { "troff", 0, 0, 0 },
+ { "tex", 1, 0, 0 },
+ { 0, 0, 0, 0 } };
-@ Parsing the commandline options.
-@d option_is(A) ((strncmp(argv[a],"--" A, strlen(A)+2)==0) ||
- (strncmp(argv[a],"-" A, strlen(A)+1)==0))
-@d option_arg(B) (mpost_optarg != NULL && strncmp(mpost_optarg,B, strlen(B))==0)
+@ Parsing the commandline options.
@<Read and set command line options@>=
{
- char *mpost_optarg;
- boolean ini_version_test = false;
- while (++a<argc) {
- mpost_optarg = strstr(argv[a],"=") ;
- if (mpost_optarg!=NULL) {
- mpost_optarg++;
- if (*mpost_optarg == '\0') mpost_optarg=NULL;
+ int g; /* `getopt' return code. */
+ int optionid;
+ for (;;) {
+ g = getopt_long_only (argc, argv, "+", mpost_options, &optionid);
+
+ if (g == -1) /* End of arguments, exit the loop. */
+ break;
+
+ if (g == '?') { /* Unknown option. */
+ fprintf(stdout,"fatal error: %s: unknown option %s\n", argv[0], argv[optind]);
+ exit(EXIT_FAILURE);
}
- if (option_is("ini")) {
- ini_version_test = true;
- } else if (option_is("s")) {
- char *s_head = argv[a];
- while (*s_head!='s') s_head++;
- s_head++;
- if (!*s_head) {
- if (((a+1)<argc) && (*(argv[(a+1)])!='-')) {
- internal_set_option(argv[++a]);
- } else {
- fprintf(stdout,"fatal error: %s: missing -s argument\n", argv[0]);
- exit(EXIT_FAILURE);
- }
- } else {
- internal_set_option(s_head);
- }
- } else if (option_is("debug")) {
- debug = 1;
- } else if (option_is ("kpathsea-debug")) {
- if (mpost_optarg!=NULL)
- kpathsea_debug |= atoi (mpost_optarg);
- } else if (option_is("mem")) {
- if (mpost_optarg!=NULL) {
+
+ if (ARGUMENT_IS ("kpathsea-debug")) {
+ kpathsea_debug |= atoi (optarg);
+
+ } else if (ARGUMENT_IS("jobname")) {
+ if (optarg!=NULL) {
+ mpost_xfree(options->job_name);
+ options->job_name = mpost_xstrdup(optarg);
+ }
+
+ } else if (ARGUMENT_IS ("progname")) {
+ user_progname = optarg;
+
+ } else if (ARGUMENT_IS ("mem")) {
+ if (optarg!=NULL) {
mpost_xfree(options->mem_name);
- options->mem_name = mpost_xstrdup(mpost_optarg);
+ options->mem_name = mpost_xstrdup(optarg);
if (user_progname == NULL)
- user_progname = mpost_optarg;
- }
- } else if (option_is("jobname")) {
- if (mpost_optarg!=NULL) {
- mpost_xfree(options->job_name);
- options->job_name = mpost_xstrdup(mpost_optarg);
+ user_progname = optarg;
}
- } else if (option_is ("progname")) {
- user_progname = mpost_optarg;
- } else if (option_is("troff") || option_is("T")) {
- options->troff_mode = (int)true;
- } else if (option_is("recorder")) {
- recorder_enabled = true;
- } else if (option_is ("tex")) {
- mpost_tex_program = mpost_optarg;
- } else if (option_is("interaction")) {
- if (option_arg("batchmode")) {
+
+ } else if (ARGUMENT_IS ("interaction")) {
+ if (STREQ (optarg, "batchmode")) {
options->interaction = mp_batch_mode;
- } else if (option_arg("nonstopmode")) {
+ } else if (STREQ (optarg, "nonstopmode")) {
options->interaction = mp_nonstop_mode;
- } else if (option_arg("scrollmode")) {
+ } else if (STREQ (optarg, "scrollmode")) {
options->interaction = mp_scroll_mode;
- } else if (option_arg("errorstopmode")) {
+ } else if (STREQ (optarg, "errorstopmode")) {
options->interaction = mp_error_stop_mode;
} else {
- fprintf(stdout,"warning: %s: unknown option argument %s\n", argv[0], argv[a]);
+ fprintf(stdout,"Ignoring unknown argument `%s' to --interaction", optarg);
}
- } else if (option_is("no-kpathsea")) {
- nokpse=true;
- } else if (option_is("file-line-error")) {
+ } else if (ARGUMENT_IS("troff") ||
+ ARGUMENT_IS("T")) {
+ options->troff_mode = (int)true;
+ } else if (ARGUMENT_IS ("tex")) {
+ mpost_tex_program = optarg;
+ } else if (ARGUMENT_IS("file-line-error") ||
+ ARGUMENT_IS("file-line-error-style")) {
options->file_line_error_style=true;
- } else if (option_is("no-file-line-error")) {
+ } else if (ARGUMENT_IS("no-file-line-error") ||
+ ARGUMENT_IS("no-file-line-error-style")) {
options->file_line_error_style=false;
- } else if (option_is("dvitomp")) {
- dvitomp_only = 1;
- } else if (option_is("help")) {
+ } else if (ARGUMENT_IS("help")) {
if (dvitomp_only) {
@<Show short help and exit@>;
} else {
@<Show help and exit@>;
}
- } else if (option_is("version")) {
+ } else if (ARGUMENT_IS("version")) {
@<Show version and exit@>;
- } else if (option_is("8bit") ||
- option_is("parse-first-line")) {
+ } else if (ARGUMENT_IS("s")) {
+ if (strchr(optarg,'=')==NULL) {
+ fprintf(stdout,"fatal error: %s: missing -s argument\n", argv[0]);
+ exit (EXIT_FAILURE);
+ } else {
+ internal_set_option(optarg);
+ }
+ } else if (ARGUMENT_IS("halt-on-error")) {
+ options->halt_on_error = true;
+ } else if (ARGUMENT_IS("8bit") ||
+ ARGUMENT_IS("parse-first-line")) {
/* do nothing, these are always on */
- } else if (option_is("halt-on-error")) {
- options->halt_on_error = true;
- } else if (option_is("translate-file") ||
- option_is("output-directory") ||
- option_is("no-parse-first-line")) {
- fprintf(stdout,"warning: %s: unimplemented option %s\n", argv[0], argv[a]);
- } else if (option_is("")) {
- fprintf(stdout,"fatal error: %s: unknown option %s\n", argv[0], argv[a]);
- exit(EXIT_FAILURE);
- } else {
- break;
- }
- }
+ } else if (ARGUMENT_IS("translate-file") ||
+ ARGUMENT_IS("output-directory") ||
+ ARGUMENT_IS("no-parse-first-line")) {
+ fprintf(stdout,"warning: %s: unimplemented option %s\n", argv[0], argv[optind]);
+ }
+ }
options->ini_version = (int)ini_version_test;
}
+@
+@<getopt structures@>=
+#define option_is(a) STREQ (dvitomp_options[optionid].name, a)
+
+/* SunOS cc can't initialize automatic structs, so make this static. */
+static struct option dvitomp_options[]
+ = { { "help", 0, 0, 0 },
+ { "no-kpathsea", 0, &nokpse, 1 },
+ { "kpathsea-debug", 1, 0, 0 },
+ { "progname", 1, 0, 0 },
+ { "version", 0, 0, 0 },
+ { 0, 0, 0, 0 } };
+
+
+
@
@<Read and set dvitomp command line options@>=
{
- char *mpost_optarg;
- boolean ini_version_test = false;
- while (++a<argc) {
- mpost_optarg = strstr(argv[a],"=") ;
- if (mpost_optarg!=NULL) {
- mpost_optarg++;
- if (*mpost_optarg == '\0') mpost_optarg=NULL;
+ int g; /* `getopt' return code. */
+ int optionid;
+ for (;;) {
+ g = getopt_long_only (argc, argv, "+", dvitomp_options, &optionid);
+
+ if (g == -1) /* End of arguments, exit the loop. */
+ break;
+
+ if (g == '?') { /* Unknown option. */
+ fprintf(stdout,"fatal error: %s: unknown option %s\n", argv[0], argv[optind]);
+ exit(EXIT_FAILURE);
}
- if (option_is("debug")) {
- debug = 1;
- } else if (option_is ("kpathsea-debug")) {
- if (mpost_optarg!=NULL)
- kpathsea_debug |= atoi (mpost_optarg);
+ if (option_is ("kpathsea-debug")) {
+ if (optarg!=NULL)
+ kpathsea_debug |= atoi (optarg);
} else if (option_is ("progname")) {
- user_progname = mpost_optarg;
- } else if (option_is("no-kpathsea")) {
- nokpse=true;
+ user_progname = optarg;
} else if (option_is("help")) {
@<Show short help and exit@>;
} else if (option_is("version")) {
@<Show version and exit@>;
- } else if (option_is("")) {
- fprintf(stdout,"fatal error: %s: unknown option %s\n", argv[0], argv[a]);
- exit(EXIT_FAILURE);
- } else {
- break;
}
}
- options->ini_version = (int)ini_version_test;
}
@
@<Show help...@>=
{
+char *s = mp_metapost_version();
+if (dvitomp_only)
+ fprintf(stdout, "\n" "This is dvitomp %s\n", s);
+else
+ fprintf(stdout, "\n" "This is MetaPost %s\n", s);
+mpost_xfree(s);
fprintf(stdout,
"\n"
"Usage: mpost [OPTION] [&MEMNAME] [MPNAME[.mp]] [COMMANDS]\n"
@@ -833,13 +871,14 @@ fprintf(stdout,
" [-no]-file-line-error disable/enable file:line:error style messages\n"
);
fprintf(stdout,
+" -debug print debugging info and leave temporary files in place\n"
" -kpathsea-debug=NUMBER set path searching debugging flags according to\n"
" the bits of NUMBER\n"
" -mem=MEMNAME or &MEMNAME use MEMNAME instead of program name or a %%& line\n"
" -recorder enable filename recorder\n"
" -troff set prologues:=1 and assume TEXPROGRAM is really troff\n"
-" -sINTERNAL=\"STRING\" set internal INTERNAL to the string value STRING\n"
-" -sINTERNAL=NUMBER set internal INTERNAL to the integer value NUMBER\n"
+" -s INTERNAL=\"STRING\" set internal INTERNAL to the string value STRING\n"
+" -s INTERNAL=NUMBER set internal INTERNAL to the integer value NUMBER\n"
" -help display this help and exit\n"
" -version output version information and exit\n"
"\n"
@@ -851,6 +890,12 @@ fprintf(stdout,
@
@<Show short help...@>=
{
+char *s = mp_metapost_version();
+if (dvitomp_only)
+ fprintf(stdout, "\n" "This is dvitomp %s\n", s);
+else
+ fprintf(stdout, "\n" "This is MetaPost %s\n", s);
+mpost_xfree(s);
fprintf(stdout,
"\n"
"Usage: dvitomp DVINAME[.dvi] [MPXNAME[.mpx]]\n"
@@ -902,10 +947,10 @@ input.
mpost_xfree(options->command_line);
options->command_line = mpost_xmalloc(command_line_size);
strcpy(options->command_line,"");
- if (a<argc) {
+ if (optind<argc) {
k=0;
- for(;a<argc;a++) {
- char *c = argv[a];
+ for(;optind<argc;optind++) {
+ char *c = argv[optind];
while (*c != '\0') {
if (k<(command_line_size-1)) {
options->command_line[k++] = *c;
@@ -1107,12 +1152,9 @@ if (options->job_name != NULL) {
if (tmp_job == NULL) {
tmp_job = mpost_xstrdup("mpout");
} else {
- size_t i = strlen(tmp_job);
- if (i>3
- && *(tmp_job+i-3)=='.'
- && *(tmp_job+i-2)=='m'
- && *(tmp_job+i-1)=='p')
- *(tmp_job+i-3)='\0';
+ char *ext = strrchr(tmp_job,'.');
+ if (ext != NULL)
+ *ext = '\0';
}
}
/* now split |tmp_job| into |job_area| and |job_name| */
@@ -1150,8 +1192,6 @@ int main (int argc, char **argv) { /* |start_here| */
int history; /* the exit status */
MP mp; /* a metapost instance */
struct MP_options * options; /* instance options */
- int a=0; /* argc counter */
- boolean nokpse = false; /* switch to {\it not} enable kpse */
char *user_progname = NULL; /* If the user overrides |argv[0]| with {\tt -progname}. */
options = mp_options();
options->ini_version = (int)false;
@@ -1164,12 +1204,12 @@ int main (int argc, char **argv) { /* |start_here| */
}
if (dvitomp_only) {
char *mpx = NULL, *dvi = NULL;
- if (a==argc) {
+ if (optind>=argc) {
/* error ? */
} else {
- dvi = argv[a++];
- if (a<argc) {
- mpx = argv[a++];
+ dvi = argv[optind++];
+ if (optind<argc) {
+ mpx = argv[optind++];
}
}
if (dvi == NULL) {
@@ -1188,7 +1228,7 @@ int main (int argc, char **argv) { /* |start_here| */
kpse_set_program_name(argv[0], user_progname);
}
@= /*@@=nullpass@@*/ @>
- if(putenv((char *)"engine=metapost"))
+ if(putenv(xstrdup("engine=metapost")))
fprintf(stdout,"warning: could not set up $engine\n");
options->main_memory = setup_var (50000,"main_memory",nokpse);
options->hash_size = (unsigned)setup_var (16384,"hash_size",nokpse);
diff --git a/Build/source/texk/web2c/mplibdir/mpxout.w b/Build/source/texk/web2c/mplibdir/mpxout.w
index 616ba9ae90c..6f7859b98ad 100644
--- a/Build/source/texk/web2c/mplibdir/mpxout.w
+++ b/Build/source/texk/web2c/mplibdir/mpxout.w
@@ -1,4 +1,4 @@
-% $Id: mpxout.w 1061 2009-05-27 13:01:37Z taco $
+% $Id: mpxout.w 1219 2010-04-01 09:05:51Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -260,6 +260,8 @@ static void mpx_abort(MPX mpx, const char *msg, ...) {
va_start(ap, msg);
fprintf(stderr, "fatal: ");
(void)vfprintf(stderr, msg, ap);
+ va_end(ap);
+ va_start(ap, msg);
mpx_printf(mpx, "fatal", msg, ap);
va_end(ap);
mpx->history=mpx_fatal_error;
@@ -400,7 +402,7 @@ static char *mpx_getline(MPX mpx, FILE *mpfile) {
if (mpx->buf==NULL)
mpx->buf = xmalloc(mpx->bufsize,1);
while ((c = getc(mpfile)) != EOF && c != '\n' && c != '\r') {
- mpx->buf[loc++] = c;
+ mpx->buf[loc++] = (char)c;
if (loc == mpx->bufsize) {
char *temp = mpx->buf;
unsigned n = mpx->bufsize + (mpx->bufsize>>4);
@@ -447,7 +449,14 @@ a percent sign, or an alphabetic token \.{btex}, \.{etex}, or
\.{verbatimtex}. (An alphabetic token is a maximal sequence of letters
and underscores.) If there are several possible substrings $t$, we
choose the leftmost one. If there is no such $t$, we set $b=s$ and return 0.
-
+
+Various values are defined, so that |mpx_copy_mpto| can distinguish between
+\.{verbatimtex} ... \.{etex} and \.{btex} ... \.{etex} (the former has no
+whitespace corrections applied).
+
+@d VERBATIM_TEX 1
+@d B_TEX 2
+
@c
static int mpx_getbta(MPX mpx, char *s) {
int ok = 1; /* zero if last character was |a-z|, |A-Z|, or |_| */
@@ -465,24 +474,27 @@ static int mpx_getbta(MPX mpx, char *s) {
return 1;
case 'b':
if (ok && mpx_match_str(mpx->tt, "btex")) {
- mpx->aa = mpx->tt + 4;
- return 1;
- } else
- ok = 0;
+ mpx->aa = mpx->tt + 4;
+ return 1;
+ } else {
+ ok = 0;
+ }
break;
case 'e':
if (ok && mpx_match_str(mpx->tt, "etex")) {
- mpx->aa = mpx->tt + 4;
- return 1;
- } else
- ok = 0;
+ mpx->aa = mpx->tt + 4;
+ return 1;
+ } else {
+ ok = 0;
+ }
break;
case 'v':
if (ok && mpx_match_str(mpx->tt, "verbatimtex")) {
- mpx->aa = mpx->tt + 11;
- return 1;
- } else
- ok = 0;
+ mpx->aa = mpx->tt + 11;
+ return 1;
+ } else {
+ ok = 0;
+ }
break;
default:
if ((*(mpx->tt) >= 'a' && *(mpx->tt) <= 'z') ||
@@ -498,61 +510,66 @@ static int mpx_getbta(MPX mpx, char *s) {
}
@ @c
-static void mpx_copy_mpto (MPX mpx, FILE *outfile) {
+static void mpx_copy_mpto (MPX mpx, FILE *outfile, int textype) {
char *s; /* where a string to print stops */
char *t; /* for finding start of last line */
char c;
char *res = NULL;
do {
- if (mpx->aa == NULL || *mpx->aa == 0) {
- if ((mpx->aa = mpx_getline(mpx,mpx->mpfile)) == NULL) {
- mpx_error(mpx,"btex section does not end");
- return;
+ if (mpx->aa == NULL || *mpx->aa == 0) {
+ if ((mpx->aa = mpx_getline(mpx,mpx->mpfile)) == NULL) {
+ mpx_error(mpx,"btex section does not end");
+ return;
+ }
}
- }
- if (mpx_getbta(mpx, mpx->aa) && *(mpx->tt) == 'e') {
- s = mpx->tt;
- } else {
- if (mpx->tt == NULL) {
- mpx_error(mpx,"btex section does not end");
- return;
- } else if (*(mpx->tt) == 'b') {
- mpx_error(mpx,"btex in TeX mode");
- return;
- } else if (*(mpx->tt) == 'v') {
- mpx_error(mpx,"verbatimtex in TeX mode");
- return;
+ if (mpx_getbta(mpx, mpx->aa) && *(mpx->tt) == 'e') {
+ s = mpx->tt;
+ } else {
+ if (mpx->tt == NULL) {
+ mpx_error(mpx,"btex section does not end");
+ return;
+ } else if (*(mpx->tt) == 'b') {
+ mpx_error(mpx,"btex in TeX mode");
+ return;
+ } else if (*(mpx->tt) == 'v') {
+ mpx_error(mpx,"verbatimtex in TeX mode");
+ return;
+ }
+ s = mpx->aa;
}
- s = mpx->aa;
- }
- c = *s;
- *s = 0;
- if (res==NULL) {
- res = xmalloc(strlen(mpx->bb)+2,1);
- res = strncpy(res,mpx->bb,(strlen(mpx->bb)+1));
- } else {
- res = xrealloc(res,strlen(res)+strlen(mpx->bb)+2,1);
- res = strncat(res,mpx->bb, strlen(mpx->bb));
- }
- if (c == '\0')
+ c = *s;
+ *s = 0;
+ if (res==NULL) {
+ res = xmalloc(strlen(mpx->bb)+2,1);
+ res = strncpy(res,mpx->bb,(strlen(mpx->bb)+1));
+ } else {
+ res = xrealloc(res,strlen(res)+strlen(mpx->bb)+2,1);
+ res = strncat(res,mpx->bb, strlen(mpx->bb));
+ }
+ if (c == '\0')
res = strncat(res, "\n", 1);
- *s = c;
+ *s = c;
} while (*(mpx->tt) != 'e');
- /* whitespace at the end */
- for (s = res + strlen(res) - 1;
+ s = res;
+ if (textype != VERBATIM_TEX) {
+ /* whitespace at the end */
+ for (s = res + strlen(res) - 1;
s >= res && (*s == ' ' || *s == '\t' || *s == '\r' || *s == '\n'); s--);
- t = s;
- *(++s) = '\0';
- /* whitespace at the start */
- for (s = res;
+ t = s;
+ *(++s) = '\0';
+ /* whitespace at the start */
+ for (s = res;
s < (res + strlen(res)) && (*s == ' ' || *s == '\t' || *s == '\r'
|| *s == '\n'); s++);
- for (; *t != '\n' && t > s; t--);
+ for (; *t != '\n' && t > s; t--);
+ }
fprintf(outfile,"%s", s);
- /* put no |%| at end if it's only 1 line total, starting with |%|;
- * this covers the special case |%&format| in a single line. */
- if (t != s || *t != '%')
- fprintf(outfile,"%%");
+ if (textype != VERBATIM_TEX) {
+ /* put no |%| at end if it's only 1 line total, starting with |%|;
+ * this covers the special case |%&format| in a single line. */
+ if (t != s || *t != '%')
+ fprintf(outfile,"%%");
+ }
free(res);
}
@@ -630,14 +647,14 @@ static void mpx_mpto(MPX mpx, char *tmpname, char *mptexpre) {
fprintf(outfile,mpx_pretex1[mode], mpx->lnno, mpname);
else
fprintf(outfile,mpx_pretex[mode], mpx->lnno, mpname);
- mpx_copy_mpto(mpx, outfile);
+ mpx_copy_mpto(mpx, outfile, B_TEX);
fprintf(outfile,"%s", mpx_posttex[mode]);
} else if (*(mpx->tt) == 'v') {
if (mpx->verbcnt++ == 0 && mpx->texcnt == 0)
fprintf(outfile,mpx_preverb1[mode], mpx->lnno, mpname);
else
fprintf(outfile,mpx_preverb[mode], mpx->lnno, mpname);
- mpx_copy_mpto(mpx, outfile);
+ mpx_copy_mpto(mpx, outfile, VERBATIM_TEX);
fprintf(outfile,"%s", mpx_postverb[mode]);
} else {
mpx_error(mpx,"unmatched etex");
@@ -1091,7 +1108,7 @@ n=mpx_get_byte(mpx); /* that is the area */
n=n+mpx_get_byte(mpx);
mpx->font_name[mpx->nfonts]=xmalloc((size_t)(n+1),1);
for (k=0;k<n;k++)
- mpx->font_name[mpx->nfonts][k]=mpx_get_byte(mpx);
+ mpx->font_name[mpx->nfonts][k]=(char)mpx_get_byte(mpx);
mpx->font_name[mpx->nfonts][k]=0
@ The scaled size and design size are stored in \.{DVI} units divided by $2^{20}$.
@@ -1185,7 +1202,7 @@ static void mpx_in_TFM (MPX mpx,web_integer f) {
web_integer k; /* index for loops */
int lh; /* length of the header data, in four-byte words */
int nw; /* number of words in the width table */
- unsigned wp; /* new value of |info_ptr| after successful input */
+ unsigned int wp; /* new value of |info_ptr| after successful input */
@<Read past the header data; |abort| if there is a problem@>;
@<Store character-width indices at the end of the |width| table@>;
@<Read the width values into the |in_width| table@>;
@@ -1201,10 +1218,10 @@ mpx_read_tfm_word(mpx);
mpx->font_bc[f]=mpx->b0*(int)(256)+mpx->b1;
mpx->font_ec[f]=mpx->b2*(int)(256)+mpx->b3;
if ( mpx->font_ec[f]<mpx->font_bc[f] ) mpx->font_bc[f]=mpx->font_ec[f]+1;
-if ( mpx->info_ptr+mpx->font_ec[f]-mpx->font_bc[f]+1>max_widths )
+if ( mpx->info_ptr+(unsigned int)mpx->font_ec[f]-(unsigned int)mpx->font_bc[f]+1>max_widths )
mpx_abort(mpx,"DVItoMP capacity exceeded (width table size=%d)!",max_widths);
@.DVItoMP capacity exceeded...@>
-wp=mpx->info_ptr+mpx->font_ec[f]-mpx->font_bc[f]+1;
+wp=mpx->info_ptr+(unsigned int)mpx->font_ec[f]-(unsigned int)mpx->font_bc[f]+1;
mpx_read_tfm_word(mpx); nw=mpx->b0*256+mpx->b1;
if ( (nw==0)||(nw>256) )
font_abort("Bad TFM file for ",f);
@@ -1270,7 +1287,7 @@ floor(mpx->dvi_scale*mpx->font_scaled_size[cur_font]*char_width(cur_font,p))
if ( mpx->in_width[0]!=0 )
font_abort("Bad TFM file for ",f); /* the first width should be zero */
@.Bad TFM file@>
-mpx->info_base[f]=(int)(mpx->info_ptr-mpx->font_bc[f]);
+mpx->info_base[f]=(int)(mpx->info_ptr-(unsigned int)mpx->font_bc[f]);
if ( wp>0 ) {
for (k=(int)mpx->info_ptr;k<=(int)wp-1;k++) {
mpx->width[k]=mpx->in_width[mpx->width[k]];
@@ -1358,7 +1375,7 @@ if ( c>mpx->font_ec[f] ) mpx->font_ec[f]=c;
char_width(f,c)=w
@ @<Store the character packet in |cmd_buf|@>=
-if ( mpx->n_cmds+p>=virtual_space )
+if ( mpx->n_cmds+(unsigned int)p>=virtual_space )
mpx_abort(mpx,"DVItoMP capacity exceeded (virtual font space=%d)",virtual_space);
@.DVItoMP capacity exceeded...@>
start_cmd(f,c)=(web_integer)mpx->n_cmds;
@@ -2591,8 +2608,9 @@ static void *destroy_avl_entry (void *pa) {
return NULL;
}
static void *copy_avl_entry (const void *pa) { /* never used */
- avl_entry *p, *q;
- p = (avl_entry *) pa;
+ const avl_entry *p;
+ avl_entry *q;
+ p = (const avl_entry *) pa;
q = malloc(sizeof(avl_entry));
if (q!=NULL) {
q->name = strdup(p->name);
@@ -2670,7 +2688,7 @@ static int mpx_get_int_map(MPX mpx, char *s) {
register int i;
if (s == NULL)
goto BAD;
- i = strtol(s, &(mpx->arg_tail), 0);
+ i = (int)strtol(s, &(mpx->arg_tail), 0);
if (s == mpx->arg_tail)
goto BAD;
return i;
@@ -2699,15 +2717,15 @@ static float mpx_get_float(MPX mpx, char *s) {
}
x = 0.0;
while (d = *s - '0', 0 <= d && d <= 9) {
- x = 10.0 * x + d;
+ x = (float)10.0 * x + (float)d;
digits++;
s++;
}
if (*s == '.') {
y = 1.0;
while (d = *++s - '0', 0 <= d && d <= 9) {
- y /= 10.0;
- x += y * d;
+ y /= (float)10.0;
+ x += y * (float)d;
digits++;
}
}
@@ -2772,8 +2790,8 @@ static void mpx_read_fmap(MPX mpx, const char *dbase) {
if (nam==buf)
continue;
tmp = xmalloc(sizeof(avl_entry),1);
- tmp->name = xmalloc (1,(buf-nam)+1);
- strncpy(tmp->name,nam,(buf-nam));
+ tmp->name = xmalloc (1,(size_t)(buf-nam)+1);
+ strncpy(tmp->name,nam,(unsigned int)(buf-nam));
tmp->name[(buf-nam)] = '\0';
tmp->num = (int)mpx->nfonts++;
assert(avl_ins (tmp, mpx->trfonts, avl_false) > 0);
@@ -3075,7 +3093,7 @@ static void mpx_set_num_char(MPX mpx, int f, int c) {
mpx->str_size = mpx->cursize;
}
mpx_print_char(mpx, (unsigned char)c);
- mpx->dmp_str_h2 = hh + char_width(f,c);
+ mpx->dmp_str_h2 = hh + (float)char_width(f,c);
}
@ Output a string.
@@ -3088,10 +3106,10 @@ static void mpx_set_string(MPX mpx, char *cname) {
return;
hh = (float)mpx->h;
mpx_set_num_char(mpx,(int)mpx->curfont, *cname);
- hh += char_width(mpx->curfont,(int)*cname);
+ hh += (float)char_width(mpx->curfont,(int)*cname);
while (*++cname) {
mpx_print_char(mpx,(unsigned char)*cname);
- hh += char_width(mpx->curfont,(int)*cname);
+ hh += (float)char_width(mpx->curfont,(int)*cname);
}
mpx->h = (web_integer)floor(hh+0.5);
mpx_finish_last_char(mpx);
@@ -3151,7 +3169,7 @@ static char *mpx_copy_spec_char(MPX mpx, char *cname) {
if (c == EOF)
mpx_abort(mpx, "vardef in charlib/%s has no arguments", cname);
putc(c, mpx->mpxfile);
- *t++ = c;
+ *t++ = (char)c;
}
putc(c, mpx->mpxfile);
*t++ = '\0';
@@ -3225,7 +3243,7 @@ OUT_LABEL:
fprintf(mpx->mpxfile, "_s(%s(_n%d)", sp->mac,f);
fprintf(mpx->mpxfile, ",%.5f,%.4f,%.4f)",
(mpx->cursize/mpx->font_design_size[f])*1.00375,
- (double)((mpx->h*mpx->unit)/100.0), YCORR-mpx->v*mpx->unit);
+ (double)(((float)mpx->h*mpx->unit)/100.0), YCORR-(float)mpx->v*mpx->unit);
mpx_slant_and_ht(mpx);
fprintf(mpx->mpxfile, ";\n");
}
@@ -3287,13 +3305,13 @@ The tables below give the Bezier control points for MetaPost's cubic
approximation to the first octant of a unit circle.
@c
-static const float xx[] = { 1.0, 1.0, 0.8946431597, 0.7071067812 };
-static const float yy[] = { 0.0, 0.2652164899, 0.5195704026, 0.7071067812 };
+static const float xx[] = { 1.0, 1.0, (float)0.8946431597, (float)0.7071067812 };
+static const float yy[] = { 0.0, (float)0.2652164899, (float)0.5195704026, (float)0.7071067812 };
@ @c
static float mpx_circangle(float t) {
float ti;
- ti = floor(t);
+ ti = (float)floor(t);
t -= ti;
return (float) atan(mpx_b_eval(yy, t) /
mpx_b_eval(xx, t)) + ti * Speed;
@@ -3404,10 +3422,10 @@ static
void mpx_do_arc(MPX mpx, float cx, float cy, float ax, float ay, float bx, float by) {
float t1, t2;
- t1 = mpx_circtime(atan2(ay, ax));
- t2 = mpx_circtime(atan2(by, bx));
+ t1 = mpx_circtime((float)atan2(ay, ax));
+ t2 = mpx_circtime((float)atan2(by, bx));
if (t2 < t1)
- t2 += 8.0;
+ t2 += (float)8.0;
fprintf(mpx->mpxfile, "subpath (%.5f,%.5f) of\n", t1, t2);
fprintf(mpx->mpxfile,
" makepath(pencircle scaled %.3f shifted (%.3f,%.3f));\n",
@@ -3431,7 +3449,7 @@ static void mpx_do_graphic(MPX mpx, char *s) {
if (s[0] == 'F' && s[1] == 'd')
return;
mpx->gx = (float) mpx->h;
- mpx->gy = YCORR / mpx->unit - ((float) mpx->v);
+ mpx->gy = (float)YCORR / mpx->unit - ((float) mpx->v);
if (!mpx->graphics_used)
mpx_prepare_graphics(mpx);
fprintf(mpx->mpxfile, "D(%.4f) ", LWscale * mpx->cursize);
@@ -3522,7 +3540,7 @@ static int mpx_do_x_cmd(MPX mpx, char *s0)
mpx->unit = mpx_get_float(mpx,s);
if (mpx->unit <= 0.0)
mpx_abort(mpx,"Bad resolution: x %s", s0);
- mpx->unit = 72.0 / mpx->unit;
+ mpx->unit = (float)72.0 / mpx->unit;
break;
case 'f':
while (*s != ' ' && *s != '\t')
@@ -3560,11 +3578,11 @@ static int mpx_do_x_cmd(MPX mpx, char *s0)
case 'S':
while (*s != ' ' && *s != '\t')
s++;
- mpx->Xslant = mpx_get_float(mpx,s) * (PI / 180.0);
- x = cos(mpx->Xslant);
+ mpx->Xslant = mpx_get_float(mpx,s) * ((float)PI / (float)180.0);
+ x = (float)cos(mpx->Xslant);
if (-1e-4 < x && x < 1e-4)
mpx_abort(mpx,"Excessive slant");
- mpx->Xslant = sin(mpx->Xslant) / x;
+ mpx->Xslant = (float)sin(mpx->Xslant) / x;
break;
default:
/* do nothing */ ;
@@ -3916,7 +3934,8 @@ First, here is a helper for messaging.
@c
static char *mpx_print_command (MPX mpx, int cmdlength, char **cmdline) {
char *s, *t;
- int i,l;
+ int i;
+ size_t l;
(void)mpx;
l = 0;
for (i = 0; i < cmdlength ; i++) {
diff --git a/Build/source/texk/web2c/mplibdir/psout.w b/Build/source/texk/web2c/mplibdir/psout.w
index e044974935a..10a6ac48584 100644
--- a/Build/source/texk/web2c/mplibdir/psout.w
+++ b/Build/source/texk/web2c/mplibdir/psout.w
@@ -1,4 +1,4 @@
-% $Id: psout.w 1098 2009-06-25 08:23:21Z taco $
+% $Id: psout.w 1219 2010-04-01 09:05:51Z taco $
%
% Copyright 2008-2009 Taco Hoekwater.
%
@@ -111,12 +111,12 @@ static int mp_strcasecmp (const char *s1, const char *s2) {
ss1 = mp_strdup(s1);
c = ss1;
while (*c != '\0') {
- *c = mp_tolower(*c); c++;
+ *c = (char)mp_tolower(*c); c++;
}
ss2 = mp_strdup(s2);
c = ss2;
while (*c != '\0') {
- *c = mp_tolower(*c); c++;
+ *c = (char)mp_tolower(*c); c++;
}
r = strcmp(ss1,ss2);
free (ss1); free(ss2);
@@ -156,7 +156,7 @@ mp->ps->ps_offset = 0;
@d wps(A) (mp->write_ascii_file)(mp,mp->output_file,(A))
@d wps_chr(A) do {
char ss[2];
- ss[0]=(A); ss[1]=0;
+ ss[0]=(char)(A); ss[1]=0;
(mp->write_ascii_file)(mp,mp->output_file,(char *)ss);
} while (0)
@d wps_cr (mp->write_ascii_file)(mp,mp->output_file,"\n")
@@ -320,7 +320,7 @@ First, here are a few helpers for parsing files
c = 10;
if (c != ' ' || (p > buf && p[-1] != 32)) {
check_buf(p - buf + 1, (buf_size));
- *p++ = c;
+ *p++ = (char)c;
}
} while (0)
@@ -429,8 +429,8 @@ static void mp_load_enc (MP mp, char *enc_name,
mp_error(mp);
}
while (*(r-1)==' ') r--; /* strip trailing spaces from encoding name */
- myname = mp_xmalloc(mp,r-mp->ps->enc_line,1);
- memcpy(myname,mp->ps->enc_line+1,(r-mp->ps->enc_line)-1);
+ myname = mp_xmalloc(mp,(size_t)(r-mp->ps->enc_line),1);
+ memcpy(myname,(mp->ps->enc_line+1),(size_t)((r-mp->ps->enc_line)-1));
*(myname+(r-mp->ps->enc_line-1))=0;
*enc_encname = myname;
while (*r!='[') r++;
@@ -552,27 +552,41 @@ static void *destroy_enc_entry (void *pa) {
mp_xfree (p);
return NULL;
}
+
+@ Not having an |mp| instance here means that lots of |malloc| and
+|strdup| checks are needed. Spotted by Peter Breitenlohner.
+
+@c
static void *copy_enc_entry (const void *pa) {
- enc_entry *p, *q;
+ const enc_entry *p;
+ enc_entry *q;
int i;
- p = (enc_entry *) pa;
+ p = (const enc_entry *) pa;
q = malloc (sizeof (enc_entry));
- memset(q,0,sizeof(enc_entry));
if (q!=NULL) {
- if (p->enc_name!=NULL)
- q->enc_name = strdup (p->enc_name);
+ memset(q,0,sizeof(enc_entry));
+ if (p->enc_name!=NULL) {
+ q->enc_name = strdup (p->enc_name);
+ if (q->enc_name == NULL)
+ return NULL;
+ }
q->loaded = p->loaded;
- q->file_name = strdup (p->file_name);
+ if (p->file_name != NULL) {
+ q->file_name = strdup (p->file_name);
+ if (q->file_name == NULL)
+ return NULL;
+ }
q->objnum = p->objnum;
q->tounicode = p->tounicode;
q->glyph_names = malloc (256 * sizeof (char *));
if (p->glyph_names == NULL)
return NULL;
for (i = 0; i < 256; i++) {
- if (p->glyph_names[i]!=notdef)
- q->glyph_names[i] = strdup(p->glyph_names[i]);
- else
- q->glyph_names[i] = (char *)notdef;
+ if (p->glyph_names[i] != NULL) {
+ q->glyph_names[i] = strdup(p->glyph_names[i]);
+ if (q->glyph_names[i] == NULL)
+ return NULL;
+ }
}
}
return (void *)q;
@@ -599,8 +613,9 @@ static enc_entry * mp_add_enc (MP mp, char *s) {
p->objnum = 0;
p->tounicode = 0;
p->glyph_names = mp_xmalloc (mp,256,sizeof (char *));
- for (i = 0; i < 256; i++)
- p->glyph_names[i] = (char *) notdef;
+ for (i = 0; i < 256; i++) {
+ p->glyph_names[i] = mp_xstrdup(mp, notdef);
+ }
assert (avl_ins (p, mp->ps->enc_tree, avl_false)>0);
destroy_enc_entry(p);
return avl_find (&tmp, mp->ps->enc_tree);
@@ -758,8 +773,9 @@ static fm_entry *new_fm_entry (MP mp) {
}
static void *copy_fm_entry (const void *p) {
- fm_entry *fm, *fp;
- fp = (fm_entry *)p;
+ fm_entry *fm;
+ const fm_entry *fp;
+ fp = (const fm_entry *)p;
fm = malloc (sizeof(fm_entry));
if (fm==NULL)
return NULL;
@@ -793,8 +809,9 @@ static ff_entry *new_ff_entry (MP mp) {
}
static void *copy_ff_entry (const void *p) {
- ff_entry *ff, *fp;
- fp = (ff_entry *)p;
+ ff_entry *ff;
+ const ff_entry *fp;
+ fp = (const ff_entry *)p;
ff = (ff_entry *)malloc (sizeof(ff_entry));
if (ff == NULL)
return NULL;
@@ -1182,11 +1199,11 @@ static int check_fm_entry (MP mp, fm_entry * fm, boolean warn) {
if (*(s - 1) == 'E' || *(s - 1) == 'e')
s--; /* e. g. 0.5ExtendFont: \%f = 0.5E */
if (str_prefix (s, "SlantFont")) {
- d *= 1000.0; /* correct rounding also for neg. numbers */
+ d *= (float)1000.0; /* correct rounding also for neg. numbers */
fm->slant = (short int) (d > 0 ? d + 0.5 : d - 0.5);
r = s + strlen ("SlantFont");
} else if (str_prefix (s, "ExtendFont")) {
- d *= 1000.0;
+ d *= (float)1000.0;
fm->extend = (short int) (d > 0 ? d + 0.5 : d - 0.5);
if (fm->extend == 1000)
fm->extend = 0;
@@ -1201,7 +1218,7 @@ static int check_fm_entry (MP mp, fm_entry * fm, boolean warn) {
"invalid entry for `%s': unknown name `%s' ignored",
fm->tfm_name, s);
mp_warn(mp,warn_s);
- *r = c;
+ *r = (char)c;
}
} else
for (; *r != ' ' && *r != '"' && *r != '\0'; r++);
@@ -1585,10 +1602,10 @@ void mp_set_job_id (MP mp) {
mp_xfree (name_string);
mp_xfree (format_string);
}
-static void fnstr_append (MP mp, const char *s) {
- size_t l = strlen (s) + 1;
- alloc_array (char, l, SMALL_ARRAY_SIZE);
- strcat (mp->ps->char_ptr, s);
+static void fnstr_append (MP mp, const char *ss) {
+ size_t n = strlen (ss) + 1;
+ alloc_array (char, n, SMALL_ARRAY_SIZE);
+ strcat (mp->ps->char_ptr, ss);
mp->ps->char_ptr = strend (mp->ps->char_ptr);
}
@@ -1648,11 +1665,13 @@ static void make_subset_tag (MP mp, fm_entry * fm_cur, char **glyph_names, font_
fnstr_append (mp,"built-in");
fnstr_append (mp," CharSet: ");
for (i = 0; i < 256; i++)
- if (mp_char_marked (mp,tex_font, (eight_bits)i) && glyph_names[i] != notdef) {
- if (glyph_names[i]!=NULL) {
- fnstr_append (mp,"/");
- fnstr_append (mp,glyph_names[i]);
- }
+ if (mp_char_marked (mp,tex_font, (eight_bits)i) &&
+ glyph_names[i] != notdef &&
+ strcmp(glyph_names[i],notdef) != 0) {
+ if (glyph_names[i]!=NULL) {
+ fnstr_append (mp,"/");
+ fnstr_append (mp,glyph_names[i]);
+ }
}
if (fm_cur->charset != NULL) {
fnstr_append (mp," Extra CharSet: ");
@@ -1667,7 +1686,7 @@ static void make_subset_tag (MP mp, fm_entry * fm_cur, char **glyph_names, font_
* of the CRC must be dropped out.
*/
for (i = 0; i < 6; i++) {
- tag[i] = 'A' + crc % 26;
+ tag[i] = (char)('A' + crc % 26);
crc /= 26;
}
tag[6] = 0;
@@ -1684,7 +1703,7 @@ static void make_subset_tag (MP mp, fm_entry * fm_cur, char **glyph_names, font_
mp->ps->hexline_length = HEXLINE_WIDTH;
end_hexline(mp);
mp->ps->t1_eexec_encrypt = false
-@d t1_log(s) mp_print(mp,(char *)s)
+@d t1_log(s) mp_print(mp,(const char *)s)
@d t1_putchar(c) wps_chr(c)
@d embed_all_glyphs(tex_font) false
@d t1_char(c) c
@@ -1717,7 +1736,7 @@ static int t1_getchar (MP mp) {
unsigned char abyte=0;
void *byte_ptr = &abyte;
if (mp->ps->t1_byte_waiting) {
- abyte = mp->ps->t1_byte_waiting;
+ abyte = (unsigned char)mp->ps->t1_byte_waiting;
mp->ps->t1_byte_waiting = 0;
} else {
(mp->read_binary_file)(mp,mp->ps->t1_file,&byte_ptr,&len);
@@ -1918,9 +1937,9 @@ static int t1_getbyte (MP mp)
return EOF;
}
mp->ps->t1_block_length = t1_getchar (mp) & 0xff;
- mp->ps->t1_block_length |= (unsigned)(t1_getchar (mp) & 0xff) << 8;
- mp->ps->t1_block_length |= (unsigned)(t1_getchar (mp) & 0xff) << 16;
- mp->ps->t1_block_length |= (unsigned)(t1_getchar (mp) & 0xff) << 24;
+ mp->ps->t1_block_length |= (int)(((unsigned)t1_getchar (mp) & 0xff) << 8);
+ mp->ps->t1_block_length |= (int)(((unsigned)t1_getchar (mp) & 0xff) << 16);
+ mp->ps->t1_block_length |= (int)(((unsigned)t1_getchar (mp) & 0xff) << 24);
c = t1_getchar (mp);
}
mp->ps->t1_block_length--;
@@ -1944,27 +1963,27 @@ static byte edecrypt (MP mp, byte cipher) {
mp->ps->last_hexbyte = cipher = (byte)(((byte)hexval (cipher) << 4) +
hexval (t1_getbyte (mp)));
}
- plain = (cipher ^ (mp->ps->t1_dr >> 8));
- mp->ps->t1_dr = (cipher + mp->ps->t1_dr) * t1_c1 + t1_c2;
+ plain = (byte)(cipher ^ (mp->ps->t1_dr >> 8));
+ mp->ps->t1_dr = (unsigned short)((cipher + mp->ps->t1_dr) * t1_c1 + t1_c2);
return plain;
}
static byte cdecrypt (byte cipher, unsigned short *cr)
{
- const byte plain = (cipher ^ (*cr >> 8));
- *cr = (cipher + *cr) * t1_c1 + t1_c2;
+ const byte plain = (byte)(cipher ^ (*cr >> 8));
+ *cr = (unsigned short)((cipher + *cr) * t1_c1 + t1_c2);
return plain;
}
static byte eencrypt (MP mp, byte plain)
{
- const byte cipher = (plain ^ (mp->ps->t1_er >> 8));
- mp->ps->t1_er = (cipher + mp->ps->t1_er) * t1_c1 + t1_c2;
+ const byte cipher = (byte)(plain ^ (mp->ps->t1_er >> 8));
+ mp->ps->t1_er = (unsigned short)((cipher + mp->ps->t1_er) * t1_c1 + t1_c2);
return cipher;
}
static byte cencrypt (byte plain, unsigned short *cr)
{
- const byte cipher = (plain ^ (*cr >> 8));
- *cr = (cipher + *cr) * t1_c1 + t1_c2;
+ const byte cipher = (byte)(plain ^ (*cr >> 8));
+ *cr = (unsigned short)((cipher + *cr) * t1_c1 + t1_c2);
return cipher;
}
@@ -2010,20 +2029,21 @@ static boolean str_suffix (const char *begin_buf, const char *end_buf,
@
@d alloc_array(T, n, s) do {
+ size_t nn = (size_t)n;
if (mp->ps->T##_array == NULL) {
- mp->ps->T##_limit = (s);
- if ((size_t)(n) > mp->ps->T##_limit)
- mp->ps->T##_limit = (size_t)(n);
+ mp->ps->T##_limit = s;
+ if (nn > mp->ps->T##_limit)
+ mp->ps->T##_limit = nn;
mp->ps->T##_array = mp_xmalloc (mp,mp->ps->T##_limit,sizeof(T##_entry));
mp->ps->T##_ptr = mp->ps->T##_array;
}
- else if ((size_t)(mp->ps->T##_ptr - mp->ps->T##_array + (n)) > mp->ps->T##_limit) {
+ else if ((size_t)(mp->ps->T##_ptr - mp->ps->T##_array) + nn > mp->ps->T##_limit) {
size_t last_ptr_index;
last_ptr_index = (size_t)(mp->ps->T##_ptr - mp->ps->T##_array);
mp->ps->T##_limit *= 2;
mp->ps->T##_limit += s;
- if ((size_t)(mp->ps->T##_ptr - mp->ps->T##_array + (n)) > mp->ps->T##_limit)
- mp->ps->T##_limit = (size_t)(mp->ps->T##_ptr - mp->ps->T##_array + (n));
+ if ((size_t)(mp->ps->T##_ptr - mp->ps->T##_array) + nn > mp->ps->T##_limit)
+ mp->ps->T##_limit = (size_t)(mp->ps->T##_ptr - mp->ps->T##_array) + nn;
mp->ps->T##_array = mp_xrealloc(mp,mp->ps->T##_array,mp->ps->T##_limit, sizeof(T##_entry));
mp->ps->T##_ptr = mp->ps->T##_array + last_ptr_index;
}
@@ -2076,7 +2096,7 @@ static void t1_getline (MP mp) {
p--;
l = (int)t1_scan_num (mp, p + 1, 0);
mp->ps->t1_cslen = (unsigned short)l;
- mp->ps->cs_start = mp->ps->t1_line_ptr - mp->ps->t1_line_array;
+ mp->ps->cs_start = (int)(mp->ps->t1_line_ptr - mp->ps->t1_line_array);
/* |mp->ps->cs_start| is an index now */
alloc_array (t1_line, l, T1_BUF_SIZE);
while (l-- > 0) {
@@ -2271,7 +2291,7 @@ static void t1_scan_keys (MP mp, font_number tex_font,fm_entry *fm_cur) {
key->valid = true;
p = mp->ps->t1_line_array + strlen (key->t1name) + 1;
skip (p, ' ');
- if ((k = key - font_keys) == FONTNAME_CODE) {
+ if ((k = (int)(key - font_keys)) == FONTNAME_CODE) {
if (*p != '/') {
char s[128];
remove_eol (p, mp->ps->t1_line_array);
@@ -2291,7 +2311,7 @@ static void t1_scan_keys (MP mp, font_number tex_font,fm_entry *fm_cur) {
else
make_subset_tag (mp,fm_cur, mp->ps->t1_builtin_glyph_names, tex_font);
- alloc_array (t1_line, (r-mp->ps->t1_line_array+6+1+strlen(mp->ps->fontname_buf)+1),
+ alloc_array (t1_line, (size_t)(r-mp->ps->t1_line_array)+6+1+strlen(mp->ps->fontname_buf)+1,
T1_BUF_SIZE);
strncpy (r, fm_cur->subset_tag , 6);
*(r+6) = '-';
@@ -2329,13 +2349,9 @@ static void t1_scan_param (MP mp, font_number tex_font,fm_entry *fm_cur)
t1_scan_keys (mp, tex_font,fm_cur);
}
static void copy_glyph_names (MP mp, char **glyph_names, int a, int b) {
- if (glyph_names[b] != notdef) {
+ if (glyph_names[b] != notdef)
mp_xfree (glyph_names[b]);
- glyph_names[b] = (char *) notdef;
- }
- if (glyph_names[a] != notdef) {
- glyph_names[b] = mp_xstrdup (mp,glyph_names[a]);
- }
+ glyph_names[b] = mp_xstrdup (mp,glyph_names[a]);
}
static void t1_builtin_enc (MP mp) {
int i, a, b, c, counter = 0;
@@ -2349,11 +2365,8 @@ static void t1_builtin_enc (MP mp) {
for (i = 0; i < 256; i++) {
if (mp->ps->t1_builtin_glyph_names[i] != notdef)
mp_xfree(mp->ps->t1_builtin_glyph_names[i]);
- if (standard_glyph_names[i] == notdef)
- mp->ps->t1_builtin_glyph_names[i] = (char *) notdef;
- else
- mp->ps->t1_builtin_glyph_names[i] =
- mp_xstrdup (mp,standard_glyph_names[i]);
+ mp->ps->t1_builtin_glyph_names[i] =
+ mp_xstrdup (mp,standard_glyph_names[i]);
}
mp->ps->t1_encoding = ENC_STANDARD;
} else {
@@ -2384,7 +2397,7 @@ static void t1_builtin_enc (MP mp) {
for (i = 0; i < 256; i++) {
if (mp->ps->t1_builtin_glyph_names[i] != notdef) {
mp_xfree(mp->ps->t1_builtin_glyph_names[i]);
- mp->ps->t1_builtin_glyph_names[i] = (char *) notdef;
+ mp->ps->t1_builtin_glyph_names[i] = mp_xstrdup(mp, notdef);
}
}
if (t1_prefix ("/Encoding [") || t1_prefix ("/Encoding[")) { /* the first case */
@@ -2494,8 +2507,10 @@ static void t1_check_end (MP mp) {
@ @<Set initial values...@>=
{
int i;
- for (i = 0; i < 256; i++)
- mp->ps->t1_builtin_glyph_names[i] = (char *) notdef;
+ for (i = 0; i < 256; i++) {
+ mp->ps->t1_builtin_glyph_names[i] = strdup(notdef);
+ assert(mp->ps->t1_builtin_glyph_names[i]);
+ }
}
@ @<Types...@>=
@@ -2602,10 +2617,7 @@ static void cs_store (MP mp, boolean is_subr) {
mp_snprintf(s,128,"CharStrings dict: more entries than dict size (%i)",mp->ps->cs_size);
mp_fatal_error(mp,s);
}
- if (strcmp (mp->ps->t1_buf_array + 1, notdef) == 0) /* skip the slash */
- ptr->glyph_name = (char *) notdef;
- else
- ptr->glyph_name = mp_xstrdup (mp,mp->ps->t1_buf_array + 1);
+ ptr->glyph_name = mp_xstrdup (mp,mp->ps->t1_buf_array + 1);
}
/* copy " RD " + cs data to |mp->ps->t1_buf_array| */
memcpy (mp->ps->t1_buf_array, mp->ps->t1_line_array + mp->ps->cs_start - 4,
@@ -2885,9 +2897,10 @@ static void t1_subset_ascii_part (MP mp, font_number tex_font, fm_entry *fm_cur)
t1_puts
(mp,"/Encoding 256 array\n0 1 255 {1 index exch /.notdef put} for\n");
for (i = 0, j = 0; i < 256; i++) {
- if (is_used_char (i) && mp->ps->t1_glyph_names[i] != notdef) {
+ if (is_used_char (i) && mp->ps->t1_glyph_names[i] != notdef &&
+ strcmp(mp->ps->t1_glyph_names[i],notdef) != 0) {
j++;
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit,
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit,
"dup %i /%s put\n", (int) t1_char (i),
mp->ps->t1_glyph_names[i]);
t1_puts(mp,mp->ps->t1_line_array);
@@ -2983,7 +2996,7 @@ static void t1_read_subrs (MP mp, font_number tex_font, fm_entry *fm_cur, int re
for (i = 0; i < POST_SUBRS_SCAN; i++) {
if (t1_charstrings ())
break;
- s += mp->ps->t1_line_ptr - mp->ps->t1_line_array;
+ s += (int)(mp->ps->t1_line_ptr - mp->ps->t1_line_array);
alloc_array (t1_buf, s, T1_BUF_SIZE);
strcat (mp->ps->t1_buf_array, mp->ps->t1_line_array);
t1_getline (mp);
@@ -3035,7 +3048,7 @@ static void t1_flush_cs (MP mp, boolean is_subr)
*mp->ps->t1_line_ptr++ = *p++;
while (mp_isdigit (*p))
p++;
- mp_snprintf (mp->ps->t1_line_ptr, (int)mp->ps->t1_line_limit, "%u", (unsigned)count);
+ mp_snprintf (mp->ps->t1_line_ptr, mp->ps->t1_line_limit, "%u", (unsigned)count);
strcat (mp->ps->t1_line_ptr, p);
mp->ps->t1_line_ptr = eol (mp->ps->t1_line_array);
t1_putline (mp);
@@ -3059,10 +3072,10 @@ static void t1_flush_cs (MP mp, boolean is_subr)
for (ptr = tab; ptr < end_tab; ptr++) {
if (ptr->is_used) {
if (is_subr)
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit,
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit,
"dup %i %u", (int) (ptr - tab), ptr->cslen);
else
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit,
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit,
"/%s %u", ptr->glyph_name, ptr->cslen);
p = strend (mp->ps->t1_line_array);
memcpy (p, ptr->data, (size_t)ptr->len);
@@ -3071,14 +3084,14 @@ static void t1_flush_cs (MP mp, boolean is_subr)
} else {
/* replace unsused subr's by |return_cs| */
if (is_subr) {
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit,
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit,
"dup %i %u%s ", (int) (ptr - tab),
cs_len, mp->ps->cs_token_pair[0]);
p = strend (mp->ps->t1_line_array);
memcpy (p, return_cs, (size_t)cs_len);
mp->ps->t1_line_ptr = p + cs_len;
t1_putline (mp);
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit,
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit,
" %s", mp->ps->cs_token_pair[1]);
mp->ps->t1_line_ptr = eol (mp->ps->t1_line_array);
t1_putline (mp);
@@ -3088,7 +3101,7 @@ static void t1_flush_cs (MP mp, boolean is_subr)
if (ptr->glyph_name != notdef)
mp_xfree (ptr->glyph_name);
}
- mp_snprintf (mp->ps->t1_line_array, (int)mp->ps->t1_line_limit, "%s", line_end);
+ mp_snprintf (mp->ps->t1_line_array, mp->ps->t1_line_limit, "%s", line_end);
mp->ps->t1_line_ptr = eol (mp->ps->t1_line_array);
t1_putline (mp);
if (is_subr)
@@ -3129,7 +3142,8 @@ static void t1_mark_glyphs (MP mp, font_number tex_font)
mark_cs (mp,notdef);
for (i = 0; i < 256; i++)
if (is_used_char (i)) {
- if (mp->ps->t1_glyph_names[i] == notdef) {
+ if (mp->ps->t1_glyph_names[i] == notdef ||
+ strcmp(mp->ps->t1_glyph_names[i],notdef)==0) {
char S[128];
mp_snprintf(S,128, "character %i is mapped to %s", i, notdef);
mp_warn(mp,S);
@@ -3153,15 +3167,15 @@ static void t1_mark_glyphs (MP mp, font_number tex_font)
ptr - mp->ps->subr_tab < mp->ps->subr_size;
ptr++)
if (ptr->is_used && ptr - mp->ps->subr_tab > mp->ps->subr_max)
- mp->ps->subr_max = ptr - mp->ps->subr_tab;
+ mp->ps->subr_max = (int)(ptr - mp->ps->subr_tab);
}
static void t1_do_subset_charstrings (MP mp, font_number tex_font)
{
cs_entry *ptr;
- mp->ps->cs_size_pos =
+ mp->ps->cs_size_pos = (int)(
strstr (mp->ps->t1_line_array, charstringname) + strlen (charstringname)
- - mp->ps->t1_line_array + 1;
+ - mp->ps->t1_line_array + 1);
/* |cs_size_pos| points to the number indicating
dict size after "/CharStrings" */
mp->ps->cs_size = (int)t1_scan_num (mp,mp->ps->t1_line_array + mp->ps->cs_size_pos, 0);
@@ -3297,10 +3311,9 @@ static void t1_free (MP mp) {
mp->ps->t1_buf_limit = 0;
for (k=0;k<=255;k++) {
- if (mp->ps->t1_builtin_glyph_names[k] != notdef) {
+ if (mp->ps->t1_builtin_glyph_names[k] != notdef)
mp_xfree(mp->ps->t1_builtin_glyph_names[k]);
- mp->ps->t1_builtin_glyph_names[k] = (char *)notdef;
- }
+ mp->ps->t1_builtin_glyph_names[k] = mp_xstrdup(mp, notdef);
}
}
@@ -3331,7 +3344,7 @@ mp_ps_font *mp_ps_font_parse (MP mp, int tex_font) {
mp_ps_font *f;
fm_entry *fm_cur;
char msg[128];
- (void)mp_has_fm_entry (mp, tex_font, &fm_cur);
+ (void)mp_has_fm_entry (mp, (font_number)tex_font, &fm_cur);
if (fm_cur == NULL) {
mp_snprintf(msg,128,"fontmap entry for `%s' not found", mp->font_name[tex_font]);
mp_warn(mp,msg);
@@ -3358,7 +3371,7 @@ mp_ps_font *mp_ps_font_parse (MP mp, int tex_font) {
f->extend = (int)fm_cur->extend;
t1_getline (mp);
while (!t1_prefix ("/Encoding")) {
- t1_scan_param (mp,tex_font, fm_cur);
+ t1_scan_param (mp, (font_number)tex_font, fm_cur);
t1_getline (mp);
}
t1_builtin_enc (mp);
@@ -3370,7 +3383,7 @@ mp_ps_font *mp_ps_font_parse (MP mp, int tex_font) {
}
do {
t1_getline (mp);
- t1_scan_param (mp,tex_font, fm_cur);
+ t1_scan_param (mp, (font_number)tex_font, fm_cur);
} while (mp->ps->t1_in_eexec == 0);
/* t1_start_eexec (mp,fm_cur); */
@@ -3378,9 +3391,9 @@ mp_ps_font *mp_ps_font_parse (MP mp, int tex_font) {
cs_init (mp);
/* the boolean is needed to make sure that |t1_read_subrs|
doesn't output stuff */
- t1_read_subrs (mp,tex_font, fm_cur, true);
+ t1_read_subrs (mp, (font_number)tex_font, fm_cur, true);
mp->ps->t1_synthetic = true ;
- t1_do_subset_charstrings (mp, tex_font);
+ t1_do_subset_charstrings (mp, (font_number)tex_font);
f->cs_tab = mp->ps->cs_tab;
mp->ps->cs_tab = NULL;
f->cs_ptr = mp->ps->cs_ptr;
@@ -3567,8 +3580,7 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr);
@d cs_debug(A)
@c
-
-#if 0 /* unused */
+#if 0
void cs_do_debug (MP mp, mp_ps_font *f, int i, char *s) {
int n = cc_tab[i].nargs;
(void)mp; /* for -Wall */
@@ -3696,20 +3708,31 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr)
break;
case CS_HMOVETO: /* |- dx HMOVETO |- */
cs_debug(CS_HMOVETO);
- finish_subpath();
- start_subpath(f,cc_get(-1),0);
+ /* treating in-line moves as 'line segments' work better than attempting
+ to split the path up in two separate sections, at least for now. */
+ if (f->pp == NULL) { /* this is the first */
+ start_subpath(f,cc_get(-1),0);
+ } else {
+ add_line_segment(f,cc_get(-1),0);
+ }
cc_clear ();
break;
case CS_RMOVETO: /* |- dx dy RMOVETO |- */
cs_debug(CS_RMOVETO);
- finish_subpath();
- start_subpath(f,cc_get(-2),cc_get(-1));
+ if (f->pp == NULL) { /* this is the first */
+ start_subpath(f,cc_get(-2),cc_get(-1));
+ } else {
+ add_line_segment(f,cc_get(-2),cc_get(-1));
+ }
cc_clear ();
break;
case CS_VMOVETO: /* |- dy VMOVETO |- */
cs_debug(CS_VMOVETO);
- finish_subpath();
- start_subpath(f,0,cc_get(-1));
+ if (f->pp == NULL) { /* this is the first */
+ start_subpath(f,0,cc_get(-1));
+ } else {
+ add_line_segment(f,0,cc_get(-1));
+ }
cc_clear ();
break;
/* hinting commands */
@@ -3736,14 +3759,15 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr)
/* start and close commands */
case CS_SEAC: /* |- asb adx ady bchar achar SEAC |- */
cs_debug(CS_SEAC);
- { double adx, ady;
+ { double adx, ady, asb;
+ asb = cc_get (0);
adx = cc_get (1);
ady = cc_get (2);
a1 = (integer)cc_get (3);
a2 = (integer)cc_get (4);
cc_clear ();
(void)cs_parse(mp,f,standard_glyph_names[a1],0); /* base */
- f->orig_x += adx;
+ f->orig_x += (adx - asb);
f->orig_y += ady;
(void)cs_parse(mp,f,standard_glyph_names[a2],0);
}
@@ -3755,11 +3779,13 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr)
break;
case CS_HSBW: /* |- sbx wx HSBW |- */
cs_debug(CS_HSBW);
- f->h = mp_xmalloc(mp, 1,sizeof(mp_edge_object));
- f->h->body = NULL; f->h->next = NULL;
- f->h->parent = mp;
- f->h->filename = NULL;
- f->h->minx = f->h->miny = f->h->maxx = f->h->maxy = 0;
+ if (!f->h) {
+ f->h = mp_xmalloc(mp, 1,sizeof(mp_edge_object));
+ f->h->body = NULL; f->h->next = NULL;
+ f->h->parent = mp;
+ f->h->filename = NULL;
+ f->h->minx = f->h->miny = f->h->maxx = f->h->maxy = 0;
+ }
f->cur_x = cc_get(-2) + f->orig_x;
f->cur_y = 0.0 + f->orig_y;
f->orig_x = f->cur_x;
@@ -3768,11 +3794,13 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr)
break;
case CS_SBW: /* |- sbx sby wx wy SBW |- */
cs_debug(CS_SBW);
- f->h = mp_xmalloc(mp, 1,sizeof(mp_edge_object));
- f->h->body = NULL; f->h->next = NULL;
- f->h->parent = mp;
- f->h->filename = NULL;
- f->h->minx = f->h->miny = f->h->maxx = f->h->maxy = 0;
+ if (!f->h) {
+ f->h = mp_xmalloc(mp, 1,sizeof(mp_edge_object));
+ f->h->body = NULL; f->h->next = NULL;
+ f->h->parent = mp;
+ f->h->filename = NULL;
+ f->h->minx = f->h->miny = f->h->maxx = f->h->maxy = 0;
+ }
f->cur_x = cc_get(-4) + f->orig_x;
f->cur_y = cc_get(-3) + f->orig_y;
f->orig_x = f->cur_x;
@@ -3813,9 +3841,7 @@ boolean cs_parse (MP mp, mp_ps_font *f, const char *cs_name, int subr)
break;
case CS_SETCURRENTPOINT: /* |- x y SETCURRENTPOINT |- */
cs_debug(CS_SETCURRENTPOINT);
- f->cur_x = cc_get(-2);
- f->cur_y = cc_get(-1);
- f->pp = NULL;
+ /* totally ignoring setcurrentpoint actually works better for most fonts ? */
cc_clear ();
break;
default:
@@ -3982,7 +4008,7 @@ static char * mp_fm_font_subset_name (MP mp, font_number f) {
if (fm != NULL && (fm->ps_name != NULL)) {
if (is_subsetted(fm)) {
char *s = mp_xmalloc(mp,strlen(fm->ps_name)+8,1);
- mp_snprintf(s,(int)strlen(fm->ps_name)+8,"%s-%s",fm->subset_tag,fm->ps_name);
+ mp_snprintf(s, strlen(fm->ps_name)+8,"%s-%s",fm->subset_tag,fm->ps_name);
return s;
} else {
return mp_xstrdup(mp,fm->ps_name);
@@ -4072,7 +4098,7 @@ static void mp_list_used_resources (MP mp, int prologues, int procset);
}
if ( mp_font_is_subsetted(mp,f) )
goto FOUND;
- if ( mp->ps->ps_offset+1+strlen(mp->font_enc_name[f])>
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_enc_name[f])>
(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+ encoding");
if ( firstitem ) {
@@ -4095,7 +4121,7 @@ static void mp_list_used_resources (MP mp, int prologues, int procset);
if ( mp_xstrcmp(mp->font_name[f],mp->font_name[ff])==0 )
goto FOUND2;
}
- if ( mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>
(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+ font");
if ( firstitem ) {
@@ -4141,7 +4167,7 @@ static void mp_list_supplied_resources (MP mp, int prologues, int procset);
}
if ( (prologues==3)&&(mp_font_is_subsetted(mp,f)))
goto FOUND;
- if ( mp->ps->ps_offset+1+strlen(mp->font_enc_name[f])>(size_t)mp->max_print_line )
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_enc_name[f])>(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+ encoding");
if ( firstitem ) {
firstitem=false;
@@ -4166,7 +4192,7 @@ static void mp_list_supplied_resources (MP mp, int prologues, int procset);
}
if ( ! mp_font_is_included(mp,f) )
goto FOUND2;
- if ( mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+ font");
if ( firstitem ) {
firstitem=false;
@@ -4208,7 +4234,7 @@ static void mp_list_needed_resources (MP mp, int prologues);
};
if ((prologues==3)&&(mp_font_is_included(mp,f)) )
goto FOUND;
- if ( mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+ font");
if ( firstitem ) {
firstitem=false;
@@ -4526,7 +4552,7 @@ search.
if ( mp_xstrcmp(mp->font_ps_name[f],mp->font_ps_name[ff])==0 )
goto FOUND;
}
- if ( mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
+ if ( (size_t)mp->ps->ps_offset+1+strlen(mp->font_ps_name[f])>(size_t)mp->max_print_line )
mp_ps_print_nl(mp, "%%+");
mp_ps_print_char(mp, ' ');
mp_ps_print(mp, mp->font_ps_name[f]);
@@ -4584,8 +4610,8 @@ while ( (mp->font_info[p].qqqq.b3==mp_unused)&&(bc<ec) ) {
@ @<Print the initial label indicating that the bitmap starts at |bc|@>=
mp_ps_print_char(mp, ' ');
-mp_hex_digit_out(mp, (quarterword)bc / 16);
-mp_hex_digit_out(mp, (quarterword)bc % 16);
+mp_hex_digit_out(mp, (quarterword)(bc / 16));
+mp_hex_digit_out(mp, (quarterword)(bc % 16));
mp_ps_print_char(mp, ':')
@
@@ -4597,7 +4623,8 @@ for (p=mp->char_base[f]+bc;p<=mp->char_base[f]+ec;p++) {
mp_hex_digit_out(mp, (quarterword)d);
d=0; b=8;
}
- if ( mp->font_info[p].qqqq.b3!=mp_unused ) d=d+b;
+ if ( mp->font_info[p].qqqq.b3!=mp_unused )
+ d+=(int)b;
b=b>>1;
}
mp_hex_digit_out(mp, (quarterword)d)
@@ -4672,7 +4699,7 @@ void mp_print_prologue (MP mp, mp_edge_object *h, int prologues, int procset) {
font_number ldf ;
ldf = mp_print_font_comments (mp, h, prologues);
mp_ps_print_ln(mp);
- if ( (prologues==1) && (mp->last_ps_fnum<mp->last_fnum) )
+ if ( (prologues==1) && mp->ps->tfm_tree == NULL && (mp->last_ps_fnum<mp->last_fnum) )
mp_read_psname_table(mp);
mp_ps_print(mp, "%%BeginProlog"); mp_ps_print_ln(mp);
if ( (prologues>0)||(procset>0) ) {
@@ -4927,7 +4954,7 @@ All node types are assumed to be |endpoint| or |explicit| only.
This function is currenly unused.
@c
-#if 0 /* unused */
+#if 0
mp_knot * mp_gr_htap_ypoc (MP mp, mp_knot *p) {
mp_knot *q, *pp, *qq, *rr; /* for list manipulation */
q=mp_xmalloc(mp, 1, sizeof (mp_knot)); /* this will correspond to |p| */
@@ -5725,6 +5752,7 @@ static void mp_gr_stroke_ellipse (MP mp, mp_graphic_object *h, boolean fill_als
mp_ps_pair_out(mp, txy,tyy);
mp_ps_print(mp, "0 0] t");
} else if ((txx!=unity)||(tyy!=unity) ) {
+ mp_ps_print(mp, " ");
mp_ps_pair_out(mp,txx,tyy);
mp_ps_print(mp, " s");
};
@@ -5869,12 +5897,12 @@ static quarterword mp_size_index (MP mp, font_number f, scaled s) ;
@ @c
quarterword mp_size_index (MP mp, font_number f, scaled s) {
pointer p,q; /* the previous and current font size nodes */
- quarterword i; /* the size index for |q| */
+ int i; /* the size index for |q| */
q=mp->font_sizes[f];
i=0;
while ( q!=null ) {
if ( abs(s-sc_factor(q))<=fscale_tolerance )
- return i;
+ return (quarterword)i;
else
{ p=q; q=link(q); incr(i); };
if ( i==max_quarterword )
@@ -5884,7 +5912,7 @@ quarterword mp_size_index (MP mp, font_number f, scaled s) {
q=mp_get_node(mp, font_size_size);
sc_factor(q)=s;
if ( i==0 ) mp->font_sizes[f]=q; else link(p)=q;
- return i;
+ return (quarterword)i;
}
@ @<Declarations@>=
@@ -5893,7 +5921,7 @@ static scaled mp_indexed_size (MP mp,font_number f, quarterword j);
@ @c
scaled mp_indexed_size (MP mp,font_number f, quarterword j) {
pointer p; /* a font size node */
- quarterword i; /* the size index for |p| */
+ int i; /* the size index for |p| */
p=mp->font_sizes[f];
i=0;
if ( p==null ) mp_confusion(mp, "size");
diff --git a/Build/source/texk/web2c/mplibdir/svgout.w b/Build/source/texk/web2c/mplibdir/svgout.w
index b94f469d78b..23bb4b860d5 100644
--- a/Build/source/texk/web2c/mplibdir/svgout.w
+++ b/Build/source/texk/web2c/mplibdir/svgout.w
@@ -97,7 +97,7 @@ line. It could also be a boolean because right now the only interesting
thing it does is keep track of whether or not we are start-of-line.
@<Globals@>=
-integer file_offset;
+size_t file_offset;
@ @<Set initial values@>=
mp->svg->file_offset = 0;
@@ -115,7 +115,7 @@ static void mp_svg_print_ln (MP mp) {
@c
static void mp_svg_print_char (MP mp, int s) {
char ss[2];
- ss[0]=s; ss[1]=0;
+ ss[0]=(char)s; ss[1]=0;
(mp->write_ascii_file)(mp,mp->output_file,(char *)ss);
mp->svg->file_offset ++;
}
@@ -150,8 +150,8 @@ strings in before feeding the attribute value to |mp_svg_attribute|.
@<Globals...@>=
char *buf;
-int loc;
-int bufsize;
+unsigned loc;
+unsigned bufsize;
@ Start with a modest size of 256. the buffer will grow automatically
when needed.
@@ -176,7 +176,7 @@ the end of the buffer.
}
buffer = mp_xmalloc(mp,l,1);
memset (buffer,0,l);
- memcpy(buffer,mp->svg->buf,mp->svg->bufsize);
+ memcpy(buffer,mp->svg->buf,(size_t)mp->svg->bufsize);
mp_xfree(mp->svg->buf);
mp->svg->buf = buffer ;
mp->svg->bufsize = l;
@@ -234,7 +234,7 @@ static void mp_svg_store_int (MP mp,integer n) {
} while (n!=0);
/* print the digits */
while ( k-->0 ){
- append_char('0'+mp->dig[k]);
+ append_char((char)('0'+mp->dig[k]));
}
}
@@ -245,9 +245,9 @@ are printed, just in case.
@c
static void mp_svg_store_dd (MP mp,integer n) {
- n=abs(n) % 100;
- append_char('0'+(n / 10));
- append_char('0'+(n % 10));
+ char nn=(char)abs(n) % 100;
+ append_char((char)('0'+(nn / 10)));
+ append_char((char)('0'+(nn % 10)));
}
@ Conversely, here is a procedure analogous to |mp_svg_store_int|.
@@ -277,7 +277,7 @@ static void mp_svg_store_scaled (MP mp,scaled s) {
do {
if ( delta>unity )
s=s+0100000-(delta / 2); /* round the final digit */
- append_char('0'+(s / unity));
+ append_char((char)('0'+(s / unity)));
s=10*(s % unity);
delta=delta*10;
} while (s>delta);
@@ -796,7 +796,8 @@ static void mp_svg_font_path_out (MP mp, mp_knot *h) {
@c
static void mp_svg_print_glyph_defs (MP mp, mp_edge_object *h) {
mp_graphic_object *p; /* object index */
- int k, l; /* general purpose indices */
+ int k; /* general purpose index */
+ size_t l; /* a string length */
int **mp_chars = NULL; /* a twodimensional array of used glyphs */
mp_ps_font *f = NULL;
mp_edge_object *ch;
@@ -853,12 +854,12 @@ static void mp_svg_print_glyph_defs (MP mp, mp_edge_object *h) {
append_string("GLYPH");
append_string(mp->font_name[k]);
append_char('_');
- mp_svg_store_int(mp,l);
+ mp_svg_store_int(mp, (int)l);
mp_svg_attribute(mp, "id", mp->svg->buf);
mp_svg_reset_buf(mp);
mp_svg_close_starttag(mp);
if (f != NULL) {
- ch = mp_ps_font_charstring(mp,f,l);
+ ch = mp_ps_font_charstring(mp,f,(int)l);
if (ch != NULL) {
p = ch->body;
mp_svg_open_starttag(mp,"path");
@@ -902,7 +903,7 @@ void mp_svg_text_out (MP mp, mp_text_object *p, int prologues) {
char *fname;
unsigned char *s;
int k; /* a character */
- int l; /* string length */
+ size_t l; /* string length */
boolean transformed ;
scaled ds; /* design size and scale factor for a text node */
fname = mp->font_ps_name[gr_font_n(p)];
@@ -977,7 +978,7 @@ void mp_svg_text_out (MP mp, mp_text_object *p, int prologues) {
mp_svg_store_int(mp,k);
append_char(';');
} else {
- append_char(k);
+ append_char((char)k);
}
}
mp_svg_print_buf(mp);
@@ -1202,7 +1203,7 @@ int mp_svg_gr_ship_out (mp_edge_object *hh, int qprologues, int standalone) {
}
if (mp->history >= mp_fatal_error_stop ) return 1;
mp_open_output_file(mp);
- if ( (qprologues>=1) && (mp->last_ps_fnum<mp->last_fnum) )
+ if ( (qprologues>=1) && mp->ps->tfm_tree == NULL && (mp->last_ps_fnum<mp->last_fnum) )
mp_read_psname_table(mp);
/* The next seems counterintuitive, but calls from |mp_svg_ship_out|
* set standalone to true, and because embedded use is likely, it is
diff --git a/Build/source/texk/web2c/mplibdir/tfmin.w b/Build/source/texk/web2c/mplibdir/tfmin.w
index db604b67caf..d14d57bf735 100644
--- a/Build/source/texk/web2c/mplibdir/tfmin.w
+++ b/Build/source/texk/web2c/mplibdir/tfmin.w
@@ -142,7 +142,7 @@ tfget; read_two(nw);
tfget; read_two(nh);
tfget; read_two(nd);
whd_size=(size_t)((ec+1-bc)+nw+nh+nd);
-if ( lf<(int)(6+tfm_lh+whd_size) ) goto BAD_TFM;
+if ( lf<(int)(6+(size_t)tfm_lh+whd_size) ) goto BAD_TFM;
tf_ignore(10)
@ Offsets are added to |char_base[n]| and |width_base[n]| so that is not
@@ -170,8 +170,8 @@ mp->last_fnum++;
n=mp->last_fnum;
mp->font_bc[n]=(eight_bits)bc;
mp->font_ec[n]=(eight_bits)ec;
-mp->char_base[n]=(int)(mp->next_fmem-bc);
-mp->width_base[n]=(int)(mp->next_fmem+ec-bc+1);
+mp->char_base[n]=(int)(mp->next_fmem-(size_t)bc);
+mp->width_base[n]=(int)(mp->next_fmem+(size_t)(ec-bc)+1);
mp->height_base[n]=mp->width_base[n]+nw;
mp->depth_base[n]=mp->height_base[n]+nh;
mp->next_fmem=mp->next_fmem+whd_size;