Ticket #3906: 0001-ZSTD-support.patch

File 0001-ZSTD-support.patch, 12.3 KB (added by kilobyte, 4 years ago)
  • lib/util.c

    From bbb08d7e23a9a3561524502b74a4e274ca63926a Mon Sep 17 00:00:00 2001
    From: Adam Borowski <kilobyte@angband.pl>
    Date: Sun, 18 Mar 2018 18:23:33 +0100
    Subject: [PATCH] ZSTD support.
    
    Signed-off-by: Adam Borowski <kilobyte@angband.pl>
    ---
     lib/util.c                       |  5 +++++
     lib/util.h                       |  3 ++-
     misc/ext.d/archive.sh            | 14 ++++++++++++++
     misc/ext.d/text.sh.in            |  7 +++++--
     misc/filehighlight.ini           |  2 +-
     misc/mc.ext.in                   | 22 ++++++++++++++++++++++
     misc/mc.menu.in                  | 12 +++++++++++-
     misc/syntax/sh.syntax            |  1 +
     src/editor/edit.c                |  1 +
     src/vfs/extfs/helpers/iso9660.in |  1 +
     src/vfs/extfs/helpers/lslR.in    |  1 +
     src/vfs/extfs/helpers/mailfs.in  |  3 +++
     src/vfs/extfs/helpers/patchfs.in |  5 +++++
     src/vfs/extfs/helpers/sfs.ini    |  2 ++
     14 files changed, 74 insertions(+), 5 deletions(-)
    
    diff --git a/lib/util.c b/lib/util.c
    index 2ecfd978d..aaa8c5f5e 100644
    a b get_compression_type (int fd, const char *name) 
    893893        && magic[2] == 0x7A && magic[3] == 0x58 && magic[4] == 0x5A && magic[5] == 0x00) 
    894894        return COMPRESSION_XZ; 
    895895 
     896    if (magic[0] == 0x28 && magic[1] == 0xB5 && magic[2] == 0x2F && magic[3] == 0xFD) 
     897        return COMPRESSION_ZSTD; 
     898 
    896899    str_len = strlen (name); 
    897900    /* HACK: we must belive to extension of LZMA file :) ... */ 
    898901    if ((str_len > 5 && strcmp (&name[str_len - 5], ".lzma") == 0) || 
    decompress_extension (int type) 
    923926        return "/ulzma" VFS_PATH_URL_DELIMITER; 
    924927    case COMPRESSION_XZ: 
    925928        return "/uxz" VFS_PATH_URL_DELIMITER; 
     929    case COMPRESSION_ZSTD: 
     930        return "/uzst" VFS_PATH_URL_DELIMITER; 
    926931    default: 
    927932        break; 
    928933    } 
  • lib/util.h

    diff --git a/lib/util.h b/lib/util.h
    index 28b834d39..46ac1f0b4 100644
    a b enum compression_type 
    6060    COMPRESSION_LZIP, 
    6161    COMPRESSION_LZ4, 
    6262    COMPRESSION_LZMA, 
    63     COMPRESSION_XZ 
     63    COMPRESSION_XZ, 
     64    COMPRESSION_ZSTD, 
    6465}; 
    6566 
    6667/* stdout or stderr stream of child process */ 
  • misc/ext.d/archive.sh

    diff --git a/misc/ext.d/archive.sh b/misc/ext.d/archive.sh
    index e6105fdc1..a4a041eaa 100755
    a b do_view_action() { 
    3535    xz) 
    3636        xz -dc "${MC_EXT_FILENAME}" 2>/dev/null 
    3737        ;; 
     38    zst) 
     39        zstd -dc "${MC_EXT_FILENAME}" 2>/dev/null 
     40        ;; 
    3841    tar) 
    3942        tar tvvf - < "${MC_EXT_FILENAME}" 
    4043        ;; 
    do_view_action() { 
    6669        xz -dc "${MC_EXT_FILENAME}" 2>/dev/null | \ 
    6770            tar tvvf - 
    6871        ;; 
     72    tar.zst|tzst) 
     73        zstd -dc "${MC_EXT_FILENAME}" 2>/dev/null | \ 
     74            tar tvvf - 
     75        ;; 
    6976    tar.F) 
    7077        freeze -dc "${MC_EXT_FILENAME}" 2>/dev/null | \ 
    7178            tar tvvf - 
    do_view_action() { 
    107114        xz -dc "${MC_EXT_FILENAME}" | \ 
    108115            cpio -itv 2>/dev/null 
    109116        ;; 
     117    cpio.zst) 
     118        zstd -dc "${MC_EXT_FILENAME}" | \ 
     119            cpio -itv 2>/dev/null 
     120        ;; 
    110121    cpio) 
    111122        cpio -itv < "${MC_EXT_FILENAME}" 2>/dev/null 
    112123        ;; 
    do_open_action() { 
    158169    xz) 
    159170        xz -dc "${MC_EXT_FILENAME}" | ${pager} 
    160171        ;; 
     172    zst) 
     173        zstd -dc "${MC_EXT_FILENAME}" | ${pager} 
     174        ;; 
    161175    par2) 
    162176        par2 r "${MC_EXT_FILENAME}" 
    163177        ;; 
  • misc/ext.d/text.sh.in

    diff --git a/misc/ext.d/text.sh.in b/misc/ext.d/text.sh.in
    index b47425876..2bd6ca05c 100644
    a b get_unpacker() { 
    3434    man.xz) 
    3535        unpacker="xz -dc" 
    3636        ;; 
     37    man.zst) 
     38        unpacker="zstd -dc" 
     39        ;; 
    3740    esac 
    3841    echo ${unpacker} 
    3942} 
    do_view_action() { 
    6467    nroff.ms) 
    6568        nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}" 
    6669        ;; 
    67     man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz) 
     70    man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz|man.zst) 
    6871        case "${MC_EXT_FILENAME}" in 
    6972        */log/*|*/logs/*) 
    7073            ${unpacker} "${MC_EXT_FILENAME}" 
    do_open_action() { 
    111114    nroff.ms) 
    112115        nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}" | ${pager} 
    113116        ;; 
    114     man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz) 
     117    man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz|man.zst) 
    115118        case "${MC_EXT_FILENAME}" in 
    116119        */log/*|*/logs/*) 
    117120            ${unpacker} "${MC_EXT_FILENAME}" 
  • misc/filehighlight.ini

    diff --git a/misc/filehighlight.ini b/misc/filehighlight.ini
    index 4a7a41855..8d6f0194b 100644
    a b  
    2828    regexp=(^#.*|.*~$) 
    2929 
    3030[archive] 
    31     extensions=7z;Z;ace;arc;arj;ark;bz2;cab;gz;lha;lz;lz4;lzh;lzma;rar;rpm;tar;tbz;tbz2;tgz;tlz;txz;xz;zip;zoo 
     31    extensions=7z;Z;ace;arc;arj;ark;bz2;cab;gz;lha;lz;lz4;lzh;lzma;rar;rpm;tar;tbz;tbz2;tgz;tlz;txz;xz;tzst;zst;zip;zoo 
    3232 
    3333[doc] 
    3434    extensions=chm;css;ctl;diz;doc;docm;docx;dtd;htm;html;letter;lsm;mail;man;me;msg;nroff;odp;ods;odt;pdf;po;ppt;pptm;pptx;ps;rtf;sgml;shtml;tex;text;txt;xls;xlsm;xlsx;xml;xsd;xslt 
  • misc/mc.ext.in

    diff --git a/misc/mc.ext.in b/misc/mc.ext.in
    index 92f908b6e..228c89311 100644
    a b regex/\.t(ar\.xz|xz)$ 
    150150        Open=%cd %p/utar:// 
    151151        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.xz 
    152152 
     153# .tar.zst, .tzst 
     154regex/\.t(ar\.zst|zst)$ 
     155        Open=%cd %p/utar:// 
     156        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.zst 
     157 
    153158# .tar.F - used in QNX 
    154159shell/.tar.F 
    155160        # Open=%cd %p/utar:// 
    shell/.cpio.xz 
    212217        Open=%cd %p/ucpio:// 
    213218        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.xz 
    214219 
     220shell/.cpio.zst 
     221        Open=%cd %p/ucpio:// 
     222        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.zst 
     223 
    215224shell/.cpio.gz 
    216225        Open=%cd %p/ucpio:// 
    217226        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.gz 
    regex/\.(diff|patch)(\.xz)$ 
    243252    Open=%cd %p/patchfs:// 
    244253    View=%view{ascii} @EXTHELPERSDIR@/archive.sh view xz 
    245254 
     255regex/\.(diff|patch)(\.zst)$ 
     256    Open=%cd %p/patchfs:// 
     257    View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zst 
     258 
    246259# ls-lR 
    247260regex/(^|\.)ls-?lR(\.gz|Z|bz2)$ 
    248261        Open=%cd %p/lslR:// 
    regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ 
    403416        Open=@EXTHELPERSDIR@/text.sh open man.xz %var{PAGER:more} 
    404417        View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.xz %var{PAGER:more} 
    405418 
     419regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.zst$ 
     420        Open=@EXTHELPERSDIR@/text.sh open man.zst %var{PAGER:more} 
     421        View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.zst %var{PAGER:more} 
     422 
    406423# CHM 
    407424shell/i/.chm 
    408425        Open=@EXTHELPERSDIR@/text.sh open chm 
    regex/\.xz$ 
    790807        Open=@EXTHELPERSDIR@/archive.sh view xz %var{PAGER:more} 
    791808        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view xz 
    792809 
     810# zstd 
     811regex/\.zst$ 
     812        Open=@EXTHELPERSDIR@/archive.sh view zst %var{PAGER:more} 
     813        View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zst 
     814 
    793815# Parity Archive 
    794816type/^Parity\ Archive\ Volume\ Set 
    795817        Open=@EXTHELPERSDIR@/archive.sh open par2 
  • misc/mc.menu.in

    diff --git a/misc/mc.menu.in b/misc/mc.menu.in
    index 8488a8750..2bf39c48e 100644
    a b shell_patterns=0 
    8484        tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \ 
    8585        echo "../$tar.tar.xz created." 
    8686 
     877       Compress the current subdirectory (tar.zst) 
     88        Pwd=`basename %d /` 
     89        echo -n "Name of the compressed file (without extension) [$Pwd]: " 
     90        read tar 
     91        [ "$tar"x = x ] && tar="$Pwd" 
     92        cd .. && \ 
     93        tar cf - "$Pwd" | zstd -f > "$tar.tar.zst" && \ 
     94        echo "../$tar.tar.zst created." 
     95 
    8796= f \.c$ & t r 
    8897+ f \.c$ & t r & ! t t 
    8998c       Compile and link current .c file 
    U Uudecode marked news articles (needs work) 
    219228        fi 
    220229        echo "Please test the output file before deleting anything." 
    221230 
    222 =+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.Z$ | f \.tar\.bz2$ & t r 
     231=+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.zst | f \.tar\.Z$ | f \.tar\.bz2$ & t r 
    223232x       Extract the contents of a compressed tar file 
    224233        unset PRG 
    225234        case %f in 
    x Extract the contents of a compressed tar file 
    230239            *.tar.lz4)  PRG="lz4 -dc";; 
    231240            *.tar.lzma) PRG="lzma -dc";; 
    232241            *.tar.xz)   PRG="xz -dc";; 
     242            *.tar.zst)  PRG="zstd -dc";; 
    233243            *)          exit 1;; 
    234244        esac 
    235245        $PRG %f | tar xvf - 
  • misc/syntax/sh.syntax

    diff --git a/misc/syntax/sh.syntax b/misc/syntax/sh.syntax
    index ff9ba2bc5..032433ee8 100644
    a b wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._ 
    19951995    keyword whole zoo cyan 
    19961996    keyword whole zsh cyan 
    19971997    keyword whole zsoelim cyan 
     1998    keyword whole zstd cyan 
    19981999    keyword whole zxpdf cyan 
    19992000 
    20002001    keyword whole pamcut cyan 
  • src/editor/edit.c

    diff --git a/src/editor/edit.c b/src/editor/edit.c
    index 174637253..016496fee 100644
    a b static const struct edit_filters 
    126126{ 
    127127    /* *INDENT-OFF* */ 
    128128    { "xz -cd %s 2>&1", "xz > %s", ".xz"}, 
     129    { "zstd -cd %s 2>&1", "zstd > %s", ".zst"}, 
    129130    { "lz4 -cd %s 2>&1", "lz4 > %s", ".lz4" }, 
    130131    { "lzip -cd %s 2>&1", "lzip > %s", ".lz"}, 
    131132    { "lzma -cd %s 2>&1", "lzma > %s", ".lzma" }, 
  • src/vfs/extfs/helpers/iso9660.in

    diff --git a/src/vfs/extfs/helpers/iso9660.in b/src/vfs/extfs/helpers/iso9660.in
    index 192667123..8c2240e8e 100644
    a b mcisofs_list () { 
    125125      *.lz4) MYCAT="lz4 -dc";; 
    126126      *.lzma) MYCAT="lzma -dc";; 
    127127      *.xz)  MYCAT="xz -dc";; 
     128      *.zst) MYCAT="zstd -dc";; 
    128129      *.bz2) MYCAT="bzip2 -dc";; 
    129130      *.gz)  MYCAT="gzip -dc";; 
    130131      *.z)   MYCAT="gzip -dc";; 
  • src/vfs/extfs/helpers/lslR.in

    diff --git a/src/vfs/extfs/helpers/lslR.in b/src/vfs/extfs/helpers/lslR.in
    index aba5457c5..69b663b40 100644
    a b case "$1" in 
    1616  *.lz4) MYCAT="lz4 -dc";; 
    1717  *.lzma) MYCAT="lzma -dc";; 
    1818  *.xz)  MYCAT="xz -dc";; 
     19  *.zst) MYCAT="zstd -dc";; 
    1920  *.bz2) MYCAT="bzip2 -dc";; 
    2021  *.gz)  MYCAT="gzip -dc";; 
    2122  *.z)   MYCAT="gzip -dc";; 
  • src/vfs/extfs/helpers/mailfs.in

    diff --git a/src/vfs/extfs/helpers/mailfs.in b/src/vfs/extfs/helpers/mailfs.in
    index e9455bef0..4bdd68b61 100644
    a b $lzipcat="lzip -dc"; # unlzip to stdout 
    1111$lz4cat="lz4 -dc";            # unlz4 to stdout 
    1212$lzcat="lzma -dc";            # unlzma to stdout 
    1313$xzcat="xz -dc";              # unxz to stdout 
     14$zstdcat="zstd -dc";          # unzstd to stdout 
    1415$file="file";                 # "file" command 
    1516$TZ='GMT';                    # default timezone (for Date module) 
    1617 
    if (/gzip/) { 
    194195    exit 1 unless (open IN, "$lzcat $mbox_qname|"); 
    195196} elsif (/xz/) { 
    196197    exit 1 unless (open IN, "$xzcat $mbox_qname|"); 
     198} elsif (/zst/) { 
     199    exit 1 unless (open IN, "$zstdcat $mbox_qname|"); 
    197200} else { 
    198201    exit 1 unless (open IN, "<$mbox_name"); 
    199202} 
  • src/vfs/extfs/helpers/patchfs.in

    diff --git a/src/vfs/extfs/helpers/patchfs.in b/src/vfs/extfs/helpers/patchfs.in
    index ef407de3a..c20cd54ef 100644
    a b my $lzip = 'lzip'; 
    1717my $lz4  = 'lz4'; 
    1818my $lzma = 'lzma'; 
    1919my $xz   = 'xz'; 
     20my $zstd = 'zstd'; 
    2021my $bzip = 'bzip2'; 
    2122my $gzip = 'gzip'; 
    2223my $fileutil = 'file -b'; 
    sub myin 
    8889        return "$lzma -dc $qfname"; 
    8990    } elsif (/^'*xz/) { 
    9091        return "$xz -dc $qfname"; 
     92    } elsif (/^'*zst/) { 
     93        return "$zstd -dc $qfname"; 
    9194    } elsif (/^'*bzip/) { 
    9295        return "$bzip -dc $qfname"; 
    9396    } elsif (/^'*gzip/) { 
    sub myout 
    112115        return "$lzma -c $sep $qfname"; 
    113116    } elsif (/^'*xz/) { 
    114117        return "$xz -c $sep $qfname"; 
     118    } elsif (/^'*zst/) { 
     119        return "$zstd -c $sep $qfname"; 
    115120    } elsif (/^'*bzip/) { 
    116121        return "$bzip -c $sep $qfname"; 
    117122    } elsif (/^'*gzip/) { 
  • src/vfs/extfs/helpers/sfs.ini

    diff --git a/src/vfs/extfs/helpers/sfs.ini b/src/vfs/extfs/helpers/sfs.ini
    index 699078aa6..d817dc9f4 100644
    a b lzma/1 lzma < %1 > %3 
    1818ulzma/1 lzma -d < %1 > %3 
    1919xz/1    xz < %1 > %3 
    2020uxz/1   xz -d < %1 > %3 
     21zst/1   zstd < %1 > %3 
     22uzst/1  zstd -d < %1 > %3 
    2123tar/1   tar cf %3 %1 
    2224tgz/1   tar czf %3 %1 
    2325uhtml/1 lynx -force_html -dump %1 > %3