texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/makeinfo crossrefs.c,NONE,1.1 crossrefs.h,NONE,1.1 Makefile.am,1


From: dirt
Subject: texinfo/makeinfo crossrefs.c,NONE,1.1 crossrefs.h,NONE,1.1 Makefile.am,1.1.1.1,1.2 cmds.c,1.14,1.15 footnote.c,1.2,1.3 html.c,1.4,1.5 makeinfo.c,1.25,1.26 node.c,1.6,1.7 sectioning.c,1.4,1.5 toc.c,1.1.1.1,1.2 makeinfo.h,1.1.1.1,1.2
Date: Tue, 6 Jan 2004 18:41:54 +0100

Update of /cvsroot/texinfo/texinfo/makeinfo
In directory sheep:/tmp/cvs-serv9222/makeinfo

Modified Files:
        Makefile.am cmds.c footnote.c html.c makeinfo.c node.c 
        sectioning.c toc.c makeinfo.h 
Added Files:
        crossrefs.c crossrefs.h 
Log Message:
2004-01-06  Alper Ersoy  <address@hidden>

        * makeinfo/makeinfo.c:
        * makeinfo/makeinfo.h: moved cross referencing commands to ...

        * makeinfo/crossrefs.c:
        * makeinfo/crossrefs.h: new files.

        * makeinfo/cmds.c:
        * makeinfo/footnote.c:
        * makeinfo/html.c:
        * makeinfo/makeinfo.c:
        * makeinfo/node.c:
        * makeinfo/sectioning.c:
        * makeinfo/toc.c: added crossrefs.h to includes.

        * makeinfo/Makefile.am: added new files crossrefs.c and crossrefs.h



--- NEW FILE: crossrefs.c ---
/* crossrefs.c -- cross references for Texinfo.
   $Id: crossrefs.c,v 1.1 2004/01/06 17:41:52 dirt Exp $

   Copyright (C) 2004 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include "system.h"
#include "cmds.h"
#include "crossrefs.h"
#include "float.h"
#include "macro.h"
#include "makeinfo.h"
#include "xml.h"

/* Flags which control initial output string for xrefs. */
int px_ref_flag = 0;
int ref_flag = 0;

/* Return next comma-delimited argument, but do not cross a close-brace
   boundary.  Clean up whitespace, too.  If EXPAND is nonzero, replace
   the entire brace-delimited argument list with its expansion before
   looking for the next comma.  */
char *
get_xref_token (expand)
     int expand;
{
  char *string;

  if (docbook)
    xml_in_xref_token = 1;

  if (expand)
    {
      int old_offset = input_text_offset;
      int old_lineno = line_number;

      get_until_in_braces ("}", &string);
      if (curchar () == '}')    /* as opposed to end of text */
        input_text_offset++;
      if (input_text_offset > old_offset)
        {
          int limit = input_text_offset;

          input_text_offset = old_offset;
          line_number = old_lineno;
          only_macro_expansion++;
          replace_with_expansion (input_text_offset, &limit);
          only_macro_expansion--;
        }
      free (string);
    }

  get_until_in_braces (",", &string);
  if (curchar () == ',')
    input_text_offset++;
  fix_whitespace (string);

  if (docbook)
    xml_in_xref_token = 0;

  return string;
}
/* NOTE: If you wonder why the HTML output is produced with such a
   peculiar mix of calls to add_word and execute_string, here's the
   reason.  get_xref_token (1) expands all macros in a reference, but
   any other commands, like @value, @@, etc., are left intact.  To
   expand them, we need to run the arguments through execute_string.
   However, characters like <, &, > and others cannot be let into
   execute_string, because they will be escaped.  See the mess?  */

