• Re: diff and patch

    From Arjen@21:1/5 to All on Tue Jun 17 12:13:59 2025
    Mark Summerfield <[email protected]> posted:

    I want these functions:

    proc diff {old new} -> # diff data "ddata"
    proc patch {old ddata} -> # new

    where old and new are strings.

    I thought the Tcllib's rcs module could do this but I can't figure it out.

    Is this possible using the rcs module or using the struct::list module's
    LCS functions?

    The patch functionality (but not the diff) is provided by the textutil package, if I understand it correctly.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Mark Summerfield on Tue Jun 17 22:36:55 2025
    Mark Summerfield <[email protected]> wrote:
    I want these functions:

    proc diff {old new} -> # diff data "ddata"
    proc patch {old ddata} -> # new

    where old and new are strings.

    I thought the Tcllib's rcs module could do this but I can't figure it out.

    Is this possible using the rcs module or using the struct::list module's
    LCS functions?

    The core of the diff algorithm is LCS. You want the LCS functions from struct::list.

    But, you don't get a "diff" from the LCS procs, you get the LCS data,
    you then have to convert that into a "diff" format of your choice.

    You likely want to look at the various "diff in tcl" pages on the wiki.
    A starting point: https://wiki.tcl-lang.org/page/diff+in+Tcl

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ashok@21:1/5 to All on Wed Jun 18 16:49:38 2025
    If you don't mind binary extensions, you may want to look at the
    DiffUtil package - https://github.com/pspjuth/DiffUtilTcl

    % package require DiffUtil
    0.4.1
    % DiffUtil::diffStrings abcdefgh abXdefgY
    ab ab c X defg defg h Y {} {}

    I don't think it's been ported to Tcl 9 though.

    /Ashok

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Obermeier@21:1/5 to All on Wed Jun 18 20:07:55 2025
    Am 18.06.2025 um 13:19 schrieb Ashok:
    If you don't mind binary extensions, you may want to look at the DiffUtil package - https://github.com/pspjuth/DiffUtilTcl

    % package require DiffUtil
    0.4.1
    % DiffUtil::diffStrings abcdefgh abXdefgY
    ab ab c X defg defg h Y {} {}

    I don't think it's been ported to Tcl 9 though.

    /Ashok

    BAWT contains a Tcl9 ready version of DiffUtil (0.4.3), see https://wiki.tcl-lang.org/page/Porting+extensions+to+Tcl+9

    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)