summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL Peter Deutsch <lpd@ghostscript.com>2000-04-04 22:13:23 +0000
committerL Peter Deutsch <lpd@ghostscript.com>2000-04-04 22:13:23 +0000
commit5dbebef729842941f079c0f6c63c64757f518a31 (patch)
tree6375d7a3f65d34769736a5cf3f1f17ed9257523c
parent247ffb74e536d1092d0968b467f4c4e97530c25e (diff)
downloadghostpdl-5dbebef729842941f079c0f6c63c64757f518a31.tar.gz
Extends .forceput to handle arrays as well as dictionaries, required to fix
a bug with internaldict. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@241 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/src/zdict.c36
-rw-r--r--gs/src/zgeneric.c56
2 files changed, 56 insertions, 36 deletions
diff --git a/gs/src/zdict.c b/gs/src/zdict.c
index e8af58a37..7e2ff3168 100644
--- a/gs/src/zdict.c
+++ b/gs/src/zdict.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989, 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
+/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
This file is part of Aladdin Ghostscript.
@@ -391,39 +391,6 @@ zdicttomark(i_ctx_t *i_ctx_p)
return code;
}
-/* <dict> <key> <value> .forceput - */
-/*
- * This forces a "put" even if the dictionary is not writable, and (if the
- * dictionary is systemdict or the save level is 0) even if the value is in
- * local VM. It is meant to be used only for replacing the value of
- * FontDirectory in systemdict when switching between local and global VM,
- * and a few similar applications. After initialization, this operator
- * should no longer be accessible by name.
- */
-private int
-zforceput(i_ctx_t *i_ctx_p)
-{
- os_ptr op = osp;
- os_ptr odp = op - 2;
- int code;
-
- check_type(*odp, t_dictionary);
- if (odp->value.pdict == systemdict->value.pdict ||
- !imemory_save_level(iimemory)
- ) {
- uint space = r_space(odp);
-
- r_set_space(odp, avm_local);
- code = idict_put(odp, op - 1, op);
- r_set_space(odp, space);
- } else
- code = idict_put(odp, op - 1, op);
- if (code < 0)
- return code;
- pop(3);
- return 0;
-}
-
/* <dict> <key> .forceundef - */
/*
* This forces an "undef" even if the dictionary is not writable.
@@ -529,7 +496,6 @@ const op_def zdict2_op_defs[] = {
/* Extensions */
{"2.dictcopynew", zdictcopynew},
{"1.dicttomark", zdicttomark},
- {"3.forceput", zforceput},
{"2.forceundef", zforceundef},
{"2.knownget", zknownget},
{"1.knownundef", zknownundef},
diff --git a/gs/src/zgeneric.c b/gs/src/zgeneric.c
index e88054d6d..1740c3273 100644
--- a/gs/src/zgeneric.c
+++ b/gs/src/zgeneric.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989, 1992, 1993, 1994, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
+/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
This file is part of Aladdin Ghostscript.
@@ -22,6 +22,7 @@
#include "ghost.h"
#include "gsstruct.h" /* for st_bytes */
#include "oper.h"
+#include "dstack.h" /* for systemdict */
#include "estack.h" /* for forall */
#include "iddict.h"
#include "iname.h"
@@ -242,6 +243,58 @@ str: check_write(*op2);
return 0;
}
+/* <array> <index> <obj> .forceput - */
+/* <dict> <key> <value> .forceput - */
+/*
+ * This forces a "put" even if the object is not writable, and (if the
+ * object is systemdict or the save level is 0) even if the value is in
+ * local VM. It is meant to be used only for replacing the value of
+ * FontDirectory in systemdict when switching between local and global VM,
+ * and a few similar applications. After initialization, this operator
+ * should no longer be accessible by name.
+ */
+private int
+zforceput(i_ctx_t *i_ctx_p)
+{
+ os_ptr op = osp;
+ os_ptr op1 = op - 1;
+ os_ptr op2 = op - 2;
+ int code;
+
+ switch (r_type(op2)) {
+ case t_array:
+ check_int_ltu(*op1, r_size(op2));
+ if (r_space(op2) > r_space(op)) {
+ if (imemory_save_level(iimemory))
+ return_error(e_invalidaccess);
+ }
+ {
+ ref *eltp = op2->value.refs + (uint) op1->value.intval;
+
+ ref_assign_old(op2, eltp, op, "put");
+ }
+ break;
+ case t_dictionary:
+ if (op2->value.pdict == systemdict->value.pdict ||
+ !imemory_save_level(iimemory)
+ ) {
+ uint space = r_space(op2);
+
+ r_set_space(op2, avm_local);
+ code = idict_put(op2, op1, op);
+ r_set_space(op2, space);
+ } else
+ code = idict_put(op2, op1, op);
+ if (code < 0)
+ return code;
+ break;
+ default:
+ return_error(e_typecheck);
+ }
+ pop(3);
+ return 0;
+}
+
/* <seq:array|packedarray|string> <index> <count> getinterval <subseq> */
private int
zgetinterval(i_ctx_t *i_ctx_p)
@@ -487,6 +540,7 @@ const op_def zgeneric_op_defs[] =
{
{"1copy", zcopy},
{"2forall", zforall},
+ {"3.forceput", zforceput},
{"2get", zget},
{"3getinterval", zgetinterval},
{"1length", zlength},