version 1.1.1.2, 2012/02/21 23:50:25
|
version 1.1.1.3, 2013/07/22 08:25:57
|
Line 35 JIT data.
|
Line 35 JIT data.
|
<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. If the two hosts have different endianness (byte order), |
and run them there. If the two hosts have different endianness (byte order), |
you should run the <b>pcre[16]_pattern_to_host_byte_order()</b> function on the | you should run the <b>pcre[16|32]_pattern_to_host_byte_order()</b> function on the |
new host before trying to match the pattern. The matching functions return |
new host before trying to match the pattern. The matching functions return |
PCRE_ERROR_BADENDIANNESS if they detect a pattern with the wrong endianness. |
PCRE_ERROR_BADENDIANNESS if they detect a pattern with the wrong endianness. |
</P> |
</P> |
Line 46 restoring a compiled pattern loses any JIT optimizatio
|
Line 46 restoring a compiled pattern loses any JIT optimizatio
|
</P> |
</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[16]_compile()</b> points to a single block of | The value returned by <b>pcre[16|32]_compile()</b> points to a single block of |
memory that holds the compiled pattern and associated data. You can find the |
memory that holds the compiled pattern and associated data. You can find the |
length of this block in bytes by calling <b>pcre[16]_fullinfo()</b> with an | length of this block in bytes by calling <b>pcre[16|32]_fullinfo()</b> with an |
argument of PCRE_INFO_SIZE. You can then save the data in any appropriate |
argument of PCRE_INFO_SIZE. You can then save the data in any appropriate |
manner. Here is sample code for the 8-bit library that compiles a pattern and |
manner. Here is sample code for the 8-bit library that compiles a pattern and |
writes it to a file. It assumes that the variable <i>fd</i> refers to a file |
writes it to a file. It assumes that the variable <i>fd</i> refers to a file |
Line 87 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[16]_study()</b> returns a pointer to a | generates additional information, <b>pcre[16|32]_study()</b> returns a pointer to a |
<b>pcre[16]_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[16]_extra</b> block itself). The | this is what you must save (not the <b>pcre[16|32]_extra</b> block itself). The |
length of the study data can be obtained by calling <b>pcre[16]_fullinfo()</b> | length of the study data can be obtained by calling <b>pcre[16|32]_fullinfo()</b> |
with an argument of PCRE_INFO_STUDYSIZE. Remember to check that |
with an argument of PCRE_INFO_STUDYSIZE. Remember to check that |
<b>pcre[16]_study()</b> did return a non-NULL value before trying to save the | <b>pcre[16|32]_study()</b> did return a non-NULL value before trying to save the |
study data. |
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, called <b>pcre[16]_pattern_to_host_byte_order()</b> if necessary, | memory, called <b>pcre[16|32]_pattern_to_host_byte_order()</b> if necessary, |
you pass its pointer to <b>pcre[16]_exec()</b> or <b>pcre[16]_dfa_exec()</b> in | you pass its pointer to <b>pcre[16|32]_exec()</b> or <b>pcre[16|32]_dfa_exec()</b> in |
the usual way. |
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[16]_compile()</b>), you | was compiled (the <i>tableptr</i> argument of <b>pcre[16|32]_compile()</b>), you |
must now pass a similar pointer to <b>pcre[16]_exec()</b> or | must now pass a similar pointer to <b>pcre[16|32]_exec()</b> or |
<b>pcre[16]_dfa_exec()</b>, because the value saved with the compiled pattern | <b>pcre[16|32]_dfa_exec()</b>, because the value saved with the compiled pattern |
will obviously be nonsense. A field in a <b>pcre[16]_extra()</b> block is used | will obviously be nonsense. A field in a <b>pcre[16|32]_extra()</b> block is used |
to pass this data, as described in the |
to 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 |
Line 126 special action at run time in this case.
|
Line 126 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[16]_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[16]_extra</b> block to the matching function in the usual way. If the | <b>pcre[16|32]_extra</b> block to the matching function in the usual way. If the |
pattern was studied for just-in-time optimization, that data cannot be saved, |
pattern was studied for just-in-time optimization, that data cannot be saved, |
and so is lost by a save/restore cycle. |
and so is lost by a save/restore cycle. |
</P> |
</P> |
Line 149 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: 10 January 2012 | Last updated: 24 June 2012 |
<br> |
<br> |
Copyright © 1997-2012 University of Cambridge. |
Copyright © 1997-2012 University of Cambridge. |
<br> |
<br> |