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

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

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

revision 766 by zherczeg, Wed Nov 23 17:23:20 2011 UTC revision 767 by zherczeg, Sat Nov 26 12:48:56 2011 UTC
# Line 3419  for (;; ptr++) Line 3419  for (;; ptr++)
3419        {        {
3420        if (previous > orig_code)        if (previous > orig_code)
3421          {          {
3422          memmove(orig_code, previous, code - previous);          memmove(orig_code, previous, IN_UCHARS(code - previous));
3423          code -= previous - orig_code;          code -= previous - orig_code;
3424          previous = orig_code;          previous = orig_code;
3425          }          }
# Line 4484  for (;; ptr++) Line 4484  for (;; ptr++)
4484    
4485      if (*previous == OP_RECURSE)      if (*previous == OP_RECURSE)
4486        {        {
4487        memmove(previous + 1 + LINK_SIZE, previous, 1 + LINK_SIZE);        memmove(previous + 1 + LINK_SIZE, previous, IN_UCHARS(1 + LINK_SIZE));
4488        *previous = OP_ONCE;        *previous = OP_ONCE;
4489        PUT(previous, 1, 2 + 2*LINK_SIZE);        PUT(previous, 1, 2 + 2*LINK_SIZE);
4490        previous[2 + 2*LINK_SIZE] = OP_KET;        previous[2 + 2*LINK_SIZE] = OP_KET;
# Line 4862  for (;; ptr++) Line 4862  for (;; ptr++)
4862            {            {
4863            *code = OP_END;            *code = OP_END;
4864            adjust_recurse(previous, 1, utf8, cd, save_hwm);            adjust_recurse(previous, 1, utf8, cd, save_hwm);
4865            memmove(previous+1, previous, len);            memmove(previous + 1, previous, IN_UCHARS(len));
4866            code++;            code++;
4867            if (repeat_max == 0)            if (repeat_max == 0)
4868              {              {
# Line 4886  for (;; ptr++) Line 4886  for (;; ptr++)
4886            int offset;            int offset;
4887            *code = OP_END;            *code = OP_END;
4888            adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd, save_hwm);            adjust_recurse(previous, 2 + LINK_SIZE, utf8, cd, save_hwm);
4889            memmove(previous + 2 + LINK_SIZE, previous, len);            memmove(previous + 2 + LINK_SIZE, previous, IN_UCHARS(len));
4890            code += 2 + LINK_SIZE;            code += 2 + LINK_SIZE;
4891            *previous++ = OP_BRAZERO + repeat_type;            *previous++ = OP_BRAZERO + repeat_type;
4892            *previous++ = OP_BRA;            *previous++ = OP_BRA;
# Line 4941  for (;; ptr++) Line 4941  for (;; ptr++)
4941                {                {
4942                pcre_uchar *hc;                pcre_uchar *hc;
4943                pcre_uchar *this_hwm = cd->hwm;                pcre_uchar *this_hwm = cd->hwm;
4944                memcpy(code, previous, len);                memcpy(code, previous, IN_UCHARS(len));
4945                for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)                for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
4946                  {                  {
4947                  PUT(cd->hwm, 0, GET(hc, 0) + len);                  PUT(cd->hwm, 0, GET(hc, 0) + len);
# Line 5008  for (;; ptr++) Line 5008  for (;; ptr++)
5008              PUTINC(code, 0, offset);              PUTINC(code, 0, offset);
5009              }              }
5010    
5011            memcpy(code, previous, len);            memcpy(code, previous, IN_UCHARS(len));
5012            for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)            for (hc = save_hwm; hc < this_hwm; hc += LINK_SIZE)
5013              {              {
5014              PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));              PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));
# Line 5111  for (;; ptr++) Line 5111  for (;; ptr++)
5111                int nlen = (int)(code - bracode);                int nlen = (int)(code - bracode);
5112                *code = OP_END;                *code = OP_END;
5113                adjust_recurse(bracode, 1 + LINK_SIZE, utf8, cd, save_hwm);                adjust_recurse(bracode, 1 + LINK_SIZE, utf8, cd, save_hwm);
5114                memmove(bracode + 1+LINK_SIZE, bracode, nlen);                memmove(bracode + 1 + LINK_SIZE, bracode, IN_UCHARS(nlen));
5115                code += 1 + LINK_SIZE;                code += 1 + LINK_SIZE;
5116                nlen += 1 + LINK_SIZE;                nlen += 1 + LINK_SIZE;
5117                *bracode = OP_BRAPOS;                *bracode = OP_BRAPOS;
# Line 5226  for (;; ptr++) Line 5226  for (;; ptr++)
5226          default:          default:
5227          *code = OP_END;          *code = OP_END;
5228          adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);          adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);
5229          memmove(tempcode + 1+LINK_SIZE, tempcode, len);          memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
5230          code += 1 + LINK_SIZE;          code += 1 + LINK_SIZE;
5231          len += 1 + LINK_SIZE;          len += 1 + LINK_SIZE;
5232          tempcode[0] = OP_ONCE;          tempcode[0] = OP_ONCE;
# Line 5343  for (;; ptr++) Line 5343  for (;; ptr++)
5343              *code = verbs[i].op_arg;              *code = verbs[i].op_arg;
5344              if (*code++ == OP_THEN_ARG) cd->external_flags |= PCRE_HASTHEN;              if (*code++ == OP_THEN_ARG) cd->external_flags |= PCRE_HASTHEN;
5345              *code++ = arglen;              *code++ = arglen;
5346              memcpy(code, arg, arglen);              memcpy(code, arg, IN_UCHARS(arglen));
5347              code += arglen;              code += arglen;
5348              *code++ = 0;              *code++ = 0;
5349              }              }
# Line 5779  for (;; ptr++) Line 5779  for (;; ptr++)
5779                if (crc < 0)                if (crc < 0)
5780                  {                  {
5781                  memmove(slot + cd->name_entry_size, slot,                  memmove(slot + cd->name_entry_size, slot,
5782                    (cd->names_found - i) * cd->name_entry_size);                    IN_UCHARS((cd->names_found - i) * cd->name_entry_size));
5783                  break;                  break;
5784                  }                  }
5785    
# Line 5810  for (;; ptr++) Line 5810  for (;; ptr++)
5810                }                }
5811    
5812              PUT2(slot, 0, cd->bracount + 1);              PUT2(slot, 0, cd->bracount + 1);
5813              memcpy(slot + 2, name, namelen);              memcpy(slot + 2, name, IN_UCHARS(namelen));
5814              slot[2+namelen] = 0;              slot[2 + namelen] = 0;
5815              }              }
5816            }            }
5817    
# Line 6877  for (;;) Line 6877  for (;;)
6877        if (cd->open_caps->flag)        if (cd->open_caps->flag)
6878          {          {
6879          memmove(start_bracket + 1 + LINK_SIZE, start_bracket,          memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
6880            code - start_bracket);            IN_UCHARS(code - start_bracket));
6881          *start_bracket = OP_ONCE;          *start_bracket = OP_ONCE;
6882          code += 1 + LINK_SIZE;          code += 1 + LINK_SIZE;
6883          PUT(start_bracket, 1, (int)(code - start_bracket));          PUT(start_bracket, 1, (int)(code - start_bracket));
# Line 7247  Returns:        pointer to compiled data Line 7247  Returns:        pointer to compiled data
7247                  with errorptr and erroroffset set                  with errorptr and erroroffset set
7248  */  */
7249    
7250  #ifndef COMPILE_PCRE16  #ifdef COMPILE_PCRE8
7251  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7252  pcre_compile(const char *pattern, int options, const char **errorptr,  pcre_compile(const char *pattern, int options, const char **errorptr,
7253    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
# Line 7257  pcre16_compile(PCRE_SPTR16 pattern, int Line 7257  pcre16_compile(PCRE_SPTR16 pattern, int
7257    int *erroroffset, const unsigned char *tables)    int *erroroffset, const unsigned char *tables)
7258  #endif  #endif
7259  {  {
7260  #ifndef COMPILE_PCRE16  #ifdef COMPILE_PCRE8
7261  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
7262  #else  #else
7263  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);  return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
# Line 7265  return pcre16_compile2(pattern, options, Line 7265  return pcre16_compile2(pattern, options,
7265  }  }
7266    
7267    
7268  #ifndef COMPILE_PCRE16  #ifdef COMPILE_PCRE8
7269  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
7270  pcre_compile2(const char *pattern, int options, int *errorcodeptr,  pcre_compile2(const char *pattern, int options, int *errorcodeptr,
7271    const char **errorptr, int *erroroffset, const unsigned char *tables)    const char **errorptr, int *erroroffset, const unsigned char *tables)
# Line 7469  cd->backref_map = 0; Line 7469  cd->backref_map = 0;
7469  /* Reflect pattern for debugging output */  /* Reflect pattern for debugging output */
7470    
7471  DPRINTF(("------------------------------------------------------------------\n"));  DPRINTF(("------------------------------------------------------------------\n"));
7472  DPRINTF(("%s\n", pattern));  #ifdef PCRE_DEBUG
7473    print_puchar(stdout, (PCRE_PUCHAR)pattern);
7474    #endif
7475    DPRINTF(("\n"));
7476    
7477  /* Pretend to compile the pattern while actually just accumulating the length  /* Pretend to compile the pattern while actually just accumulating the length
7478  of memory required. This behaviour is triggered by passing a non-NULL final  of memory required. This behaviour is triggered by passing a non-NULL final
# Line 7486  cd->start_workspace = cworkspace; Line 7489  cd->start_workspace = cworkspace;
7489  cd->start_code = cworkspace;  cd->start_code = cworkspace;
7490  cd->hwm = cworkspace;  cd->hwm = cworkspace;
7491  cd->start_pattern = (const pcre_uchar *)pattern;  cd->start_pattern = (const pcre_uchar *)pattern;
7492  cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC(pattern));  cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC((const pcre_uchar *)pattern));
7493  cd->req_varyopt = 0;  cd->req_varyopt = 0;
7494  cd->external_options = options;  cd->external_options = options;
7495  cd->external_flags = 0;  cd->external_flags = 0;
# Line 7506  code = cworkspace; Line 7509  code = cworkspace;
7509  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;  if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
7510    
7511  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,  DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
7512    cd->hwm - cworkspace));    (int)(cd->hwm - cworkspace)));
7513    
7514  if (length > MAX_PATTERN_SIZE)  if (length > MAX_PATTERN_SIZE)
7515    {    {
# Line 7519  externally provided function. Integer ov Line 7522  externally provided function. Integer ov
7522  because nowadays we limit the maximum value of cd->names_found and  because nowadays we limit the maximum value of cd->names_found and
7523  cd->name_entry_size. */  cd->name_entry_size. */
7524    
7525  size = length + sizeof(real_pcre) + cd->names_found * (cd->name_entry_size + 3);  size = sizeof(real_pcre) + (length + cd->names_found * (cd->name_entry_size + 3)) * sizeof(pcre_uchar);
7526  re = (real_pcre *)(pcre_malloc)(size);  re = (real_pcre *)(pcre_malloc)(size);
7527    
7528  if (re == NULL)  if (re == NULL)
# Line 7541  re->flags = cd->external_flags; Line 7544  re->flags = cd->external_flags;
7544  re->dummy1 = 0;  re->dummy1 = 0;
7545  re->first_byte = 0;  re->first_byte = 0;
7546  re->req_byte = 0;  re->req_byte = 0;
7547  re->name_table_offset = sizeof(real_pcre);  re->name_table_offset = sizeof(real_pcre) / sizeof(pcre_uchar);
7548  re->name_entry_size = cd->name_entry_size;  re->name_entry_size = cd->name_entry_size;
7549  re->name_count = cd->names_found;  re->name_count = cd->names_found;
7550  re->ref_count = 0;  re->ref_count = 0;

Legend:
Removed from v.766  
changed lines
  Added in v.767

  ViewVC Help
Powered by ViewVC 1.1.5