integrated Ville Laurikari's TRE
This commit is contained in:
@ -26,6 +26,7 @@ pkginclude_HEADERS = \
|
||||
str.h \
|
||||
time.h \
|
||||
tio.h \
|
||||
tre.h \
|
||||
xma.h
|
||||
|
||||
if ENABLE_CXX
|
||||
|
@ -53,8 +53,8 @@ SOURCES =
|
||||
DIST_SOURCES =
|
||||
am__pkginclude_HEADERS_DIST = alg.h chr.h dll.h env.h fio.h fma.h \
|
||||
gdl.h htb.h lda.h main.h map.h mem.h misc.h oht.h opt.h pio.h \
|
||||
pma.h rbt.h rex.h sio.h sll.h stdio.h str.h time.h tio.h xma.h \
|
||||
Mmgr.hpp StdMmgr.hpp Mmged.hpp
|
||||
pma.h rbt.h rex.h sio.h sll.h stdio.h str.h time.h tio.h tre.h \
|
||||
xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
@ -225,7 +225,7 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkginclude_HEADERS = alg.h chr.h dll.h env.h fio.h fma.h gdl.h htb.h \
|
||||
lda.h main.h map.h mem.h misc.h oht.h opt.h pio.h pma.h rbt.h \
|
||||
rex.h sio.h sll.h stdio.h str.h time.h tio.h xma.h \
|
||||
rex.h sio.h sll.h stdio.h str.h time.h tio.h tre.h xma.h \
|
||||
$(am__append_1)
|
||||
all: all-am
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: dll.h 474 2011-05-23 16:52:37Z hyunghwan.chung $
|
||||
* $Id: dll.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -257,7 +257,7 @@ void qse_dll_close (
|
||||
/**
|
||||
* The qse_dll_init() function initializes a statically declared list.
|
||||
*/
|
||||
qse_dll_t* qse_dll_init (
|
||||
int qse_dll_init (
|
||||
qse_dll_t* dll, /**< doubly linked list */
|
||||
qse_mmgr_t* mmgr /**< memory manager */
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ void qse_env_close (
|
||||
qse_env_t* env
|
||||
);
|
||||
|
||||
qse_env_t* qse_env_init (
|
||||
int qse_env_init (
|
||||
qse_env_t* env,
|
||||
qse_mmgr_t* mmgr,
|
||||
int fromcurenv
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fio.h 550 2011-08-14 15:59:55Z hyunghwan.chung $
|
||||
* $Id: fio.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -152,7 +152,7 @@ void qse_fio_close (
|
||||
/***
|
||||
* The qse_fio_close() function opens a file into @a fio.
|
||||
*/
|
||||
qse_fio_t* qse_fio_init (
|
||||
int qse_fio_init (
|
||||
qse_fio_t* fio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* path,
|
||||
|
@ -232,7 +232,7 @@ void qse_fma_close (
|
||||
* The qse_fma_init() function initializes an memory allocator statically
|
||||
* declared.
|
||||
*/
|
||||
qse_fma_t* qse_fma_init (
|
||||
int qse_fma_init (
|
||||
qse_fma_t* fma, /**< memory allocator */
|
||||
qse_mmgr_t* mmgr, /**< outer memory manager */
|
||||
qse_size_t blksize, /**< fixed block size in bytes */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: htb.h 477 2011-05-24 04:22:40Z hyunghwan.chung $
|
||||
* $Id: htb.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -341,7 +341,7 @@ void qse_htb_close (
|
||||
/**
|
||||
* The qse_htb_init() function initializes a hash table
|
||||
*/
|
||||
qse_htb_t* qse_htb_init (
|
||||
int qse_htb_init (
|
||||
qse_htb_t* htb, /**< hash table */
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
qse_size_t capa, /**< initial capacity */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lda.h 479 2011-05-24 15:14:58Z hyunghwan.chung $
|
||||
* $Id: lda.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -176,7 +176,7 @@ void qse_lda_close (
|
||||
/**
|
||||
* The qse_lda_init() function initializes a linear dynamic array.
|
||||
*/
|
||||
qse_lda_t* qse_lda_init (
|
||||
int qse_lda_init (
|
||||
qse_lda_t* lda,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa
|
||||
|
@ -165,10 +165,9 @@ void qse_oht_close (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_open() function initializes a statically declared
|
||||
* open-addressed hash table.
|
||||
* The qse_oht_open() function initializes an open-addressed hash table.
|
||||
*/
|
||||
qse_oht_t* qse_oht_init (
|
||||
int qse_oht_init (
|
||||
qse_oht_t* oht,
|
||||
qse_mmgr_t* mmgr,
|
||||
int scale,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: pio.h 539 2011-08-10 16:18:35Z hyunghwan.chung $
|
||||
* $Id: pio.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -117,6 +117,7 @@ enum qse_pio_errnum_t
|
||||
{
|
||||
QSE_PIO_ENOERR = 0, /**< no error */
|
||||
QSE_PIO_ENOMEM, /**< out of memory */
|
||||
QSE_PIO_EINVAL, /**< out of memory */
|
||||
QSE_PIO_ENOHND, /**< no handle available */
|
||||
QSE_PIO_ECHILD, /**< the child is not valid */
|
||||
QSE_PIO_EINTR, /**< interrupted */
|
||||
@ -223,9 +224,9 @@ void qse_pio_close (
|
||||
* The qse_pio_init() functions performs the same task as the qse_pio_open()
|
||||
* except that you need to allocate a #qse_pio_t structure and pass it to the
|
||||
* function.
|
||||
* @return @a pio on success, #QSE_NULL on failure
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
qse_pio_t* qse_pio_init (
|
||||
int qse_pio_init (
|
||||
qse_pio_t* pio, /**< pio object */
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
const qse_char_t* cmd, /**< command to execute */
|
||||
|
@ -71,7 +71,7 @@ void qse_pma_close (
|
||||
qse_pma_t* pma /**< memory allocator */
|
||||
);
|
||||
|
||||
qse_pma_t* qse_pma_init (
|
||||
int qse_pma_init (
|
||||
qse_pma_t* pma, /**< memory allocator */
|
||||
qse_mmgr_t* mmgr /**< memory manager */
|
||||
);
|
||||
|
@ -301,7 +301,7 @@ void qse_rbt_close (
|
||||
/**
|
||||
* The qse_rbt_init() function initializes a red-black tree
|
||||
*/
|
||||
qse_rbt_t* qse_rbt_init (
|
||||
int qse_rbt_init (
|
||||
qse_rbt_t* rbt, /**< red-black tree */
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
int kscale, /**< key scale */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: rex.h 462 2011-05-18 14:36:40Z hyunghwan.chung $
|
||||
* $Id: rex.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -210,7 +210,7 @@ void qse_rex_close (
|
||||
qse_rex_t* rex
|
||||
);
|
||||
|
||||
qse_rex_t* qse_rex_init (
|
||||
int qse_rex_init (
|
||||
qse_rex_t* rex,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_rex_node_t* code
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sio.h 547 2011-08-13 16:04:14Z hyunghwan.chung $
|
||||
* $Id: sio.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -92,7 +92,7 @@ void qse_sio_close (
|
||||
qse_sio_t* sio /**< stream */
|
||||
);
|
||||
|
||||
qse_sio_t* qse_sio_init (
|
||||
int qse_sio_init (
|
||||
qse_sio_t* sio,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* file,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sll.h 474 2011-05-23 16:52:37Z hyunghwan.chung $
|
||||
* $Id: sll.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -192,12 +192,11 @@ void qse_sll_close (
|
||||
* to it. The caller may declare a static variable of the qse_sll_t type
|
||||
* and pass its address. A memory manager still needs to be passed for
|
||||
* node manipulation later.
|
||||
*
|
||||
* @return
|
||||
* @return 0 on success, -1 on failure
|
||||
* The qse_sll_init() function returns the first parameter on success and
|
||||
* QSE_NULL on failure.
|
||||
*/
|
||||
qse_sll_t* qse_sll_init (
|
||||
int qse_sll_init (
|
||||
qse_sll_t* sll, /* singly linked list */
|
||||
qse_mmgr_t* mmgr /* memory manager */
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 550 2011-08-14 15:59:55Z hyunghwan.chung $
|
||||
* $Id: str.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -877,6 +877,19 @@ int qse_wcsxncasecmp (
|
||||
qse_size_t ln2 /**< length of the second string */
|
||||
);
|
||||
|
||||
int qse_mbszcmp (
|
||||
const qse_mchar_t* s1,
|
||||
const qse_mchar_t* s2,
|
||||
qse_size_t n
|
||||
);
|
||||
|
||||
int qse_wcszcmp (
|
||||
const qse_wchar_t* s1,
|
||||
const qse_wchar_t* s2,
|
||||
qse_size_t n
|
||||
);
|
||||
|
||||
|
||||
#ifdef QSE_CHAR_IS_MCHAR
|
||||
# define qse_strcmp(s1,s2) qse_mbscmp(s1,s2)
|
||||
# define qse_strxcmp(s1,ln1,s2) qse_mbsxcmp(s1,ln1,s2)
|
||||
@ -884,6 +897,7 @@ int qse_wcsxncasecmp (
|
||||
# define qse_strcasecmp(s1,s2) qse_mbscasecmp(s1,s2)
|
||||
# define qse_strxcasecmp(s1,ln1,s2) qse_mbsxcasecmp(s1,ln1,s2)
|
||||
# define qse_strxncasecmp(s1,ln1,s2,ln2) qse_mbsxncasecmp(s1,ln1,s2,ln2)
|
||||
# define qse_strzcmp(s1,s2,n) qse_mbszcmp(s1,s2,n)
|
||||
#else
|
||||
# define qse_strcmp(s1,s2) qse_wcscmp(s1,s2)
|
||||
# define qse_strxcmp(s1,ln1,s2) qse_wcsxcmp(s1,ln1,s2)
|
||||
@ -891,6 +905,7 @@ int qse_wcsxncasecmp (
|
||||
# define qse_strcasecmp(s1,s2) qse_wcscasecmp(s1,s2)
|
||||
# define qse_strxcasecmp(s1,ln1,s2) qse_wcsxcasecmp(s1,ln1,s2)
|
||||
# define qse_strxncasecmp(s1,ln1,s2,ln2) qse_wcsxncasecmp(s1,ln1,s2,ln2)
|
||||
# define qse_strzcmp(s1,s2,n) qse_wcszcmp(s1,s2,n)
|
||||
#endif
|
||||
|
||||
qse_mchar_t* qse_mbsdup (
|
||||
@ -2265,9 +2280,9 @@ void qse_mbs_close (
|
||||
* The qse_mbs_init() function initializes a dynamically resizable string
|
||||
* If the parameter capa is 0, it doesn't allocate the internal buffer
|
||||
* in advance and always succeeds.
|
||||
* @return @a mbs on success, #QSE_NULL on failure.
|
||||
* @return 0 on success, -1 on failure.
|
||||
*/
|
||||
qse_mbs_t* qse_mbs_init (
|
||||
int qse_mbs_init (
|
||||
qse_mbs_t* mbs,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa
|
||||
@ -2439,9 +2454,9 @@ void qse_wcs_close (
|
||||
* The qse_wcs_init() function initializes a dynamically resizable string
|
||||
* If the parameter capa is 0, it doesn't allocate the internal buffer
|
||||
* in advance and always succeeds.
|
||||
* @return @a wcs on success, #QSE_NULL on failure.
|
||||
* @return 0 on success, -1 on failure.
|
||||
*/
|
||||
qse_wcs_t* qse_wcs_init (
|
||||
int qse_wcs_init (
|
||||
qse_wcs_t* wcs,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t capa
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tio.h 554 2011-08-22 05:26:26Z hyunghwan.chung $
|
||||
* $Id: tio.h 556 2011-08-31 15:43:46Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -126,7 +126,7 @@ QSE_DEFINE_COMMON_FUNCTIONS (tio)
|
||||
*/
|
||||
qse_tio_t* qse_tio_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t ext
|
||||
qse_size_t xtnsize
|
||||
);
|
||||
|
||||
/**
|
||||
@ -140,8 +140,8 @@ int qse_tio_close (
|
||||
* The qse_tio_init() function initialize a statically declared
|
||||
* text stream processor.
|
||||
*/
|
||||
qse_tio_t* qse_tio_init (
|
||||
qse_tio_t* tip,
|
||||
int qse_tio_init (
|
||||
qse_tio_t* tio,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
|
134
qse/include/qse/cmn/tre.h
Normal file
134
qse/include/qse/cmn/tre.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_TRE_TRE_H_
|
||||
#define _QSE_TRE_TRE_H_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
enum qse_tre_errnum_t
|
||||
{
|
||||
QSE_TRE_ENOERR,
|
||||
QSE_TRE_ENOMEM, /* Out of memory */
|
||||
QSE_TRE_ENOMATCH, /* No match */
|
||||
QSE_TRE_EBADPAT, /* Invalid regular expression */
|
||||
QSE_TRE_ECOLLATE, /* Unknown collating element */
|
||||
QSE_TRE_ECTYPE, /* Unknown character class name */
|
||||
QSE_TRE_EESCAPE, /* Traling backslash */
|
||||
QSE_TRE_ESUBREG, /* Invalid backreference */
|
||||
QSE_TRE_EBRACK, /* "[]" imbalance */
|
||||
QSE_TRE_EPAREN, /* "\(\)" or "()" imbalance */
|
||||
QSE_TRE_EBRACE, /* "\{\}" or "{}" imbalance */
|
||||
QSE_TRE_EBADBR, /* Invalid content of {} */
|
||||
QSE_TRE_ERANGE, /* Invalid use of range operator */
|
||||
QSE_TRE_EBADRPT /* Invalid use of repetition operators */
|
||||
};
|
||||
typedef enum qse_tre_errnum_t qse_tre_errnum_t;
|
||||
|
||||
typedef struct qse_tre_t qse_tre_t;
|
||||
struct qse_tre_t
|
||||
{
|
||||
qse_mmgr_t* mmgr;
|
||||
qse_tre_errnum_t errnum;
|
||||
|
||||
qse_size_t re_nsub; /* Number of parenthesized subexpressions. */
|
||||
void* value; /* For internal use only. */
|
||||
};
|
||||
|
||||
#define QSE_TRE_ERRNUM(tre) ((const qse_tre_errnum_t)((tre)->errnum))
|
||||
|
||||
typedef int qse_tre_off_t;
|
||||
|
||||
typedef struct qse_tre_match_t qse_tre_match_t;
|
||||
struct qse_tre_match_t
|
||||
{
|
||||
qse_tre_off_t rm_so;
|
||||
qse_tre_off_t rm_eo;
|
||||
};
|
||||
|
||||
enum qse_tre_cflag_t
|
||||
{
|
||||
QSE_TRE_EXTENDED = (1 << 0),
|
||||
QSE_TRE_IGNORECASE = (1 << 1),
|
||||
QSE_TRE_NEWLINE = (1 << 2),
|
||||
QSE_TRE_NOSUBREG = (1 << 3),
|
||||
QSE_TRE_LITERAL = (1 << 4),
|
||||
QSE_TRE_RIGHTASSOC = (1 << 5),
|
||||
QSE_TRE_UNGREEDY = (1 << 6)
|
||||
};
|
||||
|
||||
enum qse_tre_eflag_t
|
||||
{
|
||||
QSE_TRE_NOTBOL = (1 << 0),
|
||||
QSE_TRE_NOTEOL = (1 << 1),
|
||||
QSE_TRE_BACKTRACKING = (1 << 2)
|
||||
};
|
||||
|
||||
typedef struct qse_tre_strsrc_t qse_tre_strsrc_t;
|
||||
struct qse_tre_strsrc_t
|
||||
{
|
||||
int (*get_next_char) (qse_char_t *c, unsigned int* pos_add, void* context);
|
||||
void (*rewind)(qse_size_t pos, void *context);
|
||||
int (*compare)(qse_size_t pos1, qse_size_t pos2, qse_size_t len, void* context);
|
||||
void* context;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int qse_tre_init (
|
||||
qse_tre_t* tre,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
void qse_tre_fini (
|
||||
qse_tre_t* tre
|
||||
);
|
||||
|
||||
|
||||
int qse_tre_compx (
|
||||
qse_tre_t* tre,
|
||||
const qse_char_t* regex,
|
||||
qse_size_t n,
|
||||
int cflags
|
||||
);
|
||||
|
||||
int qse_tre_comp (
|
||||
qse_tre_t* tre,
|
||||
const qse_char_t* regex,
|
||||
int cflags
|
||||
);
|
||||
|
||||
int qse_tre_execx (
|
||||
qse_tre_t* tre,
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
qse_size_t nmatch,
|
||||
qse_tre_match_t pmatch[],
|
||||
int eflags
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -150,9 +150,9 @@ void qse_xma_close (
|
||||
* to this function instead of calling qse_xma_open(). It obtains a memory zone
|
||||
* of @a zonesize bytes with the memory manager @a mmgr. Unlike qse_xma_open(),
|
||||
* it does not accept the extension size, thus not creating an extention area.
|
||||
* @return @a xma on success, #QSE_NULL on failure
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
qse_xma_t* qse_xma_init (
|
||||
int qse_xma_init (
|
||||
qse_xma_t* xma, /**< memory allocator */
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
qse_size_t zonesize /**< zone size in bytes */
|
||||
|
@ -127,7 +127,7 @@ void qse_htrd_close (
|
||||
qse_htrd_t* htrd
|
||||
);
|
||||
|
||||
qse_htrd_t* qse_htrd_init (
|
||||
int qse_htrd_init (
|
||||
qse_htrd_t* htrd,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
@ -129,7 +129,7 @@ typedef int (*qse_htre_header_walker_t) (
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_htre_t* qse_htre_init (
|
||||
int qse_htre_init (
|
||||
qse_htre_t* re,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
Reference in New Issue
Block a user