Back to index

tetex-bin  3.0
Functions | Variables
path-elt.c File Reference
#include <kpathsea/config.h>
#include <kpathsea/c-pathch.h>
#include <kpathsea/pathsearch.h>

Go to the source code of this file.

Functions

static string element P2C (const_string, passed_path, boolean, env_p)
string kpse_path_element P1C (const_string, p)

Variables

static string elt = NULL
static unsigned elt_alloc = 0
static const_string path = NULL

Function Documentation

string kpse_filename_component P1C ( const_string  ,
p   
)

Definition at line 94 of file path-elt.c.

{
  return element (p, true);
}
static string element P2C ( const_string  ,
passed_path  ,
boolean  ,
env_p   
) [static]

Definition at line 43 of file path-elt.c.

{
  const_string p;
  string ret;
  int brace_level;
  unsigned len;
  
  if (passed_path)
    path = passed_path;
  /* Check if called with NULL, and no previous path (perhaps we reached
     the end).  */
  else if (!path)
    return NULL;
  
  /* OK, we have a non-null `path' if we get here.  */
  assert (path);
  p = path;
  
  /* Find the next colon not enclosed by braces (or the end of the path).  */
  brace_level = 0;
  while (*p != 0  && !(brace_level == 0
                       && (env_p ? IS_ENV_SEP (*p) : IS_DIR_SEP (*p)))) {
    if (*p == '{') ++brace_level;
    else if (*p == '}') --brace_level;
    ++p;
  }
   
  /* Return the substring starting at `path'.  */
  len = p - path;

  /* Make sure we have enough space (including the null byte).  */
  if (len + 1 > elt_alloc)
    {
      elt_alloc = len + 1;
      elt = (string)xrealloc (elt, elt_alloc);
    }

  strncpy (elt, path, len);
  elt[len] = 0;
  ret = elt;

  /* If we are at the end, return NULL next time.  */
  if (path[len] == 0)
    path = NULL;
  else
    path += len + 1;

  return ret;
}

Here is the call graph for this function:


Variable Documentation

string elt = NULL [static]

Definition at line 27 of file path-elt.c.

unsigned elt_alloc = 0 [static]

Definition at line 28 of file path-elt.c.

const_string path = NULL [static]

Definition at line 31 of file path-elt.c.