Logo ROOT   6.12/07
Reference Guide
Macros | Enumerations | Functions
Match.cxx File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "Match.h"
Include dependency graph for Match.cxx:

Macros

#define ANY   '.'
 
#define BOL   '^'
 
#define CCL   '['
 
#define CCLEND   ']'
 
#define CLOSURE   '*'
 
#define E_ILLEGAL   1
 
#define E_NOMEM   2
 
#define E_NONE   0
 
#define E_PAT   3
 
#define EOL   '$'
 
#define ISHEXDIGIT(x)   isxdigit((unsigned char)x)
 
#define ISOCTDIGIT(x)   ('0'<=(x) && (x)<='7')
 
#define MAPSIZE   16
 
#define NCCL   '^'
 
#define OPT   '?'
 
#define PCLOSE   '+'
 

Enumerations

enum  Eaction {
  kBOL = (0x8000 | '^'), kEOL = (0x8000 | '$'), kANY = (0x8000 | '.'), kCCL = (0x8000 | '['),
  kOPT = (0x8000 | '?'), kCLOSE = (0x8000 | '*'), kPCLOSE = (0x8000 | '+'), kEND = (0x8000 | 0)
}
 

Functions

void ADVANCE (const Pattern_t *&pat)
 Advance a pointer into the pattern template to the next pattern element, this is a+1 for all pattern elements but kCCL, where you have to skip past both the kCCL character and the bitmap that follows that character. More...
 
static const char * doccl (Pattern_t *map, const char *src)
 Set bits in the map corresponding to characters specified in the src character class. More...
 
static int esc (const char **s)
 Map escape sequences into their equivalent symbols. More...
 
static int hex2bin (int c)
 Convert the hex digit represented by 'c' to an int. More...
 
int Makepat (const char *exp, Pattern_t *pat, int maxpat)
 Make a pattern template from the string pointed to by exp. More...
 
const char * Matchs (const char *str, size_t slen, const Pattern_t *pat, const char **startpat)
 Match a string with a pattern. More...
 
static int oct2bin (int c)
 Convert the hex digit represented by 'c' to an int. More...
 
static int omatch (const char **strp, size_t *slenp, const Pattern_t *pat, const char *start)
 Match one pattern element, pointed at by pat, against the character at **strp. More...
 
static const char * patcmp (const char *str, size_t slen, const Pattern_t *pat, const char *start)
 Like strcmp, but compares str against pat. More...
 
static void SETBIT (unsigned char b, Pattern_t *map)
 
static int TSTBIT (unsigned char b, const Pattern_t *map)
 

Macro Definition Documentation

◆ ANY

#define ANY   '.'

Definition at line 32 of file Match.cxx.

◆ BOL

#define BOL   '^'

Definition at line 30 of file Match.cxx.

◆ CCL

#define CCL   '['

Definition at line 33 of file Match.cxx.

◆ CCLEND

#define CCLEND   ']'

Definition at line 34 of file Match.cxx.

◆ CLOSURE

#define CLOSURE   '*'

Definition at line 36 of file Match.cxx.

◆ E_ILLEGAL

#define E_ILLEGAL   1

Definition at line 104 of file Match.cxx.

◆ E_NOMEM

#define E_NOMEM   2

Definition at line 105 of file Match.cxx.

◆ E_NONE

#define E_NONE   0

Definition at line 103 of file Match.cxx.

◆ E_PAT

#define E_PAT   3

Definition at line 106 of file Match.cxx.

◆ EOL

#define EOL   '$'

Definition at line 31 of file Match.cxx.

◆ ISHEXDIGIT

#define ISHEXDIGIT (   x)    isxdigit((unsigned char)x)

Definition at line 54 of file Match.cxx.

◆ ISOCTDIGIT

#define ISOCTDIGIT (   x)    ('0'<=(x) && (x)<='7')

Definition at line 61 of file Match.cxx.

◆ MAPSIZE

#define MAPSIZE   16

Definition at line 64 of file Match.cxx.

◆ NCCL

#define NCCL   '^'

