亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tr.c

?? linux開發技術詳解一書的源碼
?? C
?? 第 1 頁 / 共 4 頁
字號:

  if (s2)
    {
      get_s2_spec_stats (s2, s1->length);

      if (s2->n_indefinite_repeats > 1)
	{
	  error (EXIT_FAILURE, 0,
		 _("only one [c*] repeat construct may appear in string2"));
	}

      if (translating)
	{
	  if (s2->has_equiv_class)
	    {
	      error (EXIT_FAILURE, 0,
		     _("[=c=] expressions may not appear in string2 \
when translating"));
	    }

	  if (s1->length > s2->length)
	    {
	      if (!truncate_set1)
		{
		  /* string2 must be non-empty unless --truncate-set1 is
		     given or string1 is empty.  */

		  if (s2->length == 0)
		    error (EXIT_FAILURE, 0,
		     _("when not truncating set1, string2 must be non-empty"));
		  string2_extend (s1, s2);
		}
	    }

	  if (complement && s1->has_char_class
	      && ! (s2->length == s1->length && homogeneous_spec_list (s2)))
	    {
	      error (EXIT_FAILURE, 0,
		     _("when translating with complemented character classes,\
\nstring2 must map all characters in the domain to one"));
	    }

	  if (s2->has_restricted_char_class)
	    {
	      error (EXIT_FAILURE, 0,
		     _("when translating, the only character classes that may \
appear in\nstring2 are `upper' and `lower'"));
	    }
	}
      else
	/* Not translating.  */
	{
	  if (s2->n_indefinite_repeats > 0)
	    error (EXIT_FAILURE, 0,
		   _("the [c*] construct may appear in string2 only \
when translating"));
	}
    }
}

/* Read buffers of SIZE bytes via the function READER (if READER is
   NULL, read from stdin) until EOF.  When non-NULL, READER is either
   read_and_delete or read_and_xlate.  After each buffer is read, it is
   processed and written to stdout.  The buffers are processed so that
   multiple consecutive occurrences of the same character in the input
   stream are replaced by a single occurrence of that character if the
   character is in the squeeze set.  */

static void
squeeze_filter (unsigned char *buf, size_t size, Filter reader)
{
  unsigned int char_to_squeeze = NOT_A_CHAR;
  size_t i = 0;
  size_t nr = 0;

  for (;;)
    {
      size_t begin;

      if (i >= nr)
	{
	  if (reader == NULL)
	    {
	      nr = safe_read (0, (char *) buf, size);
	      if (nr == SAFE_READ_ERROR)
		error (EXIT_FAILURE, errno, _("read error"));
	    }
	  else
	    {
	      nr = (*reader) (buf, size, NULL);
	    }

	  if (nr == 0)
	    break;
	  i = 0;
	}

      begin = i;

      if (char_to_squeeze == NOT_A_CHAR)
	{
	  size_t out_len;
	  /* Here, by being a little tricky, we can get a significant
	     performance increase in most cases when the input is
	     reasonably large.  Since tr will modify the input only
	     if two consecutive (and identical) input characters are
	     in the squeeze set, we can step by two through the data
	     when searching for a character in the squeeze set.  This
	     means there may be a little more work in a few cases and
	     perhaps twice as much work in the worst cases where most
	     of the input is removed by squeezing repeats.  But most
	     uses of this functionality seem to remove less than 20-30%
	     of the input.  */
	  for (; i < nr && !in_squeeze_set[buf[i]]; i += 2)
	    ;			/* empty */

	  /* There is a special case when i == nr and we've just
	     skipped a character (the last one in buf) that is in
	     the squeeze set.  */
	  if (i == nr && in_squeeze_set[buf[i - 1]])
	    --i;

	  if (i >= nr)
	    out_len = nr - begin;
	  else
	    {
	      char_to_squeeze = buf[i];
	      /* We're about to output buf[begin..i].  */
	      out_len = i - begin + 1;

	      /* But since we stepped by 2 in the loop above,
	         out_len may be one too large.  */
	      if (i > 0 && buf[i - 1] == char_to_squeeze)
		--out_len;

	      /* Advance i to the index of first character to be
	         considered when looking for a char different from
	         char_to_squeeze.  */
	      ++i;
	    }
	  if (out_len > 0
	      && fwrite ((char *) &buf[begin], 1, out_len, stdout) == 0)
	    error (EXIT_FAILURE, errno, _("write error"));
	}

      if (char_to_squeeze != NOT_A_CHAR)
	{
	  /* Advance i to index of first char != char_to_squeeze
	     (or to nr if all the rest of the characters in this
	     buffer are the same as char_to_squeeze).  */
	  for (; i < nr && buf[i] == char_to_squeeze; i++)
	    ;			/* empty */
	  if (i < nr)
	    char_to_squeeze = NOT_A_CHAR;
	  /* If (i >= nr) we've squeezed the last character in this buffer.
	     So now we have to read a new buffer and continue comparing
	     characters against char_to_squeeze.  */
	}
    }
}

