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

Diff of /code/trunk/pcreposix.c

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

revision 7 by nigel, Sat Feb 24 21:38:09 2007 UTC revision 35 by nigel, Sat Feb 24 21:39:05 2007 UTC
# Line 12  functions. Line 12  functions.
12    
13  Written by: Philip Hazel <ph10@cam.ac.uk>  Written by: Philip Hazel <ph10@cam.ac.uk>
14    
15             Copyright (c) 1997 University of Cambridge             Copyright (c) 1997-1999 University of Cambridge
16    
17  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
18  Permission is granted to anyone to use this software for any purpose on any  Permission is granted to anyone to use this software for any purpose on any
# Line 28  restrictions: Line 28  restrictions:
28    
29  3. Altered versions must be plainly marked as such, and must not be  3. Altered versions must be plainly marked as such, and must not be
30     misrepresented as being the original software.     misrepresented as being the original software.
31    
32    4. If PCRE is embedded in any software that is released under the GNU
33       General Purpose Licence (GPL), then the terms of that licence shall
34       supersede any condition above with which it is incompatible.
35  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
36  */  */
37    
# Line 42  restrictions: Line 46  restrictions:
46  static const char *estring[] = {  static const char *estring[] = {
47    ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,  ERR10,    ERR1,  ERR2,  ERR3,  ERR4,  ERR5,  ERR6,  ERR7,  ERR8,  ERR9,  ERR10,
48    ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,    ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19, ERR20,
49    ERR21, ERR22, ERR23 };    ERR21, ERR22, ERR23, ERR24, ERR25 };
50    
51  static int eint[] = {  static int eint[] = {
52    REG_EESCAPE, /* "\\ at end of pattern" */    REG_EESCAPE, /* "\\ at end of pattern" */
# Line 67  static int eint[] = { Line 71  static int eint[] = {
71    REG_ESIZE,   /* "regular expression too large" */    REG_ESIZE,   /* "regular expression too large" */
72    REG_ESPACE,  /* "failed to get memory" */    REG_ESPACE,  /* "failed to get memory" */
73    REG_EPAREN,  /* "unmatched brackets" */    REG_EPAREN,  /* "unmatched brackets" */
74    REG_ASSERT   /* "internal error: code overflow" */    REG_ASSERT,  /* "internal error: code overflow" */
75      REG_BADPAT,  /* "unrecognized character after (?<" */
76      REG_BADPAT,  /* "lookbehind assertion is not fixed length" */
77      REG_BADPAT,  /* "malformed number after (?(" */
78      REG_BADPAT,  /* "conditional group containe more than two branches" */
79      REG_BADPAT   /* "assertion expected after (?(" */
80  };  };
81    
82  /* Table of texts corresponding to POSIX error codes */  /* Table of texts corresponding to POSIX error codes */
# Line 135  addlength = (preg != NULL && (int)preg-> Line 144  addlength = (preg != NULL && (int)preg->
144  if (errbuf_size > 0)  if (errbuf_size > 0)
145    {    {
146    if (addlength > 0 && errbuf_size >= length + addlength)    if (addlength > 0 && errbuf_size >= length + addlength)
147      sprintf(errbuf, "%s%s%-6d", message, addmessage, preg->re_erroffset);      sprintf(errbuf, "%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
148    else    else
149      {      {
150      strncpy(errbuf, message, errbuf_size - 1);      strncpy(errbuf, message, errbuf_size - 1);
# Line 186  int options = 0; Line 195  int options = 0;
195  if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;  if ((cflags & REG_ICASE) != 0) options |= PCRE_CASELESS;
196  if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;  if ((cflags & REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
197    
198  preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset);  preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
199  preg->re_erroffset = erroffset;  preg->re_erroffset = erroffset;
200    
201  if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr);  if (preg->re_pcre == NULL) return pcre_posix_error_code(errorptr);
# Line 212  int options = 0; Line 221  int options = 0;
221  if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;  if ((eflags & REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
222  if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;  if ((eflags & REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
223    
224  preg->re_erroffset = -1;   /* Only has meaning after compile */  preg->re_erroffset = (size_t)(-1);   /* Only has meaning after compile */
225    
226  rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), options,  rc = pcre_exec(preg->re_pcre, NULL, string, (int)strlen(string), 0, options,
227    (int *)pmatch, nmatch * 2);    (int *)pmatch, nmatch * 2);
228    
229  if (rc == 0) return 0;    /* All pmatch were filled in */  if (rc == 0) return 0;    /* All pmatch were filled in */
# Line 229  if (rc > 0) Line 238  if (rc > 0)
238  else switch(rc)  else switch(rc)
239    {    {
240    case PCRE_ERROR_NOMATCH: return REG_NOMATCH;    case PCRE_ERROR_NOMATCH: return REG_NOMATCH;
   case PCRE_ERROR_BADREF: return REG_ESUBREG;  
241    case PCRE_ERROR_NULL: return REG_INVARG;    case PCRE_ERROR_NULL: return REG_INVARG;
242    case PCRE_ERROR_BADOPTION: return REG_INVARG;    case PCRE_ERROR_BADOPTION: return REG_INVARG;
243    case PCRE_ERROR_BADMAGIC: return REG_INVARG;    case PCRE_ERROR_BADMAGIC: return REG_INVARG;

Legend:
Removed from v.7  
changed lines
  Added in v.35

  ViewVC Help
Powered by ViewVC 1.1.5