/[pcre]/code/branches/pcre16/pcre_fullinfo.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_fullinfo.c

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

code/trunk/pcre_fullinfo.c revision 230 by ph10, Mon Sep 10 13:23:56 2007 UTC code/branches/pcre16/pcre_fullinfo.c revision 809 by zherczeg, Mon Dec 19 11:04:45 2011 UTC
# Line 2  Line 2 
2  *      Perl-Compatible Regular Expressions       *  *      Perl-Compatible Regular Expressions       *
3  *************************************************/  *************************************************/
4    
5  /*PCRE is a library of functions to support regular expressions whose syntax  /* PCRE is a library of functions to support regular expressions whose syntax
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2007 University of Cambridge             Copyright (c) 1997-2011 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 43  information about a compiled pattern. */ Line 43  information about a compiled pattern. */
43    
44    
45  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
46  #include <config.h>  #include "config.h"
47  #endif  #endif
48    
49  #include "pcre_internal.h"  #include "pcre_internal.h"
# Line 65  Arguments: Line 65  Arguments:
65  Returns:           0 if data returned, negative on error  Returns:           0 if data returned, negative on error
66  */  */
67    
68  PCRE_EXP_DEFN int  #ifdef COMPILE_PCRE8
69    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
70  pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,  pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
71    void *where)    void *where)
72    #else
73    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
74    pcre16_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, int what,
75      void *where)
76    #endif
77  {  {
 real_pcre internal_re;  
 pcre_study_data internal_study;  
78  const real_pcre *re = (const real_pcre *)argument_re;  const real_pcre *re = (const real_pcre *)argument_re;
79  const pcre_study_data *study = NULL;  const pcre_study_data *study = NULL;
80    
# Line 79  if (re == NULL || where == NULL) return Line 83  if (re == NULL || where == NULL) return
83  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
84    study = (const pcre_study_data *)extra_data->study_data;    study = (const pcre_study_data *)extra_data->study_data;
85    
86    /* Check that the first field in the block is the magic number. If it is not,
87    return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
88    REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
89    means that the pattern is likely compiled with different endianness. */
90    
91  if (re->magic_number != MAGIC_NUMBER)  if (re->magic_number != MAGIC_NUMBER)
92    {    return re->magic_number == REVERSED_MAGIC_NUMBER?
93    re = _pcre_try_flipped(re, &internal_re, study, &internal_study);      PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
94    if (re == NULL) return PCRE_ERROR_BADMAGIC;  if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
   if (study != NULL) study = &internal_study;  
   }  
95    
96  switch (what)  switch (what)
97    {    {
98    case PCRE_INFO_OPTIONS:    case PCRE_INFO_OPTIONS:
99    *((unsigned long int *)where) = re->options & PUBLIC_OPTIONS;    *((unsigned long int *)where) = re->options & PUBLIC_COMPILE_OPTIONS;
100    break;    break;
101    
102    case PCRE_INFO_SIZE:    case PCRE_INFO_SIZE:
# Line 100  switch (what) Line 107  switch (what)
107    *((size_t *)where) = (study == NULL)? 0 : study->size;    *((size_t *)where) = (study == NULL)? 0 : study->size;
108    break;    break;
109    
110      case PCRE_INFO_JITSIZE:
111    #ifdef SUPPORT_JIT
112      *((size_t *)where) =
113          (extra_data != NULL &&
114          (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
115          extra_data->executable_jit != NULL)?
116        PRIV(jit_get_size)(extra_data->executable_jit) : 0;
117    #else
118      *((size_t *)where) = 0;
119    #endif
120    
121      break;
122    
123    case PCRE_INFO_CAPTURECOUNT:    case PCRE_INFO_CAPTURECOUNT:
124    *((int *)where) = re->top_bracket;    *((int *)where) = re->top_bracket;
125    break;    break;
# Line 110  switch (what) Line 130  switch (what)
130    
131    case PCRE_INFO_FIRSTBYTE:    case PCRE_INFO_FIRSTBYTE:
132    *((int *)where) =    *((int *)where) =
133      ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :      ((re->flags & PCRE_FIRSTSET) != 0)? re->first_char :
134      ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;      ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
135    break;    break;
136    
# Line 118  switch (what) Line 138  switch (what)
138    block, not the internal copy (with flipped integer fields). */    block, not the internal copy (with flipped integer fields). */
139    
140    case PCRE_INFO_FIRSTTABLE:    case PCRE_INFO_FIRSTTABLE:
141    *((const uschar **)where) =    *((const pcre_uint8 **)where) =
142      (study != NULL && (study->options & PCRE_STUDY_MAPPED) != 0)?      (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)?
143        ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;        ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
144    break;    break;
145    
146      case PCRE_INFO_MINLENGTH:
147      *((int *)where) =
148        (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
149          study->minlength : -1;
150      break;
151    
152      case PCRE_INFO_JIT:
153      *((int *)where) = extra_data != NULL &&
154                        (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
155                        extra_data->executable_jit != NULL;
156      break;
157    
158    case PCRE_INFO_LASTLITERAL:    case PCRE_INFO_LASTLITERAL:
159    *((int *)where) =    *((int *)where) =
160      ((re->flags & PCRE_REQCHSET) != 0)? re->req_byte : -1;      ((re->flags & PCRE_REQCHSET) != 0)? re->req_char : -1;
161    break;    break;
162    
163    case PCRE_INFO_NAMEENTRYSIZE:    case PCRE_INFO_NAMEENTRYSIZE:
# Line 137  switch (what) Line 169  switch (what)
169    break;    break;
170    
171    case PCRE_INFO_NAMETABLE:    case PCRE_INFO_NAMETABLE:
172    *((const uschar **)where) = (const uschar *)re + re->name_table_offset;    *((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset;
173    break;    break;
174    
175    case PCRE_INFO_DEFAULT_TABLES:    case PCRE_INFO_DEFAULT_TABLES:
176    *((const uschar **)where) = (const uschar *)(_pcre_default_tables);    *((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables));
177    break;    break;
178    
179      /* From release 8.00 this will always return TRUE because NOPARTIAL is
180      no longer ever set (the restrictions have been removed). */
181    
182    case PCRE_INFO_OKPARTIAL:    case PCRE_INFO_OKPARTIAL:
183    *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;    *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
184    break;    break;

Legend:
Removed from v.230  
changed lines
  Added in v.809

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12