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

Diff of /code/trunk/pcretest.c

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

revision 841 by zherczeg, Sat Dec 31 07:04:43 2011 UTC revision 903 by ph10, Sat Jan 21 16:37:17 2012 UTC
# Line 209  argument, the casting might be incorrect Line 209  argument, the casting might be incorrect
209  #define READ_CAPTURE_NAME8(p, cn8, cn16, re) \  #define READ_CAPTURE_NAME8(p, cn8, cn16, re) \
210    p = read_capture_name8(p, cn8, re)    p = read_capture_name8(p, cn8, re)
211    
212    #define STRLEN8(p) ((int)strlen((char *)p))
213    
214  #define SET_PCRE_CALLOUT8(callout) \  #define SET_PCRE_CALLOUT8(callout) \
215    pcre_callout = callout    pcre_callout = callout
216    
217  #define STRLEN8(p) ((int)strlen((char *)p))  #define PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata) \
218       pcre_assign_jit_stack(extra, callback, userdata)
219    
220  #define PCRE_COMPILE8(re, pat, options, error, erroffset, tables) \  #define PCRE_COMPILE8(re, pat, options, error, erroffset, tables) \
221    re = pcre_compile((char *)pat, options, error, erroffset, tables)    re = pcre_compile((char *)pat, options, error, erroffset, tables)
# Line 268  argument, the casting might be incorrect Line 270  argument, the casting might be incorrect
270  #define PCRE_STUDY8(extra, re, options, error) \  #define PCRE_STUDY8(extra, re, options, error) \
271    extra = pcre_study(re, options, error)    extra = pcre_study(re, options, error)
272    
273    #define PCRE_JIT_STACK_ALLOC8(startsize, maxsize) \
274      pcre_jit_stack_alloc(startsize, maxsize)
275    
276    #define PCRE_JIT_STACK_FREE8(stack) \
277      pcre_jit_stack_free(stack)
278    
279  #endif /* SUPPORT_PCRE8 */  #endif /* SUPPORT_PCRE8 */
280    
281  /* -----------------------------------------------------------*/  /* -----------------------------------------------------------*/
# Line 286  argument, the casting might be incorrect Line 294  argument, the casting might be incorrect
294  #define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p))  #define STRLEN16(p) ((int)strlen16((PCRE_SPTR16)p))
295    
296  #define SET_PCRE_CALLOUT16(callout) \  #define SET_PCRE_CALLOUT16(callout) \
297    pcre16_callout = callout    pcre16_callout = (int (*)(pcre16_callout_block *))callout
298    
299    #define PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata) \
300      pcre16_assign_jit_stack((pcre16_extra *)extra, \
301        (pcre16_jit_callback)callback, userdata)
302    
303  #define PCRE_COMPILE16(re, pat, options, error, erroffset, tables) \  #define PCRE_COMPILE16(re, pat, options, error, erroffset, tables) \
304    re = pcre16_compile((PCRE_SPTR16)pat, options, error, erroffset, tables)    re = (pcre *)pcre16_compile((PCRE_SPTR16)pat, options, error, erroffset, \
305        tables)
306    
307  #define PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \  #define PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
308      namesptr, cbuffer, size) \      namesptr, cbuffer, size) \
309    rc = pcre16_copy_named_substring(re, (PCRE_SPTR16)bptr, offsets, count, \    rc = pcre16_copy_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
310      (PCRE_SPTR16)namesptr, (PCRE_SCHAR16 *)cbuffer, size/2)      count, (PCRE_SPTR16)namesptr, (PCRE_UCHAR16 *)cbuffer, size/2)
311    
312  #define PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size) \  #define PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size) \
313    rc = pcre16_copy_substring((PCRE_SPTR16)bptr, offsets, count, i, \    rc = pcre16_copy_substring((PCRE_SPTR16)bptr, offsets, count, i, \
314      (PCRE_SCHAR16 *)cbuffer, size/2)      (PCRE_UCHAR16 *)cbuffer, size/2)
315    
316  #define PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \  #define PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
317      offsets, size_offsets, workspace, size_workspace) \      offsets, size_offsets, workspace, size_workspace) \
318    count = pcre16_dfa_exec(re, extra, (PCRE_SPTR16)bptr, len, start_offset, \    count = pcre16_dfa_exec((pcre16 *)re, (pcre16_extra *)extra, \
319      options, offsets, size_offsets, workspace, size_workspace)      (PCRE_SPTR16)bptr, len, start_offset, options, offsets, size_offsets, \
320        workspace, size_workspace)
321    
322  #define PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \  #define PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
323      offsets, size_offsets) \      offsets, size_offsets) \
324    count = pcre16_exec(re, extra, (PCRE_SPTR16)bptr, len, start_offset, \    count = pcre16_exec((pcre16 *)re, (pcre16_extra *)extra, (PCRE_SPTR16)bptr, \
325      options, offsets, size_offsets)      len, start_offset, options, offsets, size_offsets)
326    
327  #define PCRE_FREE_STUDY16(extra) \  #define PCRE_FREE_STUDY16(extra) \
328    pcre16_free_study(extra)    pcre16_free_study((pcre16_extra *)extra)
329    
330  #define PCRE_FREE_SUBSTRING16(substring) \  #define PCRE_FREE_SUBSTRING16(substring) \
331    pcre16_free_substring((PCRE_SPTR16)substring)    pcre16_free_substring((PCRE_SPTR16)substring)
# Line 322  argument, the casting might be incorrect Line 335  argument, the casting might be incorrect
335    
336  #define PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \  #define PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
337      getnamesptr, subsptr) \      getnamesptr, subsptr) \
338    rc = pcre16_get_named_substring(re, (PCRE_SPTR16)bptr, offsets, count, \    rc = pcre16_get_named_substring((pcre16 *)re, (PCRE_SPTR16)bptr, offsets, \
339      (PCRE_SPTR16)getnamesptr, (PCRE_SPTR16 *)(void*)subsptr)      count, (PCRE_SPTR16)getnamesptr, (PCRE_SPTR16 *)(void*)subsptr)
340    
341  #define PCRE_GET_STRINGNUMBER16(n, rc, ptr) \  #define PCRE_GET_STRINGNUMBER16(n, rc, ptr) \
342    n = pcre16_get_stringnumber(re, (PCRE_SPTR16)ptr)    n = pcre16_get_stringnumber(re, (PCRE_SPTR16)ptr)
# Line 337  argument, the casting might be incorrect Line 350  argument, the casting might be incorrect
350      (PCRE_SPTR16 **)(void*)listptr)      (PCRE_SPTR16 **)(void*)listptr)
351    
352  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables) \  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables) \
353    rc = pcre16_pattern_to_host_byte_order(re, extra, tables)    rc = pcre16_pattern_to_host_byte_order((pcre16 *)re, (pcre16_extra *)extra, \
354        tables)
355    
356  #define PCRE_PRINTINT16(re, outfile, debug_lengths) \  #define PCRE_PRINTINT16(re, outfile, debug_lengths) \
357    pcre16_printint(re, outfile, debug_lengths)    pcre16_printint(re, outfile, debug_lengths)
358    
359  #define PCRE_STUDY16(extra, re, options, error) \  #define PCRE_STUDY16(extra, re, options, error) \
360    extra = pcre16_study(re, options, error)    extra = (pcre_extra *)pcre16_study((pcre16 *)re, options, error)
361    
362    #define PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
363      (pcre_jit_stack *)pcre16_jit_stack_alloc(startsize, maxsize)
364    
365    #define PCRE_JIT_STACK_FREE16(stack) \
366      pcre16_jit_stack_free((pcre16_jit_stack *)stack)
367    
368  #endif /* SUPPORT_PCRE16 */  #endif /* SUPPORT_PCRE16 */
369    
# Line 382  version is called. ----- */ Line 402  version is called. ----- */
402    
403  #define STRLEN(p) (use_pcre16? STRLEN16(p) : STRLEN8(p))  #define STRLEN(p) (use_pcre16? STRLEN16(p) : STRLEN8(p))
404    
405  #define PCRE_ASSIGN_JIT_STACK pcre_assign_jit_stack  #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
406      if (use_pcre16) \
407        PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \
408      else \
409        PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)
410    
411  #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \  #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
412    if (use_pcre16) \    if (use_pcre16) \
# Line 470  version is called. ----- */ Line 494  version is called. ----- */
494    else \    else \
495      PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)      PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)
496    
497  #define PCRE_JIT_STACK_ALLOC pcre_jit_stack_alloc  #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
498  #define PCRE_JIT_STACK_FREE pcre_jit_stack_free    (use_pcre16 ? \
499         PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
500        :PCRE_JIT_STACK_ALLOC8(startsize, maxsize))
501    
502    #define PCRE_JIT_STACK_FREE(stack) \
503      if (use_pcre16) \
504        PCRE_JIT_STACK_FREE16(stack); \
505      else \
506        PCRE_JIT_STACK_FREE8(stack)
507    
508  #define PCRE_MAKETABLES \  #define PCRE_MAKETABLES \
509    (use_pcre16? pcre16_maketables() : pcre_maketables())    (use_pcre16? pcre16_maketables() : pcre_maketables())
# Line 503  version is called. ----- */ Line 535  version is called. ----- */
535  #define READ_CAPTURE_NAME         READ_CAPTURE_NAME8  #define READ_CAPTURE_NAME         READ_CAPTURE_NAME8
536  #define SET_PCRE_CALLOUT          SET_PCRE_CALLOUT8  #define SET_PCRE_CALLOUT          SET_PCRE_CALLOUT8
537  #define STRLEN                    STRLEN8  #define STRLEN                    STRLEN8
538  #define PCRE_ASSIGN_JIT_STACK     pcre_assign_jit_stack  #define PCRE_ASSIGN_JIT_STACK     PCRE_ASSIGN_JIT_STACK8
539  #define PCRE_COMPILE              PCRE_COMPILE8  #define PCRE_COMPILE              PCRE_COMPILE8
540  #define PCRE_CONFIG               pcre_config  #define PCRE_CONFIG               pcre_config
541  #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING8  #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING8
# Line 517  version is called. ----- */ Line 549  version is called. ----- */
549  #define PCRE_GET_STRINGNUMBER     PCRE_GET_STRINGNUMBER8  #define PCRE_GET_STRINGNUMBER     PCRE_GET_STRINGNUMBER8
550  #define PCRE_GET_SUBSTRING        PCRE_GET_SUBSTRING8  #define PCRE_GET_SUBSTRING        PCRE_GET_SUBSTRING8
551  #define PCRE_GET_SUBSTRING_LIST   PCRE_GET_SUBSTRING_LIST8  #define PCRE_GET_SUBSTRING_LIST   PCRE_GET_SUBSTRING_LIST8
552  #define PCRE_JIT_STACK_ALLOC      pcre_jit_stack_alloc  #define PCRE_JIT_STACK_ALLOC      PCRE_JIT_STACK_ALLOC8
553  #define PCRE_JIT_STACK_FREE       pcre_jit_stack_free  #define PCRE_JIT_STACK_FREE       PCRE_JIT_STACK_FREE8
554  #define PCRE_MAKETABLES           pcre_maketables()  #define PCRE_MAKETABLES           pcre_maketables()
555  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER8  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER8
556  #define PCRE_PRINTINT             PCRE_PRINTINT8  #define PCRE_PRINTINT             PCRE_PRINTINT8
# Line 533  version is called. ----- */ Line 565  version is called. ----- */
565  #define READ_CAPTURE_NAME         READ_CAPTURE_NAME16  #define READ_CAPTURE_NAME         READ_CAPTURE_NAME16
566  #define SET_PCRE_CALLOUT          SET_PCRE_CALLOUT16  #define SET_PCRE_CALLOUT          SET_PCRE_CALLOUT16
567  #define STRLEN                    STRLEN16  #define STRLEN                    STRLEN16
568  #define PCRE_ASSIGN_JIT_STACK     pcre16_assign_jit_stack  #define PCRE_ASSIGN_JIT_STACK     PCRE_ASSIGN_JIT_STACK16
569  #define PCRE_COMPILE              PCRE_COMPILE16  #define PCRE_COMPILE              PCRE_COMPILE16
570  #define PCRE_CONFIG               pcre16_config  #define PCRE_CONFIG               pcre16_config
571  #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING16  #define PCRE_COPY_NAMED_SUBSTRING PCRE_COPY_NAMED_SUBSTRING16
# Line 547  version is called. ----- */ Line 579  version is called. ----- */
579  #define PCRE_GET_STRINGNUMBER     PCRE_GET_STRINGNUMBER16  #define PCRE_GET_STRINGNUMBER     PCRE_GET_STRINGNUMBER16
580  #define PCRE_GET_SUBSTRING        PCRE_GET_SUBSTRING16  #define PCRE_GET_SUBSTRING        PCRE_GET_SUBSTRING16
581  #define PCRE_GET_SUBSTRING_LIST   PCRE_GET_SUBSTRING_LIST16  #define PCRE_GET_SUBSTRING_LIST   PCRE_GET_SUBSTRING_LIST16
582  #define PCRE_JIT_STACK_ALLOC      pcre16_jit_stack_alloc  #define PCRE_JIT_STACK_ALLOC      PCRE_JIT_STACK_ALLOC16
583  #define PCRE_JIT_STACK_FREE       pcre16_jit_stack_free  #define PCRE_JIT_STACK_FREE       PCRE_JIT_STACK_FREE16
584  #define PCRE_MAKETABLES           pcre16_maketables()  #define PCRE_MAKETABLES           pcre16_maketables()
585  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16  #define PCRE_PATTERN_TO_HOST_BYTE_ORDER PCRE_PATTERN_TO_HOST_BYTE_ORDER16
586  #define PCRE_PRINTINT             PCRE_PRINTINT16  #define PCRE_PRINTINT             PCRE_PRINTINT16
# Line 1126  for (j = i; j > 0; j--) Line 1158  for (j = i; j > 0; j--)
1158  *utf8bytes = utf8_table2[i] | cvalue;  *utf8bytes = utf8_table2[i] | cvalue;
1159  return i + 1;  return i + 1;
1160  }  }
1161  #endif /* NOUTF || SUPPORT_PCRE16 */  #endif
   
