/* ---------------------------------------------------------------------------- function: exit_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 154. ---------------------------------------------------------------------------- */ Bool exit_(ps_context_t *pscontext) { register OBJECT *o1 ; execStackSizeNotChanged = FALSE ; while ( ! isEmpty( executionstack )) { o1 = theTop( executionstack ) ; switch ( oType(*o1) ) { case OARRAY: /* This case used to be explicitly represented as the first if-branch. Presumably it was explicitly different to the default for efficiency reasons, but that seems a bit spurious now. */ pop( & executionstack ) ; break ; case ONOTHING: /* Represents a looping context if len non-zero */ if ( theLen(*o1)) { npop( theLen(*o1), & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case ONULL : switch ( theLen(*o1)) { case ISINTERPRETEREXIT: oInteger(*o1) = NAME_exit; return TRUE; case ISPATHFORALL : path_free_list(thePathOf(*(PATHFORALL *)oOther(*o1)), mm_pool_temp) ; free_forallpath(oOther(*o1)) ; npop( 5 , & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case OMARK : /* Represents a stopped mark */ return error_handler( INVALIDEXIT ) ; case OFILE : /* Represents a run object - if length set to special value */ currfileCache = NULL ; if ( IsRunFile( o1 )) return error_handler( INVALIDEXIT ) ; default: pop( & executionstack ) ; } } return quit_(pscontext) ; }
PRIVATE void getch() { char c; if (currentcolumn == linelength) { Again: currentcolumn = 0; linelength = 0; linenumber++; while ((c = getc(infile[ilevel])) != EOLN) { linbuf[linelength++] = c; if feof(infile[ilevel]) { ilevel--; D( printf("reset to level %d\n",ilevel); ) if (ilevel < 0) quit_(); } }
static Bool dothestop(ps_context_t *pscontext, Bool super) { execStackSizeNotChanged = FALSE ; while ( ! isEmpty( executionstack )) { register OBJECT *o1 = theTop(executionstack) ; int32 *tptr ; FILELIST *flptr ; switch ( oType(*o1) ) { case OMARK : /* Represents a stopped mark */ if ( ! super || theLen(*o1)) { mm_context_t *mmc = ps_core_context(pscontext)->mm_context; if ( theLen(*o1)) { allow_interrupt = FALSE; /* superstop disables interrupt */ clear_interrupts(); } /* Reset allocation cost after error handling. */ if ( mmc != NULL) /* this can run before MM init */ mm_set_allocation_cost(mmc, mm_cost_normal); pop( & executionstack ) ; return push( & tnewobj , & operandstack ) ; } pop( & executionstack ) ; break ; case ONULL : switch ( theLen(*o1)) { case ISINTERPRETEREXIT : /* indicate that we're in a stopped context by changing the object's value */ oInteger(*o1) = super ? NAME_superstop : NAME_stop ; return TRUE; case ISPATHFORALL : tptr = oOther(*o1) ; path_free_list(thePathOf(*(PATHFORALL *)tptr), mm_pool_temp) ; free_forallpath( tptr ) ; npop( 4 , & executionstack ) ; break ; } pop( & executionstack ) ; break ; case OFILE : /* Represents a run object - if length is special value */ currfileCache = NULL ; if ( IsRunFile ( o1 )) { flptr = oFile(*o1) ; if ( isIOpenFileFilter( o1 , flptr )) (void)(*theIMyCloseFile( flptr ))( flptr, CLOSE_EXPLICIT ) ; } pop( & executionstack ) ; break ; default: pop( & executionstack ) ; } } return quit_(pscontext) ; }