/[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

code/branches/pcre16/pcre_printint.c revision 833 by zherczeg, Wed Dec 28 08:38:29 2011 UTC code/trunk/pcre_printint.c revision 1414 by zherczeg, Sun Dec 22 16:27:35 2013 UTC
# Line 55  asked to print out a compiled regex for Line 55  asked to print out a compiled regex for
55  #include "config.h"  #include "config.h"
56  #endif  #endif
57    
58    /* For pcretest program. */
59    #define PRIV(name) name
60    
61  /* We have to include pcre_internal.h because we need the internal info for  /* We have to include pcre_internal.h because we need the internal info for
62  displaying the results of pcre_study() and we also need to know about the  displaying the results of pcre_study() and we also need to know about the
63  internal macros, structures, and other internal data values; pcretest has  internal macros, structures, and other internal data values; pcretest has
# Line 75  having a separate .h file just for this. Line 78  having a separate .h file just for this.
78  #ifdef PCRE_INCLUDED  #ifdef PCRE_INCLUDED
79  static /* Keep the following function as private. */  static /* Keep the following function as private. */
80  #endif  #endif
81  #ifdef COMPILE_PCRE8  
82    #if defined COMPILE_PCRE8
83  void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);  void pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths);
84  #else  #elif defined COMPILE_PCRE16
85  void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);  void pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths);
86    #elif defined COMPILE_PCRE32
87    void pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths);
88  #endif  #endif
89    
90  /* Macro that decides whether a character should be output as a literal or in  /* Macro that decides whether a character should be output as a literal or in
# Line 94  for testing purposes. */ Line 100  for testing purposes. */
100    
101  /* The table of operator names. */  /* The table of operator names. */
102    
103  static const char *OP_names[] = { OP_NAME_LIST };  static const char *priv_OP_names[] = { OP_NAME_LIST };
104    
105  /* This table of operator lengths is not actually used by the working code,  /* This table of operator lengths is not actually used by the working code,
106  but its size is needed for a check that ensures it is the correct size for the  but its size is needed for a check that ensures it is the correct size for the
107  number of opcodes (thus catching update omissions). */  number of opcodes (thus catching update omissions). */
108    
109  static const pcre_uint8 OP_lengths[] = { OP_LENGTHS };  static const pcre_uint8 priv_OP_lengths[] = { OP_LENGTHS };
110    
111    
112    
# Line 108  static const pcre_uint8 OP_lengths[] = { Line 114  static const pcre_uint8 OP_lengths[] = {
114  *       Print single- or multi-byte character    *  *       Print single- or multi-byte character    *
115  *************************************************/  *************************************************/
116    
117  static int  static unsigned int
118  print_char(FILE *f, pcre_uchar *ptr, BOOL utf)  print_char(FILE *f, pcre_uchar *ptr, BOOL utf)
119  {  {
120  int c = *ptr;  pcre_uint32 c = *ptr;
121    
122  #ifndef SUPPORT_UTF  #ifndef SUPPORT_UTF
123    
124  (void)utf;  /* Avoid compiler warning */  (void)utf;  /* Avoid compiler warning */
125  if (PRINTABLE(c)) fprintf(f, "%c", c);  if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
126  else if (c <= 0xff) fprintf(f, "\\x%02x", c);  else if (c <= 0x80) fprintf(f, "\\x%02x", c);
127  else fprintf(f, "\\x{%x}", c);  else fprintf(f, "\\x{%x}", c);
128  return 0;  return 0;
129    
130  #else  #else
131    
132  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
133    
134  if (!utf || (c & 0xc0) != 0xc0)  if (!utf || (c & 0xc0) != 0xc0)
135    {    {
136    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);    if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
137      else if (c < 0x80) fprintf(f, "\\x%02x", c);
138      else fprintf(f, "\\x{%02x}", c);
139    return 0;    return 0;
140    }    }
141  else  else
# Line 157  else Line 165  else
165    return a;    return a;
166    }    }
167    
168  #else  #elif defined COMPILE_PCRE16
   
 #ifdef COMPILE_PCRE16  
