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

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

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

code/trunk/pcre_info.c revision 230 by ph10, Mon Sep 10 13:23:56 2007 UTC code/branches/pcre16/pcre_info.c revision 809 by zherczeg, Mon Dec 19 11:04:45 2011 UTC
# Line 6  Line 6 
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-2009 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 44  deprecated, as it has been superseded by Line 44  deprecated, as it has been superseded by
44    
45    
46  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
47  #include <config.h>  #include "config.h"
48  #endif  #endif
49    
50  #include "pcre_internal.h"  #include "pcre_internal.h"
# Line 72  Returns:        number of capturing subp Line 72  Returns:        number of capturing subp
72                  or negative values on error                  or negative values on error
73  */  */
74    
75  PCRE_EXP_DEFN int  #ifdef COMPILE_PCRE8
76  pcre_info(const pcre *argument_re, int *optptr, int *first_byte)  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
77    pcre_info(const pcre *argument_re, int *optptr, int *first_char)
78    #else
79    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
80    pcre16_info(const pcre *argument_re, int *optptr, int *first_char)
81    #endif
82  {  {
 real_pcre internal_re;  
83  const real_pcre *re = (const real_pcre *)argument_re;  const real_pcre *re = (const real_pcre *)argument_re;
84  if (re == NULL) return PCRE_ERROR_NULL;  if (re == NULL) return PCRE_ERROR_NULL;
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, NULL, NULL);      PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
94    if (re == NULL) return PCRE_ERROR_BADMAGIC;  if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
95    }  
96  if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_OPTIONS);  if (optptr != NULL) *optptr = (int)(re->options & PUBLIC_COMPILE_OPTIONS);
97  if (first_byte != NULL)  if (first_char != NULL)
98    *first_byte = ((re->flags & PCRE_FIRSTSET) != 0)? re->first_byte :    *first_char = ((re->flags & PCRE_FIRSTSET) != 0)? re->first_char :
99       ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;       ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
100  return re->top_bracket;  return re->top_bracket;
101  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.5