summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Cherepanov <alex.cherepanov@artifex.com>2009-06-05 05:55:54 +0000
committerAlex Cherepanov <alex.cherepanov@artifex.com>2009-06-05 05:55:54 +0000
commitd84be56069dc2579c88d360da2ccc2ad5825a490 (patch)
tree8a34ca16fc77e7e433f08ad28b09e632e2a3cfa5
parent3a9526f1355c818ad24694e61dc02c9d877e0e8d (diff)
Switch to 32-bit PostScript integers on 64 bit platform. Bug 690474.
DIFFERENCES: FTS test files 002-21.ps, 170-01.ps, 181-01.ps, 438-01.ps no longer fail on 64-bit platform. CET tests changed from 'not matching' to 'matching'. 19-13 22-2 22-11 23-12W 23-18 23-20 23-30 24-1 24-4 24-5 24-6 25-2 25-4 25-6 25-8 25-9 25-10 25-11 25-12 25-16 25-21 25-22 26-1 26-5 26-6 26-7 26-11 26-13 CET tests changed the checksum but still 'not matching' 25-1 25-14 CET files with PostScript error fixed but still 'not matching'. 25-13 26-2 27-5 git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9778 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/base/gsalloc.c2
-rw-r--r--gs/psi/ibnum.c19
-rw-r--r--gs/psi/ibnum.h2
-rw-r--r--gs/psi/idebug.c2
-rw-r--r--gs/psi/idparam.c5
-rw-r--r--gs/psi/iparam.c10
-rw-r--r--gs/psi/iref.h2
-rw-r--r--gs/psi/iscan.c4
-rw-r--r--gs/psi/iscanbin.c9
-rw-r--r--gs/psi/iscannum.c132
-rw-r--r--gs/psi/iutil.c2
-rw-r--r--gs/psi/zarith.c18
-rw-r--r--gs/psi/zcontrol.c8
-rw-r--r--gs/psi/zdict.c8
-rw-r--r--gs/psi/zdps.c7
-rw-r--r--gs/psi/zfcid0.c4
-rw-r--r--gs/psi/zfile.c2
-rw-r--r--gs/psi/zfunc4.c4
-rw-r--r--gs/psi/zgeneric.c4
-rw-r--r--gs/psi/ziodev.c2
-rw-r--r--gs/psi/zmath.c6
-rw-r--r--gs/psi/zstack.c2
-rw-r--r--gs/psi/ztype.c12
23 files changed, 87 insertions, 179 deletions
diff --git a/gs/base/gsalloc.c b/gs/base/gsalloc.c
index 97418dfde..ca794105d 100644
--- a/gs/base/gsalloc.c
+++ b/gs/base/gsalloc.c
@@ -202,7 +202,7 @@ ialloc_alloc_state(gs_memory_t * parent, uint chunk_size)
iimem->large_size = ((chunk_size / 4) & -obj_align_mod) + 1;
iimem->is_controlled = false;
iimem->gc_status.vm_threshold = chunk_size * 3L;
- iimem->gc_status.max_vm = max_long;
+ iimem->gc_status.max_vm = 0x7fffffff;
iimem->gc_status.psignal = NULL;
iimem->gc_status.signal_value = 0;
iimem->gc_status.enabled = false;
diff --git a/gs/psi/ibnum.c b/gs/psi/ibnum.c
index a440ed396..f80b1d2cd 100644
--- a/gs/psi/ibnum.c
+++ b/gs/psi/ibnum.c
@@ -124,11 +124,11 @@ sdecode_number(const byte * str, int format, ref * np)
case num_int32:
case num_int32 + 16:
if ((format & 31) == 0) {
- np->value.intval = sdecodelong(str, format);
+ np->value.intval = sdecodeint32(str, format);
return t_integer;
} else {
np->value.realval =
- (double)sdecodelong(str, format) *
+ (double)sdecodeint32(str, format) *
binary_scale[format & 31];
return t_real;
}
@@ -178,18 +178,13 @@ sdecodeshort(const byte * p, int format)
}
/* Decode a (32-bit, signed) long. */
-long
-sdecodelong(const byte * p, int format)
+int
+sdecodeint32(const byte * p, int format)
{
int a = p[0], b = p[1], c = p[2], d = p[3];
- long v = (num_is_lsb(format) ?
- ((long)d << 24) + ((long)c << 16) + (b << 8) + a :
- ((long)a << 24) + ((long)b << 16) + (c << 8) + d);
-
-#if arch_sizeof_long > 4
- /* Propagate bit 31 as the sign. */
- v = (v ^ 0x80000000L) - 0x80000000L;
-#endif
+ int v = (num_is_lsb(format) ?
+ ((int)d << 24) + ((int)c << 16) + (b << 8) + a :
+ ((int)a << 24) + ((int)b << 16) + (c << 8) + d);
return v;
}
diff --git a/gs/psi/ibnum.h b/gs/psi/ibnum.h
index 7290ae650..78223c33e 100644
--- a/gs/psi/ibnum.h
+++ b/gs/psi/ibnum.h
@@ -72,7 +72,7 @@ int num_array_get(const gs_memory_t *mem, const ref *, int, uint, ref *);
int sdecode_number(const byte *, int, ref *);
int sdecodeshort(const byte *, int);
uint sdecodeushort(const byte *, int);
-long sdecodelong(const byte *, int);
+int sdecodeint32(const byte *, int);
int sdecode_float(const byte *, int, float *);
#endif /* ibnum_INCLUDED */
diff --git a/gs/psi/idebug.c b/gs/psi/idebug.c
index 1c7ad2fa6..86f304eb0 100644
--- a/gs/psi/idebug.c
+++ b/gs/psi/idebug.c
@@ -85,7 +85,7 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref)
case t_fontID:
goto strct;
case t_integer:
- dprintf1("int %ld", pref->value.intval);
+ dprintf1("int %d", pref->value.intval);
break;
case t_mark:
dprintf("mark");
diff --git a/gs/psi/idparam.c b/gs/psi/idparam.c
index d7f63133f..5ad44dfa1 100644
--- a/gs/psi/idparam.c
+++ b/gs/psi/idparam.c
@@ -58,8 +58,7 @@ dict_int_null_param(const ref * pdict, const char *kstr, int minval,
int maxval, int defaultval, int *pvalue)
{
ref *pdval;
- int code;
- long ival;
+ int code, ival;
if (pdict == 0 || dict_find_string(pdict, kstr, &pdval) <= 0) {
ival = defaultval;
@@ -378,7 +377,7 @@ dict_uid_param(const ref * pdict, gs_uid * puid, int defaultval,
} else {
if (!r_has_type(puniqueid, t_integer))
return_error(e_typecheck);
- if (puniqueid->value.intval < 0 || puniqueid->value.intval > 0xffffffL)
+ if (puniqueid->value.intval < 0 || puniqueid->value.intval > 0xffffff)
return_error(e_rangecheck);
/* Apparently fonts created by Fontographer often have */
/* a UniqueID of 0, contrary to Adobe's specifications. */
diff --git a/gs/psi/iparam.c b/gs/psi/iparam.c
index afebdfb2c..a1f20dc20 100644
--- a/gs/psi/iparam.c
+++ b/gs/psi/iparam.c
@@ -63,7 +63,7 @@ ref_to_key(const ref * pref, gs_param_key_t * key, iparam_list *plist)
int len;
byte *buf;
- sprintf(istr, "%ld", pref->value.intval);
+ sprintf(istr, "%d", pref->value.intval);
len = strlen(istr);
/* GC will take care of freeing this: */
buf = gs_alloc_string(plist->memory, len, "ref_to_key");
@@ -390,7 +390,7 @@ stack_param_enumerate(iparam_list * plist, gs_param_enumerator_t * penum,
{
int code;
stack_param_list *const splist = (stack_param_list *) plist;
- long index = penum->intval;
+ int index = penum->intval;
ref *stack_element;
do {
@@ -560,12 +560,6 @@ ref_param_read_int_array(gs_param_list * plist, gs_param_name pkey,
code = gs_note_error(e_typecheck);
break;
}
-#if arch_sizeof_int < arch_sizeof_long
- if (elt.value.intval != (int)elt.value.intval) {
- code = gs_note_error(e_rangecheck);
- break;
- }
-#endif
piv[i] = (int)elt.value.intval;
}
if (code < 0) {
diff --git a/gs/psi/iref.h b/gs/psi/iref.h
index 8d6c95e91..a381eb162 100644
--- a/gs/psi/iref.h
+++ b/gs/psi/iref.h
@@ -380,7 +380,7 @@ struct ref_s {
struct tas_s tas;
union v { /* name the union to keep gdb happy */
- long intval;
+ int intval;
ushort boolval;
float realval;
ulong saveid;
diff --git a/gs/psi/iscan.c b/gs/psi/iscan.c
index fc4a956ed..0f997dda2 100644
--- a/gs/psi/iscan.c
+++ b/gs/psi/iscan.c
@@ -693,10 +693,10 @@ scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
uint size = ref_stack_count_inline(&o_stack) - pstack;
ref arr;
- if_debug4('S', "[S}]d=%d, s=%d->%ld, c=%d\n",
+ if_debug4('S', "[S}]d=%d, s=%d->%d, c=%d\n",
pdepth, pstack,
(pstack == pdepth ? 0 :
- ref_stack_index(&o_stack, size)->value.intval),
+ ref_stack_index(&o_stack, size)->value.intval),
size + pstack);
myref = (pstack == pdepth ? pref : &arr);
if (check_only) {
diff --git a/gs/psi/iscanbin.c b/gs/psi/iscanbin.c
index 6c47369b3..883ec8481 100644
--- a/gs/psi/iscanbin.c
+++ b/gs/psi/iscanbin.c
@@ -195,7 +195,7 @@ scan_bos(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate)
if (top_size == 0) {
/* Extended header (2-byte array size, 4-byte length) */
- ulong lsize;
+ uint lsize;
if (rcnt < 7) {
s_end_inline(s, p - 1, rlimit);
@@ -203,7 +203,7 @@ scan_bos(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate)
return scan_Refill;
}
pbs->top_size = top_size = sdecodeushort(p + 2, num_format);
- pbs->lsize = lsize = sdecodelong(p + 4, num_format);
+ pbs->lsize = lsize = sdecodeint32(p + 4, num_format);
if ((size = lsize) != lsize) {
scan_bos_error(pstate, "bin obj seq length too large");
return_error(e_limitcheck);
@@ -534,8 +534,7 @@ scan_bos_continue(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
for (; index < max_array_index; p += SIZEOF_BIN_SEQ_OBJ, index++) {
ref *op = abase + index;
uint osize;
- long value;
- uint atype, attrs;
+ int value, atype, attrs;
s_end_inline(s, p, rlimit); /* in case of error */
if (rlimit - p < SIZEOF_BIN_SEQ_OBJ) {
@@ -555,7 +554,7 @@ scan_bos_continue(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
* syntaxerror if any unused field is non-zero (per PLRM).
*/
osize = sdecodeushort(p + 3, num_format);
- value = sdecodelong(p + 5, num_format);
+ value = sdecodeint32(p + 5, num_format);
switch (p[1] & 0x7f) {
case BS_TYPE_NULL:
if (osize | value) { /* unused */
diff --git a/gs/psi/iscannum.c b/gs/psi/iscannum.c
index f49c1e1ba..ae13a2ea7 100644
--- a/gs/psi/iscannum.c
+++ b/gs/psi/iscannum.c
@@ -53,7 +53,6 @@ scan_number(const byte * str, const byte * end, int sign,
};
int ival;
- long lval;
double dval;
int exp10;
int code = 0;
@@ -102,8 +101,26 @@ scan_number(const byte * str, const byte * end, int sign,
GET_NEXT(c, sp, goto iret);
if (!IS_DIGIT(d, c))
break;
- if (WOULD_OVERFLOW(((unsigned)ival), d, max_scan))
- goto i2l;
+ if (WOULD_OVERFLOW(((unsigned)ival), d, max_scan)) {
+ //goto i2l;
+ if (ival == max_int / 10 && d == (max_int % 10) + 1 && sign < 0) {
+ GET_NEXT(c, sp, c = EOFC);
+ dval = -(double)min_int;
+ if (c == 'e' || c == 'E') {
+ exp10 = 0;
+ goto fs;
+ } else if (c == '.') {
+ GET_NEXT(c, sp, c = EOFC);
+ exp10 = 0;
+ goto fd;
+ } else if (!IS_DIGIT(d, c)) {
+ ival = min_int;
+ break;
+ }
+ } else
+ dval = ival;
+ goto l2d;
+ }
}
ind: /* We saw a non-digit while accumulating an integer in ival. */
switch (c) {
@@ -113,6 +130,8 @@ scan_number(const byte * str, const byte * end, int sign,
default:
*psp = sp;
code = 1;
+ break;
+ case EOFC:
break;
case 'e':
case 'E':
@@ -123,8 +142,8 @@ scan_number(const byte * str, const byte * end, int sign,
goto fe;
case '#':
{
- const uint radix = (uint)ival;
- ulong uval = 0, lmax;
+ const int radix = ival;
+ uint uval = 0, imax;
if (sign || radix < min_radix || radix > max_radix)
return_error(e_syntaxerror);
@@ -134,19 +153,19 @@ scan_number(const byte * str, const byte * end, int sign,
switch (radix) {
case 2:
- shift = 1, lmax = max_ulong >> 1;
+ shift = 1, imax = max_uint >> 1;
break;
case 4:
- shift = 2, lmax = max_ulong >> 2;
+ shift = 2, imax = max_uint >> 2;
break;
case 8:
- shift = 3, lmax = max_ulong >> 3;
+ shift = 3, imax = max_uint >> 3;
break;
case 16:
- shift = 4, lmax = max_ulong >> 4;
+ shift = 4, imax = max_uint >> 4;
break;
case 32:
- shift = 5, lmax = max_ulong >> 5;
+ shift = 5, imax = max_uint >> 5;
break;
default: /* can't happen */
return_error(e_rangecheck);
@@ -159,13 +178,13 @@ scan_number(const byte * str, const byte * end, int sign,
code = 1;
break;
}
- if (uval > lmax)
+ if (uval > imax)
return_error(e_limitcheck);
}
} else {
- int lrem = max_ulong % radix;
+ int irem = max_uint % radix;
- lmax = max_ulong / radix;
+ imax = max_uint / radix;
for (;; uval = uval * radix + d) {
GET_NEXT(c, sp, break);
d = decoder[c];
@@ -174,8 +193,8 @@ scan_number(const byte * str, const byte * end, int sign,
code = 1;
break;
}
- if (uval >= lmax &&
- (uval > lmax || d > lrem)
+ if (uval >= imax &&
+ (uval > imax || d > irem)
)
return_error(e_limitcheck);
}
@@ -188,59 +207,6 @@ iret:
make_int(pref, (sign < 0 ? -ival : ival));
return code;
- /* Accumulate a long in lval. */
-i2l:
- for (lval = (unsigned)ival;;) {
- if (WOULD_OVERFLOW(((unsigned long)lval), d, ((unsigned long)max_long))) {
- /* Make a special check for entering the smallest */
- /* (most negative) integer. */
- if (lval == max_long / 10 &&
- d == (int)(max_long % 10) + 1 && sign < 0
- ) {
- GET_NEXT(c, sp, c = EOFC);
- dval = -(double)min_long;
- if (c == 'e' || c == 'E') {
- exp10 = 0;
- goto fs;
- } else if (c == '.') {
- GET_NEXT(c, sp, c = EOFC);
- exp10 = 0;
- goto fd;
- } else if (!IS_DIGIT(d, c)) {
- lval = min_long;
- break;
- }
- } else
- dval = (unsigned long)lval;
- goto l2d;
- }
- lval = lval * 10 + d;
- GET_NEXT(c, sp, goto lret);
- if (!IS_DIGIT(d, c))
- break;
- }
- switch (c) {
- case '.':
- GET_NEXT(c, sp, c = EOFC);
- exp10 = 0;
- goto l2r;
- case EOFC:
- break;
- default:
- *psp = sp;
- code = 1;
- break;
- case 'e':
- case 'E':
- exp10 = 0;
- goto le;
- case '#':
- return_error(e_syntaxerror);
- }
-lret:
- make_int(pref, (sign < 0 ? -lval : lval));
- return code;
-
/* Accumulate a double in dval. */
l2d:
exp10 = 0;
@@ -291,8 +257,8 @@ i2r:
break;
}
if (WOULD_OVERFLOW(ival, d, max_int)) {
- lval = ival;
- goto l2r;
+ dval = ival;
+ goto fd;
}
ival = ival * 10 + d;
exp10--;
@@ -310,32 +276,6 @@ i2r:
dval = ival;
goto fe;
- /* We saw a '.' while accumulating a long in lval. */
-l2r:
- while (IS_DIGIT(d, c) || c == '-') {
- /* Handle bogus '-' following '.' as in i2r above. */
- if (c == '-') {
- if ((scanner_options & SCAN_PDF_INV_NUM) == 0)
- break;
- do {
- GET_NEXT(c, sp, c = EOFC);
- } while (IS_DIGIT(d, c));
- break;
- }
- if (WOULD_OVERFLOW(lval, d, max_long)) {
- dval = lval;
- goto fd;
- }
- lval = lval * 10 + d;
- exp10--;
- GET_NEXT(c, sp, c = EOFC);
- }
-le:
- if (sign < 0)
- lval = -lval;
- dval = lval;
- goto fe;
-
/* Now we are accumulating a double in dval. */
fd:
while (IS_DIGIT(d, c)) {
diff --git a/gs/psi/iutil.c b/gs/psi/iutil.c
index 29736348c..7f3aa6330 100644
--- a/gs/psi/iutil.c
+++ b/gs/psi/iutil.c
@@ -492,7 +492,7 @@ other:
data = (const byte *)(op->value.boolval ? "true" : "false");
break;
case t_integer:
- sprintf(buf, "%ld", op->value.intval);
+ sprintf(buf, "%d", op->value.intval);
break;
case t_string:
check_read(*op);
diff --git a/gs/psi/zarith.c b/gs/psi/zarith.c
index d8eb91b4f..820056f77 100644
--- a/gs/psi/zarith.c
+++ b/gs/psi/zarith.c
@@ -27,9 +27,9 @@
*/
/* Define max and min values for what will fit in value.intval. */
-#define MIN_INTVAL min_long
-#define MAX_INTVAL max_long
-#define MAX_HALF_INTVAL ((1L << (size_of(long) * 4 - 1)) - 1)
+#define MIN_INTVAL 0x80000000
+#define MAX_INTVAL 0x7fffffff
+#define MAX_HALF_INTVAL 0x7fff
/* <num1> <num2> add <sum> */
/* We make this into a separate procedure because */
@@ -59,7 +59,7 @@ zop_add(register os_ptr op)
op[-1].value.realval += (double)op->value.intval;
break;
case t_integer: {
- long int2 = op->value.intval;
+ int int2 = op->value.intval;
if (((op[-1].value.intval += int2) ^ int2) < 0 &&
((op[-1].value.intval - int2) ^ int2) >= 0
@@ -153,10 +153,10 @@ zmul(i_ctx_t *i_ctx_p)
op[-1].value.realval *= (double)op->value.intval;
break;
case t_integer: {
- long int1 = op[-1].value.intval;
- long int2 = op->value.intval;
- unsigned long abs1 = (unsigned long)(int1 >= 0 ? int1 : -int1);
- unsigned long abs2 = (unsigned long)(int2 >= 0 ? int2 : -int2);
+ int int1 = op[-1].value.intval;
+ int int2 = op->value.intval;
+ uint abs1 = (uint)(int1 >= 0 ? int1 : -int1);
+ uint abs2 = (uint)(int2 >= 0 ? int2 : -int2);
float fprod;
if ((abs1 > MAX_HALF_INTVAL || abs2 > MAX_HALF_INTVAL) &&
@@ -207,7 +207,7 @@ zop_sub(register os_ptr op)
op[-1].value.realval -= (double)op->value.intval;
break;
case t_integer: {
- long int1 = op[-1].value.intval;
+ int int1 = op[-1].value.intval;
if ((int1 ^ (op[-1].value.intval = int1 - op->value.intval)) < 0 &&
(int1 ^ op->value.intval) < 0
diff --git a/gs/psi/zcontrol.c b/gs/psi/zcontrol.c
index 1c8cd668c..1ba6041de 100644
--- a/gs/psi/zcontrol.c
+++ b/gs/psi/zcontrol.c
@@ -362,7 +362,7 @@ for_pos_int_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
register es_ptr ep = esp;
- long var = ep[-3].value.intval;
+ int var = ep[-3].value.intval;
if (var > ep[-1].value.intval) {
esp -= 5; /* pop everything */
@@ -381,7 +381,7 @@ for_neg_int_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
register es_ptr ep = esp;
- long var = ep[-3].value.intval;
+ int var = ep[-3].value.intval;
if (var < ep[-1].value.intval) {
esp -= 5; /* pop everything */
@@ -454,9 +454,9 @@ for_samples_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
es_ptr ep = esp;
- long var = ep[-4].value.intval;
+ int var = ep[-4].value.intval;
float a = ep[-3].value.realval;
- long n = ep[-2].value.intval;
+ int n = ep[-2].value.intval;
float b = ep[-1].value.realval;
if (var > n) {
diff --git a/gs/psi/zdict.c b/gs/psi/zdict.c
index 65b49d8b2..536346af9 100644
--- a/gs/psi/zdict.c
+++ b/gs/psi/zdict.c
@@ -30,12 +30,8 @@ zdict(i_ctx_t *i_ctx_p)
os_ptr op = osp;
check_type(*op, t_integer);
-#if arch_sizeof_int < arch_sizeof_long
- check_int_leu(*op, max_uint);
-#else
if (op->value.intval < 0)
return_error(e_rangecheck);
-#endif
return dict_create((uint) op->value.intval, op);
}
@@ -496,12 +492,8 @@ zsetmaxlength(i_ctx_t *i_ctx_p)
if (i_ctx_p->in_superexec == 0)
check_dict_write(*op1);
check_type(*op, t_integer);
-#if arch_sizeof_int < arch_sizeof_long
- check_int_leu(*op, max_uint);
-#else
if (op->value.intval < 0)
return_error(e_rangecheck);
-#endif
new_size = (uint) op->value.intval;
if (dict_length(op - 1) > new_size)
return_error(e_dictfull);
diff --git a/gs/psi/zdps.c b/gs/psi/zdps.c
index a876cbd30..19d305707 100644
--- a/gs/psi/zdps.c
+++ b/gs/psi/zdps.c
@@ -41,19 +41,18 @@ zsetscreenphase(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code;
- long x, y;
+ int x, y;
check_type(op[-2], t_integer);
check_type(op[-1], t_integer);
check_type(*op, t_integer);
x = op[-1].value.intval;
y = op->value.intval;
- if (x != (int)x || y != (int)y ||
- op[-2].value.intval < -1 ||
+ if (op[-2].value.intval < -1 ||
op[-2].value.intval >= gs_color_select_count
)
return_error(e_rangecheck);
- code = gs_setscreenphase(igs, (int)x, (int)y,
+ code = gs_setscreenphase(igs, x, y,
(gs_color_select_t) op[-2].value.intval);
if (code >= 0)
pop(3);
diff --git a/gs/psi/zfcid0.c b/gs/psi/zfcid0.c
index 7061c6437..f4df51ade 100644
--- a/gs/psi/zfcid0.c
+++ b/gs/psi/zfcid0.c
@@ -542,7 +542,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p)
if (code < 0) { /* failed to load glyph data, put CID 0 */
int default_fallback_CID = 0 ;
- if_debug2('J', "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %ld\n", default_fallback_CID, op->value.intval);
+ if_debug2('J', "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %d\n", default_fallback_CID, op->value.intval);
op->value.intval = default_fallback_CID;
@@ -553,7 +553,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p)
&gdata, &fidx);
if (code < 0) {
- if_debug1('J', "[J]ztype9cidmap() could not load default glyph (CID %ld)\n", op->value.intval);
+ if_debug1('J', "[J]ztype9cidmap() could not load default glyph (CID %d)\n", op->value.intval);
return_error(e_invalidfont);
}
diff --git a/gs/psi/zfile.c b/gs/psi/zfile.c
index e7034df7d..37f7fe8a8 100644
--- a/gs/psi/zfile.c
+++ b/gs/psi/zfile.c
@@ -381,7 +381,7 @@ file_continue(i_ctx_t *i_ctx_p)
os_ptr op = osp;
es_ptr pscratch = esp - 2;
file_enum *pfen = r_ptr(esp - 1, file_enum);
- long devlen = esp[-3].value.intval;
+ int devlen = esp[-3].value.intval;
gx_io_device *iodev = r_ptr(esp - 4, gx_io_device);
uint len = r_size(pscratch);
uint code;
diff --git a/gs/psi/zfunc4.c b/gs/psi/zfunc4.c
index 666cd5e60..2a326e6f4 100644
--- a/gs/psi/zfunc4.c
+++ b/gs/psi/zfunc4.c
@@ -172,10 +172,6 @@ check_psc_function(i_ctx_t *i_ctx_p, const ref *pref, int depth, byte *ops, int
case t_integer: {
int i = elt.value.intval;
-#if ARCH_SIZEOF_INT < ARCH_SIZEOF_LONG
- if (i != elt.value.intval) /* check for truncation */
- return_error(e_rangecheck);
-#endif
if (i == (byte)i) {
*p = PtCr_byte;
p[1] = (byte)i;
diff --git a/gs/psi/zgeneric.c b/gs/psi/zgeneric.c
index 243d3d07c..bd1c191c3 100644
--- a/gs/psi/zgeneric.c
+++ b/gs/psi/zgeneric.c
@@ -71,7 +71,7 @@ zcopy_integer(i_ctx_t *i_ctx_p)
int count, i;
int code;
- if ((ulong) op->value.intval > (ulong)(op - osbot)) {
+ if ((uint) op->value.intval > (uint)(op - osbot)) {
/* There might be enough elements in other blocks. */
check_type(*op, t_integer);
if (op->value.intval >= (int)ref_stack_count(&o_stack))
@@ -478,7 +478,7 @@ dict_continue(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
es_ptr obj = esp - 2;
- int index = (int)esp->value.intval;
+ int index = esp->value.intval;
push(2); /* make room for key and value */
if ((index = dict_next(obj, index, op - 1)) >= 0) { /* continue */
diff --git a/gs/psi/ziodev.c b/gs/psi/ziodev.c
index d41069e0c..74a5a3cd9 100644
--- a/gs/psi/ziodev.c
+++ b/gs/psi/ziodev.c
@@ -74,8 +74,6 @@ zgetiodevice(i_ctx_t *i_ctx_p)
const byte *dname;
check_type(*op, t_integer);
- if (op->value.intval != (int)op->value.intval)
- return_error(e_rangecheck);
iodev = gs_getiodevice((int)(op->value.intval));
if (iodev == 0) /* index out of range */
return_error(e_rangecheck);
diff --git a/gs/psi/zmath.c b/gs/psi/zmath.c
index e86c7bd61..1f6cfb599 100644
--- a/gs/psi/zmath.c
+++ b/gs/psi/zmath.c
@@ -225,14 +225,10 @@ static int
zsrand(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
- long state;
+ int state;
check_type(*op, t_integer);
state = op->value.intval;
-#if arch_sizeof_long > 4
- /* Trim the state back to 32 bits. */
- state = (int)state;
-#endif
/*
* The following somewhat bizarre adjustments are according to
* public information from Adobe describing their implementation.
diff --git a/gs/psi/zstack.c b/gs/psi/zstack.c
index 84ec98ac4..21703f9b7 100644
--- a/gs/psi/zstack.c
+++ b/gs/psi/zstack.c
@@ -112,7 +112,7 @@ zroll(i_ctx_t *i_ctx_p)
check_type(*op1, t_integer);
check_type(*op, t_integer);
- if ((ulong) op1->value.intval > (ulong)(op1 - osbot)) {
+ if ((uint) op1->value.intval > (uint)(op1 - osbot)) {
/*
* The data might span multiple stack blocks.
* There are efficient ways to handle this situation,
diff --git a/gs/psi/ztype.c b/gs/psi/ztype.c
index 2175cdecf..5fe51d6a5 100644
--- a/gs/psi/ztype.c
+++ b/gs/psi/ztype.c
@@ -48,10 +48,10 @@ static int convert_to_string(const gs_memory_t *mem, os_ptr, os_ptr);
* constant expressions, so we can't use min_long and max_long.
* What a nuisance!
*/
-#define ALT_MIN_LONG (-1L << (arch_sizeof_long * 8 - 1))
-#define ALT_MAX_LONG (~(ALT_MIN_LONG))
-static const double min_int_real = (ALT_MIN_LONG * 1.0 - 1);
-static const double max_int_real = (ALT_MAX_LONG * 1.0 + 1);
+#define ALT_MIN_INT (-1 << 31)
+#define ALT_MAX_INT (~(ALT_MIN_INT))
+static const double min_int_real = (ALT_MIN_INT * 1.0 - 1);
+static const double max_int_real = (ALT_MAX_INT * 1.0 + 1);
#define REAL_CAN_BE_INT(v)\
((v) > min_int_real && (v) < max_int_real)
@@ -357,14 +357,14 @@ zcvrs(i_ctx_t *i_ctx_p)
return_error(e_rangecheck); /* CET 24-05 wants rangecheck */
}
} else {
- ulong ival;
+ uint ival;
byte digits[sizeof(ulong) * 8];
byte *endp = &digits[countof(digits)];
byte *dp = endp;
switch (r_type(op - 2)) {
case t_integer:
- ival = (ulong) op[-2].value.intval;
+ ival = (uint) op[-2].value.intval;
break;
case t_real:
{