169    
170  if (!utf || (c & 0xfc00) != 0xd800)  if (!utf || (c & 0xfc00) != 0xd800)
171    {    {
172    if (PRINTABLE(c)) fprintf(f, "%c", c);    if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
173    else if (c <= 0xff) fprintf(f, "\\x%02x", c);    else if (c <= 0x80) fprintf(f, "\\x%02x", c);
174    else fprintf(f, "\\x{%x}", c);    else fprintf(f, "\\x{%02x}", c);
175    return 0;    return 0;
176    }    }
177  else  else
# Line 185  else Line 191  else
191    return 1;    return 1;
192    }    }
193    
194  #endif /* COMPILE_PCRE16 */  #elif defined COMPILE_PCRE32
195    
196  #endif /* COMPILE_PCRE8 */  if (!utf || (c & 0xfffff800u) != 0xd800u)
197      {
198      if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
199      else if (c <= 0x80) fprintf(f, "\\x%02x", c);
200      else fprintf(f, "\\x{%x}", c);
201      return 0;
202      }
203    else
204      {
205      /* This is a check for malformed UTF-32; it should only occur if the sanity
206      check has been turned off. Rather than swallow a surrogate, just stop if
207      we hit one. Print it with \X instead of \x as an indication. */
208      fprintf(f, "\\X{%x}", c);
209      return 0;
210      }
211    
212    #endif /* COMPILE_PCRE[8|16|32] */
213    
214  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
215  }  }
# Line 201  print_puchar(FILE *f, PCRE_PUCHAR ptr) Line 223  print_puchar(FILE *f, PCRE_PUCHAR ptr)
223  {  {
224  while (*ptr != '\0')  while (*ptr != '\0')
225    {    {
226    register int c = *ptr++;    register pcre_uint32 c = *ptr++;
227    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
228    }    }
229  }  }
# Line 211  while (*ptr != '\0') Line 233  while (*ptr != '\0')
233  *************************************************/  *************************************************/
234    
235  static const char *  static const char *
236  get_ucpname(int ptype, int pvalue)  get_ucpname(unsigned int ptype, unsigned int pvalue)
237  {  {
238  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
239  int i;  int i;
# Line 228  return (ptype == pvalue)? "??" : "??"; Line 250  return (ptype == pvalue)? "??" : "??";
250  }  }
251    
252    
253    /*************************************************
254    *       Print Unicode property value             *
255    *************************************************/
256    
257    /* "Normal" properties can be printed from tables. The PT_CLIST property is a
258    pseudo-property that contains a pointer to a list of case-equivalent
259    characters. This is used only when UCP support is available and UTF mode is
260    selected. It should never occur otherwise, but just in case it does, have
261    something ready to print. */
262    
263    static void
264    print_prop(FILE *f, pcre_uchar *code, const char *before, const char *after)
265    {
266    if (code[1] != PT_CLIST)
267      {
268      fprintf(f, "%s%s %s%s", before, priv_OP_names[*code], get_ucpname(code[1],
269        code[2]), after);
270      }
271    else
272      {
273      const char *not = (*code == OP_PROP)? "" : "not ";
274    #ifndef SUPPORT_UCP
275      fprintf(f, "%s%sclist %d%s", before, not, code[2], after);
276    #else
277      const pcre_uint32 *p = PRIV(ucd_caseless_sets) + code[2];
278      fprintf (f, "%s%sclist", before, not);
279      while (*p < NOTACHAR) fprintf(f, " %04x", *p++);
280      fprintf(f, "%s", after);
281    #endif
282      }
283    }
284    
285    
286    
287    
288  /*************************************************  /*************************************************
289  *         Print compiled regex                   *  *         Print compiled regex                   *
# Line 242  written that do not depend on the value Line 298  written that do not depend on the value
298  #ifdef PCRE_INCLUDED  #ifdef PCRE_INCLUDED
299  static /* Keep the following function as private. */  static /* Keep the following function as private. */
300  #endif  #endif
301  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
302  void  void
303  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre_printint(pcre *external_re, FILE *f, BOOL print_lengths)
304  #else  #elif defined COMPILE_PCRE16
305  void  void
306  pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)  pcre16_printint(pcre *external_re, FILE *f, BOOL print_lengths)
307    #elif defined COMPILE_PCRE32
308    void
309    pcre32_printint(pcre *external_re, FILE *f, BOOL print_lengths)
310  #endif  #endif
311  {  {
312  real_pcre *re = (real_pcre *)external_re;  REAL_PCRE *re = (REAL_PCRE *)external_re;
313  pcre_uchar *codestart, *code;  pcre_uchar *codestart, *code;
314  BOOL utf;  BOOL utf;
315    
# Line 271  if (re->magic_number != MAGIC_NUMBER) Line 330  if (re->magic_number != MAGIC_NUMBER)
330    }    }
331    
332  code = codestart = (pcre_uchar *)re + offset + count * size;  code = codestart = (pcre_uchar *)re + offset + count * size;
333  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
334  utf = (options & PCRE_UTF8) != 0;  utf = (options & PCRE_UTF8) != 0;
335    
336  for(;;)  for(;;)
337    {    {
338    pcre_uchar *ccode;    pcre_uchar *ccode;
339    const char *flag = "  ";    const char *flag = "  ";
340    int c;    pcre_uint32 c;
341    int extra = 0;    unsigned int extra = 0;
342    
343    if (print_lengths)    if (print_lengths)
344      fprintf(f, "%3d ", (int)(code - codestart));      fprintf(f, "%3d ", (int)(code - codestart));
# Line 297  for(;;) Line 356  for(;;)
356    
357        case OP_TABLE_LENGTH:        case OP_TABLE_LENGTH:
358        case OP_TABLE_LENGTH +        case OP_TABLE_LENGTH +
359          ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&          ((sizeof(priv_OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
360          (sizeof(OP_lengths) == OP_TABLE_LENGTH)):          (sizeof(priv_OP_lengths) == OP_TABLE_LENGTH)):
361        break;        break;
362  /* ========================================================================== */  /* ========================================================================== */
363    
364      case OP_END:      case OP_END:
365      fprintf(f, "    %s\n", OP_names[*code]);      fprintf(f, "    %s\n", priv_OP_names[*code]);
366      fprintf(f, "------------------------------------------------------------------\n");      fprintf(f, "------------------------------------------------------------------\n");
367      return;      return;
368    
# Line 335  for(;;) Line 394  for(;;)
394      case OP_SCBRAPOS:      case OP_SCBRAPOS:
395      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
396        else fprintf(f, "    ");        else fprintf(f, "    ");
397      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));      fprintf(f, "%s %d", priv_OP_names[*code], GET2(code, 1+LINK_SIZE));
398      break;      break;
399    
400      case OP_BRA:      case OP_BRA:
# Line 358  for(;;) Line 417  for(;;)
417      case OP_REVERSE:      case OP_REVERSE:
418      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
419        else fprintf(f, "    ");        else fprintf(f, "    ");
420      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", priv_OP_names[*code]);
421      break;      break;
422    
423      case OP_CLOSE:      case OP_CLOSE:
424      fprintf(f, "    %s %d", OP_names[*code], GET2(code, 1));      fprintf(f, "    %s %d", priv_OP_names[*code], GET2(code, 1));
425      break;      break;
426    
427      case OP_CREF:      case OP_CREF:
428      case OP_NCREF:      fprintf(f, "%3d %s", GET2(code,1), priv_OP_names[*code]);
429      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);      break;
430    
431        case OP_DNCREF:
432          {
433          pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
434            IMM2_SIZE;
435          fprintf(f, " %s Cond ref <", flag);
436          print_puchar(f, entry);
437          fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
438          }
439      break;      break;
440    
441      case OP_RREF:      case OP_RREF:
# Line 378  for(;;) Line 446  for(;;)
446        fprintf(f, "    Cond recurse %d", c);        fprintf(f, "    Cond recurse %d", c);
447      break;      break;
448    
449      case OP_NRREF:      case OP_DNRREF:
450      c = GET2(code, 1);        {
451      if (c == RREF_ANY)        pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
452        fprintf(f, "    Cond nrecurse any");          IMM2_SIZE;
453      else        fprintf(f, " %s Cond recurse <", flag);
454        fprintf(f, "    Cond nrecurse %d", c);        print_puchar(f, entry);
455          fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
456          }
457      break;      break;
458    
459      case OP_DEF:      case OP_DEF:
# Line 422  for(;;) Line 492  for(;;)
492      fprintf(f, " %s ", flag);      fprintf(f, " %s ", flag);
493      if (*code >= OP_TYPESTAR)      if (*code >= OP_TYPESTAR)
494        {        {
       fprintf(f, "%s", OP_names[code[1]]);  
495        if (code[1] == OP_PROP || code[1] == OP_NOTPROP)        if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
496          {          {
497          fprintf(f, " %s ", get_ucpname(code[2], code[3]));          print_prop(f, code + 1, "", " ");
498          extra = 2;          extra = 2;
499          }          }
500          else fprintf(f, "%s", priv_OP_names[code[1]]);
501        }        }
502      else extra = print_char(f, code+1, utf);      else extra = print_char(f, code+1, utf);
503      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", priv_OP_names[*code]);
504      break;      break;
505    
506      case OP_EXACTI:      case OP_EXACTI:
# Line 456  for(;;) Line 526  for(;;)
526      case OP_TYPEUPTO:      case OP_TYPEUPTO:
527      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
528      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
     fprintf(f, "    %s", OP_names[code[1 + IMM2_SIZE]]);  
