Back to index

tetex-bin  3.0
Classes | Typedefs | Enumerations | Functions | Variables
insertion.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  istack_elt

Typedefs

typedef struct istack_elt INSERTION_ELT

Enumerations

enum  insertion_type {
  cartouche, copying, defcv, deffn,
  defivar, defmac, defmethod, defop,
  defopt, defspec, deftp, deftypecv,
  deftypefn, deftypefun, deftypeivar, deftypemethod,
  deftypeop, deftypevar, deftypevr, defun,
  defvar, defvr, detailmenu, direntry,
  display, documentdescription, enumerate, example,
  floatenv, flushleft, flushright, format,
  ftable, group, ifclear, ifdocbook,
  ifhtml, ifinfo, ifnotdocbook, ifnothtml,
  ifnotinfo, ifnotplaintext, ifnottex, ifnotxml,
  ifplaintext, ifset, iftex, ifxml,
  itemize, lisp, menu, multitable,
  quotation, rawdocbook, rawhtml, rawtex,
  rawxml, smalldisplay, smallexample, smallformat,
  smalllisp, verbatim, table, tex,
  vtable, titlepage, bad_type
}

Functions

void init_insertion_stack (void)
void command_name_condition (void)
void cm_ifdocbook (void)
void cm_ifnotdocbook (void)
void cm_docbook (int arg)
void cm_ifhtml (void)
void cm_ifnothtml (void)
void cm_html (int arg)
void cm_ifinfo (void)
void cm_ifnotinfo (void)
void cm_ifplaintext (void)
void cm_ifnotplaintext (void)
void cm_iftex (void)
void cm_ifnottex (void)
void cm_tex (void)
void cm_ifxml (void)
void cm_ifnotxml (void)
void cm_xml (int arg)
void handle_verbatim_environment (int find_end_verbatim)
void begin_insertion (enum insertion_type type)
void pop_insertion (void)
void discard_insertions (int specials_ok)
int is_in_insertion_of_type (int type)
int command_needs_braces (char *cmd)
enum insertion_type find_type_from_name (char *name)

Variables

int insertion_level
INSERTION_ELTinsertion_stack
int in_menu
int in_detailmenu
int had_menu_commentary
int in_paragraph
int headitem_flag
int after_headitem

Class Documentation

struct istack_elt

Definition at line 38 of file insertion.h.

Collaboration diagram for istack_elt:
Class Members
char * filename
int filling_enabled
int in_fixed_width_font
int indented_fill
int inhibited
int insertion
char * item_function
int line_number
struct istack_elt * next

Typedef Documentation

typedef struct istack_elt INSERTION_ELT

Enumeration Type Documentation

Enumerator:
cartouche 
copying 
defcv 
deffn 
defivar 
defmac 
defmethod 
defop 
defopt 
defspec 
deftp 
deftypecv 
deftypefn 
deftypefun 
deftypeivar 
deftypemethod 
deftypeop 
deftypevar 
deftypevr 
defun 
defvar 
defvr 
detailmenu 
direntry 
display 
documentdescription 
enumerate 
example 
floatenv 
flushleft 
flushright 
format 
ftable 
group 
ifclear 
ifdocbook 
ifhtml 
ifinfo 
ifnotdocbook 
ifnothtml 
ifnotinfo 
ifnotplaintext 
ifnottex 
ifnotxml 
ifplaintext 
ifset 
iftex 
ifxml 
itemize 
lisp 
menu 
multitable 
quotation 
rawdocbook 
rawhtml 
rawtex 
rawxml 
smalldisplay 
smallexample 
smallformat 
smalllisp 
verbatim 
table 
tex 
vtable 
titlepage 
bad_type 

Definition at line 24 of file insertion.h.


Function Documentation

Definition at line 420 of file insertion.c.