/* Read buffers of SIZE bytes from stdin until one is found that
   contains at least one character not in the delete set.  Store
   in the array BUF, all characters from that buffer that are not
   in the delete set, and return the number of characters saved
   or 0 upon EOF.  */

static size_t
read_and_delete (unsigned char *buf, size_t size, Filter not_used)
{
  size_t n_saved;
  static int hit_eof = 0;

  assert (not_used == NULL);

  if (hit_eof)
    return 0;

  /* This enclosing do-while loop is to make sure that
     we don't return zero (indicating EOF) when we've
     just deleted all the characters in a buffer.  */
  do
    {
      size_t i;
      size_t nr = safe_read (0, (char *) buf, size);

      if (nr == SAFE_READ_ERROR)
	error (EXIT_FAILURE, errno, _("read error"));
      if (nr == 0)
	{
	  hit_eof = 1;
	  return 0;
	}

      /* This first loop may be a waste of code, but gives much
         better performance when no characters are deleted in
         the beginning of a buffer.  It just avoids the copying
         of buf[i] into buf[n_saved] when it would be a NOP.  */

      for (i = 0; i < nr && !in_delete_set[buf[i]]; i++)
	/* empty */ ;
      n_saved = i;

      for (++i; i < nr; i++)
	if (!in_delete_set[buf[i]])
	  buf[n_saved++] = buf[i];
    }
  while (n_saved == 0);

  return n_saved;
}

/* Read at most SIZE bytes from stdin into the array BUF.  Then
   perform the in-place and one-to-one mapping specified by the global
   array `xlate'.  Return the number of characters read, or 0 upon EOF.  */

static size_t
read_and_xlate (unsigned char *buf, size_t size, Filter not_used)
{
  size_t bytes_read = 0;
  static int hit_eof = 0;
  size_t i;

  assert (not_used == NULL);

  if (hit_eof)
    return 0;

  bytes_read = safe_read (0, (char *) buf, size);
  if (bytes_read == SAFE_READ_ERROR)
    error (EXIT_FAILURE, errno, _("read error"));
  if (bytes_read == 0)
    {
      hit_eof = 1;
      return 0;
    }

  for (i = 0; i < bytes_read; i++)
    buf[i] = xlate[buf[i]];

  return bytes_read;
}

/* Initialize a boolean membership set IN_SET with the character
   values obtained by traversing the linked list of constructs S
   using the function `get_next'.  If COMPLEMENT_THIS_SET is
   nonzero the resulting set is complemented.  */

static void
set_initialize (struct Spec_list *s, int complement_this_set, SET_TYPE *in_set)
{
  int c;
  size_t i;

  memset (in_set, 0, N_CHARS * sizeof (in_set[0]));
  s->state = BEGIN_STATE;
  while ((c = get_next (s, NULL)) != -1)
    in_set[c] = 1;
  if (complement_this_set)
    for (i = 0; i < N_CHARS; i++)
      in_set[i] = (!in_set[i]);
}

