⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regex.c

📁 功能较全面的反汇编器:反汇编器ht-2.0.15.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
  at_dot,	/* Succeeds if at point.  */  after_dot,	/* Succeeds if after point.  */	/* Matches any character whose syntax is specified.  Followed by		 a byte which contains a syntax code, e.g., Sword.  */  syntaxspec,	/* Matches any character whose syntax is not that specified.  */  notsyntaxspec#endif /* emacs */} re_opcode_t;/* Common operations on the compiled pattern.  *//* Store NUMBER in two contiguous bytes starting at DESTINATION.  */#define STORE_NUMBER(destination, number)				\  do {									\    (destination)[0] = (number) & 0377;					\    (destination)[1] = (number) >> 8;					\  } while (0)/* Same as STORE_NUMBER, except increment DESTINATION to   the byte after where the number is stored.  Therefore, DESTINATION   must be an lvalue.  */#define STORE_NUMBER_AND_INCR(destination, number)			\  do {									\    STORE_NUMBER (destination, number);					\    (destination) += 2;							\  } while (0)/* Put into DESTINATION a number stored in two contiguous bytes starting   at SOURCE.  */#define EXTRACT_NUMBER(destination, source)				\  do {									\    (destination) = *(source) & 0377;					\    (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8;		\  } while (0)#ifdef DEBUGstatic voidextract_number (dest, source)    int *dest;    unsigned char *source;{  int temp = SIGN_EXTEND_CHAR (*(source + 1));   *dest = *source & 0377;  *dest += temp << 8;}#ifndef EXTRACT_MACROS /* To debug the macros.  */#undef EXTRACT_NUMBER#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)#endif /* not EXTRACT_MACROS */#endif /* DEBUG *//* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.   SOURCE must be an lvalue.  */#define EXTRACT_NUMBER_AND_INCR(destination, source)			\  do {									\    EXTRACT_NUMBER (destination, source);				\    (source) += 2; 							\  } while (0)#ifdef DEBUGstatic voidextract_number_and_incr (destination, source)    int *destination;    unsigned char **source;{   extract_number (destination, *source);  *source += 2;}#ifndef EXTRACT_MACROS#undef EXTRACT_NUMBER_AND_INCR#define EXTRACT_NUMBER_AND_INCR(dest, src) \  extract_number_and_incr (&dest, &src)#endif /* not EXTRACT_MACROS */#endif /* DEBUG *//* If DEBUG is defined, Regex prints many voluminous messages about what   it is doing (if the variable `debug' is nonzero).  If linked with the   main program in `iregex.c', you can enter patterns and strings   interactively.  And if linked with the main program in `main.c' and   the other test files, you can run the already-written tests.  */#ifdef DEBUG/* We use standard I/O for debugging.  */#include <stdio.h>/* It is useful to test things that ``must'' be true when debugging.  */#include <assert.h>static int debug = 0;#define DEBUG_STATEMENT(e) e#define DEBUG_PRINT1(x) if (debug) printf (x)#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) 				\  if (debug) print_partial_compiled_pattern (s, e)#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)			\  if (debug) print_double_string (w, s1, sz1, s2, sz2)/* Print the fastmap in human-readable form.  */voidprint_fastmap (fastmap)    char *fastmap;{  unsigned was_a_range = 0;  unsigned i = 0;      while (i < (1 << BYTEWIDTH))    {	 if (fastmap[i++])	{	  was_a_range = 0;		putchar (i - 1);		while (i < (1 << BYTEWIDTH)  &&  fastmap[i])		  {		    was_a_range = 1;		    i++;		  }	  if (was_a_range)		  {		    printf ("-");		    putchar (i - 1);		  }	   }    }  putchar ('\n'); }/* Print a compiled pattern string in human-readable form, starting at   the START pointer into it and ending just before the pointer END.  */voidprint_partial_compiled_pattern (start, end)    unsigned char *start;    unsigned char *end;{  int mcnt, mcnt2;  unsigned char *p = start;  unsigned char *pend = end;  if (start == NULL)    {	 printf ("(null)\n");	 return;    }      /* Loop over pattern commands.  */  while (p < pend)    {	 printf ("%d:\t", p - start);	 switch ((re_opcode_t) *p++)	{	   case no_op:		printf ("/no_op");		break;	case exactn:	  mcnt = *p++;		printf ("/exactn/%d", mcnt);		do	    {		    putchar ('/');		 putchar (*p++);		  }		while (--mcnt);		break;	case start_memory:		mcnt = *p++;		printf ("/start_memory/%d/%d", mcnt, *p++);		break;	case stop_memory:		mcnt = *p++;	  printf ("/stop_memory/%d/%d", mcnt, *p++);		break;	case duplicate:	  printf ("/duplicate/%d", *p++);	  break;	case anychar:	  printf ("/anychar");	  break;	case charset:	   case charset_not:		{		  register int c, last = -100;	    register int in_range = 0;	    printf ("/charset [%s",			  (re_opcode_t) *(p - 1) == charset_not ? "^" : "");		  		  assert (p + *p < pend);		  for (c = 0; c < 256; c++)		 if (c / 8 < *p		  && (p[1 + (c/8)] & (1 << (c % 8))))		{		  /* Are we starting a range?  */		  if (last + 1 == c && ! in_range)		    {			 putchar ('-');			 in_range = 1;		    }		  /* Have we broken a range?  */		  else if (last + 1 != c && in_range)		    {			 putchar (last);			 in_range = 0;		    }			 		  if (! in_range)		    putchar (c);		  last = c;		    }	    if (in_range)		 putchar (last);	    putchar (']');	    p += 1 + *p;	  }	  break;	case begline:	  printf ("/begline");		break;	case endline:		printf ("/endline");		break;	case on_failure_jump:		extract_number_and_incr (&mcnt, &p);	  printf ("/on_failure_jump to %d", p + mcnt - start);		break;	case on_failure_keep_string_jump:		extract_number_and_incr (&mcnt, &p);	  printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);		break;	case dummy_failure_jump:		extract_number_and_incr (&mcnt, &p);	  printf ("/dummy_failure_jump to %d", p + mcnt - start);		break;	case push_dummy_failure:		printf ("/push_dummy_failure");		break;			   case maybe_pop_jump:		extract_number_and_incr (&mcnt, &p);	  printf ("/maybe_pop_jump to %d", p + mcnt - start);	  break;	   case pop_failure_jump:	  extract_number_and_incr (&mcnt, &p);	  printf ("/pop_failure_jump to %d", p + mcnt - start);	  break;          			   case jump_past_alt:	  extract_number_and_incr (&mcnt, &p);	  printf ("/jump_past_alt to %d", p + mcnt - start);	  break;          			   case jump:	  extract_number_and_incr (&mcnt, &p);	  printf ("/jump to %d", p + mcnt - start);	  break;	   case succeed_n: 		extract_number_and_incr (&mcnt, &p);		extract_number_and_incr (&mcnt2, &p);	  printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);		break;	   	   case jump_n: 		extract_number_and_incr (&mcnt, &p);		extract_number_and_incr (&mcnt2, &p);	  printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);		break;	   	   case set_number_at: 		extract_number_and_incr (&mcnt, &p);		extract_number_and_incr (&mcnt2, &p);	  printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);		break;	   	   case wordbound:	  printf ("/wordbound");	  break;	case notwordbound:	  printf ("/notwordbound");		break;	case wordbeg:	  printf ("/wordbeg");	  break;			case wordend:	  printf ("/wordend");		#ifdef emacs	case before_dot:	  printf ("/before_dot");		break;	case at_dot:	  printf ("/at_dot");		break;	case after_dot:	  printf ("/after_dot");		break;	case syntaxspec:		printf ("/syntaxspec");	  mcnt = *p++;	  printf ("/%d", mcnt);		break;	  	case notsyntaxspec:		printf ("/notsyntaxspec");	  mcnt = *p++;	  printf ("/%d", mcnt);	  break;#endif /* emacs */	case wordchar:	  printf ("/wordchar");		break;	  	case notwordchar:	  printf ("/notwordchar");		break;	case begbuf:	  printf ("/begbuf");		break;	case endbuf:	  printf ("/endbuf");		break;	   default:		printf ("?%d", *(p-1));	}	 putchar ('\n');    }  printf ("%d:\tend of pattern.\n", p - start);}voidprint_compiled_pattern (bufp)    struct re_pattern_buffer *bufp;{  unsigned char *buffer = bufp->buffer;  print_partial_compiled_pattern (buffer, buffer + bufp->used);  printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated);  if (bufp->fastmap_accurate && bufp->fastmap)    {	 printf ("fastmap: ");	 print_fastmap (bufp->fastmap);    }  printf ("re_nsub: %d\t", bufp->re_nsub);  printf ("regs_alloc: %d\t", bufp->regs_allocated);  printf ("can_be_null: %d\t", bufp->can_be_null);  printf ("newline_anchor: %d\n", bufp->newline_anchor);  printf ("no_sub: %d\t", bufp->no_sub);  printf ("not_bol: %d\t", bufp->not_bol);  printf ("not_eol: %d\t", bufp->not_eol);  printf ("syntax: %d\n", bufp->syntax);  /* Perhaps we should print the translate table?  */}voidprint_double_string (where, string1, size1, string2, size2)    const char *where;    const char *string1;    const char *string2;    int size1;    int size2;{  unsigned this_char;    if (where == NULL)    printf ("(null)");  else    {	 if (FIRST_STRING_P (where))	   {		for (this_char = where - string1; this_char < size1; this_char++)		  putchar (string1[this_char]);		where = string2;    	   }	 for (this_char = where - string2; this_char < size2; this_char++)	   putchar (string2[this_char]);    }}#else /* not DEBUG */#undef assert#define assert(e)#define DEBUG_STATEMENT(e)#define DEBUG_PRINT1(x)#define DEBUG_PRINT2(x1, x2)#define DEBUG_PRINT3(x1, x2, x3)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -