/[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 510 by ph10, Sat Mar 27 17:45:29 2010 UTC revision 903 by ph10, Sat Jan 21 16:37:17 2012 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-2009 University of Cambridge             Copyright (c) 1997-2012 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 57  previously been set. */ Line 57  previously been set. */
57  #  define PCREPOSIX_EXP_DEFN __declspec(dllexport)  #  define PCREPOSIX_EXP_DEFN __declspec(dllexport)
58  #endif  #endif
59    
60    /* We include pcre.h before pcre_internal.h so that the PCRE library functions
61    are declared as "import" for Windows by defining PCRE_EXP_DECL as "import".
62    This is needed even though pcre_internal.h itself includes pcre.h, because it
63    does so after it has set PCRE_EXP_DECL to "export" if it is not already set. */
64    
65  #include "pcre.h"  #include "pcre.h"
66  #include "pcre_internal.h"  #include "pcre_internal.h"
67  #include "pcreposix.h"  #include "pcreposix.h"
# Line 145  static const int eint[] = { Line 150  static const int eint[] = {
150    /* 65 */    /* 65 */
151    REG_BADPAT,  /* different names for subpatterns of the same number are not allowed */    REG_BADPAT,  /* different names for subpatterns of the same number are not allowed */
152    REG_BADPAT,  /* (*MARK) must have an argument */    REG_BADPAT,  /* (*MARK) must have an argument */
153      REG_INVARG,  /* this version of PCRE is not compiled with PCRE_UCP support */
154      REG_BADPAT,  /* \c must be followed by an ASCII character */
155      REG_BADPAT,  /* \k is not followed by a braced, angle-bracketed, or quoted name */
156      /* 70 */
157      REG_BADPAT,  /* internal error: unknown opcode in find_fixedlength() */
158      REG_BADPAT,  /* \N is not supported in a class */
159      REG_BADPAT,  /* too many forward references */
160      REG_BADPAT,  /* disallowed UTF-8/16 code point (>= 0xd800 && <= 0xdfff) */
161      REG_BADPAT   /* invalid UTF-16 string (should not occur) */
162  };  };
163    
164  /* Table of texts corresponding to POSIX error codes */  /* Table of texts corresponding to POSIX error codes */
# Line 215  return length + addlength; Line 229  return length + addlength;
229  PCREPOSIX_EXP_DEFN void PCRE_CALL_CONVENTION  PCREPOSIX_EXP_DEFN void PCRE_CALL_CONVENTION
230  regfree(regex_t *preg)  regfree(regex_t *preg)
231  {  {
232  (pcre_free)(preg->re_pcre);  (PUBL(free))(preg->re_pcre);
233  }  }
234    
235    
# Line 248  if ((cflags & REG_NEWLINE) != 0) option Line 262  if ((cflags & REG_NEWLINE) != 0) option
262  if ((cflags & REG_DOTALL) != 0)   options |= PCRE_DOTALL;  if ((cflags & REG_DOTALL) != 0)   options |= PCRE_DOTALL;
263  if ((cflags & REG_NOSUB) != 0)    options |= PCRE_NO_AUTO_CAPTURE;  if ((cflags & REG_NOSUB) != 0)    options |= PCRE_NO_AUTO_CAPTURE;
264  if ((cflags & REG_UTF8) != 0)     options |= PCRE_UTF8;  if ((cflags & REG_UTF8) != 0)     options |= PCRE_UTF8;
265    if ((cflags & REG_UCP) != 0)      options |= PCRE_UCP;
266  if ((cflags & REG_UNGREEDY) != 0) options |= PCRE_UNGREEDY;  if ((cflags & REG_UNGREEDY) != 0) options |= PCRE_UNGREEDY;
267    
268  preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,  preg->re_pcre = pcre_compile2(pattern, options, &errorcode, &errorptr,
# Line 263  if (preg->re_pcre == NULL) Line 278  if (preg->re_pcre == NULL)
278      eint[errorcode] : REG_BADPAT;      eint[errorcode] : REG_BADPAT;
279    }    }
280    
281  preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL);  (void)pcre_fullinfo((const pcre *)preg->re_pcre, NULL, PCRE_INFO_CAPTURECOUNT,
282      &(preg->re_nsub));
283  return 0;  return 0;
284  }  }
285    
# Line 337  if ((eflags & REG_STARTEND) != 0) Line 353  if ((eflags & REG_STARTEND) != 0)
353  else  else
354    {    {
355    so = 0;    so = 0;
356    eo = strlen(string);    eo = (int)strlen(string);
357    }    }
358    
359  rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),  rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string + so, (eo - so),
360    0, options, ovector, nmatch * 3);    0, options, ovector, (int)(nmatch * 3));
361    
362  if (rc == 0) rc = nmatch;    /* All captured slots were filled in */  if (rc == 0) rc = (int)nmatch;    /* All captured slots were filled in */
363    
364  /* Successful match */  /* Successful match */
365    
# Line 389  switch(rc) Line 405  switch(rc)
405    case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE;    case PCRE_ERROR_MATCHLIMIT: return REG_ESPACE;
406    case PCRE_ERROR_BADUTF8: return REG_INVARG;    case PCRE_ERROR_BADUTF8: return REG_INVARG;
407    case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG;    case PCRE_ERROR_BADUTF8_OFFSET: return REG_INVARG;
408      case PCRE_ERROR_BADMODE: return REG_INVARG;
409    default: return REG_ASSERT;    default: return REG_ASSERT;
410    }    }
411  }  }

Legend:
Removed from v.510  
changed lines
  Added in v.903

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12