From owner-p4-projects@FreeBSD.ORG Sun Aug 3 16:13:54 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 84ADE1065674; Sun, 3 Aug 2008 16:13:54 +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 49463106568F for ; Sun, 3 Aug 2008 16:13:54 +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 38AC48FC12 for ; Sun, 3 Aug 2008 16:13:54 +0000 (UTC) (envelope-from gabor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m73GDsi0047209 for ; Sun, 3 Aug 2008 16:13:54 GMT (envelope-from gabor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m73GDsq0047207 for perforce@freebsd.org; Sun, 3 Aug 2008 16:13:54 GMT (envelope-from gabor@freebsd.org) Date: Sun, 3 Aug 2008 16:13:54 GMT Message-Id: <200808031613.m73GDsq0047207@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 146535 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, 03 Aug 2008 16:13:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=146535 Change 146535 by gabor@gabor_server on 2008/08/03 16:13:49 - Add some work-in-progress code for --strip-trailing-cr Affected files ... .. //depot/projects/soc2008/gabor_textproc/diff/diff.c#17 edit .. //depot/projects/soc2008/gabor_textproc/diff/diff.h#6 edit .. //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#6 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/diff/diff.c#17 (text+ko) ==== @@ -46,7 +46,7 @@ #include "diff.h" int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag; -int sflag, tflag, Tflag, wflag, uniflag; +int sflag, tflag, Tflag, wflag, uniflag, strip_cr; int format, status; int fcase_behave = FCASE_SENSITIVE; unsigned long long context; @@ -63,6 +63,7 @@ FROMFILE_OPT, TOFILE_OPT, UNIDIR_OPT, + STRIPCR_OPT, NOOP_OPT }; @@ -70,8 +71,7 @@ static struct option longopts[] = { { "ignore-file-name-case", no_argument, NULL, FCASE_IGNORE_OPT }, { "no-ignore-file-name-case", no_argument, NULL, FCASE_SENSITIVE_OPT }, -/* XXX: UNIMPLEMENTED - { "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR }, */ + { "strip-trailing-cr", no_argument, NULL, STRIPCR_OPT }, { "normal", no_argument, NULL, NORMAL_OPT }, /* XXX: UNIMPLEMENTED { "tabsize", optional_argument, NULL, OPT_TSIZE }, */ @@ -284,9 +284,9 @@ case FCASE_IGNORE_OPT: fcase_behave = FCASE_IGNORE; break; - case 'F': - case 'y': - case 'W': + case STRIPCR_OPT: + strip_cr = 1; + break; case NOOP_OPT: /* noop, compatibility */ break; ==== //depot/projects/soc2008/gabor_textproc/diff/diff.h#6 (text+ko) ==== @@ -83,7 +83,7 @@ }; extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag, - sflag, tflag, Tflag, wflag, uniflag; + sflag, tflag, Tflag, wflag, uniflag, strip_cr; extern int format, status; extern int fcase_behave; extern unsigned long long context; ==== //depot/projects/soc2008/gabor_textproc/diff/diffreg.c#6 (text+ko) ==== @@ -779,8 +779,16 @@ (c == '\n' && d == EOF))) { break; } + if ((strip_cr) && + ((c == EOF && d == '\r') || + (c == '\r' && d == EOF))) + break; ctold++; ctnew++; + while ((strip_cr) && (c == '\r')) + c = getc(f1); + while ((strip_cr) && (d == '\r')) + d = getc(f2); if (bflag && isspace(c) && isspace(d)) { do { if (c == '\n') @@ -1228,6 +1236,8 @@ if (!bflag && !wflag) { if (iflag) for (i = 0; (t = getc(f)) != '\n'; i++) { + if (t == '\r' && strip_cr) + continue; if (t == EOF) { if (i == 0) return (0); @@ -1237,6 +1247,8 @@ } else for (i = 0; (t = getc(f)) != '\n'; i++) { + if (t == '\r' && strip_cr) + continue; if (t == EOF) { if (i == 0) return (0); @@ -1276,6 +1288,7 @@ * There is a remote possibility that we end up with a zero sum. * Zero is used as an EOF marker, so return 1 instead. */ + printf("HASH: %d\n", (sum == 0 ? 1 : sum)); return (sum == 0 ? 1 : sum); }