1162    
1163    
1164  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
# Line 1145  Note that this function does not object Line 1176  Note that this function does not object
1176  deliberate; it makes it possible to construct UTF-16 strings that are invalid,  deliberate; it makes it possible to construct UTF-16 strings that are invalid,
1177  for the purpose of testing that they are correctly faulted.  for the purpose of testing that they are correctly faulted.
1178    
1179  Patterns to be converted are either plain ASCII or UTF-8; data lines are always  Patterns to be converted are either plain ASCII or UTF-8; data lines are always
1180  in UTF-8 so that values greater than 255 can be handled.  in UTF-8 so that values greater than 255 can be handled.
1181    
1182  Arguments:  Arguments:
# Line 1157  Arguments: Line 1188  Arguments:
1188  Returns:     number of 16-bit data items used (excluding trailing zero)  Returns:     number of 16-bit data items used (excluding trailing zero)
1189               OR -1 if a UTF-8 string is malformed               OR -1 if a UTF-8 string is malformed
1190               OR -2 if a value > 0x10ffff is encountered               OR -2 if a value > 0x10ffff is encountered
1191               OR -3 if a value > 0xffff is encountered when not in UTF mode               OR -3 if a value > 0xffff is encountered when not in UTF mode
1192  */  */
1193    
1194  static int  static int
# Line 1514  pcre_uint16 *npp = *pp; Line 1545  pcre_uint16 *npp = *pp;
1545  while (isalnum(*p)) *npp++ = *p++;  while (isalnum(*p)) *npp++ = *p++;
1546  *npp++ = 0;  *npp++ = 0;
1547  *npp = 0;  *npp = 0;
1548  if (pcre16_get_stringnumber(re, (PCRE_SPTR16)(*pp)) < 0)  if (pcre16_get_stringnumber((pcre16 *)re, (PCRE_SPTR16)(*pp)) < 0)
1549    {    {
1550    fprintf(outfile, "no parentheses with name \"");    fprintf(outfile, "no parentheses with name \"");
1551    PCHARSV(*pp, 0, -1, outfile);    PCHARSV(*pp, 0, -1, outfile);
# Line 1703  int rc; Line 1734  int rc;
1734    
1735  if (use_pcre16)  if (use_pcre16)
1736  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
1737    rc = pcre16_fullinfo(re, study, option, ptr);    rc = pcre16_fullinfo((pcre16 *)re, (pcre16_extra *)study, option, ptr);
1738  #else  #else
1739    rc = PCRE_ERROR_BADMODE;    rc = PCRE_ERROR_BADMODE;
1740  #endif  #endif
# Line 1772  architecture. */ Line 1803  architecture. */
1803  static void  static void
1804  regexflip(pcre *ere, pcre_extra *extra)  regexflip(pcre *ere, pcre_extra *extra)
1805  {  {
1806  real_pcre *re = (real_pcre *)ere;  REAL_PCRE *re = (REAL_PCRE *)ere;
1807  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
1808  int op;  int op;
1809  pcre_uint16 *ptr = (pcre_uint16 *)re + re->name_table_offset;  pcre_uint16 *ptr = (pcre_uint16 *)re + re->name_table_offset;
# Line 2073  printf("This version of pcretest is not Line 2104  printf("This version of pcretest is not
2104  #endif  #endif
2105  printf("\nOptions:\n");  printf("\nOptions:\n");
2106  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
2107  printf("  -16      use 16-bit interface\n");  printf("  -16      use the 16-bit library\n");
2108  #endif  #endif
2109  printf("  -b       show compiled code (bytecode)\n");  printf("  -b       show compiled code\n");
2110  printf("  -C       show PCRE compile-time options and exit\n");  printf("  -C       show PCRE compile-time options and exit\n");
2111  printf("  -C arg   show a specific compile-time option\n");  printf("  -C arg   show a specific compile-time option\n");
2112  printf("           and exit with its value. The arg can be:\n");  printf("           and exit with its value. The arg can be:\n");
# Line 2151  pcre_jit_stack *jit_stack = NULL; Line 2182  pcre_jit_stack *jit_stack = NULL;
2182  substring names, each list itself being terminated by an empty name. Assume  substring names, each list itself being terminated by an empty name. Assume
2183  that 1024 is plenty long enough for the few names we'll be testing. It is  that 1024 is plenty long enough for the few names we'll be testing. It is
2184  easiest to keep separate 8-bit and 16-bit versions, using the 16-bit version  easiest to keep separate 8-bit and 16-bit versions, using the 16-bit version
2185  for the actual memory, to ensure alignment. By defining these variables always  for the actual memory, to ensure alignment. */
 (whether or not 8-bit or 16-bit is supported), we avoid too much mess with  
 #ifdefs in the code. */  
2186    
2187  pcre_uint16 copynames[1024];  pcre_uint16 copynames[1024];
2188  pcre_uint16 getnames[1024];  pcre_uint16 getnames[1024];
2189    
2190    #ifdef SUPPORT_PCRE16
2191  pcre_uint16 *cn16ptr;  pcre_uint16 *cn16ptr;
2192  pcre_uint16 *gn16ptr;  pcre_uint16 *gn16ptr;
2193    #endif
2194    
2195    #ifdef SUPPORT_PCRE8
2196  pcre_uint8 *copynames8 = (pcre_uint8 *)copynames;  pcre_uint8 *copynames8 = (pcre_uint8 *)copynames;
2197  pcre_uint8 *getnames8 = (pcre_uint8 *)getnames;  pcre_uint8 *getnames8 = (pcre_uint8 *)getnames;
2198  pcre_uint8 *cn8ptr;  pcre_uint8 *cn8ptr;
2199  pcre_uint8 *gn8ptr;  pcre_uint8 *gn8ptr;
2200    #endif
2201    
2202  /* Get buffers from malloc() so that valgrind will check their misuse when  /* Get buffers from malloc() so that valgrind will check their misuse when
2203  debugging. They grow automatically when very long lines are read. The 16-bit  debugging. They grow automatically when very long lines are read. The 16-bit
# Line 2336  while (argc > 1 && argv[op][0] == '-') Line 2369  while (argc > 1 && argv[op][0] == '-')
2369          goto EXIT;          goto EXIT;
2370          }          }
2371        if (strcmp(argv[op + 1], "newline") == 0)        if (strcmp(argv[op + 1], "newline") == 0)
2372          {          {
2373          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
2374          /* Note that these values are always the ASCII values, even          /* Note that these values are always the ASCII values, even
2375          in EBCDIC environments. CR is 13 and NL is 10. */          in EBCDIC environments. CR is 13 and NL is 10. */
# Line 2345  while (argc > 1 && argv[op][0] == '-') Line 2378  while (argc > 1 && argv[op][0] == '-')
2378            (rc == -2)? "ANYCRLF" :            (rc == -2)? "ANYCRLF" :
2379            (rc == -1)? "ANY" : "???");            (rc == -1)? "ANY" : "???");
2380          goto EXIT;          goto EXIT;
2381          }          }
2382        printf("Unknown -C option: %s\n", argv[op + 1]);        printf("Unknown -C option: %s\n", argv[op + 1]);
2383        goto EXIT;        goto EXIT;
2384        }        }
# Line 2377  are set, either both UTFs are supported Line 2410  are set, either both UTFs are supported
2410      printf("  %sUnicode properties support\n", rc? "" : "No ");      printf("  %sUnicode properties support\n", rc? "" : "No ");
2411      (void)PCRE_CONFIG(PCRE_CONFIG_JIT, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_JIT, &rc);
2412      if (rc)      if (rc)
2413        printf("  Just-in-time compiler support\n");        {
2414          const char *arch;
2415          (void)PCRE_CONFIG(PCRE_CONFIG_JITTARGET, &arch);
2416          printf("  Just-in-time compiler support: %s\n", arch);
2417          }
2418      else      else
2419        printf("  No just-in-time compiler support\n");        printf("  No just-in-time compiler support\n");
2420      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
# Line 2399  are set, either both UTFs are supported Line 2436  are set, either both UTFs are supported
2436      (void)PCRE_CONFIG(PCRE_CONFIG_MATCH_LIMIT_RECURSION, &lrc);      (void)PCRE_CONFIG(PCRE_CONFIG_MATCH_LIMIT_RECURSION, &lrc);
2437      printf("  Default recursion depth limit = %ld\n", lrc);      printf("  Default recursion depth limit = %ld\n", lrc);
2438      (void)PCRE_CONFIG(PCRE_CONFIG_STACKRECURSE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_STACKRECURSE, &rc);
2439      printf("  Match recursion uses %s\n", rc? "stack" : "heap");      printf("  Match recursion uses %s", rc? "stack" : "heap");
2440        if (showstore)
2441          {
2442          PCRE_EXEC(stack_size, NULL, NULL, NULL, -999, -999, 0, NULL, 0);
2443          printf(": %sframe size = %d bytes", rc? "approximate " : "", -stack_size);
2444          }
2445        printf("\n");
2446      goto EXIT;      goto EXIT;
2447      }      }
2448    else if (strcmp(argv[op], "-help") == 0 ||    else if (strcmp(argv[op], "-help") == 0 ||
# Line 2492  while (!done) Line 2535  while (!done)
2535    pcre_uint8 *p, *pp, *ppp;    pcre_uint8 *p, *pp, *ppp;
2536    pcre_uint8 *to_file = NULL;    pcre_uint8 *to_file = NULL;
2537    const pcre_uint8 *tables = NULL;    const pcre_uint8 *tables = NULL;
2538    pcre_uint32 get_options;    unsigned long int get_options;
2539    unsigned long int true_size, true_study_size = 0;    unsigned long int true_size, true_study_size = 0;
2540    size_t size, regex_gotten_store;    size_t size, regex_gotten_store;
2541    int do_allcaps = 0;    int do_allcaps = 0;
# Line 2554  while (!done) Line 2597  while (!done)
2597      true_study_size =      true_study_size =
2598        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
2599    
2600      re = (real_pcre *)new_malloc(true_size);      re = (pcre *)new_malloc(true_size);
2601      regex_gotten_store = first_gotten_store;      regex_gotten_store = first_gotten_store;
2602    
2603      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
2604    
2605      magic = ((real_pcre *)re)->magic_number;      magic = ((REAL_PCRE *)re)->magic_number;
2606      if (magic != MAGIC_NUMBER)      if (magic != MAGIC_NUMBER)
2607        {        {
2608        if (swap_uint32(magic) == MAGIC_NUMBER)        if (swap_uint32(magic) == MAGIC_NUMBER)
# Line 2869  while (!done) Line 2912  while (!done)
2912          fprintf(outfile, "**Failed: character value greater than 0x10ffff "          fprintf(outfile, "**Failed: character value greater than 0x10ffff "
2913            "cannot be converted to UTF-16\n");            "cannot be converted to UTF-16\n");
2914          goto SKIP_DATA;          goto SKIP_DATA;
2915    
2916          case -3: /* "Impossible error" when to16 is called arg1 FALSE */          case -3: /* "Impossible error" when to16 is called arg1 FALSE */
2917          fprintf(outfile, "**Failed: character value greater than 0xffff "          fprintf(outfile, "**Failed: character value greater than 0xffff "
2918            "cannot be converted to 16-bit in non-UTF mode\n");            "cannot be converted to 16-bit in non-UTF mode\n");
2919          goto SKIP_DATA;          goto SKIP_DATA;
2920    
2921          default:          default:
2922          break;          break;
# Line 2939  while (!done) Line 2982  while (!done)
2982      /* Extract the size for possible writing before possibly flipping it,      /* Extract the size for possible writing before possibly flipping it,
2983      and remember the store that was got. */      and remember the store that was got. */
2984    
2985      true_size = ((real_pcre *)re)->size;      true_size = ((REAL_PCRE *)re)->size;
2986      regex_gotten_store = first_gotten_store;      regex_gotten_store = first_gotten_store;
2987    
2988      /* Output code size information if requested */      /* Output code size information if requested */
# Line 2947  while (!done) Line 2990  while (!done)
2990      if (log_store)      if (log_store)
2991        fprintf(outfile, "Memory allocation (code space): %d\n",        fprintf(outfile, "Memory allocation (code space): %d\n",
2992          (int)(first_gotten_store -          (int)(first_gotten_store -
2993                sizeof(real_pcre) -                sizeof(REAL_PCRE) -
2994                ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));                ((REAL_PCRE *)re)->name_count * ((REAL_PCRE *)re)->name_entry_size));
2995    
2996      /* If -s or /S was present, study the regex to generate additional info to      /* If -s or /S was present, study the regex to generate additional info to
2997      help with the matching, unless the pattern has the SS option, which      help with the matching, unless the pattern has the SS option, which
# Line 3079  while (!done) Line 3122  while (!done)
3122        if (!okpartial) fprintf(outfile, "Partial matching not supported\n");        if (!okpartial) fprintf(outfile, "Partial matching not supported\n");
3123        if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");        if (hascrorlf) fprintf(outfile, "Contains explicit CR or LF match\n");
3124    
3125        all_options = ((real_pcre *)re)->options;        all_options = ((REAL_PCRE *)re)->options;
3126        if (do_flip) all_options = swap_uint32(all_options);        if (do_flip) all_options = swap_uint32(all_options);
3127    
3128        if (get_options == 0) fprintf(outfile, "No options\n");        if (get_options == 0) fprintf(outfile, "No options\n");
# Line 3141  while (!done) Line 3184  while (!done)
3184        else        else
3185          {          {
3186          const char *caseless =          const char *caseless =
3187            ((((real_pcre *)re)->flags & PCRE_FCH_CASELESS) == 0)?            ((((REAL_PCRE *)re)->flags & PCRE_FCH_CASELESS) == 0)?
3188            "" : " (caseless)";            "" : " (caseless)";
3189    
3190          if (PRINTOK(first_char))          if (PRINTOK(first_char))
# Line 3161  while (!done) Line 3204  while (!done)
3204        else        else
3205          {          {
3206          const char *caseless =          const char *caseless =
3207            ((((real_pcre *)re)->flags & PCRE_RCH_CASELESS) == 0)?            ((((REAL_PCRE *)re)->flags & PCRE_RCH_CASELESS) == 0)?
3208            "" : " (caseless)";            "" : " (caseless)";
3209    
3210          if (PRINTOK(need_char))          if (PRINTOK(need_char))
# Line 3338  while (!done) Line 3381  while (!done)
3381      *copynames = 0;      *copynames = 0;
3382      *getnames = 0;      *getnames = 0;
3383    
3384    #ifdef SUPPORT_PCRE16
3385      cn16ptr = copynames;      cn16ptr = copynames;
3386      gn16ptr = getnames;      gn16ptr = getnames;
3387    #endif
3388    #ifdef SUPPORT_PCRE8
3389      cn8ptr = copynames8;      cn8ptr = copynames8;
3390      gn8ptr = getnames8;      gn8ptr = getnames8;
3391    #endif
3392    
3393      SET_PCRE_CALLOUT(callout);      SET_PCRE_CALLOUT(callout);
3394      first_callout = 1;      first_callout = 1;
# Line 3386  while (!done) Line 3433  while (!done)
3433        {        {
3434        int i = 0;        int i = 0;
3435        int n = 0;        int n = 0;
3436    
3437        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.
3438        In non-UTF mode, allow the value of the byte to fall through to later,        In non-UTF mode, allow the value of the byte to fall through to later,
3439        where values greater than 127 are turned into UTF-8 when running in        where values greater than 127 are turned into UTF-8 when running in
3440        16-bit mode. */        16-bit mode. */
3441    
3442        if (c != '\\')        if (c != '\\')
3443          {          {
3444          if (use_utf)          if (use_utf)
3445            {            {
3446            *q++ = c;            *q++ = c;
3447            continue;            continue;
3448            }            }
3449          }          }
3450    
3451        /* Handle backslash escapes */        /* Handle backslash escapes */
3452    
3453        else switch ((c = *p++))        else switch ((c = *p++))
3454          {          {
3455          case 'a': c =    7; break;          case 'a': c =    7; break;
# Line 3433  while (!done) Line 3480  while (!done)
3480            least one MacOS environment. */            least one MacOS environment. */
3481    
3482            for (pt++; isxdigit(*pt); pt++)            for (pt++; isxdigit(*pt); pt++)
3483              c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'a' - 10);              {
3484                if (++i == 9)
3485                  fprintf(outfile, "** Too many hex digits in \\x{...} item; "
3486                                   "using only the first eight.\n");
3487                else c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'a' - 10);
3488                }
3489            if (*pt == '}')            if (*pt == '}')
3490              {              {
3491              p = pt + 1;              p = pt + 1;
# Line 3442  while (!done) Line 3494  while (!done)
3494            /* Not correct form for \x{...}; fall through */            /* Not correct form for \x{...}; fall through */
3495            }            }
3496    
3497          /* \x without {} always defines just one byte in 8-bit mode. This          /* \x without {} always defines just one byte in 8-bit mode. This
3498          allows UTF-8 characters to be constructed byte by byte, and also allows          allows UTF-8 characters to be constructed byte by byte, and also allows
3499          invalid UTF-8 sequences to be made. Just copy the byte in UTF mode.          invalid UTF-8 sequences to be made. Just copy the byte in UTF mode.
3500          Otherwise, pass it down to later code so that it can be turned into          Otherwise, pass it down to later code so that it can be turned into
3501          UTF-8 when running in 16-bit mode. */          UTF-8 when running in 16-bit mode. */
3502    
3503          c = 0;          c = 0;
# Line 3455  while (!done) Line 3507  while (!done)
3507            p++;            p++;
3508            }            }
3509          if (use_utf)          if (use_utf)
3510            {            {
3511            *q++ = c;            *q++ = c;
3512            continue;            continue;
3513            }            }
3514          break;          break;
3515    
3516          case 0:   /* \ followed by EOF allows for an empty line */          case 0:   /* \ followed by EOF allows for an empty line */
# Line 3564  while (!done) Line 3616  while (!done)
3616              && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0              && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0
3617              && extra->executable_jit != NULL)              && extra->executable_jit != NULL)
3618            {            {
3619            if (jit_stack != NULL) PCRE_JIT_STACK_FREE(jit_stack);            if (jit_stack != NULL) { PCRE_JIT_STACK_FREE(jit_stack); }
3620            jit_stack = PCRE_JIT_STACK_ALLOC(1, n * 1024);            jit_stack = PCRE_JIT_STACK_ALLOC(1, n * 1024);
3621            PCRE_ASSIGN_JIT_STACK(extra, jit_callback, jit_stack);            PCRE_ASSIGN_JIT_STACK(extra, jit_callback, jit_stack);
3622            }            }
# Line 3663  while (!done) Line 3715  while (!done)
3715          continue;          continue;
3716          }          }
3717    
3718        /* We now have a character value in c that may be greater than 255. In        /* We now have a character value in c that may be greater than 255. In
3719        16-bit mode, we always convert characters to UTF-8 so that values greater        16-bit mode, we always convert characters to UTF-8 so that values greater
3720        than 255 can be passed to non-UTF 16-bit strings. In 8-bit mode we        than 255 can be passed to non-UTF 16-bit strings. In 8-bit mode we
3721        convert to UTF-8 if we are in UTF mode. Values greater than 127 in UTF        convert to UTF-8 if we are in UTF mode. Values greater than 127 in UTF
3722        mode must have come from \x{...} or octal constructs because values from        mode must have come from \x{...} or octal constructs because values from
3723        \x.. get this far only in non-UTF mode. */        \x.. get this far only in non-UTF mode. */
3724    
3725    #if !defined NOUTF || defined SUPPORT_PCRE16
3726        if (use_pcre16 || use_utf)        if (use_pcre16 || use_utf)
3727          {          {
3728          pcre_uint8 buff8[8];          pcre_uint8 buff8[8];
# Line 3678  while (!done) Line 3731  while (!done)
3731          for (ii = 0; ii < utn; ii++) *q++ = buff8[ii];          for (ii = 0; ii < utn; ii++) *q++ = buff8[ii];
3732          }          }
3733        else        else
3734    #endif
3735          {          {
3736          if (c > 255)          if (c > 255)
3737            {            {
# Line 3689  while (!done) Line 3743  while (!done)
3743          *q++ = c;          *q++ = c;
3744          }          }
3745        }        }
3746    
3747      /* Reached end of subject string */      /* Reached end of subject string */
3748    
3749      *q = 0;      *q = 0;
3750      len = (int)(q - dbuffer);      len = (int)(q - dbuffer);
3751    
# Line 3777  while (!done) Line 3831  while (!done)
3831  #ifdef SUPPORT_PCRE16  #ifdef SUPPORT_PCRE16
3832      if (use_pcre16)      if (use_pcre16)
3833        {        {
3834        len = to16(TRUE, bptr, (((real_pcre *)re)->options) & PCRE_UTF8, len);        len = to16(TRUE, bptr, (((REAL_PCRE *)re)->options) & PCRE_UTF8, len);
3835        switch(len)        switch(len)
3836          {          {
3837          case -1:          case -1:
# Line 3793  while (!done) Line 3847  while (!done)
3847          case -3:          case -3:
3848          fprintf(outfile, "**Failed: character value greater than 0xffff "          fprintf(outfile, "**Failed: character value greater than 0xffff "
3849            "cannot be converted to 16-bit in non-UTF mode\n");            "cannot be converted to 16-bit in non-UTF mode\n");
3850          goto NEXT_DATA;          goto NEXT_DATA;
3851    
3852          default:          default:
3853          break;          break;
# Line 4157  while (!done) Line 4211  while (!done)
4211          if (g_notempty != 0)          if (g_notempty != 0)
4212            {            {
4213            int onechar = 1;            int onechar = 1;
4214            unsigned int obits = ((real_pcre *)re)->options;            unsigned int obits = ((REAL_PCRE *)re)->options;
4215            use_offsets[0] = start_offset;            use_offsets[0] = start_offset;
4216            if ((obits & PCRE_NEWLINE_BITS) == 0)            if ((obits & PCRE_NEWLINE_BITS) == 0)
4217              {              {

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12