From owner-p4-projects@FreeBSD.ORG Sun Jul 6 10:00:00 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0F9461065677; Sun, 6 Jul 2008 10:00:00 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6ED31065673 for ; Sun, 6 Jul 2008 09:59:59 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id AFFF88FC13 for ; Sun, 6 Jul 2008 09:59:59 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m669xxf1096249 for ; Sun, 6 Jul 2008 09:59:59 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m669xxRp096247 for perforce@freebsd.org; Sun, 6 Jul 2008 09:59:59 GMT (envelope-from gabor@freebsd.org) Date: Sun, 6 Jul 2008 09:59:59 GMT Message-Id: <200807060959.m669xxRp096247@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gabor@freebsd.org using -f From: Gabor Kovesdan To: Perforce Change Reviews Cc: Subject: PERFORCE change 144769 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Jul 2008 10:00:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=144769 Change 144769 by gabor@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;