tin  2.4.5
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.5.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcretest.c File Reference
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <locale.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "pcre_internal.h"
#include "pcre_tables.c"
#include "pcre_printint.src"
#include "pcreposix.h"
Include dependency graph for pcretest.c:

Go to the source code of this file.

Macros

#define INPUT_MODE   "rb"
 
#define OUTPUT_MODE   "wb"
 
#define PCRE_SPY   /* For Win32 build, import data, not export */
 
#define _pcre_utf8_table1   utf8_table1
 
#define _pcre_utf8_table1_size   utf8_table1_size
 
#define _pcre_utf8_table2   utf8_table2
 
#define _pcre_utf8_table3   utf8_table3
 
#define _pcre_utf8_table4   utf8_table4
 
#define _pcre_utt   utt
 
#define _pcre_utt_size   utt_size
 
#define _pcre_OP_lengths   OP_lengths
 
#define PRINTHEX(c)   (locale_set? isprint(c) : PRINTABLE(c))
 
#define CLOCKS_PER_SEC   100
 
#define LOOPREPEAT   500000
 

Functions

static uscharextend_inputline (FILE *f, uschar *start)
 
static int get_value (unsigned char *str, unsigned char **endptr)
 
static int utf82ord (unsigned char *utf8bytes, int *vptr)
 
static int ord2utf8 (int cvalue, uschar *utf8bytes)
 
static int pchars (unsigned char *p, int length, FILE *f)
 
static int callout (pcre_callout_block *cb)
 
static void * new_malloc (size_t size)
 
static void new_free (void *block)
 
static void * stack_malloc (size_t size)
 
static void stack_free (void *block)
 
static void new_info (pcre *re, pcre_extra *study, int option, void *ptr)
 
static unsigned long int byteflip (unsigned long int value, int n)
 
static int check_match_limit (pcre *re, pcre_extra *extra, uschar *bptr, int len, int start_offset, int options, int *use_offsets, int use_size_offsets, int flag, unsigned long int *limit, int errnumber, const char *msg)
 
static int check_newline (uschar *p, FILE *f)
 
static void usage (void)
 
int main (int argc, char **argv)
 

Variables

static FILE * outfile
 
static int log_store = 0
 
static int callout_count
 
static int callout_extra
 
static int callout_fail_count
 
static int callout_fail_id
 
static int first_callout
 
static int locale_set = 0
 
static int show_malloc
 
static int use_utf8
 
static size_t gotten_store
 
static int buffer_size = 50000
 
static uscharbuffer = NULL
 
static uschardbuffer = NULL
 
static uscharpbuffer = NULL
 

Macro Definition Documentation

◆ _pcre_OP_lengths

#define _pcre_OP_lengths   OP_lengths

Definition at line 90 of file pcretest.c.

◆ _pcre_utf8_table1

#define _pcre_utf8_table1   utf8_table1

Definition at line 83 of file pcretest.c.

◆ _pcre_utf8_table1_size

#define _pcre_utf8_table1_size   utf8_table1_size

Definition at line 84 of file pcretest.c.

◆ _pcre_utf8_table2

#define _pcre_utf8_table2   utf8_table2

Definition at line 85 of file pcretest.c.

◆ _pcre_utf8_table3

#define _pcre_utf8_table3   utf8_table3

Definition at line 86 of file pcretest.c.

◆ _pcre_utf8_table4

#define _pcre_utf8_table4   utf8_table4

Definition at line 87 of file pcretest.c.

◆ _pcre_utt

#define _pcre_utt   utt

Definition at line 88 of file pcretest.c.

◆ _pcre_utt_size

#define _pcre_utt_size   utt_size

Definition at line 89 of file pcretest.c.

◆ CLOCKS_PER_SEC

#define CLOCKS_PER_SEC   100

Definition at line 129 of file pcretest.c.

◆ INPUT_MODE

#define INPUT_MODE   "rb"

PCRE testing program *

Definition at line 65 of file pcretest.c.

◆ LOOPREPEAT

#define LOOPREPEAT   500000

Definition at line 135 of file pcretest.c.

◆ OUTPUT_MODE

#define OUTPUT_MODE   "wb"

Definition at line 66 of file pcretest.c.

◆ PCRE_SPY

#define PCRE_SPY   /* For Win32 build, import data, not export */

Definition at line 70 of file pcretest.c.

◆ PRINTHEX

#define PRINTHEX (   c)    (locale_set? isprint(c) : PRINTABLE(c))

Definition at line 106 of file pcretest.c.

Function Documentation

◆ byteflip()

static unsigned long int byteflip ( unsigned long int  value,
int  n 
)
static

