Diff for /embedaddon/pcre/doc/html/pcreprecompile.html between versions 1.1 and 1.1.1.3

version 1.1, 2012/02/21 23:05:52 version 1.1.1.3, 2013/07/22 08:25:57
Line 29  If you are not using any private character tables (see Line 29  If you are not using any private character tables (see
 <a href="pcre_maketables.html"><b>pcre_maketables()</b></a>  <a href="pcre_maketables.html"><b>pcre_maketables()</b></a>
 documentation), this is relatively straightforward. If you are using private  documentation), this is relatively straightforward. If you are using private
 tables, it is a little bit more complicated. However, if you are using the  tables, it is a little bit more complicated. However, if you are using the
just-in-time optimization feature of <b>pcre_study()</b>, it is not possible tojust-in-time optimization feature, it is not possible to save and reload the
save and reload the JIT data.JIT data.
 </P>  </P>
 <P>  <P>
 If you save compiled patterns to a file, you can copy them to a different host  If you save compiled patterns to a file, you can copy them to a different host
and run them there. This works even if the new host has the opposite endiannessand run them there. If the two hosts have different endianness (byte order),
to the one on which the patterns were compiled. There may be a smallyou should run the <b>pcre[16|32]_pattern_to_host_byte_order()</b> function on the
performance penalty, but it should be insignificant. However, compiling regularnew host before trying to match the pattern. The matching functions return
expressions with one version of PCRE for use with a different version is notPCRE_ERROR_BADENDIANNESS if they detect a pattern with the wrong endianness.
guaranteed to work and may cause crashes, and saving and restoring a compiled 
pattern loses any JIT optimization data. 
 </P>  </P>
   <P>
   Compiling regular expressions with one version of PCRE for use with a different
   version is not guaranteed to work and may cause crashes, and saving and
   restoring a compiled pattern loses any JIT optimization data.
   </P>
 <br><a name="SEC2" href="#TOC1">SAVING A COMPILED PATTERN</a><br>  <br><a name="SEC2" href="#TOC1">SAVING A COMPILED PATTERN</a><br>
 <P>  <P>
The value returned by <b>pcre_compile()</b> points to a single block of memoryThe value returned by <b>pcre[16|32]_compile()</b> points to a single block of
that holds the compiled pattern and associated data. You can find the length ofmemory that holds the compiled pattern and associated data. You can find the
this block in bytes by calling <b>pcre_fullinfo()</b> with an argument oflength of this block in bytes by calling <b>pcre[16|32]_fullinfo()</b> with an
PCRE_INFO_SIZE. You can then save the data in any appropriate manner. Here isargument of PCRE_INFO_SIZE. You can then save the data in any appropriate
sample code that compiles a pattern and writes it to a file. It assumes thatmanner. Here is sample code for the 8-bit library that compiles a pattern and
the variable <i>fd</i> refers to a file that is open for output:writes it to a file. It assumes that the variable <i>fd</i> refers to a file
 that is open for output:
 <pre>  <pre>
   int erroroffset, rc, size;    int erroroffset, rc, size;
   char *error;    char *error;
Line 83  If the pattern has been studied, it is also possible t Line 87  If the pattern has been studied, it is also possible t
 data in a similar way to the compiled pattern itself. However, if the  data in a similar way to the compiled pattern itself. However, if the
 PCRE_STUDY_JIT_COMPILE was used, the just-in-time data that is created cannot  PCRE_STUDY_JIT_COMPILE was used, the just-in-time data that is created cannot
 be saved because it is too dependent on the current environment. When studying  be saved because it is too dependent on the current environment. When studying
generates additional information, <b>pcre_study()</b> returns a pointer to agenerates additional information, <b>pcre[16|32]_study()</b> returns a pointer to a
<b>pcre_extra</b> data block. Its format is defined in the<b>pcre[16|32]_extra</b> data block. Its format is defined in the
 <a href="pcreapi.html#extradata">section on matching a pattern</a>  <a href="pcreapi.html#extradata">section on matching a pattern</a>
 in the  in the
 <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
 documentation. The <i>study_data</i> field points to the binary study data, and  documentation. The <i>study_data</i> field points to the binary study data, and
