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

Diff of /code/trunk/pcre_get.c

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

revision 236 by ph10, Tue Sep 11 12:57:06 2007 UTC revision 1055 by chpe, Tue Oct 16 15:53:30 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-2007 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 65  Returns:      the number of the named pa Line 65  Returns:      the number of the named pa
65                  (PCRE_ERROR_NOSUBSTRING) if not found                  (PCRE_ERROR_NOSUBSTRING) if not found
66  */  */
67    
68  int  #if defined COMPILE_PCRE8
69    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
70  pcre_get_stringnumber(const pcre *code, const char *stringname)  pcre_get_stringnumber(const pcre *code, const char *stringname)
71    #elif defined COMPILE_PCRE16
72    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
73    pcre16_get_stringnumber(const pcre16 *code, PCRE_SPTR16 stringname)
74    #elif defined COMPILE_PCRE32
75    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
76    pcre32_get_stringnumber(const pcre32 *code, PCRE_SPTR32 stringname)
77    #endif
78  {  {
79  int rc;  int rc;
80  int entrysize;  int entrysize;
81  int top, bot;  int top, bot;
82  uschar *nametable;  pcre_uchar *nametable;
83    
84    #ifdef COMPILE_PCRE8
85  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
86    return rc;    return rc;
87  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
# Line 81  if ((rc = pcre_fullinfo(code, NULL, PCRE Line 90  if ((rc = pcre_fullinfo(code, NULL, PCRE
90    return rc;    return rc;
91  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
92    return rc;    return rc;
93    #endif
94    #ifdef COMPILE_PCRE16
95    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
96      return rc;
97    if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
98    
99    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
100      return rc;
101    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
102      return rc;
103    #endif
104    #ifdef COMPILE_PCRE32
105    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
106      return rc;
107    if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
108    
109    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
110      return rc;
111    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
112      return rc;
113    #endif
114    
115  bot = 0;  bot = 0;
116  while (top > bot)  while (top > bot)
117    {    {
118    int mid = (top + bot) / 2;    int mid = (top + bot) / 2;
119    uschar *entry = nametable + entrysize*mid;    pcre_uchar *entry = nametable + entrysize*mid;
120    int c = strcmp(stringname, (char *)(entry + 2));    int c = STRCMP_UC_UC((pcre_uchar *)stringname,
121    if (c == 0) return (entry[0] << 8) + entry[1];      (pcre_uchar *)(entry + IMM2_SIZE));
122      if (c == 0) return GET2(entry, 0);
123    if (c > 0) bot = mid + 1; else top = mid;    if (c > 0) bot = mid + 1; else top = mid;
124    }    }
125    
# Line 114  Returns:      the length of each entry, Line 145  Returns:      the length of each entry,
145                  (PCRE_ERROR_NOSUBSTRING) if not found                  (PCRE_ERROR_NOSUBSTRING) if not found
146  */  */
147    
148  int  #if defined COMPILE_PCRE8
149    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
150  pcre_get_stringtable_entries(const pcre *code, const char *stringname,  pcre_get_stringtable_entries(const pcre *code, const char *stringname,
151    char **firstptr, char **lastptr)    char **firstptr, char **lastptr)
152    #elif defined COMPILE_PCRE16
153    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
154    pcre16_get_stringtable_entries(const pcre16 *code, PCRE_SPTR16 stringname,
155      PCRE_UCHAR16 **firstptr, PCRE_UCHAR16 **lastptr)
156    #elif defined COMPILE_PCRE32
157    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
158    pcre32_get_stringtable_entries(const pcre32 *code, PCRE_SPTR32 stringname,
159      PCRE_UCHAR32 **firstptr, PCRE_UCHAR32 **lastptr)
160    #endif
161  {  {
162  int rc;  int rc;
163  int entrysize;  int entrysize;
164  int top, bot;  int top, bot;
165  uschar *nametable, *lastentry;  pcre_uchar *nametable, *lastentry;
166    
167    #ifdef COMPILE_PCRE8
168  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
169    return rc;    return rc;
170  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
# Line 131  if ((rc = pcre_fullinfo(code, NULL, PCRE Line 173  if ((rc = pcre_fullinfo(code, NULL, PCRE
173    return rc;    return rc;
174  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)  if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
175    return rc;    return rc;
176    #endif
177    #ifdef COMPILE_PCRE16
178    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
179      return rc;
180    if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
181    
182    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
183      return rc;
184    if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
185      return rc;
186    #endif
187    #ifdef COMPILE_PCRE32
188    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
189      return rc;
190    if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
191    
192    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
193      return rc;
194    if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
195      return rc;
196    #endif
197    
198  lastentry = nametable + entrysize * (top - 1);  lastentry = nametable + entrysize * (top - 1);
199  bot = 0;  bot = 0;
200  while (top > bot)  while (top > bot)
201    {    {
202    int mid = (top + bot) / 2;    int mid = (top + bot) / 2;
203    uschar *entry = nametable + entrysize*mid;    pcre_uchar *entry = nametable + entrysize*mid;
204    int c = strcmp(stringname, (char *)(entry + 2));    int c = STRCMP_UC_UC((pcre_uchar *)stringname,
205        (pcre_uchar *)(entry + IMM2_SIZE));
206    if (c == 0)    if (c == 0)
207      {      {
208      uschar *first = entry;      pcre_uchar *first = entry;
209      uschar *last = entry;      pcre_uchar *last = entry;
210      while (first > nametable)      while (first > nametable)
211        {        {
212        if (strcmp(stringname, (char *)(first - entrysize + 2)) != 0) break;        if (STRCMP_UC_UC((pcre_uchar *)stringname,
213            (pcre_uchar *)(first - entrysize + IMM2_SIZE)) != 0) break;
214        first -= entrysize;        first -= entrysize;
215        }        }
216      while (last < lastentry)      while (last < lastentry)
217        {        {
218        if (strcmp(stringname, (char *)(last + entrysize + 2)) != 0) break;        if (STRCMP_UC_UC((pcre_uchar *)stringname,
219            (pcre_uchar *)(last + entrysize + IMM2_SIZE)) != 0) break;
220        last += entrysize;        last += entrysize;
221        }        }
222    #if defined COMPILE_PCRE8
223      *firstptr = (char *)first;      *firstptr = (char *)first;
224      *lastptr = (char *)last;      *lastptr = (char *)last;
225    #elif defined COMPILE_PCRE16
226        *firstptr = (PCRE_UCHAR16 *)first;
227        *lastptr = (PCRE_UCHAR16 *)last;
228    #elif defined COMPILE_PCRE32
229        *firstptr = (PCRE_UCHAR32 *)first;
230        *lastptr = (PCRE_UCHAR32 *)last;
231    #endif
232      return entrysize;      return entrysize;
233      }      }
234    if (c > 0) bot = mid + 1; else top = mid;    if (c > 0) bot = mid + 1; else top = mid;
# Line 182  Returns:       the number of the first t Line 256  Returns:       the number of the first t
256                 or a negative number on error                 or a negative number on error
257  */  */
258    
259    #if defined COMPILE_PCRE8
260  static int  static int
261  get_first_set(const pcre *code, const char *stringname, int *ovector)  get_first_set(const pcre *code, const char *stringname, int *ovector)
262    #elif defined COMPILE_PCRE16
263    static int
264    get_first_set(const pcre16 *code, PCRE_SPTR16 stringname, int *ovector)
265    #elif defined COMPILE_PCRE32
266    static int
267    get_first_set(const pcre32 *code, PCRE_SPTR32 stringname, int *ovector)
268    #endif
269  {  {
270  const real_pcre *re = (const real_pcre *)code;  const REAL_PCRE *re = (const REAL_PCRE *)code;
271  int entrysize;  int entrysize;
272    pcre_uchar *entry;
273    #if defined COMPILE_PCRE8
274  char *first, *last;  char *first, *last;
275  uschar *entry;  #elif defined COMPILE_PCRE16
276    PCRE_UCHAR16 *first, *last;
277    #elif defined COMPILE_PCRE32
278    PCRE_UCHAR32 *first, *last;
279    #endif
280    
281    #if defined COMPILE_PCRE8
282  if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)  if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
283    return pcre_get_stringnumber(code, stringname);    return pcre_get_stringnumber(code, stringname);
284  entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);  entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
285    #elif defined COMPILE_PCRE16
286    if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
287      return pcre16_get_stringnumber(code, stringname);
288    entrysize = pcre16_get_stringtable_entries(code, stringname, &first, &last);
289    #elif defined COMPILE_PCRE32
290    if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
291      return pcre32_get_stringnumber(code, stringname);
292    entrysize = pcre32_get_stringtable_entries(code, stringname, &first, &last);
293    #endif
294  if (entrysize <= 0) return entrysize;  if (entrysize <= 0) return entrysize;
295  for (entry = (uschar *)first; entry <= (uschar *)last; entry += entrysize)  for (entry = (pcre_uchar *)first; entry <= (pcre_uchar *)last; entry += entrysize)
296    {    {
297    int n = (entry[0] << 8) + entry[1];    int n = GET2(entry, 0);
298    if (ovector[n*2] >= 0) return n;    if (ovector[n*2] >= 0) return n;
299    }    }
300  return (first[0] << 8) + first[1];  return GET2(entry, 0);
301  }  }
302    
303    
# Line 231  Returns:         if successful: Line 330  Returns:         if successful:
330                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
331  */  */
332    
333  int  #if defined COMPILE_PCRE8
334    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
335  pcre_copy_substring(const char *subject, int *ovector, int stringcount,  pcre_copy_substring(const char *subject, int *ovector, int stringcount,
336    int stringnumber, char *buffer, int size)    int stringnumber, char *buffer, int size)
337    #elif defined COMPILE_PCRE16
338    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
339    pcre16_copy_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
340      int stringnumber, PCRE_UCHAR16 *buffer, int size)
341    #elif defined COMPILE_PCRE32
342    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
343    pcre32_copy_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
344      int stringnumber, PCRE_UCHAR32 *buffer, int size)
345    #endif
346  {  {
347  int yield;  int yield;
348  if (stringnumber < 0 || stringnumber >= stringcount)  if (stringnumber < 0 || stringnumber >= stringcount)
# Line 241  if (stringnumber < 0 || stringnumber >= Line 350  if (stringnumber < 0 || stringnumber >=
350  stringnumber *= 2;  stringnumber *= 2;
351  yield = ovector[stringnumber+1] - ovector[stringnumber];  yield = ovector[stringnumber+1] - ovector[stringnumber];
352  if (size < yield + 1) return PCRE_ERROR_NOMEMORY;  if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
353  memcpy(buffer, subject + ovector[stringnumber], yield);  memcpy(buffer, subject + ovector[stringnumber], IN_UCHARS(yield));
354  buffer[yield] = 0;  buffer[yield] = 0;
355  return yield;  return yield;
356  }  }
# Line 276  Returns:         if successful: Line 385  Returns:         if successful:
385                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
386  */  */
387    
388  int  #if defined COMPILE_PCRE8
389  pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector,  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
390    int stringcount, const char *stringname, char *buffer, int size)  pcre_copy_named_substring(const pcre *code, const char *subject,
391      int *ovector, int stringcount, const char *stringname,
392      char *buffer, int size)
393    #elif defined COMPILE_PCRE16
394    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
395    pcre16_copy_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
396      int *ovector, int stringcount, PCRE_SPTR16 stringname,
397      PCRE_UCHAR16 *buffer, int size)
398    #elif defined COMPILE_PCRE32
399    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
400    pcre32_copy_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
401      int *ovector, int stringcount, PCRE_SPTR32 stringname,
402      PCRE_UCHAR32 *buffer, int size)
403    #endif
404  {  {
405  int n = get_first_set(code, stringname, ovector);  int n = get_first_set(code, stringname, ovector);
406  if (n <= 0) return n;  if (n <= 0) return n;
407    #if defined COMPILE_PCRE8
408  return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);  return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
409    #elif defined COMPILE_PCRE16
410    return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size);
411    #elif defined COMPILE_PCRE32
412    return pcre32_copy_substring(subject, ovector, stringcount, n, buffer, size);
413    #endif
414  }  }
415    
416    
# Line 308  Returns:         if successful: 0 Line 436  Returns:         if successful: 0
436                     PCRE_ERROR_NOMEMORY (-6) failed to get store                     PCRE_ERROR_NOMEMORY (-6) failed to get store
437  */  */
438    
439  int  #if defined COMPILE_PCRE8
440    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
441  pcre_get_substring_list(const char *subject, int *ovector, int stringcount,  pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
442    const char ***listptr)    const char ***listptr)
443    #elif defined COMPILE_PCRE16
444    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
445    pcre16_get_substring_list(PCRE_SPTR16 subject, int *ovector, int stringcount,
446      PCRE_SPTR16 **listptr)
447    #elif defined COMPILE_PCRE32
448    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
449    pcre32_get_substring_list(PCRE_SPTR32 subject, int *ovector, int stringcount,
450      PCRE_SPTR32 **listptr)
451    #endif
452  {  {
453  int i;  int i;
454  int size = sizeof(char *);  int size = sizeof(pcre_uchar *);
455  int double_count = stringcount * 2;  int double_count = stringcount * 2;
456  char **stringlist;  pcre_uchar **stringlist;
457  char *p;  pcre_uchar *p;
458    
459  for (i = 0; i < double_count; i += 2)  for (i = 0; i < double_count; i += 2)
460    size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;    size += sizeof(pcre_uchar *) + IN_UCHARS(ovector[i+1] - ovector[i] + 1);
461    
462  stringlist = (char **)(pcre_malloc)(size);  stringlist = (pcre_uchar **)(PUBL(malloc))(size);
463  if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;  if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;
464    
465    #if defined COMPILE_PCRE8
466  *listptr = (const char **)stringlist;  *listptr = (const char **)stringlist;
467  p = (char *)(stringlist + stringcount + 1);  #elif defined COMPILE_PCRE16
468    *listptr = (PCRE_SPTR16 *)stringlist;
469    #elif defined COMPILE_PCRE32
470    *listptr = (PCRE_SPTR32 *)stringlist;
471    #endif
472    p = (pcre_uchar *)(stringlist + stringcount + 1);
473    
474  for (i = 0; i < double_count; i += 2)  for (i = 0; i < double_count; i += 2)
475    {    {
476    int len = ovector[i+1] - ovector[i];    int len = ovector[i+1] - ovector[i];
477    memcpy(p, subject + ovector[i], len);    memcpy(p, subject + ovector[i], IN_UCHARS(len));
478    *stringlist++ = p;    *stringlist++ = p;
479    p += len;    p += len;
480    *p++ = 0;    *p++ = 0;
# Line 347  return 0; Line 491  return 0;
491  *************************************************/  *************************************************/
492    
493  /* This function exists for the benefit of people calling PCRE from non-C  /* This function exists for the benefit of people calling PCRE from non-C
494  programs that can call its functions, but not free() or (pcre_free)() directly.  programs that can call its functions, but not free() or (PUBL(free))()
495    directly.
496    
497  Argument:   the result of a previous pcre_get_substring_list()  Argument:   the result of a previous pcre_get_substring_list()
498  Returns:    nothing  Returns:    nothing
499  */  */
500    
501  void  #if defined COMPILE_PCRE8
502    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
503  pcre_free_substring_list(const char **pointer)  pcre_free_substring_list(const char **pointer)
504    #elif defined COMPILE_PCRE16
505    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
506    pcre16_free_substring_list(PCRE_SPTR16 *pointer)
507    #elif defined COMPILE_PCRE32
508    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
509    pcre32_free_substring_list(PCRE_SPTR32 *pointer)
510    #endif
511  {  {
512  (pcre_free)((void *)pointer);  (PUBL(free))((void *)pointer);
513  }  }
514    
515    
# Line 386  Returns:         if successful: Line 539  Returns:         if successful:
539                     PCRE_ERROR_NOSUBSTRING (-7) substring not present                     PCRE_ERROR_NOSUBSTRING (-7) substring not present
540  */  */
541    
542  int  #if defined COMPILE_PCRE8
543    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
544  pcre_get_substring(const char *subject, int *ovector, int stringcount,  pcre_get_substring(const char *subject, int *ovector, int stringcount,
545    int stringnumber, const char **stringptr)    int stringnumber, const char **stringptr)
546    #elif defined COMPILE_PCRE16
547    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
548    pcre16_get_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
549      int stringnumber, PCRE_SPTR16 *stringptr)
550    #elif defined COMPILE_PCRE32
551    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
552    pcre32_get_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
553      int stringnumber, PCRE_SPTR32 *stringptr)
554    #endif
555  {  {
556  int yield;  int yield;
557  char *substring;  pcre_uchar *substring;
558  if (stringnumber < 0 || stringnumber >= stringcount)  if (stringnumber < 0 || stringnumber >= stringcount)
559    return PCRE_ERROR_NOSUBSTRING;    return PCRE_ERROR_NOSUBSTRING;
560  stringnumber *= 2;  stringnumber *= 2;
561  yield = ovector[stringnumber+1] - ovector[stringnumber];  yield = ovector[stringnumber+1] - ovector[stringnumber];
562  substring = (char *)(pcre_malloc)(yield + 1);  substring = (pcre_uchar *)(PUBL(malloc))(IN_UCHARS(yield + 1));
563  if (substring == NULL) return PCRE_ERROR_NOMEMORY;  if (substring == NULL) return PCRE_ERROR_NOMEMORY;
564  memcpy(substring, subject + ovector[stringnumber], yield);  memcpy(substring, subject + ovector[stringnumber], IN_UCHARS(yield));
565  substring[yield] = 0;  substring[yield] = 0;
566  *stringptr = substring;  #if defined COMPILE_PCRE8
567    *stringptr = (const char *)substring;
568    #elif defined COMPILE_PCRE16
569    *stringptr = (PCRE_SPTR16)substring;
570    #elif defined COMPILE_PCRE32
571    *stringptr = (PCRE_SPTR32)substring;
572    #endif
573  return yield;  return yield;
574  }  }
575    
# Line 433  Returns:         if successful: Line 602  Returns:         if successful:
602                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
603  */  */
604    
605  int  #if defined COMPILE_PCRE8
606  pcre_get_named_substring(const pcre *code, const char *subject, int *ovector,  PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
607    int stringcount, const char *stringname, const char **stringptr)  pcre_get_named_substring(const pcre *code, const char *subject,
608      int *ovector, int stringcount, const char *stringname,
609      const char **stringptr)
610    #elif defined COMPILE_PCRE16
611    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
612    pcre16_get_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
613      int *ovector, int stringcount, PCRE_SPTR16 stringname,
614      PCRE_SPTR16 *stringptr)
615    #elif defined COMPILE_PCRE32
616    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
617    pcre32_get_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
618      int *ovector, int stringcount, PCRE_SPTR32 stringname,
619      PCRE_SPTR32 *stringptr)
620    #endif
621  {  {
622  int n = get_first_set(code, stringname, ovector);  int n = get_first_set(code, stringname, ovector);
623  if (n <= 0) return n;  if (n <= 0) return n;
624    #if defined COMPILE_PCRE8
625  return pcre_get_substring(subject, ovector, stringcount, n, stringptr);  return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
626    #elif defined COMPILE_PCRE16
627    return pcre16_get_substring(subject, ovector, stringcount, n, stringptr);
628    #elif defined COMPILE_PCRE32
629    return pcre32_get_substring(subject, ovector, stringcount, n, stringptr);
630    #endif
631  }  }
632    
633    
# Line 450  return pcre_get_substring(subject, ovect Line 638  return pcre_get_substring(subject, ovect
638  *************************************************/  *************************************************/
639    
640  /* This function exists for the benefit of people calling PCRE from non-C  /* This function exists for the benefit of people calling PCRE from non-C
641  programs that can call its functions, but not free() or (pcre_free)() directly.  programs that can call its functions, but not free() or (PUBL(free))()
642    directly.
643    
644  Argument:   the result of a previous pcre_get_substring()  Argument:   the result of a previous pcre_get_substring()
645  Returns:    nothing  Returns:    nothing
646  */  */
647    
648  void  #if defined COMPILE_PCRE8
649    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
650  pcre_free_substring(const char *pointer)  pcre_free_substring(const char *pointer)
651    #elif defined COMPILE_PCRE16
652    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
653    pcre16_free_substring(PCRE_SPTR16 pointer)
654    #elif defined COMPILE_PCRE32
655    PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
656    pcre32_free_substring(PCRE_SPTR32 pointer)
657    #endif
658  {  {
659  (pcre_free)((void *)pointer);  (PUBL(free))((void *)pointer);
660  }  }
661    
662  /* End of pcre_get.c */  /* End of pcre_get.c */

Legend:
Removed from v.236  
changed lines
  Added in v.1055

  ViewVC Help
Powered by ViewVC 1.1.5