Menu

diff: function truncated to 40 characters

Help
philip
2009-05-21
2012-07-26
  • philip

    philip - 2009-05-21

    Hello,
    When I use <diff -up file1.c file2.c> to compare two file, I find the function is truncated to 40 characters. Then I download the source code, and find print_context_function( ) in src\diffutils\2.8.7\diffutils-2.8.7-src\context.c file, I think the hard-coded const 40 is the reason:

    / Print FUNCTION in a context header. /
    static void
    print_context_function (FILE out, char const function)
    {
    int i;
    putc (' ', out);
    for (i = 0; i < 40 && function[i] != '\n'; i++)
    continue;
    fwrite (function, sizeof (char), i, out);
    }

    I want to known here why use the hard-coded const 40? We should delete the for loop and change the code to :

    / Print FUNCTION in a context header. /
    static void
    print_context_function (FILE out, char const function)
    {
    putc (' ', out);
    fwrite (function, sizeof (char), i, out);
    }

     
    • GnuWin

      GnuWin - 2009-05-21

      This looks more a feature of the original diff package than of the GnuWin32 port. So please report this to the appropriate diffutils mailing list; see http://www.gnu.org/software/diffutils/diffutils.html

       
MongoDB Logo MongoDB