home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10490 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.9 KB  |  71 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!caen!destroyer!ubc-cs!hassan
  3. From: hassan@cs.ubc.ca (Moustafa M Hassan)
  4. Subject: Re: Postscript files
  5. Message-ID: <1992Aug29.015831.3441@cs.ubc.ca>
  6. Summary: Hack!
  7. Keywords: Hack!
  8. Sender: usenet@cs.ubc.ca (Usenet News)
  9. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  10. Date: Sat, 29 Aug 92 01:58:31 GMT
  11. Lines: 58
  12.  
  13.  
  14. If you just want to see what the file looks like before printing, use a 
  15. ps viewer like gs or ghostscript (anonymous ftp to nic.funet.fi).  If, 
  16. however, you're at a vt10* terminal or something else with no graphics
  17. capabilities (or for some other reason you insist on seeing the unformatted
  18. text) you can use the following hack (it reads from stdin and writes to 
  19. stdout):
  20.  
  21. #include <stdio.h>
  22.  
  23. void process(char *line)
  24. {
  25.   short go=0;
  26.   while(*line){
  27.     if(*line=='(' && *(line-1)!='\\'){
  28.       go=1;
  29.       line++;
  30.     }
  31.     if(*line==')' && *(line-1)!='\\')
  32.       go =0;
  33.  
  34.     if(!(*line=='\\' && (*(line+1)=='(' || *(line+1)==')') ))
  35.       if(*line && go)
  36.     putchar(*line);
  37.     line++;
  38.   }
  39. }
  40.     
  41. int main(void)
  42. {
  43.   char space[256],c[256], line[256];
  44.   long i,j,k;
  45.  
  46.   while(fgets(line,256,stdin)){
  47.     if(sscanf(line,"%ld%ld%s%s",&i,&j,space,c)!=4)
  48.       continue;
  49.     process(line);
  50.  
  51.   }
  52.     exit(0);
  53. }
  54.  
  55.     
  56.     
  57. It's not guaranteed to work;  I've only tested it on a few files;  besides,
  58. I don't know ps 8^).  I just read through a couple ps files, and this 
  59. worked.  Anyhow, it does absolutely no formatting and looks really ugly, but
  60. if you want something better, you should stick with ps  8^).
  61.  
  62.  
  63. Hack, hack!
  64.  
  65. ********************************************************************
  66. * Moustafa Hassan          |                                       *
  67. * hassan@cs.ubc.ca         |  Political correctness is a euphemism *  
  68. * TEL/FAX: (604) 535-2826  |  for intellectual stagnation.         *
  69. ********************************************************************
  70.     
  71.