home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / texipf21.zip / texi2ipf / table.c < prev    next >
C/C++ Source or Header  |  1996-12-17  |  2KB  |  87 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.  * Modified by Martin "Herbert" Dietze, Email herbert@wiloyee.shnet.org
  30.  *
  31.  */
  32.  
  33. /*
  34.  * History:
  35.  *
  36.  * $Log: table.c,v $
  37.  * Revision 1.2  1996/12/17 15:14:22  herbert
  38.  * Only some cosmetic changes. The code looks still rather ugly to me :-)
  39.  *
  40.  * Revision 1.1.1.1  1996/12/02 12:10:01  herbert
  41.  * Texi2IPF 1.0
  42.  *
  43.  */
  44.  
  45. #include "texi2ipf.h"
  46. #include "table.h"
  47. #include <stdio.h>     /* just to get NULL */
  48. #include <string.h>
  49.  
  50. static char * id =
  51. "@(#)$Id: table.c,v 1.2 1996/12/17 15:14:22 herbert Exp $";
  52.  
  53. char indexmacro[] = "";
  54. char trquotes[] = "";
  55.  
  56. struct misccmds * cmds;
  57. struct tablerecd * table, * endoftable;
  58.  
  59. void initialize( void)
  60. {
  61.     long tablesize;
  62.  
  63.     table = mstable;
  64.     tablesize = sizeof mstable;
  65.     cmds = &mscmds;
  66.     endoftable = table + tablesize/sizeof table[0];
  67.     puts( cmds->init);
  68.     puts( trquotes);
  69. }
  70.  
  71.  
  72. /*
  73.  * lookup - linear search for texinfo command in table
  74.  * i used bsearch() for a while but it isnt portable and makes lint squawk.
  75.  */
  76.  
  77. struct tablerecd * lookup( char *token)
  78. {
  79.     struct tablerecd *tptr;
  80.  
  81.     for ( tptr = table; tptr < endoftable; ++tptr ) {
  82.         if ( STREQ( tptr->texstart, token))
  83.             return tptr;
  84.     }
  85.     return NULL;
  86. }
  87.