~ubuntu-branches/ubuntu/utopic/pcre3/utopic-proposed

« back to all changes in this revision

Viewing changes to pcredemo.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Baker
  • Date: 2010-05-07 21:18:05 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100507211805-hgyyr2003bmbu54m
Tags: 8.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
pcresample documentation for a short discussion ("man pcresample" if you have
8
8
the PCRE man pages installed).
9
9
 
10
 
In Unix-like environments, compile this program thuswise:
11
 
 
12
 
  gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib \
13
 
    -R/usr/local/lib -lpcre
 
10
In Unix-like environments, if PCRE is installed in your standard system
 
11
libraries, you should be able to compile this program using this command:
 
12
 
 
13
gcc -Wall pcredemo.c -lpcre -o pcredemo
 
14
 
 
15
If PCRE is not installed in a standard place, it is likely to be installed with
 
16
support for the pkg-config mechanism. If you have pkg-config, you can compile
 
17
this program using this command:
 
18
 
 
19
gcc -Wall pcredemo.c `pkg-config --cflags --libs libpcre` -o pcredemo
 
20
 
 
21
If you do not have pkg-config, you may have to use this:
 
22
 
 
23
gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib \
 
24
  -R/usr/local/lib -lpcre -o pcredemo
14
25
 
15
26
Replace "/usr/local/include" and "/usr/local/lib" with wherever the include and
16
 
library files for PCRE are installed on your system. You don't need -I and -L
17
 
if PCRE is installed in the standard system libraries. Only some operating
 
27
library files for PCRE are installed on your system. Only some operating
18
28
systems (e.g. Solaris) use the -R option.
19
29
 
20
30
Building under Windows:
223
233
*                                                                        *
224
234
* If the previous match WAS for an empty string, we can't do that, as it *
225
235
* would lead to an infinite loop. Instead, a special call of pcre_exec() *
226
 
* is made with the PCRE_NOTEMPTY and PCRE_ANCHORED flags set. The first  *
227
 
* of these tells PCRE that an empty string is not a valid match; other   *
228
 
* possibilities must be tried. The second flag restricts PCRE to one     *
229
 
* match attempt at the initial string position. If this match succeeds,  *
230
 
* an alternative to the empty string match has been found, and we can    *
231
 
* proceed round the loop.                                                *
 
236
* is made with the PCRE_NOTEMPTY_ATSTART and PCRE_ANCHORED flags set.    *
 
237
* The first of these tells PCRE that an empty string at the start of the *
 
238
* subject is not a valid match; other possibilities must be tried. The   *
 
239
* second flag restricts PCRE to one match attempt at the initial string  *
 
240
* position. If this match succeeds, an alternative to the empty string   *
 
241
* match has been found, and we can proceed round the loop.               *
232
242
*************************************************************************/
233
243
 
234
244
if (!find_all)
251
261
  if (ovector[0] == ovector[1])
252
262
    {
253
263
    if (ovector[0] == subject_length) break;
254
 
    options = PCRE_NOTEMPTY | PCRE_ANCHORED;
 
264
    options = PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED;
255
265
    }
256
266
 
257
267
  /* Run the next matching operation */