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

📄 diff.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
📖 第 1 页 / 共 3 页
字号:
	case 'H':	  /* Turn on heuristics that speed processing of large files	     with a small density of changes.  */	  heuristic = 1;	  break;	case 'i':	  /* Ignore changes in case.  */	  ignore_case_flag = 1;	  ignore_some_changes = 1;	  ignore_some_line_changes = 1;	  break;	case 'I':	  /* Ignore changes affecting only lines that match the	     specified regexp.  */	  add_regexp (&ignore_regexp_list, optarg);	  ignore_some_changes = 1;	  break;	case 'l':	  /* Pass the output through `pr' to paginate it.  */	  paginate_flag = 1;#if !defined(SIGCHLD) && defined(SIGCLD)#define SIGCHLD SIGCLD#endif#ifdef SIGCHLD	  /* Pagination requires forking and waiting, and	     System V fork+wait does not work if SIGCHLD is ignored.  */	  signal (SIGCHLD, SIG_DFL);#endif	  break;	case 'L':	  /* Specify file labels for `-c' output headers.  */	  if (!file_label[0])	    file_label[0] = optarg;	  else if (!file_label[1])	    file_label[1] = optarg;	  else	    fatal ("too many file label options");	  break;	case 'n':	  /* Output RCS-style diffs, like `-f' except that each command	     specifies the number of lines affected.  */	  specify_style (OUTPUT_RCS);	  break;	case 'N':	  /* When comparing directories, if a file appears only in one	     directory, treat it as present but empty in the other.  */	  entire_new_file_flag = 1;	  break;	case 'o':	  /* Output in the old tradition style.  */	  specify_style (OUTPUT_NORMAL);	  break;	case 'p':	  /* Make context-style output and show name of last C function.  */	  show_c_function = 1;	  add_regexp (&function_regexp_list, "^[_a-zA-Z$]");	  break;	case 'P':	  /* When comparing directories, if a file appears only in	     the second directory of the two,	     treat it as present but empty in the other.  */	  unidirectional_new_file_flag = 1;	  break;	case 'q':	  no_details_flag = 1;	  break;	case 'r':	  /* When comparing directories,	     recursively compare any subdirectories found.  */	  recursive = 1;	  break;	case 's':	  /* Print a message if the files are the same.  */	  print_file_same_flag = 1;	  break;	case 'S':	  /* When comparing directories, start with the specified	     file name.  This is used for resuming an aborted comparison.  */	  dir_start_file = optarg;	  break;	case 't':	  /* Expand tabs to spaces in the output so that it preserves	     the alignment of the input files.  */	  tab_expand_flag = 1;	  break;	case 'T':	  /* Use a tab in the output, rather than a space, before the	     text of an input line, so as to keep the proper alignment	     in the input line without changing the characters in it.  */	  tab_align_flag = 1;	  break;	case 'u':	  /* Output the context diff in unidiff format.  */	  specify_style (OUTPUT_UNIFIED);	  break;	case 'v':	  printf ("diff - GNU diffutils version %s\n", version_string);	  exit (0);	case 'w':	  /* Ignore horizontal white space when comparing lines.  */	  ignore_all_space_flag = 1;	  ignore_some_changes = 1;	  ignore_some_line_changes = 1;	  break;	case 'x':	  add_exclude (optarg);	  break;	case 'X':	  if (add_exclude_file (optarg) != 0)	    pfatal_with_name (optarg);	  break;	case 'y':	  /* Use side-by-side (sdiff-style) columnar output. */	  specify_style (OUTPUT_SDIFF);	  break;	case 'W':	  /* Set the line width for OUTPUT_SDIFF.  */	  if (ck_atoi (optarg, &width) || width <= 0)	    fatal ("column width must be a positive integer");	  break;	case 129:	  sdiff_left_only = 1;	  break;	case 130:	  sdiff_skip_common_lines = 1;	  break;	case 131:	  /* sdiff-style columns output. */	  specify_style (OUTPUT_SDIFF);	  sdiff_help_sdiff = 1;	  break;	case 132:	case 133:	case 134:	  specify_style (OUTPUT_IFDEF);	  if (specify_format (&line_format[c - 132], optarg) != 0)	    error ("conflicting line format", 0, 0);	  break;	case 135:	  specify_style (OUTPUT_IFDEF);	  {	    int i, err = 0;	    for (i = 0; i < sizeof (line_format) / sizeof (*line_format); i++)	      err |= specify_format (&line_format[i], optarg);	    if (err)	      error ("conflicting line format", 0, 0);	  }	  break;	case 136:	case 137:	case 138:	case 139:	  specify_style (OUTPUT_IFDEF);	  if (specify_format (&group_format[c - 136], optarg) != 0)	    error ("conflicting group format", 0, 0);	  break;	case 140:	  if (ck_atoi (optarg, &horizon_lines) || horizon_lines < 0)	    fatal ("horizon must be a nonnegative integer");	  break;	case 141:	  usage ();	  check_stdout ();	  exit (0);	case 142:	  /* Use binary I/O when reading and writing data.	     On Posix hosts, this has no effect.  */#if HAVE_SETMODE	  binary_I_O = 1;	  setmode (STDOUT_FILENO, O_BINARY);#endif	  break;	default:	  try_help (0);	}      prev = c;    }  if (argc - optind != 2)    try_help (argc - optind < 2 ? "missing operand" : "extra operand");  {    /*     *	We maximize first the half line width, and then the gutter width,     *	according to the following constraints:     *	1.  Two half lines plus a gutter must fit in a line.     *	2.  If the half line width is nonzero:     *	    a.  The gutter width is at least GUTTER_WIDTH_MINIMUM.     *	    b.  If tabs are not expanded to spaces,     *		a half line plus a gutter is an integral number of tabs,     *		so that tabs in the right column line up.     */    int t = tab_expand_flag ? 1 : TAB_WIDTH;    int off = (width + t + GUTTER_WIDTH_MINIMUM) / (2*t)  *  t;    sdiff_half_width = max (0, min (off - GUTTER_WIDTH_MINIMUM, width - off)),    sdiff_column2_offset = sdiff_half_width ? off : width;  }  if (show_c_function && output_style != OUTPUT_UNIFIED)    specify_style (OUTPUT_CONTEXT);  if (output_style != OUTPUT_CONTEXT && output_style != OUTPUT_UNIFIED)    context = 0;  else if (context == -1)    /* Default amount of context for -c.  */    context = 3;  if (output_style == OUTPUT_IFDEF)    {      /* Format arrays are char *, not char const *,	 because integer formats are temporarily modified.	 But it is safe to assign a constant like "%=" to a format array,	 since "%=" does not format any integers.  */      int i;      for (i = 0; i < sizeof (line_format) / sizeof (*line_format); i++)	if (!line_format[i])	  line_format[i] = "%l\n";      if (!group_format[OLD])	group_format[OLD]	  = group_format[UNCHANGED] ? group_format[UNCHANGED] : "%<";      if (!group_format[NEW])	group_format[NEW]	  = group_format[UNCHANGED] ? group_format[UNCHANGED] : "%>";      if (!group_format[UNCHANGED])	group_format[UNCHANGED] = "%=";      if (!group_format[CHANGED])	group_format[CHANGED] = concat (group_format[OLD],					group_format[NEW], "");    }  no_diff_means_no_output =    (output_style == OUTPUT_IFDEF ?      (!*group_format[UNCHANGED]       || (strcmp (group_format[UNCHANGED], "%=") == 0	   && !*line_format[UNCHANGED]))     : output_style == OUTPUT_SDIFF ? sdiff_skip_common_lines : 1);  switch_string = option_list (argv + 1, optind - 1);  val = compare_files (0, argv[optind], 0, argv[optind + 1], 0);  /* Print any messages that were saved up for last.  */  print_message_queue ();  check_stdout ();  exit (val);  return val;}/* Add the compiled form of regexp PATTERN to REGLIST.  */static voidadd_regexp (reglist, pattern)     struct regexp_list **reglist;     char const *pattern;{  struct regexp_list *r;  char const *m;  r = (struct regexp_list *) xmalloc (sizeof (*r));  bzero (r, sizeof (*r));  r->buf.fastmap = xmalloc (256);  m = re_compile_pattern (pattern, strlen (pattern), &r->buf);  if (m != 0)    error ("%s: %s", pattern, m);  /* Add to the start of the list, since it's easier than the end.  */  r->next = *reglist;  *reglist = r;}static voidtry_help (reason)     char const *reason;{  if (reason)    error ("%s", reason, 0);  error ("Try `%s --help' for more information.", program_name, 0);  exit (2);}static voidcheck_stdout (){  if (ferror (stdout) || fclose (stdout) != 0)    fatal ("write error");}static char const * const option_help[] = {"-i  --ignore-case  Consider upper- and lower-case to be the same.","-w  --ignore-all-space  Ignore all white space.","-b  --ignore-space-change  Ignore changes in the amount of white space.","-B  --ignore-blank-lines  Ignore changes whose lines are all blank.","-I RE  --ignore-matching-lines=RE  Ignore changes whose lines all match RE.",#if HAVE_SETMODE"--binary  Read and write data in binary mode.",#endif"-a  --text  Treat all files as text.\n","-c  -C NUM  --context[=NUM]  Output NUM (default 2) lines of copied context.","-u  -U NUM  --unified[=NUM]  Output NUM (default 2) lines of unified context.","  -NUM  Use NUM context lines.","  -L LABEL  --label LABEL  Use LABEL instead of file name.","  -p  --show-c-function  Show which C function each change is in.","  -F RE  --show-function-line=RE  Show the most recent line matching RE.","-q  --brief  Output only whether files differ.","-e  --ed  Output an ed script.","-n  --rcs  Output an RCS format diff.","-y  --side-by-side  Output in two columns.","  -w NUM  --width=NUM  Output at most NUM (default 130) characters per line.","  --left-column  Output only the left column of common lines.","  --suppress-common-lines  Do not output common lines.","-DNAME  --ifdef=NAME  Output merged file to show `#ifdef NAME' diffs.","--GTYPE-group-format=GFMT  Similar, but format GTYPE input groups with GFMT.","--line-format=LFMT  Similar, but format all input lines with LFMT.","--LTYPE-line-format=LFMT  Similar, but format LTYPE input lines with LFMT.","  LTYPE is `old', `new', or `unchanged'.  GTYPE is LTYPE or `changed'.","  GFMT may contain:","    %<  lines from FILE1","    %>  lines from FILE2","    %=  lines common to FILE1 and FILE2","    %[-][WIDTH][.[PREC]]{doxX}LETTER  printf-style spec for LETTER","      LETTERs are as follows for new group, lower case for old group:","        F  first line number","        L  last line number","        N  number of lines = L-F+1","        E  F-1","        M  L+1","  LFMT may contain:","    %L  contents of line","    %l  contents of line, excluding any trailing newline","    %[-][WIDTH][.[PREC]]{doxX}n  printf-style spec for input line number","  Either GFMT or LFMT may contain:","    %%  %","    %c'C'  the single character C","    %c'\\OOO'  the character with octal code OOO\n","-l  --paginate  Pass the output through `pr' to paginate it.","-t  --expand-tabs  Expand tabs to spaces in output.","-T  --initial-tab  Make tabs line up by prepending a tab.\n","-r  --recursive  Recursively compare any subdirectories found.","-N  --new-file  Treat absent files as empty.","-P  --unidirectional-new-file  Treat absent first files as empty.",

⌨️ 快捷键说明

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