Mxx_ru 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mxx_ru/cpp/qt4.rb +31 -0
- data/lib/mxx_ru/cpp/qt4details.rb +571 -0
- data/lib/mxx_ru/cpp/rucodegen.rb +1 -1
- data/lib/mxx_ru/cpp/target.rb +43 -53
- data/lib/mxx_ru/cpp/toolset.rb +24 -0
- data/lib/mxx_ru/cpp/toolsets/vc8_family.rb +2 -6
- data/lib/mxx_ru/version.rb +1 -1
- metadata +4 -22
- data/tests/c/pcre/chartables.c +0 -183
- data/tests/c/pcre/config.h +0 -99
- data/tests/c/pcre/dftables.c +0 -167
- data/tests/c/pcre/get.c +0 -349
- data/tests/c/pcre/internal.h +0 -677
- data/tests/c/pcre/maketables.c +0 -140
- data/tests/c/pcre/pcre.c +0 -8304
- data/tests/c/pcre/pcre.h +0 -193
- data/tests/c/pcre/pcre.rb +0 -14
- data/tests/c/pcre/pcredemo.c +0 -316
- data/tests/c/pcre/pcregrep.c +0 -642
- data/tests/c/pcre/pcreposix.c +0 -305
- data/tests/c/pcre/pcreposix.h +0 -88
- data/tests/c/pcre/pcretest.c +0 -1483
- data/tests/c/pcre/perltest +0 -211
- data/tests/c/pcre/printint.c +0 -360
- data/tests/c/pcre/study.c +0 -472
data/tests/c/pcre/pcre.h
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
/*************************************************
|
2
|
-
* Perl-Compatible Regular Expressions *
|
3
|
-
*************************************************/
|
4
|
-
|
5
|
-
/* Copyright (c) 1997-2003 University of Cambridge */
|
6
|
-
|
7
|
-
#ifndef _PCRE_H
|
8
|
-
#define _PCRE_H
|
9
|
-
|
10
|
-
/* The file pcre.h is build by "configure". Do not edit it; instead
|
11
|
-
make changes to pcre.in. */
|
12
|
-
|
13
|
-
#define PCRE_MAJOR @PCRE_MAJOR@
|
14
|
-
#define PCRE_MINOR @PCRE_MINOR@
|
15
|
-
#define PCRE_DATE @PCRE_DATE@
|
16
|
-
|
17
|
-
/* Win32 uses DLL by default */
|
18
|
-
|
19
|
-
#ifdef _WIN32
|
20
|
-
# ifdef PCRE_DEFINITION
|
21
|
-
# ifdef DLL_EXPORT
|
22
|
-
# define PCRE_DATA_SCOPE __declspec(dllexport)
|
23
|
-
# endif
|
24
|
-
# else
|
25
|
-
# ifndef PCRE_STATIC
|
26
|
-
# define PCRE_DATA_SCOPE extern __declspec(dllimport)
|
27
|
-
# endif
|
28
|
-
# endif
|
29
|
-
#endif
|
30
|
-
#ifndef PCRE_DATA_SCOPE
|
31
|
-
# define PCRE_DATA_SCOPE extern
|
32
|
-
#endif
|
33
|
-
|
34
|
-
/* Have to include stdlib.h in order to ensure that size_t is defined;
|
35
|
-
it is needed here for malloc. */
|
36
|
-
|
37
|
-
#include <stdlib.h>
|
38
|
-
|
39
|
-
/* Allow for C++ users */
|
40
|
-
|
41
|
-
#ifdef __cplusplus
|
42
|
-
extern "C" {
|
43
|
-
#endif
|
44
|
-
|
45
|
-
/* Options */
|
46
|
-
|
47
|
-
#define PCRE_CASELESS 0x0001
|
48
|
-
#define PCRE_MULTILINE 0x0002
|
49
|
-
#define PCRE_DOTALL 0x0004
|
50
|
-
#define PCRE_EXTENDED 0x0008
|
51
|
-
#define PCRE_ANCHORED 0x0010
|
52
|
-
#define PCRE_DOLLAR_ENDONLY 0x0020
|
53
|
-
#define PCRE_EXTRA 0x0040
|
54
|
-
#define PCRE_NOTBOL 0x0080
|
55
|
-
#define PCRE_NOTEOL 0x0100
|
56
|
-
#define PCRE_UNGREEDY 0x0200
|
57
|
-
#define PCRE_NOTEMPTY 0x0400
|
58
|
-
#define PCRE_UTF8 0x0800
|
59
|
-
#define PCRE_NO_AUTO_CAPTURE 0x1000
|
60
|
-
#define PCRE_NO_UTF8_CHECK 0x2000
|
61
|
-
|
62
|
-
/* Exec-time and get/set-time error codes */
|
63
|
-
|
64
|
-
#define PCRE_ERROR_NOMATCH (-1)
|
65
|
-
#define PCRE_ERROR_NULL (-2)
|
66
|
-
#define PCRE_ERROR_BADOPTION (-3)
|
67
|
-
#define PCRE_ERROR_BADMAGIC (-4)
|
68
|
-
#define PCRE_ERROR_UNKNOWN_NODE (-5)
|
69
|
-
#define PCRE_ERROR_NOMEMORY (-6)
|
70
|
-
#define PCRE_ERROR_NOSUBSTRING (-7)
|
71
|
-
#define PCRE_ERROR_MATCHLIMIT (-8)
|
72
|
-
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
|
73
|
-
#define PCRE_ERROR_BADUTF8 (-10)
|
74
|
-
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
|
75
|
-
|
76
|
-
/* Request types for pcre_fullinfo() */
|
77
|
-
|
78
|
-
#define PCRE_INFO_OPTIONS 0
|
79
|
-
#define PCRE_INFO_SIZE 1
|
80
|
-
#define PCRE_INFO_CAPTURECOUNT 2
|
81
|
-
#define PCRE_INFO_BACKREFMAX 3
|
82
|
-
#define PCRE_INFO_FIRSTBYTE 4
|
83
|
-
#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
|
84
|
-
#define PCRE_INFO_FIRSTTABLE 5
|
85
|
-
#define PCRE_INFO_LASTLITERAL 6
|
86
|
-
#define PCRE_INFO_NAMEENTRYSIZE 7
|
87
|
-
#define PCRE_INFO_NAMECOUNT 8
|
88
|
-
#define PCRE_INFO_NAMETABLE 9
|
89
|
-
#define PCRE_INFO_STUDYSIZE 10
|
90
|
-
|
91
|
-
/* Request types for pcre_config() */
|
92
|
-
|
93
|
-
#define PCRE_CONFIG_UTF8 0
|
94
|
-
#define PCRE_CONFIG_NEWLINE 1
|
95
|
-
#define PCRE_CONFIG_LINK_SIZE 2
|
96
|
-
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
|
97
|
-
#define PCRE_CONFIG_MATCH_LIMIT 4
|
98
|
-
#define PCRE_CONFIG_STACKRECURSE 5
|
99
|
-
|
100
|
-
/* Bit flags for the pcre_extra structure */
|
101
|
-
|
102
|
-
#define PCRE_EXTRA_STUDY_DATA 0x0001
|
103
|
-
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
|
104
|
-
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
|
105
|
-
|
106
|
-
/* Types */
|
107
|
-
|
108
|
-
struct real_pcre; /* declaration; the definition is private */
|
109
|
-
typedef struct real_pcre pcre;
|
110
|
-
|
111
|
-
/* The structure for passing additional data to pcre_exec(). This is defined in
|
112
|
-
such as way as to be extensible. */
|
113
|
-
|
114
|
-
typedef struct pcre_extra {
|
115
|
-
unsigned long int flags; /* Bits for which fields are set */
|
116
|
-
void *study_data; /* Opaque data from pcre_study() */
|
117
|
-
unsigned long int match_limit; /* Maximum number of calls to match() */
|
118
|
-
void *callout_data; /* Data passed back in callouts */
|
119
|
-
} pcre_extra;
|
120
|
-
|
121
|
-
/* The structure for passing out data via the pcre_callout_function. We use a
|
122
|
-
structure so that new fields can be added on the end in future versions,
|
123
|
-
without changing the API of the function, thereby allowing old clients to work
|
124
|
-
without modification. */
|
125
|
-
|
126
|
-
typedef struct pcre_callout_block {
|
127
|
-
int version; /* Identifies version of block */
|
128
|
-
/* ------------------------ Version 0 ------------------------------- */
|
129
|
-
int callout_number; /* Number compiled into pattern */
|
130
|
-
int *offset_vector; /* The offset vector */
|
131
|
-
const char *subject; /* The subject being matched */
|
132
|
-
int subject_length; /* The length of the subject */
|
133
|
-
int start_match; /* Offset to start of this match attempt */
|
134
|
-
int current_position; /* Where we currently are */
|
135
|
-
int capture_top; /* Max current capture */
|
136
|
-
int capture_last; /* Most recently closed capture */
|
137
|
-
void *callout_data; /* Data passed in with the call */
|
138
|
-
/* ------------------------------------------------------------------ */
|
139
|
-
} pcre_callout_block;
|
140
|
-
|
141
|
-
/* Indirection for store get and free functions. These can be set to
|
142
|
-
alternative malloc/free functions if required. Special ones are used in the
|
143
|
-
non-recursive case for "frames". There is also an optional callout function
|
144
|
-
that is triggered by the (?) regex item. Some magic is required for Win32 DLL;
|
145
|
-
it is null on other OS. For Virtual Pascal, these have to be different again.
|
146
|
-
*/
|
147
|
-
|
148
|
-
#ifndef VPCOMPAT
|
149
|
-
PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
|
150
|
-
PCRE_DATA_SCOPE void (*pcre_free)(void *);
|
151
|
-
PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
|
152
|
-
PCRE_DATA_SCOPE void (*pcre_stack_free)(void *);
|
153
|
-
PCRE_DATA_SCOPE int (*pcre_callout)(pcre_callout_block *);
|
154
|
-
#else /* VPCOMPAT */
|
155
|
-
extern void *pcre_malloc(size_t);
|
156
|
-
extern void pcre_free(void *);
|
157
|
-
extern void *pcre_stack_malloc(size_t);
|
158
|
-
extern void pcre_stack_free(void *);
|
159
|
-
extern int pcre_callout(pcre_callout_block *);
|
160
|
-
#endif /* VPCOMPAT */
|
161
|
-
|
162
|
-
/* Exported PCRE functions */
|
163
|
-
|
164
|
-
extern pcre *pcre_compile(const char *, int, const char **,
|
165
|
-
int *, const unsigned char *);
|
166
|
-
extern int pcre_config(int, void *);
|
167
|
-
extern int pcre_copy_named_substring(const pcre *, const char *,
|
168
|
-
int *, int, const char *, char *, int);
|
169
|
-
extern int pcre_copy_substring(const char *, int *, int, int,
|
170
|
-
char *, int);
|
171
|
-
extern int pcre_exec(const pcre *, const pcre_extra *,
|
172
|
-
const char *, int, int, int, int *, int);
|
173
|
-
extern void pcre_free_substring(const char *);
|
174
|
-
extern void pcre_free_substring_list(const char **);
|
175
|
-
extern int pcre_fullinfo(const pcre *, const pcre_extra *, int,
|
176
|
-
void *);
|
177
|
-
extern int pcre_get_named_substring(const pcre *, const char *,
|
178
|
-
int *, int, const char *, const char **);
|
179
|
-
extern int pcre_get_stringnumber(const pcre *, const char *);
|
180
|
-
extern int pcre_get_substring(const char *, int *, int, int,
|
181
|
-
const char **);
|
182
|
-
extern int pcre_get_substring_list(const char *, int *, int,
|
183
|
-
const char ***);
|
184
|
-
extern int pcre_info(const pcre *, int *, int *);
|
185
|
-
extern const unsigned char *pcre_maketables(void);
|
186
|
-
extern pcre_extra *pcre_study(const pcre *, int, const char **);
|
187
|
-
extern const char *pcre_version(void);
|
188
|
-
|
189
|
-
#ifdef __cplusplus
|
190
|
-
} /* extern "C" */
|
191
|
-
#endif
|
192
|
-
|
193
|
-
#endif /* End of pcre.h */
|
data/tests/c/pcre/pcre.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'mxx_ru/cpp'
|
2
|
-
|
3
|
-
Mxx_ru::setup_target(
|
4
|
-
Mxx_ru::Cpp::Lib_target.new( "pcre.rb" ) {
|
5
|
-
target( "lib/pcre.4.5" )
|
6
|
-
|
7
|
-
define( "PCRE_STATIC", Mxx_ru::Cpp::Target::OPT_UPSPREAD )
|
8
|
-
|
9
|
-
c_source( "get.c" )
|
10
|
-
c_source( "maketables.c" )
|
11
|
-
c_source( "pcre.c" )
|
12
|
-
c_source( "study.c" )
|
13
|
-
}
|
14
|
-
)
|
data/tests/c/pcre/pcredemo.c
DELETED
@@ -1,316 +0,0 @@
|
|
1
|
-
/*************************************************
|
2
|
-
* PCRE DEMONSTRATION PROGRAM *
|
3
|
-
*************************************************/
|
4
|
-
|
5
|
-
/* This is a demonstration program to illustrate the most straightforward ways
|
6
|
-
of calling the PCRE regular expression library from a C program. See the
|
7
|
-
pcresample documentation for a short discussion.
|
8
|
-
|
9
|
-
Compile thuswise:
|
10
|
-
gcc -Wall pcredemo.c -I/opt/local/include -L/opt/local/lib \
|
11
|
-
-R/opt/local/lib -lpcre
|
12
|
-
|
13
|
-
Replace "/opt/local/include" and "/opt/local/lib" with wherever the include and
|
14
|
-
library files for PCRE are installed on your system. Only some operating
|
15
|
-
systems (e.g. Solaris) use the -R option.
|
16
|
-
*/
|
17
|
-
|
18
|
-
|
19
|
-
#include <stdio.h>
|
20
|
-
#include <string.h>
|
21
|
-
#include <pcre.h>
|
22
|
-
|
23
|
-
#define OVECCOUNT 30 /* should be a multiple of 3 */
|
24
|
-
|
25
|
-
|
26
|
-
int main(int argc, char **argv)
|
27
|
-
{
|
28
|
-
pcre *re;
|
29
|
-
const char *error;
|
30
|
-
char *pattern;
|
31
|
-
char *subject;
|
32
|
-
unsigned char *name_table;
|
33
|
-
int erroffset;
|
34
|
-
int find_all;
|
35
|
-
int namecount;
|
36
|
-
int name_entry_size;
|
37
|
-
int ovector[OVECCOUNT];
|
38
|
-
int subject_length;
|
39
|
-
int rc, i;
|
40
|
-
|
41
|
-
|
42
|
-
/*************************************************************************
|
43
|
-
* First, sort out the command line. There is only one possible option at *
|
44
|
-
* the moment, "-g" to request repeated matching to find all occurrences, *
|
45
|
-
* like Perl's /g option. We set the variable find_all non-zero if it is *
|
46
|
-
* present. Apart from that, there must be exactly two arguments. *
|
47
|
-
*************************************************************************/
|
48
|
-
|
49
|
-
find_all = 0;
|
50
|
-
for (i = 1; i < argc; i++)
|
51
|
-
{
|
52
|
-
if (strcmp(argv[i], "-g") == 0) find_all = 1;
|
53
|
-
else break;
|
54
|
-
}
|
55
|
-
|
56
|
-
/* After the options, we require exactly two arguments, which are the pattern,
|
57
|
-
and the subject string. */
|
58
|
-
|
59
|
-
if (argc - i != 2)
|
60
|
-
{
|
61
|
-
printf("Two arguments required: a regex and a subject string\n");
|
62
|
-
return 1;
|
63
|
-
}
|
64
|
-
|
65
|
-
pattern = argv[i];
|
66
|
-
subject = argv[i+1];
|
67
|
-
subject_length = (int)strlen(subject);
|
68
|
-
|
69
|
-
|
70
|
-
/*************************************************************************
|
71
|
-
* Now we are going to compile the regular expression pattern, and handle *
|
72
|
-
* and errors that are detected. *
|
73
|
-
*************************************************************************/
|
74
|
-
|
75
|
-
re = pcre_compile(
|
76
|
-
pattern, /* the pattern */
|
77
|
-
0, /* default options */
|
78
|
-
&error, /* for error message */
|
79
|
-
&erroffset, /* for error offset */
|
80
|
-
NULL); /* use default character tables */
|
81
|
-
|
82
|
-
/* Compilation failed: print the error message and exit */
|
83
|
-
|
84
|
-
if (re == NULL)
|
85
|
-
{
|
86
|
-
printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
|
87
|
-
return 1;
|
88
|
-
}
|
89
|
-
|
90
|
-
|
91
|
-
/*************************************************************************
|
92
|
-
* If the compilation succeeded, we call PCRE again, in order to do a *
|
93
|
-
* pattern match against the subject string. This just does ONE match. If *
|
94
|
-
* further matching is needed, it will be done below. *
|
95
|
-
*************************************************************************/
|
96
|
-
|
97
|
-
rc = pcre_exec(
|
98
|
-
re, /* the compiled pattern */
|
99
|
-
NULL, /* no extra data - we didn't study the pattern */
|
100
|
-
subject, /* the subject string */
|
101
|
-
subject_length, /* the length of the subject */
|
102
|
-
0, /* start at offset 0 in the subject */
|
103
|
-
0, /* default options */
|
104
|
-
ovector, /* output vector for substring information */
|
105
|
-
OVECCOUNT); /* number of elements in the output vector */
|
106
|
-
|
107
|
-
/* Matching failed: handle error cases */
|
108
|
-
|
109
|
-
if (rc < 0)
|
110
|
-
{
|
111
|
-
switch(rc)
|
112
|
-
{
|
113
|
-
case PCRE_ERROR_NOMATCH: printf("No match\n"); break;
|
114
|
-
/*
|
115
|
-
Handle other special cases if you like
|
116
|
-
*/
|
117
|
-
default: printf("Matching error %d\n", rc); break;
|
118
|
-
}
|
119
|
-
return 1;
|
120
|
-
}
|
121
|
-
|
122
|
-
/* Match succeded */
|
123
|
-
|
124
|
-
printf("\nMatch succeeded at offset %d\n", ovector[0]);
|
125
|
-
|
126
|
-
|
127
|
-
/*************************************************************************
|
128
|
-
* We have found the first match within the subject string. If the output *
|
129
|
-
* vector wasn't big enough, set its size to the maximum. Then output any *
|
130
|
-
* substrings that were captured. *
|
131
|
-
*************************************************************************/
|
132
|
-
|
133
|
-
/* The output vector wasn't big enough */
|
134
|
-
|
135
|
-
if (rc == 0)
|
136
|
-
{
|
137
|
-
rc = OVECCOUNT/3;
|
138
|
-
printf("ovector only has room for %d captured substrings\n", rc - 1);
|
139
|
-
}
|
140
|
-
|
141
|
-
/* Show substrings stored in the output vector by number. Obviously, in a real
|
142
|
-
application you might want to do things other than print them. */
|
143
|
-
|
144
|
-
for (i = 0; i < rc; i++)
|
145
|
-
{
|
146
|
-
char *substring_start = subject + ovector[2*i];
|
147
|
-
int substring_length = ovector[2*i+1] - ovector[2*i];
|
148
|
-
printf("%2d: %.*s\n", i, substring_length, substring_start);
|
149
|
-
}
|
150
|
-
|
151
|
-
|
152
|
-
/*************************************************************************
|
153
|
-
* That concludes the basic part of this demonstration program. We have *
|
154
|
-
* compiled a pattern, and performed a single match. The code that follows*
|
155
|
-
* first shows how to access named substrings, and then how to code for *
|
156
|
-
* repeated matches on the same subject. *
|
157
|
-
*************************************************************************/
|
158
|
-
|
159
|
-
/* See if there are any named substrings, and if so, show them by name. First
|
160
|
-
we have to extract the count of named parentheses from the pattern. */
|
161
|
-
|
162
|
-
(void)pcre_fullinfo(
|
163
|
-
re, /* the compiled pattern */
|
164
|
-
NULL, /* no extra data - we didn't study the pattern */
|
165
|
-
PCRE_INFO_NAMECOUNT, /* number of named substrings */
|
166
|
-
&namecount); /* where to put the answer */
|
167
|
-
|
168
|
-
if (namecount <= 0) printf("No named substrings\n"); else
|
169
|
-
{
|
170
|
-
unsigned char *tabptr;
|
171
|
-
printf("Named substrings\n");
|
172
|
-
|
173
|
-
/* Before we can access the substrings, we must extract the table for
|
174
|
-
translating names to numbers, and the size of each entry in the table. */
|
175
|
-
|
176
|
-
(void)pcre_fullinfo(
|
177
|
-
re, /* the compiled pattern */
|
178
|
-
NULL, /* no extra data - we didn't study the pattern */
|
179
|
-
PCRE_INFO_NAMETABLE, /* address of the table */
|
180
|
-
&name_table); /* where to put the answer */
|
181
|
-
|
182
|
-
(void)pcre_fullinfo(
|
183
|
-
re, /* the compiled pattern */
|
184
|
-
NULL, /* no extra data - we didn't study the pattern */
|
185
|
-
PCRE_INFO_NAMEENTRYSIZE, /* size of each entry in the table */
|
186
|
-
&name_entry_size); /* where to put the answer */
|
187
|
-
|
188
|
-
/* Now we can scan the table and, for each entry, print the number, the name,
|
189
|
-
and the substring itself. */
|
190
|
-
|
191
|
-
tabptr = name_table;
|
192
|
-
for (i = 0; i < namecount; i++)
|
193
|
-
{
|
194
|
-
int n = (tabptr[0] << 8) | tabptr[1];
|
195
|
-
printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
|
196
|
-
ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
|
197
|
-
tabptr += name_entry_size;
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
|
202
|
-
/*************************************************************************
|
203
|
-
* If the "-g" option was given on the command line, we want to continue *
|
204
|
-
* to search for additional matches in the subject string, in a similar *
|
205
|
-
* way to the /g option in Perl. This turns out to be trickier than you *
|
206
|
-
* might think because of the possibility of matching an empty string. *
|
207
|
-
* What happens is as follows: *
|
208
|
-
* *
|
209
|
-
* If the previous match was NOT for an empty string, we can just start *
|
210
|
-
* the next match at the end of the previous one. *
|
211
|
-
* *
|
212
|
-
* If the previous match WAS for an empty string, we can't do that, as it *
|
213
|
-
* would lead to an infinite loop. Instead, a special call of pcre_exec() *
|
214
|
-
* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first *
|
215
|
-
* of these tells PCRE that an empty string is not a valid match; other *
|
216
|
-
* possibilities must be tried. The second flag restricts PCRE to one *
|
217
|
-
* match attempt at the initial string position. If this match succeeds, *
|
218
|
-
* an alternative to the empty string match has been found, and we can *
|
219
|
-
* proceed round the loop. *
|
220
|
-
*************************************************************************/
|
221
|
-
|
222
|
-
if (!find_all) return 0; /* Finish unless -g was given */
|
223
|
-
|
224
|
-
/* Loop for second and subsequent matches */
|
225
|
-
|
226
|
-
for (;;)
|
227
|
-
{
|
228
|
-
int options = 0; /* Normally no options */
|
229
|
-
int start_offset = ovector[1]; /* Start at end of previous match */
|
230
|
-
|
231
|
-
/* If the previous match was for an empty string, we are finished if we are
|
232
|
-
at the end of the subject. Otherwise, arrange to run another match at the
|
233
|
-
same point to see if a non-empty match can be found. */
|
234
|
-
|
235
|
-
if (ovector[0] == ovector[1])
|
236
|
-
{
|
237
|
-
if (ovector[0] == subject_length) break;
|
238
|
-
options = PCRE_NOTEMPTY | PCRE_ANCHORED;
|
239
|
-
}
|
240
|
-
|
241
|
-
/* Run the next matching operation */
|
242
|
-
|
243
|
-
rc = pcre_exec(
|
244
|
-
re, /* the compiled pattern */
|
245
|
-
NULL, /* no extra data - we didn't study the pattern */
|
246
|
-
subject, /* the subject string */
|
247
|
-
subject_length, /* the length of the subject */
|
248
|
-
start_offset, /* starting offset in the subject */
|
249
|
-
options, /* options */
|
250
|
-
ovector, /* output vector for substring information */
|
251
|
-
OVECCOUNT); /* number of elements in the output vector */
|
252
|
-
|
253
|
-
/* This time, a result of NOMATCH isn't an error. If the value in "options"
|
254
|
-
is zero, it just means we have found all possible matches, so the loop ends.
|
255
|
-
Otherwise, it means we have failed to find a non-empty-string match at a
|
256
|
-
point where there was a previous empty-string match. In this case, we do what
|
257
|
-
Perl does: advance the matching position by one, and continue. We do this by
|
258
|
-
setting the "end of previous match" offset, because that is picked up at the
|
259
|
-
top of the loop as the point at which to start again. */
|
260
|
-
|
261
|
-
if (rc == PCRE_ERROR_NOMATCH)
|
262
|
-
{
|
263
|
-
if (options == 0) break;
|
264
|
-
ovector[1] = start_offset + 1;
|
265
|
-
continue; /* Go round the loop again */
|
266
|
-
}
|
267
|
-
|
268
|
-
/* Other matching errors are not recoverable. */
|
269
|
-
|
270
|
-
if (rc < 0)
|
271
|
-
{
|
272
|
-
printf("Matching error %d\n", rc);
|
273
|
-
return 1;
|
274
|
-
}
|
275
|
-
|
276
|
-
/* Match succeded */
|
277
|
-
|
278
|
-
printf("\nMatch succeeded again at offset %d\n", ovector[0]);
|
279
|
-
|
280
|
-
/* The match succeeded, but the output vector wasn't big enough. */
|
281
|
-
|
282
|
-
if (rc == 0)
|
283
|
-
{
|
284
|
-
rc = OVECCOUNT/3;
|
285
|
-
printf("ovector only has room for %d captured substrings\n", rc - 1);
|
286
|
-
}
|
287
|
-
|
288
|
-
/* As before, show substrings stored in the output vector by number, and then
|
289
|
-
also any named substrings. */
|
290
|
-
|
291
|
-
for (i = 0; i < rc; i++)
|
292
|
-
{
|
293
|
-
char *substring_start = subject + ovector[2*i];
|
294
|
-
int substring_length = ovector[2*i+1] - ovector[2*i];
|
295
|
-
printf("%2d: %.*s\n", i, substring_length, substring_start);
|
296
|
-
}
|
297
|
-
|
298
|
-
if (namecount <= 0) printf("No named substrings\n"); else
|
299
|
-
{
|
300
|
-
unsigned char *tabptr = name_table;
|
301
|
-
printf("Named substrings\n");
|
302
|
-
for (i = 0; i < namecount; i++)
|
303
|
-
{
|
304
|
-
int n = (tabptr[0] << 8) | tabptr[1];
|
305
|
-
printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
|
306
|
-
ovector[2*n+1] - ovector[2*n], subject + ovector[2*n]);
|
307
|
-
tabptr += name_entry_size;
|
308
|
-
}
|
309
|
-
}
|
310
|
-
} /* End of loop to find second and subsequent matches */
|
311
|
-
|
312
|
-
printf("\n");
|
313
|
-
return 0;
|
314
|
-
}
|
315
|
-
|
316
|
-
/* End of pcredemo.c */
|