/[pcre]/code/branches/pcre16/pcre_printint.src
ViewVC logotype

Diff of /code/branches/pcre16/pcre_printint.src

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

revision 117 by ph10, Fri Mar 9 15:59:06 2007 UTC revision 579 by ph10, Wed Nov 24 17:39:25 2010 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2007 University of Cambridge             Copyright (c) 1997-2010 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 43  internal form of a compiled regular expr Line 43  internal form of a compiled regular expr
43  local functions. This source file is used in two places:  local functions. This source file is used in two places:
44    
45  (1) It is #included by pcre_compile.c when it is compiled in debugging mode  (1) It is #included by pcre_compile.c when it is compiled in debugging mode
46  (DEBUG defined in pcre_internal.h). It is not included in production compiles.  (PCRE_DEBUG defined in pcre_internal.h). It is not included in production
47    compiles.
48    
49  (2) It is always #included by pcretest.c, which can be asked to print out a  (2) It is always #included by pcretest.c, which can be asked to print out a
50  compiled regex for debugging purposes. */  compiled regex for debugging purposes. */
# Line 54  hexadecimal. We don't use isprint() beca Line 55  hexadecimal. We don't use isprint() beca
55  (even without the use of locales) and we want the output always to be the same,  (even without the use of locales) and we want the output always to be the same,
56  for testing purposes. This macro is used in pcretest as well as in this file. */  for testing purposes. This macro is used in pcretest as well as in this file. */
57    
58    #ifdef EBCDIC
59    #define PRINTABLE(c) ((c) >= 64 && (c) < 255)
60    #else
61  #define PRINTABLE(c) ((c) >= 32 && (c) < 127)  #define PRINTABLE(c) ((c) >= 32 && (c) < 127)
62    #endif
63    
64  /* The table of operator names. */  /* The table of operator names. */
65    
# Line 122  get_ucpname(int ptype, int pvalue) Line 127  get_ucpname(int ptype, int pvalue)
127  {  {
128  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
129  int i;  int i;
130  for (i = _pcre_utt_size; i >= 0; i--)  for (i = _pcre_utt_size - 1; i >= 0; i--)
131    {    {
132    if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;    if (ptype == _pcre_utt[i].type && pvalue == _pcre_utt[i].value) break;
133    }    }
134  return (i >= 0)? _pcre_utt[i].name : "??";  return (i >= 0)? _pcre_utt_names + _pcre_utt[i].name_offset : "??";
135  #else  #else
136  /* It gets harder and harder to shut off unwanted compiler warnings. */  /* It gets harder and harder to shut off unwanted compiler warnings. */
137  ptype = ptype * pvalue;  ptype = ptype * pvalue;
# Line 142  return (ptype == pvalue)? "??" : "??"; Line 147  return (ptype == pvalue)? "??" : "??";
147    
148  /* Make this function work for a regex with integers either byte order.  /* Make this function work for a regex with integers either byte order.
149  However, we assume that what we are passed is a compiled regex. The  However, we assume that what we are passed is a compiled regex. The
150  print_lengths flag controls whether offsets and lengths of items are printed.  print_lengths flag controls whether offsets and lengths of items are printed.
151  They can be turned off from pcretest so that automatic tests on bytecode can be  They can be turned off from pcretest so that automatic tests on bytecode can be
152  written that do not depend on the value of LINK_SIZE. */  written that do not depend on the value of LINK_SIZE. */
153    
# Line 181  for(;;) Line 186  for(;;)
186    if (print_lengths)    if (print_lengths)
187      fprintf(f, "%3d ", (int)(code - codestart));      fprintf(f, "%3d ", (int)(code - codestart));
188    else    else
189      fprintf(f, "    ");      fprintf(f, "    ");
190    
191    switch(*code)    switch(*code)
192      {      {
193    /* ========================================================================== */
194          /* These cases are never obeyed. This is a fudge that causes a compile-
195          time error if the vectors OP_names or _pcre_OP_lengths, which are indexed
196          by opcode, are not the correct length. It seems to be the only way to do
197          such a check at compile time, as the sizeof() operator does not work in
198          the C preprocessor. We do this while compiling pcretest, because that
199          #includes pcre_tables.c, which holds _pcre_OP_lengths. We can't do this
200          when building pcre_compile.c with PCRE_DEBUG set, because it doesn't then
201          know the size of _pcre_OP_lengths. */
202    
203    #ifdef COMPILING_PCRETEST
204          case OP_TABLE_LENGTH:
205          case OP_TABLE_LENGTH +
206            ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
207            (sizeof(_pcre_OP_lengths) == OP_TABLE_LENGTH)):
208          break;
209    #endif
210    /* ========================================================================== */
211    
212      case OP_END:      case OP_END:
213      fprintf(f, "    %s\n", OP_names[*code]);      fprintf(f, "    %s\n", OP_names[*code]);
214      fprintf(f, "------------------------------------------------------------------\n");      fprintf(f, "------------------------------------------------------------------\n");
# Line 219  for(;;) Line 243  for(;;)
243      case OP_CBRA:      case OP_CBRA:
244      case OP_SCBRA:      case OP_SCBRA:
245      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
246        else fprintf(f, "    ");        else fprintf(f, "    ");
247      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));      fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
248      break;      break;
249    
# Line 238  for(;;) Line 262  for(;;)
262      case OP_SCOND:      case OP_SCOND:
263      case OP_REVERSE:      case OP_REVERSE:
264      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));      if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
265        else fprintf(f, "    ");        else fprintf(f, "    ");
266      fprintf(f, "%s", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
267      break;      break;
268    
269        case OP_CLOSE:
270        fprintf(f, "    %s %d", OP_names[*code], GET2(code, 1));
271        break;
272    
273      case OP_CREF:      case OP_CREF:
274        case OP_NCREF:
275      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);      fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
276      break;      break;
277    
# Line 254  for(;;) Line 283  for(;;)
283        fprintf(f, "    Cond recurse %d", c);        fprintf(f, "    Cond recurse %d", c);
284      break;      break;
285    
286        case OP_NRREF:
287        c = GET2(code, 1);
288        if (c == RREF_ANY)
289          fprintf(f, "    Cond nrecurse any");
290        else
291          fprintf(f, "    Cond nrecurse %d", c);
292        break;
293    
294      case OP_DEF:      case OP_DEF:
295      fprintf(f, "    Cond def");      fprintf(f, "    Cond def");
296      break;      break;
# Line 356  for(;;) Line 393  for(;;)
393    
394      case OP_RECURSE:      case OP_RECURSE:
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", OP_names[*code]);      fprintf(f, "%s", OP_names[*code]);
398      break;      break;
399    
# Line 497  for(;;) Line 534  for(;;)
534        }        }
535      break;      break;
536    
537        case OP_MARK:
538        case OP_PRUNE_ARG:
539        case OP_SKIP_ARG:
540        fprintf(f, "    %s %s", OP_names[*code], code + 2);
541        extra += code[1];
542        break;
543    
544        case OP_THEN:
545        if (print_lengths)
546          fprintf(f, "    %s %d", OP_names[*code], GET(code, 1));
547        else
548          fprintf(f, "    %s", OP_names[*code]);
549        break;
550    
551        case OP_THEN_ARG:
552        if (print_lengths)
553          fprintf(f, "    %s %d %s", OP_names[*code], GET(code, 1),
554            code + 2 + LINK_SIZE);
555        else
556          fprintf(f, "    %s %s", OP_names[*code], code + 2 + LINK_SIZE);
557        extra += code[1+LINK_SIZE];
558        break;
559    
560      /* Anything else is just an item with no data*/      /* Anything else is just an item with no data*/
561    
562      default:      default:

Legend:
Removed from v.117  
changed lines
  Added in v.579

  ViewVC Help
Powered by ViewVC 1.1.5