Back to index

tetex-bin  3.0
Functions | Variables
info-utils.c File Reference
#include "info.h"
#include "info-utils.h"
#include "man.h"

Go to the source code of this file.

Functions

static void save_filename (char *filename)
static void saven_filename (char *filename, int len)
static void save_nodename (char *nodename)
static void saven_nodename (char *nodename, int len)
static REFERENCE ** info_references_internal (char *label, SEARCH_BINDING *binding)
void info_parse_node (char *string, int newlines_okay)
void info_parse_label (char *label, NODE *node)
REFERENCE ** info_menu_of_node (NODE *node)
REFERENCE ** info_xrefs_of_node (NODE *node)
REFERENCE ** info_menu_items (SEARCH_BINDING *binding)
REFERENCE ** info_xrefs (SEARCH_BINDING *binding)
REFERENCEinfo_get_labeled_reference (char *label, REFERENCE **references)
REFERENCE ** info_concatenate_references (REFERENCE **ref1, REFERENCE **ref2)
REFERENCEinfo_copy_reference (REFERENCE *src)
void info_free_references (REFERENCE **references)
void canonicalize_whitespace (char *string)
char * printed_representation (unsigned char character, int hpos)
static void save_string (char *string, char **string_p, int *string_size_p)
static void saven_string (char *string, int len, char **string_p, int *string_size_p)
char * filename_non_directory (char *pathname)
int internal_info_node_p (NODE *node)
void name_internal_node (NODE *node, char *name)
WINDOWget_internal_info_window (char *name)
WINDOWget_window_of_node (NODE *node)

Variables

int ISO_Latin_p = 1
char * info_parsed_filename = (char *)NULL
char * info_parsed_nodename = (char *)NULL
int info_parsed_line_number = 0
static char the_rep [10]
static int parsed_filename_size = 0
static int parsed_nodename_size = 0

Function Documentation

void canonicalize_whitespace ( char *  string)

Definition at line 431 of file info-utils.c.

