G:/ScriptBasic/source/extensions/re/interface.c File Reference

#include <stdio.h>
#include <string.h>
#include "../../basext.h"
#include <sys/types.h>
#include "regex.h"

Go to the source code of this file.

Data Structures

struct  _ModuleObject
struct  list

Defines

#define RE_REG_NOMATCH   0x00080001
#define RE_REG_BADPAT   0x00080002
#define RE_REG_ECOLLATE   0x00080003
#define RE_REG_ECTYPE   0x00080004
#define RE_REG_EESCAPE   0x00080005
#define RE_REG_ESUBREG   0x00080006
#define RE_REG_EBRACK   0x00080007
#define RE_REG_EPAREN   0x00080008
#define RE_REG_EBRACE   0x00080009
#define RE_REG_BADBR   0x0008000A
#define RE_REG_ERANGE   0x0008000B
#define RE_REG_ESPACE   0x0008000C
#define RE_REG_BADRPT   0x0008000D
#define RE_REG_EMPTY   0x0008000E
#define RE_REG_ASSERT   0x0008000F
#define RE_REG_INVARG   0x00080010
#define reset_pmatches(p)
#define SBCASE   0x0001
#define SBNEWLINE   0x0002
#define ReleaseList(X)   release_list(pSt,(X))

Typedefs

typedef _ModuleObject ModuleObject
typedef _ModuleObjectpModuleObject

Functions

static int ConvertError (int Error)
besVERSION_NEGOTIATE return (int)
 if (if(p->iErrorRegcomp=regcomp(preg==NULL)
 besDEREFERENCE (vString)
 if (p->iErrorRegex=regexec(pmatch==NULL)
 besDEREFERENCE (vReplace)
 if (vReplace)
 besFREE (pmatch)
 besFREE (preg)
besEND besFUNCTION (nmatch)
 if (((unsigned) n))
 if (iError)
 besALLOC_RETURN_STRING (i)
static void release_list (pSupportTable pSt, struct list *p)
 besFUNCTION (replace)
 for (iStart=0;((unsigned) iStart)< STRLEN(vString);)
 if (((unsigned) iTerm)< STRLEN(vString))
 regfree (preg)
 for (item=root;item;item=item->next)
 ReleaseList (root)

Variables

 vRegexp = besCONVERT2STRING(vRegexp)
 preg = (regex_t *)besALLOC(sizeof(regex_t))
 nmatch = preg->re_nsub + 1
 vString = besARGUMENT(1)
 vString = besCONVERT2STRING(vString)
 pmatch = (regmatch_t *)besALLOC(sizeof(regmatch_t) * nmatch )
 vReplace = besARGUMENT(3)
 vReplace = besARGUMENT(1)
 vReplace = besCONVERT2STRING(vReplace)
 i = 0
 iError
 iError
 vRegexp = besCONVERT2STRING(vRegexp)
 preg = (regex_t *)besALLOC(sizeof(regex_t))
 nmatch = preg->re_nsub + 1
 vString = besARGUMENT(1)
 vString = besCONVERT2STRING(vString)
 vReplace = besARGUMENT(3)
 vReplace = besCONVERT2STRING(vReplace)
 i = 0
 i = 0


Define Documentation

#define RE_REG_ASSERT   0x0008000F
 

Definition at line 54 of file interface.c.

Referenced by ConvertError().

#define RE_REG_BADBR   0x0008000A
 

Definition at line 49 of file interface.c.

Referenced by ConvertError().

#define RE_REG_BADPAT   0x00080002
 

Definition at line 41 of file interface.c.

Referenced by ConvertError().

#define RE_REG_BADRPT   0x0008000D
 

Definition at line 52 of file interface.c.

Referenced by ConvertError().

#define RE_REG_EBRACE   0x00080009
 

Definition at line 48 of file interface.c.

Referenced by ConvertError().

#define RE_REG_EBRACK   0x00080007
 

Definition at line 46 of file interface.c.

Referenced by ConvertError().

#define RE_REG_ECOLLATE   0x00080003
 

Definition at line 42 of file interface.c.

Referenced by ConvertError().

#define RE_REG_ECTYPE   0x00080004
 

Definition at line 43 of file interface.c.

Referenced by ConvertError().

#define RE_REG_EESCAPE   0x00080005
 

Definition at line 44 of file interface.c.

Referenced by ConvertError().

#define RE_REG_EMPTY   0x0008000E
 

Definition at line 53 of file interface.c.

Referenced by ConvertError().

#define RE_REG_EPAREN   0x00080008
 

Definition at line 47 of file interface.c.

Referenced by ConvertError().

#define RE_REG_ERANGE   0x0008000B
 

Definition at line 50 of file interface.c.

Referenced by ConvertError().

#define RE_REG_ESPACE   0x0008000C
 

Definition at line 51 of file interface.c.

Referenced by ConvertError().

#define RE_REG_ESUBREG   0x00080006
 

Definition at line 45 of file interface.c.

Referenced by ConvertError().

#define RE_REG_INVARG   0x00080010
 

Definition at line 55 of file interface.c.

Referenced by ConvertError().

#define RE_REG_NOMATCH   0x00080001
 

Definition at line 40 of file interface.c.

Referenced by ConvertError().

#define ReleaseList  )     release_list(pSt,(X))
 

Definition at line 460 of file interface.c.

Referenced by if().

#define reset_pmatches p   ) 
 

Value:

if( p->lMatches ){\
   besFREE(p->lMatchLen);\
   p->lMatchLen = NULL;\
   besFREE(p->pszMatch);\
   p->pszMatch = NULL;\
   p->lMatches = 0;\
   }

Referenced by for(), and return().

#define SBCASE   0x0001
 

#define SBNEWLINE   0x0002
 


Typedef Documentation

typedef struct _ModuleObject ModuleObject
 

=H The module RE

This module implements some simple regular expression handling functions. They can be used to match some strings against regular expressions and to use matched sub strings to format replace strings. This module provides functions that are similar to the Perl language operators T<m//> and T<s///>.

typedef struct _ModuleObject * pModuleObject
 

=H The module RE

This module implements some simple regular expression handling functions. They can be used to match some strings against regular expressions and to use matched sub strings to format replace strings. This module provides functions that are similar to the Perl language operators T<m//> and T<s///>.


Function Documentation

besALLOC_RETURN_STRING i   ) 
 

besDEREFERENCE vReplace   ) 
 

besDEREFERENCE vString   ) 
 

