Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Dec 2016 11:35:51 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r310948 - user/bapt/diff
Message-ID:  <201612311135.uBVBZpBX054741@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Sat Dec 31 11:35:51 2016
New Revision: 310948
URL: https://svnweb.freebsd.org/changeset/base/310948

Log:
  Implement diff --ignore-file-name-case
  
  Note that the --no-ignore-file-name-case is not planned to be implemented
  as this is the default and there is no configuration switch to change that
  default
  
  Obtained from:	soc2012

Modified:
  user/bapt/diff/diff.c
  user/bapt/diff/diff.h
  user/bapt/diff/diffdir.c

Modified: user/bapt/diff/diff.c
==============================================================================
--- user/bapt/diff/diff.c	Sat Dec 31 11:30:18 2016	(r310947)
+++ user/bapt/diff/diff.c	Sat Dec 31 11:35:51 2016	(r310948)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
 #include "xmalloc.h"
 
 int	 lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag;
-int	 diff_format, diff_context, status;
+int	 diff_format, diff_context, status, ignore_file_case;
 int	 tabsize = 8;
 char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
 struct stat stb1, stb2;
@@ -51,6 +51,7 @@ regex_t	 ignore_re;
 enum {
 	OPT_TSIZE = CHAR_MAX + 1,
 	OPT_STRIPCR,
+	OPT_IGN_FN_CASE,
 };
 
 static struct option longopts[] = {
@@ -79,6 +80,7 @@ static struct option longopts[] = {
 	{ "ignore-all-space",		no_argument,		0,	'w' },
 	{ "exclude",			required_argument,	0,	'x' },
 	{ "exclude-from",		required_argument,	0,	'X' },
+	{ "ignore-file-name-case",	no_argument,		NULL,	OPT_IGN_FN_CASE },
 	{ "strip-trailing-cr",		no_argument,		NULL,	OPT_STRIPCR },
 	{ "tabsize",			optional_argument,	NULL,	OPT_TSIZE },
 	{ NULL,				0,			0,	'\0'}
@@ -219,6 +221,9 @@ main(int argc, char **argv)
 		case 'x':
 			push_excludes(optarg);
 			break;
+		case OPT_IGN_FN_CASE:
+			ignore_file_case = 1;
+			break;
 		case OPT_TSIZE:
 			tabsize = (int) strtonum(optarg, 1, INT_MAX, &errstr);
 			if (errstr) {

Modified: user/bapt/diff/diff.h
==============================================================================
--- user/bapt/diff/diff.h	Sat Dec 31 11:30:18 2016	(r310947)
+++ user/bapt/diff/diff.h	Sat Dec 31 11:35:51 2016	(r310948)
@@ -84,7 +84,7 @@ struct excludes {
 };
 
 extern int	lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag;
-extern int	diff_format, diff_context, status;
+extern int	diff_format, diff_context, status, ignore_file_case;
 extern int	tabsize;
 extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;
 extern struct	stat stb1, stb2;

Modified: user/bapt/diff/diffdir.c
==============================================================================
--- user/bapt/diff/diffdir.c	Sat Dec 31 11:30:18 2016	(r310947)
+++ user/bapt/diff/diffdir.c	Sat Dec 31 11:35:51 2016	(r310948)
@@ -124,7 +124,8 @@ diffdir(char *p1, char *p2, int flags)
 		dent2 = dp2 != edp2 ? *dp2 : NULL;
 
 		pos = dent1 == NULL ? 1 : dent2 == NULL ? -1 :
-		    strcmp(dent1->d_name, dent2->d_name);
+		    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, flags);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612311135.uBVBZpBX054741>