Skip to content

Commit

Permalink
released 0.9.6
Browse files Browse the repository at this point in the history
fix #11
fix #12
  • Loading branch information
genivia-inc committed Feb 29, 2024
1 parent 3f944fe commit 12438e9
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 37 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
SUBDIRS = lzma/C src
SUBDIRS =
if ENABLE_7ZIP
SUBDIRS += lzma/C
endif
SUBDIRS += src

man1_MANS = man/ugrep-indexer.1

Expand Down
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@ENABLE_7ZIP_TRUE@am__append_1 = lzma/C
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_brotlilib.m4 \
Expand Down Expand Up @@ -193,7 +194,7 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
DIST_SUBDIRS = $(SUBDIRS)
DIST_SUBDIRS = lzma/C src
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
README.md ar-lib compile config.guess config.sub depcomp \
install-sh missing
Expand Down Expand Up @@ -350,7 +351,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = lzma/C src
SUBDIRS = $(am__append_1) src
man1_MANS = man/ugrep-indexer.1
EXTRA_DIST = README.md LICENSE.txt CONTRIBUTING.md CODE_OF_CONDUCT.md
all: config.h
Expand Down
Binary file modified bin/win32/ugrep-indexer.exe
Binary file not shown.
Binary file modified bin/win64/ugrep-indexer.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ LIBOBJS
PTHREAD_LIBS
PTHREAD_CFLAGS
EXTRA_CFLAGS
ENABLE_7ZIP_FALSE
ENABLE_7ZIP_TRUE
PLATFORM
host_os
host_vendor
Expand Down Expand Up @@ -7808,6 +7810,14 @@ printf "%s\n" "yes" >&6; }
fi

fi
if test "x$with_7zip" = "xyes"; then
ENABLE_7ZIP_TRUE=
ENABLE_7ZIP_FALSE='#'
else
ENABLE_7ZIP_TRUE='#'
ENABLE_7ZIP_FALSE=
fi



