Author: bernhard
Date: Sat Apr 23 08:49:53 2005
New Revision: 7919
Modified:
trunk/languages/LANGUAGES.STATUS
trunk/languages/m4/ChangeLog
trunk/languages/m4/src/input.imc
trunk/languages/m4/src/m4.imc
trunk/languages/m4/t/regex/001_pcre.t
trunk/languages/m4/t/regex/002_tokens.t
trunk/languages/m4/t/regex/003_two_compiles.t
trunk/runtime/parrot/library/libpcre.imc
trunk/runtime/parrot/library/pcre.imc
trunk/t/library/pcre.t
Log:
Clean up tabs in libpcre.imc and pcre.imc.
Make m4/t/regex/003_two_compiles.t work with library/pcre.imc
Start to use library/pcre.imc in languages/m4/src/input.imc.
Modified: trunk/languages/LANGUAGES.STATUS
==============================================================================
--- trunk/languages/LANGUAGES.STATUS (original)
+++ trunk/languages/LANGUAGES.STATUS Sat Apr 23 08:49:53 2005
@@ -81,9 +81,9 @@
D: Port of GNU m4 to PIR
S: Functioning for handcrafted test cases.
S: Far from complete.
-S: Revision 0.0.4
+S: Revision 0.0.11
M: Yes
-V: 0.1.0
+V: 0.1.2
N: miniperl
Modified: trunk/languages/m4/ChangeLog
==============================================================================
--- trunk/languages/m4/ChangeLog (original)
+++ trunk/languages/m4/ChangeLog Sat Apr 23 08:49:53 2005
@@ -1,6 +1,9 @@
# $Id$
2005-04-08 Bernhard Schmalhofer
+ * Adapt the PCRE tests to changes in 'library/pcre.imc'
+
+2005-04-08 Bernhard Schmalhofer
* The packfile functions now take a 'Interp *' as first argument
2005-02-19 Bernhard Schmalhofer
Modified: trunk/languages/m4/src/input.imc
==============================================================================
--- trunk/languages/m4/src/input.imc (original)
+++ trunk/languages/m4/src/input.imc Sat Apr 23 08:49:53 2005
@@ -51,8 +51,13 @@
.local pmc NULL
NULL = null
- .local pmc pcre_lib
- pcre_lib = loadlib "libpcre"
+ .local pmc init_func, compile_func, match_func, dollar_func, pcre_lib
+ init_func = find_global 'PCRE', 'init'
+ compile_func = find_global 'PCRE', 'compile'
+ dollar_func = find_global 'PCRE', 'dollar'
+ match_func = find_global 'PCRE', 'match'
+ state['pcre_match_func'] = match_func
+ pcre_lib = init_func()
.local pmc err_decl
.local pmc err
Modified: trunk/languages/m4/src/m4.imc
==============================================================================
--- trunk/languages/m4/src/m4.imc (original)
+++ trunk/languages/m4/src/m4.imc Sat Apr 23 08:49:53 2005
@@ -52,6 +52,8 @@
.sub m4 @MAIN
.param pmc argv
+ load_bytecode "library/pcre.imc"
+
# name of the program
.local string program_name
program_name = shift argv
Modified: trunk/languages/m4/t/regex/001_pcre.t
==============================================================================
--- trunk/languages/m4/t/regex/001_pcre.t (original)
+++ trunk/languages/m4/t/regex/001_pcre.t Sat Apr 23 08:49:53 2005
@@ -6,10 +6,10 @@
# Test loading of pcre library, Perl compatible regular expressions
pir_output_is( << 'END_PIR', << 'OUTPUT', "call parrot and do something" );
-.include "library/pcre.imc"
.sub test @MAIN
- .local pmc pcre_lib
+ load_bytecode "library/pcre.imc"
+
.local pmc init_func
init_func = find_global 'PCRE', 'init'
.local pmc compile_func
@@ -18,8 +18,7 @@
match_func= find_global 'PCRE', 'match'
.local pmc dollar_func
dollar_func = find_global 'PCRE', 'dollar'
-
- print "\n"
+ .local pmc pcre_lib
pcre_lib = init_func()
.local string error
@@ -62,7 +61,6 @@
print "'\n"
.end
END_PIR
-
1 match(es):
asdf
OUTPUT
Modified: trunk/languages/m4/t/regex/002_tokens.t
==============================================================================
--- trunk/languages/m4/t/regex/002_tokens.t (original)
+++ trunk/languages/m4/t/regex/002_tokens.t Sat Apr 23 08:49:53 2005
@@ -18,10 +18,10 @@
my %regex = ( name => q{[_a-zA-Z][_a-zA-Z0-9]*},
quoted => q{^`[^`]*'} );
return q{
-.include "library/pcre.imc"
.sub test @MAIN
- .local pmc pcre_lib
+ load_bytecode "library/pcre.imc"
+
.local pmc init_func
init_func = find_global 'PCRE', 'init'
.local pmc compile_func
@@ -30,8 +30,7 @@
match_func= find_global 'PCRE', 'match'
.local pmc dollar_func
dollar_func = find_global 'PCRE', 'dollar'
-
- print "\n"
+ .local pmc pcre_lib
pcre_lib = init_func()
.local string error
@@ -121,7 +120,7 @@
print "match failed\\n"
.return()
.end
-.include "library/pcre.imc"
+load_bytecode "library/pcre.imc"
.sub _main [EMAIL PROTECTED]
load_bytecode "pge.pir"
pge( "$string", "$regex{$token}" )
@@ -174,7 +173,6 @@
{
my $code = get_pir_pcre( 'foo', 'name' );
pir_output_is( $code, << 'OUTPUT', "'foo' is a name" );
-
1 match(es):
foo
OUTPUT
@@ -182,7 +180,6 @@
{
my $code = get_pir_pcre( '_tmp', 'name' );
pir_output_is( $code, << 'OUTPUT', "'_tmp' is a name" );
-
1 match(es):
_tmp
OUTPUT
@@ -190,7 +187,6 @@
{
my $code = get_pir_pcre( 'name2', 'name' );
pir_output_is( $code, << 'OUTPUT', "'name2' is a name" );
-
1 match(es):
name2
OUTPUT
@@ -198,7 +194,6 @@
{
my $code = get_pir_pcre( "`quoted'", 'quoted' );
pir_output_is( $code, << 'OUTPUT', "'`quoted'' is a quoted string" );
-
1 match(es):
`quoted'
OUTPUT
@@ -206,7 +201,6 @@
{
my $code = get_pir_pcre( "`'", 'quoted' );
pir_output_is( $code, << 'OUTPUT', "'`'' is a quoted string" );
-
1 match(es):
`'
OUTPUT
Modified: trunk/languages/m4/t/regex/003_two_compiles.t
==============================================================================
--- trunk/languages/m4/t/regex/003_two_compiles.t (original)
+++ trunk/languages/m4/t/regex/003_two_compiles.t Sat Apr 23 08:49:53 2005
@@ -2,14 +2,14 @@
use strict;
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 1;
-{
- my $pir = << 'END_PIR';
-.include "library/pcre.imc"
+# See whethe to regexes can be compiled
+pir_output_is( << 'END_PIR', << 'OUTPUT', "compile two regexes" );
.sub test @MAIN
- .local pmc pcre_lib
+ load_bytecode "library/pcre.imc"
+
.local pmc init_func
init_func = find_global 'PCRE', 'init'
.local pmc compile_func
@@ -18,42 +18,53 @@
match_func= find_global 'PCRE', 'match'
.local pmc dollar_func
dollar_func = find_global 'PCRE', 'dollar'
-
- print "\n"
+ .local pmc pcre_lib
pcre_lib = init_func()
.local string error
.local int errptr
+ .local pmc regex_1, regex_2
.local string pat
- .local pmc regex
- pat = 'as'
- ( regex, error, errptr )= compile_func( pat, 0 )
- $I0 = defined regex
+
+ pat = "asdf"
+ ( regex_1, error, errptr )= compile_func( pat, 0 )
+ $I0 = defined regex_1
unless $I0 goto match_err
- .local pmc regex_2
- #pat = 'df'
- #.PCRE_COMPILE(pat, 0, regex, error, errptr)
- #$I0 = defined regex_2
- #unless $I0 goto match_err
+ pat = "123"
+ ( regex_2, error, errptr )= compile_func( pat, 0 )
+ $I0 = defined regex_2
+ unless $I0 goto match_err
- .local int ok
+ .local int ok, i
.local pmc result
- .local string s
- s = "asdf"
- ( ok, result )= match_func( regex, s, 0, 0 )
+ .local string s, match
+ s = "0123asdf89"
+
+ # Try the first regex
+ ( ok, result )= match_func( regex_1, s, 0, 0 )
+ if ok < 0 goto nomatch
+ print ok
+ print " match(es):\n"
+ i = 0
+lp_1: match = dollar_func( s, ok, result, i )
+ print match
+ print "\n"
+ inc i
+ if i < ok goto lp_1
+
+ # Try the second regex
+ ( ok, result )= match_func( regex_2, s, 0, 0 )
if ok < 0 goto nomatch
print ok
print " match(es):\n"
- .local int i
i = 0
- .local string match
- .local string s
-lp: .PCRE_DOLLAR(s, ok, result, i, match)
+lp_2: match = dollar_func( s, ok, result, i )
print match
print "\n"
inc i
- if i < ok goto lp
+ if i < ok goto lp_2
+
end
nomatch:
print "no match\n"
@@ -68,380 +79,8 @@
print "'\n"
.end
END_PIR
-
- pir_output_is( $pir, << 'OUTPUT', "calling .PCRE_COMPILE one time" );
-
-1 match(es):
-as
-OUTPUT
-}
-{
- my $pir = << 'END_PIR';
-.sub test @MAIN
-
- # Loading shared lib
- .local pmc pcre_lib
- loadlib pcre_lib, "libpcre"
-
- # pcre *pcre_compile(const char *pattern, int options,
- # const char **errptr, int *erroffset,
- # const unsigned char *tableptr
- .local pmc pcre_compile
- dlfunc pcre_compile, pcre_lib, "pcre_compile", "ptiB3P"
-
- #int pcre_exec(const pcre *code, const pcre_extra *extra,
- # const char *subject, int length, int startoffset,
- # int options, int *ovector, int ovecsize);
- .local pmc pcre_exec
- dlfunc pcre_exec, pcre_lib, "pcre_exec", "ipPtiiipi"
-
- .local string error
- repeat error, " ", 500 # could be enough
- .local int errptr
- .local string s
- s = "asdf"
- .local int s_len
- length s_len, s
- .local pmc NULL
- null NULL
- .local int ok
- .local pmc ovector
- ovector = new ManagedStruct
- ovector = 120 # 1/(2/3) * 4 * 2 * 10 for 10 result pairs
- .local int is_defined
-
- # compile regular expression 'as'
- .local pmc re_as
- .pcc_begin prototyped
- .arg 'as'
- .arg 0
- .arg error
- .arg errptr
- .arg NULL
- .nci_call pcre_compile
- .result re_as
- .pcc_end
-
- defined is_defined, re_as
- unless is_defined goto COMPILE_FAILED
-
- # compile regular expression 'df'
- .local pmc re_df
- .pcc_begin prototyped
- .arg 'df'
- .arg 0
- .arg error
- .arg errptr
- .arg NULL
- .nci_call pcre_compile
- .result re_df
- .pcc_end
-
- # Try a match
- .pcc_begin prototyped
- .arg re_as
- .arg NULL # P extra
- .arg s # t subject
- .arg s_len
- .arg 0
- .arg 0
- .arg ovector # p ovector
- .arg 10 # i ovecsize
- .nci_call pcre_exec
- .result ok
- .pcc_end
- if ok < 0 goto EXEC_FAILED
- print ok
- print " match(es):\n"
-
- # Try another match
- .pcc_begin prototyped
- .arg re_df
- .arg NULL # P extra
- .arg s # t subject
- .arg s_len
- .arg 0
- .arg 0
- .arg ovector # p ovector
- .arg 10 # i ovecsize
- .nci_call pcre_exec
- .result ok
- .pcc_end
- print ok
- if ok < 0 goto NO_MATCH
- print " match(es):\n"
-
- end
-
-NO_MATCH:
- print " no match\n"
- end
-
-COMPILE_FAILED:
- print "error in pcre_compile :"
- print error
- print "\n"
- end
-
-.end
-END_PIR
-
- pir_output_is( $pir, << 'OUTPUT', "calling pcre_compile directly two times"
);
1 match(es):
+asdf
1 match(es):
+123
OUTPUT
-}
-{
- my $pir = << 'END_PIR';
-# Macros for accessing libpcre
-.include "library/pcre.imc"
-
-.sub test @MAIN
-
- # Loading shared lib
- .local pmc pcre_lib
- .PCRE_INIT(pcre_lib)
-
- # pcre *pcre_compile(const char *pattern, int options,
- # const char **errptr, int *erroffset,
- # const unsigned char *tableptr
- .local pmc pcre_compile
- pcre_compile = global "pcre::compile"
-
- #int pcre_exec(const pcre *code, const pcre_extra *extra,
- # const char *subject, int length, int startoffset,
- # int options, int *ovector, int ovecsize);
- .local pmc pcre_exec
- pcre_exec = global "pcre::exec"
-
- .local int is_defined
-
- # Variables for compiling
- .local string error
- repeat error, " ", 500 # could be enough
- .local int errptr
- .local pmc NULL
- null NULL
-
- # compile regular expression 'as'
- .local pmc re_as
- .PCRE_COMPILE('as', 0, re_as, error, errptr)
-
- # compile regular expression 'df'
- .local pmc re_df
- .PCRE_COMPILE('df', 0, re_df, error, errptr)
-
- # Variables for matching
- .local string s
- s = "asdf"
- .local int s_len
- length s_len, s
- .local int ok
- .local pmc ovector
- ovector = new ManagedStruct
- ovector = 120 # 1/(2/3) * 4 * 2 * 10 for 10 result pairs
-
- # Try a match
- .pcc_begin prototyped
- .arg re_as
- .arg NULL # P extra
- .arg s # t subject
- .arg s_len
- .arg 0
- .arg 0
- .arg ovector # p ovector
- .arg 10 # i ovecsize
- .nci_call pcre_exec
- .result ok
- .pcc_end
- if ok < 0 goto EXEC_FAILED
- print "ok: "
- print ok
- print " 'as' matches\n"
-
- # Try another match
- .pcc_begin prototyped
- .arg re_df
- .arg NULL # P extra
- .arg s # t subject
- .arg s_len
- .arg 0
- .arg 0
- .arg ovector # p ovector
- .arg 10 # i ovecsize
- .nci_call pcre_exec
- .result ok
- .pcc_end
- print "ok: "
- print ok
- if ok < 0 goto NO_MATCH
- print " 'df' matches\n"
-
- end
-
-NO_MATCH:
- print " no match\n"
- end
-
-COMPILE_FAILED:
- print "error in pcre_compile :"
- print error
- print "\n"
- end
-
-.end
-END_PIR
-
- pir_output_is( $pir, << 'OUTPUT', "calling pcre_compile directly two times"
);
-ok: 1 'as' matches
-ok: 1 'df' matches
-OUTPUT
-}
-if ( 0 )
-{
- my $pir = << 'END_PIR';
-.include "library/pcre.imc"
-.sub test @MAIN
- print "\n"
- .local pmc lib
- .PCRE_INIT(lib)
- .local string error
- .local int errptr
- .local string pat
-
- .local pmc regex
- pat = 'as'
- .PCRE_COMPILE(pat, 0, regex, error, errptr)
- $I0 = defined regex
- unless $I0 goto match_err
-
- .local pmc regex_2
- pat = 'df'
- .PCRE_COMPILE(pat, 0, regex_2, error, errptr)
- $I0 = defined regex_2
- unless $I0 goto match_err
-
- .local int ok
- .local pmc result
- .local string s
- s = "asdf"
- .PCRE_MATCH(regex, s, 0, 0, ok, result)
- if ok < 0 goto nomatch
- print ok
- print " match(es):\n"
- .local int i
- i = 0
- .local string match
- .local string s
-lp: .PCRE_DOLLAR(s, ok, result, i, match)
- print match
- print "\n"
- inc i
- if i < ok goto lp
- end
-nomatch:
- print "no match\n"
- end
-match_err:
- print "error in regex: "
- print "at: '"
- length $I0, pat
- $I0 = $I0 - errptr
- substr $S0, pat, errptr, $I0
- print $S0
- print "'\n"
- exit 1
-.end
-END_PIR
-
- pir_output_is( $pir, << 'OUTPUT', "calling .PCRE_COMPILE two times" );
-
-1 match(es):
-as
-OUTPUT
-}
-
-# doesn't work
-if ( 0 )
-{
- my $pir = << 'END_PIR';
-.include "library/pcre.imc"
-.sub test @MAIN
- print "\n"
- .local pmc lib
- .PCRE_INIT(lib)
- .local string error
- .local int errptr
- .local string pat
-
- .local pmc regex
- pat = 'as'
- .PCRE_COMPILE(pat, 0, regex, error, errptr)
- $I0 = defined regex
- unless $I0 goto match_err
-
- .local int ok
- .local pmc result
- .local string s
- .local int i
- s = "asdf"
- .PCRE_MATCH(regex, s, 0, 0, ok, result)
- if ok < 0 goto nomatch
- print ok
- print " match(es):\n"
- i = 0
- .local string match
-lp: .PCRE_DOLLAR(s, ok, result, i, match)
- print match
- print "\n"
- inc i
- if i < ok goto lp
-
- .local pmc regex_2
- .local string pat_2
- pat_2 = 'df'
- .local string error_2
- .local int errptr_2
- #.PCRE_COMPILE(pat_2, 0, regex_2, error_2, errptr_2)
- #------ Start of PCRE_COMPILE ------------------
- $P1 = global "_pcre_compile" # This sub is defined in libpcre.imc
- .pcc_begin prototyped
- .arg pat_2
- .arg 0
- .pcc_call $P1
- .result regex_2
- .result error_2
- .result errptr_2
- .pcc_end
- #------ End of PCRE_COMPILE ------------------
- $I0 = defined regex_2
- unless $I0 goto match_err
-
- .local int ok_2
- .local pmc result_2
- .local string s_2
- .local int i_2
- s_2 = "asdf"
-
- end
-nomatch:
- print "no match\n"
- end
-match_err:
- print "error in regex: "
- print "at: '"
- length $I0, pat
- $I0 = $I0 - errptr
- substr $S0, pat, errptr, $I0
- print $S0
- print "'\n"
- exit 1
-.end
-END_PIR
-
- pir_output_is( $pir, << 'OUTPUT', "calling .PCRE_COMPILE two times" );
-ok: 1 'as' match(es):
-ok: 1 'df' match(es):
-OUTPUT
-}
-
Modified: trunk/runtime/parrot/library/libpcre.imc
==============================================================================
--- trunk/runtime/parrot/library/libpcre.imc (original)
+++ trunk/runtime/parrot/library/libpcre.imc Sat Apr 23 08:49:53 2005
@@ -1,3 +1,6 @@
+# Copyright: 2004-2005 The Perl Foundation. All Rights Reserved.
+# $Id$
+
=head1 TITEL
libpcre.imc - NCI interface to Perl-Compatible Regular Expression library
@@ -18,7 +21,7 @@
.local string error
.local pmc PCRE_NCI_compile
- .local int error_size
+ .local int error_size
.local pmc NULL
null NULL
@@ -26,19 +29,19 @@
.local pmc errptr
errptr= new PerlInt
- ## error message string size
- error_size= 500
+ ## error message string size
+ error_size= 500
- ## allocate space in string for error message
+ ## allocate space in string for error message
repeat error, " ", error_size
- PCRE_NCI_compile= find_global 'PCRE::NCI', 'PCRE_compile'
+ PCRE_NCI_compile= find_global 'PCRE::NCI', 'PCRE_compile'
.local pmc code
- code= PCRE_NCI_compile( pat, options, error, errptr, NULL )
+ code= PCRE_NCI_compile( pat, options, error, errptr, NULL )
- .local int is_code_defined
+ .local int is_code_defined
is_code_defined = defined code
unless is_code_defined goto RETURN
@@ -58,33 +61,33 @@
.local int len
length len, s
- .local pmc NULL
+ .local pmc NULL
null NULL
- ## osize -- 1/(2/3) * 4 * 2
- .local int osize
- osize= 12
-
- ## number of result pairs
- .local int num_result_pairs
- num_result_pairs= 10
+ ## osize -- 1/(2/3) * 4 * 2
+ .local int osize
+ osize= 12
+
+ ## number of result pairs
+ .local int num_result_pairs
+ num_result_pairs= 10
- .local int ovector_length
- ovector_length= osize * num_result_pairs
+ .local int ovector_length
+ ovector_length= osize * num_result_pairs
- .local pmc ovector
+ .local pmc ovector
ovector= new ManagedStruct
ovector= ovector_length
- ## on 32 bit systems
+ ## on 32 bit systems
.local pmc PCRE_NCI_exec
PCRE_NCI_exec = find_global 'PCRE::NCI', 'PCRE_exec'
- .local int ok
+ .local int ok
- ok= PCRE_NCI_exec( regex, NULL, s, len, start, options, ovector, 10 )
+ ok= PCRE_NCI_exec( regex, NULL, s, len, start, options, ovector, 10 )
- .return( ok, ovector )
+ .return( ok, ovector )
.end
@@ -101,11 +104,11 @@
.local int ovecs
.local int ovece
- .local pmc struct
+ .local pmc struct
struct= new SArray
struct= 3
- .include "datatypes.pasm"
+ .include "datatypes.pasm"
struct[0] = .DATATYPE_INT
$I0 = ok * 2
Modified: trunk/runtime/parrot/library/pcre.imc
==============================================================================
--- trunk/runtime/parrot/library/pcre.imc (original)
+++ trunk/runtime/parrot/library/pcre.imc Sat Apr 23 08:49:53 2005
@@ -1,20 +1,23 @@
+# Copyright: 2004-2005 The Perl Foundation. All Rights Reserved.
+# $Id$
+
=head1 TITLE
pcre.imc - user interface to Perl-Compatible Regular Expression library
=head1 SYNOPSIS
- .include 'library/pcre.imc'
- lib= pcre_init()
+ load_bytecode 'library/pcre.imc'
+ lib = pcre_init()
- func= find_global 'PCRE', 'compile'
- ( regex, error, errptr )= func( pat, options )
+ func = find_global 'PCRE', 'compile'
+ ( regex, error, errptr )= func( pat, options )
- func= find_global 'PCRE', 'match'
- ( ok, result )= func( regex, string, start, options )
+ func = find_global 'PCRE', 'match'
+ ( ok, result )= func( regex, string, start, options )
- func= find_global 'PCRE', 'dollar'
- match= func( string, ok, result, i )
+ func = find_global 'PCRE', 'dollar'
+ match = func( string, ok, result, i )
=head1 DESCRIPTION
@@ -40,47 +43,47 @@
=cut
.sub init
- .local pmc libpcre
- .local pmc pcre_function
- .local pmc config
- .local string osname
+ .local pmc libpcre
+ .local pmc pcre_function
+ .local pmc config
+ .local string osname
- config= _config()
- osname= config['osname']
+ config = _config()
+ osname = config['osname']
- if 'MSWin32' == osname goto LIB_WIN32
+ if 'MSWin32' == osname goto LIB_WIN32
LIB_DEFAULT:
- loadlib libpcre, 'libpcre'
- branch LIB_LOADED
+ loadlib libpcre, 'libpcre'
+ branch LIB_LOADED
LIB_WIN32:
- loadlib libpcre, 'pcre'
+ loadlib libpcre, 'pcre'
LIB_LOADED:
- store_global 'PCRE', 'lib', libpcre
+ store_global 'PCRE', 'lib', libpcre
- load_bytecode 'library/libpcre.imc'
+ load_bytecode 'library/libpcre.imc'
- # pcre *pcre_compile(const char *pattern, int options,
- # const char **errptr, int *erroffset,
- # const unsigned char *tableptr
- dlfunc pcre_function, libpcre, 'pcre_compile', 'ptiB3P'
- store_global 'PCRE::NCI', 'PCRE_compile', pcre_function
+ # pcre *pcre_compile(const char *pattern, int options,
+ # const char **errptr, int *erroffset,
+ # const unsigned char *tableptr
+ dlfunc pcre_function, libpcre, 'pcre_compile', 'ptiB3P'
+ store_global 'PCRE::NCI', 'PCRE_compile', pcre_function
#int pcre_exec(const pcre *code, const pcre_extra *extra,
# const char *subject, int length, int startoffset,
# int options, int *ovector, int ovecsize);
- dlfunc pcre_function, libpcre, 'pcre_exec', 'ipPtiiipi'
- store_global 'PCRE::NCI', 'PCRE_exec', pcre_function
+ dlfunc pcre_function, libpcre, 'pcre_exec', 'ipPtiiipi'
+ store_global 'PCRE::NCI', 'PCRE_exec', pcre_function
#int pcre_copy_substring(const char *subject, int *ovector,
# int stringcount, int stringnumber, char *buffer,
# int buffersize);
- dlfunc pcre_function, libpcre, 'pcre_copy_substring', 'itpiibi'
- store_global 'PCRE::NCI', 'PCRE_copy_substring', pcre_function
+ dlfunc pcre_function, libpcre, 'pcre_copy_substring', 'itpiibi'
+ store_global 'PCRE::NCI', 'PCRE_copy_substring', pcre_function
- .return( libpcre )
+ .return( libpcre )
.end
@@ -92,19 +95,19 @@
=cut
.sub compile prototyped
- .param string pattern
- .param int options
- .local pmc pcre_function
+ .param string pattern
+ .param int options
+ .local pmc pcre_function
- pcre_function= find_global 'PCRE::NCI', 'compile'
+ pcre_function= find_global 'PCRE::NCI', 'compile'
- .local pmc regex
- .local string error
- .local int errptr
+ .local pmc regex
+ .local string error
+ .local int errptr
- ( regex, error, errptr )= pcre_function( pattern, options )
+ ( regex, error, errptr )= pcre_function( pattern, options )
- .return( regex, error, errptr )
+ .return( regex, error, errptr )
.end
@@ -118,20 +121,20 @@
=cut
.sub match prototyped
- .param pmc regex
- .param string str
- .param int start
- .param int options
- .local pmc pcre_function
+ .param pmc regex
+ .param string str
+ .param int start
+ .param int options
+ .local pmc pcre_function
- pcre_function= find_global 'PCRE::NCI', 'exec'
+ pcre_function= find_global 'PCRE::NCI', 'exec'
- .local int ok
- .local pmc res
+ .local int ok
+ .local pmc res
- ( ok, res )= pcre_function( regex, str, start, options )
+ ( ok, res )= pcre_function( regex, str, start, options )
- .return( ok, res )
+ .return( ok, res )
.end
@@ -143,19 +146,19 @@
=cut
.sub dollar prototyped
- .param string str
- .param int ok
- .param pmc res
- .param int n
- .local pmc pcre_function
+ .param string str
+ .param int ok
+ .param pmc res
+ .param int n
+ .local pmc pcre_function
- pcre_function= find_global 'PCRE::NCI', 'result'
+ pcre_function= find_global 'PCRE::NCI', 'result'
- .local string matched
+ .local string matched
- matched= pcre_function( str, ok, res, n )
+ matched= pcre_function( str, ok, res, n )
- .return( matched )
+ .return( matched )
.end
Modified: trunk/t/library/pcre.t
==============================================================================
--- trunk/t/library/pcre.t (original)
+++ trunk/t/library/pcre.t Sat Apr 23 08:49:53 2005
@@ -8,7 +8,7 @@
=head1 SYNOPSIS
- % perl -Ilib t/library/pcre.t
+ % perl -Ilib t/library/pcre.t
=head1 DESCRIPTION
@@ -31,71 +31,71 @@
## 1
pir_output_is( <<'CODE', <<'OUT', 'soup to nuts' );
-.include 'library/pcre.imc'
.sub main @MAIN
- .local pmc func
- .local pmc lib
+ load_bytecode "library/pcre.imc"
+ .local pmc func
+ .local pmc lib
- find_global func, 'PCRE', 'init'
- isnull func, NOK1
- branch OK1
+ find_global func, 'PCRE', 'init'
+ isnull func, NOK1
+ branch OK1
NOK1:
- print 'not '
+ print 'not '
OK1:
- print "ok 1\n"
+ print "ok 1\n"
- lib= func()
- isnull lib, NOK2
- branch OK2
+ lib= func()
+ isnull lib, NOK2
+ branch OK2
NOK2:
- print 'not '
+ print 'not '
OK2:
- print "ok 2\n"
+ print "ok 2\n"
- .local string s
- .local string pat
+ .local string s
+ .local string pat
- s= '--a--'
- pat= 'a'
+ s= '--a--'
+ pat= 'a'
- .local pmc code
- .local string error
- .local int errptr
+ .local pmc code
+ .local string error
+ .local int errptr
- func= find_global 'PCRE', 'compile'
- ( code, error, errptr )= func( pat, 0 )
+ func= find_global 'PCRE', 'compile'
+ ( code, error, errptr )= func( pat, 0 )
- .local int is_code_defined
- is_code_defined= defined code
- if is_code_defined goto OK3
- print 'not '
+ .local int is_code_defined
+ is_code_defined= defined code
+ if is_code_defined goto OK3
+ print 'not '
OK3:
- print "ok 3\n"
+ print "ok 3\n"
- .local int ok
- .local pmc result
+ .local int ok
+ .local pmc result
- func= find_global 'PCRE', 'match'
- ( ok, result )= func( code, s, 0, 0 )
+ func= find_global 'PCRE', 'match'
+ ( ok, result )= func( code, s, 0, 0 )
- unless ok < 0 goto OK4
- print 'not '
+ unless ok < 0 goto OK4
+ print 'not '
OK4:
- print "ok 4\n"
+ print "ok 4\n"
.local int i
i= 0
.local string match
- func= find_global 'PCRE', 'dollar'
- match= func( s, ok, result, i )
- if 'a' == match goto OK5
- print 'not '
+ func= find_global 'PCRE', 'dollar'
+ match= func( s, ok, result, i )
+ if 'a' == match goto OK5
+ print 'not '
OK5:
- print "ok 5\n"
+ print "ok 5\n"
.end
CODE