{
  register int i, j;
  int len, whitespace_found, whitespace_loc = 0;
  char *temp;

  if (!string)
    return;

  len = strlen (string);
  temp = (char *)xmalloc (1 + len);

  /* Search for sequences of whitespace or newlines.  Replace all such
     sequences in the string with just a single space. */

  whitespace_found = 0;
  for (i = 0, j = 0; string[i]; i++)
    {
      if (whitespace_or_newline (string[i]))
        {
          whitespace_found++;
          whitespace_loc = i;
          continue;
        }
      else
        {
          if (whitespace_found && whitespace_loc)
            {
              whitespace_found = 0;

              /* Suppress whitespace at start of string. */
              if (j)
                temp[j++] = ' ';
            }

          temp[j++] = string[i];
        }
    }

  /* Kill trailing whitespace. */
  if (j && whitespace (temp[j - 1]))
    j--;

  temp[j] = '\0';
  strcpy (string, temp);
  free (temp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* filename_non_directory ( char *  pathname)

Definition at line 633 of file info-utils.c.

{
  register char *filename = pathname + strlen (pathname);

  if (HAVE_DRIVE (pathname))
    pathname += 2;

  while (filename > pathname && !IS_SLASH (filename[-1]))
    filename--;

  return (filename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

WINDOW* get_internal_info_window ( char *  name)

Definition at line 678 of file info-utils.c.

{
  WINDOW *win;

  for (win = windows; win; win = win->next)
    if (internal_info_node_p (win->node) &&
        (strcmp (win->node->nodename, name) == 0))
      break;

  return (win);
}

Here is the call graph for this function:

Definition at line 692 of file info-utils.c.

{
  WINDOW *win = (WINDOW *)NULL;

  for (win = windows; win; win = win->next)
    if (win->node == node)
      break;

  return (win);
}

Here is the caller graph for this function:

Definition at line 351 of file info-utils.c.

{
  register int i, j;
  REFERENCE **result;
  int size;

  /* With one argument passed as NULL, simply return the other arg. */
  if (!ref1)
    return (ref2);
  else if (!ref2)
    return (ref1);

  /* Get the total size of the slots that we will need. */
  for (i = 0; ref1[i]; i++);
  size = i;
  for (i = 0; ref2[i]; i++);
  size += i;

  result = (REFERENCE **)xmalloc ((1 + size) * sizeof (REFERENCE *));

  /* Copy the contents over. */
  for (i = 0; ref1[i]; i++)
    result[i] = ref1[i];

  j = i;
  for (i = 0; ref2[i]; i++)
    result[j++] = ref2[i];

  result[j] = (REFERENCE *)NULL;
  free (ref1);
  free (ref2);
  return (result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 391 of file info-utils.c.

{
  REFERENCE *dest = xmalloc (sizeof (REFERENCE));
  dest->label = src->label ? xstrdup (src->label) : NULL;
  dest->filename = src->filename ? xstrdup (src->filename) : NULL;
  dest->nodename = src->nodename ? xstrdup (src->nodename) : NULL;
  dest->start = src->start;
  dest->end = src->end;
  
  return dest;
}

Here is the call graph for this function:

void info_free_references ( REFERENCE **  references)

Definition at line 407 of file info-utils.c.

{
  register int i;
  REFERENCE *entry;

  if (references)
    {
      for (i = 0; references && (entry = references[i]); i++)
        {
          maybe_free (entry->label);
          maybe_free (entry->filename);
          maybe_free (entry->nodename);

          free (entry);
        }

      free (references);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

REFERENCE* info_get_labeled_reference ( char *  label,
REFERENCE **  references 
)

Definition at line 334 of file info-utils.c.

{
  register int i;
  REFERENCE *entry;

  for (i = 0; references && (entry = references[i]); i++)
    {
      if (strcmp (label, entry->label) == 0)
        return (entry);
    }
  return ((REFERENCE *)NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 223 of file info-utils.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 172 of file info-utils.c.

{
  long position;
  SEARCH_BINDING tmp_search;
  REFERENCE **menu = (REFERENCE **)NULL;

  tmp_search.buffer = node->contents;
  tmp_search.start = 0;
  tmp_search.end = node->nodelen;
  tmp_search.flags = S_FoldCase;

  /* Find the start of the menu. */
  position = search_forward (INFO_MENU_LABEL, &tmp_search);

  if (position == -1)
    return ((REFERENCE **) NULL);

  /* We have the start of the menu now.  Glean menu items from the rest
     of the node. */
  tmp_search.start = position + strlen (INFO_MENU_LABEL);
  tmp_search.start += skip_line (tmp_search.buffer + tmp_search.start);
  tmp_search.start--;
  menu = info_menu_items (&tmp_search);
  return (menu);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void info_parse_label ( char *  label,
NODE node 
)

Definition at line 142 of file info-utils.c.

{
  register int i;
  char *nodeline;

  /* Default answer to failure. */
  save_nodename ((char *)NULL);
  save_filename ((char *)NULL);

  /* Find the label in the first line of this node. */
  nodeline = node->contents;
  i = string_in_line (label, nodeline);

  if (i == -1)
    return;

  nodeline += i;
  nodeline += skip_whitespace (nodeline);
  info_parse_node (nodeline, DONT_SKIP_NEWLINES);
}

Here is the call graph for this function:

void info_parse_node ( char *  string,
int  newlines_okay 
)

Definition at line 60 of file info-utils.c.

{
  register int i = 0;

  /* Default the answer. */
  save_filename ((char *)NULL);
  save_nodename ((char *)NULL);

  /* Special case of nothing passed.  Return nothing. */
  if (!string || !*string)
    return;

  string += skip_whitespace (string);

  /* Check for (FILENAME)NODENAME. */
  if (*string == '(')
    {
      i = 0;
      /* Advance past the opening paren. */
      string++;

      /* Find the closing paren. */
      while (string[i] && string[i] != ')')
        i++;

      /* Remember parsed filename. */
      saven_filename (string, i);

      /* Point directly at the nodename. */
      string += i;

      if (*string)
        string++;
    }

  /* Parse out nodename. */
  i = skip_node_characters (string, newlines_okay);
  saven_nodename (string, i);
  canonicalize_whitespace (info_parsed_nodename);
  if (info_parsed_nodename && !*info_parsed_nodename)
    {
      free (info_parsed_nodename);
      info_parsed_nodename = (char *)NULL;
    }

  /* Parse ``(line ...)'' part of menus, if any.  */
  {
    char *rest = string + i;

    /* Advance only if it's not already at end of string.  */
    if (*rest)
      rest++;

    /* Skip any whitespace first, and then a newline in case the item
       was so long to contain the ``(line ...)'' string in the same
       physical line.  */
    while (whitespace(*rest))
      rest++;
    if (*rest == '\n')
      {
        rest++;
        while (whitespace(*rest))
          rest++;
      }

    /* Are we looking at an opening parenthesis?  That can only mean
       we have a winner. :)  */
    if (strncmp (rest, "(line ", strlen ("(line ")) == 0)
      {
        rest += strlen ("(line ");
        info_parsed_line_number = strtol (rest, NULL, 0);
      }
    else
      info_parsed_line_number = 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static REFERENCE ** info_references_internal ( char *  label,
SEARCH_BINDING binding 
) [static]

Definition at line 240 of file info-utils.c.

{
  SEARCH_BINDING tmp_search;
  REFERENCE **refs = (REFERENCE **)NULL;
  int refs_index = 0, refs_slots = 0;
  int searching_for_menu_items = 0;
  long position;

  tmp_search.buffer = binding->buffer;
  tmp_search.start = binding->start;
  tmp_search.end = binding->end;
  tmp_search.flags = S_FoldCase | S_SkipDest;

  searching_for_menu_items = (strcasecmp (label, INFO_MENU_ENTRY_LABEL) == 0);

  while ((position = search_forward (label, &tmp_search)) != -1)
    {
      int offset, start;
      char *refdef;
      REFERENCE *entry;

      tmp_search.start = position;
      tmp_search.start += skip_whitespace (tmp_search.buffer + tmp_search.start);
      start = tmp_search.start - binding->start;
      refdef = tmp_search.buffer + tmp_search.start;
      offset = string_in_line (":", refdef);

      /* When searching for menu items, if no colon, there is no
         menu item on this line. */
      if (offset == -1)
        {
          if (searching_for_menu_items)
            continue;
          else
            {
              int temp;

              temp = skip_line (refdef);
              offset = string_in_line (":", refdef + temp);
              if (offset == -1)
                continue;       /* Give up? */
              else
                offset += temp;
            }
        }

      entry = (REFERENCE *)xmalloc (sizeof (REFERENCE));
      entry->filename = (char *)NULL;
      entry->nodename = (char *)NULL;
      entry->label = (char *)xmalloc (offset);
      strncpy (entry->label, refdef, offset - 1);
      entry->label[offset - 1] = '\0';
      canonicalize_whitespace (entry->label);

      refdef += offset;
      entry->start = start;
      entry->end = refdef - binding->buffer;

      /* If this reference entry continues with another ':' then the
         nodename is the same as the label. */
      if (*refdef == ':')
        {
          entry->nodename = xstrdup (entry->label);
        }
      else
        {
          /* This entry continues with a specific nodename.  Parse the
             nodename from the specification. */

          refdef += skip_whitespace_and_newlines (refdef);

          if (searching_for_menu_items)
            info_parse_node (refdef, DONT_SKIP_NEWLINES);
          else
            info_parse_node (refdef, SKIP_NEWLINES);

          if (info_parsed_filename)
            entry->filename = xstrdup (info_parsed_filename);

          if (info_parsed_nodename)
            entry->nodename = xstrdup (info_parsed_nodename);

          entry->line_number = info_parsed_line_number;
        }

      add_pointer_to_array
        (entry, refs_index, refs, refs_slots, 50, REFERENCE *);
    }
  return (refs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file info-utils.c.

{
  return (info_references_internal (INFO_XREF_LABEL, binding));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 202 of file info-utils.c.

{
  SEARCH_BINDING tmp_search;

#if defined (HANDLE_MAN_PAGES)
  if (node->flags & N_IsManPage)
    return (xrefs_of_manpage (node));
#endif

  tmp_search.buffer = node->contents;
  tmp_search.start = 0;
  tmp_search.end = node->nodelen;
  tmp_search.flags = S_FoldCase;

  return (info_xrefs (&tmp_search));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 648 of file info-utils.c.

{
#if defined (NEVER)
  if (node &&
      (node->filename && !*node->filename) &&
      !node->parent && node->nodename)
    return (1);
  else
    return (0);
#else
  return ((node != (NODE *)NULL) && ((node->flags & N_IsInternal) != 0));
#endif /* !NEVER */
}

Here is the caller graph for this function:

void name_internal_node ( NODE node,
char *  name 
)

Definition at line 664 of file info-utils.c.

{
  if (!node)
    return;

  node->filename = "";
  node->parent = (char *)NULL;
  node->nodename = name;
  node->flags |= N_IsInternal;
}

Here is the caller graph for this function:

char* printed_representation ( unsigned char  character,
int  hpos 
)

Definition at line 485 of file info-utils.c.

{
  register int i = 0;
  int printable_limit = ISO_Latin_p ? 255 : 127;

  if (raw_escapes_p && character == '\033')
    the_rep[i++] = character;
  /* Show CTRL-x as ^X.  */
  else if (iscntrl (character) && character < 127)
    {
      switch (character)
        {
        case '\r':
        case '\n':
          the_rep[i++] = character;
          break;

        case '\t':
          {
            int tw;

            tw = ((hpos + 8) & 0xf8) - hpos;
            while (i < tw)
              the_rep[i++] = ' ';
          }
          break;

        default:
          the_rep[i++] = '^';
          the_rep[i++] = (character | 0x40);
        }
    }
  /* Show META-x as 0370.  */
  else if (character > printable_limit)
    {
      sprintf (the_rep + i, "\\%0o", character);
      i = strlen (the_rep);
    }
  else if (character == DEL)
    {
      the_rep[i++] = '^';
      the_rep[i++] = '?';
    }
  else
    the_rep[i++] = character;

  the_rep[i] = 0;

  return the_rep;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void save_filename ( char *  filename) [static]

Definition at line 556 of file info-utils.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void save_nodename ( char *  nodename) [static]

Definition at line 572 of file info-utils.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void save_string ( char *  string,
char **  string_p,
int string_size_p 
) [static]

Definition at line 589 of file info-utils.c.

{
  if (!string || !*string)
    {
      if (*string_p)
        free (*string_p);

      *string_p = (char *)NULL;
      *string_size_p = 0;
    }
  else
    {
      if (strlen (string) >= (unsigned int) *string_size_p)
        *string_p = (char *)xrealloc
          (*string_p, (*string_size_p = 1 + strlen (string)));

      strcpy (*string_p, string);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void saven_filename ( char *  filename,
int  len 
) [static]

Definition at line 563 of file info-utils.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void saven_nodename ( char *  nodename,
int  len 
) [static]

Definition at line 579 of file info-utils.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void saven_string ( char *  string,
int  len,
char **  string_p,
int string_size_p 
) [static]

Definition at line 611 of file info-utils.c.

{
  if (!string)
    {
      if (*string_p)
        free (*string_p);

      *string_p = (char *)NULL;
      *string_size_p = 0;
    }
  else
    {
      if (len >= *string_size_p)
        *string_p = (char *)xrealloc (*string_p, (*string_size_p = 1 + len));

      strncpy (*string_p, string, len);
      (*string_p)[len] = '\0';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* info_parsed_filename = (char *)NULL

Definition at line 34 of file info-utils.c.

Definition at line 42 of file info-utils.c.

char* info_parsed_nodename = (char *)NULL

Definition at line 38 of file info-utils.c.

Definition at line 30 of file info-utils.c.

int parsed_filename_size = 0 [static]

Definition at line 544 of file info-utils.c.

int parsed_nodename_size = 0 [static]

Definition at line 547 of file info-utils.c.

char the_rep[10] [static]

Definition at line 480 of file info-utils.c.