/* Make a cross reference. */
void
cm_xref (arg)
{
  if (arg == START)
    {
      char *arg1 = get_xref_token (1); /* expands all macros in xref */
      char *arg2 = get_xref_token (0);
      char *arg3 = get_xref_token (0);
      char *arg4 = get_xref_token (0);
      char *arg5 = get_xref_token (0);
      char *tem;

      /* "@xref{,Foo,, Bar, Baz} is not valid usage of @xref.  The
         first argument must never be blank." --rms.
         We hereby comply by disallowing such constructs.  */
      if (!*arg1)
        line_error (_("First argument to cross-reference may not be empty"));

      if (docbook)
        {
          if (!*arg4 && !*arg5)
            {
              char *arg1_id = xml_id (arg1);

              if (!*arg2 && !*arg3)
                arg3 = xstrdup (xml_get_assoc_for_id (arg1_id));

              if (*arg2 || *arg3)
                {
                  xml_insert_element_with_attribute (XREFNODENAME, START,
                                                     "linkend=\"%s\"", arg1_id);
                  free (arg1_id);
                  execute_string (*arg3 ? arg3 : arg2);
                  xml_insert_element (XREFNODENAME, END);
                }
              else
                {
                  xml_insert_element_with_attribute (XREF, START,
                                                     "linkend=\"%s\"", arg1_id);
                  xml_insert_element (XREF, END);
                  free (arg1_id);
                }
            }
          else if (*arg5)
            {
              add_word_args (_("See section ``%s'' in "), *arg3 ? arg3 : arg1);
              xml_insert_element (CITE, START);
              add_word (arg5);
              xml_insert_element (CITE, END);
            }
          else if (*arg4)
            {
              /* Very sad, we are losing xrefs made to ``info only'' books.  */
            }
        }
      else if (xml)
        {
          xml_insert_element (XREF, START);
          xml_insert_element (XREFNODENAME, START);
          execute_string (arg1);
          xml_insert_element (XREFNODENAME, END);
          if (*arg2)
            {
              xml_insert_element (XREFINFONAME, START);
              execute_string (arg2);
              xml_insert_element (XREFINFONAME, END);
            }
          if (*arg3)
            {
              xml_insert_element (XREFPRINTEDDESC, START);
              execute_string (arg3);
              xml_insert_element (XREFPRINTEDDESC, END);
            }
          if (*arg4)
            {
              xml_insert_element (XREFINFOFILE, START);
              execute_string (arg4);
              xml_insert_element (XREFINFOFILE, END);
            }
          if (*arg5)
            {
              xml_insert_element (XREFPRINTEDNAME, START);
              execute_string (arg5);
              xml_insert_element (XREFPRINTEDNAME, END);
            }
          xml_insert_element (XREF, END);
        }
      else if (html)
        {
          if (!ref_flag)
            add_word_args ("%s", px_ref_flag ? _("see ") : _("See "));
        }
      else
        add_word_args ("%s", px_ref_flag ? "*note " : "*Note ");

      if (!xml)
        {
          if (*arg5 || *arg4)
            {
              /* arg1 - node name
                 arg2 - reference name
                 arg3 - title or topic (and reference name if arg2 is NULL)
                 arg4 - info file name
                 arg5 - printed manual title  */
              char *ref_name;

              if (!*arg2)
                {
                  if (*arg3)
                    ref_name = arg3;
                  else
                    ref_name = arg1;
                }
              else
                ref_name = arg2;

              if (html)
                {
                  /* html fixxme: revisit this; external node name not
                     much use to us with numbered nodes. */
                  add_html_elt ("<a href=");
                  /* Note that if we are splitting, and the referenced
                     tag is an anchor rather than a node, we will
                     produce a reference to a file whose name is
                     derived from the anchor name.  However, only
                     nodes create files, so we are referencing a
                     non-existent file.  cm_anchor, which see, deals
                     with that problem.  */
                  if (splitting)
                    execute_string ("\"../%s/", arg4);
                  else
                    execute_string ("\"%s.html", arg4);
                  /* Do not collapse -- to -, etc., in references.  */
                  in_fixed_width_font++;
                  tem = expansion (arg1, 0); /* expand @-commands in node */
                  in_fixed_width_font--;
                  add_anchor_name (tem, 1);
                  free (tem);
                  add_word ("\">");
                  execute_string ("%s", ref_name);
                  add_word ("</a>");
                }
              else
                {
                  execute_string ("%s:", ref_name);
                  in_fixed_width_font++;
                  execute_string (" (%s)%s%s", arg4, arg1, px_ref_flag ? "." : 
"");
                  in_fixed_width_font--;
                }

              /* Free all of the arguments found. */
              if (arg1) free (arg1);
              if (arg2) free (arg2);
              if (arg3) free (arg3);
              if (arg4) free (arg4);
              if (arg5) free (arg5);
              return;
            }
          else
            remember_node_reference (arg1, line_number, followed_reference);

          if (*arg3)
            {
              if (html)
                {
                  add_html_elt ("<a href=\"");
                  in_fixed_width_font++;
                  tem = expansion (arg1, 0);
                  in_fixed_width_font--;
                  add_anchor_name (tem, 1);
                  free (tem);
                  add_word ("\">");
                  execute_string ("%s", *arg2 ? arg2 : arg3);
                  add_word ("</a>");
                }
              else
                {
                  execute_string ("%s:", *arg2 ? arg2 : arg3);
                  in_fixed_width_font++;
                  execute_string (" %s%s", arg1, px_ref_flag ? "." : "");
                  in_fixed_width_font--;
                }
            }
          else
            {
              if (html)
                {
                  add_html_elt ("<a href=\"");
                  in_fixed_width_font++;
                  tem = expansion (arg1, 0);
                  in_fixed_width_font--;
                  add_anchor_name (tem, 1);
                  free (tem);
                  add_word ("\">");
                  if (*arg2)
                    execute_string ("%s", arg2);
                  else
                    {
                      char *fref = get_float_ref (arg1);
                      execute_string ("%s", fref ? fref : arg1);
                      free (fref);
                    }
                  add_word ("</a>");
                }
              else
                {
                  if (*arg2)
                    {
                      execute_string ("%s:", arg2);
                      in_fixed_width_font++;
                      execute_string (" %s%s", arg1, px_ref_flag ? "." : "");
                      in_fixed_width_font--;
                    }
                  else
                    {
                      char *fref = get_float_ref (arg1);
                      if (fref)
                        { /* Reference is being made to a float.  */
                          execute_string ("%s:", fref);
                          in_fixed_width_font++;
                          execute_string (" %s%s", arg1, px_ref_flag ? "." : 
"");
                          in_fixed_width_font--;
                        }
                      else
                        {
                          in_fixed_width_font++;
                          execute_string ("%s::", arg1);
                          in_fixed_width_font--;
                        }
                    }
                }
            }
        }
      /* Free all of the arguments found. */
      if (arg1) free (arg1);
      if (arg2) free (arg2);
      if (arg3) free (arg3);
      if (arg4) free (arg4);
      if (arg5) free (arg5);
    }
  else
    { /* Check to make sure that the next non-whitespace character is
         valid to follow an xref (so info readers can find the node
         names).  `input_text_offset' is pointing at the "}" which ended
         the xref or ref command.  This is not used for @pxref, since we
         insert the necessary periods above if needed.  And for @ref, we
         also allow ), which doesn't make sense for @xref.  */
      int temp;

      for (temp = input_text_offset + 1; temp < input_text_length; )
        {
          if (cr_or_whitespace (input_text[temp]))
            temp++;
          else {
            /* sorry to switch indentation styles, but it's just too
               much nesting.  --karl.  */
            if (input_text[temp] != '.' && input_text[temp] != ',') {
              warning (_("`.' or `,' must follow ref, not %c"),
                           input_text[temp]);
            }
            break;
          }
        }
    }
}

