home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 181_01 / filter32.doc < prev    next >
Text File  |  1979-12-31  |  4KB  |  86 lines

  1. FILTER.DOC 6/85 Ted Carnevale
  2.  
  3.      Although most of my programming is done under CP/M, I have 
  4. to work with several different machines that use different, 
  5. incompatible operating systems.  When it comes time to transfer 
  6. files between machines, there is no end of difficulty with extra 
  7. or missing line feeds, carriage returns, and cr-lf pairs.
  8.      This is a real pain to correct manually, so I wrote filter.c 
  9. to handle this drudgery for me.  It's written for the Software 
  10. Toolworks compiler, which runs under CP/M and is excellent except 
  11. that it does peculiar things to the cr-lf pair that marks end of 
  12. line in CP/M unless files are read and written in binary mode.  
  13. (Peculiar to CP/M programmers, that is, but perfectly logical and 
  14. reasonable under other operating systems that use a different 
  15. convention for marking end of line).  c80def.h contains some 
  16. #defines that are generally handy, including a few that are vital 
  17. to this program.  In case you don't have C80, filter.obj has the 
  18. compiled program.
  19.      Instructions for using filter are displayed if it is invoked 
  20. with incorrect or no command line arguments.  Basically, it is 
  21. invoked like so:
  22.  
  23.      filter infile outfile -opstring
  24.  
  25. where opstring tells filter what to do (-c to insert cr before 
  26. lf, -l to insert lf after cr, -n to insert cr lf after cr lf, -xb 
  27. to strip blanks, -xc to remove cr, -xl to remove lf, -xn to 
  28. convert cr lf cr lf to cr lf).  The opstring must be preceded by 
  29. a dash, but it may occur anywhere on the command line after 
  30. filter.  Incorrect options are ignored.  Several options can be 
  31. specified at one time, but watch out for unintended effects if 
  32. you do that!  The order in which things are done depends on the 
  33. order of statements in the switch clause in dowork().
  34.      The name of the source file is the very first non-opstring 
  35. on the command line after filter, and the name of the destination 
  36. file is the second non-opstring.  Only infile is mandatory--if 
  37. infile is not specified, filter prints a help message and exits.  
  38. If outfile is not specified, filter outputs to the console.  Note 
  39. that CP/M may do funny things if it encounters an isolated cr or 
  40. lf, so what you see on the console when using the c or l options 
  41. isn't necessarily what would go into the destination file.  For 
  42. example, 
  43.  
  44.      filter xxx -xc 
  45.  
  46. would simply show the contents of xxx on the console apparently 
  47. unchanged, but 
  48.  
  49.      filter xxx -xc yyy
  50.  
  51. would write yyy without carriage returns (as you would see 
  52. immediately if you "type yyy").
  53.      Beware of "text files" in which some characters have the 
  54. high bit set, e.g. files produced in WordStar's document mode.  
  55. The filter will fail to recognize these as printable characters, 
  56. and they will be stripped from the output.  It would be easy to 
  57. incorporate another command line option (flagged by the character 
  58. w, for example) that would allow you to mask out the high bit 
  59. when desired, or to just put it into the program as a permanent 
  60. feature if you prefer.  I didn't bother since pip's z option does 
  61. this for me if necessary.
  62.      Furthermore, I didn't bother to implement blank compression 
  63. into tabs, since C80 comes with a nice, small utility that does 
  64. that.  But if you really want to add it, go ahead.
  65.  
  66.  
  67.  
  68. Date      Version   Comments
  69. ----------------------------
  70. 6/30/85   2.1       First public release
  71. 7/6/85    2.2       Some programs output text files that are 
  72.                     terminated with a single ^Z, others fill the 
  73.                     last CP/M logical sector with ^Z's.  Version 
  74.                     2.1 couldn't handle source files that ended 
  75.                     in only one ^Z.  Version 2.2 can.
  76. 7/19/85   3.2       CP/M files that contain an exact multiple of 
  77.                     128 bytes do NOT end with ^Z.  Prior versions 
  78.                     would hang when they got past the last 
  79.                     character in such a file.  In this version, 
  80.                     xgetc() has been revised to correct this 
  81.                     problem.  Also, file input is buffered.  A 
  82.                     bigger buffer could be used (most economical 
  83.                     to do this dynamically with alloc()), which 
  84.                     would speed up access on floppy-based 
  85.                     hardware.
  86.