/[pcre]/code/trunk/pcre_study.c
ViewVC logotype

Diff of /code/trunk/pcre_study.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 849 by ph10, Wed Dec 28 17:16:11 2011 UTC revision 850 by zherczeg, Wed Jan 4 17:29:11 2012 UTC
# Line 1298  return yield; Line 1298  return yield;
1298  *************************************************/  *************************************************/
1299    
1300  /* This function is handed a compiled expression that it must study to produce  /* This function is handed a compiled expression that it must study to produce
1301  information that will speed up the matching. It returns a pcre_extra block  information that will speed up the matching. It returns a pcre[16]_extra block
1302  which then gets handed back to pcre_exec().  which then gets handed back to pcre_exec().
1303    
1304  Arguments:  Arguments:
# Line 1307  Arguments: Line 1307  Arguments:
1307    errorptr  points to where to place error messages;    errorptr  points to where to place error messages;
1308              set NULL unless error              set NULL unless error
1309    
1310  Returns:    pointer to a pcre_extra block, with study_data filled in and the  Returns:    pointer to a pcre[16]_extra block, with study_data filled in and
1311                appropriate flags set;                the appropriate flags set;
1312              NULL on error or if no optimization possible              NULL on error or if no optimization possible
1313  */  */
1314    
# Line 1316  Returns:    pointer to a pcre_extra bloc Line 1316  Returns:    pointer to a pcre_extra bloc
1316  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
1317  pcre_study(const pcre *external_re, int options, const char **errorptr)  pcre_study(const pcre *external_re, int options, const char **errorptr)
1318  #else  #else
1319  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION
1320  pcre16_study(const pcre *external_re, int options, const char **errorptr)  pcre16_study(const pcre *external_re, int options, const char **errorptr)
1321  #endif  #endif
1322  {  {
1323  int min;  int min;
1324  BOOL bits_set = FALSE;  BOOL bits_set = FALSE;
1325  pcre_uint8 start_bits[32];  pcre_uint8 start_bits[32];
1326  pcre_extra *extra = NULL;  PUBL(extra) *extra = NULL;
1327  pcre_study_data *study;  pcre_study_data *study;
1328  const pcre_uint8 *tables;  const pcre_uint8 *tables;
1329  pcre_uchar *code;  pcre_uchar *code;
# Line 1408  switch(min = find_minlength(code, code, Line 1408  switch(min = find_minlength(code, code,
1408    }    }
1409    
1410  /* If a set of starting bytes has been identified, or if the minimum length is  /* If a set of starting bytes has been identified, or if the minimum length is
1411  greater than zero, or if JIT optimization has been requested, get a pcre_extra  greater than zero, or if JIT optimization has been requested, get a
1412  block and a pcre_study_data block. The study data is put in the latter, which  pcre[16]_extra block and a pcre_study_data block. The study data is put in the
1413  is pointed to by the former, which may also get additional data set later by  latter, which is pointed to by the former, which may also get additional data
1414  the calling program. At the moment, the size of pcre_study_data is fixed. We  set later by the calling program. At the moment, the size of pcre_study_data
1415  nevertheless save it in a field for returning via the pcre_fullinfo() function  is fixed. We nevertheless save it in a field for returning via the
1416  so that if it becomes variable in the future, we don't have to change that  pcre_fullinfo() function so that if it becomes variable in the future,
1417  code. */  we don't have to change that code. */
1418    
1419  if (bits_set || min > 0  if (bits_set || min > 0
1420  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
# Line 1422  if (bits_set || min > 0 Line 1422  if (bits_set || min > 0
1422  #endif  #endif
1423    )    )
1424    {    {
1425    extra = (pcre_extra *)(PUBL(malloc))    extra = (PUBL(extra) *)(PUBL(malloc))
1426      (sizeof(pcre_extra) + sizeof(pcre_study_data));      (sizeof(PUBL(extra)) + sizeof(pcre_study_data));
1427    if (extra == NULL)    if (extra == NULL)
1428      {      {
1429      *errorptr = "failed to get memory";      *errorptr = "failed to get memory";
1430      return NULL;      return NULL;
1431      }      }
1432    
1433    study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));    study = (pcre_study_data *)((char *)extra + sizeof(PUBL(extra)));
1434    extra->flags = PCRE_EXTRA_STUDY_DATA;    extra->flags = PCRE_EXTRA_STUDY_DATA;
1435    extra->study_data = study;    extra->study_data = study;
1436    
# Line 1502  return extra; Line 1502  return extra;
1502    
1503  /* This function frees the memory that was obtained by pcre_study().  /* This function frees the memory that was obtained by pcre_study().
1504    
1505  Argument:   a pointer to the pcre_extra block  Argument:   a pointer to the pcre[16]_extra block
1506  Returns:    nothing  Returns:    nothing
1507  */  */
1508    
# Line 1511  PCRE_EXP_DEFN void Line 1511  PCRE_EXP_DEFN void
1511  pcre_free_study(pcre_extra *extra)  pcre_free_study(pcre_extra *extra)
1512  #else  #else
1513  PCRE_EXP_DEFN void  PCRE_EXP_DEFN void
1514  pcre16_free_study(pcre_extra *extra)  pcre16_free_study(pcre16_extra *extra)
1515  #endif  #endif
1516  {  {
1517  if (extra == NULL)  if (extra == NULL)

Legend:
Removed from v.849  
changed lines
  Added in v.850

  ViewVC Help
Powered by ViewVC 1.1.5