home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!caen!destroyer!ubc-cs!hassan
- From: hassan@cs.ubc.ca (Moustafa M Hassan)
- Subject: Re: Postscript files
- Message-ID: <1992Aug29.015831.3441@cs.ubc.ca>
- Summary: Hack!
- Keywords: Hack!
- Sender: usenet@cs.ubc.ca (Usenet News)
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Date: Sat, 29 Aug 92 01:58:31 GMT
- Lines: 58
-
-
- If you just want to see what the file looks like before printing, use a
- ps viewer like gs or ghostscript (anonymous ftp to nic.funet.fi). If,
- however, you're at a vt10* terminal or something else with no graphics
- capabilities (or for some other reason you insist on seeing the unformatted
- text) you can use the following hack (it reads from stdin and writes to
- stdout):
-
- #include <stdio.h>
-
- void process(char *line)
- {
- short go=0;
- while(*line){
- if(*line=='(' && *(line-1)!='\\'){
- go=1;
- line++;
- }
- if(*line==')' && *(line-1)!='\\')
- go =0;
-
- if(!(*line=='\\' && (*(line+1)=='(' || *(line+1)==')') ))
- if(*line && go)
- putchar(*line);
- line++;
- }
- }
-
- int main(void)
- {
- char space[256],c[256], line[256];
- long i,j,k;
-
- while(fgets(line,256,stdin)){
- if(sscanf(line,"%ld%ld%s%s",&i,&j,space,c)!=4)
- continue;
- process(line);
-
- }
- exit(0);
- }
-
-
-
- It's not guaranteed to work; I've only tested it on a few files; besides,
- I don't know ps 8^). I just read through a couple ps files, and this
- worked. Anyhow, it does absolutely no formatting and looks really ugly, but
- if you want something better, you should stick with ps 8^).
-
-
- Hack, hack!
-
- ********************************************************************
- * Moustafa Hassan | *
- * hassan@cs.ubc.ca | Political correctness is a euphemism *
- * TEL/FAX: (604) 535-2826 | for intellectual stagnation. *
- ********************************************************************
-
-