home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnurecod.zip / lat1ltex.c < prev    next >
C/C++ Source or Header  |  1994-10-11  |  6KB  |  163 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #include "recode.h"
  21.  
  22. struct translation
  23.   {
  24.     int code;            /* code being translated */
  25.     const char *string;        /* translation string */
  26.   };
  27.  
  28. static struct translation const diacritic_translations [] =
  29.   {
  30.     {192, "\\`A"},        /* capital A with grave accent */
  31.     {193, "\\'A"},        /* capital A with acute accent */
  32.     {194, "\\^A"},        /* capital A with circumflex accent */
  33.     {195, "\\~A"},        /* capital A with tilde */
  34.     {196, "\\\"A"},        /* capital A diaeresis */
  35.     {197, "\\AA{}"},        /* capital A with ring above */
  36.     {198, "\\AE{}"},        /* capital diphthong A with E */
  37.     {199, "\\c{C}"},        /* capital C with cedilla */
  38.     {200, "\\`E"},        /* capital E with grave accent */
  39.     {201, "\\'E"},        /* capital E with acute accent */
  40.     {202, "\\^E"},        /* capital E with circumflex accent */
  41.     {203, "\\\"E"},        /* capital E with diaeresis */
  42.     {204, "\\`I"},        /* capital I with grave accent */
  43.     {205, "\\'I"},        /* capital I with acute accent */
  44.     {206, "\\^I"},        /* capital I with circumflex accent */
  45.     {207, "\\\"I"},        /* capital I with diaeresis */
  46.     {209, "\\~N"},        /* capital N with tilde */
  47.     {210, "\\`O"},        /* capital O with grave accent */
  48.     {211, "\\'O"},        /* capital O with acute accent */
  49.     {212, "\\^O"},        /* capital O with circumflex accent */
  50.     {213, "\\~O"},        /* capital O with tilde */
  51.     {214, "\\\"O"},        /* capital O with diaeresis */
  52.     {216, "\\O{}"},        /* capital O with oblique stroke */
  53.     {217, "\\`U"},        /* capital U with grave accent */
  54.     {218, "\\'U"},        /* capital U with acute accent */
  55.     {219, "\\^U"},        /* capital U with circumflex accent */
  56.     {220, "\\\"U"},        /* capital U with diaeresis */
  57.     {221, "\\'Y"},        /* capital Y with acute accent */
  58.     {223, "\\ss{}"},        /* small german sharp s */
  59.     {224, "\\`a"},        /* small a with grave accent */
  60.     {225, "\\'a"},        /* small a with acute accent */
  61.     {226, "\\^a"},        /* small a with circumflex accent */
  62.     {227, "\\~a"},        /* small a with tilde */
  63.     {228, "\\\"a"},        /* small a with diaeresis */
  64.     {229, "\\aa{}"},        /* small a with ring above */
  65.     {230, "\\ae{}"},        /* small diphthong a with e */
  66.     {231, "\\c{c}"},        /* small c with cedilla */
  67.     {232, "\\`e"},        /* small e with grave accent */
  68.     {233, "\\'e"},        /* small e with acute accent */
  69.     {234, "\\^e"},        /* small e with circumflex accent */
  70.     {235, "\\\"e"},        /* small e with diaeresis */
  71.     {236, "\\`{\\i}"},        /* small i with grave accent */
  72.     {237, "\\'{\\i}"},        /* small i with acute accent */
  73.     {238, "\\^{\\i}"},        /* small i with circumflex accent */
  74.     {239, "\\\"{\\i}"},        /* small i with diaeresis */
  75.     {241, "\\~n"},        /* small n with tilde */
  76.     {242, "\\`o"},        /* small o with grave accent */
  77.     {243, "\\'o"},        /* small o with acute accent */
  78.     {244, "\\^o"},        /* small o with circumflex accent */
  79.     {245, "\\~o"},        /* small o with tilde */
  80.     {246, "\\\"o"},        /* small o with diaeresis */
  81.     {248, "\\o{}"},        /* small o with oblique stroke */
  82.     {249, "\\`u"},        /* small u with grave accent */
  83.     {250, "\\'u"},        /* small u with acute accent */
  84.     {251, "\\^u"},        /* small u with circumflex accent */
  85.     {252, "\\\"u"},        /* small u with diaeresis */
  86.     {253, "\\'y"},        /* small y with acute accent */
  87.     {255, "\\\"y"},        /* small y with diaeresis */
  88.     {0, NULL}
  89.   };
  90.  
  91. static struct translation const other_translations [] =
  92.   {
  93.     { 35, "\\#"},
  94.     { 36, "\\$"},
  95.     { 37, "\\%"},
  96.     { 38, "\\&"},
  97.     { 92, "\\backslash{}"},
  98.     { 95, "\\_"},
  99.     {123, "\\{"},
  100.     {125, "\\}"},
  101.     {160, "~"},            /* no-break space */
  102.     {161, "!'"},        /* inverted exclamation mark */
  103.     {167, "\\S{}"},        /* paragraph sign, section sign */
  104.     {168, "\\\"{}"},        /* diaeresis */
  105.     {171, "``"},        /* left angle quotation mark */
  106.     {172, "\\neg{}"},        /* not sign */
  107.     {173, "\\-"},        /* soft hyphen */
  108.     {176, "\\mbox{$^\\circ$}"}, /* degree sign */
  109.     {177, "\\mbox{$\\pm$}"},    /* plus-minus sign */
  110.     {178, "\\mbox{$^2$}"},    /* superscript two */
  111.     {179, "\\mbox{$^3$}"},    /* superscript three */
  112.     {180, "\\'{}"},        /* acute accent */
  113.     {181, "\\mbox{$\\mu$}"},    /* small greek mu, micro sign */
  114.     {183, "\\cdotp"},        /* middle dot */
  115.     {184, "\\,{}"},        /* cedilla */
  116.     {185, "\\mbox{$^1$}"},    /* superscript one */
  117.     {187, "''"},        /* right angle quotation mark */
  118.     {188, "\\frac1/4{}"},    /* vulgar fraction one quarter */
  119.     {189, "\\frac1/2{}"},    /* vulgar fraction one half */
  120.     {190, "\\frac3/4{}"},    /* vulgar fraction three quarters */
  121.     {191, "?'"},        /* inverted question mark */
  122.     {0, NULL}
  123.   };
  124.  
  125. static void
  126. init_latin1_latex (STEP *step)
  127. {
  128.   char *pool;
  129.   const char **table;
  130.   int counter;
  131.   struct translation const *cursor;
  132.  
  133.   table = (const char **) xmalloc (256 * sizeof (char *) + 256);
  134.   pool = (char *) (table + 256);
  135.  
  136.   for (counter = 0; counter < 128; counter++)
  137.     {
  138.       table[counter] = pool;
  139.       *pool++ = counter;
  140.       *pool++ = '\0';
  141.     }
  142.   for (counter = 128; counter < 256; counter++)
  143.     table[counter] = NULL;
  144.   for (cursor = diacritic_translations; cursor->code; cursor++)
  145.     table[cursor->code] = cursor->string;
  146.  
  147.   if (!diacritics_only)
  148.     for (cursor = other_translations; cursor->code; cursor++)
  149.       table[cursor->code] = cursor->string;
  150.  
  151.   step->one_to_many = table;
  152. }
  153.  
  154. void
  155. module_latin1_latex (void)
  156. {
  157.   declare_step ("Latin-1", "LaTeX", ONE_TO_MANY, init_latin1_latex,
  158.         file_one_to_many);
  159.  
  160.   declare_alias ("TeX", "LaTeX");
  161.   declare_alias ("ltex", "LaTeX");
  162. }
  163.