🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1078

GNU diff `-U LINES' wanted

#1078
From: J.T. Conklin
Date: Wed, 11 Nov 1992 21:59
137 lines
5585 bytes
>>>>> pinard@icule.UUCP (Francois Pinard) writes:
Francois> In GNU diff 2.0 documentation, -LINES is declared to be
Francois> obsolescent.  Let me suggest implementing a new `-U LINES'
Francois> meaning `--unified=LINES' to parallel the fact that `-C
Francois> LINES' means `--context=LINES'.  One should not ought to
Francois> recourse to full option names nor obsolescent features just
Francois> for specifying a number of context lines for unidiffs.

I liked this idea so much, I added to my copy of diff.  If you haven't
done this yourself, here is a patch containing the code and texinfo
changes.

	--jtc

diff -c diff/ChangeLog:1.1.1.1 diff/ChangeLog:1.2
*** diff/ChangeLog:1.1.1.1	Tue Nov 10 17:08:40 1992
--- diff/ChangeLog	Tue Nov 10 17:08:41 1992
***************
*** 1,3 ****
--- 1,9 ----
+ Fri Nov  6 12:11:05 1992  J.T. Conklin  (conklin@talisman.kaleida.com)
+ 
+ 	* diff.c (main): Allow -U.
+ 	(usage): Document -U.
+ 	diff.texi: Document -U.
+ 	
  Tue Sep 15 14:27:25 1992  David J. MacKenzie  (djm@nutrimat.gnu.ai.mit.edu)
  
  	* Version 2.0.
diff -c diff/diff.c:1.1.1.1 diff/diff.c:1.2
*** diff/diff.c:1.1.1.1	Tue Nov 10 17:08:41 1992
--- diff/diff.c	Tue Nov 10 17:08:41 1992
***************
*** 243,249 ****
    /* Decode the options.  */
  
    while ((c = getopt_long (argc, argv,
! 			   "0123456789abBcC:dD:efF:hHiI:lL:nNpPqrsS:tTuvwW:x:X:y",
  			   longopts, (int *)0)) != EOF)
      {
        switch (c)
--- 243,249 ----
    /* Decode the options.  */
  
    while ((c = getopt_long (argc, argv,
! 			   "0123456789abBcC:dD:efF:hHiI:lL:nNpPqrsS:tTuU:vwW:x:X:y",
  			   longopts, (int *)0)) != EOF)
      {
        switch (c)
***************
*** 287,292 ****
--- 287,293 ----
  	  break;
  
  	case 'C':
+ 	case 'U':
  	case 129:		/* +context[=lines] */
  	case 130:		/* +unified[=lines] */
  	  if (optarg)
***************
*** 300,307 ****
  
  	  /* Falls through.  */
  	case 'c':
! 	  /* Make context-style output.  */
! 	  specify_style (c == 130 ? OUTPUT_UNIFIED : OUTPUT_CONTEXT);
  	  break;
  
  	case 'd':
--- 301,311 ----
  
  	  /* Falls through.  */
  	case 'c':
! 	case 'u':
! 	  /* context diffs are more common then unified diffs, so we
! 	     test against the context diff flags first */
! 	  specify_style ((c == 'c' || c == 'C' || c == 129)
! 			 ? OUTPUT_CONTEXT : OUTPUT_UNIFIED);
  	  break;
  
  	case 'd':
***************
*** 432,442 ****
  	  tab_align_flag = 1;
  	  break;
  
- 	case 'u':
- 	  /* Output the context diff in unidiff format.  */
- 	  specify_style (OUTPUT_UNIFIED);
- 	  break;
- 
  	case 'v':
  	  fprintf (stderr, "GNU diff version %s\n", version_string);
  	  break;
--- 436,441 ----
***************
*** 560,566 ****
    fprintf (stderr, "Usage: %s [options] from-file to-file\n", program);
    fprintf (stderr, "Options:\n\
         [-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D symbol] [-F regexp]\n\
!        [-I regexp] [-L from-label [-L to-label]] [-S starting-file]\n\
         [-W columns] [-x pattern] [-X pattern-file] [--exclude=pattern]\n\
         [--exclude-from=pattern-file] [--ignore-blank-lines] [--context[=lines]]\n\
         [--ifdef=symbol] [--show-function-line=regexp] [--speed-large-files]\n\
--- 559,565 ----
    fprintf (stderr, "Usage: %s [options] from-file to-file\n", program);
    fprintf (stderr, "Options:\n\
         [-abBcdefhHilnNpPqrstTuvwy] [-C lines] [-D symbol] [-F regexp]\n\
!        [-I regexp] [-L from-label [-L to-label]] [-S starting-file] [-U lines]\n\
         [-W columns] [-x pattern] [-X pattern-file] [--exclude=pattern]\n\
         [--exclude-from=pattern-file] [--ignore-blank-lines] [--context[=lines]]\n\
         [--ifdef=symbol] [--show-function-line=regexp] [--speed-large-files]\n\
diff -c diff/diff.texi:1.1.1.1 diff/diff.texi:1.2
*** diff/diff.texi:1.1.1.1	Tue Nov 10 17:08:42 1992
--- diff/diff.texi	Tue Nov 10 17:08:42 1992
***************
*** 756,764 ****
  
  The unified output format is a variation on the context format that is
  more compact because it omits redundant context lines.  To select this
! output format, use the @samp{-u} or @samp{--unified@r{[}=@var{lines}@r{]}}
! option.  The argument @var{lines} is the number of lines of context to
! show.  When it is not given, it defaults to three.
  
  At present, only GNU @code{diff} can produce this format and only GNU
  @code{patch} can automatically apply diffs in this format.
--- 756,765 ----
  
  The unified output format is a variation on the context format that is
  more compact because it omits redundant context lines.  To select this
! output format, use the @samp{-U @var{lines}},
! @samp{--unified@r{[}=@var{lines}@r{]}}, or @samp{-u} option.  The
! argument @var{lines} is the number of lines of context to show.  When it
! is not given, it defaults to three.
  
  At present, only GNU @code{diff} can produce this format and only GNU
  @code{patch} can automatically apply diffs in this format.
Technical Details
Message-ID: <9211112159.AA13343@talisman.kaleida.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!talisman.kaleida.com!conklin
References: conklin@talisman.kaleida.com (J.T. Conklin)

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!talisman.kaleida.com!conklin
From: conklin@talisman.kaleida.com (J.T. Conklin)
Subject: GNU diff `-U LINES' wanted
Message-ID: <9211112159.AA13343@talisman.kaleida.com>
Sender: gnulists@ai.mit.edu
Reply-To: conklin@kaleida.com
Organization: GNUs Not Usenet
References: conklin@talisman.kaleida.com (J.T. Conklin)
Distribution: gnu
Date: Wed, 11 Nov 1992 21:59:53 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 138