/* * Set up to collect the data for the sampled function. This is used for * those alternate tint transforms that cannot be converted into a * type 4 function. */ static int sampled_data_setup(i_ctx_t *i_ctx_p, gs_function_t *pfn, const ref * pproc, int (*finish_proc)(i_ctx_t *), gs_memory_t * mem) { os_ptr op = osp; gs_sampled_data_enum *penum; int i; gs_function_Sd_params_t * params = (gs_function_Sd_params_t *)&pfn->params; check_estack(estack_storage + 1); /* Verify space on estack */ check_ostack(params->m + O_STACK_PAD); /* and the operand stack */ check_ostack(params->n + O_STACK_PAD); /* * Allocate space for the enumerator data structure. */ penum = gs_sampled_data_enum_alloc(imemory, "zbuildsampledfuntion(params)"); if (penum == NULL) return_error(e_VMerror); /* Initialize data in the enumeration structure */ penum->pfn = pfn; for(i=0; i< params->m; i++) penum->indexes[i] = 0; /* * Save stack depth for checking the correct number of values on stack * after the function, which is being sampled, is called. */ penum->o_stack_depth = ref_stack_count(&o_stack); /* * Note: As previously mentioned, we are putting some spare (unused) stack * space under the input values in case the function unbalances the stack. * It is possible for the function to pop or change values on the stack * outside of the input values. (This has been found to happen with some * proc sets from Adobe.) */ push(O_STACK_PAD); for (i = 0; i < O_STACK_PAD; i++) /* Set space = null */ make_null(op - i); /* Push everything on the estack */ esp += estack_storage; make_op_estack(esp - 2, finish_proc); /* Finish proc onto estack */ sample_proc = *pproc; /* Save function to be sampled */ make_istruct(esp, 0, penum); /* Color cube enumeration structure */ push_op_estack(sampled_data_sample); /* Start sampling data */ return o_push_estack; }
/* <int> .oserrorstring false */ static int zoserrorstring(i_ctx_t *i_ctx_p) { os_ptr op = osp; const char *str; int code; uint len; byte ch; check_type(*op, t_integer); str = gp_strerror((int)op->value.intval); if (str == 0 || (len = strlen(str)) == 0) { make_false(op); return 0; } check_ostack(1); code = string_to_ref(str, op, iimemory, ".oserrorstring"); if (code < 0) return code; /* Strip trailing end-of-line characters. */ while ((len = r_size(op)) != 0 && ((ch = op->value.bytes[--len]) == '\r' || ch == '\n') ) r_dec_size(op, 1); push(1); make_true(op); return 0; }
/* <file> .filename false */ static int zfilename(i_ctx_t *i_ctx_p) { os_ptr op = osp; stream *s; gs_const_string fname; byte *str; check_file(s, op); if (sfilename(s, &fname) < 0) { make_false(op); return 0; } check_ostack(1); str = ialloc_string(fname.size, "filename"); if (str == 0) return_error(e_VMerror); memcpy(str, fname.data, fname.size); push(1); /* can't fail */ make_const_string( op - 1 , a_all | imemory_space((const struct gs_ref_memory_s*) imemory), fname.size, str); make_true(op); return 0; }
/* Clean up by closing the file. */ static int execfile_cleanup(i_ctx_t *i_ctx_p) { check_ostack(1); *++osp = esp[2]; return zclosefile(i_ctx_p); }
/* <string> .libfile <string> false */ int /* exported for zsysvm.c */ zlibfile(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code; byte cname[DEFAULT_BUFFER_SIZE]; uint clen; gs_parsed_file_name_t pname; stream *s; gx_io_device *iodev_dflt; check_ostack(2); code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions, imemory); if (code < 0) return code; iodev_dflt = iodev_default(imemory); if (pname.iodev == NULL) pname.iodev = iodev_dflt; if (pname.iodev != iodev_dflt) { /* Non-OS devices don't have search paths (yet). */ code = zopen_file(i_ctx_p, &pname, "r", &s, imemory); if (code >= 0) { code = ssetfilename(s, op->value.const_bytes, r_size(op)); if (code < 0) { sclose(s); return_error(e_VMerror); } } if (code < 0) { push(1); make_false(op); return 0; } make_stream_file(op, s, "r"); } else { ref fref; code = lib_file_open(i_ctx_p->lib_path, imemory, i_ctx_p, pname.fname, pname.len, (char *)cname, sizeof(cname), &clen, &fref); if (code >= 0) { s = fptr(&fref); code = ssetfilename(s, cname, clen); if (code < 0) { sclose(s); return_error(e_VMerror); } } if (code < 0) { if (code == e_VMerror || code == e_invalidfileaccess) return code; push(1); make_false(op); return 0; } ref_assign(op, &fref); } push(1); make_true(op); return 0; }
/* Finish normally. */ static int execfile_finish(i_ctx_t *i_ctx_p) { check_ostack(1); esp -= 2; execfile_cleanup(i_ctx_p); return o_pop_estack; }
static int zwritecvp_at(i_ctx_t *i_ctx_p, os_ptr op, uint start, bool first) { stream *s; byte str[100]; /* arbitrary */ ref rstr; const byte *data = str; uint len; int code, status; check_write_file(s, op - 2); check_type(*op, t_integer); code = obj_cvp(op - 1, str, sizeof(str), &len, (int)op->value.intval, start, imemory, true); if (code == e_rangecheck) { code = obj_string_data(imemory, op - 1, &data, &len); if (len < start) return_error(e_rangecheck); data += start; len -= start; } if (code < 0) return code; r_set_size(&rstr, len); rstr.value.const_bytes = data; status = write_string(&rstr, s); switch (status) { default: return_error(e_ioerror); case 0: break; case INTC: case CALLC: len = start + len - r_size(&rstr); if (!first) --osp; /* pop(1) without affecting op */ return handle_write_status(i_ctx_p, status, op - 2, &len, zwritecvp_continue); } if (code == 1) { if (first) check_ostack(1); push_op_estack(zwritecvp_continue); if (first) push(1); make_int(osp, start + len); return o_push_estack; } if (first) /* zwritecvp */ pop(3); else /* zwritecvp_continue */ pop(4); return 0; }
int ztoken(i_ctx_t *i_ctx_p) { os_ptr op = osp; switch (r_type(op)) { default: return_op_typecheck(op); case t_file: { stream *s; scanner_state state; check_read_file(i_ctx_p, s, op); check_ostack(1); gs_scanner_init(&state, op); return token_continue(i_ctx_p, &state, true); } case t_string: { ref token; /* -1 is to remove the string operand in case of error. */ int orig_ostack_depth = ref_stack_count(&o_stack) - 1; int code; /* Don't pop the operand in case of invalidaccess. */ if (!r_has_attr(op, a_read)) return_error(e_invalidaccess); code = gs_scan_string_token(i_ctx_p, op, &token); switch (code) { case scan_EOF: /* no tokens */ make_false(op); return 0; default: if (code < 0) { /* * Clear anything that may have been left on the ostack, * including the string operand. */ if (orig_ostack_depth < ref_stack_count(&o_stack)) pop(ref_stack_count(&o_stack)- orig_ostack_depth); return code; } } push(2); op[-1] = token; make_true(op); return 0; } } }
/* <redproc> <greenproc> <blueproc> <grayproc> setcolortransfer - */ static int zsetcolortransfer(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code; check_proc(op[-3]); check_proc(op[-2]); check_proc(op[-1]); check_proc(*op); check_ostack(zcolor_remap_one_ostack * 4 - 4); check_estack(1 + zcolor_remap_one_estack * 4); istate->transfer_procs.red = op[-3]; istate->transfer_procs.green = op[-2]; istate->transfer_procs.blue = op[-1]; istate->transfer_procs.gray = *op; if ((code = gs_setcolortransfer_remap(igs, gs_mapped_transfer, gs_mapped_transfer, gs_mapped_transfer, gs_mapped_transfer, false)) < 0 ) return code; /* Use osp rather than op here, because zcolor_remap_one pushes. */ pop(4); push_op_estack(zcolor_reset_transfer); if ((code = zcolor_remap_one(i_ctx_p, &istate->transfer_procs.red, igs->set_transfer.red, igs, zcolor_remap_one_finish)) < 0 || (code = zcolor_remap_one(i_ctx_p, &istate->transfer_procs.green, igs->set_transfer.green, igs, zcolor_remap_one_finish)) < 0 || (code = zcolor_remap_one(i_ctx_p, &istate->transfer_procs.blue, igs->set_transfer.blue, igs, zcolor_remap_one_finish)) < 0 || (code = zcolor_remap_one(i_ctx_p, &istate->transfer_procs.gray, igs->set_transfer.gray, igs, zcolor_remap_one_finish)) < 0 ) return code; return o_push_estack; }
/* <proc> setblackgeneration - */ static int zsetblackgeneration(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code; check_proc(*op); check_ostack(zcolor_remap_one_ostack - 1); check_estack(1 + zcolor_remap_one_estack); code = gs_setblackgeneration_remap(igs, gs_mapped_transfer, false); if (code < 0) return code; istate->black_generation = *op; pop(1); push_op_estack(zcolor_remap_color); return zcolor_remap_one(i_ctx_p, &istate->black_generation, igs->black_generation, igs, zcolor_remap_one_finish); }
/* <proc> setundercolorremoval - */ static int zsetundercolorremoval(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code; check_proc(*op); check_ostack(zcolor_remap_one_ostack - 1); check_estack(1 + zcolor_remap_one_estack); code = gs_setundercolorremoval_remap(igs, gs_mapped_transfer, false); if (code < 0) return code; istate->undercolor_removal = *op; pop(1); push_op_estack(zcolor_remap_color); return zcolor_remap_one(i_ctx_p, &istate->undercolor_removal, igs->undercolor_removal, igs, zcolor_remap_one_signed_finish); }
/* Get the value of a single parameter to the stack, or signal an error. */ static int currentparam1(i_ctx_t *i_ctx_p, const param_set * pset) { os_ptr op = osp; ref sref; int code; check_type(*op, t_name); check_ostack(2); name_string_ref(imemory, (const ref *)op, &sref); code = current_param_list(i_ctx_p, pset, &sref); if (code < 0) return code; if (osp == op) return_error(gs_error_undefined); /* We know osp == op + 2. */ ref_assign(op, op + 2); pop(2); return code; }
static int path_continue(i_ctx_t *i_ctx_p) { gs_path_enum *penum = r_ptr(esp, gs_path_enum); gs_point ppts[3]; int code; /* Make sure we have room on the o-stack for the worst case */ /* before we enumerate the next path element. */ check_ostack(6); /* 3 points for curveto */ code = gs_path_enum_next(penum, ppts); switch (code) { case 0: /* all done */ esp -= 6; path_cleanup(i_ctx_p); return o_pop_estack; default: /* error */ return code; case gs_pe_moveto: esp[2] = esp[-4]; /* moveto proc */ pf_push(i_ctx_p, ppts, 1); break; case gs_pe_lineto: esp[2] = esp[-3]; /* lineto proc */ pf_push(i_ctx_p, ppts, 1); break; case gs_pe_curveto: esp[2] = esp[-2]; /* curveto proc */ pf_push(i_ctx_p, ppts, 3); break; case gs_pe_closepath: esp[2] = esp[-1]; /* closepath proc */ break; } push_op_estack(path_continue); ++esp; /* include pushed procedure */ return o_push_estack; }
/* the stacks would get restored in case of an error. */ static int zstop(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint count = count_to_stopped(i_ctx_p, 1L); if (count) { /* * If there are any t_oparrays on the e-stack, they will pop * any new items from the o-stack. Wait to push the 'true' * until we have run all the unwind procedures. */ check_ostack(2); pop_estack(i_ctx_p, count); op = osp; push(1); make_true(op); return o_pop_estack; } /* No mark, quit. (per Adobe documentation) */ push(2); return unmatched_exit(op, zstop); }
/* - .typenames <name1|null> ... <nameN|null> */ static int ztypenames(i_ctx_t *i_ctx_p) { os_ptr op = osp; static const char *const tnames[] = { REF_TYPE_NAME_STRINGS }; int i; check_ostack(t_next_index); for (i = 0; i < t_next_index; i++) { ref *const rtnp = op + 1 + i; if (i >= countof(tnames) || tnames[i] == 0) make_null(rtnp); else { int code = name_enter_string(imemory, tnames[i], rtnp); if (code < 0) return code; r_set_attrs(rtnp, a_executable); } } osp += t_next_index; return 0; }
static int zsethalftone5(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint count; gs_halftone_component *phtc; gs_halftone_component *pc; int code = 0; int j; gs_halftone *pht; gx_device_halftone *pdht; ref sprocs[GS_CLIENT_COLOR_MAX_COMPONENTS + 1]; ref tprocs[GS_CLIENT_COLOR_MAX_COMPONENTS + 1]; gs_memory_t *mem; uint edepth = ref_stack_count(&e_stack); int npop = 2; int dict_enum = dict_first(op); ref rvalue[2]; int cname, colorant_number; byte * pname; uint name_size; int halftonetype, type = 0; gs_state *pgs = igs; int space_index = r_space_index(op - 1); mem = (gs_memory_t *) idmemory->spaces_indexed[space_index]; check_type(*op, t_dictionary); check_dict_read(*op); check_type(op[-1], t_dictionary); check_dict_read(op[-1]); /* * We think that Type 2 and Type 4 halftones, like * screens set by setcolorscreen, adapt automatically to * the device color space, so we need to mark them * with a different internal halftone type. */ dict_int_param(op - 1, "HalftoneType", 1, 5, 0, &type); halftonetype = (type == 2 || type == 4) ? ht_type_multiple_colorscreen : ht_type_multiple; /* Count how many components that we will actually use. */ for (count = 0; ;) { bool have_default = false; /* Move to next element in the dictionary */ if ((dict_enum = dict_next(op, dict_enum, rvalue)) == -1) break; /* * Verify that we have a valid component. We may have a * /HalfToneType entry. */ if (!r_has_type(&rvalue[1], t_dictionary)) continue; /* Get the name of the component verify that we will use it. */ cname = name_index(mem, &rvalue[0]); code = gs_get_colorname_string(mem, cname, &pname, &name_size); if (code < 0) break; colorant_number = gs_cname_to_colorant_number(pgs, pname, name_size, halftonetype); if (colorant_number < 0) continue; else if (colorant_number == GX_DEVICE_COLOR_MAX_COMPONENTS) { /* If here then we have the "Default" component */ if (have_default) return_error(e_rangecheck); have_default = true; } count++; /* * Check to see if we have already reached the legal number of * components. */ if (count > GS_CLIENT_COLOR_MAX_COMPONENTS + 1) { code = gs_note_error(e_rangecheck); break; } } check_estack(5); /* for sampling Type 1 screens */ refset_null(sprocs, count); refset_null(tprocs, count); rc_alloc_struct_0(pht, gs_halftone, &st_halftone, imemory, pht = 0, ".sethalftone5"); phtc = gs_alloc_struct_array(mem, count, gs_halftone_component, &st_ht_component_element, ".sethalftone5"); rc_alloc_struct_0(pdht, gx_device_halftone, &st_device_halftone, imemory, pdht = 0, ".sethalftone5"); if (pht == 0 || phtc == 0 || pdht == 0) { j = 0; /* Quiet the compiler: gs_note_error isn't necessarily identity, so j could be left ununitialized. */ code = gs_note_error(e_VMerror); } else { dict_enum = dict_first(op); for (j = 0, pc = phtc; ;) { int type; /* Move to next element in the dictionary */ if ((dict_enum = dict_next(op, dict_enum, rvalue)) == -1) break; /* * Verify that we have a valid component. We may have a * /HalfToneType entry. */ if (!r_has_type(&rvalue[1], t_dictionary)) continue; /* Get the name of the component */ cname = name_index(mem, &rvalue[0]); code = gs_get_colorname_string(mem, cname, &pname, &name_size); if (code < 0) break; colorant_number = gs_cname_to_colorant_number(pgs, pname, name_size, halftonetype); if (colorant_number < 0) continue; /* Do not use this component */ pc->cname = cname; pc->comp_number = colorant_number; /* Now process the component dictionary */ check_dict_read(rvalue[1]); if (dict_int_param(&rvalue[1], "HalftoneType", 1, 7, 0, &type) < 0) { code = gs_note_error(e_typecheck); break; } switch (type) { default: code = gs_note_error(e_rangecheck); break; case 1: code = dict_spot_params(&rvalue[1], &pc->params.spot, sprocs + j, tprocs + j); pc->params.spot.screen.spot_function = spot1_dummy; pc->type = ht_type_spot; break; case 3: code = dict_threshold_params(&rvalue[1], &pc->params.threshold, tprocs + j); pc->type = ht_type_threshold; break; case 7: code = dict_threshold2_params(&rvalue[1], &pc->params.threshold2, tprocs + j, imemory); pc->type = ht_type_threshold2; break; } if (code < 0) break; pc++; j++; } } if (code >= 0) { pht->type = halftonetype; pht->params.multiple.components = phtc; pht->params.multiple.num_comp = j; pht->params.multiple.get_colorname_string = gs_get_colorname_string; code = gs_sethalftone_prepare(igs, pht, pdht); } if (code >= 0) { /* * Put the actual frequency and angle in the spot function component dictionaries. */ dict_enum = dict_first(op); for (pc = phtc; ; ) { /* Move to next element in the dictionary */ if ((dict_enum = dict_next(op, dict_enum, rvalue)) == -1) break; /* Verify that we have a valid component */ if (!r_has_type(&rvalue[1], t_dictionary)) continue; /* Get the name of the component and verify that we will use it. */ cname = name_index(mem, &rvalue[0]); code = gs_get_colorname_string(mem, cname, &pname, &name_size); if (code < 0) break; colorant_number = gs_cname_to_colorant_number(pgs, pname, name_size, halftonetype); if (colorant_number < 0) continue; if (pc->type == ht_type_spot) { code = dict_spot_results(i_ctx_p, &rvalue[1], &pc->params.spot); if (code < 0) break; } pc++; } } if (code >= 0) { /* * Schedule the sampling of any Type 1 screens, * and any (Type 1 or Type 3) TransferFunctions. * Save the stack depths in case we have to back out. */ uint odepth = ref_stack_count(&o_stack); ref odict, odict5; odict = op[-1]; odict5 = *op; pop(2); op = osp; esp += 5; make_mark_estack(esp - 4, es_other, sethalftone_cleanup); esp[-3] = odict; make_istruct(esp - 2, 0, pht); make_istruct(esp - 1, 0, pdht); make_op_estack(esp, sethalftone_finish); for (j = 0; j < count; j++) { gx_ht_order *porder = NULL; if (pdht->components == 0) porder = &pdht->order; else { /* Find the component in pdht that matches component j in the pht; gs_sethalftone_prepare() may permute these. */ int k; int comp_number = phtc[j].comp_number; for (k = 0; k < count; k++) { if (pdht->components[k].comp_number == comp_number) { porder = &pdht->components[k].corder; break; } } } switch (phtc[j].type) { case ht_type_spot: code = zscreen_enum_init(i_ctx_p, porder, &phtc[j].params.spot.screen, &sprocs[j], 0, 0, space_index); if (code < 0) break; /* falls through */ case ht_type_threshold: if (!r_has_type(tprocs + j, t__invalid)) { /* Schedule TransferFunction sampling. */ /****** check_xstack IS WRONG ******/ check_ostack(zcolor_remap_one_ostack); check_estack(zcolor_remap_one_estack); code = zcolor_remap_one(i_ctx_p, tprocs + j, porder->transfer, igs, zcolor_remap_one_finish); op = osp; } break; default: /* not possible here, but to keep */ /* the compilers happy.... */ ; } if (code < 0) { /* Restore the stack. */ ref_stack_pop_to(&o_stack, odepth); ref_stack_pop_to(&e_stack, edepth); op = osp; op[-1] = odict; *op = odict5; break; } npop = 0; } } if (code < 0) { gs_free_object(mem, pdht, ".sethalftone5"); gs_free_object(mem, phtc, ".sethalftone5"); gs_free_object(mem, pht, ".sethalftone5"); return code; } pop(npop); return (ref_stack_count(&e_stack) > edepth ? o_push_estack : 0); }
/* <string> status false */ static int zstatus(i_ctx_t *i_ctx_p) { os_ptr op = osp; switch (r_type(op)) { case t_file: { stream *s; make_bool(op, (file_is_valid(s, op) ? 1 : 0)); } return 0; case t_string: { gs_parsed_file_name_t pname; struct stat fstat; int code = parse_file_name(op, &pname, i_ctx_p->LockFilePermissions); if (code < 0) return code; code = gs_terminate_file_name(&pname, imemory, "status"); if (code < 0) return code; code = (*pname.iodev->procs.file_status)(pname.iodev, pname.fname, &fstat); switch (code) { case 0: check_ostack(4); /* * Check to make sure that the file size fits into * a PostScript integer. (On some systems, long is * 32 bits, but file sizes are 64 bits.) */ push(4); make_int(op - 4, stat_blocks(&fstat)); make_int(op - 3, fstat.st_size); /* * We can't check the value simply by using ==, * because signed/unsigned == does the wrong thing. * Instead, since integer assignment only keeps the * bottom bits, we convert the values to double * and then test for equality. This handles all * cases of signed/unsigned or width mismatch. */ if ((double)op[-4].value.intval != (double)stat_blocks(&fstat) || (double)op[-3].value.intval != (double)fstat.st_size ) return_error(e_limitcheck); make_int(op - 2, fstat.st_mtime); make_int(op - 1, fstat.st_ctime); make_bool(op, 1); break; case e_undefinedfilename: make_bool(op, 0); code = 0; } gs_free_file_name(&pname, "status"); return code; } default: return_op_typecheck(op); } }
/* <name_string> <access_string> file <file> */ int /* exported for zsysvm.c */ zfile(i_ctx_t *i_ctx_p) { os_ptr op = osp; char file_access[4]; gs_parsed_file_name_t pname; int code = parse_file_access_string(op, file_access); stream *s; if (code < 0) return code; code = parse_file_name(op - 1, &pname, i_ctx_p->LockFilePermissions); if (code < 0) return code; /* * HACK: temporarily patch the current context pointer into the * state pointer for stdio-related devices. See ziodev.c for * more information. */ if (pname.iodev && pname.iodev->dtype == iodev_dtype_stdio) { bool statement = (strcmp(pname.iodev->dname, "%statementedit%") == 0); bool lineedit = (strcmp(pname.iodev->dname, "%lineedit%") == 0); if (pname.fname) return_error(e_invalidfileaccess); if (statement || lineedit) { /* These need special code to support callouts */ gx_io_device *indev = gs_findiodevice((const byte *)"%stdin", 6); stream *ins; if (strcmp(file_access, "r")) return_error(e_invalidfileaccess); indev->state = i_ctx_p; code = (indev->procs.open_device)(indev, file_access, &ins, imemory); indev->state = 0; if (code < 0) return code; check_ostack(2); push(2); make_stream_file(op - 3, ins, file_access); make_bool(op-2, statement); make_int(op-1, 0); make_string(op, icurrent_space, 0, NULL); return zfilelineedit(i_ctx_p); } pname.iodev->state = i_ctx_p; code = (*pname.iodev->procs.open_device)(pname.iodev, file_access, &s, imemory); pname.iodev->state = NULL; } else { if (pname.iodev == NULL) pname.iodev = iodev_default; code = zopen_file(i_ctx_p, &pname, file_access, &s, imemory); } if (code < 0) return code; code = ssetfilename(s, op[-1].value.const_bytes, r_size(op - 1)); if (code < 0) { sclose(s); return_error(e_VMerror); } make_stream_file(op - 1, s, file_access); pop(1); return code; }
/* <in1> ... <function_struct> %execfunction <out1> ... */ int zexecfunction(i_ctx_t *i_ctx_p) { os_ptr op = osp; /* * Since this operator's name begins with %, the name is not defined * in systemdict. The only place this operator can ever appear is * in the execute-only closure created by .buildfunction. * Therefore, in principle it is unnecessary to check the argument. * However, we do a little checking anyway just on general * principles. Note that since the argument may be an instance of * any subclass of gs_function_t, we currently have no way to check * its type. */ if (!r_is_struct(op) || !r_has_masked_attrs(op, a_executable | a_execute, a_executable | a_all) ) return_error(gs_error_typecheck); { gs_function_t *pfn = (gs_function_t *) op->value.pstruct; int m = pfn->params.m, n = pfn->params.n; int diff = n - (m + 1); if (diff > 0) check_ostack(diff); { float params[20]; /* arbitrary size, just to avoid allocs */ float *in; float *out; int code = 0; if (m + n <= countof(params)) { in = params; } else { in = (float *)ialloc_byte_array(m + n, sizeof(float), "%execfunction(in/out)"); if (in == 0) code = gs_note_error(gs_error_VMerror); } out = in + m; if (code < 0 || (code = float_params(op - 1, m, in)) < 0 || (code = gs_function_evaluate(pfn, in, out)) < 0 ) DO_NOTHING; else { if (diff > 0) push(diff); /* can't fail */ else if (diff < 0) { pop(-diff); op = osp; } code = make_floats(op + 1 - n, out, n); } if (in != params) ifree_object(in, "%execfunction(in)"); return code; } } }