From 8580b4d6ece885d6720d4a8456e93777f9bfc1cb Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 3 Aug 2026 13:07:05 +0200 Subject: [PATCH] [core] mv hard-coded zip utils (forked and adapted) to builtins This is a C code that was copy-pasted from zip 2.0 and unzip 5.12 in 1993-1994 It was then slightly adapted for ROOT but most of the structure is the same. Here, the code is put into the builtins directory. This is done for several reasons: - consistency with libafterimage, mathtext, glad: they have been all forked from upstream and fixed / adapted for ROOT. Likewise for core/zip - better separates C code from C++ code, separate folders - makes it clearer to deal with licensing and copyright notices by better separating source of the code - gives more recognition to original authors (before adaptions and modifications) - when a bug is found, it easens the opportunity to crosscheck with upstream whether it was fixed there - it allows in the future a more easy drop-in replacemente with a more up-to-date library or even a real zlib-based builtin rather than a hard-coded copy paste --- CMakeLists.txt | 1 + {core/zip/src => builtins/zip}/Bits.c | 0 {core/zip/src => builtins/zip}/Bits.h | 0 builtins/zip/CMakeLists.txt | 15 +++++++++++++++ {core/zip/src => builtins/zip}/Tailor.h | 0 {core/zip/src => builtins/zip}/ZDeflate.c | 0 {core/zip/src => builtins/zip}/ZIP.h | 0 {core/zip/src => builtins/zip}/ZInflate.c | 0 {core/zip/src => builtins/zip}/ZTrees.c | 0 core/zip/CMakeLists.txt | 5 +---- 10 files changed, 17 insertions(+), 4 deletions(-) rename {core/zip/src => builtins/zip}/Bits.c (100%) rename {core/zip/src => builtins/zip}/Bits.h (100%) create mode 100644 builtins/zip/CMakeLists.txt rename {core/zip/src => builtins/zip}/Tailor.h (100%) rename {core/zip/src => builtins/zip}/ZDeflate.c (100%) rename {core/zip/src => builtins/zip}/ZIP.h (100%) rename {core/zip/src => builtins/zip}/ZInflate.c (100%) rename {core/zip/src => builtins/zip}/ZTrees.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23f6b90b10453..20ae8a46c58cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -393,6 +393,7 @@ install(FILES ${CMAKE_BINARY_DIR}/etc/gitinfo.txt DESTINATION ${CMAKE_INSTALL_SY #---Recurse into the given subdirectories. This does not actually cause another cmake executable # to run. The same process will walk through the project's entire directory structure. add_subdirectory (core) +add_subdirectory (builtins/zip) # hard coded builtin for core/zip add_subdirectory (math) add_subdirectory (hist) add_subdirectory (tree) diff --git a/core/zip/src/Bits.c b/builtins/zip/Bits.c similarity index 100% rename from core/zip/src/Bits.c rename to builtins/zip/Bits.c diff --git a/core/zip/src/Bits.h b/builtins/zip/Bits.h similarity index 100% rename from core/zip/src/Bits.h rename to builtins/zip/Bits.h diff --git a/builtins/zip/CMakeLists.txt b/builtins/zip/CMakeLists.txt new file mode 100644 index 0000000000000..c01f3c2159689 --- /dev/null +++ b/builtins/zip/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +target_sources(Core PRIVATE + Bits.h # was renamed from Bits.c at https://github.com/root-project/root/commit/3b2f05c8ddf1001cc8eb05ad60b07b10af6ac293#diff-ff111e76990c56e7019ed0d837f1f615e280dc679ed393200c4f75b61094c5b7 and later split back to Bits.c in https://github.com/root-project/root/commit/25d5805abac4d408554e99aec6e49b8a671a2d96 + Tailor.h # forked from 1993: zip 2.0 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/inc/Tailor.h vs https://github.com/pmqs/Info-ZIP-Family-Tree-for-Zip/blob/d25ed515bc56fae136b635d764ce8b363041aef5/tailor.h) + ZIP.h # forked from 1993: zip 2.0 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/inc/ZIP.h vs https://github.com/pmqs/Info-ZIP-Family-Tree-for-Zip/blob/d25ed515bc56fae136b635d764ce8b363041aef5/zip.h) + Bits.c # forked from 1993: zip 2.0 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/src/Bits.c vs https://github.com/pmqs/Info-ZIP-Family-Tree-for-Zip/blob/d25ed515bc56fae136b635d764ce8b363041aef5/bits.c) + ZDeflate.c # forked from 1993: zip 2.0 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/src/Deflate.c vs https://github.com/pmqs/Info-ZIP-Family-Tree-for-Zip/blob/d25ed515bc56fae136b635d764ce8b363041aef5/deflate.c) + ZInflate.c # forked from 1994: version c14o / unzip-5.12 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/src/Inflate.c vs https://github.com/freebsd/freebsd-src/commit/37c32e9f3a0dc8ba9d0b7cd06742502dcba1b457 or https://stuff.mit.edu/afs/sipb.mit.edu/project/sipbsrc/i386_nbsd1/unzip-5.12/inflate.c) + ZTrees.c # forked from 1993: zip 2.0 (https://github.com/root-project/root/blob/852600061bcacd9b255d44f6312c96b6b1e00a2d/zip/src/Trees.c vs https://github.com/pmqs/Info-ZIP-Family-Tree-for-Zip/blob/d25ed515bc56fae136b635d764ce8b363041aef5/trees.c) +) diff --git a/core/zip/src/Tailor.h b/builtins/zip/Tailor.h similarity index 100% rename from core/zip/src/Tailor.h rename to builtins/zip/Tailor.h diff --git a/core/zip/src/ZDeflate.c b/builtins/zip/ZDeflate.c similarity index 100% rename from core/zip/src/ZDeflate.c rename to builtins/zip/ZDeflate.c diff --git a/core/zip/src/ZIP.h b/builtins/zip/ZIP.h similarity index 100% rename from core/zip/src/ZIP.h rename to builtins/zip/ZIP.h diff --git a/core/zip/src/ZInflate.c b/builtins/zip/ZInflate.c similarity index 100% rename from core/zip/src/ZInflate.c rename to builtins/zip/ZInflate.c diff --git a/core/zip/src/ZTrees.c b/builtins/zip/ZTrees.c similarity index 100% rename from core/zip/src/ZTrees.c rename to builtins/zip/ZTrees.c diff --git a/core/zip/CMakeLists.txt b/core/zip/CMakeLists.txt index 72d1bfb756dd8..e800fbbf4d6a3 100644 --- a/core/zip/CMakeLists.txt +++ b/core/zip/CMakeLists.txt @@ -7,15 +7,12 @@ find_package(ZLIB REQUIRED) target_sources(Core PRIVATE - src/Bits.c - src/ZDeflate.c - src/ZTrees.c - src/ZInflate.c src/Compression.cxx src/RZip.cxx ) target_link_libraries(Core PRIVATE ZLIB::ZLIB) +target_include_directories(Core PRIVATE ../../builtins/zip) target_include_directories(Core PUBLIC $