Byte flipping function *

Definition at line 588 of file pcretest.c.

Referenced by main().

◆ callout()

◆ check_match_limit()

static int check_match_limit ( pcre re,
pcre_extra extra,
uschar bptr,
int  len,
int  start_offset,
int  options,
int *  use_offsets,
int  use_size_offsets,
int  flag,
unsigned long int *  limit,
int  errnumber,
const char *  msg 
)
static

Check match or recursion limit *

Definition at line 605 of file pcretest.c.

References pcre_extra::flags, outfile, PCRE_ERROR_NOMATCH, PCRE_ERROR_PARTIAL, and pcre_exec().

Referenced by main().

◆ check_newline()

static int check_newline ( uschar p,
FILE *  f 
)
static

Check newline indicator *

Definition at line 666 of file pcretest.c.

References PCRE_NEWLINE_ANY, PCRE_NEWLINE_CR, PCRE_NEWLINE_CRLF, and PCRE_NEWLINE_LF.

Referenced by main().

◆ extend_inputline()

static uschar* extend_inputline ( FILE *  f,
uschar start 
)
static

Read or extend an input line *

Definition at line 183 of file pcretest.c.

References buffer, buffer_size, dbuffer, and pbuffer.

Referenced by main().

◆ get_value()

static int get_value ( unsigned char *  str,
unsigned char **  endptr 
)
static

Read number from string *

Definition at line 257 of file pcretest.c.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Main Program *

Definition at line 718 of file pcretest.c.

References buffer, buffer_size, byteflip(), callout(), callout_count, pcre_extra::callout_data, callout_extra, callout_fail_count, callout_fail_id, check_match_limit(), check_newline(), CLOCKS_PER_SEC, dbuffer, debug, errno, extend_inputline(), FALSE, real_pcre::first_byte, first_callout, pcre_extra::flags, GET2, get_value(), gotten_store, INPUT_MODE, locale_set, log_store, LOOPREPEAT, MAGIC_NUMBER, real_pcre::magic_number, pcre_extra::match_limit, pcre_extra::match_limit_recursion, real_pcre::name_count, real_pcre::name_entry_size, real_pcre::name_table_offset, new_free(), new_info(), new_malloc(), real_pcre::options, pcre_study_data::options, ord2utf8(), outfile, OUTPUT_MODE, pbuffer, pchars(), PCRE_ANCHORED, PCRE_AUTO_CALLOUT, pcre_callout, PCRE_CASELESS, pcre_compile(), pcre_config(), PCRE_CONFIG_LINK_SIZE, PCRE_CONFIG_MATCH_LIMIT, PCRE_CONFIG_MATCH_LIMIT_RECURSION, PCRE_CONFIG_NEWLINE, PCRE_CONFIG_POSIX_MALLOC_THRESHOLD, PCRE_CONFIG_STACKRECURSE, PCRE_CONFIG_UNICODE_PROPERTIES, PCRE_CONFIG_UTF8, pcre_copy_named_substring(), pcre_copy_substring(), pcre_dfa_exec(), PCRE_DFA_RESTART, PCRE_DFA_SHORTEST, PCRE_DOLLAR_ENDONLY, PCRE_DOTALL, PCRE_DUPNAMES, PCRE_ERROR_MATCHLIMIT, PCRE_ERROR_NOMATCH, PCRE_ERROR_PARTIAL, PCRE_ERROR_RECURSIONLIMIT, pcre_exec(), PCRE_EXTENDED, PCRE_EXTRA, PCRE_EXTRA_CALLOUT_DATA, PCRE_EXTRA_MATCH_LIMIT, PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_STUDY_DATA, PCRE_FIRSTLINE, pcre_free, pcre_free_substring(), pcre_free_substring_list(), pcre_get_named_substring(), pcre_get_stringnumber(), pcre_get_substring(), pcre_get_substring_list(), pcre_info(), PCRE_INFO_BACKREFMAX, PCRE_INFO_CAPTURECOUNT, PCRE_INFO_FIRSTBYTE, PCRE_INFO_FIRSTTABLE, PCRE_INFO_LASTLITERAL, PCRE_INFO_NAMECOUNT, PCRE_INFO_NAMEENTRYSIZE, PCRE_INFO_NAMETABLE, PCRE_INFO_OPTIONS, PCRE_INFO_SIZE, pcre_maketables(), pcre_malloc, PCRE_MULTILINE, PCRE_NEWLINE_ANY, PCRE_NEWLINE_BITS, PCRE_NEWLINE_CR, PCRE_NEWLINE_CRLF, PCRE_NEWLINE_LF, PCRE_NO_AUTO_CAPTURE, PCRE_NO_UTF8_CHECK, PCRE_NOPARTIAL, PCRE_NOTBOL, PCRE_NOTEMPTY, PCRE_NOTEOL, PCRE_PARTIAL, pcre_stack_free, pcre_stack_malloc, pcre_study(), PCRE_UNGREEDY, PCRE_UTF8, pcre_version(), PRINTHEX, quiet, regex_t::re_pcre, REG_DOTALL, REG_ICASE, REG_NEWLINE, REG_NOSUB, REG_NOTBOL, REG_NOTEOL, REG_UTF8, regcomp(), regerror(), regexec(), regfree(), real_pcre::req_byte, REQ_CASELESS, setlocale, show_malloc, real_pcre::size, pcre_study_data::size, stack_free(), stack_malloc(), strerror(), pcre_extra::study_data, real_pcre::top_backref, real_pcre::top_bracket, usage(), and use_utf8.

