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