home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / TEXI2IPF / TABLE.C < prev    next >
Text File  |  1993-02-14  |  2KB  |  71 lines

  1. /*
  2.  * table.c - set up translation tables for texi2roff
  3.  *
  4.  * texi2roff history:
  5.  *             Release 1.0a    August 1988
  6.  *             Release 2.0     January 1990
  7.  *
  8.  * Copyright 1988, 1989, 1990  Beverly A.Erlebacher
  9.  * erlebach@cs.toronto.edu    ...uunet!utai!erlebach
  10.  *
  11.  * texi2ipf history:
  12.  *             Release 1.0     February 1993
  13.  *
  14.  * Modified by Marcus Gröber, Fido 2:2402/61.1
  15.  *
  16.  *
  17.  * When adding more commands:
  18.  *
  19.  * - be sure that gettoken() can recognize not just the ending token
  20.  *   (texend) but also the end of the starting token (texstart) for
  21.  *   the command, if it doesnt already occur in a table.
  22.  *
  23.  * - keep the tables sorted
  24.  *
  25.  * - try to keep all troff strings here and in the table header files
  26.  *
  27.  * - strive diligently to keep the program table-driven
  28.  */
  29.  
  30. #include <stdio.h>     /* just to get NULL */
  31. #include "texi2ipf.h"
  32. #include "table.h"
  33.  
  34. char indexmacro[] = "";
  35. char trquotes[] = "";
  36.  
  37. struct misccmds * cmds;
  38. struct tablerecd * table, * endoftable;
  39.  
  40. void
  41. initialize()
  42. {
  43.     long tablesize;
  44.  
  45.     table = mstable;
  46.     tablesize = sizeof mstable;
  47.     cmds = &mscmds;
  48.     endoftable = table + tablesize/sizeof table[0];
  49.     puts(cmds->init);
  50.     puts(trquotes);
  51. }
  52.  
  53.  
  54. /*
  55.  * lookup - linear search for texinfo command in table
  56.  * i used bsearch() for a while but it isnt portable and makes lint squawk.
  57.  */
  58.  
  59. struct tablerecd *
  60. lookup(token)
  61. char *token;
  62. {
  63.     struct tablerecd *tptr;
  64.  
  65.     for (tptr = table; tptr < endoftable; ++tptr) {
  66.        if (STREQ(tptr->texstart, token))
  67.            return tptr;
  68.     }
  69.     return NULL;
  70. }
  71.