PERFORCE change 179612 for review

Benjamin Fiedler bfiedler at FreeBSD.org
Mon Jun 14 17:50:10 UTC 2010


http://p4web.freebsd.org/@@179612?ac=10

Change 179612 by bfiedler at freebsd-home on 2010/06/14 17:49:42

	Tweaking around with 'B' flag

Affected files ...

.. //depot/projects/soc2010/bsdtextproc/diff/diff.c#6 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diff.h#3 edit
.. //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#4 edit

Differences ...

==== //depot/projects/soc2010/bsdtextproc/diff/diff.c#6 (text+ko) ====

@@ -298,7 +298,6 @@
 			break;
 		case OPT_STRIPCR:
 			strip_cr=1;
-			/*push_ignore_pats("\r\n$");*/
 			break;
 		case OPT_IGN_FN_CASE:
 			ignore_file_case = 1;

==== //depot/projects/soc2010/bsdtextproc/diff/diff.h#3 (text+ko) ====

@@ -75,8 +75,9 @@
 	struct excludes	*next;
 };
 
-extern int	 aflag, Bflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
+extern int	 aflag, bflag, dflag, iflag, lflag, Nflag, Pflag, pflag, rflag,
 		 sflag, tflag, Tflag, wflag;
+extern int	 Bflag, strip_cr;
 extern int	 format, context, status;
 extern char	 ignore_file_case;
 extern char	*start, *ifdefname, *diffargs, *label[2], *ignore_pats;

==== //depot/projects/soc2010/bsdtextproc/diff/diffreg.c#4 (text+ko) ====

@@ -570,11 +570,7 @@
 			sz = sz * 3 / 2;
 			p = erealloc(p, (sz + 3) * sizeof(struct line));
 		}
-
-		/* ignore blank lines (also EOF)*/
-		if( !(Bflag && h == 1) ) {
-			p[++j].value = h;
-		}
+		p[++j].value = h;
 	}
 	len[i] = j;
 	file[i] = p;
@@ -770,7 +766,7 @@
 			ixnew[j] = ctnew += skipline(f2);
 			j++;
 		}
-		if (bflag || wflag || iflag) {
+		if (bflag || wflag || iflag || Bflag) {
 			for (;;) {
 				c = getc(f1);
 				d = getc(f2);
@@ -778,7 +774,7 @@
 				 * GNU diff ignores a missing newline
 				 * in one file if bflag || wflag.
 				 */
-				if ((bflag || wflag) &&
+				if ((bflag || wflag || Bflag) &&
 				    ((c == EOF && d == '\n') ||
 				    (c == '\n' && d == EOF))) {
 					break;
@@ -805,6 +801,23 @@
 						d = getc(f2);
 						ctnew++;
 					}
+				} else if (Bflag) {
+					while( c == '\n' && d != '\n' ) {
+						c = getc(f1);
+				                ixold[i] = ctold;
+						ixnew[j] = ctnew;
+               					j++; i++;
+						if( i == len[0] || j == len[1] ) { break; }
+					}
+		
+					while( d == '\n' && c != '\n') {
+						d = getc(f2);
+						ixold[i] = ctold;
+                                                ixnew[j] = ctnew;
+						j++; i++;
+						if( i == len[0] || j == len[1] ) { break; }
+					}
+					break;
 				}
 				if (chrtran[c] != chrtran[d]) {
 					jackpot++;


More information about the p4-projects mailing list