besFREE preg   ) 
 

besFREE pmatch   ) 
 

besFUNCTION replace   ) 
 

=section replace =H Search and replace =verbatim re::replace(string,regexp,replace) re::s(string,regexp,replace) =noverbatim This function searches the string for matches of the regular expression and replaces the actual matches with the replace string. This is the same functionality as the T<=~s/> operator in Perl.

The function fills the R<dollar> array the same way as the function R<match>.

For example

=verbatim import re.bas

print re::s("almakbat*","a(.)","$1s") print print re::$(0)," ",re::$(1) print =noverbatim will print

=verbatim lsmksbts* at t =noverbatim

As you can see in this case the value of T<re::$(0)> is the string that was matched by the last replace inside the string.

Definition at line 494 of file interface.c.

References besALLOC_RETURN_LONG, besRETURNVALUE, and LONGVALUE().

besEND besFUNCTION nmatch   ) 
 

=section n =H number of matches

=verbatim re::n() =noverbatim return the number of usable matches substrings

Definition at line 327 of file interface.c.

References besCONVERT2LONG(), and LONGVALUE().

static int ConvertError int  Error  )  [static]
 

Definition at line 57 of file interface.c.

References RE_REG_ASSERT, RE_REG_BADBR, RE_REG_BADPAT, RE_REG_BADRPT, RE_REG_EBRACE, RE_REG_EBRACK, RE_REG_ECOLLATE, RE_REG_ECTYPE, RE_REG_EESCAPE, RE_REG_EMPTY, RE_REG_EPAREN, RE_REG_ERANGE, RE_REG_ESPACE, RE_REG_ESUBREG, RE_REG_INVARG, RE_REG_NOMATCH, REG_ASSERT, REG_BADBR, REG_BADPAT, REG_BADRPT, REG_EBRACE, REG_EBRACK, REG_ECOLLATE, REG_ECTYPE, REG_EESCAPE, REG_EMPTY, REG_EPAREN, REG_ERANGE, REG_ESPACE, REG_ESUBREG, REG_INVARG, and REG_NOMATCH.

