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

Diff of /code/trunk/pcre_printint.c

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

revision 906 by zherczeg, Tue Jan 24 09:55:16 2012 UTC revision 1046 by ph10, Tue Sep 25 16:27:58 2012 UTC
# Line 120  int c = *ptr; Line 120  int c = *ptr;
120    
121  (void)utf;  /* Avoid compiler warning */  (void)utf;  /* Avoid compiler warning */
122  if (PRINTABLE(c)) fprintf(f, "%c", c);  if (PRINTABLE(c)) fprintf(f, "%c", c);
123  else if (c <= 0xff) fprintf(f, "\\x%02x", c);  else if (c <= 0x80) fprintf(f, "\\x%02x", c);
124  else fprintf(f, "\\x{%x}", c);  else fprintf(f, "\\x{%x}", c);
125  return 0;  return 0;
126    
# Line 130  return 0; Line 130  return 0;
130    
131  if (!utf || (c & 0xc0) != 0xc0)  if (!utf || (c & 0xc0) != 0xc0)
132    {    {
133    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);    if (PRINTABLE(c)) fprintf(f, "%c", c);
134      else if (c < 0x80) fprintf(f, "\\x%02x", c);
135      else fprintf(f, "\\x{%02x}", c);
136    return 0;    return 0;
137    }    }
138  else  else
# Line 167  else Line 169  else
169  if (!utf || (c & 0xfc00) != 0xd800)  if (!utf || (c & 0xfc00) != 0xd800)
170    {    {
171    if (PRINTABLE(c)) fprintf(f, "%c", c);    if (PRINTABLE(c)) fprintf(f, "%c", c);
172    else if (c <= 0xff) fprintf(f, "\\x%02x", c);    else if (c <= 0x80) fprintf(f, "\\x%02x", c);
173    else fprintf(f, "\\x{%x}", c);    else fprintf(f, "\\x{%02x}", c);
174    return 0;    return 0;
175    }    }
176  else  else
# Line 231  return (ptype == pvalue)? "??" : "??"; Line 233  return (ptype == pvalue)? "??" : "??";
233  }  }
234    
235    
236    /*************************************************
237    *       Print Unicode property value             *
238    *************************************************/
239    
240    /* "Normal" properties can be printed from tables. The PT_CLIST property is a
241    pseudo-property that contains a pointer to a list of case-equivalent
242    characters. This is used only when UCP support is available and UTF mode is
243    selected. It should never occur otherwise, but just in case it does, have
244    something ready to print. */
245    
246    static void
247    print_prop(FILE *f, pcre_uchar *code, const char *before, const char *after)
248    {
249    if (code[1] != PT_CLIST)
250      {
251      fprintf(f, "%s%s %s%s", before, priv_OP_names[*code], get_ucpname(code[1],
252        code[2]), after);
253      }
254    else
255      {
256      const char *not = (*code == OP_PROP)? "" : "not ";
257    #ifndef SUPPORT_UCP
258      fprintf(f, "%s%sclist %d%s", before, not, code[2], after);
259    #else
260      const pcre_uint32 *p = PRIV(ucd_caseless_sets) + code[2];
261      fprintf (f, "%s%sclist", before, not);
262      while (*p < NOTACHAR) fprintf(f, " %04x", *p++);
263      fprintf(f, "%s", after);
264    #endif
265      }
266    }
267    
268    
269    
270    
271  /*************************************************  /*************************************************
272  *         Print compiled regex                   *  *         Print compiled regex                   *
# Line 425  for(;;) Line 461  for(;;)
461      fprintf(f, " %s ", flag);      fprintf(f, " %s ", flag);
462      if (*code >= OP_TYPESTAR)      if (*code >= OP_TYPESTAR)
463        {        {
       fprintf(f, "%s", priv_OP_names[code[1]]);  
464        if (code[1] == OP_PROP || code[1] == OP_NOTPROP)        if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
465          {          {
466          fprintf(f, " %s ", get_ucpname(code[2], code[3]));          print_prop(f, code + 1, "", " ");
467          extra = 2;          extra = 2;
468          }          }
469          else fprintf(f, "%s", priv_OP_names[code[1]]);
470        }        }
471      else extra = print_char(f, code+1, utf);      else extra = print_char(f, code+1, utf);
472      fprintf(f, "%s", priv_OP_names[*code]);      fprintf(f, "%s", priv_OP_names[*code]);
# Line 459  for(;;) Line 495  for(;;)
495      case OP_TYPEUPTO:      case OP_TYPEUPTO:
496      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
497      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
     fprintf(f, "    %s", priv_OP_names[code[1 + IMM2_SIZE]]);  
498      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)      if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
499        {        {
500        fprintf(f, " %s ", get_ucpname(code[1 + IMM2_SIZE + 1],        print_prop(f, code + IMM2_SIZE + 1, "    ", " ");
         code[1 + IMM2_SIZE + 2]));  
501        extra = 2;        extra = 2;
502        }        }
503        else fprintf(f, "    %s", priv_OP_names[code[1 + IMM2_SIZE]]);
504      fprintf(f, "{");      fprintf(f, "{");
505      if (*code != OP_TYPEEXACT) fprintf(f, "0,");      if (*code != OP_TYPEEXACT) fprintf(f, "0,");
506      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
# Line 477  for(;;) Line 512  for(;;)
512      flag = "/i";      flag = "/i";
513      /* Fall through */      /* Fall through */
514      case OP_NOT:      case OP_NOT:
515      c = code[1];      fprintf(f, " %s [^", flag);
516      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);      extra = print_char(f, code + 1, utf);
517      else if (utf || c > 0xff)      fprintf(f, "]");
       fprintf(f, " %s [^\\x{%02x}]", flag, c);  
     else  
       fprintf(f, " %s [^\\x%02x]", flag, c);  
518      break;      break;
519    
520      case OP_NOTSTARI:      case OP_NOTSTARI:
# Line 506  for(;;) Line 538  for(;;)
538      case OP_NOTQUERY:      case OP_NOTQUERY:
539      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
540      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
541      c = code[1];      fprintf(f, " %s [^", flag);
542      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);      extra = print_char(f, code + 1, utf);
543        else fprintf(f, " %s [^\\x%02x]", flag, c);      fprintf(f, "]%s", priv_OP_names[*code]);
     fprintf(f, "%s", priv_OP_names[*code]);  
544      break;      break;
545    
546      case OP_NOTEXACTI:      case OP_NOTEXACTI:
# Line 523  for(;;) Line 554  for(;;)
554      case OP_NOTUPTO:      case OP_NOTUPTO:
555      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
556      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
557      c = code[1 + IMM2_SIZE];      fprintf(f, " %s [^", flag);
558      if (PRINTABLE(c)) fprintf(f, " %s [^%c]{", flag, c);      extra = print_char(f, code + 1 + IMM2_SIZE, utf);
559        else fprintf(f, " %s [^\\x%02x]{", flag, c);      fprintf(f, "]{");
560      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
561      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
562      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
# Line 554  for(;;) Line 585  for(;;)
585    
586      case OP_PROP:      case OP_PROP:
587      case OP_NOTPROP:      case OP_NOTPROP:
588      fprintf(f, "    %s %s", priv_OP_names[*code], get_ucpname(code[1], code[2]));      print_prop(f, code, "    ", "");
589      break;      break;
590    
591      /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no      /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no

Legend:
Removed from v.906  
changed lines
  Added in v.1046

  ViewVC Help
Powered by ViewVC 1.1.5