int
main (int argc, char **argv)
{
  int c;
  int non_option_args;
  struct Spec_list buf1, buf2;
  struct Spec_list *s1 = &buf1;
  struct Spec_list *s2 = &buf2;

  program_name = argv[0];
  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  atexit (close_stdout);

  while ((c = getopt_long (argc, argv, "cdst", long_options, NULL)) != -1)
    {
      switch (c)
	{
	case 0:
	  break;

	case 'c':
	  complement = 1;
	  break;

	case 'd':
	  delete = 1;
	  break;

	case 's':
	  squeeze_repeats = 1;
	  break;

	case 't':
	  truncate_set1 = 1;
	  break;

	case_GETOPT_HELP_CHAR;

	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);

	default:
	  usage (2);
	  break;
	}
    }

  posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL);

  non_option_args = argc - optind;
  translating = (non_option_args == 2 && !delete);

  /* Change this test if it is valid to give tr no options and
     no args at all.  POSIX doesn't specifically say anything
     either way, but it looks like they implied it's invalid
     by omission.  If you want to make tr do a slow imitation
     of `cat' use `tr a a'.  */
  if (non_option_args > 2)
    {
      error (0, 0, _("too many arguments"));
      usage (2);
    }

  if (!delete && !squeeze_repeats && non_option_args != 2)
    error (EXIT_FAILURE, 0, _("two strings must be given when translating"));

  if (delete && squeeze_repeats && non_option_args != 2)
    error (EXIT_FAILURE, 0, _("two strings must be given when both \
deleting and squeezing repeats"));

  /* If --delete is given without --squeeze-repeats, then
     only one string argument may be specified.  But POSIX
     says to ignore any string2 in this case, so if POSIXLY_CORRECT
     is set, pretend we never saw string2.  But I think
     this deserves a fatal error, so that's the default.  */
  if ((delete && !squeeze_repeats) && non_option_args != 1)
    {
      if (posix_pedantic && non_option_args == 2)
	--non_option_args;
      else
	error (EXIT_FAILURE, 0,
	       _("only one string may be given when deleting \
without squeezing repeats"));
    }

  if (squeeze_repeats && non_option_args == 0)
    error (EXIT_FAILURE, 0,
	   _("at least one string must be given when squeezing repeats"));

  spec_init (s1);
  if (parse_str ((unsigned char *) argv[optind], s1))
    exit (EXIT_FAILURE);

  if (non_option_args == 2)
    {
      spec_init (s2);
      if (parse_str ((unsigned char *) argv[optind + 1], s2))
	exit (EXIT_FAILURE);
    }
  else
    s2 = NULL;

  validate (s1, s2);

  /* Use binary I/O, since `tr' is sometimes used to transliterate
     non-printable characters, or characters which are stripped away
     by text-mode reads (like CR and ^Z).  */
  SET_BINARY2 (STDIN_FILENO, STDOUT_FILENO);

  if (squeeze_repeats && non_option_args == 1)
    {
      set_initialize (s1, complement, in_squeeze_set);
      squeeze_filter (io_buf, IO_BUF_SIZE, NULL);
    }
  else if (delete && non_option_args == 1)
    {
      size_t nr;

      set_initialize (s1, complement, in_delete_set);
      do
	{
	  nr = read_and_delete (io_buf, IO_BUF_SIZE, NULL);
	  if (nr > 0 && fwrite ((char *) io_buf, 1, nr, stdout) == 0)
	    error (EXIT_FAILURE, errno, _("write error"));
	}
      while (nr > 0);
    }
  else if (squeeze_repeats && delete && non_option_args == 2)
    {
      set_initialize (s1, complement, in_delete_set);
      set_initialize (s2, 0, in_squeeze_set);
      squeeze_filter (io_buf, IO_BUF_SIZE, read_and_delete);
    }
  else if (translating)
    {
      if (complement)
	{
	  int i;
	  SET_TYPE *in_s1 = in_delete_set;

	  set_initialize (s1, 0, in_s1);
	  s2->state = BEGIN_STATE;
	  for (i = 0; i < N_CHARS; i++)
	    xlate[i] = i;
	  for (i = 0; i < N_CHARS; i++)
	    {
	      if (!in_s1[i])
		{
		  int ch = get_next (s2, NULL);
		  assert (ch != -1 || truncate_set1);
		  if (ch == -1)
		    {
		      /* This will happen when tr is invoked like e.g.
		         tr -cs A-Za-z0-9 '\012'.  */
		      break;
		    }
		  xlate[i] = ch;
		}
	    }
	  assert (get_next (s2, NULL) == -1 || truncate_set1);
	}
      else
	{
	  int c1, c2;
	  int i;
	  enum Upper_Lower_class class_s1;
	  enum Upper_Lower_class class_s2;

	  for (i = 0; i < N_CHARS; i++)
	    xlate[i] = i;
	  s1->state = BEGIN_STATE;
	  s2->state = BEGIN_STATE;
	  for (;;)
	    {
	      c1 = get_next (s1, &class_s1);
	      c2 = get_next (s2, &class_s2);
	      if (!class_ok[(int) class_s1][(int) class_s2])
		error (EXIT_FAILURE, 0,
		       _("misaligned [:upper:] and/or [:lower:] construct"));

	      if (class_s1 == UL_LOWER && class_s2 == UL_UPPER)
		{
		  for (i = 0; i < N_CHARS; i++)
		    if (ISLOWER (i))
		      xlate[i] = toupper (i);
		}
	      else if (class_s1 == UL_UPPER && class_s2 == UL_LOWER)
		{
		  for (i = 0; i < N_CHARS; i++)
		    if (ISUPPER (i))
		      xlate[i] = tolower (i);
		}
	      else if ((class_s1 == UL_LOWER && class_s2 == UL_LOWER)
		       || (class_s1 == UL_UPPER && class_s2 == UL_UPPER))
		{
		  /* By default, GNU tr permits the identity mappings: from
		     [:upper:] to [:upper:] and [:lower:] to [:lower:].  But
		     when POSIXLY_CORRECT is set, those evoke diagnostics.  */
		  if (posix_pedantic)
		    {
		      error (EXIT_FAILURE, 0,
			     _("\
invalid identity mapping;  when translating, any [:lower:] or [:upper:]\n\
construct in string1 must be aligned with a corresponding construct\n\
([:upper:] or [:lower:], respectively) in string2"));
		    }
		}
	      else
		{
		  /* The following should have been checked by validate...  */
		  if (c1 == -1 || c2 == -1)
		    break;
		  xlate[c1] = c2;
		}
	    }
	  assert (c1 == -1 || truncate_set1);
	}
      if (squeeze_repeats)
	{
	  set_initialize (s2, 0, in_squeeze_set);
	  squeeze_filter (io_buf, IO_BUF_SIZE, read_and_xlate);
	}
      else
	{
	  size_t bytes_read;

	  do
	    {
	      bytes_read = read_and_xlate (io_buf, IO_BUF_SIZE, NULL);
	      if (bytes_read > 0
		  && fwrite ((char *) io_buf, 1, bytes_read, stdout) == 0)
		error (EXIT_FAILURE, errno, _("write error"));
	    }
	  while (bytes_read > 0);
	}
    }

  if (close (STDIN_FILENO) != 0)
    error (EXIT_FAILURE, errno, _("standard input"));

  exit (EXIT_SUCCESS);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产日韩精品一区| 91蜜桃在线免费视频| 依依成人精品视频| 日韩成人午夜电影| 韩国v欧美v亚洲v日本v| 国产成人精品影院| 色狠狠一区二区| 91精品国产一区二区| 久久久国产精华| 一区二区欧美视频| 国产一区二区三区不卡在线观看| 成人免费视频caoporn| 国产视频在线观看一区二区三区| 欧美国产激情二区三区| 午夜精品久久久久| av电影在线观看一区| 欧美日韩电影在线播放| 日韩欧美在线综合网| 亚洲国产精品国自产拍av| 91极品美女在线| 日本不卡免费在线视频| 91在线国内视频| 国产日韩欧美在线一区| 欧美少妇xxx| 日韩美女视频19| 99精品欧美一区二区蜜桃免费| 亚洲国产欧美一区二区三区丁香婷| 国产91色综合久久免费分享| 3d动漫精品啪啪| 性感美女久久精品| 色哟哟一区二区| 一区二区三区在线观看视频| 久久综合色鬼综合色| 国产精品一色哟哟哟| 亚洲欧洲精品天堂一级| 99精品视频在线观看免费| 亚洲最色的网站| 国产精品福利在线播放| 97国产一区二区| jvid福利写真一区二区三区| 国精产品一区一区三区mba视频| 亚洲香肠在线观看| 一区二区三区成人| 国产精品国产三级国产aⅴ入口 | 91久久精品一区二区三区| 国产激情一区二区三区| 国产伦精品一区二区三区免费 | 乱中年女人伦av一区二区| 欧美国产精品一区二区| 色综合咪咪久久| av在线播放成人| 99re热这里只有精品视频| 91网页版在线| 欧美日本国产视频| 在线观看日韩国产| 狠狠色丁香久久婷婷综| 精品一区二区免费在线观看| 亚洲午夜视频在线观看| 图片区小说区国产精品视频| 激情综合网天天干| thepron国产精品| 777a∨成人精品桃花网| 国产亚洲1区2区3区| 一区二区三区蜜桃| 日韩激情中文字幕| 亚洲电影视频在线| 亚洲成a人在线观看| 久久99精品国产麻豆不卡| 国产不卡在线一区| 欧美日产在线观看| 欧美韩日一区二区三区| 亚洲一本大道在线| 捆绑调教一区二区三区| www.爱久久.com| 欧美美女激情18p| www.日韩av| 久久综合丝袜日本网| 亚洲综合丁香婷婷六月香| 国产精品久久久久久久浪潮网站| 亚洲伊人色欲综合网| 成人av在线观| k8久久久一区二区三区| 日韩欧美国产电影| 欧美一区二区三区免费视频| 欧美成人精品3d动漫h| 欧美老年两性高潮| 亚洲欧美乱综合| 综合电影一区二区三区| 国产精品一区二区你懂的| 日韩一区二区免费高清| 婷婷国产在线综合| 欧洲激情一区二区| 亚洲成人资源网| 欧美喷潮久久久xxxxx| 亚洲自拍都市欧美小说| 欧美中文字幕一二三区视频| 韩国一区二区在线观看| 26uuu精品一区二区| 激情综合网天天干| 国产精品久久久久久久久免费桃花 | 亚洲日本在线视频观看| 成人综合在线视频| 中文字幕一区二区三区精华液| 成人国产免费视频| 亚洲精品亚洲人成人网 | 欧美日本乱大交xxxxx| 奇米一区二区三区| 中文字幕高清不卡| 在线观看www91| 在线观看91视频| 免费不卡在线观看| 欧美经典三级视频一区二区三区| 99精品视频免费在线观看| 亚洲自拍都市欧美小说| 久久久久久久久久电影| 99re这里只有精品首页| 日本欧美一区二区三区| 欧美精品一区二区高清在线观看| 亚洲女厕所小便bbb| 精品99久久久久久| 91免费版在线| 岛国精品一区二区| 午夜激情综合网| 中文字幕一区av| 久久久精品人体av艺术| 91精品综合久久久久久| 91伊人久久大香线蕉| 精品一区二区三区免费毛片爱| 亚洲狠狠丁香婷婷综合久久久| 欧美成人video| 欧美日韩在线播放一区| 理论片日本一区| 午夜精品在线看| 亚洲国产综合人成综合网站| 欧美激情中文不卡| 久久午夜老司机| 精品国产一二三| 精品av综合导航| 欧美大片一区二区| 欧美疯狂性受xxxxx喷水图片| 一本色道亚洲精品aⅴ| 成人av综合在线| 成人a级免费电影| 99精品视频中文字幕| 成人av网站在线观看免费| 成人高清在线视频| 成人小视频在线观看| 粉嫩绯色av一区二区在线观看| 国产精品一二三四| 91在线国产福利| 欧美日韩一级二级| 欧美一级黄色录像| 26uuu精品一区二区在线观看| 久久婷婷国产综合国色天香| 国产午夜精品福利| 一区二区三区电影在线播| 天堂在线一区二区| 国产老妇另类xxxxx| 播五月开心婷婷综合| 欧美性一级生活| 欧美—级在线免费片| 亚洲综合在线第一页| 美女视频一区二区三区| 一区二区三区资源| 蜜桃久久久久久| 成人自拍视频在线观看| 精品视频在线视频| 久久久久久久久久美女| 一区二区国产视频| 国产精品一区二区不卡| 7777精品伊人久久久大香线蕉| 亚洲国产精品v| 日韩黄色免费电影| 91美女片黄在线观看| 久久久夜色精品亚洲| 亚洲成人福利片| 成人午夜看片网址| 精品福利二区三区| 亚洲一区二区三区美女| 99精品国产99久久久久久白柏| 欧美精品一区二区三区在线播放| 亚洲一级在线观看| 日本黄色一区二区| 亚洲欧洲美洲综合色网| 国产91色综合久久免费分享| 精品久久久久久久人人人人传媒| 亚洲国产日韩一区二区| 色播五月激情综合网| 国产精品视频一区二区三区不卡| 国产精品久久久久久久久久久免费看| 精品影视av免费| 亚洲精品一区二区三区99| 美女网站色91| 精品粉嫩超白一线天av| 国产成人在线看| 国产精品青草久久| av在线播放不卡| 亚洲一区二区三区四区在线观看| 欧美视频中文字幕| 久久精品国产一区二区三|