1
0

psextract 777 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/rc
  2. # extract pages $OLIST from postscript on stdin
  3. if(~ $OLIST '')
  4. exec cat
  5. awk '
  6. BEGIN {
  7. x=ENVIRON["OLIST"];
  8. gsub(/^-o/, "", x);
  9. na = split(x, a, ",");
  10. header = 1;
  11. goodpage = 0;
  12. }
  13. header || goodpage {
  14. print
  15. }
  16. /^%%EndSetup[ ]*$/ { header = 0; next }
  17. /^%%Page:/ {
  18. header = 0;
  19. p=$2+0;
  20. goodpage = 0;
  21. for(i=1; i<=na; i++){
  22. if(aa=match(a[i], "-")){
  23. low=substr(a[i], 1, RSTART);
  24. high=substr(a[i], RSTART+RLENGTH);
  25. if(low == "")
  26. low = 0;
  27. else
  28. low = low+0;
  29. if(high == "")
  30. high = 100000;
  31. else
  32. high = high+0;
  33. if(low <= p && p <= high){
  34. goodpage = 1;
  35. break;
  36. }
  37. }else{
  38. if(a[i] == p){
  39. goodpage = 1;
  40. break;
  41. }
  42. }
  43. }
  44. }
  45. /^%%EndPage[ ]*$/ {
  46. goodpage = 0;
  47. }
  48. /^%%Trailer[ ]*$/ {
  49. goodpage = 1;
  50. }
  51. '