1 /* $OpenBSD: sdiff.c,v 1.36 2015/12/29 19:04:46 gsoares Exp $ */
4 * Written by Raymond Lai <ray@cyth.net>.
11 #include <sys/param.h>
12 #include <sys/queue.h>
14 #include <sys/types.h>
34 #define DIFF_PATH "/usr/bin/diff"
38 * Each column must be at least one character wide, plus three
39 * characters between the columns (space, [<|>], space).
43 /* 3 kilobytes of chars */
46 /* A single diff line. */
48 STAILQ_ENTRY(diffline) diffentries;
54 static void astrcat(char **, const char *);
55 static void enqueue(char *, char, char *);
56 static char *mktmpcpy(const char *);
57 static int istextfile(FILE *);
58 static void binexec(char *, char *, char *) __dead2;
59 static void freediff(struct diffline *);
60 static void int_usage(void);
61 static int parsecmd(FILE *, FILE *, FILE *);
62 static void printa(FILE *, size_t);
63 static void printc(FILE *, size_t, FILE *, size_t);
64 static void printcol(const char *, size_t *, const size_t);
65 static void printd(FILE *, size_t);
66 static void println(const char *, const char, const char *);
67 static void processq(void);
68 static void prompt(const char *, const char *);
69 static void usage(void) __dead2;
70 static char *xfgets(FILE *);
72 static STAILQ_HEAD(, diffline) diffhead = STAILQ_HEAD_INITIALIZER(diffhead);
73 static size_t line_width; /* width of a line (two columns and divider) */
74 static size_t width; /* width of each column */
75 static size_t file1ln, file2ln; /* line number of file1 and file2 */
76 static int Iflag = 0; /* ignore sets matching regexp */
77 static int lflag; /* print only left column for identical lines */
78 static int sflag; /* skip identical lines */
79 FILE *outfp; /* file to save changes to */
80 const char *tmpdir; /* TMPDIR or /tmp */
83 HELP_OPT = CHAR_MAX + 1,
95 /* the following groupings must be in sequence */
103 /* end order-sensitive enums */
109 /* pid from the diff parent (if applicable) */
115 static struct option longopts[] = {
116 /* options only processed in sdiff */
117 { "left-column", no_argument, NULL, LEFTC_OPT },
118 { "suppress-common-lines", no_argument, NULL, 's' },
119 { "width", required_argument, NULL, 'w' },
121 { "output", required_argument, NULL, 'o' },
122 { "diff-program", required_argument, NULL, DIFFPROG_OPT },
124 { "pipe-fd", required_argument, NULL, PIPE_FD },
125 { "diff-pid", required_argument, NULL, DIFF_PID },
126 /* Options processed by diff. */
127 { "ignore-file-name-case", no_argument, NULL, FCASE_IGNORE_OPT },
128 { "no-ignore-file-name-case", no_argument, NULL, FCASE_SENSITIVE_OPT },
129 { "strip-trailing-cr", no_argument, NULL, STRIPCR_OPT },
130 { "tabsize", required_argument, NULL, TSIZE_OPT },
131 { "help", no_argument, NULL, HELP_OPT },
132 { "text", no_argument, NULL, 'a' },
133 { "ignore-blank-lines", no_argument, NULL, 'B' },
134 { "ignore-space-change", no_argument, NULL, 'b' },
135 { "minimal", no_argument, NULL, 'd' },
136 { "ignore-tab-expansion", no_argument, NULL, 'E' },
137 { "ignore-matching-lines", required_argument, NULL, 'I' },
138 { "ignore-case", no_argument, NULL, 'i' },
139 { "expand-tabs", no_argument, NULL, 't' },
140 { "speed-large-files", no_argument, NULL, 'H' },
141 { "ignore-all-space", no_argument, NULL, 'W' },
143 { NULL, 0, NULL, '\0'}
146 static const char *help_msg[] = {
147 "\nusage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1 file2\n",
148 "\t-l, --left-column, Only print the left column for identical lines.",
149 "\t-o OUTFILE, --output=OUTFILE, nteractively merge file1 and file2 into outfile.",
150 "\t-s, --suppress-common-lines, Skip identical lines.",
151 "\t-w WIDTH, --width=WIDTH, Print a maximum of WIDTH characters on each line.",
152 "\tOptions passed to diff(1) are:",
153 "\t\t-a, --text, Treat file1 and file2 as text files.",
154 "\t\t-b, --ignore-trailing-cr, Ignore trailing blank spaces.",
155 "\t\t-d, --minimal, Minimize diff size.",
156 "\t\t-I RE, --ignore-matching-lines=RE, Ignore changes whose line matches RE.",
157 "\t\t-i, --ignore-case, Do a case-insensitive comparison.",
158 "\t\t-t, --expand-tabs Expand tabs to spaces.",
159 "\t\t-W, --ignore-all-spaces, Ignore all spaces.",
160 "\t\t--speed-large-files, Assume large file with scattered changes.",
161 "\t\t--strip-trailing-cr, Strip trailing carriage return.",
162 "\t\t--ignore-file-name-case, Ignore case of file names.",
163 "\t\t--no-ignore-file-name-case, Do not ignore file name case",
164 "\t\t--tabsize NUM, Change size of tabs (default 8.)",
170 * Create temporary file if source_file is not a regular file.
171 * Returns temporary file name if one was malloced, NULL if unnecessary.
174 mktmpcpy(const char *source_file)
182 /* Open input and output. */
183 ifd = open(source_file, O_RDONLY, 0);
184 /* File was opened successfully. */
186 if (fstat(ifd, &sb) == -1)
187 err(2, "error getting file status from %s", source_file);
190 if (S_ISREG(sb.st_mode)) {
195 /* If ``-'' does not exist the user meant stdin. */
196 if (errno == ENOENT && strcmp(source_file, "-") == 0)
199 err(2, "error opening %s", source_file);
202 /* Not a regular file, so copy input into temporary file. */
203 if (asprintf(&target_file, "%s/sdiff.XXXXXXXXXX", tmpdir) == -1)
205 if ((ofd = mkstemp(target_file)) == -1) {
206 warn("error opening %s", target_file);
209 while ((rcount = read(ifd, buf, sizeof(buf))) != -1 &&
213 wcount = write(ofd, buf, (size_t)rcount);
214 if (-1 == wcount || rcount != wcount) {
215 warn("error writing to %s", target_file);
220 warn("error reading from %s", source_file);
227 return (target_file);
235 main(int argc, char **argv)
237 FILE *diffpipe=NULL, *file1, *file2;
238 size_t diffargc = 0, wflag = WIDTH;
239 int ch, fd[2] = {-1}, status;
240 pid_t pid=0; pid_t ppid =-1;
241 const char *outfile = NULL;
243 char **diffargv, *diffprog = DIFF_PATH, *filename1, *filename2,
244 *tmp1, *tmp2, *s1, *s2;
248 * Process diff flags.
251 * Allocate memory for diff arguments and NULL.
252 * Each flag has at most one argument, so doubling argc gives an
253 * upper limit of how many diff args can be passed. argv[0],
254 * file1, and file2 won't have arguments so doubling them will
255 * waste some memory; however we need an extra space for the
256 * NULL at the end, so it sort of works out.
258 if (!(diffargv = calloc(argc, sizeof(char **) * 2)))
261 /* Add first argument, the program name. */
262 diffargv[diffargc++] = diffprog;
264 /* create a dynamic string for merging single-switch options */
265 if ( asprintf(&diffargv[diffargc++], "-") < 0 )
268 while ((ch = getopt_long(argc, argv, "aBbdEHI:ilo:stWw:",
269 longopts, NULL)) != -1) {
273 /* only compatible --long-name-form with diff */
274 case FCASE_IGNORE_OPT:
275 case FCASE_SENSITIVE_OPT:
280 /* combine no-arg single switches */
290 for(popt = longopts; ch != popt->val && popt->name != NULL; popt++);
291 diffargv[1] = realloc(diffargv[1], sizeof(char) * strlen(diffargv[1]) + 2);
293 * In diff, the 'W' option is 'w' and the 'w' is 'W'.
296 sprintf(diffargv[1], "%sw", diffargv[1]);
298 sprintf(diffargv[1], "%s%c", diffargv[1], ch);
301 diffargv[0] = diffprog = optarg;
305 diffargv[diffargc++] = "-I";
306 diffargv[diffargc++] = optarg;
318 wflag = strtonum(optarg, WIDTH_MIN,
321 errx(2, "width is %s: %s", errstr, optarg);
324 ppid = strtonum(optarg, 0, INT_MAX, &errstr);
326 errx(2, "diff pid value is %s: %s", errstr, optarg);
329 for (i = 0; help_msg[i] != NULL; i++)
330 printf("%s\n", help_msg[i]);
339 /* no single switches were used */
340 if (strcmp(diffargv[1], "-") == 0 ) {
341 for ( i = 1; i < argc-1; i++) {
342 diffargv[i] = diffargv[i+1];
344 diffargv[diffargc-1] = NULL;
354 if (outfile && (outfp = fopen(outfile, "w")) == NULL)
355 err(2, "could not open: %s", optarg);
357 if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
364 * Create temporary files for diff and sdiff to share if file1
365 * or file2 are not regular files. This allows sdiff and diff
366 * to read the same inputs if one or both inputs are stdin.
368 * If any temporary files were created, their names would be
369 * saved in tmp1 or tmp2. tmp1 should never equal tmp2.
372 /* file1 and file2 are the same, so copy to same temp file. */
373 if (strcmp(filename1, filename2) == 0) {
374 if ((tmp1 = mktmpcpy(filename1)))
375 filename1 = filename2 = tmp1;
376 /* Copy file1 and file2 into separate temp files. */
378 if ((tmp1 = mktmpcpy(filename1)))
380 if ((tmp2 = mktmpcpy(filename2)))
384 diffargv[diffargc++] = filename1;
385 diffargv[diffargc++] = filename2;
386 /* Add NULL to end of array to indicate end of array. */
387 diffargv[diffargc++] = NULL;
389 /* Subtract column divider and divide by two. */
390 width = (wflag - 3) / 2;
391 /* Make sure line_width can fit in size_t. */
392 if (width > (SIZE_MAX - 3) / 2)
393 errx(2, "width is too large: %zu", width);
394 line_width = width * 2 + 3;
400 switch (pid = fork()) {
403 /* We don't read from the pipe. */
405 if (dup2(fd[1], STDOUT_FILENO) == -1)
406 err(2, "child could not duplicate descriptor");
407 /* Free unused descriptor. */
409 execvp(diffprog, diffargv);
410 err(2, "could not execute diff: %s", diffprog);
413 err(2, "could not fork");
418 /* We don't write to the pipe. */
421 /* Open pipe to diff command. */
422 if ((diffpipe = fdopen(fd[0], "r")) == NULL)
423 err(2, "could not open diff pipe");
425 if ((file1 = fopen(filename1, "r")) == NULL)
426 err(2, "could not open %s", filename1);
427 if ((file2 = fopen(filename2, "r")) == NULL)
428 err(2, "could not open %s", filename2);
429 if (!istextfile(file1) || !istextfile(file2)) {
430 /* Close open files and pipe, delete temps */
433 if (diffpipe != NULL)
437 warn("Error deleting %s.", tmp1);
440 warn("Error deleting %s.", tmp2);
443 binexec(diffprog, filename1, filename2);
445 /* Line numbers start at one. */
446 file1ln = file2ln = 1;
448 /* Read and parse diff output. */
449 while (parsecmd(diffpipe, file1, file2) != EOF)
453 /* Wait for diff to exit. */
454 if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status) ||
455 WEXITSTATUS(status) >= 2)
456 err(2, "diff exited abnormally.");
458 /* Delete and free unneeded temporary files. */
461 warn("Error deleting %s.", tmp1);
464 warn("Error deleting %s.", tmp2);
467 filename1 = filename2 = tmp1 = tmp2 = NULL;
469 /* No more diffs, so print common lines. */
471 while ((s1 = xfgets(file1)))
472 enqueue(s1, ' ', NULL);
478 enqueue(s1, ' ', s2);
484 /* Process unmodified lines. */
487 /* Return diff exit status. */
488 return (WEXITSTATUS(status));
492 * When sdiff/zsdiff detects a binary file as input, executes them with
493 * diff/zdiff to maintain the same behavior as GNU sdiff with binary input.
496 binexec(char *diffprog, char *f1, char *f2)
499 char *args[] = {diffprog, f1, f2, (char *) 0};
500 execv(diffprog, args);
502 /* If execv() fails, sdiff's execution will continue below. */
503 errx(1, "Could not execute diff process.\n");
507 * Checks whether a file appears to be a text file.
517 for (i = 0; i <= MAX_CHECK; i++) {
531 * Prints an individual column (left or right), taking into account
532 * that tabs are variable-width. Takes a string, the current column
533 * the cursor is on the screen, and the maximum value of the column.
534 * The column value is updated as we go along.
537 printcol(const char *s, size_t *col, const size_t col_max)
540 for (; *s && *col < col_max; ++s) {
546 * If rounding to next multiple of eight causes
547 * an integer overflow, just return.
549 if (*col > SIZE_MAX - 8)
552 /* Round to next multiple of eight. */
553 new_col = (*col / 8 + 1) * 8;
556 * If printing the tab goes past the column
557 * width, don't print it and just quit.
559 if (new_col > col_max)
571 * Prompts user to either choose between two strings or edit one, both,
575 prompt(const char *s1, const char *s2)
579 /* Print command prompt. */
582 /* Get user input. */
583 for (; (cmd = xfgets(stdin)); free(cmd)) {
586 /* Skip leading whitespace. */
587 for (p = cmd; isspace(*p); ++p)
593 if (eparse(p, s1, s2) == -1)
598 /* Choose left column as-is. */
600 fprintf(outfp, "%s\n", s1);
601 /* End of command parsing. */
607 /* Choose right column as-is. */
609 fprintf(outfp, "%s\n", s2);
610 /* End of command parsing. */
619 /* Interactive usage help. */
625 /* Prompt user again. */
633 * If there was no error, we received an EOF from stdin, so we
642 * Takes two strings, separated by a column divider. NULL strings are
643 * treated as empty columns. If the divider is the ` ' character, the
644 * second column is not printed (-l flag). In this case, the second
645 * string must be NULL. When the second column is NULL, the divider
646 * does not print the trailing space following the divider character.
648 * Takes into account that tabs can take multiple columns.
651 println(const char *s1, const char div, const char *s2)
655 /* Print first column. Skips if s1 == NULL. */
658 /* Skip angle bracket and space. */
659 printcol(s1, &col, width);
663 /* Otherwise, we pad this column up to width. */
664 for (; col < width; ++col)
667 /* Only print left column. */
668 if (div == ' ' && !s2) {
674 * Print column divider. If there is no second column, we don't
675 * need to add the space for padding.
678 printf(" %c\n", div);
684 /* Skip angle bracket and space. */
685 printcol(s2, &col, line_width);
691 * Reads a line from file and returns as a string. If EOF is reached,
692 * NULL is returned. The returned string must be freed afterwards.
705 if ((l = getline(&s, &linecap, file)) == -1) {
707 err(2, "error reading file");
718 * Parse ed commands from diffpipe and print lines from file1 (lines
719 * to change or delete) or file2 (lines to add or change).
723 parsecmd(FILE *diffpipe, FILE *file1, FILE *file2)
725 size_t file1start, file1end, file2start, file2end, n;
726 /* ed command line and pointer to characters in line */
731 /* Read ed command. */
732 if (!(line = xfgets(diffpipe)))
736 /* Go to character after line number. */
741 file1start = strtonum(line, 0, INT_MAX, &errstr);
743 errx(2, "file1 start is %s: %s", errstr, line);
745 /* A range is specified for file1. */
748 /* Go to character after file2end. */
753 file1end = strtonum(q, 0, INT_MAX, &errstr);
755 errx(2, "file1 end is %s: %s", errstr, line);
756 if (file1start > file1end)
757 errx(2, "invalid line range in file1: %s", line);
759 file1end = file1start;
762 /* Check that cmd is valid. */
763 if (!(cmd == 'a' || cmd == 'c' || cmd == 'd'))
764 errx(2, "ed command not recognized: %c: %s", cmd, line);
767 /* Go to character after line number. */
772 file2start = strtonum(q, 0, INT_MAX, &errstr);
774 errx(2, "file2 start is %s: %s", errstr, line);
777 * There should either be a comma signifying a second line
778 * number or the line should just end here.
780 if (c != ',' && c != '\0')
781 errx(2, "invalid line range in file2: %c: %s", c, line);
785 file2end = strtonum(p, 0, INT_MAX, &errstr);
787 errx(2, "file2 end is %s: %s", errstr, line);
788 if (file2start >= file2end)
789 errx(2, "invalid line range in file2: %s", line);
791 file2end = file2start;
793 /* Appends happen _after_ stated line. */
795 if (file1start != file1end)
796 errx(2, "append cannot have a file1 range: %s",
798 if (file1start == SIZE_MAX)
799 errx(2, "file1 line range too high: %s", line);
800 file1start = ++file1end;
803 * I'm not sure what the deal is with the line numbers for
806 else if (cmd == 'd') {
807 if (file2start != file2end)
808 errx(2, "delete cannot have a file2 range: %s",
810 if (file2start == SIZE_MAX)
811 errx(2, "file2 line range too high: %s", line);
812 file2start = ++file2end;
816 * Continue reading file1 and file2 until we reach line numbers
817 * specified by diff. Should only happen with -I flag.
819 for (; file1ln < file1start && file2ln < file2start;
820 ++file1ln, ++file2ln) {
823 if (!(s1 = xfgets(file1)))
824 errx(2, "file1 shorter than expected");
825 if (!(s2 = xfgets(file2)))
826 errx(2, "file2 shorter than expected");
828 /* If the -l flag was specified, print only left column. */
832 * XXX - If -l and -I are both specified, all
833 * unchanged or ignored lines are shown with a
834 * `(' divider. This matches GNU sdiff, but I
835 * believe it is a bug. Just check out:
836 * gsdiff -l -I '^$' samefile samefile.
839 enqueue(s1, '(', NULL);
841 enqueue(s1, ' ', NULL);
843 enqueue(s1, ' ', s2);
845 /* Ignore deleted lines. */
846 for (; file1ln < file1start; ++file1ln) {
849 if (!(s = xfgets(file1)))
850 errx(2, "file1 shorter than expected");
852 enqueue(s, '(', NULL);
854 /* Ignore added lines. */
855 for (; file2ln < file2start; ++file2ln) {
858 if (!(s = xfgets(file2)))
859 errx(2, "file2 shorter than expected");
861 /* If -l flag was given, don't print right column. */
865 enqueue(NULL, ')', s);
868 /* Process unmodified or skipped lines. */
873 printa(file2, file2end);
874 n = file2end - file2start + 1;
877 printc(file1, file1end, file2, file2end);
878 n = file1end - file1start + 1 + 1 + file2end - file2start + 1;
881 printd(file1, file1end);
882 n = file1end - file1start + 1;
885 errx(2, "invalid diff command: %c: %s", cmd, line);
889 /* Skip to next ed line. */
891 if (!(line = xfgets(diffpipe)))
892 errx(2, "diff ended early");
900 * Queues up a diff line.
903 enqueue(char *left, char div, char *right)
905 struct diffline *diffp;
907 if (!(diffp = malloc(sizeof(struct diffline))))
911 diffp->right = right;
912 STAILQ_INSERT_TAIL(&diffhead, diffp, diffentries);
916 * Free a diffline structure and its elements.
919 freediff(struct diffline *diffp)
928 * Append second string into first. Repeated appends to the same string
929 * are cached, making this an O(n) function, where n = strlen(append).
932 astrcat(char **s, const char *append)
934 /* Length of string in previous run. */
935 static size_t offset = 0;
938 * String from previous run. Compared to *s to see if we are
939 * dealing with the same string. If so, we can use offset.
941 static const char *oldstr = NULL;
945 * First string is NULL, so just copy append.
948 if (!(*s = strdup(append)))
951 /* Keep track of string. */
959 * *s is a string so concatenate.
962 /* Did we process the same string in the last run? */
964 * If this is a different string from the one we just processed
972 /* Size = strlen(*s) + \n + strlen(append) + '\0'. */
973 newsiz = offset + 1 + strlen(append) + 1;
975 /* Resize *s to fit new string. */
976 newstr = realloc(*s, newsiz);
981 /* *s + offset should be end of string. */
983 strlcpy(*s + offset, "\n", newsiz - offset);
984 strlcat(*s + offset, append, newsiz - offset);
986 /* New string length should be exactly newsiz - 1 characters. */
987 /* Store generated string's values. */
993 * Process diff set queue, printing, prompting, and saving each diff
994 * line stored in queue.
999 struct diffline *diffp;
1000 char divc, *left, *right;
1002 /* Don't process empty queue. */
1003 if (STAILQ_EMPTY(&diffhead))
1006 /* Remember the divider. */
1007 divc = STAILQ_FIRST(&diffhead)->div;
1012 * Go through set of diffs, concatenating each line in left or
1013 * right column into two long strings, `left' and `right'.
1015 STAILQ_FOREACH(diffp, &diffhead, diffentries) {
1017 * Print changed lines if -s was given,
1018 * print all lines if -s was not given.
1020 if (!sflag || diffp->div == '|' || diffp->div == '<' ||
1022 println(diffp->left, diffp->div, diffp->right);
1024 /* Append new lines to diff set. */
1026 astrcat(&left, diffp->left);
1028 astrcat(&right, diffp->right);
1031 /* Empty queue and free each diff line and its elements. */
1032 while (!STAILQ_EMPTY(&diffhead)) {
1033 diffp = STAILQ_FIRST(&diffhead);
1034 STAILQ_REMOVE_HEAD(&diffhead, diffentries);
1038 /* Write to outfp, prompting user if lines are different. */
1041 case ' ': case '(': case ')':
1042 fprintf(outfp, "%s\n", left);
1044 case '|': case '<': case '>':
1045 prompt(left, right);
1048 errx(2, "invalid divider: %c", divc);
1051 /* Free left and right. */
1057 * Print lines following an (a)ppend command.
1060 printa(FILE *file, size_t line2)
1064 for (; file2ln <= line2; ++file2ln) {
1065 if (!(line = xfgets(file)))
1066 errx(2, "append ended early");
1067 enqueue(NULL, '>', line);
1073 * Print lines following a (c)hange command, from file1ln to file1end
1074 * and from file2ln to file2end.
1077 printc(FILE *file1, size_t file1end, FILE *file2, size_t file2end)
1080 STAILQ_ENTRY(fileline) fileentries;
1083 STAILQ_HEAD(, fileline) delqhead = STAILQ_HEAD_INITIALIZER(delqhead);
1085 /* Read lines to be deleted. */
1086 for (; file1ln <= file1end; ++file1ln) {
1087 struct fileline *linep;
1090 /* Read lines from both. */
1091 if (!(line1 = xfgets(file1)))
1092 errx(2, "error reading file1 in delete in change");
1094 /* Add to delete queue. */
1095 if (!(linep = malloc(sizeof(struct fileline))))
1097 linep->line = line1;
1098 STAILQ_INSERT_TAIL(&delqhead, linep, fileentries);
1101 /* Process changed lines.. */
1102 for (; !STAILQ_EMPTY(&delqhead) && file2ln <= file2end;
1104 struct fileline *del;
1108 if (!(add = xfgets(file2)))
1109 errx(2, "error reading add in change");
1111 del = STAILQ_FIRST(&delqhead);
1112 enqueue(del->line, '|', add);
1113 STAILQ_REMOVE_HEAD(&delqhead, fileentries);
1115 * Free fileline structure but not its elements since
1116 * they are queued up.
1122 /* Process remaining lines to add. */
1123 for (; file2ln <= file2end; ++file2ln) {
1127 if (!(add = xfgets(file2)))
1128 errx(2, "error reading add in change");
1130 enqueue(NULL, '>', add);
1134 /* Process remaining lines to delete. */
1135 while (!STAILQ_EMPTY(&delqhead)) {
1136 struct fileline *filep;
1138 filep = STAILQ_FIRST(&delqhead);
1139 enqueue(filep->line, '<', NULL);
1140 STAILQ_REMOVE_HEAD(&delqhead, fileentries);
1147 * Print deleted lines from file, from file1ln to file1end.
1150 printd(FILE *file1, size_t file1end)
1154 /* Print out lines file1ln to line2. */
1155 for (; file1ln <= file1end; ++file1ln) {
1156 if (!(line1 = xfgets(file1)))
1157 errx(2, "file1 ended early in delete");
1158 enqueue(line1, '<', NULL);
1164 * Interactive mode usage.
1170 puts("e:\tedit blank diff\n"
1171 "eb:\tedit both diffs concatenated\n"
1172 "el:\tedit left diff\n"
1173 "er:\tedit right diff\n"
1174 "l | 1:\tchoose left diff\n"
1175 "r | 2:\tchoose right diff\n"
1176 "s:\tsilent mode--don't print identical lines\n"
1177 "v:\tverbose mode--print identical lines\n"
1186 "usage: sdiff [-abdilstW] [-I regexp] [-o outfile] [-w width] file1"