From ff0be17cf75cba769c404d12312a72c9528f4552 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Fri, 24 May 2019 16:55:43 -0400 Subject: [PATCH 1/3] Build Manual --- doc/zstd_manual.html | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html index f1628b50d..1e05f0cb3 100644 --- a/doc/zstd_manual.html +++ b/doc/zstd_manual.html @@ -594,7 +594,7 @@ size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
size_t ZSTD_CStreamOutSize(void);   /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block in all circumstances. */
 

-

This is a legacy streaming API, and can be replaced by ZSTD_CCtx_reset() and

 ZSTD_compressStream2(). It is redundent, but is still fully supported.
+

This is a legacy streaming API, and can be replaced by ZSTD_CCtx_reset() and

 ZSTD_compressStream2(). It is redundant, but is still fully supported.
  Advanced parameters and dictionary compression can only be used through the
  new API.
 
@@ -647,9 +647,7 @@ size_t ZSTD_freeCStream(ZSTD_CStream* zcs);

ZSTD_DStream management functions

ZSTD_DStream* ZSTD_createDStream(void);
 size_t ZSTD_freeDStream(ZSTD_DStream* zds);
 

-

Streaming decompression functions

size_t ZSTD_initDStream(ZSTD_DStream* zds);
-size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
-

+

Streaming decompression functions


size_t ZSTD_DStreamInSize(void);    /*!< recommended size for input buffer */
 

size_t ZSTD_DStreamOutSize(void);   /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */
@@ -1407,9 +1405,32 @@ size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict*
  
 


-

Advanced Streaming decompression functions

size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: no dictionary will be used if dict == NULL or dictSize < 8 */
-size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);  /**< note : ddict is referenced, it must outlive decompression session */
-size_t ZSTD_resetDStream(ZSTD_DStream* zds);  /**< re-use decompression parameters from previous init; saves dictionary loading */
+

Advanced Streaming decompression functions

/**
+ * This function is deprecated, and is equivalent to:
+ *
+ *     ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
+ *     ZSTD_DCtx_loadDictionary(zds, dict, dictSize);
+ *
+ * note: no dictionary will be used if dict == NULL or dictSize < 8
+ */
+size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
+/**
+ * This function is deprecated, and is equivalent to:
+ *
+ *     ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
+ *     ZSTD_DCtx_refDDict(zds, ddict);
+ *
+ * note : ddict is referenced, it must outlive decompression session
+ */
+size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
+/**
+ * This function is deprecated, and is equivalent to:
+ *
+ *     ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
+ *
+ * re-use decompression parameters from previous init; saves dictionary loading
+ */
+size_t ZSTD_resetDStream(ZSTD_DStream* zds);
 

Buffer-less and synchronous inner streaming functions

   This is an advanced API, giving full control over buffer management, for users which need direct control over memory.

From 61025d5b7d283e62304e177dd21db65225c4a5b2 Mon Sep 17 00:00:00 2001
From: "W. Felix Handte" 
Date: Fri, 24 May 2019 16:55:59 -0400
Subject: [PATCH 2/3] zstdgrep: Handle -f Flag

---
 programs/zstdgrep | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/programs/zstdgrep b/programs/zstdgrep
index cb804b8be..4879fb0da 100755
--- a/programs/zstdgrep
+++ b/programs/zstdgrep
@@ -58,6 +58,9 @@ while [ "$#" -gt 0 ] && [ "${endofopts}" -eq 0 ]; do
                     shift 2
                     break
                     ;;
+                -f)
+                    pattern_found=2
+                    ;;
                 *)
                     ;;
             esac
@@ -117,7 +120,11 @@ else
     set -f
     while [ "$#" -gt 0 ]; do
         # shellcheck disable=SC2086
-        "${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- "${pattern}" -
+        if [ $pattern_found -eq 2 ]; then
+            "${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- -
+        else
+            "${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- "${pattern}" -
+        fi
         [ "$?" -ne 0 ] && EXIT_CODE=1
         shift
     done

From 6a0638048a33ef87971dcd2141e45e7e5bd90307 Mon Sep 17 00:00:00 2001
From: "W. Felix Handte" 
Date: Fri, 24 May 2019 17:21:44 -0400
Subject: [PATCH 3/3] Add Test

---
 tests/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/Makefile b/tests/Makefile
index f11b73183..4ee684e08 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -359,6 +359,9 @@ test-zstdgrep: gzstd
 	-echo 'hello world' > test.txt && $(PRGDIR)/zstd test.txt
 	env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep hello test.txt.zst
 	env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep weird test.txt.zst && return 1 || return 0
+	-echo 'hello' > pattern.txt
+	env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep -f pattern.txt test.txt.zst
+	$(RM) test.txt test.txt.zst pattern.txt
 
 test-fullbench: fullbench datagen
 	$(QEMU_SYS) ./fullbench -i1