🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #124

Re: How do I recognize postscript from a file

#124
From: Peter Weingartner
Date: Tue, 03 Nov 1992 11:14
27 lines
2013 bytes
In article <1992Nov3.083527.20756@ugle.unit.no> helgeaa@colargol (Helge O. Aarstein) writes:

   We are trying to make a filter for the lp-command to reject 
   non-postscript files. But, there is a problem: 
	   How can I be sure that the file contains postscript-
	   code?

The simplest way is probably to check to see that the first two
characters of the file are '%!'.  Most programs that generate
PostScript code will at least those two characters at the begining.
The only time I have seen them left out is in hand-written code that
was just to test.  This method is used by the lpr I have used to
distinquish a PostScript file from another kind it might know how to
print.  Of course, '%!' is only a comment, so it can be left out
without affecting the execution of the program, so this method is not
fool-proof.  Since most programs include that code, though, it is
reasonably good (and simple!).  If you wanted to be really sure, I
suppose you could write a grammar checker that verified
PostScript-ness, but such a thing would be complicated and would need
to be updated with future revisions.  So, I recommend the '%!'.

--Peter
-- 
"The brilliant Cerebron, attacking the problem analytically, discovered three
 distinct kinds of dragon: the mythical, the chimerical, and the purely
 hypothetical. They were all, one might say, nonexistent, but each nonexistsed
 in an entirely different way." -- Standislaw Lem _Cyberiad_
Technical Details
Message-ID: <EWEINGAR.92Nov3111448@loanshark.cs.indiana.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!usenet.ins.cwru.edu!agate!ames!saimiri.primate.wisc.edu!sdd.hp.com!news.cs.indiana.edu!loanshark!eweingar
References: <1992Nov3.083527.20756@ugle.unit.no>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!usenet.ins.cwru.edu!agate!ames!saimiri.primate.wisc.edu!sdd.hp.com!news.cs.indiana.edu!loanshark!eweingar
From: eweingar@loanshark.cs.indiana.edu (Peter Weingartner)
Subject: Re: How do I recognize postscript from a file
In-Reply-To: helgeaa@colargol's message of 3 Nov 92 08:35:27 GMT
Message-ID: <EWEINGAR.92Nov3111448@loanshark.cs.indiana.edu>
Organization: Indiana University Computer Science
References: <1992Nov3.083527.20756@ugle.unit.no>
Date: 3 Nov 92 11:14:48
Lines: 27