Back to index

php5  5.3.10
Functions | Variables
regposerr.c File Reference
#include "config.h"
#include "onigposix.h"
#include <strings.h>
#include <stdio.h>

Go to the source code of this file.

Functions

size_t regerror (int posix_ecode, const regex_t *reg, char *buf, size_t size)

Variables

static char * ESTRING []

Function Documentation

size_t regerror ( int  posix_ecode,
const regex_t reg,
char *  buf,
size_t  size 
)

Definition at line 66 of file regposerr.c.

{
  char* s;
  char tbuf[35];
  size_t len;

  if (posix_ecode > 0 && posix_ecode < sizeof(ESTRING) / sizeof(ESTRING[0])) {
    s = ESTRING[posix_ecode];
  }
  else if (posix_ecode == 0) {
    s = "";
  }
  else {
    sprintf(tbuf, "undefined error code (%d)", posix_ecode);
    s = tbuf;
  }

  len = strlen(s) + 1; /* use strlen() because s is ascii encoding. */

  if (buf != NULL && size > 0) {
    strncpy(buf, s, size - 1);
    buf[size - 1] = '\0';
  }
  return len;
}

Variable Documentation

char* ESTRING[] [static]
Initial value:
 {
  NULL,
  "failed to match",                         
  "Invalid regular expression",              
  "invalid collating element referenced",    
  "invalid character class type referenced", 
  "bad backslash-escape sequence",           
  "invalid back reference number",           
  "imbalanced [ and ]",                      
  "imbalanced ( and )",                      
  "imbalanced { and }",                      
  "invalid repeat range {n,m}",              
  "invalid range",                           
  "Out of memory",                           
  "? * + not preceded by valid regular expression", 

  
  "internal error",                          
  "invalid wide char value",                 
  "invalid argument",                        
  "multi-thread error"                       
}

Definition at line 39 of file regposerr.c.