PERFORCE change 179341 for review
Benjamin Fiedler
bfiedler at FreeBSD.org
Wed Jun 9 02:17:06 UTC 2010
http://p4web.freebsd.org/@@179341?ac=10
Change 179341 by bfiedler at freebsd-7803 on 2010/06/09 02:17:04
Added a few basic options (help, [no]ignore-file-name-case) and integer definitions. Changed makefile to use -g by default.
Affected files ...
.. //depot/projects/soc2010/bsdtextproc/diff/Makefile#2 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diff.c#2 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diff.h#2 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diffdir.c#2 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#2 edit
Differences ...
==== //depot/projects/soc2010/bsdtextproc/diff/Makefile#2 (text+ko) ====
@@ -1,8 +1,9 @@
# $FreeBSD$
# $OpenBSD: Makefile,v 1.2 2003/06/25 02:42:50 deraadt Exp $
+DEBUG = -g
PROG= diff
SRCS= diff.c diffdir.c diffreg.c
-CFLAGS+= -std=c99 -Wall -pedantic
+CFLAGS+= -std=c99 -Wall -pedantic $(DEBUG)
.include <bsd.prog.mk>
==== //depot/projects/soc2010/bsdtextproc/diff/diff.c#2 (text+ko) ====
@@ -44,7 +44,7 @@
#include "diff.h"
-int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
+int aflag, Bflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag;
int sflag, tflag, Tflag, wflag;
int format, context, status;
char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
@@ -52,11 +52,36 @@
struct excludes *excludes_list;
regex_t ignore_re;
+int flag_opts = 0;
+
#define OPTIONS "0123456789abC:cdD:efhI:iL:lnNPpqrS:sTtU:uvwX:x:"
+
+char ignore_file_case = 0;
+
+/* Options which exceed manageable alphanumeric assignments */
+enum
+{
+ OPT_IGN_FN_CASE = CHAR_MAX + 1,
+ OPT_NIGN_FN_CASE,
+ OPT_STRIPCR,
+ OPT_NORMAL,
+ OPT_LEFTC,
+ OT_SUPCL,
+ OPT_GTYPE,
+ OPT_LF,
+ OPT_LLF,
+ OPT_TSIZE,
+ OPT_UNINF,
+ OPT_FFILE,
+ OPT_TOFILE,
+ OPT_HLINES,
+ OPT_LFILES,
+ OPT_HELP,
+};
+
+
static struct option longopts[] = {
/* XXX: UNIMPLEMENTED
- { "ignore-file-name-case", no_argument, NULL, OPT_IGN_FN_CASE },
- { "no-ignore-file-name-case", no_argument, NULL, OPT_NIGN_FN_CASE },
{ "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR },
{ "normal", no_argument, NULL, OPT_NORMAL },
{ "left-column", no_argument, NULL, OPT_LEFTC },
@@ -69,11 +94,13 @@
{ "from-file", required_argument, NULL, OPT_FFILE },
{ "to-file", required_argument, NULL, OPT_TOFILE },
{ "horizon-lines", required_argument, NULL, OPT_HLINES },
- { "speed-large-files", no_argument, NULL, OPT_LFILES },
- { "help", no_argument, NULL, OPT_HELP }, */
+ { "speed-large-files", no_argument, NULL, OPT_LFILES }, */
+ { "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 },
{ "text", no_argument, NULL, 'a' },
-/* XXX: UNIMPLEMENTED
- { "ignore-blank-lines", no_argument, NULL, 'B' }, */
+/* XXX: UNIMPLEMENTED */
+ { "ignore-blank-lines", no_argument, NULL, 'B' },
{ "ignore-space-change", no_argument, NULL, 'b' },
/* XXX: -c is incompatible with GNU version */
{ "context", optional_argument, NULL, 'C' },
@@ -112,6 +139,15 @@
{ NULL, 0, NULL, '\0'}
};
+static const char* help_msg[] = {
+"-a --text treat files as ASCII text",
+"-B --ignore-blank-lines Ignore blank newlines in the comparison",
+"-b --ignore-space-change Ignore all changes due to whitespace",
+"-C NUM --context=[NUM] Show NUM lines before and after change (default 3)",
+"-D --ifdef=NAME",
+NULL };
+
+
void usage(void);
void push_excludes(char *);
void push_ignore_pats(char *);
@@ -149,6 +185,9 @@
case 'b':
bflag = 1;
break;
+ case 'B':
+ Bflag = 1;
+ break;
case 'C':
case 'c':
format = D_CONTEXT;
@@ -247,6 +286,13 @@
case 'x':
push_excludes(optarg);
break;
+ case OPT_IGN_FN_CASE:
+ ignore_file_case = 1;
+ break;
+ case OPT_NIGN_FN_CASE:
+ ignore_file_case = 0;
+ break;
+ case OPT_HELP:
default:
usage();
break;
==== //depot/projects/soc2010/bsdtextproc/diff/diff.h#2 (text+ko) ====
@@ -75,9 +75,10 @@
struct excludes *next;
};
-extern int aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
+extern int aflag, Bflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
sflag, tflag, Tflag, wflag;
extern int format, context, status;
+extern char ignore_file_case;
extern char *start, *ifdefname, *diffargs, *label[2], *ignore_pats;
extern struct stat stb1, stb2;
extern struct excludes *excludes_list;
==== //depot/projects/soc2010/bsdtextproc/diff/diffdir.c#2 (text+ko) ====
@@ -108,8 +108,9 @@
dent1 = *dp1;
dent2 = *dp2;
- pos = dent1 == NULL ? 1 : dent2 == NULL ? -1 :
- strcmp(dent1->d_name, dent2->d_name);
+ pos = dent1 == NULL ? 1 : dent2 == NULL ? -1 : ignore_file_case ?
+ strcasecmp(dent1->d_name, dent2->d_name) :
+ strcmp(dent1->d_name, dent2->d_name) ;
if (pos == 0) {
/* file exists in both dirs, diff it */
diffit(dent1, path1, dirlen1, path2, dirlen2);
==== //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#2 (text+ko) ====
@@ -483,9 +483,11 @@
if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != stb2.st_size ||
(stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT))
return (1);
+
for (;;) {
i = fread(buf1, 1, sizeof(buf1), f1);
j = fread(buf2, 1, sizeof(buf2), f2);
+
if (i != j)
return (1);
if (i == 0 && j == 0) {
More information about the p4-projects
mailing list