529      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)
530        {        {
531        fprintf(f, " %s ", get_ucpname(code[1 + IMM2_SIZE + 1],        print_prop(f, code + IMM2_SIZE + 1, "    ", " ");
         code[1 + IMM2_SIZE + 2]));  
532        extra = 2;        extra = 2;
533        }        }
534        else fprintf(f, "    %s", priv_OP_names[code[1 + IMM2_SIZE]]);
535      fprintf(f, "{");      fprintf(f, "{");
536      if (*code != OP_TYPEEXACT) fprintf(f, "0,");      if (*code != OP_TYPEEXACT) fprintf(f, "0,");
537      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
# Line 474  for(;;) Line 543  for(;;)
543      flag = "/i";      flag = "/i";
544      /* Fall through */      /* Fall through */
545      case OP_NOT:      case OP_NOT:
546      c = code[1];      fprintf(f, " %s [^", flag);
547      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);      extra = print_char(f, code + 1, utf);
548      else if (utf || c > 0xff)      fprintf(f, "]");
       fprintf(f, " %s [^\\x{%02x}]", flag, c);  
     else  
       fprintf(f, " %s [^\\x%02x]", flag, c);  
549      break;      break;
550    
551      case OP_NOTSTARI:      case OP_NOTSTARI:
# Line 503  for(;;) Line 569  for(;;)
569      case OP_NOTQUERY:      case OP_NOTQUERY:
570      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
571      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
572      c = code[1];      fprintf(f, " %s [^", flag);
573      if (PRINTABLE(c)) fprintf(f, " %s [^%c]", flag, c);      extra = print_char(f, code + 1, utf);
574        else fprintf(f, " %s [^\\x%02x]", flag, c);      fprintf(f, "]%s", priv_OP_names[*code]);
     fprintf(f, "%s", OP_names[*code]);  