Definition at line 35 of file Match.cxx.

◆ OPT

#define OPT   '?'

Definition at line 38 of file Match.cxx.

◆ PCLOSE

#define PCLOSE   '+'

Definition at line 37 of file Match.cxx.

Enumeration Type Documentation

◆ Eaction

enum Eaction
Enumerator
kBOL 
kEOL 
kANY 
kCCL 
kOPT 
kCLOSE 
kPCLOSE 
kEND 

Definition at line 40 of file Match.cxx.

Function Documentation

◆ ADVANCE()

void ADVANCE ( const Pattern_t *&  pat)
inline

Advance a pointer into the pattern template to the next pattern element, this is a+1 for all pattern elements but kCCL, where you have to skip past both the kCCL character and the bitmap that follows that character.

Definition at line 72 of file Match.cxx.

◆ doccl()

static const char * doccl ( Pattern_t map,
const char *  src 
)
static

Set bits in the map corresponding to characters specified in the src character class.

Definition at line 244 of file Match.cxx.

◆ esc()

static int esc ( const char **  s)
static

Map escape sequences into their equivalent symbols.

Return the equivalent ASCII character. *s is advanced past the escape sequence. If no escape sequence is present, the current character is returned and the string is advanced by one. The following are recognized:

  • \b backspace
  • \f formfeed
  • \n newline
  • \r carriage return
  • \s space
  • \t tab
  • \e ASCII ESC character ('\033')
  • \DDD number formed of 1-3 octal digits
  • \xDD number formed of 1-2 hex digits
  • \^C C = any letter. Control code

Definition at line 438 of file Match.cxx.

◆ hex2bin()

static int hex2bin ( int  c)
static

Convert the hex digit represented by 'c' to an int.

'c' must be one of: 0123456789abcdefABCDEF

Definition at line 406 of file Match.cxx.

◆ Makepat()

int Makepat ( const char *  exp,
Pattern_t pat,
int  maxpat 
)

Make a pattern template from the string pointed to by exp.

Stop when \0 is found in exp. The pattern template is assembled in pat whose length is given by maxpat.

Return:

  • E_ILLEGAL Illegal input pattern.
  • E_NOMEM out of memory.
  • E_PAT pattern too long.

Definition at line 129 of file Match.cxx.

◆ Matchs()

const char* Matchs ( const char *  str,
size_t  slen,
const Pattern_t pat,
const char **  startpat 
)

Match a string with a pattern.

Definition at line 220 of file Match.cxx.

◆ oct2bin()

static int oct2bin ( int  c)
static

Convert the hex digit represented by 'c' to an int.

'c' must be a digit in the range '0'-'7'.

Definition at line 415 of file Match.cxx.

◆ omatch()

static int omatch ( const char **  strp,
size_t *  slenp,
const Pattern_t pat,
const char *  start 
)
static

Match one pattern element, pointed at by pat, against the character at **strp.

Return 0 on a failure, 1 on success. *strp is advanced to skip over the matched character on a successful match. Closure is handled one level up by patcmp().

"start" points at the character at the left edge of the line. This might not be the same thing as *strp if the search is starting in the middle of the string. An end-of- line anchor matches end of string only.

Definition at line 369 of file Match.cxx.

◆ patcmp()

static const char * patcmp ( const char *  str,
size_t  slen,
const Pattern_t pat,
const char *  start 
)
static

Like strcmp, but compares str against pat.

Each element of str is compared with the template until either a mis-match is found or the end of the template is reached. In the former case a 0 is returned; in the latter, a pointer into str (pointing after the last character in the matched pattern) is returned. start points at the first character in the string, which might not be the same thing as str if the search started in the middle of the string.

Definition at line 287 of file Match.cxx.

◆ SETBIT()

static void SETBIT ( unsigned char  b,
Pattern_t map 
)
static

Definition at line 89 of file Match.cxx.

◆ TSTBIT()

static int TSTBIT ( unsigned char  b,
const Pattern_t map 
)
static

Definition at line 96 of file Match.cxx.