{
  int no_discard = 0;

  if (defun_insertion (type))
    {
      push_insertion (type, xstrdup (""));
      no_discard++;
    }
  else
    {
      push_insertion (type, get_item_function ());
    }

  switch (type)
    {
    case menu:
      if (!no_headers)
        close_paragraph ();

      filling_enabled = no_indent = 0;
      inhibit_paragraph_indentation = 1;

      if (html)
        {
          had_menu_commentary = 1;
        }
      else if (!no_headers && !xml)
        add_word ("* Menu:\n");

      if (xml)
        xml_insert_element (MENU, START);
      else
        in_fixed_width_font++;

      next_menu_item_number = 1;
      in_menu++;
      no_discard++;
      break;

    case detailmenu:
      if (!in_menu)
        {
          if (!no_headers)
            close_paragraph ();

          filling_enabled = no_indent = 0;
          inhibit_paragraph_indentation = 1;

          no_discard++;
        }

      if (xml)
        {
          xml_insert_element (DETAILMENU, START);
          skip_whitespace_and_newlines();
        }
      else
        in_fixed_width_font++;

      in_detailmenu++;
      break;

    case direntry:
      close_single_paragraph ();
      filling_enabled = no_indent = 0;
      inhibit_paragraph_indentation = 1;
      insert_string ("START-INFO-DIR-ENTRY\n");
      break;

    case documentdescription:
      {
        char *desc;
        int start_of_end;
        int save_fixed_width;

        discard_until ("\n"); /* ignore the @documentdescription line */
        start_of_end = get_until ("\n@end documentdescription", &desc);
        save_fixed_width = in_fixed_width_font;

        in_fixed_width_font = 0;
        document_description = expansion (desc, 0);
        free (desc);

        in_fixed_width_font = save_fixed_width;
        input_text_offset = start_of_end; /* go back to the @end to match */
      }
      break;

    case copying:
        /* Save the copying text away for @insertcopying,
           typically used on the back of the @titlepage (for TeX) and
           the Top node (for info/html).  */
      if (input_text[input_text_offset] != '\n')
        discard_until ("\n"); /* ignore remainder of @copying line */

        input_text_offset = get_until ("\n@end copying", &copying_text);
        canon_white (copying_text);

      /* For info, output the copying text right away, so it will end up
         in the header of the Info file, before the first node, and thus
         get copied automatically to all the split files.  For xml, also
         output it right away since xml output is never split.
         For html, we output it specifically in html_output_head. 
         For plain text, there's no way to hide it, so the author must
          use @insertcopying in the desired location.  */
      if (docbook)
       {
         if (!xml_in_bookinfo)
           {
             xml_insert_element (BOOKINFO, START);
             xml_in_bookinfo = 1;
           }
          xml_insert_element (LEGALNOTICE, START);
       }

      if (!html && !no_headers)
        cm_insert_copying ();

      if (docbook)
        xml_insert_element (LEGALNOTICE, END);

      break;

    case quotation:
      /* @quotation does filling (@display doesn't).  */
      if (html)
        add_html_block_elt ("<blockquote>\n");
      else
        {
          /* with close_single_paragraph, we get no blank line above
             within @copying.  */
          close_paragraph ();
          last_char_was_newline = no_indent = 0;
          indented_fill = filling_enabled = 1;
          inhibit_paragraph_indentation = 1;
        }
      current_indent += default_indentation_increment;
      if (xml)
        xml_insert_quotation (insertion_stack->item_function, START);
      else if (strlen(insertion_stack->item_function))
        execute_string ("@b{%s:} ", insertion_stack->item_function);
      break;

    case example:
    case smallexample:
    case lisp:
    case smalllisp:
      in_fixed_width_font++;
      /* fall through */

      /* Like @example but no fixed width font. */
    case display:
    case smalldisplay:
      /* Like @display but without indentation. */
    case smallformat:
    case format:
      close_single_paragraph ();
      inhibit_paragraph_indentation = 1;
      filling_enabled = 0;
      last_char_was_newline = 0;

      if (html)
        /* Kludge alert: if <pre> is followed by a newline, IE3,
           mozilla, maybe others render an extra blank line before the
           pre-formatted block.  So don't output a newline.  */
        add_html_block_elt_args ("<pre class=\"%s\">", command);

      if (type != format && type != smallformat)
        {
          current_indent += example_indentation_increment;
          if (html)
            {
              /* Since we didn't put \n after <pre>, we need to insert
                 the indentation by hand.  */
              int i;
              for (i = current_indent; i > 0; i--)
                add_char (' ');
            }
        }
      break;

    case multitable:
      do_multitable ();
      break;

    case table:
    case ftable:
    case vtable:
    case itemize:
      close_single_paragraph ();
      current_indent += default_indentation_increment;
      filling_enabled = indented_fill = 1;
#if defined (INDENT_PARAGRAPHS_IN_TABLE)
      inhibit_paragraph_indentation = 0;
#else
      inhibit_paragraph_indentation = 1;
#endif /* !INDENT_PARAGRAPHS_IN_TABLE */

      /* Make things work for losers who forget the itemize syntax. */
      if (type == itemize)
        {
          if (!(*insertion_stack->item_function))
            {
              free (insertion_stack->item_function);
              insertion_stack->item_function = xstrdup ("@bullet");
            }
        }

      if (!*insertion_stack->item_function)
        {
          line_error (_("%s requires an argument: the formatter for %citem"),
                      insertion_type_pname (type), COMMAND_PREFIX);
        }

      if (html)
        {
          if (type == itemize)
            {
              add_html_block_elt ("<ul>\n");
              in_paragraph = 0;
            }
          else
            { /* We are just starting, so this <dl>
                 has no <dt> children yet.  */
              html_deflist_has_term = 0;
              add_html_block_elt ("<dl>\n");
            }
        }
      if (xml)
        xml_begin_table (type, insertion_stack->item_function);

      while (input_text[input_text_offset] == '\n'
          && input_text[input_text_offset+1] == '\n')
        {
          line_number++;
          input_text_offset++;
        }

      break;

    case enumerate:
      close_single_paragraph ();
      no_indent = 0;
#if defined (INDENT_PARAGRAPHS_IN_TABLE)
      inhibit_paragraph_indentation = 0;
#else
      inhibit_paragraph_indentation = 1;
#endif /* !INDENT_PARAGRAPHS_IN_TABLE */

      current_indent += default_indentation_increment;
      filling_enabled = indented_fill = 1;

      if (html)
        {
          enum_html ();
          in_paragraph = 0;
        }

      if (xml)
        xml_begin_enumerate (enumeration_arg);
      
      if (isdigit (*enumeration_arg))
        start_enumerating (atoi (enumeration_arg), ENUM_DIGITS);
      else
        start_enumerating (*enumeration_arg, ENUM_ALPHA);
      break;

      /* @group produces no output in info. */
    case group:
      /* Only close the paragraph if we are not inside of an
         @example-like environment. */
      if (xml)
        xml_insert_element (GROUP, START);
      else if (!insertion_stack->next
          || (insertion_stack->next->insertion != display
              && insertion_stack->next->insertion != smalldisplay
              && insertion_stack->next->insertion != example
              && insertion_stack->next->insertion != smallexample
              && insertion_stack->next->insertion != lisp
              && insertion_stack->next->insertion != smalllisp
              && insertion_stack->next->insertion != format
              && insertion_stack->next->insertion != smallformat
              && insertion_stack->next->insertion != flushleft
              && insertion_stack->next->insertion != flushright))
        close_single_paragraph ();
      break;

    case cartouche:
      if (html)
       add_html_block_elt ("<p><table class=\"cartouche\" summary=\"cartouche\" border=\"1\"><tr><td>\n");
      if (in_menu)
        no_discard++;
      break;

    case floatenv:
      /* Cannot nest floats, so complain.  */
      if (float_active)
        {
          line_error (_("%cfloat environments cannot be nested"), COMMAND_PREFIX);
          pop_insertion ();
          break;
        }

      float_active++;

      { /* Collect data about this float.  */
        /* Example: @float [FLOATTYPE][,XREFLABEL][,POSITION] */
        char floattype[200] = "";
        char xreflabel[200] = "";
        char position[200]  = "";
        char *text;
        char *caption;
        char *shortcaption;
        int start_of_end;
        int save_line_number = line_number;
        int save_input_text_offset = input_text_offset;
        int i;

        if (strlen (insertion_stack->item_function) > 0)
          {
            int i = 0, t = 0, c = 0;
            while (insertion_stack->item_function[i])
              {
                if (insertion_stack->item_function[i] == ',')
                  {
                    switch (t)
                      {
                      case 0:
                        floattype[c] = '\0';
                        break;
                      case 1:
                        xreflabel[c] = '\0';
                        break;
                      case 2:
                        position[c] = '\0';
                        break;
                      }
                    c = 0;
                    t++;
                    i++;
                    continue;
                  }

                switch (t)
                  {
                  case 0:
                    floattype[c] = insertion_stack->item_function[i];
                    break;
                  case 1:
                    xreflabel[c] = insertion_stack->item_function[i];
                    break;
                  case 2:
                    position[c] = insertion_stack->item_function[i];
                    break;
                  }
                c++;
                i++;
              }
          }

        skip_whitespace_and_newlines ();

        start_of_end = get_until ("\n@end float", &text);

        /* Get also the @caption.  */
        i = search_forward_until_pos ("\n@caption{",
            save_input_text_offset, start_of_end);
        if (i > -1)
          {
            input_text_offset = i + sizeof ("\n@caption{") - 1;
            get_until_in_braces ("\n@end float", &caption);
            input_text_offset = save_input_text_offset;
          }
        else
          caption = "";

        /* ... and the @shortcaption.  */
        i = search_forward_until_pos ("\n@shortcaption{",
            save_input_text_offset, start_of_end);
        if (i > -1)
          {
            input_text_offset = i + sizeof ("\n@shortcaption{") - 1;
            get_until_in_braces ("\n@end float", &shortcaption);
            input_text_offset = save_input_text_offset;
          }
        else
          shortcaption = "";

        canon_white (xreflabel);
        canon_white (floattype);
        canon_white (position);
        canon_white (caption);
        canon_white (shortcaption);

        add_new_float (xstrdup (xreflabel),
            xstrdup (caption), xstrdup (shortcaption),
            xstrdup (floattype), xstrdup (position));

        /* Move to the start of the @float so the contents get processed as
           usual.  */
        input_text_offset = save_input_text_offset;
        line_number = save_line_number;
      }

      if (html)
        add_html_block_elt ("<div class=\"float\">\n");
      else if (docbook)
        xml_insert_element (FLOAT, START);
      else if (xml)
        {
          xml_insert_element_with_attribute (FLOAT, START,
              "name=\"%s\"", current_float_id ());

          xml_insert_element (FLOATTYPE, START);
          execute_string ("%s", current_float_type ());
          xml_insert_element (FLOATTYPE, END);

          xml_insert_element (FLOATPOS, START);
          execute_string ("%s", current_float_position ());
          xml_insert_element (FLOATPOS, END);
        }
      else
        { /* Info */
          close_single_paragraph ();
          inhibit_paragraph_indentation = 1;
        }

      /* Anchor now.  Note that XML documents get their
         anchors with <float name="anchor"> tag.  */
      if ((!xml || docbook) && strlen (current_float_id ()) > 0)
        execute_string ("@anchor{%s}", current_float_id ());

      break;

      /* Insertions that are no-ops in info, but do something in TeX. */
    case ifclear:
    case ifdocbook:
    case ifhtml:
    case ifinfo:
    case ifnotdocbook:
    case ifnothtml:
    case ifnotinfo:
    case ifnotplaintext:
    case ifnottex:
    case ifnotxml:
    case ifplaintext:
    case ifset:
    case iftex:
    case ifxml:
    case rawtex:
      if (in_menu)
        no_discard++;
      break;

    case rawdocbook:
    case rawhtml:
    case rawxml:
      raw_output_block++;

      if (raw_output_block > 0)
        {
          xml_no_para = 1;
          escape_html = 0;
          xml_keep_space++;
        }

      {
        /* Some deuglification for improved readability.  */
        extern int xml_in_para;
        if (xml && !xml_in_para && xml_indentation_increment > 0)
          add_char ('\n');
      }

      break;

    case defcv:
    case deffn:
    case defivar:
    case defmac:
    case defmethod:
    case defop:
    case defopt:
    case defspec:
    case deftp:
    case deftypecv:
    case deftypefn:
    case deftypefun:
    case deftypeivar:
    case deftypemethod:
    case deftypeop:
    case deftypevar:
    case deftypevr:
    case defun:
    case defvar:
    case defvr:
      inhibit_paragraph_indentation = 1;
      filling_enabled = indented_fill = 1;
      current_indent += default_indentation_increment;
      no_indent = 0;
      if (xml)
       xml_begin_definition ();
      break;

    case flushleft:
      close_single_paragraph ();
      inhibit_paragraph_indentation = 1;
      filling_enabled = indented_fill = no_indent = 0;
      if (html)
        add_html_block_elt ("<div align=\"left\">");
      break;

    case flushright:
      close_single_paragraph ();
      filling_enabled = indented_fill = no_indent = 0;
      inhibit_paragraph_indentation = 1;
      force_flush_right++;
      if (html)
        add_html_block_elt ("<div align=\"right\">");
      break;

    case titlepage:
      xml_insert_element (TITLEPAGE, START);
      break;

    default:
      line_error ("begin_insertion internal error: type=%d", type);
    }

  if (!no_discard)
    discard_until ("\n");
}