void
cm_pxref (arg)
     int arg;
{
  if (arg == START)
    {
      px_ref_flag++;
      cm_xref (arg);
      px_ref_flag--;
    }
  /* cm_xref isn't called with arg == END, which disables the code near
     the end of cm_xref that checks for `.' or `,' after the
     cross-reference.  This is because cm_xref generates the required
     character itself (when needed) if px_ref_flag is set.  */
}

void
cm_ref (arg)
     int arg;
{
  /* Call cm_xref for both START and END, so we get the checking.  */
  ref_flag++;
  cm_xref (arg);
  ref_flag--;
}

void
cm_inforef (arg)
     int arg;
{
  if (arg == START)
    {
      char *node = get_xref_token (1); /* expands all macros in inforef */
      char *pname = get_xref_token (0);
      char *file = get_xref_token (0);

      /* (see comments at cm_xref).  */
      if (!*node)
        line_error (_("First argument to @inforef may not be empty"));

      if (xml && !docbook)
        {
          xml_insert_element (INFOREF, START);
          xml_insert_element (INFOREFNODENAME, START);
          execute_string (node);
          xml_insert_element (INFOREFNODENAME, END);
          if (*pname)
            {
              xml_insert_element (INFOREFREFNAME, START);
              execute_string (pname);
              xml_insert_element (INFOREFREFNAME, END);
            }
          xml_insert_element (INFOREFINFONAME, START);
          execute_string (file);
          xml_insert_element (INFOREFINFONAME, END);

          xml_insert_element (INFOREF, END);
        }
      else if (html)
        {
          char *tem;

          add_word (_("see "));
          /* html fixxme: revisit this */
          add_html_elt ("<a href=");
          if (splitting)
            execute_string ("\"../%s/", file);
          else
            execute_string ("\"%s.html", file);
          tem = expansion (node, 0);
          add_anchor_name (tem, 1);
          add_word ("\">");
          execute_string ("%s", *pname ? pname : tem);
          add_word ("</a>");
          free (tem);
        }
      else
        {
          if (*pname)
            execute_string ("*note %s: (%s)%s", pname, file, node);
          else
            execute_string ("*note (%s)%s::", file, node);
        }

      free (node);
      free (pname);
      free (file);
    }
}

