|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T z
Length: 3320 (0xcf8) Types: TextFile Names: »zarray.c«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89 └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« └─⟦a24a58cd3⟧ └─⟦this⟧ »zarray.c«
/* Copyright (C) 1989 Aladdin Enterprises. All rights reserved. Distributed by Free Software Foundation, Inc. This file is part of Ghostscript. Ghostscript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the Ghostscript General Public License for full details. Everyone is granted permission to copy, modify and redistribute Ghostscript, but only under the conditions described in the Ghostscript General Public License. A copy of this license is supposed to have been given to you along with Ghostscript so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ /* zarray.c */ /* Array operators for GhostScript */ #include "ghost.h" #include "alloc.h" #include "errors.h" #include "oper.h" #include "store.h" #include "sstorei.h" /* The generic operators (copy, get, put, getinterval, putinterval, */ /* length, and forall) are implemented in zgeneric.c. */ /* Forward references */ private int make_array(P3(register ref *, int, int)); /* Import the array packing flag */ extern int array_packing; /* Import the operand stack limit */ extern ref *ostop; /* Import null */ extern ref null; /* array */ int zarray(register ref *op) { return make_array(op, t_array, a_all); } /* aload */ int zaload(register ref *op) { ref aref; check_array(*op); aref = *op; if ( aref.size > ostop - op ) return e_rangecheck; memcpy((char *)op, (char *)aref.value.refs, aref.size * sizeof(ref)); push(aref.size); *op = aref; return 0; } /* astore */ int zastore(register ref *op) { uint size; check_type(*op, t_array); size = op->size; if ( size > op - osbot ) return e_stackunderflow; refcpy(op->value.refs, op - size, size); op[-size] = *op; pop(size); return 0; } /* currentpacking */ int zcurrentpacking(register ref *op) { push(1); make_bool(op, array_packing); return 0; } /* packedarray */ int zpackedarray(register ref *op) { return make_array(op, t_packedarray, a_read+a_execute); } /* setpacking */ int zsetpacking(register ref *op) { check_type(*op, t_boolean); array_packing = op->value.index; pop(1); return 0; } /* ------ Initialization procedure ------ */ void zarray_op_init() { static op_def my_defs[] = { {"1aload", zaload}, {"1array", zarray}, {"1astore", zastore}, {"0currentpacking", zcurrentpacking}, {"1packedarray", zpackedarray}, {"1setpacking", zsetpacking}, op_def_end }; z_op_init(my_defs); } /* ------ Internal procedures ------ */ /* Make an array or a packed array from the operand stack. */ private int make_array(register ref *op, int type, int attrs) { ref *abody; uint size; ushort ta = null.type_attrs; check_type(*op, t_integer); if ( op->value.intval < 0 || op->value.intval > (uint)(-1) / sizeof(ref) - 1 ) return e_rangecheck; size = op->value.intval; abody = (ref *)alloc(size * sizeof(ref), "make_array"); /* WRONG (may overflow) */ if ( abody == 0 ) return e_VMerror; make_tasv(op, type, attrs, size, refs, abody); while ( size-- ) abody++->type_attrs = ta; return 0; }