home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume4 / nrtable / table.doc < prev    next >
Encoding:
Text File  |  1986-11-30  |  6.7 KB  |  177 lines

  1. DOCUMENTATION OF NROFF TAB FILE UTILITY
  2. -Bruce Townsend, Bell-Northern Research, March 1985
  3.  (utcs!bnr-vpa!bruce)
  4.  
  5.     This file contains some documentation for the table program.
  6. This program makes printer and terminal driver tables suitable for
  7. nroff. The development of this program was motivated by the lack of
  8. any other means to prepare custom nroff driver tables, for those
  9. systems which do not have the original source that prepared the driver
  10. tables (usually found in /usr/lib/term).
  11.     The format for the tables imbodied in this program was deduced
  12. from a "term" manual page, and by examining the contents of several
  13. existing tab files. Therefore, this program is not definitive in
  14. any sense, but is intended as a help for those who (like myself) do
  15. not have access to any formal tools that make these tab files.
  16.     Also it is possible that this program will require modification
  17. for systems where the size of an integer is not 32 bits. The system
  18. that this program was developed on is an HP9000 (System III) and the
  19. data sizes are:
  20.         long    32
  21.         int    32
  22.         short    16
  23.         char     8
  24. As I have not had access to different machines, I do not know whether
  25. certain data in the tab file is of int or long type, since that type
  26. is the same on our machine. I have assumed int type.
  27.  
  28. If your luck is really bad, I suppose it is possible that the format
  29. of the tab file is different across various implementations.
  30.  
  31. The format of the tab file is:
  32. Type    Name        Size on HP9000        Description
  33. ----    ----        --------------        -----------
  34. int    c_size        4 bytes    - The amount of character data in bytes
  35.                 that follows the t_stor structure. In fact
  36.                 the size of the file in bytes should be:
  37.                 c_size + sizeof (c_size) + sizeof (t_stor)
  38.                 (On our machine: c_size + 1004)
  39.  
  40. struct {        1000 bytes - This is the storage for the "t"
  41.     int bset;        structure with one change. All the elements
  42.     int breset;        of the t structure which were pointers to
  43.     int Hor;        strings are now integer indexes to one
  44.     int Vert;        large character array.
  45.     int Newline;
  46.     int Char;
  47.     int Em;
  48.     int Halfline;
  49.     int Adj;
  50.     int twinit;
  51.     int twrest;
  52.     int twnl;
  53.     int hlr;
  54.     int hlf;
  55.     int flr;
  56.     int bdon;
  57.     int bdoff;
  58.     int iton;
  59.     int itoff;
  60.     int ploton;
  61.     int plotoff;
  62.     int up;
  63.     int down;
  64.     int right;
  65.     int left;
  66.     int codetab[256-32];
  67.     int zzz;
  68. } t_stor;
  69.  
  70. char    array[c_size]    (variable size)- This is the storage for the strings
  71.                     pointed to by the indexes.
  72.  
  73.         How to Use the Table Program
  74.         ----------------------------
  75. Examine the "term" manual page which explains the purpose of each of
  76. the items in the "t" structure. Make a copy of the tabXXX.c program
  77. and edit it, replacing XXX with a suitable mnemonic. Initialize the
  78. t structure to the integer or character string values that are necessary
  79. for the terminal or printer in question. You have a high degree of
  80. flexibility here, and variable-width characters, overstrike combinations,
  81. etc are easy to implement.
  82.  
  83. The only catch here is determining which index of the t.codetab[] array
  84. corresponds to which nroff printable character. This information is not
  85. in the manual page. After some experimentation, I have made a table
  86. which list the characters I know about. The table has some holes in it,
  87. but is as complete as I can make it. If anyone has additions or
  88. corrections, please let me know. The table is found in the file
  89. charlist. Also, the comments in tabXXX.c should help.
  90.  
  91. WARNING: ALL CHARACTER STRINGS IN THE codetab[] array MUST be at
  92. least two characters in size, not counting the null terminator.
  93. The typical definition for a zero-width string which prints nothing
  94. is "\000\0" and NOT "". THIS IS VERY IMPORTANT, because it is
  95. necessary to allow the first byte of these strings to be zero
  96. in the case of zero-width strings that do print something.
  97. E.G. the string "\000^\b" is a zero-width "hat" character.
  98.  
  99. If the amount of char data is very large, you may need to increase the
  100. definition of C_SIZE in table.c. It is now set at 10000 characters.
  101. The table.c program will burp out a message to this effect if
  102. necessary.
  103.  
  104. The t.bset and t.breset flags will need definitions from either
  105. <termio.h> or <sgtty.h>. Include whichever is appropriate for your
  106. system in tabXXX.c.
  107.  
  108. After the tabXXX.c file has been edited, place it in the same
  109. directory as table.c and the Makefile, and compile the table with:
  110.     make tabXXX
  111.  
  112. This will compile and run a program which will in turn make the
  113. tab file. Move the tabfile to its destination directory (likely
  114. /usr/term/tab).
  115.  
  116. Run nroff as:
  117.     nroff -TXXX ...
  118. (for example):
  119.     nroff -T630P ...
  120.  
  121. Debugging is not easy.
  122. You can use the supplied program which takes a tab file (tabXXX) and
  123. makes a source file (tabXXX.c). The program is called elbat (reverse
  124. of table) Do this by:
  125.     elbat tabXXX > tabXXX.c
  126. and compare to your original tabXXX.c
  127.     Do this for tab files that you have already to check that
  128. the format is the same on your system as on mine.
  129.  
  130.  
  131.         The Table Program
  132.         -----------------
  133.  
  134. As mentioned before, this program is not to be considered a
  135. definitive one. It works for HP9000's as far as I can tell.
  136.  
  137. However, it does have the feature of compressing the supplied
  138. character data as much as possible. If one string is the tail of
  139. another (e.g. the strings abcdef and def), than only the largest
  140. string is stored. The smaller is indexed into the middle of the
  141. larger. Repeated strings (including the null string) are only stored
  142. once.
  143.  
  144. It should generate a tabfile very close to the size of the distributed
  145. tables. Check by using elbat on a distributed table, compile using
  146. the table utility, and compare the sizes. The character data will
  147. almost certainly be stored in a different order than in the
  148. distributed table, so "cmp -l" will find most bytes different.
  149. However, the nroff results using the two files should be identical.
  150.  
  151. The program has not been extensively tested. There may be bugs or
  152. misinformation. Let me know of any problems.
  153.  
  154. If the tab files produced by this program do not work at all on your
  155. system, then it may be that the data types for c_size, and
  156. t_stor.whatever are incorrect. (Long instead of int?) You can get an
  157. indication by looking at the first word (int or long?) of an
  158. existing tab file. This is the amount of char data stored in the
  159. file. Subtract it from the size of the file in bytes. The result
  160. will be the size of the t_stor structure plus the size of the c_size
  161. variable. The t_stor structure has 250 elements in it. If each is
  162. 4 bytes, as on our system, and the c_size variable is 4 bytes also,
  163. then the result of the previous subtraction should be 1004. If
  164. the sizeof(int) on your system is 16 bits, then the difference
  165. should be 502. If it is not, then perhaps the types (some or all)
  166. of c_size, and the elements in t_stor should be changed to reflect
  167. this.
  168.  
  169.             Good luck!
  170.  
  171. I can be reached at:
  172.  
  173.         utcs!bnr-vpa!bruce            (UUCP)
  174. or        (613) 726 - 3008            (Phone)
  175.         (Ottawa, Canada)
  176.  
  177.