/* A URL reference.  */
void
cm_uref (arg)
     int arg;
{
  if (arg == START)
    {
      extern int printing_index;
      char *url  = get_xref_token (1); /* expands all macros in uref */
      char *desc = get_xref_token (0);
      char *replacement = get_xref_token (0);

      if (docbook)
        {
          xml_insert_element_with_attribute (UREF, START, "url=\"%s\"",
              text_expansion (url));
          if (*replacement)
            execute_string (replacement);
          else if (*desc)
            execute_string (desc);
          else
            execute_string (url);
          xml_insert_element (UREF, END);
        }
      else if (xml)
        {
          xml_insert_element (UREF, START);
          xml_insert_element (UREFURL, START);
          execute_string (url);
          xml_insert_element (UREFURL, END);
          if (*desc)
            {
              xml_insert_element (UREFDESC, START);
              execute_string (desc);
              xml_insert_element (UREFDESC, END);
            }
          if (*replacement)
            {
              xml_insert_element (UREFREPLACEMENT, START);
              execute_string (replacement);
              xml_insert_element (UREFREPLACEMENT, END);
            }
          xml_insert_element (UREF, END);
        }
      else if (html)
        { /* never need to show the url */
          add_html_elt ("<a href=");
          /* don't collapse `--' etc. in the url */
          in_fixed_width_font++;
          execute_string ("\"%s\"", url);
          in_fixed_width_font--;
          add_word (">");
          execute_string ("%s", *replacement ? replacement
                                : (*desc ? desc : url));
          add_word ("</a>");
        }
      else if (*replacement) /* do not show the url */
        execute_string ("%s", replacement);
      else if (*desc)        /* show both text and url */
        {
          execute_string ("%s ", desc);
          in_fixed_width_font++;
          execute_string ("(%s)", url);
          in_fixed_width_font--;
        }
      else /* no text at all, so have the url to show */
        {
          in_fixed_width_font++;
          execute_string ("%s%s%s",
                          printing_index ? "" : "`",
                          url,
                          printing_index ? "" : "'");
          in_fixed_width_font--;
        }
      if (url)
        free (url);
      if (desc)
        free (desc);
      if (replacement)
        free (replacement);
    }
}

/* An email reference.  */
void
cm_email (arg)
     int arg;
{
  if (arg == START)
    {
      char *addr = get_xref_token (1); /* expands all macros in email */
      char *name = get_xref_token (0);

      if (xml && docbook)
        {
          xml_insert_element_with_attribute (EMAIL, START, "url=\"mailto:%s\"";, 
addr);
          if (*name)
              execute_string (name);
          xml_insert_element (EMAIL, END);
        }
      else if (xml)
        {
          xml_insert_element (EMAIL, START);
          xml_insert_element (EMAILADDRESS, START);
          execute_string (addr);
          xml_insert_element (EMAILADDRESS, END);
          if (*name)
            {
              xml_insert_element (EMAILNAME, START);
              execute_string (name);
              xml_insert_element (EMAILNAME, END);
            }
          xml_insert_element (EMAIL, END);
        }
      else if (html)
        {
          add_html_elt ("<a href=");
          /* don't collapse `--' etc. in the address */
          in_fixed_width_font++;
          execute_string ("\"mailto:%s\"";, addr);
          in_fixed_width_font--;
          add_word (">");
          execute_string ("%s", *name ? name : addr);
          add_word ("</a>");
        }
      else
        {
          execute_string ("%s%s", name, *name ? " "  : "");
          in_fixed_width_font++;
          execute_string ("<%s>", addr);
          in_fixed_width_font--;
        }

      if (addr)
        free (addr);
      if (name)
        free (name);
    }
}

--- NEW FILE: crossrefs.h ---
/* crossrefs.h -- declarations for the cross references.
   $Id: crossrefs.h,v 1.1 2004/01/06 17:41:52 dirt Exp $

   Copyright (C) 2004 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#ifndef XREF_H
#define XREF_H

enum reftype
{
  menu_reference, followed_reference
};

extern char *get_xref_token ();

#endif /* not XREF_H */

Index: Makefile.am
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** Makefile.am 6 Dec 2003 01:33:19 -0000       1.1.1.1
--- Makefile.am 6 Jan 2004 17:41:51 -0000       1.2
***************
*** 18,22 ****
  
  makeinfo_SOURCES = \
!   cmds.c cmds.h defun.c defun.h \
    files.c files.h float.c float.h footnote.c footnote.h \
    html.c html.h index.c index.h insertion.c insertion.h lang.c lang.h \
--- 18,22 ----
  
  makeinfo_SOURCES = \
!   cmds.c cmds.h crossrefs.c crossrefs.h defun.c defun.h \
    files.c files.h float.c float.h footnote.c footnote.h \
    html.c html.h index.c index.h insertion.c insertion.h lang.c lang.h \

Index: cmds.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/cmds.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** cmds.c      5 Jan 2004 14:37:52 -0000       1.14
--- cmds.c      6 Jan 2004 17:41:51 -0000       1.15
***************
*** 21,24 ****
--- 21,25 ----
  #include "system.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "defun.h"
  #include "files.h"

Index: footnote.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/footnote.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** footnote.c  28 Dec 2003 11:48:52 -0000      1.2
--- footnote.c  6 Jan 2004 17:41:51 -0000       1.3
***************
*** 19,22 ****
--- 19,23 ----
  
  #include "system.h"
+ #include "crossrefs.h"
  #include "footnote.h"
  #include "macro.h"

Index: html.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/html.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** html.c      5 Jan 2004 14:37:52 -0000       1.4
--- html.c      6 Jan 2004 17:41:51 -0000       1.5
***************
*** 20,23 ****
--- 20,24 ----
  #include "system.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "html.h"
  #include "lang.h"

