Back to index

tetex-bin  3.0
Functions | Variables
lang.c File Reference
#include "system.h"
#include "cmds.h"
#include "files.h"
#include "lang.h"
#include "makeinfo.h"
#include "xml.h"

Go to the source code of this file.

Functions

void cm_documentlanguage (void)
static int cm_search_iso_map (char *html)
void cm_documentencoding (void)
char * current_document_encoding (void)
static void add_encoded_char (char *html_str, char *info_str)
static void cm_accent_generic_html (int arg, int start, int end, char *html_supported, int single, int html_solo_standalone, char *html_solo)
static void cm_accent_generic_no_headers (int arg, int start, int end, int single, char *html_solo)
void cm_accent (int arg)
static void cm_accent_generic (int arg, int start, int end, char *html_supported, int single, int html_solo_standalone, char *html_solo)
void cm_accent_umlaut (int arg, int start, int end)
void cm_accent_acute (int arg, int start, int end)
void cm_accent_cedilla (int arg, int start, int end)
void cm_accent_hat (int arg, int start, int end)
void cm_accent_grave (int arg, int start, int end)
void cm_accent_tilde (int arg, int start, int end)
void cm_special_char (int arg)
void cm_dotless (int arg, int start, int end)

Variables

encoding_code_type document_encoding_code = no_encoding
language_code_type language_code = en
char * unknown_encoding = NULL
static iso_map_type us_ascii_map [] = {{NULL, 0, 0}}
static iso_map_type iso8859_1_map []
static iso_map_type iso8859_15_map []
static iso_map_type iso8859_2_map []
encoding_type encoding_table []
language_type language_table []

Function Documentation

static void add_encoded_char ( char *  html_str,
char *  info_str 
) [static]

Definition at line 700 of file lang.c.

