Back to index

glibc  2.9
Functions | Variables
regexp.h File Reference
#include <features.h>
#include <alloca.h>
#include <regex.h>
#include <stdlib.h>
#include <string.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * compile (char *__restrict instring, char *__restrict expbuf, __const char *__restrict endbuf, int eof)
int step (__const char *__restrict __string, __const char *__restrict __expbuf) __THROW
int advance (__const char *__restrict __string, __const char *__restrict __expbuf) __THROW

Variables

__BEGIN_DECLS char * loc1
char * loc2
char * locs

Function Documentation

int advance ( __const char *__restrict  __string,
__const char *__restrict  __expbuf 
)

Here is the caller graph for this function:

char* compile ( char *__restrict  instring,
char *__restrict  expbuf,
__const char *__restrict  endbuf,
int  eof 
)

Definition at line 103 of file regexp.h.

{
  char *__input_buffer = NULL;
  size_t __input_size = 0;
  size_t __current_size = 0;
  int __ch;
  int __error;
  INIT

  /* Align the expression buffer according to the needs for an object
     of type `regex_t'.  Then check for minimum size of the buffer for
     the compiled regular expression.  */
  regex_t *__expr_ptr;
# if defined __GNUC__ && __GNUC__ >= 2
  const size_t __req = __alignof__ (regex_t *);
# else
  /* How shall we find out?  We simply guess it and can change it is
     this really proofs to be wrong.  */
  const size_t __req = 8;
# endif
  expbuf += __req;
  expbuf -= (expbuf - ((char *) 0)) % __req;
  if (endbuf < expbuf + sizeof (regex_t))
    {
      ERROR (50);
    }
  __expr_ptr = (regex_t *) expbuf;
  /* The remaining space in the buffer can be used for the compiled
     pattern.  */
  __expr_ptr->__REPB_PREFIX (buffer) = expbuf + sizeof (regex_t);
  __expr_ptr->__REPB_PREFIX (allocated)
    = endbuf - (char *) __expr_ptr->__REPB_PREFIX (buffer);

  while ((__ch = (GETC ())) != eof)
    {
      if (__ch == '\0' || __ch == '\n')
       {
         UNGETC (__ch);
         break;
       }

      if (__current_size + 1 >= __input_size)
       {
         size_t __new_size = __input_size ? 2 * __input_size : 128;
         char *__new_room = (char *) alloca (__new_size);
         /* See whether we can use the old buffer.  */
         if (__new_room + __new_size == __input_buffer)
           {
             __input_size += __new_size;
             __input_buffer = (char *) memcpy (__new_room, __input_buffer,
                                          __current_size);
           }
         else if (__input_buffer + __input_size == __new_room)
           __input_size += __new_size;
         else
           {
             __input_size = __new_size;
             __input_buffer = (char *) memcpy (__new_room, __input_buffer,
                                          __current_size);
           }
       }
      __input_buffer[__current_size++] = __ch;
    }
  if (__current_size)
    __input_buffer[__current_size++] = '\0';
  else
    __input_buffer = "";

  /* Now compile the pattern.  */
  __error = regcomp (__expr_ptr, __input_buffer, REG_NEWLINE);
  if (__error != 0)
    /* Oh well, we have to translate POSIX error codes.  */
    switch (__error)
      {
      case REG_BADPAT:
      case REG_ECOLLATE:
      case REG_ECTYPE:
      case REG_EESCAPE:
      case REG_BADRPT:
      case REG_EEND:
      case REG_ERPAREN:
      default:
       /* There is no matching error code.  */
       RETURN (36);
      case REG_ESUBREG:
       RETURN (25);
      case REG_EBRACK:
       RETURN (49);
      case REG_EPAREN:
       RETURN (42);
      case REG_EBRACE:
       RETURN (44);
      case REG_BADBR:
       RETURN (46);
      case REG_ERANGE:
       RETURN (11);
      case REG_ESPACE:
      case REG_ESIZE:
       ERROR (50);
      }

  /* Everything is ok.  */
  RETURN ((char *) (__expr_ptr->__REPB_PREFIX (buffer)
                  + __expr_ptr->__REPB_PREFIX (used)));
}

Here is the call graph for this function:

int step ( __const char *__restrict  __string,
__const char *__restrict  __expbuf 
)

Here is the caller graph for this function:


Variable Documentation

Definition at line 25 of file regexp.c.

char* loc2

Definition at line 26 of file regexp.c.

char* locs

Definition at line 29 of file regexp.c.