bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

extend diff3 to ignore whitespace differences - here's a patch


From: John Lumby
Subject: extend diff3 to ignore whitespace differences - here's a patch
Date: Wed, 03 Dec 2003 16:28:23 -0500

*** diff3.c.orig        2002-04-05 15:37:31.000000000 -0500
--- diff3.c     2003-12-03 15:52:29.000000000 -0500
***************
*** 178,183 ****
--- 178,186 ----
 /* If nonzero, output a merged file.  */
 static bool merge;

+ /* If nonzero, ignore white space */
+ static bool ignore_white_space;
+
 char *program_name;

 static char *read_diff (char const *, char const *, char **);
***************
*** 254,260 ****
   textdomain (PACKAGE);
   c_stack_action (c_stack_die);

! while ((c = getopt_long (argc, argv, "aeimvx3AEL:TX", longopts, 0)) != -1)
     {
       switch (c)
        {
--- 257,263 ----
   textdomain (PACKAGE);
   c_stack_action (c_stack_die);

! while ((c = getopt_long (argc, argv, "aeimvwx3AEL:TX", longopts, 0)) != -1)
     {
       switch (c)
        {
***************
*** 292,297 ****
--- 295,304 ----
        case 'T':
          initial_tab = 1;
          break;
+         case 'w':
+           ignore_white_space = 1;          /* jel ignore_white_space */
+ text = 1; /* if ignoring white space, assume text */
+         break;
        case 'v':
          printf ("diff3 %s\n%s\n\n%s\n\n%s\n",
                  version_string, copyright_string,
***************
*** 1155,1160 ****
--- 1162,1169 ----

   ap = argv;
   *ap++ = diff_program;
+   if (ignore_white_space)
+     *ap++ = "-w";                  /* jel ignore_white_space */
   if (text)
     *ap++ = "-a";
   *ap++ = "--horizon-lines=100";
***************
*** 1193,1206 ****
 #else

   FILE *fpipe;
!   char const args[] = " -a --horizon-lines=100 -- ";
   char *command = xmalloc (quote_system_arg (0, diff_program)
                           + sizeof args - 1
                           + quote_system_arg (0, filea) + 1
                           + quote_system_arg (0, fileb) + 1);
   char *p = command;
   p += quote_system_arg (p, diff_program);
!   strcpy (p, args + (text ? 0 : 3));
   p += strlen (p);
   p += quote_system_arg (p, filea);
   *p++ = ' ';
--- 1202,1216 ----
 #else

   FILE *fpipe;
! char const args[] = " -w" " -a --horizon-lines=100 -- "; /* jel ignore_white_space */
   char *command = xmalloc (quote_system_arg (0, diff_program)
                           + sizeof args - 1
                           + quote_system_arg (0, filea) + 1
                           + quote_system_arg (0, fileb) + 1);
   char *p = command;
   p += quote_system_arg (p, diff_program);
!   /*   in the following, we assume that ignore_white_space implies text */
!   strcpy (p, args + (ignore_white_space ? 0 : (text ? 3 : 6)));
   p += strlen (p);
   p += quote_system_arg (p, filea);
   *p++ = ' ';

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca





reply via email to

[Prev in Thread] Current Thread [Next in Thread]