XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
libregexp.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include "cutils.h"
#include "libregexp.h"
#include "libunicode.h"
#include "libregexp-opcode.h"
Include dependency graph for libregexp.c:

Classes

struct  REParseState
 
struct  REOpCode
 
struct  REString
 
struct  REStringList
 
union  StackElem
 
struct  REExecContext
 

Macros

#define DEF(id, size)   REOP_ ## id,
 
#define CAPTURE_COUNT_MAX   255
 
#define REGISTER_COUNT_MAX   255
 
#define INTERRUPT_COUNTER_INIT   10000
 
#define CP_LS   0x2028
 
#define CP_PS   0x2029
 
#define TMP_BUF_SIZE   128
 
#define DEF(id, size)   { size },
 
#define RE_HEADER_FLAGS   0
 
#define RE_HEADER_CAPTURE_COUNT   2
 
#define RE_HEADER_REGISTER_COUNT   3
 
#define RE_HEADER_BYTECODE_LEN   4
 
#define RE_HEADER_LEN   8
 
#define CLASS_RANGE_BASE   0x40000000
 
#define GET_CHAR(c, cptr, cbuf_end, cbuf_type)
 
#define PEEK_CHAR(c, cptr, cbuf_end, cbuf_type)
 
#define PEEK_PREV_CHAR(c, cptr, cbuf_start, cbuf_type)
 
#define GET_PREV_CHAR(c, cptr, cbuf_start, cbuf_type)
 
#define PREV_CHAR(cptr, cbuf_start, cbuf_type)
 
#define BP_TYPE_BITS   3
 
#define CHECK_STACK_SPACE(n)
 
#define SAVE_CAPTURE(idx, value)
 
#define SAVE_CAPTURE_CHECK(idx, value)
 

Typedefs

typedef struct REString REString
 

Enumerations

enum  REOPCodeEnum { REOP_COUNT }
 
enum  CharRangeEnum {
  CHAR_RANGE_d , CHAR_RANGE_D , CHAR_RANGE_s , CHAR_RANGE_S ,
  CHAR_RANGE_w , CHAR_RANGE_W
}
 
enum  REExecStateEnum { RE_EXEC_STATE_SPLIT , RE_EXEC_STATE_LOOKAHEAD , RE_EXEC_STATE_NEGATIVE_LOOKAHEAD }
 

Functions

int lre_parse_escape (const uint8_t **pp, int allow_utf16)
 
uint8_t * lre_compile (int *plen, char *error_msg, int error_msg_size, const char *buf, size_t buf_len, int re_flags, void *opaque)
 
int lre_exec (uint8_t **capture, const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen, int cbuf_type, void *opaque)
 
int lre_get_alloc_count (const uint8_t *bc_buf)
 
int lre_get_capture_count (const uint8_t *bc_buf)
 
int lre_get_flags (const uint8_t *bc_buf)
 
const char * lre_get_groupnames (const uint8_t *bc_buf)
 

Macro Definition Documentation

◆ BP_TYPE_BITS

#define BP_TYPE_BITS   3

◆ CAPTURE_COUNT_MAX

#define CAPTURE_COUNT_MAX   255

◆ CHECK_STACK_SPACE

#define CHECK_STACK_SPACE (   n)
Value:
if (unlikely((stack_end - sp) < (n))) { \
size_t saved_sp = sp - s->stack_buf; \
size_t saved_bp = bp - s->stack_buf; \
if (stack_realloc(s, sp - s->stack_buf + (n))) \
stack_end = s->stack_buf + s->stack_size; \
sp = s->stack_buf + saved_sp; \
bp = s->stack_buf + saved_bp; \
}
#define unlikely(x)
Definition compiler.h:30
#define LRE_RET_MEMORY_ERROR
Definition libregexp.h:40

◆ CLASS_RANGE_BASE

#define CLASS_RANGE_BASE   0x40000000

◆ CP_LS

#define CP_LS   0x2028

◆ CP_PS

#define CP_PS   0x2029

◆ DEF [1/2]

#define DEF (   id,
  size 
)    REOP_ ## id,

◆ DEF [2/2]

#define DEF (   id,
  size 
)    { size },

◆ GET_CHAR

#define GET_CHAR (   c,
  cptr,
  cbuf_end,
  cbuf_type 
)
Value:
do { \
if (cbuf_type == 0) { \
c = *cptr++; \
} else { \
const uint16_t *_p = (const uint16_t *)cptr; \
const uint16_t *_end = (const uint16_t *)cbuf_end; \
c = *_p++; \
if (is_hi_surrogate(c) && cbuf_type == 2) { \
if (_p < _end && is_lo_surrogate(*_p)) { \
c = from_surrogate(c, *_p++); \
} \
} \
cptr = (const void *)_p; \
} \
} while (0)
unsigned short int uint16_t
Definition acefiex.h:162

◆ GET_PREV_CHAR

#define GET_PREV_CHAR (   c,
  cptr,
  cbuf_start,
  cbuf_type 
)
Value:
do { \
if (cbuf_type == 0) { \
cptr--; \
c = cptr[0]; \
} else { \
const uint16_t *_p = (const uint16_t *)cptr - 1; \
const uint16_t *_start = (const uint16_t *)cbuf_start; \
c = *_p; \
if (is_lo_surrogate(c) && cbuf_type == 2) { \
if (_p > _start && is_hi_surrogate(_p[-1])) { \
c = from_surrogate(*--_p, c); \
} \
} \
cptr = (const void *)_p; \
} \
} while (0)