PTHREAD_CFLAGS=""
Expand Down Expand Up @@ -7959,6 +7969,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_7ZIP_TRUE}" && test -z "${ENABLE_7ZIP_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_7ZIP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ else
fi

fi
AM_CONDITIONAL([ENABLE_7ZIP],[test "x$with_7zip" = "xyes"])

AC_SUBST(EXTRA_CFLAGS)
AC_SUBST([PTHREAD_CFLAGS], [""])
Expand Down
5 changes: 5 additions & 0 deletions lzma/7zls.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
@copyright (c) BSD-3 License - see LICENSE.txt
*/

/* to build and run 7zls:
cc -o 7zls 7zls.c C/libviiz.a
./7zls ../tests/archive.7z
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand Down
5 changes: 3 additions & 2 deletions lzma/C/7zCrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ UInt32 Z7_FASTCALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UI
#endif
#endif
#endif
#elif (defined(__clang__) && (__clang_major__ >= 3)) \
|| (defined(__GNUC__) && (__GNUC__ > 4))
#elif ( (defined(__clang__) && (__clang_major__ >= 3)) || \
(defined(__GNUC__) && (__GNUC__ > 4) ) ) && \
(__ARM_ARCH >= 8)
#if !defined(__ARM_FEATURE_CRC32)
#define __ARM_FEATURE_CRC32 1
#if defined(__clang__)
Expand Down
20 changes: 1 addition & 19 deletions lzma/C/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ build_triplet = @build@
host_triplet = @host@
subdir = lzma/C
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_boost_regex.m4 \
$(top_srcdir)/m4/ax_check_brotlilib.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_brotlilib.m4 \
$(top_srcdir)/m4/ax_check_bz2lib.m4 \
$(top_srcdir)/m4/ax_check_bzip3lib.m4 \
$(top_srcdir)/m4/ax_check_lz4lib.m4 \
$(top_srcdir)/m4/ax_check_lzmalib.m4 \
$(top_srcdir)/m4/ax_check_pcre2.m4 \
$(top_srcdir)/m4/ax_check_zlib.m4 \
$(top_srcdir)/m4/ax_check_zstdlib.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
Expand Down Expand Up @@ -212,17 +210,13 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BASH_COMPLETION_CFLAGS = @BASH_COMPLETION_CFLAGS@
BASH_COMPLETION_DIR = @BASH_COMPLETION_DIR@
BASH_COMPLETION_LIBS = @BASH_COMPLETION_LIBS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
Expand All @@ -234,10 +228,6 @@ ECHO_T = @ECHO_T@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXTRA_CFLAGS = @EXTRA_CFLAGS@
FISH_COMPLETION_CFLAGS = @FISH_COMPLETION_CFLAGS@
FISH_COMPLETION_DIR = @FISH_COMPLETION_DIR@
FISH_COMPLETION_LIBS = @FISH_COMPLETION_LIBS@
GREP_PATH = @GREP_PATH@
HAVE_CXX11 = @HAVE_CXX11@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
Expand All @@ -260,22 +250,14 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PLATFORM = @PLATFORM@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SIMD_AVX2_FLAGS = @SIMD_AVX2_FLAGS@
SIMD_AVX512BW_FLAGS = @SIMD_AVX512BW_FLAGS@
SIMD_FLAGS = @SIMD_FLAGS@
STRIP = @STRIP@
VERSION = @VERSION@
ZSH_COMPLETION_DIR = @ZSH_COMPLETION_DIR@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down
3 changes: 3 additions & 0 deletions lzma/C/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ LZMA SDK is placed in the public domain.

LZMA SDK by Igor Pavlov.

Updated to apply YOKOTA Hiroshi's patches:
https://salsa.debian.org/debian/7zip/-/blob/master/debian/patches/0002-Disable-hardware-acceleration-support-on-armel.patch?ref_type=heads

Included in this directory is a new C API to simplify decompression:

- viizip.h declarations, see below (hides implementation details)
Expand Down
5 changes: 3 additions & 2 deletions lzma/C/viizip.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,11 @@ int viiget(struct viizip *viizip, char *name, size_t max, time_t *mtime, uint64_
return res == SZ_OK ? 0 : -1;
}

/* decompress up to len bytes into buf[], return number of bytes decompressed */
/* decompress up to len bytes into buf[], return number of bytes decompressed or -1 on error */
ssize_t viidec(struct viizip *viizip, unsigned char *buf, size_t len)
{
if (viizip == NULL)
/* if not initialized or not called viiget() then return error */
if (viizip == NULL || viizip->index == 0)
return -1;

switch (viizip->state)
Expand Down
4 changes: 2 additions & 2 deletions man/ugrep-indexer.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH UGREP-INDEXER "1" "December 31, 2023" "ugrep-indexer 0.9.5" "User Commands"
.TH UGREP-INDEXER "1" "February 29, 2024" "ugrep-indexer 0.9.6" "User Commands"
.SH NAME
\fBugrep-indexer\fR -- file indexer to accelerate recursive searching
.SH SYNOPSIS
Expand Down Expand Up @@ -33,7 +33,7 @@ Specifies indexing accuracy. A low accuracy reduces the indexing
storage overhead at the cost of a higher rate of false positive
pattern matches (more noise). A high accuracy reduces the rate of
false positive regex pattern matches (less noise) at the cost of an
increased indexing storage overhead. An accuracy between 3 and 7
increased indexing storage overhead. An accuracy between 2 and 7
is recommended. The default accuracy is 5.
.TP
\fB\-.\fR, \fB\-\-hidden\fR
Expand Down
22 changes: 17 additions & 5 deletions src/ugrep-indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@copyright (c) BSD-3 License - see LICENSE.txt
*/

#define UGREP_INDEXER_VERSION "0.9.5 beta"
#define UGREP_INDEXER_VERSION "0.9.6"

// use a task-parallel thread to decompress the stream into a pipe to search, also handles nested archives
#define WITH_DECOMPRESSION_THREAD
Expand Down Expand Up @@ -350,6 +350,10 @@ struct Stream {

void close()
{
// close input separately when not associated with the file
if (input.file() != file && input.file() != NULL)
fclose(input.file());
// close the file
if (file != NULL)
fclose(file);
file = NULL;
Expand All @@ -367,6 +371,14 @@ struct Stream {

if (flag_decompress)
{
// close the underlying pipe previously created with pipe() and fdopen()
if (input.file() != NULL)
{
// close and unassign input
fclose(input.file());
input.clear();
}

partname.clear();

// start decompression thread if not running, get pipe with decompressed input
Expand All @@ -378,7 +390,7 @@ struct Stream {
}

// read archive/compressed/plain data from the decompression thread chain pipe
input = reflex::Input(pipe_in);
input = pipe_in;
}
else
{
Expand Down Expand Up @@ -434,10 +446,10 @@ struct Stream {
// -z: open next archived file if any or close the compressed file/archive
if (flag_decompress)
{
// close the input FILE* and its underlying pipe previously created with pipe() and fdopen()
// close the pipe previously created with pipe() and fdopen()
if (input.file() != NULL)
{
// close and unassign input, i.e. input.file() == NULL, also closes pipe_fd[0] per fdopen()
// close and unassign input
fclose(input.file());
input.clear();
}
Expand All @@ -449,7 +461,7 @@ struct Stream {
if (pipe_in != NULL)
{
// assign the next extracted file as input to search
input = reflex::Input(pipe_in);
input = pipe_in;

// start searching the next file in the archive
return true;
Expand Down
9 changes: 5 additions & 4 deletions src/zstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <ctime>
#include <climits>
#include <exception>
#include <stdexcept>
#include <streambuf>
#include <zlib.h>

Expand Down Expand Up @@ -538,8 +539,8 @@ class zstreambuf : public std::streambuf {
// read and decompress zip file data into buf[0..len-1], return number of bytes decompressed, 0 for EOF or -1 for error
std::streamsize decompress(unsigned char *buf, size_t len)
{
// if no more data to decompress, then return 0 to indicate EOF
if (zend_)
// if header() was not called or no more data to decompress, then return 0 to indicate EOF
if (znew_ || zend_)
return 0;

std::streamsize num = 0;
Expand Down Expand Up @@ -1362,8 +1363,8 @@ class zstreambuf : public std::streambuf {

catch (const std::invalid_argument&)
{
/* non-seekable 7zip files cannot be decompressed, */
cannot_decompress("non-seekable 7zip archive", pathname);
/* non-seekable and password-protected 7zip files cannot be decompressed */
cannot_decompress("7zip archive: encrypted data or 7z input is not seekable", pathname);
file_ = NULL;
}

Expand Down

0 comments on commit 12438e9

Please sign in to comment.