Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Version 1.20.0
- rtlib: When array out of bounds check files, show variable/field name, index, lbound, and ubound in the error message
- fbc: '-exx' enables '-earraydims' by default to error on wrong number of array dimensions or unallocated arrays breaking previous use of @array(0,...) = NULL to detect unallocated arrays
- fbc: set bit value '__FB_ERR__' = &h400 if '-earraydims' is enabled
- PEEK, POKE, and SWAP are now quirk words instead of keywords allowing these names to be used as member procedure names
- PEEK, POKE, and SWAP are now quirk words instead of keywords allowing these names to be used as member procedure names
- fbdoc: change CRegex.bas to use pcre2 since the libpcre (a.k.a pcre3) is obsolete in favour of pcre2 by upstream (Ahmad Khalifa)

[added]
- x86_64: optimize SHL MOD INTDIV to use 32-bit operation when result will be converted to long/ulong
Expand Down
6 changes: 4 additions & 2 deletions contrib/travis/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ if [ "$FBTRAVIS_TARGET_BITS" = "32" ]; then
libcurl4-openssl-dev:i386 \
libmysqlclient-dev:i386 \
libaspell-dev:i386 \
libpcre3-dev:i386
libpcre3-dev:i386 \
libpcre2-dev:i386
else
sudo apt-get -y --no-install-recommends install \
libncurses-dev \
Expand All @@ -40,7 +41,8 @@ else
libcurl4-openssl-dev \
libmysqlclient-dev \
libaspell-dev \
libpcre3-dev
libpcre3-dev \
libpcre2-dev
fi

source "$(dirname "$0")/bootstrap-settings.sh"
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/chkdocs.bas
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "funcs"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/getindex.bas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/getpage.bas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/insert.bas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

'' libs
#inclib "fbdoc"
#inclib "pcre"

using fb
using fbdoc
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/mkimglst.bas
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/mkprntoc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/putpage.bas
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include once "cmd_opts.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/rebuild.bas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

'' libs
#inclib "fbdoc"
#inclib "pcre"

using fb
using fbdoc
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/samps.bas
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include once "fbdoc_keywords.bi"

#inclib "fbdoc"
#inclib "pcre"

using fb
using fbdoc
Expand Down
1 change: 0 additions & 1 deletion doc/fbchkdoc/spell.bas
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include once "spellcheck.bi"

'' libs
#inclib "pcre"
#inclib "curl"

using fb
Expand Down
123 changes: 67 additions & 56 deletions doc/libfbdoc/CRegex.bas
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@
#endif
#endif

#include once "pcre.bi"
#define PCRE2_CODE_UNIT_WIDTH 8
#include once "pcre2.bi"

namespace fb

type CRegexCtx_
as pcre ptr reg
as pcre_extra ptr extra
as long ptr vectb
as zstring ptr subject
as integer sublen
as integer substrcnt
as zstring ptr ptr substrlist
as pcre2_code ptr code
as pcre2_compile_context ptr ccontext
as pcre2_match_data ptr matchdata
as PCRE2_SIZE ptr ovector
as zstring ptr subject
as integer sublen
as PCRE2_SIZE substrcnt
as zstring ptr ptr substrlist
end type

'':::::
Expand All @@ -52,21 +54,23 @@ namespace fb
byval options as REGEX_OPT _
)

dim as zstring ptr err_msg
dim as long err_ofs
dim as ulong errorflag
dim as integer erroffset

ctx = new CRegexCtx

'' Support any CR/LF/CRLF, no matter how libpcre was compiled
options or= PCRE_NEWLINE_ANYCRLF
'' Support any CR/LF/CRLF line ending
ctx->ccontext = pcre2_compile_context_create( NULL )
pcre2_set_newline(ctx->ccontext, PCRE2_NEWLINE_ANYCRLF)

ctx->code = pcre2_compile( pattern, PCRE2_ZERO_TERMINATED, _
options, @errorflag, @erroffset, ctx->ccontext )
ctx->matchdata = pcre2_match_data_create_from_pattern(ctx->code, NULL)

ctx->reg = pcre_compile( pattern, options, @err_msg, @err_ofs, NULL )
ctx->extra = pcre_study( ctx->reg, 0, @err_msg )
pcre_fullinfo( ctx->reg, ctx->extra, PCRE_INFO_CAPTURECOUNT, @ctx->substrcnt )
ctx->substrcnt += 1
ctx->vectb = allocate( sizeof( *ctx->vectb ) * (3 * ctx->substrcnt) )
ctx->substrlist = NULL
ctx->substrcnt = NULL
ctx->subject = NULL
ctx->ovector = NULL
ctx->sublen = 0

end constructor
Expand All @@ -78,7 +82,7 @@ namespace fb
)

if( ctx->substrlist <> NULL ) then
pcre_free_substring_list( ctx->substrlist )
pcre2_substring_list_free ( ctx->substrlist )
ctx->substrlist = NULL
end if

Expand All @@ -88,27 +92,26 @@ namespace fb
destructor CRegex _
( _
)

if( ctx = NULL ) then
exit destructor
end if

_ClearSubstrlist( ctx )

if( ctx->vectb <> NULL ) then
deallocate( ctx->vectb )
ctx->vectb = NULL
if( ctx->matchdata <> NULL ) then
pcre2_match_data_free(ctx->matchdata)
ctx->matchdata = NULL
end if
if( ctx->code <> NULL ) then
pcre2_code_free(ctx->code)
ctx->code = NULL
end if
if( ctx->ccontext <> NULL ) then
pcre2_compile_context_free( ctx->ccontext )
ctx->ccontext = NULL
end if

