Crossfire Server, Branch 1.12  R12190
Defines | Functions | Variables
re-cmp.c File Reference

Pattern match a string, parsing some of the common RE-metacharacters. More...

#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <limits.h>
#include <re-cmp.h>
#include <ctype.h>
#include <global.h>
#include <define.h>
Include dependency graph for re-cmp.c:

Go to the source code of this file.

Defines

#define exit_if_null

Functions

const char * re_cmp (const char *str, const char *regexp)
 re-cmp - get regular expression match.
static Boolean re_cmp_step (const char *str, const char *regexp, unsigned slot, int matches)
 Tries to match a string with a regexp.
static const char * re_get_token (selection *sel, const char *regexp)
 Get the first regular expression token found in regexp in sel.
static void re_init (void)
 Init the regular expression structures.
static Boolean re_match_token (uchar c, selection *sel)
 Tests if a char matches a token.

Variables

static Boolean re_init_done = False
static const char * re_substr [RE_TOKEN_MAX]
static selectionre_token [RE_TOKEN_MAX]
static unsigned int re_token_depth

Detailed Description

Pattern match a string, parsing some of the common RE-metacharacters.

This code is public domain, but I would appreciate to hear of improvements or even the fact that you use it in your program.

Deliberate BUGS:

Author: Kjetil T. Homme (kjetilho@ifi.uio.no) May 1993

Definition in file re-cmp.c.


Define Documentation

#define exit_if_null

Referenced by re_get_token().


Function Documentation

const char * re_cmp ( const char *  str,
const char *  regexp 
)

re-cmp - get regular expression match.

Parameters:
strstring that will be matched against the regexp.
regexpregular expression.
Returns:
  • no match or error in regexp.
  • pointer to beginning of matching string

Definition at line 70 of file re-cmp.c.

References Boolean, False, re_cmp(), re_cmp_step(), re_get_token(), re_init(), re_init_done, re_match_token(), re_substr, re_token_depth, rep_null_or_more, rep_null_or_once, rep_once, rep_once_or_more, and True.

Referenced by cfapi_system_re_cmp(), matches(), and re_cmp().

Here is the call graph for this function:

Here is the caller graph for this function:

static Boolean re_cmp_step ( const char *  str,
const char *  regexp,
unsigned  slot,
int  matches 
) [static]

Tries to match a string with a regexp.

Parameters:
strstring to match
regexppattern
slotnumber of the token which under consideration
matcheshow many times the token has matched
Returns:
True if match, False else.

Definition at line 191 of file re-cmp.c.

References Boolean, False, matches(), re_get_token(), re_match_token(), re_substr, re_token_depth, rep_null_or_more, rep_null_or_once, rep_once, rep_once_or_more, sel_end, and True.

Referenced by re_cmp().

Here is the call graph for this function:

Here is the caller graph for this function:

static const char * re_get_token ( selection sel,
const char *  regexp 
) [static]

Get the first regular expression token found in regexp in sel.

Parameters:
[out]selwhere to store the token.
regexpregular expression.
Returns:
  • NULL: syntax error
  • pointer to first character past token.

Definition at line 332 of file re-cmp.c.

References selection::array, Boolean, exit_if_null, False, selection::range, rep_null_or_more, rep_null_or_once, rep_once, rep_once_or_more, selection::repeat, sel_any, sel_array, sel_end, sel_not_range, sel_not_single, sel_range, sel_single, selection::single, True, selection::type, selection::u, and uchar.

Referenced by re_cmp(), and re_cmp_step().

Here is the caller graph for this function:

static void re_init ( void  ) [static]

Init the regular expression structures.

Note:
will fatal() in case of memory error.

Definition at line 272 of file re-cmp.c.

References fatal(), OUT_OF_MEMORY, re_init_done, RE_TOKEN_MAX, and True.

Referenced by re_cmp().

Here is the call graph for this function:

Here is the caller graph for this function:

static Boolean re_match_token ( uchar  c,
selection sel 
) [static]

Tests if a char matches a token.

Parameters:
cchar to test.
seltoken to test.
Returns:
True if matches, False else.

Definition at line 294 of file re-cmp.c.

References selection::array, False, selection::range, sel_any, sel_array, sel_end, sel_not_range, sel_not_single, sel_range, sel_single, selection::single, tolower, True, selection::type, and selection::u.

Referenced by re_cmp(), and re_cmp_step().

Here is the caller graph for this function:


Variable Documentation

Definition at line 51 of file re-cmp.c.

Referenced by re_cmp(), and re_init().

const char* re_substr[RE_TOKEN_MAX] [static]

Definition at line 53 of file re-cmp.c.

Referenced by re_cmp(), and re_cmp_step().

Definition at line 52 of file re-cmp.c.

unsigned int re_token_depth [static]

Definition at line 54 of file re-cmp.c.

Referenced by re_cmp(), and re_cmp_step().