PERFORCE change 179379 for review
Benjamin Fiedler
bfiedler at FreeBSD.org
Thu Jun 10 06:01:36 UTC 2010
http://p4web.freebsd.org/@@179379?ac=10
Change 179379 by bfiedler at freebsd-home on 2010/06/10 06:01:16
Correct implementation for diff -y
Affected files ...
.. //depot/projects/soc2010/bsdtextproc/diff/diff.c#5 edit
Differences ...
==== //depot/projects/soc2010/bsdtextproc/diff/diff.c#5 (text+ko) ====
@@ -48,6 +48,8 @@
int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
int sflag, tflag, Tflag, wflag;
int Bflag, yflag;
+int strip_cr;
+char ignore_file_case = 0;
int format, context, status;
char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
struct stat stb1, stb2;
@@ -56,9 +58,8 @@
int flag_opts = 0;
-#define OPTIONS "0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwXy:x"
+#define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwXy:x"
-char ignore_file_case = 0;
/* Options which exceed manageable alphanumeric assignments */
enum
@@ -84,7 +85,6 @@
static struct option longopts[] = {
/* XXX: UNIMPLEMENTED
- { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR },
{ "normal", no_argument, NULL, OPT_NORMAL },
{ "left-column", no_argument, NULL, OPT_LEFTC },
{ "suppress-common-lines", no_argument, NULL, OT_SUPCL },
@@ -97,6 +97,7 @@
{ "to-file", required_argument, NULL, OPT_TOFILE },
{ "horizon-lines", required_argument, NULL, OPT_HLINES },
{ "speed-large-files", no_argument, NULL, OPT_LFILES }, */
+ { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR },
{ "help", no_argument, NULL, OPT_HELP },
{ "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE },
{ "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE },
@@ -150,12 +151,13 @@
};
char **help_strs = (char **)help_msg;
+void set_argstr(char **, char **);
+
void usage(void);
void push_excludes(char *);
void push_ignore_pats(char *);
void read_excludes_file(char *);
-void set_argstr(char **, char **);
int
main(int argc, char **argv)
@@ -163,7 +165,7 @@
char *ep, **oargv;
long l;
int ch, lastch, gotstdin, prevoptind, newarg;
- int oargc;
+ int oargc;
oargv = argv;
oargc = argc;
@@ -294,6 +296,10 @@
case 'y':
yflag = 1;
break;
+ case OPT_STRIPCR:
+ strip_cr=1;
+ /*push_ignore_pats("\r\n$");*/
+ break;
case OPT_IGN_FN_CASE:
ignore_file_case = 1;
break;
@@ -320,17 +326,15 @@
if(yflag) {
/* remove y flag from args and call sdiff */
-/*
for(argv=oargv; argv && strcmp(*argv, "-y") != 0; argv++);
- while(argv != oargv[oargc]){
- *argv=*(argv+1)
+ while(argv != &oargv[oargc]){
+ *argv=*(argv+1);
argv++;
}
+ oargv[0] = _PATH_SDIFF;
*argv= "\0";
-*/
- set_argstr(oargv, argv);
- char *sdiff_argv[] = { "sdiff", argv[-1], argv[0], NULL };
- execv(_PATH_SDIFF, sdiff_argv);
+
+ execv(_PATH_SDIFF, oargv);
_exit(127);
}
More information about the p4-projects
mailing list