575      break;      break;
576    
577      case OP_NOTEXACTI:      case OP_NOTEXACTI:
# Line 520  for(;;) Line 585  for(;;)
585      case OP_NOTUPTO:      case OP_NOTUPTO:
586      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
587      case OP_NOTPOSUPTO:      case OP_NOTPOSUPTO:
588      c = code[1 + IMM2_SIZE];      fprintf(f, " %s [^", flag);
589      if (PRINTABLE(c)) fprintf(f, " %s [^%c]{", flag, c);      extra = print_char(f, code + 1 + IMM2_SIZE, utf);
590        else fprintf(f, " %s [^\\x%02x]{", flag, c);      fprintf(f, "]{");
591      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");      if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
592      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
593      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");      if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
# Line 533  for(;;) Line 598  for(;;)
598      case OP_RECURSE:      case OP_RECURSE:
599      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
600        else fprintf(f, "    ");        else fprintf(f, "    ");
601      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", priv_OP_names[*code]);
602      break;      break;
603    
604      case OP_REFI:      case OP_REFI:
# Line 541  for(;;) Line 606  for(;;)
606      /* Fall through */      /* Fall through */
607      case OP_REF:      case OP_REF:
608      fprintf(f, " %s \\%d", flag, GET2(code,1));      fprintf(f, " %s \\%d", flag, GET2(code,1));
609      ccode = code + PRIV(OP_lengths)[*code];      ccode = code + priv_OP_lengths[*code];
610        goto CLASS_REF_REPEAT;
611    
612        case OP_DNREFI:
613        flag = "/i";
614        /* Fall through */
615        case OP_DNREF:
616          {
617          pcre_uchar *entry = (pcre_uchar *)re + offset + (GET2(code, 1) * size) +
618            IMM2_SIZE;
619          fprintf(f, " %s \\k<", flag);
620          print_puchar(f, entry);
621          fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
622          }
623        ccode = code + priv_OP_lengths[*code];
624      goto CLASS_REF_REPEAT;      goto CLASS_REF_REPEAT;
625    
626      case OP_CALLOUT:      case OP_CALLOUT:
627      fprintf(f, "    %s %d %d %d", OP_names[*code], code[1], GET(code,2),      fprintf(f, "    %s %d %d %d", priv_OP_names[*code], code[1], GET(code,2),
628        GET(code, 2 + LINK_SIZE));        GET(code, 2 + LINK_SIZE));
629      break;      break;
630    
631      case OP_PROP:      case OP_PROP:
632      case OP_NOTPROP:      case OP_NOTPROP:
633      fprintf(f, "    %s %s", OP_names[*code], get_ucpname(code[1], code[2]));      print_prop(f, code, "    ", "");
634      break;      break;
635    
636      /* OP_XCLASS can only occur in UTF or PCRE16 modes. However, there's no      /* OP_XCLASS cannot occur in 8-bit, non-UTF mode. However, there's no harm
637      harm in having this code always here, and it makes it less messy without      in having this code always here, and it makes it less messy without all
638      all those #ifdefs. */      those #ifdefs. */
639    
640      case OP_CLASS:      case OP_CLASS:
641      case OP_NCLASS:      case OP_NCLASS:
642      case OP_XCLASS:      case OP_XCLASS:
643        {        {
644        int i, min, max;        int i;
645          unsigned int min, max;
646        BOOL printmap;        BOOL printmap;
647          BOOL invertmap = FALSE;
648        pcre_uint8 *map;        pcre_uint8 *map;
649          pcre_uint8 inverted_map[32];
650    
651        fprintf(f, "    [");        fprintf(f, "    [");
652    
# Line 573  for(;;) Line 655  for(;;)
655          extra = GET(code, 1);          extra = GET(code, 1);
656          ccode = code + LINK_SIZE + 1;          ccode = code + LINK_SIZE + 1;
657          printmap = (*ccode & XCL_MAP) != 0;          printmap = (*ccode & XCL_MAP) != 0;
658          if ((*ccode++ & XCL_NOT) != 0) fprintf(f, "^");          if ((*ccode & XCL_NOT) != 0)
659              {
660              invertmap = (*ccode & XCL_HASPROP) == 0;
661              fprintf(f, "^");
662              }
663            ccode++;
664          }          }
665        else        else
666          {          {
# Line 586  for(;;) Line 673  for(;;)
673        if (printmap)        if (printmap)
674          {          {
675          map = (pcre_uint8 *)ccode;          map = (pcre_uint8 *)ccode;
676            if (invertmap)
677              {
678              for (i = 0; i < 32; i++) inverted_map[i] = ~map[i];
679              map = inverted_map;
680              }
681    
682          for (i = 0; i < 256; i++)          for (i = 0; i < 256; i++)
683            {            {
684            if ((map[i/8] & (1 << (i&7))) != 0)            if ((map[i/8] & (1 << (i&7))) != 0)
# Line 613  for(;;) Line 706  for(;;)
706    
707        if (*code == OP_XCLASS)        if (*code == OP_XCLASS)
708          {          {
709          int ch;          pcre_uchar ch;
710          while ((ch = *ccode++) != XCL_END)          while ((ch = *ccode++) != XCL_END)
711            {            {
712            if (ch == XCL_PROP)            BOOL not = FALSE;
713              {            const char *notch = "";
714              int ptype = *ccode++;  
715              int pvalue = *ccode++;            switch(ch)
             fprintf(f, "\\p{%s}", get_ucpname(ptype, pvalue));  
             }  
           else if (ch == XCL_NOTPROP)  
             {  
             int ptype = *ccode++;  
             int pvalue = *ccode++;  
             fprintf(f, "\\P{%s}", get_ucpname(ptype, pvalue));  
             }  
           else  
716              {              {
717                case XCL_NOTPROP:
718                not = TRUE;
719                notch = "^";
720                /* Fall through */
721    
722                case XCL_PROP:
723                  {
724                  unsigned int ptype = *ccode++;
725                  unsigned int pvalue = *ccode++;
726    
727                  switch(ptype)
728                    {
729                    case PT_PXGRAPH:
730                    fprintf(f, "[:%sgraph:]", notch);
731                    break;
732    
733                    case PT_PXPRINT:
734                    fprintf(f, "[:%sprint:]", notch);
735                    break;
736    
737                    case PT_PXPUNCT:
738                    fprintf(f, "[:%spunct:]", notch);
739                    break;
740    
741                    default:
742                    fprintf(f, "\\%c{%s}", (not? 'P':'p'),
743                      get_ucpname(ptype, pvalue));
744                    break;
745                    }
746                  }
747                break;
748    
749                default:
750              ccode += 1 + print_char(f, ccode, utf);              ccode += 1 + print_char(f, ccode, utf);
751              if (ch == XCL_RANGE)              if (ch == XCL_RANGE)
752                {                {
753                fprintf(f, "-");                fprintf(f, "-");
754                ccode += 1 + print_char(f, ccode, utf);                ccode += 1 + print_char(f, ccode, utf);
755                }                }
756                break;
757              }              }
758            }            }
759          }          }
# Line 655  for(;;) Line 773  for(;;)
773          case OP_CRMINPLUS:          case OP_CRMINPLUS:
774          case OP_CRQUERY:          case OP_CRQUERY:
775          case OP_CRMINQUERY:          case OP_CRMINQUERY:
776          fprintf(f, "%s", OP_names[*ccode]);          case OP_CRPOSSTAR:
777          extra += PRIV(OP_lengths)[*ccode];          case OP_CRPOSPLUS:
778            case OP_CRPOSQUERY:
779            fprintf(f, "%s", priv_OP_names[*ccode]);
780            extra += priv_OP_lengths[*ccode];
781          break;          break;
782    
783          case OP_CRRANGE:          case OP_CRRANGE:
784          case OP_CRMINRANGE:          case OP_CRMINRANGE:
785            case OP_CRPOSRANGE:
786          min = GET2(ccode,1);          min = GET2(ccode,1);
787          max = GET2(ccode,1 + IMM2_SIZE);          max = GET2(ccode,1 + IMM2_SIZE);
788          if (max == 0) fprintf(f, "{%d,}", min);          if (max == 0) fprintf(f, "{%u,}", min);
789          else fprintf(f, "{%d,%d}", min, max);          else fprintf(f, "{%u,%u}", min, max);
790          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");          if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
791          extra += PRIV(OP_lengths)[*ccode];          else if (*ccode == OP_CRPOSRANGE) fprintf(f, "+");
792            extra += priv_OP_lengths[*ccode];
793          break;          break;
794    
795          /* Do nothing if it's not a repeat; this code stops picky compilers          /* Do nothing if it's not a repeat; this code stops picky compilers
# Line 682  for(;;) Line 805  for(;;)
805      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
806      case OP_SKIP_ARG:      case OP_SKIP_ARG:
807      case OP_THEN_ARG:      case OP_THEN_ARG:
808      fprintf(f, "    %s ", OP_names[*code]);      fprintf(f, "    %s ", priv_OP_names[*code]);
809      print_puchar(f, code + 2);      print_puchar(f, code + 2);
810      extra += code[1];      extra += code[1];
811      break;      break;
812    
813      case OP_THEN:      case OP_THEN:
814      fprintf(f, "    %s", OP_names[*code]);      fprintf(f, "    %s", priv_OP_names[*code]);
815      break;      break;
816    
817      case OP_CIRCM:      case OP_CIRCM:
# Line 699  for(;;) Line 822  for(;;)
822      /* Anything else is just an item with no data, but possibly a flag. */      /* Anything else is just an item with no data, but possibly a flag. */
823    
824      default:      default:
825      fprintf(f, " %s %s", flag, OP_names[*code]);      fprintf(f, " %s %s", flag, priv_OP_names[*code]);
826      break;      break;
827      }      }
828    
829    code += PRIV(OP_lengths)[*code] + extra;    code += priv_OP_lengths[*code] + extra;
830    fprintf(f, "\n");    fprintf(f, "\n");
831    }    }
832  }  }

Legend:
Removed from v.833  
changed lines
  Added in v.1414

  ViewVC Help
Powered by ViewVC 1.1.5