◆ INTERRUPT_COUNTER_INIT

#define INTERRUPT_COUNTER_INIT   10000

◆ PEEK_CHAR

#define PEEK_CHAR (   c,
  cptr,
  cbuf_end,
  cbuf_type 
)
Value:
do { \
if (cbuf_type == 0) { \
c = cptr[0]; \
} else { \
const uint16_t *_p = (const uint16_t *)cptr; \
const uint16_t *_end = (const uint16_t *)cbuf_end; \
c = *_p++; \
if (is_hi_surrogate(c) && cbuf_type == 2) { \
if (_p < _end && is_lo_surrogate(*_p)) { \
c = from_surrogate(c, *_p); \
} \
} \
} \
} while (0)

◆ PEEK_PREV_CHAR

#define PEEK_PREV_CHAR (   c,
  cptr,
  cbuf_start,
  cbuf_type 
)
Value:
do { \
if (cbuf_type == 0) { \
c = cptr[-1]; \
} else { \
const uint16_t *_p = (const uint16_t *)cptr - 1; \
const uint16_t *_start = (const uint16_t *)cbuf_start; \
c = *_p; \
if (is_lo_surrogate(c) && cbuf_type == 2) { \
if (_p > _start && is_hi_surrogate(_p[-1])) { \
c = from_surrogate(*--_p, c); \
} \
} \
} \
} while (0)

◆ PREV_CHAR

#define PREV_CHAR (   cptr,
  cbuf_start,
  cbuf_type 
)
Value:
do { \
if (cbuf_type == 0) { \
cptr--; \
} else { \
const uint16_t *_p = (const uint16_t *)cptr - 1; \
const uint16_t *_start = (const uint16_t *)cbuf_start; \
if (is_lo_surrogate(*_p) && cbuf_type == 2) { \
if (_p > _start && is_hi_surrogate(_p[-1])) { \
--_p; \
} \
} \
cptr = (const void *)_p; \
} \
} while (0)

◆ RE_HEADER_BYTECODE_LEN

#define RE_HEADER_BYTECODE_LEN   4

◆ RE_HEADER_CAPTURE_COUNT

#define RE_HEADER_CAPTURE_COUNT   2

◆ RE_HEADER_FLAGS

#define RE_HEADER_FLAGS   0

◆ RE_HEADER_LEN

#define RE_HEADER_LEN   8

◆ RE_HEADER_REGISTER_COUNT

#define RE_HEADER_REGISTER_COUNT   3

◆ REGISTER_COUNT_MAX

#define REGISTER_COUNT_MAX   255

◆ SAVE_CAPTURE

#define SAVE_CAPTURE (   idx,
  value 
)
Value:
{ \
CHECK_STACK_SPACE(2); \
sp[0].val = idx; \
sp[1].ptr = capture[idx]; \
sp += 2; \
capture[idx] = (value); \
}

◆ SAVE_CAPTURE_CHECK

#define SAVE_CAPTURE_CHECK (   idx,
  value 
)
Value:
{ \
StackElem *sp1; \
sp1 = sp; \
for(;;) { \
if (sp1 > bp) { \
if (sp1[-2].val == idx) \
break; \
sp1 -= 2; \
} else { \
CHECK_STACK_SPACE(2); \
sp[0].val = idx; \
sp[1].ptr = capture[idx]; \
sp += 2; \
break; \
} \
} \
capture[idx] = (value); \
}
Definition libregexp.c:2716

◆ TMP_BUF_SIZE

#define TMP_BUF_SIZE   128

Typedef Documentation

◆ REString

typedef struct REString REString

Enumeration Type Documentation

◆ CharRangeEnum

Enumerator
CHAR_RANGE_d 
CHAR_RANGE_D 
CHAR_RANGE_s 
CHAR_RANGE_S 
CHAR_RANGE_w 
CHAR_RANGE_W 

◆ REExecStateEnum

Enumerator
RE_EXEC_STATE_SPLIT 
RE_EXEC_STATE_LOOKAHEAD 
RE_EXEC_STATE_NEGATIVE_LOOKAHEAD 

◆ REOPCodeEnum

Enumerator
REOP_COUNT 

Function Documentation

◆ lre_compile()

uint8_t * lre_compile ( int *  plen,
char *  error_msg,
int  error_msg_size,
const char *  buf,
size_t  buf_len,
int  re_flags,
void *  opaque 
)

◆ lre_exec()

int lre_exec ( uint8_t **  capture,
const uint8_t *  bc_buf,
const uint8_t *  cbuf,
int  cindex,
int  clen,
int  cbuf_type,
void *  opaque 
)

◆ lre_get_alloc_count()

int lre_get_alloc_count ( const uint8_t *  bc_buf)

◆ lre_get_capture_count()

int lre_get_capture_count ( const uint8_t *  bc_buf)

◆ lre_get_flags()

int lre_get_flags ( const uint8_t *  bc_buf)

◆ lre_get_groupnames()

const char * lre_get_groupnames ( const uint8_t *  bc_buf)

◆ lre_parse_escape()

int lre_parse_escape ( const uint8_t **  pp,
int  allow_utf16 
)