home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 280_01 / swtools.doc < prev    next >
INI File  |  1989-01-13  |  6KB  |  125 lines

  1. [SWTOOLS.DOC of JUGPDS Vol.52 & 53]
  2.  
  3.             Software Tools in Lattice C V3.1 & V20/V30/80186
  4.  
  5.  
  6.                        Original Version in BDS C 
  7.                                    by 
  8.                    Hakuou KATAYOSE (JUG-CP/M No.179)
  9.                     49-114 Kawauchi-Sanjuunin-machi, 
  10.                        Sendai, Miyagi 980, Japan
  11.                            Phone: 0222-61-3219
  12.  
  13.  
  14.                          Modified for Lattice C (80186/V20/V30) 
  15.                                    by
  16.                       Toshiya Ota (JUG-CP/M No.10)
  17.                     Sakae ko-po 205   5-19-6 Hosoda
  18.                 Katusika-ku Tokyo 124
  19.  
  20.                               Feb.10, 1987
  21.  
  22. 1. Introduction
  23.      Here  is  yet  another  version  of  Software  Tools  (Kernighan & 
  24. Plauger) in Lattice C V3.1J.  The original source programs in Ratfor have
  25. been translated into C. Also included are some utilities to compile and to
  26. demonstrate the application of the tools.
  27.  
  28. 2.  Programs from Software Tools
  29.     I have implemented almost every program in  Software Tools except for
  30. those in Chapter 6 "EDITING" and  Chapter 9 "A RATFOR-FORTRAN TRANSLATOR".
  31.  
  32. ------------------------------------------------------------------------
  33. Program Name           Description (Page of the original K&P book)
  34. ------------------------------------------------------------------------
  35. COUNT              (charcount +  linecount + wordcount) (p12,13,15)
  36. DETAB/ENTAB        Handling of TAB (p20,37)
  37. OVERSTRIK          Overstrike of a line (p40)
  38. COMPRESS/EXPAND    Compression and expansion of a text (p44,48)
  39. CRYPT0,CRYPT1      Encrypt of a text file. Note that a encrypt file may
  40.            contain EOF marks; 0X01A(control-Z).  CRYPT1 is to
  41.            handle a binary file, it lacks the pipe and I/O
  42.            redirection facilities of CRYPT0. I would recommend
  43.            CRYPT1 as the more reliable. 
  44. TRANSLIT           Character transliteration (p56)  
  45. COMPARE            Comparison of two files (p70,73)
  46. CONCAT0,COMCAT1    Concatenation of text files (p78)
  47. ARCHIVE            File archiver (p88)        
  48. MSORT,SORT         Sorting of a text file. MSORT can handle up to about
  49.            2000 lines or 30k bytes. SORT is for sorting with
  50.            merge.
  51. UNIQUE             Stripping adjacent duplicate lines (p125)
  52. KWIC/UNROT         Keyword in context index (p128,131)
  53. FRQNCY           Word frequency list for a document file (p126)
  54. FIND/CHANGE       Find (grep) and change patterns in text (p139,156)
  55. FORMAT           Text formatter (p234)
  56. MACRO           Expand macros with arguments (p270)
  57. ------------------------------------------------------------------------
  58.  
  59.      To compile and link the source programs described  above, you will
  60. need  to include some header files (stdio.h, ctype.h) and the  function 
  61. libraries TOOLSLB.LIB. [The source for all four is included in JUGPDS
  62.  Vols.52 and 53]
  63.  
  64.  
  65. 3. Some Notes on Translating Software Tools from Ratfor to Lattice C
  66.  
  67.      Since  Ratfor  is  a  preprocessor for  Fortran,   the  parameters 
  68. (arguments) for FUNCTIONs and SUBROUTINEs  are referenced by address -- 
  69. pointers in the C language.  You can not pass arguments by value unless
  70. you make appropriate changes to the C functions.
  71.  
  72.      The  next  point to watch is the difference of arrays.  Fortran 
  73. arrays start with element 1; C start at 0.  If you declare A(50), you 
  74. have the Ratfor array A(1)-A(50),  but A[0]-A[4] in C.  This difference
  75. is important when you specify  the limits for a loop counter.  
  76. Fortran-77  gives  greater  compatibility  because it allows  you  to 
  77. declare A(0:49).
  78.      Also note that the elements of multi-dimensional arrays are stored
  79. in different orders -- by column in Fortran, by row in C.
  80.  
  81.         Fortran ... A(1,1),A(2,1),A(3,1),...
  82.         C       ... A[0][0],A[0][1],A[0][2],...
  83.  
  84. So you have to exchange column and row for a two-dimensional array, if 
  85. you want to use C pointers.
  86.  
  87. 4. Another notes on Compiling/Using from T. Ota.
  88.  
  89. a) Library
  90.   All library functions is saparated from DEFF3.C and PAT.C (Original 
  91. Library Source file). Lattice C (or other MS-DOS C compilers) generate only
  92. 1 modules from 1 source file. So , if library functions compiled by 1 file,
  93. then Object library (menber of .LIB file) has many functions ,and if linked
  94. main routine and library , useless functions linked togather.
  95.  For that reason, I have saparated library functions to one by one.
  96.  
  97. b) 80186 option
  98.   Lattice C V3.1 can make the code for 80186. This mode generates 80186 
  99. object code far more efficiently (in terms of memory and speed). So, I 
  100. compiled allfunctions in both 8086 mode and 80186 mode.
  101.   TOOLEXEN.ARC contains all executable files (.EXE files) which was compiled 
  102. by 8086 mode. TOOLEXEV.ARC contains 80186 and V20/V30 executable files. You
  103. may choise either of them.
  104.   Similarly, TOOLSLBN.LIB contains 8086 mode functions, and TOOLSLBV.LIB 
  105. contains 80186 mode functions. You must copy either librariy to TOOLSLB.LIB
  106. for linking the programs.
  107.  
  108. c) Note on MSORT.EXE
  109.   MSORT.EXE uses much free memory. You must specify the stack size when
  110. you invoke the command.
  111.  (Exsample:  MSORT =9999 <infile >outfile)
  112.  
  113. [ Disk Editors comments:
  114.  The original of the source code of this disk is JUGPDS Vols.17 and 18. 
  115. That code has been written in BDS C. The present version is based on Lattice 
  116. C V3.1J. I tested the .EXE files on a NEC PC-9801E with V30. T.Ohta.
  117.  
  118.      Maynard Hogg (JUG-CP/M No.99) volunteered to improve this documen-
  119. tation.  Thank you Maynard.  Y.M. ]
  120.  
  121.             Written at 1987-02-08 02:39Z (GMT)
  122. ank you Maynard.  Y.M. ]
  123.  
  124.             Written at 1987-02-08 02:39Z (GMT)
  125.