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

📄 regex.c

📁 制作2.6内核的CLFS时 使用的diffutils-2.8.7.tar.gz包
💻 C
📖 第 1 页 / 共 5 页
字号:
		printf("[.");		while(*p != 0)		  PUT_CHAR((i++,*p++));		i++,p++;		printf(".]");	      }	    length = *workp++; /* the length of equivalence_class */	    for (i=0 ; i<length ;)	      {		printf("[=");		while(*p != 0)		  PUT_CHAR((i++,*p++));		i++,p++;		printf("=]");	      }	    length = *workp++; /* the length of char_range */	    for (i=0 ; i<length ; i++)	      {		wchar_t range_start = *p++;		wchar_t range_end = *p++;		printf("%C-%C", range_start, range_end);	      }	    length = *workp++; /* the length of char */	    for (i=0 ; i<length ; i++)	      printf("%C", *p++);	    putchar (']');#  else            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;#  endif /* WCHAR */	  }	  break;	case begline:	  printf ("/begline");          break;	case endline:          printf ("/endline");          break;	case on_failure_jump:          PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/on_failure_jump to %td", p + mcnt - start);#  else  	  printf ("/on_failure_jump to %ld", (long int) (p + mcnt - start));#  endif          break;	case on_failure_keep_string_jump:          PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/on_failure_keep_string_jump to %td", p + mcnt - start);#  else  	  printf ("/on_failure_keep_string_jump to %ld",		  (long int) (p + mcnt - start));#  endif          break;	case dummy_failure_jump:          PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/dummy_failure_jump to %td", p + mcnt - start);#  else  	  printf ("/dummy_failure_jump to %ld", (long int) (p + mcnt - start));#  endif          break;	case push_dummy_failure:          printf ("/push_dummy_failure");          break;        case maybe_pop_jump:          PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/maybe_pop_jump to %td", p + mcnt - start);#  else  	  printf ("/maybe_pop_jump to %ld", (long int) (p + mcnt - start));#  endif	  break;        case pop_failure_jump:	  PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/pop_failure_jump to %td", p + mcnt - start);#  else  	  printf ("/pop_failure_jump to %ld", (long int) (p + mcnt - start));#  endif	  break;        case jump_past_alt:	  PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/jump_past_alt to %td", p + mcnt - start);#  else  	  printf ("/jump_past_alt to %ld", (long int) (p + mcnt - start));#  endif	  break;        case jump:	  PREFIX(extract_number_and_incr) (&mcnt, &p);#  ifdef _LIBC  	  printf ("/jump to %td", p + mcnt - start);#  else  	  printf ("/jump to %ld", (long int) (p + mcnt - start));#  endif	  break;        case succeed_n:          PREFIX(extract_number_and_incr) (&mcnt, &p);	  p1 = p + mcnt;          PREFIX(extract_number_and_incr) (&mcnt2, &p);#  ifdef _LIBC	  printf ("/succeed_n to %td, %d times", p1 - start, mcnt2);#  else	  printf ("/succeed_n to %ld, %d times",		  (long int) (p1 - start), mcnt2);#  endif          break;        case jump_n:          PREFIX(extract_number_and_incr) (&mcnt, &p);	  p1 = p + mcnt;          PREFIX(extract_number_and_incr) (&mcnt2, &p);	  printf ("/jump_n to %d, %d times", p1 - start, mcnt2);          break;        case set_number_at:          PREFIX(extract_number_and_incr) (&mcnt, &p);	  p1 = p + mcnt;          PREFIX(extract_number_and_incr) (&mcnt2, &p);#  ifdef _LIBC	  printf ("/set_number_at location %td to %d", p1 - start, mcnt2);#  else	  printf ("/set_number_at location %ld to %d",		  (long int) (p1 - start), mcnt2);#  endif          break;        case wordbound:	  printf ("/wordbound");	  break;	case notwordbound:	  printf ("/notwordbound");          break;	case wordbeg:	  printf ("/wordbeg");	  break;	case wordend:	  printf ("/wordend");	  break;#  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 ("?%ld", (long int) *(p-1));	}      putchar ('\n');    }#  ifdef _LIBC  printf ("%td:\tend of pattern.\n", p - start);#  else  printf ("%ld:\tend of pattern.\n", (long int) (p - start));#  endif}voidPREFIX(print_compiled_pattern) (struct re_pattern_buffer *bufp){  UCHAR_T *buffer = (UCHAR_T*) bufp->buffer;  PREFIX(print_partial_compiled_pattern) (buffer, buffer				  + bufp->used / sizeof(UCHAR_T));  printf ("%ld bytes used/%ld bytes allocated.\n",	  bufp->used, bufp->allocated);  if (bufp->fastmap_accurate && bufp->fastmap)    {      printf ("fastmap: ");      print_fastmap (bufp->fastmap);    }#  ifdef _LIBC  printf ("re_nsub: %Zd\t", bufp->re_nsub);#  else  printf ("re_nsub: %ld\t", (long int) bufp->re_nsub);#  endif  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: %lx\n", bufp->syntax);  /* Perhaps we should print the translate table?  */}voidPREFIX(print_double_string) (const CHAR_T *where,			     const CHAR_T *string1,			     const CHAR_T *string2,			     int size1,			     int size2){  int this_char;  if (where == NULL)    printf ("(null)");  else    {      int cnt;      if (FIRST_STRING_P (where))        {          for (this_char = where - string1; this_char < size1; this_char++)	    PUT_CHAR (string1[this_char]);          where = string2;        }      cnt = 0;      for (this_char = where - string2; this_char < size2; this_char++)	{	  PUT_CHAR (string2[this_char]);	  if (++cnt > 100)	    {	      fputs ("...", stdout);	      break;	    }	}    }}#  ifndef DEFINED_ONCEvoidprintchar (c)     int c;{  putc (c, stderr);}#  endif# else /* not DEBUG */#  ifndef DEFINED_ONCE#   undef assert#   define assert(e)#   define DEBUG_STATEMENT(e)#   define DEBUG_PRINT1(x)#   define DEBUG_PRINT2(x1, x2)#   define DEBUG_PRINT3(x1, x2, x3)#   define DEBUG_PRINT4(x1, x2, x3, x4)#  endif /* not DEFINED_ONCE */#  define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)#  define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)# endif /* not DEBUG */# ifdef WCHAR/* This  convert a multibyte string to a wide character string.   And write their correspondances to offset_buffer(see below)   and write whether each wchar_t is binary data to is_binary.   This assume invalid multibyte sequences as binary data.   We assume offset_buffer and is_binary is already allocated   enough space.  */static size_tconvert_mbs_to_wcs (CHAR_T *dest,		    const unsigned char* src,		    /* The length of multibyte string.  */		    size_t len,		    /* Correspondences between src(char string) and		       dest(wchar_t string) for optimization.  E.g.:		       src  = "xxxyzz"		       dest = {'X', 'Y', 'Z'}			 (each "xxx", "y" and "zz" represent one			  multibyte character corresponding to 'X',			  'Y' and 'Z'.)		       offset_buffer = {0, 0+3("xxx"), 0+3+1("y"),					0+3+1+2("zz")}				     = {0, 3, 4, 6} */		    int *offset_buffer,		    char *is_binary){  wchar_t *pdest = dest;  const unsigned char *psrc = src;  size_t wc_count = 0;  mbstate_t mbs;  int i, consumed;  size_t mb_remain = len;  size_t mb_count = 0;  /* Initialize the conversion state.  */  memset (&mbs, 0, sizeof (mbstate_t));  offset_buffer[0] = 0;  for( ; mb_remain > 0 ; ++wc_count, ++pdest, mb_remain -= consumed,	 psrc += consumed)    {      consumed = mbrtowc (pdest, psrc, mb_remain, &mbs);      if (consumed <= 0)	/* failed to convert. maybe src contains binary data.	   So we consume 1 byte manualy.  */	{	  *pdest = *psrc;	  consumed = 1;	  is_binary[wc_count] = TRUE;	}      else	is_binary[wc_count] = FALSE;      /* In sjis encoding, we use yen sign as escape character in	 place of reverse solidus. So we convert 0x5c(yen sign in	 sjis) to not 0xa5(yen sign in UCS2) but 0x5c(reverse	 solidus in UCS2).  */      if (consumed == 1 && (int) *psrc == 0x5c && (int) *pdest == 0xa5)	*pdest = (wchar_t) *psrc;      offset_buffer[wc_count + 1] = mb_count += consumed;    }  /* Fill remain of the buffer with sentinel.  */  for (i = wc_count + 1 ; i <= len ; i++)    offset_buffer[i] = mb_count + 1;  return wc_count;}# endif /* WCHAR */

⌨️ 快捷键说明

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