if( ctx->extra <> NULL ) then
pcre_free( ctx->extra )
ctx->extra = NULL
end if

if( ctx->reg <> NULL ) then
pcre_free( ctx->reg )
ctx->reg = NULL
end if


delete ctx

Expand All @@ -134,24 +137,28 @@ namespace fb
byval lgt as integer, _
byval options as REGEX_OPT _
) as integer

if( ctx = NULL ) then


if( ctx = NULL or ctx->code = NULL ) then
return FALSE
end if

_Clearsubstrlist( ctx )

ctx->subject = subject
ctx->sublen = iif( lgt >= 0, lgt, len( *subject ) )

'' Support any CR/LF/CRLF, no matter how libpcre was compiled
options or= PCRE_NEWLINE_ANYCRLF
Dim as Integer rc
rc = pcre2_match(ctx->code, ctx->subject, _
PCRE2_ZERO_TERMINATED, 0, options, _
ctx->matchdata, NULL)
if rc < 0 then
return FALSE
end if
ctx->substrcnt = rc
ctx->ovector = pcre2_get_ovector_pointer(ctx->matchdata)

function = ( pcre_exec( ctx->reg, ctx->extra, _
subject, ctx->sublen, _
0, options, _
ctx->vectb, 3 * ctx->substrcnt ) > 0 )

function = TRUE
end function

'':::::
Expand All @@ -160,20 +167,24 @@ namespace fb
byval options as REGEX_OPT _
) as integer

if( ctx = NULL ) then
if( ctx = NULL or ctx->code = NULL or ctx->ovector = NULL ) then
return FALSE
end if

_Clearsubstrlist( ctx )

'' Support any CR/LF/CRLF, no matter how libpcre was compiled
options or= PCRE_NEWLINE_ANYCRLF

function = ( pcre_exec( ctx->reg, ctx->extra, _
ctx->subject, ctx->sublen, _
ctx->vectb[1], options, _
ctx->vectb, 3 * ctx->substrcnt ) > 0 )
Dim as Integer rc, startoffset, startchar
startoffset = ctx->ovector[1]
rc = pcre2_match(ctx->code, ctx->subject, _
PCRE2_ZERO_TERMINATED, startoffset, options, _
ctx->matchdata, NULL)
if rc < 0 then
return FALSE
end if
ctx->substrcnt = rc
ctx->ovector = pcre2_get_ovector_pointer(ctx->matchdata)

function = TRUE
end function

'':::::
Expand All @@ -191,7 +202,7 @@ namespace fb
end if

if( ctx->substrlist = NULL ) then
pcre_get_substring_list( ctx->subject, ctx->vectb, ctx->substrcnt, @ctx->substrlist )
pcre2_substring_list_get ( ctx->matchdata, @ctx->substrlist, NULL)
end if

function = ctx->substrlist[i]
Expand All @@ -211,8 +222,8 @@ namespace fb
if( i >= ctx->substrcnt ) then
return -1
end if
function = ctx->vectb[i * 2 + 0]

function = ctx->ovector[i * 2 + 0]

end function

Expand All @@ -230,8 +241,8 @@ namespace fb
return -1
end if

function = ctx->vectb[i * 2 + 1] - ctx->vectb[i * 2 + 0]
function = ctx->ovector[i * 2 + 1] - ctx->ovector[i * 2 + 0]

end function

end namespace
37 changes: 20 additions & 17 deletions doc/libfbdoc/CRegex.bi
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,25 @@ namespace fb
type CRegexCtx as CRegexCtx_

enum REGEX_OPT
REGEX_OPT_CASELESS = &h0001
REGEX_OPT_MULTILINE = &h0002
REGEX_OPT_DOTALL = &h0004
REGEX_OPT_EXTENDED = &h0008
REGEX_OPT_ANCHORED = &h0010
REGEX_OPT_DOLLAR_ENDONLY = &h0020
REGEX_OPT_EXTRA_ = &h0040
REGEX_OPT_NOTBOL = &h0080
REGEX_OPT_NOTEOL = &h0100
REGEX_OPT_UNGREEDY = &h0200
REGEX_OPT_NOTEMPTY = &h0400
REGEX_OPT_UTF8 = &h0800
REGEX_OPT_NO_AUTO_CAPTURE = &h1000
REGEX_OPT_NO_UTF8_CHECK = &h2000
REGEX_OPT_AUTO_CALLOUT = &h4000
REGEX_OPT_PARTIAL = &h8000
'' Options for Compile
REGEX_OPT_AUTO_CALLOUT = &h00000004u
REGEX_OPT_CASELESS = &h00000008u
REGEX_OPT_DOLLAR_ENDONLY = &h00000010u
REGEX_OPT_DOTALL = &h00000020u
REGEX_OPT_EXTENDED = &h00000080u
REGEX_OPT_MULTILINE = &h00000400u
REGEX_OPT_NO_AUTO_CAPTURE = &h00002000u
REGEX_OPT_UNGREEDY = &h00040000u
REGEX_OPT_UTF8 = &h00080000u
'' Options for Match
REGEX_OPT_NOTBOL = &h00000001u
REGEX_OPT_NOTEOL = &h00000002u
REGEX_OPT_NOTEMPTY = &h00000004u
REGEX_OPT_PARTIAL_SOFT = &h00000010u
REGEX_OPT_PARTIAL_HARD = &h00000020u
'' Options for both
REGEX_OPT_NO_UTF8_CHECK = &h40000000u
REGEX_OPT_ANCHORED = &h80000000u
end enum

type CRegex
Expand Down Expand Up @@ -96,4 +99,4 @@ namespace fb

end namespace

#endif
#endif