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

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

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

revision 800 by zherczeg, Thu Dec 1 06:08:45 2011 UTC revision 801 by ph10, Mon Dec 12 16:23:37 2011 UTC
# Line 190  static int locale_set = 0; Line 190  static int locale_set = 0;
190  static int show_malloc;  static int show_malloc;
191  static int use_utf8;  static int use_utf8;
192  static size_t gotten_store;  static size_t gotten_store;
193    static size_t first_gotten_store = 0;
194  static const unsigned char *last_callout_mark = NULL;  static const unsigned char *last_callout_mark = NULL;
195    
196  /* The buffers grow automatically if very long input lines are encountered. */  /* The buffers grow automatically if very long input lines are encountered. */
# Line 998  return (cb->callout_number != callout_fa Line 999  return (cb->callout_number != callout_fa
999  *************************************************/  *************************************************/
1000    
1001  /* Alternative malloc function, to test functionality and save the size of a  /* Alternative malloc function, to test functionality and save the size of a
1002  compiled re. The show_malloc variable is set only during matching. */  compiled re, which is the first store request that pcre_compile() makes. The
1003    show_malloc variable is set only during matching. */
1004    
1005  static void *new_malloc(size_t size)  static void *new_malloc(size_t size)
1006  {  {
1007  void *block = malloc(size);  void *block = malloc(size);
1008  gotten_store = size;  gotten_store = size;
1009    if (first_gotten_store == 0) first_gotten_store = size;
1010  if (show_malloc)  if (show_malloc)
1011    fprintf(outfile, "malloc       %3d %p\n", (int)size, block);    fprintf(outfile, "malloc       %3d %p\n", (int)size, block);
1012  return block;  return block;
# Line 1519  while (!done) Line 1522  while (!done)
1522        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];        (sbuf[4] << 24) | (sbuf[5] << 16) | (sbuf[6] << 8) | sbuf[7];
1523    
1524      re = (real_pcre *)new_malloc(true_size);      re = (real_pcre *)new_malloc(true_size);
1525      regex_gotten_store = gotten_store;      regex_gotten_store = first_gotten_store;
1526    
1527      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;      if (fread(re, 1, true_size, f) != true_size) goto FAIL_READ;
1528    
# Line 1628  while (!done) Line 1631  while (!done)
1631    /* Look for options after final delimiter */    /* Look for options after final delimiter */
1632    
1633    options = 0;    options = 0;
1634      study_options = 0;
1635    log_store = showstore;  /* default from command line */    log_store = showstore;  /* default from command line */
1636    
1637    while (*pp != 0)    while (*pp != 0)
# Line 1776  while (!done) Line 1780  while (!done)
1780      if ((options & PCRE_UCP) != 0) cflags |= REG_UCP;      if ((options & PCRE_UCP) != 0) cflags |= REG_UCP;
1781      if ((options & PCRE_UNGREEDY) != 0) cflags |= REG_UNGREEDY;      if ((options & PCRE_UNGREEDY) != 0) cflags |= REG_UNGREEDY;
1782    
1783        first_gotten_store = 0;
1784      rc = regcomp(&preg, (char *)p, cflags);      rc = regcomp(&preg, (char *)p, cflags);
1785    
1786      /* Compilation failed; go back for another re, skipping to blank line      /* Compilation failed; go back for another re, skipping to blank line
# Line 1813  while (!done) Line 1818  while (!done)
1818            (double)CLOCKS_PER_SEC);            (double)CLOCKS_PER_SEC);
1819        }        }
1820    
1821        first_gotten_store = 0;
1822      re = pcre_compile((char *)p, options, &error, &erroroffset, tables);      re = pcre_compile((char *)p, options, &error, &erroroffset, tables);
1823    
1824      /* Compilation failed; go back for another re, skipping to blank line      /* Compilation failed; go back for another re, skipping to blank line
# Line 1847  while (!done) Line 1853  while (!done)
1853      new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);      new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options);
1854      if ((get_options & PCRE_UTF8) != 0) use_utf8 = 1;      if ((get_options & PCRE_UTF8) != 0) use_utf8 = 1;
1855    
1856      /* Print information if required. There are now two info-returning      /* Extract the size for possible writing before possibly flipping it,
1857      functions. The old one has a limited interface and returns only limited      and remember the store that was got. */
1858      data. Check that it agrees with the newer one. */  
1859        true_size = ((real_pcre *)re)->size;
1860        regex_gotten_store = first_gotten_store;
1861    
1862        /* Output code size information if requested */
1863    
1864      if (log_store)      if (log_store)
1865        fprintf(outfile, "Memory allocation (code space): %d\n",        fprintf(outfile, "Memory allocation (code space): %d\n",
1866          (int)(gotten_store -          (int)(first_gotten_store -
1867                sizeof(real_pcre) -                sizeof(real_pcre) -
1868                ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));                ((real_pcre *)re)->name_count * ((real_pcre *)re)->name_entry_size));
1869    
     /* Extract the size for possible writing before possibly flipping it,  
     and remember the store that was got. */  
   
     true_size = ((real_pcre *)re)->size;  
     regex_gotten_store = gotten_store;  
   
1870      /* 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
1871      help with the matching, unless the pattern has the SS option, which      help with the matching, unless the pattern has the SS option, which
1872      suppresses the effect of /S (used for a few test patterns where studying is      suppresses the effect of /S (used for a few test patterns where studying is
# Line 1887  while (!done) Line 1891  while (!done)
1891        if (error != NULL)        if (error != NULL)
1892          fprintf(outfile, "Failed to study: %s\n", error);          fprintf(outfile, "Failed to study: %s\n", error);
1893        else if (extra != NULL)        else if (extra != NULL)
1894            {
1895          true_study_size = ((pcre_study_data *)(extra->study_data))->size;          true_study_size = ((pcre_study_data *)(extra->study_data))->size;
1896            if (log_store)
1897              {
1898              size_t jitsize;
1899              new_info(re, extra, PCRE_INFO_JITSIZE, &jitsize);
1900              if (jitsize != 0)
1901                fprintf(outfile, "Memory allocation (JIT code): %d\n", jitsize);
1902              }
1903            }
1904        }        }
1905    
1906      /* If /K was present, we set up for handling MARK data. */      /* If /K was present, we set up for handling MARK data. */
# Line 1940  while (!done) Line 1953  while (!done)
1953          }          }
1954        }        }
1955    
1956      /* Extract information from the compiled data if required */      /* Extract information from the compiled data if required. There are now
1957        two info-returning functions. The old one has a limited interface and
1958        returns only limited data. Check that it agrees with the newer one. */
1959    
1960      SHOW_INFO:      SHOW_INFO:
1961    

Legend:
Removed from v.800  
changed lines
  Added in v.801

  ViewVC Help
Powered by ViewVC 1.1.5