Here is the call graph for this function:

void cm_docbook ( int  arg)

Definition at line 1762 of file insertion.c.

{
  if (process_docbook)
    begin_insertion (rawdocbook);
  else
    command_name_condition ();
}

Here is the call graph for this function:

void cm_html ( int  arg)

Definition at line 1744 of file insertion.c.

{
  if (process_html)
    begin_insertion (rawhtml);
  else
    command_name_condition ();
}

Here is the call graph for this function:

Definition at line 1817 of file insertion.c.

{
  if (!process_info)
    begin_insertion (ifnotinfo);
  else
    command_name_condition ();
}

Here is the call graph for this function:

Definition at line 1836 of file insertion.c.

{
  if (!process_plaintext)
    begin_insertion (ifnotplaintext);
  else
    command_name_condition ();
}

Here is the call graph for this function:

void cm_tex ( void  )

Definition at line 1846 of file insertion.c.

{
  if (process_tex)
    begin_insertion (rawtex);
  else
    command_name_condition ();
}

Here is the call graph for this function:

void cm_xml ( int  arg)

Definition at line 1753 of file insertion.c.

{
  if (process_xml)
    begin_insertion (rawxml);
  else
    command_name_condition ();
}

Here is the call graph for this function:

Definition at line 405 of file insertion.c.

