Personally I think the attached is much better than the origonal
(details in comments at top)

Also it would be nice to add:

regex/\.(patch|diff)\.*(gz|bz2)*$
        Open=%cd %p#patchfs

in the default bindings file (just above ### Archives ###)

Also s/lynx/links/ seems appropriate in the default bindings file.

cheers,
Pádraig.
#! /bin/sh

# Peter Daum    <[EMAIL PROTECTED]> (Jan 1998, mc-4.1.22)
#
#    Initial implementation.
#
# Padraig Brady <[EMAIL PROTECTED]>      (May 2002, mc-4.5.51)
#
#    Added support for unified diffs of files and not just directories,
#    i.e. when there is no "diff date file1 file2" line. Note patchfs
#    does not fully support context or "default" format diffs at present,
#    and will only display a SUMMARY of these type if diffstat is present.
#    I cleaned things up a lot and added support for viewing the SUMMARY
#    (previously called FILELIST) using diffstat if present.
#
# override any locale for dates. But LANG override LC_TIME (at least in glibc)
# unset LC_ALL
# LC_TIME=C
# export LC_TIME
LC_ALL=C
export LC_ALL

patchfs_list ()
{
    date=`date +"%b %d %H:%M"`
    perm="-r--r--r--"
    uid=00000000
    gid=00000000
    size=00000000
    nlink="  1"

    echo "$perm $nlink $uid $gid $size $date SUMMARY"
    $cat $1 | 
    sed -n "s/^+++ \([^         ]*\).*/$perm $nlink $uid $gid $size $date \1/gp"
}

patchfs_copyout ()
{
    if [ "$2" = SUMMARY ]; then  # list of all affected files
        if diffstat -V >/dev/null 2>&1; then
            $cat $1 | diffstat 2>/dev/null > $3
        else
            sed -n "s/^+++ \([^         ]*\).*/\1/gp" > $3
        fi
        exit 0
    fi
    
    fn=`echo $2 | sed 's|/|\\\/|g'`   # escape '/' in filename
    $cat $1 |
    sed -e '/^diff /d' |
    sed -ne "/^+++ .*$fn/,/^--- /{
                  /^--- /d
                  p
              }" > $3
}

patchfs_run ()
{
    exit 0
}

type=`file $2`
case $type in
    *bzip*) cat="bzip2 -dc" ;;
    *gzip*) cat="gzip -dc" ;;
    *text*) cat="cat" ;;
    *) exit 1
esac

umask 077
case "$1" in
    list) patchfs_list $2; exit 0;;
    copyout) patchfs_copyout $2 $3 $4; exit 0;;
    run) patchfs_run; exit 0;;
esac

exit 1

Reply via email to