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

Diff of /code/trunk/pcre_printint.src

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

revision 92 by nigel, Sat Feb 24 21:41:34 2007 UTC revision 93 by nigel, Sat Feb 24 21:41:42 2007 UTC
# Line 49  local functions. This source file is use Line 49  local functions. This source file is use
49  compiled regex for debugging purposes. */  compiled regex for debugging purposes. */
50    
51    
52    /* Macro that decides whether a character should be output as a literal or in
53    hexadecimal. We don't use isprint() because that can vary from system to system
54    (even without the use of locales) and we want the output always to be the same,
55    for testing purposes. This macro is used in pcretest as well as in this file. */
56    
57    #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
58    
59    /* The table of operator names. */
60    
61  static const char *OP_names[] = { OP_NAME_LIST };  static const char *OP_names[] = { OP_NAME_LIST };
62    
63    
64    
65  /*************************************************  /*************************************************
66  *       Print single- or multi-byte character    *  *       Print single- or multi-byte character    *
67  *************************************************/  *************************************************/
# Line 63  int c = *ptr; Line 73  int c = *ptr;
73    
74  if (!utf8 || (c & 0xc0) != 0xc0)  if (!utf8 || (c & 0xc0) != 0xc0)
75    {    {
76    if (isprint(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);    if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x%02x", c);
77    return 0;    return 0;
78    }    }
79  else  else
# Line 160  for(;;) Line 170  for(;;)
170    
171    fprintf(f, "%3d ", (int)(code - codestart));    fprintf(f, "%3d ", (int)(code - codestart));
172    
   if (*code >= OP_BRA)  
     {  
     if (*code - OP_BRA > EXTRACT_BASIC_MAX)  
       fprintf(f, "%3d Bra extra\n", GET(code, 1));  
     else  
       fprintf(f, "%3d Bra %d\n", GET(code, 1), *code - OP_BRA);  
     code += _pcre_OP_lengths[OP_BRA];  
     continue;  
     }  
   
173    switch(*code)    switch(*code)
174      {      {
175      case OP_END:      case OP_END:
# Line 203  for(;;) Line 203  for(;;)
203      fprintf(f, "\n");      fprintf(f, "\n");
204      continue;      continue;
205    
206        case OP_CBRA:
207        case OP_SCBRA:
208        fprintf(f, "%3d %s %d", GET(code, 1), OP_names[*code],
209          GET2(code, 1+LINK_SIZE));
210        break;
211    
212        case OP_BRA:
213        case OP_SBRA:
214      case OP_KETRMAX:      case OP_KETRMAX:
215      case OP_KETRMIN:      case OP_KETRMIN:
216      case OP_ALT:      case OP_ALT:
# Line 213  for(;;) Line 221  for(;;)
221      case OP_ASSERTBACK_NOT:      case OP_ASSERTBACK_NOT:
222      case OP_ONCE:      case OP_ONCE:
223      case OP_COND:      case OP_COND:
224        case OP_SCOND:
225      case OP_REVERSE:      case OP_REVERSE:
226      fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);      fprintf(f, "%3d %s", GET(code, 1), OP_names[*code]);
227      break;      break;
228    
229      case OP_BRANUMBER:      case OP_CREF:
230      printf("%3d %s", GET2(code, 1), OP_names[*code]);      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
231      break;      break;
232    
233      case OP_CREF:      case OP_RREF:
234      if (GET2(code, 1) == CREF_RECURSE)      c = GET2(code, 1);
235        fprintf(f, "    Cond recurse");      if (c == RREF_ANY)
236          fprintf(f, "    Cond recurse any");
237      else      else
238        fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);        fprintf(f, "    Cond recurse %d", c);
239        break;
240    
241        case OP_DEF:
242        fprintf(f, "    Cond def");
243      break;      break;
244    
245      case OP_STAR:      case OP_STAR:
246      case OP_MINSTAR:      case OP_MINSTAR:
247        case OP_POSSTAR:
248      case OP_PLUS:      case OP_PLUS:
249      case OP_MINPLUS:      case OP_MINPLUS:
250        case OP_POSPLUS:
251      case OP_QUERY:      case OP_QUERY:
252      case OP_MINQUERY:      case OP_MINQUERY:
253        case OP_POSQUERY:
254      case OP_TYPESTAR:      case OP_TYPESTAR:
255      case OP_TYPEMINSTAR:      case OP_TYPEMINSTAR:
256        case OP_TYPEPOSSTAR:
257      case OP_TYPEPLUS:      case OP_TYPEPLUS:
258      case OP_TYPEMINPLUS:      case OP_TYPEMINPLUS:
259        case OP_TYPEPOSPLUS:
260      case OP_TYPEQUERY:      case OP_TYPEQUERY:
261      case OP_TYPEMINQUERY:      case OP_TYPEMINQUERY:
262        case OP_TYPEPOSQUERY:
263      fprintf(f, "    ");      fprintf(f, "    ");
264      if (*code >= OP_TYPESTAR)      if (*code >= OP_TYPESTAR)
265        {        {
# Line 257  for(;;) Line 277  for(;;)
277      case OP_EXACT:      case OP_EXACT:
278      case OP_UPTO:      case OP_UPTO:
279      case OP_MINUPTO:      case OP_MINUPTO:
280        case OP_POSUPTO:
281      fprintf(f, "    ");      fprintf(f, "    ");
282      extra = print_char(f, code+3, utf8);      extra = print_char(f, code+3, utf8);
283      fprintf(f, "{");      fprintf(f, "{");
284      if (*code != OP_EXACT) fprintf(f, ",");      if (*code != OP_EXACT) fprintf(f, "0,");
285      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
286      if (*code == OP_MINUPTO) fprintf(f, "?");      if (*code == OP_MINUPTO) fprintf(f, "?");
287          else if (*code == OP_POSUPTO) fprintf(f, "+");
288      break;      break;
289    
290      case OP_TYPEEXACT:      case OP_TYPEEXACT:
291      case OP_TYPEUPTO:      case OP_TYPEUPTO:
292      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
293        case OP_TYPEPOSUPTO:
294      fprintf(f, "    %s", OP_names[code[3]]);      fprintf(f, "    %s", OP_names[code[3]]);
295      if (code[3] == OP_PROP || code[3] == OP_NOTPROP)      if (code[3] == OP_PROP || code[3] == OP_NOTPROP)
296        {        {
# Line 278  for(;;) Line 301  for(;;)
301      if (*code != OP_TYPEEXACT) fprintf(f, "0,");      if (*code != OP_TYPEEXACT) fprintf(f, "0,");
302      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
303      if (*code == OP_TYPEMINUPTO) fprintf(f, "?");      if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
304          else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
305      break;      break;
306    
307      case OP_NOT:      case OP_NOT:
308      if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);      c = code[1];
309        if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
310        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, "    [^\\x%02x]", c);
311      break;      break;
312    
313      case OP_NOTSTAR:      case OP_NOTSTAR:
314      case OP_NOTMINSTAR:      case OP_NOTMINSTAR:
315        case OP_NOTPOSSTAR:
316      case OP_NOTPLUS:      case OP_NOTPLUS:
317      case OP_NOTMINPLUS:      case OP_NOTMINPLUS:
318        case OP_NOTPOSPLUS:
319      case OP_NOTQUERY:      case OP_NOTQUERY:
320      case OP_NOTMINQUERY:      case OP_NOTMINQUERY:
321      if (isprint(c = code[1])) fprintf(f, "    [^%c]", c);      case OP_NOTPOSQUERY:
322        c = code[1];
323        if (PRINTABLE(c)) fprintf(f, "    [^%c]", c);
324        else fprintf(f, "    [^\\x%02x]", c);        else fprintf(f, "    [^\\x%02x]", c);
325      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
326      break;      break;
# Line 299  for(;;) Line 328  for(;;)
328      case OP_NOTEXACT:      case OP_NOTEXACT:
329      case OP_NOTUPTO:      case OP_NOTUPTO:
330      case OP_NOTMINUPTO:      case OP_NOTMINUPTO:
331      if (isprint(c = code[3])) fprintf(f, "    [^%c]{", c);      case OP_NOTPOSUPTO:
332        c = code[3];
333        if (PRINTABLE(c)) fprintf(f, "    [^%c]{", c);
334        else fprintf(f, "    [^\\x%02x]{", c);        else fprintf(f, "    [^\\x%02x]{", c);
335      if (*code != OP_NOTEXACT) fprintf(f, "0,");      if (*code != OP_NOTEXACT) fprintf(f, "0,");
336      fprintf(f, "%d}", GET2(code,1));      fprintf(f, "%d}", GET2(code,1));
337      if (*code == OP_NOTMINUPTO) fprintf(f, "?");      if (*code == OP_NOTMINUPTO) fprintf(f, "?");
338          else if (*code == OP_NOTPOSUPTO) fprintf(f, "+");
339      break;      break;
340    
341      case OP_RECURSE:      case OP_RECURSE:
# Line 363  for(;;) Line 395  for(;;)
395              for (j = i+1; j < 256; j++)              for (j = i+1; j < 256; j++)
396                if ((ccode[j/8] & (1 << (j&7))) == 0) break;                if ((ccode[j/8] & (1 << (j&7))) == 0) break;
397              if (i == '-' || i == ']') fprintf(f, "\\");              if (i == '-' || i == ']') fprintf(f, "\\");
398              if (isprint(i)) fprintf(f, "%c", i); else fprintf(f, "\\x%02x", i);              if (PRINTABLE(i)) fprintf(f, "%c", i);
399                  else fprintf(f, "\\x%02x", i);
400              if (--j > i)              if (--j > i)
401                {                {
402                if (j != i + 1) fprintf(f, "-");                if (j != i + 1) fprintf(f, "-");
403                if (j == '-' || j == ']') fprintf(f, "\\");                if (j == '-' || j == ']') fprintf(f, "\\");
404                if (isprint(j)) fprintf(f, "%c", j); else fprintf(f, "\\x%02x", j);                if (PRINTABLE(j)) fprintf(f, "%c", j);
405                    else fprintf(f, "\\x%02x", j);
406                }                }
407              i = j;              i = j;
408              }              }

Legend:
Removed from v.92  
changed lines
  Added in v.93

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12