{
  char *discarder = xmalloc (8 + strlen (command));

  sprintf (discarder, "\n%cend %s", COMMAND_PREFIX, command);
  discard_until (discarder);
  discard_until ("\n");

  free (discarder);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int command_needs_braces ( char *  cmd)

Definition at line 2091 of file insertion.c.

{
  int i;
  for (i = 0; command_table[i].name; i++)
    {
      if (STREQ (command_table[i].name, cmd))
        return command_table[i].argument_in_braces == BRACE_ARGS;
    }

  return 0; /* macro or alias */
}

Here is the caller graph for this function:

void discard_insertions ( int  specials_ok)

Definition at line 1318 of file insertion.c.

{
  int real_line_number = line_number;
  while (insertion_stack)
    {
      if (specials_ok
          && ((ifclear <= insertion_stack->insertion
               && insertion_stack->insertion <= iftex)
              || insertion_stack->insertion == rawdocbook
              || insertion_stack->insertion == rawhtml
              || insertion_stack->insertion == rawxml
              || insertion_stack->insertion == rawtex))
        break;
      else
        {
          const char *offender = insertion_type_pname (insertion_stack->insertion);

          file_line_error (insertion_stack->filename,
                           insertion_stack->line_number,
                           _("No matching `%cend %s'"), COMMAND_PREFIX,
                           offender);
          pop_insertion ();
        }
    }
  line_number = real_line_number;
}

Here is the call graph for this function:

Here is the caller graph for this function:

enum insertion_type find_type_from_name ( char *  name)

Definition at line 244 of file insertion.c.

{
  int index = 0;
  while (index < (int) bad_type)
    {
      if (STREQ (name, insertion_type_names[index]))
        return (enum insertion_type) index;
      if (index == rawdocbook && STREQ (name, "docbook"))
        return rawdocbook;
      if (index == rawhtml && STREQ (name, "html"))
        return rawhtml;
      if (index == rawxml && STREQ (name, "xml"))
        return rawxml;
      if (index == rawtex && STREQ (name, "tex"))
        return rawtex;
      index++;
    }
  return bad_type;
}

Here is the caller graph for this function:

void handle_verbatim_environment ( int  find_end_verbatim)

Definition at line 1620 of file insertion.c.

{
  int character;
  int seen_end = 0;
  int save_filling_enabled = filling_enabled;
  int save_inhibit_paragraph_indentation = inhibit_paragraph_indentation;
  int save_escape_html = escape_html;

  if (!insertion_stack)
    close_single_paragraph (); /* no blank lines if not at outer level */
  inhibit_paragraph_indentation = 1;
  filling_enabled = 0;
  in_fixed_width_font++;
  last_char_was_newline = 0;

  /* No indentation: this is verbatim after all
     If you want indent, enclose @verbatim in @example
       current_indent += default_indentation_increment;
   */

  if (html)
    { /* If inside @example, we'll be preceded by the indentation
         already.  Browsers will ignore those spaces because we're about
         to start another <pre> (don't ask me).  So, wipe them out for
         cleanliness, and re-insert.  */
      int i;
      kill_self_indent (default_indentation_increment);
      add_html_block_elt ("<pre class=\"verbatim\">");
      for (i = current_indent; i > 0; i--)
        add_char (' ');
    }
  else if (xml)
    {
      xml_insert_element (VERBATIM, START);
      escape_html = 0;
      add_word ("<![CDATA[");
    }

  while (input_text_offset < input_text_length)
    {
      character = curchar ();

      if (character == '\n')
        line_number++;

      /* Assume no newlines in END_VERBATIM. */
      else if (find_end_verbatim && (character == COMMAND_PREFIX) /* @ */
          && (input_text_length - input_text_offset > sizeof (END_VERBATIM))
          && !strncmp (&input_text[input_text_offset+1], END_VERBATIM,
                       sizeof (END_VERBATIM)-1))
        {
          input_text_offset += sizeof (END_VERBATIM);
          seen_end = 1;
          break;
        }

      if (html && character == '&' && escape_html)
        add_word ("&amp;");
      else if (html && character == '<' && escape_html)
        add_word ("&lt;");
      else
        add_char (character);

      input_text_offset++;
    }

  if (find_end_verbatim && !seen_end)
    warning (_("end of file inside verbatim block"));

  if (html)
    { /* See comments in example case above.  */
      kill_self_indent (default_indentation_increment);
      add_word ("</pre>");
    }
  else if (xml)
    {
      add_word ("]]>");
      xml_insert_element (VERBATIM, END);
      escape_html = save_escape_html;
    }
  
  in_fixed_width_font--;
  filling_enabled = save_filling_enabled;
  inhibit_paragraph_indentation = save_inhibit_paragraph_indentation;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 84 of file insertion.c.

Here is the caller graph for this function:

Definition at line 267 of file insertion.c.

{
  INSERTION_ELT *temp = insertion_stack;

  if (!insertion_level)
    return 0;

  while (temp)
    {
      if (temp->insertion == type)
        return 1;
      temp = temp->next;
    }

  return 0;
}

Here is the caller graph for this function:

Definition at line 201 of file insertion.c.

{
  INSERTION_ELT *temp = insertion_stack;

  if (temp == NULL)
    return;

  in_fixed_width_font = temp->in_fixed_width_font;
  inhibit_paragraph_indentation = temp->inhibited;
  filling_enabled = temp->filling_enabled;
  indented_fill = temp->indented_fill;
  free_and_clear (&(temp->item_function));
  free_and_clear (&(temp->filename));
  insertion_stack = insertion_stack->next;
  free (temp);
  insertion_level--;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 498 of file multi.c.

Definition at line 57 of file insertion.c.

Definition at line 2369 of file insertion.c.

Definition at line 60 of file insertion.c.

Definition at line 63 of file insertion.c.

Definition at line 67 of file insertion.c.

Definition at line 53 of file insertion.c.

Definition at line 50 of file insertion.c.