diff options
author | Akira TAGOH <akira@tagoh.org> | 2010-07-27 22:08:12 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2010-07-27 22:08:12 +0900 |
commit | 206fa845a48f2d6cda5f02265e37ea89334ae525 (patch) | |
tree | 7f7fde81b90ceca6c2fe464883bccd399f80fcbb /lib | |
parent | 931cc4e7ac0dff5906ec86cbc747a10ec0fa01e8 (diff) |
* lib/hg_init.ps (anchorsearch): defined.
(cvs): ditto.
(definefont): ditto.
(executive): ditto.
(findfont): ditto.
(floor): ditto.
(load): ditto.
(matrix): ditto.
(pstack): ditto.
(prompt): ditto.
(putinterval): ditto.
(quit): ditto.
(run): ditto.
(stack): ditto.
(start): ditto.
(store): ditto.
(undefinefont): ditto.
(version): ditto.
(=): ditto.
(==): ditto.
(.seterror): ditto.
(.defaulterrorhandler): ditto.
(handleerror): ditto.
(.printerror): ditto.
(/StandardEncoding): ditto.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hg_init.ps | 311 |
1 files changed, 311 insertions, 0 deletions
diff --git a/lib/hg_init.ps b/lib/hg_init.ps index 60e51c3..e67b1e2 100644 --- a/lib/hg_init.ps +++ b/lib/hg_init.ps @@ -129,6 +129,317 @@ systemdict /.statementedit known { } bind def } ifelse +%%% +%%% Level 1 operators +% string seek anchorsearch post match true | string false +/anchorsearch { + {1 index 3 1 roll} stopped { + $error /newerror get { + $error /errorname get /rangecheck eq { + $error /errorname /stackunderflow put + } if + stop + } if + } if + search { + length 0 eq { + 3 -1 roll pop true + } { + pop pop false + } ifelse + } { + pop false + } ifelse +} bind odef +% any -string- cvs -substring- +/cvs { + count 2 lt { + /cvs errordict /stackunderflow get exec + } if + dup type /stringtype ne { + /cvs errordict /typecheck get exec + } { + exch .stringcvs exch copy + } ifelse +} bind odef +% key font|cidfont definefont font|cidfont +/definefont { + .definefont +} bind odef +% - executive - +/executive { + { + { + {..statementedit} stopped { + % need to detect an empty line separately to take care of /undefinedfilename. + $error /newerror get { + $error /errorname get /undefinedfilename eq { + pop pop .clearerror .exit + } { + % we don't care of this error here. + stop + } ifelse + } if + } if + dup type /filetype eq {cvx exec} if + } stopped { + $error /newerror get { + errordict /handleerror get exec + .clearerror + } if + } if + } loop +} bind def +% key findfont -dict- +/findfont { + .findfont +} bind odef +% num floor num +/floor { + dup cvi + 1 index 1 index sub + 0 lt { + 1 sub + } if + exch type /realtype eq {cvr} if +} bind odef +% -key- load -value- +/load { + dup where { + exch get + } { + /load errordict /undefined get exec + } ifelse +} bind odef +% matrix -matrix- +/matrix { + 6 array identmatrix +} bind odef +% pstack - +/pstack { + 0 1 count 3 sub {index ==} for +} bind odef +% - prompt - +/prompt { + .promptmsg print flush +} bind odef +% -array- index -array- putinterval - +% -string- index -string- putinterval - +/putinterval { + dup length + 2 index add + 3 index length gt { + /putinterval cvx + errordict /rangecheck get exec + } if + {2 index 2 index 3 -1 roll put 1 add} forall + pop pop +} bind odef +% - quit - +/quit { + 0 .quit +} bind odef +% -string- run - +/run { + (r) file cvx exec +} bind odef +% stack - +/stack { + 0 1 count 3 sub {index =} for +} bind odef +% - start - +/start { + executive +} bind odef +% key value store - +/store { + 1 index where { + } { + currentdict + } ifelse + 3 1 roll put +} bind odef +% key undefinefont - +/undefinefont { + .undefinefont +} bind odef +% - version -string- +/version { + (1000) +} odef +% any = - +/= { + =only (\n) print +} bind odef +% any == - +/== { + ==only (\n) print +} bind odef + +%% Initialize error procedures +% <command> <error> .seterror - +/.seterror { + $error /newerror true put + $error exch /errorname exch put + $error exch /command exch put + $error /.isstop true put + $error /recordstacks known { + $error /recordstacks get + } { + true + } ifelse { + % record stacks + count copy count 2 idiv array astore $error /ostack 3 -1 roll put + countexecstack array execstack $error /estack 3 -1 roll % -dict- /estack -array- + % modify estack to make a correct stack when an error actually happened + dup length 1 sub 0 exch getinterval % -dict- /estack -array- + dup length array copy % -dict- /estack -array- + dup dup length 1 sub $error /command get put put + countdictstack array dictstack $error /dstack 3 -1 roll put + } if +} bind def +% <command> <error> .defaulterrorhandler - +/.defaulterrorhandler { + % enter the local allocation mode in advance to avoid /invalidaccess again. + false .setglobal + .seterror + stop +} bind def +% - handleerror - +/handleerror { + errordict /handleerror get exec +} bind odef +% - .printerror - +/.printerror { + % stacking $error and evaluate the value doesn't work. + % because the executable object may be in the dictionary. + % it will does into the estack directly then. + $error /newerror get { + (Error: ) print $error /errorname get ==only + ( in ) print $error /command get ==only + (\n) print + % save objects in current ostack + count array astore + $error /ostack known { + $error /ostack get dup length + (Operand Stack[) print =only (]:\n) print + {( ) print ==only} forall + (\n) print + } if + $error /estack known { + $error /estack get dup length + (Execution Stack[) print =only (]:\n) print + {( ) print ==only} forall + (\n) print + } if + $error /dstack known { + $error /dstack get dup length + (Dictionary stack[) print =only (]:\n) print + { + ( ) print + dup type /dicttype eq { + (--dict:) print + dup length ==only (/) print dup maxlength ==only + dup wcheck not { + ((ro)) print + } if + /gcheck where { + pop gcheck { + ((G)) + } { + ((L)) + } ifelse print + } { + pop + } ifelse (--) print + } { + ==only + } ifelse + } forall + (\n) print + } if + % restore objects + aload pop + } if +} bind def + +mark /dictfull /dictstackoverflow /dictstackunderflow /execstackoverflow +/interrupt /invalidaccess /invalidexit /invalidfileaccess /invalidfont +/invalidrestore /ioerror /limitcheck /nocurrentpoint /rangecheck +/stackoverflow /stackunderflow /syntaxerror /timeout /typecheck /undefined +/undefinedfilename /undefinedresult /unmatchedmark /unregistered /VMerror +counttomark { + dup [exch {.defaulterrorhandler} /exec load] cvx bind errordict 3 1 roll put +} repeat +cleartomark + +% create StandardEncoding vector table +/StandardEncoding [ + % \00x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \01x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \02x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \03x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \04x + /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright + % \05x + /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash + % \06x + /zero /one /two /three /four /five /six /seven + % \07x + /eight /nine /colon /semicolon /less /equal /greater /question + % \10x + /at /A /B /C /D /E /F /G + % \11x + /H /I /J /K /L /M /N /O + % \12x + /P /Q /R /S /T /U /V /W + % \13x + /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore + % \14x + /quoteleft /a /b /c /d /e /f /g + % \15x + /h /i /j /k /l /m /n /o + % \16x + /p /q /r /s /t /u /v /w + % \17x + /x /y /z /braceleft /bar /braceright /asciitilde /.notdef + % \20x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \21x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \22x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \23x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \24x + /.notdef /exclamdown /cent /sterling /fraction /yen /florin /section + % \25x + /currency /quotesingle /quotedblleft /guillemotleft /guilsingleft /guilsinglright /fi /fl + % \26x + /.notdef /endash /dagger /daggerdbl /periodcentered /.notdef /paragraph /bullet + % \27x + /.quotesinglbase /quotedblbase /quotedblright /guillemotright /ellipsis /perthousand /.notdef /questiondown + % \30x + /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent + % \31x + /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron + % \32x + /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \33x + /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef + % \34x + /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef + % \35x + /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef + % \36x + /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef + % \37x + /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef] def + % Initialize against current language level. (hg_init_l1.ps) (r) file cvx exec systemdict /languagelevel known { |