for item  = root ; item ; item = item->next  ) 
 

Definition at line 726 of file interface.c.

for  ) 
 

Definition at line 554 of file interface.c.

References reset_pmatches.

if  ) 
 

Definition at line 696 of file interface.c.

References besFREE(), besRETURNVALUE, COMMAND_ERROR_SUCCESS, memcpy(), NULL, pmatch, preg, regfree(), ReleaseList, STRINGVALUE(), STRLEN(), and vString.

if iError   ) 
 

Definition at line 424 of file interface.c.

References besRETURNVALUE, COMMAND_ERROR_SUCCESS, and NULL.

if ((unsigned) n)   ) 
 

Definition at line 363 of file interface.c.

if vReplace  = NULL  ) 
 

Definition at line 276 of file interface.c.

References besALLOC_RETURN_STRING(), besCONVERT2STRING(), besFREE(), besRETURNVALUE, COMMAND_ERROR_SUCCESS, iError, NULL, pmatch, preg, regfree(), STRINGVALUE(), STRLEN(), and vReplace.

if p->iErrorRegex = regexec(  pmatch = NULL  ) 
 

Definition at line 224 of file interface.c.

if if( p->iErrorRegcomp = regcomp(  preg = NULL  ) 
 

Definition at line 196 of file interface.c.

regfree preg   ) 
 

Referenced by if(), and main().

static void release_list pSupportTable  pSt,
struct list p
[static]
 

Definition at line 450 of file interface.c.

References besFREE(), p, and q.

ReleaseList root   ) 
 

besVERSION_NEGOTIATE return int   ) 
 

Definition at line 82 of file interface.c.

References reset_pmatches.


Variable Documentation

i = 0
 

Definition at line 730 of file interface.c.

i = 0
 

Definition at line 725 of file interface.c.

i = 0
 

Definition at line 418 of file interface.c.

iError
 

Initial value:

  besMatchParameter(STRINGVALUE(vReplace),
                    STRLEN(vReplace),
                    p->pszMatch,
                    p->lMatchLen,
                    STRINGVALUE(besRETURNVALUE),
                    p->lMatches,
                    &(STRLEN(besRETURNVALUE)))

Definition at line 429 of file interface.c.

iError
 

Initial value:

  besMatchSize(STRINGVALUE(vReplace),
               STRLEN(vReplace),
               p->lMatchLen,
               p->lMatches,&i)

Definition at line 419 of file interface.c.

nmatch = preg->re_nsub + 1
 

Definition at line 542 of file interface.c.

nmatch = preg->re_nsub + 1
 

Definition at line 216 of file interface.c.

pmatch = (regmatch_t *)besALLOC(sizeof(regmatch_t) * nmatch )
 

Definition at line 223 of file interface.c.

Referenced by if(), and regexec().

preg = (regex_t *)besALLOC(sizeof(regex_t))
 

Definition at line 522 of file interface.c.

preg = (regex_t *)besALLOC(sizeof(regex_t))
 

Definition at line 195 of file interface.c.

Referenced by if(), and regerror().

vRegexp = besCONVERT2STRING(vRegexp)
 

Definition at line 521 of file interface.c.

vRegexp = besCONVERT2STRING(vRegexp)
 

Definition at line 194 of file interface.c.

vReplace = besCONVERT2STRING(vReplace)
 

Definition at line 552 of file interface.c.

vReplace = besARGUMENT(3)
 

Definition at line 550 of file interface.c.

vReplace = besCONVERT2STRING(vReplace)
 

Definition at line 417 of file interface.c.

vReplace = besARGUMENT(1)
 

Definition at line 412 of file interface.c.

vReplace = besARGUMENT(3)
 

Definition at line 274 of file interface.c.

Referenced by if().

vString = besCONVERT2STRING(vString)
 

Definition at line 547 of file interface.c.

vString = besARGUMENT(1)
 

Definition at line 544 of file interface.c.

vString = besCONVERT2STRING(vString)
 

Definition at line 221 of file interface.c.

vString = besARGUMENT(1)
 

Definition at line 218 of file interface.c.


Generated on Sun Mar 12 23:56:36 2006 for ScriptBasic by  doxygen 1.4.6-NO