Index: makeinfo.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** makeinfo.c  6 Jan 2004 14:30:37 -0000       1.25
--- makeinfo.c  6 Jan 2004 17:41:51 -0000       1.26
***************
*** 27,30 ****
--- 27,31 ----
  #include "makeinfo.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "files.h"
  #include "float.h"
***************
*** 71,78 ****
  static char *save_command_output_filename = NULL;
  
- /* Flags which control initial output string for xrefs. */
- int px_ref_flag = 0;
- int ref_flag = 0;
- 
  #define INITIAL_PARAGRAPH_SPACE 5000
  int paragraph_buffer_len = INITIAL_PARAGRAPH_SPACE;
--- 72,75 ----
***************
*** 3219,3774 ****
  }
  
- /* Cross references.  */
- 
- /* Return next comma-delimited argument, but do not cross a close-brace
-    boundary.  Clean up whitespace, too.  If EXPAND is nonzero, replace
-    the entire brace-delimited argument list with its expansion before
-    looking for the next comma.  */
- char *
- get_xref_token (expand)
-      int expand;
- {
-   char *string;
- 
-   if (docbook)
-     xml_in_xref_token = 1;
- 
-   if (expand)
-     {
-       int old_offset = input_text_offset;
-       int old_lineno = line_number;
- 
-       get_until_in_braces ("}", &string);
-       if (curchar () == '}')    /* as opposed to end of text */
-         input_text_offset++;
-       if (input_text_offset > old_offset)
-         {
-           int limit = input_text_offset;
- 
-           input_text_offset = old_offset;
-           line_number = old_lineno;
-           only_macro_expansion++;
-           replace_with_expansion (input_text_offset, &limit);
-           only_macro_expansion--;
-         }
-       free (string);
-     }
- 
-   get_until_in_braces (",", &string);
-   if (curchar () == ',')
-     input_text_offset++;
-   fix_whitespace (string);
- 
-   if (docbook)
-     xml_in_xref_token = 0;
- 
-   return string;
- }
- 
- /* NOTE: If you wonder why the HTML output is produced with such a
-    peculiar mix of calls to add_word and execute_string, here's the
-    reason.  get_xref_token (1) expands all macros in a reference, but
-    any other commands, like @value, @@, etc., are left intact.  To
-    expand them, we need to run the arguments through execute_string.
-    However, characters like <, &, > and others cannot be let into
-    execute_string, because they will be escaped.  See the mess?  */
- 
- /* Make a cross reference. */
- void
- cm_xref (arg)
- {
-   if (arg == START)
-     {
-       char *arg1 = get_xref_token (1); /* expands all macros in xref */
-       char *arg2 = get_xref_token (0);
-       char *arg3 = get_xref_token (0);
-       char *arg4 = get_xref_token (0);
-       char *arg5 = get_xref_token (0);
-       char *tem;
- 
-       /* "@xref{,Foo,, Bar, Baz} is not valid usage of @xref.  The
-          first argument must never be blank." --rms.
-          We hereby comply by disallowing such constructs.  */
-       if (!*arg1)
-         line_error (_("First argument to cross-reference may not be empty"));
- 
-       if (docbook)
-         {
-           if (!*arg4 && !*arg5)
-             {
-               char *arg1_id = xml_id (arg1);
- 
-               if (!*arg2 && !*arg3)
-                 arg3 = xstrdup (xml_get_assoc_for_id (arg1_id));
- 
-               if (*arg2 || *arg3)
-                 {
-                   xml_insert_element_with_attribute (XREFNODENAME, START,
-                                                      "linkend=\"%s\"", 
arg1_id);
-                   free (arg1_id);
-                   execute_string (*arg3 ? arg3 : arg2);
-                   xml_insert_element (XREFNODENAME, END);
-                 }
-               else
-                 {
-                   xml_insert_element_with_attribute (XREF, START,
-                                                      "linkend=\"%s\"", 
arg1_id);
-                   xml_insert_element (XREF, END);
-                   free (arg1_id);
-                 }
-             }
-           else if (*arg5)
-             {
-               add_word_args (_("See section ``%s'' in "), *arg3 ? arg3 : 
arg1);
-               xml_insert_element (CITE, START);
-               add_word (arg5);
-               xml_insert_element (CITE, END);
-             }
-           else if (*arg4)
-             {
-               /* Very sad, we are losing xrefs made to ``info only'' books.  
*/
-             }
-         }
-       else if (xml)
-         {
-           xml_insert_element (XREF, START);
-           xml_insert_element (XREFNODENAME, START);
-           execute_string (arg1);
-           xml_insert_element (XREFNODENAME, END);
-           if (*arg2)
-             {
-               xml_insert_element (XREFINFONAME, START);
-               execute_string (arg2);
-               xml_insert_element (XREFINFONAME, END);
-             }
-           if (*arg3)
-             {
-               xml_insert_element (XREFPRINTEDDESC, START);
-               execute_string (arg3);
-               xml_insert_element (XREFPRINTEDDESC, END);
-             }
-           if (*arg4)
-             {
-               xml_insert_element (XREFINFOFILE, START);
-               execute_string (arg4);
-               xml_insert_element (XREFINFOFILE, END);
-             }
-           if (*arg5)
-             {
-               xml_insert_element (XREFPRINTEDNAME, START);
-               execute_string (arg5);
-               xml_insert_element (XREFPRINTEDNAME, END);
-             }
-           xml_insert_element (XREF, END);
-         }
-       else if (html)
-         {
-           if (!ref_flag)
-             add_word_args ("%s", px_ref_flag ? _("see ") : _("See "));
-         }
-       else
-         add_word_args ("%s", px_ref_flag ? "*note " : "*Note ");
- 
-       if (!xml)
-         {
-           if (*arg5 || *arg4)
-             {
-               /* arg1 - node name
-                  arg2 - reference name
-                  arg3 - title or topic (and reference name if arg2 is NULL)
-                  arg4 - info file name
-                  arg5 - printed manual title  */
-               char *ref_name;
- 
-               if (!*arg2)
-                 {
-                   if (*arg3)
-                     ref_name = arg3;
-                   else
-                     ref_name = arg1;
-                 }
-               else
-                 ref_name = arg2;
- 
-               if (html)
-                 {
-                   /* html fixxme: revisit this; external node name not
-                      much use to us with numbered nodes. */
-                   add_html_elt ("<a href=");
-                   /* Note that if we are splitting, and the referenced
-                      tag is an anchor rather than a node, we will
-                      produce a reference to a file whose name is
-                      derived from the anchor name.  However, only
-                      nodes create files, so we are referencing a
-                      non-existent file.  cm_anchor, which see, deals
-                      with that problem.  */
-                   if (splitting)
-                     execute_string ("\"../%s/", arg4);
-                   else
-                     execute_string ("\"%s.html", arg4);
-                   /* Do not collapse -- to -, etc., in references.  */
-                   in_fixed_width_font++;
-                   tem = expansion (arg1, 0); /* expand @-commands in node */
-                   in_fixed_width_font--;
-                   add_anchor_name (tem, 1);
-                   free (tem);
-                   add_word ("\">");
-                   execute_string ("%s", ref_name);
-                   add_word ("</a>");
-                 }
-               else
-                 {
-                   execute_string ("%s:", ref_name);
-                   in_fixed_width_font++;
-                   execute_string (" (%s)%s%s", arg4, arg1, px_ref_flag ? "." 
: "");
-                   in_fixed_width_font--;
-                 }
- 
-               /* Free all of the arguments found. */
-               if (arg1) free (arg1);
-               if (arg2) free (arg2);
-               if (arg3) free (arg3);
-               if (arg4) free (arg4);
-               if (arg5) free (arg5);
-               return;
-             }
-           else
-             remember_node_reference (arg1, line_number, followed_reference);
- 
-           if (*arg3)
-             {
-               if (html)
-                 {
-                   add_html_elt ("<a href=\"");
-                   in_fixed_width_font++;
-                   tem = expansion (arg1, 0);
-                   in_fixed_width_font--;
-                   add_anchor_name (tem, 1);
-                   free (tem);
-                   add_word ("\">");
-                   execute_string ("%s", *arg2 ? arg2 : arg3);
-                   add_word ("</a>");
-                 }
-               else
-                 {
-                   execute_string ("%s:", *arg2 ? arg2 : arg3);
-                   in_fixed_width_font++;
-                   execute_string (" %s%s", arg1, px_ref_flag ? "." : "");
-                   in_fixed_width_font--;
-                 }
-             }
-           else
-             {
-               if (html)
-                 {
-                   add_html_elt ("<a href=\"");
-                   in_fixed_width_font++;
-                   tem = expansion (arg1, 0);
-                   in_fixed_width_font--;
-                   add_anchor_name (tem, 1);
-                   free (tem);
-                   add_word ("\">");
-                   if (*arg2)
-                     execute_string ("%s", arg2);
-                   else
-                     {
-                       char *fref = get_float_ref (arg1);
-                       execute_string ("%s", fref ? fref : arg1);
-                       free (fref);
-                     }
-                   add_word ("</a>");
-                 }
-               else
-                 {
-                   if (*arg2)
-                     {
-                       execute_string ("%s:", arg2);
-                       in_fixed_width_font++;
-                       execute_string (" %s%s", arg1, px_ref_flag ? "." : "");
-                       in_fixed_width_font--;
-                     }
-                   else
-                     {
-                       char *fref = get_float_ref (arg1);
-                       if (fref)
-                         { /* Reference is being made to a float.  */
-                           execute_string ("%s:", fref);
-                           in_fixed_width_font++;
-                           execute_string (" %s%s", arg1, px_ref_flag ? "." : 
"");
-                           in_fixed_width_font--;
-                         }
-                       else
-                         {
-                           in_fixed_width_font++;
-                           execute_string ("%s::", arg1);
-                           in_fixed_width_font--;
-                         }
-                     }
-                 }
-             }
-         }
-       /* Free all of the arguments found. */
-       if (arg1) free (arg1);
-       if (arg2) free (arg2);
-       if (arg3) free (arg3);
-       if (arg4) free (arg4);
-       if (arg5) free (arg5);
-     }
-   else
-     { /* Check to make sure that the next non-whitespace character is
-          valid to follow an xref (so info readers can find the node
-          names).  `input_text_offset' is pointing at the "}" which ended
-          the xref or ref command.  This is not used for @pxref, since we
-          insert the necessary periods above if needed.  And for @ref, we
-          also allow ), which doesn't make sense for @xref.  */
-       int temp;
- 
-       for (temp = input_text_offset + 1; temp < input_text_length; )
-         {
-           if (cr_or_whitespace (input_text[temp]))
-             temp++;
-           else {
-             /* sorry to switch indentation styles, but it's just too
-                much nesting.  --karl.  */
-             if (input_text[temp] != '.' && input_text[temp] != ',') {
-               warning (_("`.' or `,' must follow ref, not %c"),
-                            input_text[temp]);
-             }
-             break;
-           }
-         }
-     }
- }
- 
- void
- cm_pxref (arg)
-      int arg;
- {
-   if (arg == START)
-     {
-       px_ref_flag++;
-       cm_xref (arg);
-       px_ref_flag--;
-     }
-   /* cm_xref isn't called with arg == END, which disables the code near
-      the end of cm_xref that checks for `.' or `,' after the
-      cross-reference.  This is because cm_xref generates the required
-      character itself (when needed) if px_ref_flag is set.  */
- }
- 
- void
- cm_ref (arg)
-      int arg;
- {
-   /* Call cm_xref for both START and END, so we get the checking.  */
-   ref_flag++;
-   cm_xref (arg);
-   ref_flag--;
- }
- 
- void
- cm_inforef (arg)
-      int arg;
- {
-   if (arg == START)
-     {
-       char *node = get_xref_token (1); /* expands all macros in inforef */
-       char *pname = get_xref_token (0);
-       char *file = get_xref_token (0);
- 
-       /* (see comments at cm_xref).  */
-       if (!*node)
-         line_error (_("First argument to @inforef may not be empty"));
- 
-       if (xml && !docbook)
-         {
-           xml_insert_element (INFOREF, START);
-           xml_insert_element (INFOREFNODENAME, START);
-           execute_string (node);
-           xml_insert_element (INFOREFNODENAME, END);
-           if (*pname)
-             {
-               xml_insert_element (INFOREFREFNAME, START);
-               execute_string (pname);
-               xml_insert_element (INFOREFREFNAME, END);
-             }
-           xml_insert_element (INFOREFINFONAME, START);
-           execute_string (file);
-           xml_insert_element (INFOREFINFONAME, END);
- 
-           xml_insert_element (INFOREF, END);
-         }
-       else if (html)
-         {
-           char *tem;
- 
-           add_word (_("see "));
-           /* html fixxme: revisit this */
-           add_html_elt ("<a href=");
-           if (splitting)
-             execute_string ("\"../%s/", file);
-           else
-             execute_string ("\"%s.html", file);
-           tem = expansion (node, 0);
-           add_anchor_name (tem, 1);
-           add_word ("\">");
-           execute_string ("%s", *pname ? pname : tem);
-           add_word ("</a>");
-           free (tem);
-         }
-       else
-         {
-           if (*pname)
-             execute_string ("*note %s: (%s)%s", pname, file, node);
-           else
-             execute_string ("*note (%s)%s::", file, node);
-         }
- 
-       free (node);
-       free (pname);
-       free (file);
-     }
- }
- 
- /* A URL reference.  */
- void
- cm_uref (arg)
-      int arg;
- {
-   if (arg == START)
-     {
-       extern int printing_index;
-       char *url  = get_xref_token (1); /* expands all macros in uref */
-       char *desc = get_xref_token (0);
-       char *replacement = get_xref_token (0);
- 
-       if (docbook)
-         {
-           xml_insert_element_with_attribute (UREF, START, "url=\"%s\"",
-               text_expansion (url));
-           if (*replacement)
-             execute_string (replacement);
-           else if (*desc)
-             execute_string (desc);
-           else
-             execute_string (url);
-           xml_insert_element (UREF, END);
-         }
-       else if (xml)
-         {
-           xml_insert_element (UREF, START);
-           xml_insert_element (UREFURL, START);
-           execute_string (url);
-           xml_insert_element (UREFURL, END);
-           if (*desc)
-             {
-               xml_insert_element (UREFDESC, START);
-               execute_string (desc);
-               xml_insert_element (UREFDESC, END);
-             }
-           if (*replacement)
-             {
-               xml_insert_element (UREFREPLACEMENT, START);
-               execute_string (replacement);
-               xml_insert_element (UREFREPLACEMENT, END);
-             }
-           xml_insert_element (UREF, END);
-         }
-       else if (html)
-         { /* never need to show the url */
-           add_html_elt ("<a href=");
-           /* don't collapse `--' etc. in the url */
-           in_fixed_width_font++;
-           execute_string ("\"%s\"", url);
-           in_fixed_width_font--;
-           add_word (">");
-           execute_string ("%s", *replacement ? replacement
-                                 : (*desc ? desc : url));
-           add_word ("</a>");
-         }
-       else if (*replacement) /* do not show the url */
-         execute_string ("%s", replacement);
-       else if (*desc)        /* show both text and url */
-         {
-           execute_string ("%s ", desc);
-           in_fixed_width_font++;
-           execute_string ("(%s)", url);
-           in_fixed_width_font--;
-         }
-       else /* no text at all, so have the url to show */
-         {
-           in_fixed_width_font++;
-           execute_string ("%s%s%s",
-                           printing_index ? "" : "`",
-                           url,
-                           printing_index ? "" : "'");
-           in_fixed_width_font--;
-         }
-       if (url)
-         free (url);
-       if (desc)
-         free (desc);
-       if (replacement)
-         free (replacement);
-     }
- }
- 
- /* An email reference.  */
- void
- cm_email (arg)
-      int arg;
- {
-   if (arg == START)
-     {
-       char *addr = get_xref_token (1); /* expands all macros in email */
-       char *name = get_xref_token (0);
- 
-       if (xml && docbook)
-         {
-           xml_insert_element_with_attribute (EMAIL, START, 
"url=\"mailto:%s\"";, addr);
-           if (*name)
-               execute_string (name);
-           xml_insert_element (EMAIL, END);
-         }
-       else if (xml)
-         {
-           xml_insert_element (EMAIL, START);
-           xml_insert_element (EMAILADDRESS, START);
-           execute_string (addr);
-           xml_insert_element (EMAILADDRESS, END);
-           if (*name)
-             {
-               xml_insert_element (EMAILNAME, START);
-               execute_string (name);
-               xml_insert_element (EMAILNAME, END);
-             }
-           xml_insert_element (EMAIL, END);
-         }
-       else if (html)
-         {
-           add_html_elt ("<a href=");
-           /* don't collapse `--' etc. in the address */
-           in_fixed_width_font++;
-           execute_string ("\"mailto:%s\"";, addr);
-           in_fixed_width_font--;
-           add_word (">");
-           execute_string ("%s", *name ? name : addr);
-           add_word ("</a>");
-         }
-       else
-         {
-           execute_string ("%s%s", name, *name ? " "  : "");
-           in_fixed_width_font++;
-           execute_string ("<%s>", addr);
-           in_fixed_width_font--;
-         }
- 
-       if (addr)
-         free (addr);
-       if (name)
-         free (name);
-     }
- }
- 
  /* An external image is a reference, kind of.  The parsing is (not
     coincidentally) similar, anyway.  */