{
  if (html)
    add_word_args ("&%s;", html_str);
  else if (xml)
    xml_insert_entity (html_str);
  else if (enable_encoding)
    {
      /* Look for HTML_STR in the current translation table.  */
      int rc = cm_search_iso_map (html_str);
      if (rc >= 0)
        /* We found it, add the real character.  */
        add_char (encoding_table[document_encoding_code].isotab[rc].bytecode);
      else
        { /* We didn't find it, that seems bad.  */
          warning (_("invalid encoded character `%s'"), html_str);
          add_word (info_str);
        }
    }
  else
    add_word (info_str);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cm_accent ( int  arg)

Definition at line 840 of file lang.c.

{
  int old_escape_html = escape_html;
  escape_html = 0;
  if (arg == START)
    {
      /* Must come first to avoid ambiguity with overdot.  */
      if (strcmp (command, "udotaccent") == 0)      /* underdot */
        add_char ('.');
    }
  else if (arg == END)
    {
      if (strcmp (command, "=") == 0)               /* macron */
        add_word ((html || xml) ? "¯" : "=");
      else if (strcmp (command, "H") == 0)          /* Hungarian umlaut */
        add_word ("''");
      else if (strcmp (command, "dotaccent") == 0)  /* overdot */
        add_meta_char ('.');
      else if (strcmp (command, "ringaccent") == 0) /* ring */
        add_char ('*');
      else if (strcmp (command, "tieaccent") == 0)  /* long tie */
        add_char ('[');
      else if (strcmp (command, "u") == 0)          /* breve */
        add_char ('(');
      else if (strcmp (command, "ubaraccent") == 0) /* underbar */
        add_char ('_');
      else if (strcmp (command, "v") == 0)          /* hacek/check */
        add_word ((html || xml) ? "&lt;" : "<");
    }
  escape_html = old_escape_html;
}

Here is the call graph for this function:

void cm_accent_acute ( int  arg,
int  start,
int  end 
)

Definition at line 913 of file lang.c.

{
  cm_accent_generic (arg, start, end, "AEIOUYaeiouy", '\'', 1, "acute");
}

Here is the call graph for this function:

void cm_accent_cedilla ( int  arg,
int  start,
int  end 
)

Definition at line 919 of file lang.c.

{
  cm_accent_generic (arg, start, end, "Cc", ',', 1, "cedil");
}

Here is the call graph for this function:

static void cm_accent_generic ( int  arg,
int  start,
int  end,
char *  html_supported,
int  single,
int  html_solo_standalone,
char *  html_solo 
) [static]

Definition at line 882 of file lang.c.

{
  /* Accentuating space characters makes no sense, so issue a warning.  */
  if (arg == START && isspace (input_text[input_text_offset]))
    warning ("Accent command `@%s' must not be followed by whitespace",
        command);

  if (html || xml)
    cm_accent_generic_html (arg, start, end, html_supported,
                            single, html_solo_standalone, html_solo);
  else if (no_headers)
    cm_accent_generic_no_headers (arg, start, end, single, html_solo);
  else if (arg == END)
    {
      if (enable_encoding)
        /* use 8-bit if available */
        cm_accent_generic_no_headers (arg, start, end, single, html_solo);
      else
        /* use regular character */
        add_char (single);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void cm_accent_generic_html ( int  arg,
int  start,
int  end,
char *  html_supported,
int  single,
int  html_solo_standalone,
char *  html_solo 
) [static]

Definition at line 728 of file lang.c.

{
  static int valid_html_accent; /* yikes */

  if (arg == START)
    { /* If HTML has good support for this character, use it.  */
      if (strchr (html_supported, curchar ()))
        { /* Yes; start with an ampersand.  The character itself
             will be added later in read_command (makeinfo.c).  */
         int saved_escape_html = escape_html;
         escape_html = 0;
          valid_html_accent = 1;
          add_char ('&');
         escape_html = saved_escape_html;
        }
      else
        { /* @dotless{i} is not listed in html_supported but HTML entities
            starting with `i' can be used, such as &icirc;.  */
         int save_input_text_offset = input_text_offset;
         char *accent_contents;

         get_until_in_braces ("\n", &accent_contents);
         canon_white (accent_contents);

         if (strstr (accent_contents, "@dotless{i"))
           {
             add_word_args ("&%c", accent_contents[9]);
             valid_html_accent = 1;
           }
         else
           {
             /* Search for @dotless{} wasn't successful, so rewind.  */
             input_text_offset = save_input_text_offset;
             valid_html_accent = 0;
             if (html_solo_standalone)
              { /* No special HTML support, so produce standalone char.  */
                if (xml)
                  xml_insert_entity (html_solo);
                else
                  add_word_args ("&%s;", html_solo);
              }
             else
              /* If the html_solo does not exist as standalone character
                 (namely &circ; &grave; &tilde;), then we use
                 the single character version instead.  */
              add_char (single);
           }

         free (accent_contents);
        }
    }
  else if (arg == END)
    { /* Only if we saw a valid_html_accent can we use the full
         HTML accent (umlaut, grave ...).  */
      if (valid_html_accent)
        {
          add_word (html_solo);
          add_char (';');
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void cm_accent_generic_no_headers ( int  arg,
int  start,
int  end,
int  single,
char *  html_solo 
) [static]

Definition at line 793 of file lang.c.

{
  if (arg == END)
    {
      if (no_encoding)
        add_char (single);
      else
        {
          int rc;
          char *buffer = xmalloc (1 + strlen (html_solo) + 1);
          buffer[0] = output_paragraph[end - 1];
          buffer[1] = 0;
          strcat (buffer, html_solo);

          rc = cm_search_iso_map (buffer);
          if (rc >= 0)
            /* A little bit tricky ;-)
               Here we replace the character which has
               been inserted in read_command with
               the value we have found in converting table
               Does there exist a better way to do this?  kama. */
            output_paragraph[end - 1]
              = encoding_table[document_encoding_code].isotab[rc].bytecode;
          else
            { /* If we didn't find a translation for this character,
                 put the single instead. E.g., &Xuml; does not exist so X&uml;
                 should be produced. */
              /* When the below warning is issued, an author has nothing
                 wrong in their document, let alone anything ``fixable''
                 on their side.  So it is commented out for now.  */
              /* warning (_("%s is an invalid ISO code, using %c"),
                       buffer, single); */
              add_char (single);
            }

          free (buffer);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cm_accent_grave ( int  arg,
int  start,
int  end 
)

Definition at line 931 of file lang.c.

{
  cm_accent_generic (arg, start, end, "AEIOUaeiou", '`', 0, "grave");
}

Here is the call graph for this function:

void cm_accent_hat ( int  arg,
int  start,
int  end 
)

Definition at line 925 of file lang.c.

{
  cm_accent_generic (arg, start, end, "AEIOUaeiou", '^', 0, "circ");
}

Here is the call graph for this function:

void cm_accent_tilde ( int  arg,
int  start,
int  end 
)

Definition at line 937 of file lang.c.

{
  cm_accent_generic (arg, start, end, "ANOano", '~', 0, "tilde");
}

Here is the call graph for this function:

void cm_accent_umlaut ( int  arg,
int  start,
int  end 
)

Definition at line 907 of file lang.c.

{
  cm_accent_generic (arg, start, end, "aouAOUEeIiy", '"', 1, "uml");
}

Here is the call graph for this function:

Definition at line 619 of file lang.c.

{
  if (!handling_delayed_writes)
    {
      encoding_code_type enc;
      char *enc_arg;

      /* This is ugly and probably needs to apply to other commands'
         argument parsing as well.  When we're doing @documentencoding,
         we're generally in the frontmatter of the document, and so the.
         expansion in html/xml/docbook would generally be the empty string.
         (Because those modes wait until the first normal text of the
         document to start outputting.)  The result would thus be a warning
         "unrecognized encoding name `'".  Sigh.  */
      int save_html = html;
      int save_xml = xml;

      html = 0;
      xml = 0;
      get_rest_of_line (1, &enc_arg);
      html = save_html;
      xml = save_xml;

      /* See if we have this encoding.  */
      for (enc = no_encoding+1; enc != last_encoding_code; enc++)
        {
          if (strcasecmp (enc_arg, encoding_table[enc].encname) == 0)
            {
              document_encoding_code = enc;
              break;
            }
        }

      /* If we didn't find this code, complain.  */
      if (enc == last_encoding_code)
        {
          warning (_("unrecognized encoding name `%s'"), enc_arg);
          /* Let the previous one go.  */
          if (unknown_encoding && *unknown_encoding)
            free (unknown_encoding);
          unknown_encoding = xstrdup (enc_arg);
        }

      else if (encoding_table[document_encoding_code].isotab == NULL)
        warning (_("sorry, encoding `%s' not supported"), enc_arg);

      free (enc_arg);
    }
  else if (xml)
    {
      char *encoding = current_document_encoding ();

      if (encoding && *encoding)
        {
          insert_string (" encoding=\"");
          insert_string (encoding);
          insert_string ("\"");
        }

      free (encoding);
    }
}

Here is the call graph for this function:

Definition at line 560 of file lang.c.

{
  language_code_type c;
  char *lang_arg;

  /* Read the line with the language code on it.  */
  get_rest_of_line (0, &lang_arg);

  /* Linear search is fine these days.  */
  for (c = aa; c != last_language_code; c++)
    {
      if (strcmp (lang_arg, language_table[c].abbrev) == 0)
        { /* Set current language code.  */
          language_code = c;
          break;
        }
    }

  /* If we didn't find this code, complain.  */
  if (c == last_language_code)
    warning (_("%s is not a valid ISO 639 language code"), lang_arg);

  if (xml && !docbook)
    {
      xml_insert_element_with_attribute (DOCUMENTLANGUAGE, START, "xml:lang=\"%s\"", lang_arg);
      xml_insert_element (DOCUMENTLANGUAGE, END);
    }

  free (lang_arg);
}

Here is the call graph for this function:

void cm_dotless ( int  arg,
int  start,
int  end 
)

Definition at line 1001 of file lang.c.

{
  if (arg == END)
    {
      xml_no_para --;
      if (output_paragraph[start] != 'i' && output_paragraph[start] != 'j')
        /* This error message isn't perfect if the argument is multiple
           characters, but it doesn't seem worth getting right.  */
        line_error (_("%c%s expects `i' or `j' as argument, not `%c'"),
                    COMMAND_PREFIX, command, output_paragraph[start]);

      else if (end - start != 1)
        line_error (_("%c%s expects a single character `i' or `j' as argument"),
                    COMMAND_PREFIX, command);

      /* We've already inserted the `i' or `j', so nothing to do.  */
    }
  else
    xml_no_para ++;
}

Here is the call graph for this function:

static int cm_search_iso_map ( char *  html) [static]

Definition at line 597 of file lang.c.

{
  int i;
  iso_map_type *iso = encoding_table[document_encoding_code].isotab;

  /* If no conversion table for this encoding, quit.  */
  if (!iso)
    return -1;

  for (i = 0; iso[i].html; i++)
    {
      if (strcmp (html, iso[i].html) == 0)
        return i;
    }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 946 of file lang.c.

{
  int old_escape_html = escape_html;
  escape_html = 0;

  if (arg == START)
    {
      if ((*command == 'L' || *command == 'l'
           || *command == 'O' || *command == 'o')
          && command[1] == 0)
        { /* Lslash lslash Oslash oslash.
             Lslash and lslash aren't supported in HTML.  */
          if (command[0] == 'O')
            add_encoded_char ("Oslash", "/O");
          else if (command[0] == 'o')
            add_encoded_char ("oslash", "/o");
          else
            add_word_args ("/%c", command[0]);
        }
      else if (strcmp (command, "exclamdown") == 0)
        add_encoded_char ("iexcl", "!");
      else if (strcmp (command, "questiondown") == 0)
        add_encoded_char ("iquest", "?");
      else if (strcmp (command, "euro") == 0)
        /* http://www.cs.tut.fi/~jkorpela/html/euro.html suggests that
           &euro; degrades best in old browsers.  */
        add_encoded_char ("euro", "Euro ");
      else if (strcmp (command, "pounds") == 0)
        add_encoded_char ("pound" , "#");
      else if (strcmp (command, "ordf") == 0)
        add_encoded_char ("ordf" , "a");
      else if (strcmp (command, "ordm") == 0)
        add_encoded_char ("ordm" , "o");
      else if (strcmp (command, "AE") == 0)
        add_encoded_char ("AElig", command);
      else if (strcmp (command, "ae") == 0)
        add_encoded_char ("aelig",  command);
      else if (strcmp (command, "OE") == 0)
        add_encoded_char ("OElig", command);
      else if (strcmp (command, "oe") == 0)
        add_encoded_char ("oelig", command);
      else if (strcmp (command, "AA") == 0)
        add_encoded_char ("Aring", command);
      else if (strcmp (command, "aa") == 0)
        add_encoded_char ("aring", command);
      else if (strcmp (command, "ss") == 0)
        add_encoded_char ("szlig", command);
      else
        line_error ("cm_special_char internal error: command=@%s", command);
    }
  escape_html = old_escape_html;
}

Here is the call graph for this function:

Definition at line 683 of file lang.c.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 31 of file lang.c.

Initial value:
 {
  { no_encoding, "(no encoding)", NULL },
  { US_ASCII,    "US-ASCII",    us_ascii_map },
  { ISO_8859_1,  "iso-8859-1",  (iso_map_type *) iso8859_1_map },
  { ISO_8859_2,  "iso-8859-2",  (iso_map_type *) iso8859_2_map },
  { ISO_8859_3,  "iso-8859-3",  NULL },
  { ISO_8859_4,  "iso-8859-4",  NULL },
  { ISO_8859_5,  "iso-8859-5",  NULL },
  { ISO_8859_6,  "iso-8859-6",  NULL },
  { ISO_8859_7,  "iso-8859-7",  NULL },
  { ISO_8859_8,  "iso-8859-8",  NULL },
  { ISO_8859_9,  "iso-8859-9",  NULL },
  { ISO_8859_10, "iso-8859-10", NULL },
  { ISO_8859_11, "iso-8859-11", NULL },
  { ISO_8859_12, "iso-8859-12", NULL },
  { ISO_8859_13, "iso-8859-13", NULL },
  { ISO_8859_14, "iso-8859-14", NULL },
  { ISO_8859_15, "iso-8859-15", (iso_map_type *) iso8859_15_map },
  { last_encoding_code, NULL, NULL }
}

Definition at line 387 of file lang.c.

Definition at line 164 of file lang.c.

Definition at line 44 of file lang.c.

Definition at line 287 of file lang.c.

Definition at line 34 of file lang.c.

Definition at line 409 of file lang.c.

Definition at line 37 of file lang.c.

iso_map_type us_ascii_map[] = {{NULL, 0, 0}} [static]

Definition at line 39 of file lang.c.