~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/zcontrol.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: zcontrol.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: zcontrol.c 8250 2007-09-25 13:31:24Z giles $ */
15
15
/* Control operators */
16
16
#include "string_.h"
17
17
#include "ghost.h"
24
24
#include "store.h"
25
25
 
26
26
/* Forward references */
27
 
private int check_for_exec(const_os_ptr);
28
 
private int no_cleanup(i_ctx_t *);
29
 
private uint count_exec_stack(i_ctx_t *, bool);
30
 
private uint count_to_stopped(i_ctx_t *, long);
31
 
private int unmatched_exit(os_ptr, op_proc_t);
 
27
static int check_for_exec(const_os_ptr);
 
28
static int no_cleanup(i_ctx_t *);
 
29
static uint count_exec_stack(i_ctx_t *, bool);
 
30
static uint count_to_stopped(i_ctx_t *, long);
 
31
static int unmatched_exit(os_ptr, op_proc_t);
32
32
 
33
33
/* See the comment in opdef.h for an invariant which allows */
34
34
/* more efficient implementation of for, loop, and repeat. */
35
35
 
36
36
/* <[test0 body0 ...]> .cond - */
37
 
private int cond_continue(i_ctx_t *);
38
 
private int
 
37
static int cond_continue(i_ctx_t *);
 
38
static int
39
39
zcond(i_ctx_t *i_ctx_p)
40
40
{
41
41
    os_ptr op = osp;
58
58
    pop(1);
59
59
    return o_push_estack;
60
60
}
61
 
private int
 
61
static int
62
62
cond_continue(i_ctx_t *i_ctx_p)
63
63
{
64
64
    os_ptr op = osp;
119
119
}
120
120
 
121
121
/* <obj1> ... <objn> <n> .execn - */
122
 
private int
 
122
static int
123
123
zexecn(i_ctx_t *i_ctx_p)
124
124
{
125
125
    os_ptr op = osp;
156
156
}
157
157
 
158
158
/* <obj> superexec - */
159
 
private int end_superexec(i_ctx_t *);
160
 
private int
 
159
static int end_superexec(i_ctx_t *);
 
160
static int
161
161
zsuperexec(i_ctx_t *i_ctx_p)
162
162
{
163
163
    os_ptr op = osp;
176
176
    i_ctx_p->in_superexec++;
177
177
    return o_push_estack;
178
178
}
179
 
private int
 
