PERFORCE change 144769 for review
Gabor Kovesdan
gabor at FreeBSD.org
Sun Jul 6 10:00:00 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=144769
Change 144769 by gabor at gabor_server on 2008/07/06 09:59:55
- Add --unidirectional-new-file
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/diff/diff.1#3 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diff.c#10 edit
.. //depot/projects/soc2008/gabor_textproc/diff/diff.h#5 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/diff/diff.1#3 (text+ko) ====
@@ -30,7 +30,7 @@
.\"
.\" @(#)diff.1 8.1 (Berkeley) 6/30/93
.\"
-.Dd Jul 4, 2008
+.Dd Jul 6, 2008
.Dt DIFF 1
.Os
.Sh NAME
@@ -281,6 +281,8 @@
The
.Ar file
argument can be a directory.
+.It Fl Fl unidirectional-new-file
+Treat the first file as empty and generate a diff accordingly.
.It Fl w , Fl Fl ignore-all-space
Is similar to
.Fl b
==== //depot/projects/soc2008/gabor_textproc/diff/diff.c#10 (text+ko) ====
@@ -45,7 +45,7 @@
#include "diff.h"
int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
-int sflag, tflag, Tflag, wflag;
+int sflag, tflag, Tflag, wflag, uniflag;
int format, status;
int fcase_behave = FCASE_SENSITIVE;
unsigned long long context;
@@ -60,7 +60,8 @@
FCASE_SENSITIVE_OPT,
FCASE_IGNORE_OPT,
FROMFILE_OPT,
- TOFILE_OPT
+ TOFILE_OPT,
+ UNIDIR_OPT
};
#define OPTIONS "0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwX:x:"
@@ -76,8 +77,8 @@
{ "GTYPE-group-format", required_argument, NULL, OPT_GTYPE },
{ "line-format", required_argument, NULL, OPT_LF },
{ "LTYPE-line-format", required_argument, NULL, OPT_LLF },
- { "tabsize", optional_argument, NULL, OPT_TSIZE },
- { "unidirectional-new-file", no_argument, NULL, OPT_UNINF }, */
+ { "tabsize", optional_argument, NULL, OPT_TSIZE }, */
+ { "unidirectional-new-file", no_argument, NULL, UNIDIR_OPT },
{ "from-file", required_argument, NULL, FROMFILE_OPT },
{ "to-file", required_argument, NULL, TOFILE_OPT },
/* XXX: UNIMPLEMENTED
@@ -133,7 +134,7 @@
main(int argc, char **argv)
{
char *ep, *fromfile = NULL, *tofile = NULL, **oargv;
- int ch, lastch, gotstdin, prevoptind, newarg;
+ int ch, lastch, gotstdin, prevoptind, newarg, flags = 0;
char *dst, *src;
oargv = argv;
@@ -261,6 +262,9 @@
err(2, "--from-file and --to-file are both specified");
asprintf(&fromfile, "%s", optarg);
break;
+ case UNIDIR_OPT:
+ uniflag = 1;
+ break;
case TOFILE_OPT:
if (fromfile != NULL)
err(2, "--from-file and --to-file are both specified");
@@ -326,8 +330,12 @@
if (strcmp(src, "-") == 0) {
fstat(STDIN_FILENO, &stb1);
gotstdin = 1;
- } else if (stat(src, &stb1) != 0)
- err(2, "%s", src);
+ } else if (stat(src, &stb1) != 0) {
+ if (uniflag)
+ flags |= D_EMPTY1;
+ else
+ err(2, "%s", src);
+ }
if (strcmp(dst, "-") == 0) {
fstat(STDIN_FILENO, &stb2);
gotstdin = 1;
@@ -352,7 +360,7 @@
if (stat(argv[1], &stb2) < 0)
err(2, "%s", argv[1]);
}
- print_status(diffreg(src, dst, 0), src, dst,
+ print_status(diffreg(src, dst, flags), src, dst,
NULL);
if (fromfile != NULL)
dst = argv[ch];
==== //depot/projects/soc2008/gabor_textproc/diff/diff.h#5 (text+ko) ====
@@ -83,7 +83,7 @@
};
extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
- sflag, tflag, Tflag, wflag;
+ sflag, tflag, Tflag, wflag, uniflag;
extern int format, status;
extern int fcase_behave;
extern unsigned long long context;
More information about the p4-projects
mailing list