Back to index

cell-binutils  2.17cvs20070401
Functions | Variables
concat.c File Reference
#include "ansidecl.h"
#include "libiberty.h"
#include <sys/types.h>
#include <stdarg.h>

Go to the source code of this file.

Functions

static unsigned long vconcat_length (const char *, va_list)
static char * vconcat_copy (char *dst, const char *first, va_list args)
unsigned long concat_length (const char *first,...)
char * concat_copy (char *dst, const char *first,...)
char * concat_copy2 (const char *first,...)
char * concat (const char *first,...)
char * reconcat (char *optr, const char *first,...)

Variables

char * libiberty_concat_ptr

Function Documentation

char* concat ( const char *  first,
  ... 
)

Definition at line 152 of file concat.c.

{
  char *newstr;

  /* First compute the size of the result and get sufficient memory.  */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
  VA_CLOSE (args);

  /* Now copy the individual pieces to the result string. */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (newstr, first, args);
  VA_CLOSE (args);

  return newstr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* concat_copy ( char *  dst,
const char *  first,
  ... 
)

Definition at line 116 of file concat.c.

{
  char *save_dst;

  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, dst);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (dst, first, args);
  save_dst = dst; /* With K&R C, dst goes out of scope here.  */
  VA_CLOSE (args);

  return save_dst;
}

Here is the call graph for this function:

char* concat_copy2 ( const char *  first,
  ... 
)

Definition at line 141 of file concat.c.

{
  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (libiberty_concat_ptr, first, args);
  VA_CLOSE (args);

  return libiberty_concat_ptr;
}

Here is the call graph for this function:

unsigned long concat_length ( const char *  first,
  ... 
)

Definition at line 101 of file concat.c.

{
  unsigned long length;

  VA_OPEN (args, first);
  VA_FIXEDARG (args, const char *, first);
  length = vconcat_length (first, args);
  VA_CLOSE (args);

  return length;
}

Here is the call graph for this function:

char* reconcat ( char *  optr,
const char *  first,
  ... 
)

Definition at line 189 of file concat.c.

{
  char *newstr;

  /* First compute the size of the result and get sufficient memory.  */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, optr);
  VA_FIXEDARG (args, const char *, first);
  newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
  VA_CLOSE (args);

  /* Now copy the individual pieces to the result string. */
  VA_OPEN (args, first);
  VA_FIXEDARG (args, char *, optr);
  VA_FIXEDARG (args, const char *, first);
  vconcat_copy (newstr, first, args);
  if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C.  */
    free (optr);
  VA_CLOSE (args);

  return newstr;
}

Here is the call graph for this function:

static char* vconcat_copy ( char *  dst,
const char *  first,
va_list  args 
) [inline, static]

Definition at line 82 of file concat.c.

{
  char *end = dst;
  const char *arg;

  for (arg = first; arg ; arg = va_arg (args, const char *))
    {
      unsigned long length = strlen (arg);
      memcpy (end, arg, length);
      end += length;
    }
  *end = '\000';

  return dst;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static unsigned long vconcat_length ( const char *  first,
va_list  args 
) [inline, static]

Definition at line 70 of file concat.c.

{
  unsigned long length = 0;
  const char *arg;

  for (arg = first; arg ; arg = va_arg (args, const char *))
    length += strlen (arg);

  return length;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 133 of file concat.c.