179
static int
180
180
end_superexec(i_ctx_t *i_ctx_p)
181
181
{
182
182
    i_ctx_p->in_superexec--;
190
190
/*      After execution, the array will be placed on  the top of the    */
191
191
/*      operand stack (on top of any elemetns pushed by <executable>    */
192
192
/*      for both the normal case and for the error case.                */
193
 
private int end_runandhide(i_ctx_t *);
194
 
private int err_end_runandhide(i_ctx_t *);
195
 
private int
 
193
static int end_runandhide(i_ctx_t *);
 
194
static int err_end_runandhide(i_ctx_t *);
 
195
static int
196
196
zrunandhide(i_ctx_t *i_ctx_p)
197
197
{
198
198
    os_ptr op = osp;
218
218
    pop(2);
219
219
    return o_push_estack;
220
220
}
221
 
private int
 
221
static int
222
222
runandhide_restore_hidden(i_ctx_t *i_ctx_p, ref *obj, ref *attrs)
223
223
{
224
224
    os_ptr op = osp;
232
232
}
233
233
 
234
234
/* - %end_runandhide hiddenobject */
235
 
private int
 
235
static int
236
236
end_runandhide(i_ctx_t *i_ctx_p)
237
237
{
238
238
    int code;
244
244
}
245
245
 
246
246
/* restore hidden object for error returns */
247
 
private int
 
247
static int
248
248
err_end_runandhide(i_ctx_t *i_ctx_p)
249
249
{
250
250
    int code;
294
294
}
295
295
 
296
296
/* <init> <step> <limit> <proc> for - */
297
 
private int
 
297
static int
298
298
    for_pos_int_continue(i_ctx_t *),
299
299
    for_neg_int_continue(i_ctx_t *),
300
300
    for_real_continue(i_ctx_t *);
357
357
/* Execution stack contains mark, control variable, increment, */
358
358
/* limit, and procedure (procedure is topmost.) */
359
359
/* Continuation operator for positive integers. */
360
 
private int
 
360
static int
361
361
for_pos_int_continue(i_ctx_t *i_ctx_p)
362
362
{
363
363
    os_ptr op = osp;
376
376
    return o_push_estack;
377
377
}
378
378
/* Continuation operator for negative integers. */
379
 
private int
 
379
static int
380
380
for_neg_int_continue(i_ctx_t *i_ctx_p)
381
381
{
382
382
    os_ptr op = osp;
395
395
    return o_push_estack;
396
396
}
397
397
/* Continuation operator for reals. */
398
 
private int
 
398
static int
399
399
for_real_continue(i_ctx_t *i_ctx_p)
400
400
{
401
401
    os_ptr op = osp;
425
425
 *
426
426
 * NOTE: This computation must match the SAMPLE_LOOP_VALUE macro in gscie.h.
427
427
 */
428
 
private int for_samples_continue(i_ctx_t *);
 
428
static int for_samples_continue(i_ctx_t *);
429
429
/* <first> <count> <last> <proc> %for_samples - */
430
430
int
431
431
zfor_samples(i_ctx_t *i_ctx_p)
449
449
    return o_push_estack;
450
450
}
451
451
/* Continuation procedure */
452
 
private int
 
452
static int
453
453
for_samples_continue(i_ctx_t *i_ctx_p)
454
454
{
455
455
    os_ptr op = osp;
472
472
}
473
473
 
474
474
/* <int> <proc> repeat - */
475
 
private int repeat_continue(i_ctx_t *);
 
475
static int repeat_continue(i_ctx_t *);
476
476
int
477
477
zrepeat(i_ctx_t *i_ctx_p)
478
478
{
492
492
    return repeat_continue(i_ctx_p);
493
493
}
494
494
/* Continuation operator for repeat */
495
 
private int
 
495
static int
496
496
repeat_continue(i_ctx_t *i_ctx_p)
497
497
{
498
498
    es_ptr ep = esp;            /* saved proc */
508
508
}
509
509
 
510
510
/* <proc> loop */
511
 
private int loop_continue(i_ctx_t *);
512
 
private int
 
511
static int loop_continue(i_ctx_t *);
 
512
static int
513
513
zloop(i_ctx_t *i_ctx_p)
514
514
{
515
515
    os_ptr op = osp;
525
525
    return loop_continue(i_ctx_p);
526
526
}
527
527
/* Continuation operator for loop */
528
 
private int
 
528
static int
529
529
loop_continue(i_ctx_t *i_ctx_p)
530
530
{
531
531
    register es_ptr ep = esp;   /* saved proc */
536
536
}
537
537
 
538
538
/* - exit - */
539
 
private int
 
539
static int
540
540
zexit(i_ctx_t *i_ctx_p)
541
541
{
542
542
    os_ptr op = osp;
575
575
 
576
576
/* In the normal (no-error) case, pop the mask from the e-stack, */
577
577
/* and move the result to the o-stack. */
578
 
private int
 
578
static int
579
579
stopped_push(i_ctx_t *i_ctx_p)
580
580
{
581
581
    os_ptr op = osp;
590
590
/* Equivalent to true 1 .stop. */
591
591
/* This is implemented in C because if were a pseudo-operator, */
592
592
/* the stacks would get restored in case of an error. */
593
 
private int
 
593
static int
594
594
zstop(i_ctx_t *i_ctx_p)
595
595
{
596
596
    os_ptr op = osp;
615
615
}
616
616
 
617
617
/* <result> <mask> .stop - */
618
 
private int
 
618
static int
619
619
zzstop(i_ctx_t *i_ctx_p)
620
620
{
621
621
    os_ptr op = osp;
648
648
/* Equivalent to false 1 .stopped. */
649
649
/* This is implemented in C because if were a pseudo-operator, */
650
650
/* the stacks would get restored in case of an error. */
651
 
private int
 
651
static int
652
652
zstopped(i_ctx_t *i_ctx_p)
653
653
{
654
654
    os_ptr op = osp;
668
668
}
669
669
 
670
670
/* <obj> <result> <mask> .stopped <result> */
671
 
private int
 
671
static int
672
672
zzstopped(i_ctx_t *i_ctx_p)
673
673
{
674
674
    os_ptr op = osp;
688
688
 
689
689
/* <mask> .instopped false */
690
690
/* <mask> .instopped <result> true */
691
 
private int
 
691
static int
692
692
zinstopped(i_ctx_t *i_ctx_p)
693
693
{
694
694
    os_ptr op = osp;
708
708
/* <include_marks> .countexecstack <int> */
709
709
/* - countexecstack <int> */
710
710
/* countexecstack is an operator solely for the sake of the Genoa tests. */
711
 
private int
 
711
static int
712
712
zcountexecstack(i_ctx_t *i_ctx_p)
713
713
{
714
714
    os_ptr op = osp;
717
717
    make_int(op, count_exec_stack(i_ctx_p, false));
718
718
    return 0;
719
719
}
720
 
private int
 
720
static int
721
721
zcountexecstack1(i_ctx_t *i_ctx_p)
722
722
{
723
723
    os_ptr op = osp;
730
730
/* <array> <include_marks> .execstack <subarray> */
731
731
/* <array> execstack <subarray> */
732
732
/* execstack is an operator solely for the sake of the Genoa tests. */
733
 
private int execstack_continue(i_ctx_t *);
734
 
private int execstack2_continue(i_ctx_t *);
735
 
private int
 
733
static int execstack_continue(i_ctx_t *);
 
734
static int execstack2_continue(i_ctx_t *);
 
735
static int
736
736
push_execstack(i_ctx_t *i_ctx_p, os_ptr op1, bool include_marks,
737
737
               op_proc_t cont)
738
738
{
765
765
    push_op_estack(cont);
766
766
    return o_push_estack;
767
767
}
768
 
private int
 
768
static int
769
769
zexecstack(i_ctx_t *i_ctx_p)
770
770
{
771
771
    os_ptr op = osp;
772
772
 
773
773
    return push_execstack(i_ctx_p, op, false, execstack_continue);
774
774
}
775
 
private int
 
775
static int
776
776
zexecstack2(i_ctx_t *i_ctx_p)
777
777
{
778
778
    os_ptr op = osp;
782
782
}
783
783
/* Continuation operator to do the actual transfer. */
784
784
/* r_size(op1) was set just above. */
785
 
private int
 
785
static int
786
786
do_execstack(i_ctx_t *i_ctx_p, bool include_marks, os_ptr op1)
787
787
{
788
788
    os_ptr op = osp;
831
831
    pop(op - op1);
832
832
    return 0;
833
833
}
834
 
private int
 
834
static int
835
835
execstack_continue(i_ctx_t *i_ctx_p)
836
836
{
837
837
    os_ptr op = osp;
838
838
 
839
839
    return do_execstack(i_ctx_p, false, op);
840
840
}
841
 
private int
 
841
static int
842
842
execstack2_continue(i_ctx_t *i_ctx_p)
843
843
{
844
844
    os_ptr op = osp;
847
847
}
848
848
 
849
849
/* - .needinput - */
850
 
private int
 
850
static int
851
851
zneedinput(i_ctx_t *i_ctx_p)
852
852
{
853
853
    return e_NeedInput;         /* interpreter will exit to caller */
854
854
}
855
855
 
856
856
/* <obj> <int> .quit - */
857
 
private int
 
857
static int
858
858
zquit(i_ctx_t *i_ctx_p)
859
859
{
860
860
    os_ptr op = osp;
865
865
}
866
866
 
867
867
/* - currentfile <file> */
868
 
private ref *zget_current_file(i_ctx_t *);
869
 
private int
 
868
static ref *zget_current_file(i_ctx_t *);
 
869
static int
870
870
zcurrentfile(i_ctx_t *i_ctx_p)
871
871
{
872
872
    os_ptr op = osp;
899
899
    return 0;
900
900
}
901
901
/* Get the current file from which the interpreter is reading. */
902
 
private ref *
 
902
static ref *
903
903
zget_current_file(i_ctx_t *i_ctx_p)
904
904
{
905
905
    ref_stack_enum_t rsenum;
977
977
 * interpreter to catch them, so that we can signal the error with the
978
978
 * object still on the operand stack.
979
979
 */
980
 
private bool
 
980
static bool
981
981
check_for_exec(const_os_ptr op)
982
982
{
983
983
    if (!r_has_attr(op, a_execute) && /* only true if noaccess */
990
990
}
991
991
 
992
992
/* Vacuous cleanup routine */
993
 
private int
 
993
static int
994
994
no_cleanup(i_ctx_t *i_ctx_p)
995
995
{
996
996
    return 0;
1000
1000
 * Count the number of elements on the exec stack, with or without
1001
1001
 * the normally invisible elements (*op is a Boolean that indicates this).
1002
1002
 */
1003
 
private uint
 
1003
static uint
1004
1004
count_exec_stack(i_ctx_t *i_ctx_p, bool include_marks)
1005
1005
{
1006
1006
    uint count = ref_stack_count(&e_stack);
1021
1021
 * mark on the e-stack with a given mask.  Return 0 if there is no 'stopped'
1022
1022
 * mark.
1023
1023
 */
1024
 
private uint
 
1024
static uint
1025
1025
count_to_stopped(i_ctx_t *i_ctx_p, long mask)
1026
1026
{
1027
1027
    ref_stack_enum_t rsenum;
1074
1074
 * enclosing control scope (loop or stopped).  The caller has already
1075
1075
 * ensured two free slots on the top of the o-stack.
1076
1076
 */
1077
 
private int
 
1077
static int
1078
1078
unmatched_exit(os_ptr op, op_proc_t opproc)
1079
1079
{
1080
1080
    make_oper(op - 1, 0, opproc);