◆ new_free()

static void new_free ( void *  block)
static

Definition at line 542 of file pcretest.c.

References outfile, and show_malloc.

Referenced by main().

◆ new_info()

static void new_info ( pcre re,
pcre_extra study,
int  option,
void *  ptr 
)
static

Call pcre_fullinfo() *

Definition at line 574 of file pcretest.c.

References outfile, and pcre_fullinfo().

Referenced by main().

◆ new_malloc()

static void* new_malloc ( size_t  size)
static

Local malloc functions *

Definition at line 533 of file pcretest.c.

References gotten_store, outfile, and show_malloc.

Referenced by main().

◆ ord2utf8()

static int ord2utf8 ( int  cvalue,
uschar utf8bytes 
)
static

Convert character value to UTF-8 *

Definition at line 348 of file pcretest.c.

Referenced by main().

◆ pchars()

static int pchars ( unsigned char *  p,
int  length,
FILE *  f 
)
static

Print character string *

Definition at line 375 of file pcretest.c.

References PRINTHEX, use_utf8, and utf82ord().

Referenced by callout(), internal_dfa_exec(), main(), match(), match_ref(), and pcre_exec().

◆ stack_free()

static void stack_free ( void *  block)
static

Definition at line 560 of file pcretest.c.

References outfile, and show_malloc.

Referenced by main().

◆ stack_malloc()

static void* stack_malloc ( size_t  size)
static

Definition at line 552 of file pcretest.c.

References outfile, and show_malloc.

Referenced by main().

◆ usage()

static void usage ( void  )
static

Usage function *

Definition at line 683 of file pcretest.c.

Referenced by main().

◆ utf82ord()

static int utf82ord ( unsigned char *  utf8bytes,
int *  vptr 
)
static

Convert UTF-8 string to value *

Definition at line 287 of file pcretest.c.

References utf8_table3.

Referenced by pchars().

Variable Documentation

◆ buffer

◆ buffer_size

int buffer_size = 50000
static

Definition at line 153 of file pcretest.c.

Referenced by extend_inputline(), and main().

◆ callout_count

int callout_count
static

Definition at line 141 of file pcretest.c.

Referenced by callout(), and main().

◆ callout_extra

int callout_extra
static

Definition at line 142 of file pcretest.c.

Referenced by callout(), and main().

◆ callout_fail_count

int callout_fail_count
static

Definition at line 143 of file pcretest.c.

Referenced by callout(), and main().

◆ callout_fail_id

int callout_fail_id
static

Definition at line 144 of file pcretest.c.

Referenced by callout(), and main().

◆ dbuffer

uschar* dbuffer = NULL
static

Definition at line 155 of file pcretest.c.

Referenced by extend_inputline(), and main().

◆ first_callout

int first_callout
static

Definition at line 145 of file pcretest.c.

Referenced by callout(), and main().

◆ gotten_store

size_t gotten_store
static

Definition at line 149 of file pcretest.c.

Referenced by main(), and new_malloc().

◆ locale_set

int locale_set = 0
static

Definition at line 146 of file pcretest.c.

Referenced by main().

◆ log_store

int log_store = 0
static

Definition at line 140 of file pcretest.c.

Referenced by main().

◆ outfile

◆ pbuffer

uschar* pbuffer = NULL
static

Definition at line 156 of file pcretest.c.

Referenced by callout(), extend_inputline(), and main().

◆ show_malloc

int show_malloc
static

Definition at line 147 of file pcretest.c.

Referenced by main(), new_free(), new_malloc(), stack_free(), and stack_malloc().

◆ use_utf8

int use_utf8
static

Definition at line 148 of file pcretest.c.

Referenced by main(), and pchars().