this is what you must save (not the <b>pcre_extra</b> block itself). The lengththis is what you must save (not the <b>pcre[16|32]_extra</b> block itself). The
of the study data can be obtained by calling <b>pcre_fullinfo()</b> with anlength of the study data can be obtained by calling <b>pcre[16|32]_fullinfo()</b>
argument of PCRE_INFO_STUDYSIZE. Remember to check that <b>pcre_study()</b> didwith an argument of PCRE_INFO_STUDYSIZE. Remember to check that
return a non-NULL value before trying to save the study data.<b>pcre[16|32]_study()</b> did return a non-NULL value before trying to save the
 study data.
 </P>  </P>
 <br><a name="SEC3" href="#TOC1">RE-USING A PRECOMPILED PATTERN</a><br>  <br><a name="SEC3" href="#TOC1">RE-USING A PRECOMPILED PATTERN</a><br>
 <P>  <P>
 Re-using a precompiled pattern is straightforward. Having reloaded it into main  Re-using a precompiled pattern is straightforward. Having reloaded it into main
memory, you pass its pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> inmemory, called <b>pcre[16|32]_pattern_to_host_byte_order()</b> if necessary,
the usual way. This should work even on another host, and even if that host hasyou pass its pointer to <b>pcre[16|32]_exec()</b> or <b>pcre[16|32]_dfa_exec()</b> in
the opposite endianness to the one where the pattern was compiled.the usual way.
 </P>  </P>
 <P>  <P>
 However, if you passed a pointer to custom character tables when the pattern  However, if you passed a pointer to custom character tables when the pattern
was compiled (the <i>tableptr</i> argument of <b>pcre_compile()</b>), you mustwas compiled (the <i>tableptr</i> argument of <b>pcre[16|32]_compile()</b>), you
now pass a similar pointer to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>,must now pass a similar pointer to <b>pcre[16|32]_exec()</b> or
because the value saved with the compiled pattern will obviously be nonsense. A<b>pcre[16|32]_dfa_exec()</b>, because the value saved with the compiled pattern
field in a <b>pcre_extra()</b> block is used to pass this data, as described inwill obviously be nonsense. A field in a <b>pcre[16|32]_extra()</b> block is used
theto pass this data, as described in the
 <a href="pcreapi.html#extradata">section on matching a pattern</a>  <a href="pcreapi.html#extradata">section on matching a pattern</a>
 in the  in the
 <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
Line 115  documentation. Line 120  documentation.
 </P>  </P>
 <P>  <P>
 If you did not provide custom character tables when the pattern was compiled,  If you did not provide custom character tables when the pattern was compiled,
the pointer in the compiled pattern is NULL, which causes <b>pcre_exec()</b> tothe pointer in the compiled pattern is NULL, which causes the matching
use PCRE's internal tables. Thus, you do not need to take any special action atfunctions to use PCRE's internal tables. Thus, you do not need to take any
run time in this case.special action at run time in this case.
 </P>  </P>
 <P>  <P>
 If you saved study data with the compiled pattern, you need to create your own  If you saved study data with the compiled pattern, you need to create your own
<b>pcre_extra</b> data block and set the <i>study_data</i> field to point to the<b>pcre[16|32]_extra</b> data block and set the <i>study_data</i> field to point to the
 reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA bit in the  reloaded study data. You must also set the PCRE_EXTRA_STUDY_DATA bit in the
 <i>flags</i> field to indicate that study data is present. Then pass the  <i>flags</i> field to indicate that study data is present. Then pass the
<b>pcre_extra</b> block to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> in the<b>pcre[16|32]_extra</b> block to the matching function in the usual way. If the
usual way. If the pattern was studied for just-in-time optimization, that datapattern was studied for just-in-time optimization, that data cannot be saved,
cannot be saved, and so is lost by a save/restore cycle.and so is lost by a save/restore cycle.
 </P>  </P>
 <br><a name="SEC4" href="#TOC1">COMPATIBILITY WITH DIFFERENT PCRE RELEASES</a><br>  <br><a name="SEC4" href="#TOC1">COMPATIBILITY WITH DIFFERENT PCRE RELEASES</a><br>
 <P>  <P>
Line 144  Cambridge CB2 3QH, England. Line 149  Cambridge CB2 3QH, England.
 </P>  </P>
 <br><a name="SEC6" href="#TOC1">REVISION</a><br>  <br><a name="SEC6" href="#TOC1">REVISION</a><br>
 <P>  <P>
Last updated: 26 August 2011Last updated: 24 June 2012
 <br>  <br>
Copyright &copy; 1997-2011 University of Cambridge.Copyright &copy; 1997-2012 University of Cambridge.
 <br>  <br>
 <p>  <p>
 Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.

Removed from v.1.1  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>