--- 3216,3219 ----

Index: node.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/node.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** node.c      6 Jan 2004 16:32:12 -0000       1.6
--- node.c      6 Jan 2004 17:41:51 -0000       1.7
***************
*** 21,24 ****
--- 21,25 ----
  #include "system.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "files.h"
  #include "footnote.h"

Index: sectioning.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/sectioning.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sectioning.c        28 Dec 2003 11:48:52 -0000      1.4
--- sectioning.c        6 Jan 2004 17:41:52 -0000       1.5
***************
*** 22,25 ****
--- 22,26 ----
  #include "system.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "macro.h"
  #include "makeinfo.h"

Index: toc.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/toc.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** toc.c       6 Dec 2003 01:33:53 -0000       1.1.1.1
--- toc.c       6 Jan 2004 17:41:52 -0000       1.2
***************
*** 23,26 ****
--- 23,27 ----
  #include "makeinfo.h"
  #include "cmds.h"
+ #include "crossrefs.h"
  #include "files.h"
  #include "macro.h"

Index: makeinfo.h
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** makeinfo.h  6 Dec 2003 01:33:48 -0000       1.1.1.1
--- makeinfo.h  6 Jan 2004 17:41:52 -0000       1.2
***************
*** 32,42 ****
  /* Hardcoded per GNU standards, not dependent on argv[0].  */
  DECLARE (char *, progname, "makeinfo");
- 
- enum reftype
- {
-   menu_reference, followed_reference
- };
- 
- extern char *get_xref_token ();
  
  /* Nonzero means a string is in execution, as opposed to a file. */
--- 32,35 ----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]