From 87c6550f150a54949c528512e4fc93c1d137c67c Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 8 Oct 2002 23:56:38 +0000 Subject: [PATCH] Minor tweaks, mostly to comments. --- nufxlib-0/Deflate.c | 6 +++++- nufxlib-0/FileIO.c | 1 + nufxlib-0/Makefile.in | 5 ++++- nufxlib-0/README.txt | 16 ++++++++++++++++ nufxlib-0/Squeeze.c | 13 +++++++++++-- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/nufxlib-0/Deflate.c b/nufxlib-0/Deflate.c index 9c11743..4d396c1 100644 --- a/nufxlib-0/Deflate.c +++ b/nufxlib-0/Deflate.c @@ -8,7 +8,11 @@ * * This compression format is totally unsupported on the Apple II. This * is provided primarily for the benefit of Apple II emulators that want - * a better storage format for disk images than SHK+LZW or a ZIP. + * a better storage format for disk images than SHK+LZW or a ZIP file. + * + * This code was developed and tested with ZLIB_VERSION "1.1.3". It is + * expected to work with any version >= 1.1.3 and < 2.x. Please visit + * http://www.zlib.org/ for more information. */ #include "NufxLibPriv.h" diff --git a/nufxlib-0/FileIO.c b/nufxlib-0/FileIO.c index d7085ea..28c7971 100644 --- a/nufxlib-0/FileIO.c +++ b/nufxlib-0/FileIO.c @@ -1287,6 +1287,7 @@ Nu_TruncateOpenFile(FILE* fp, long length) return errno ? errno : -1; return kNuErrNone; #else + /* not fatal; return this to indicate that it's an unsupported operation */ return kNuErrInternal; #endif } diff --git a/nufxlib-0/Makefile.in b/nufxlib-0/Makefile.in index 2633890..1fb0d73 100644 --- a/nufxlib-0/Makefile.in +++ b/nufxlib-0/Makefile.in @@ -72,11 +72,14 @@ $(STATIC_PRODUCT): $(OBJS) $(AR) $@ $(OBJS) @RANLIB@ $@ +# BUG: we probably want -fPIC -D_REENTRANT on the compile lines for this. +# BUG: for Linux we may want -Wl,-soname,libnufx.so.1 on the link line. $(SHARED_PRODUCT): $(OBJS) -rm -f $(STATIC_PRODUCT) $(SHARED_PRODUCT) $(CC) @SHARE_FLAGS@ -o $@ $(OBJS) @LIBS@ -# the build date is approximate, the build flags are accurate +# The build date is approximate, the build flags are accurate so long +# as they were changed by touching the makefile. Version.c: Version.c.in Makefile (sed -e "s/BUILT/`date`/" -e "s/OPTFLAGS/$(OPT)/" < Version.c.in > Version.c) diff --git a/nufxlib-0/README.txt b/nufxlib-0/README.txt index d11b88c..bb84a45 100644 --- a/nufxlib-0/README.txt +++ b/nufxlib-0/README.txt @@ -90,3 +90,19 @@ add the appropriate goodies. (Seems to me you'd always want this on, but for some reason Solaris makes you take an extra step, so I'm not going to define it by default.) + +Legalese +======== + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/nufxlib-0/Squeeze.c b/nufxlib-0/Squeeze.c index a20337b..7ef73b8 100644 --- a/nufxlib-0/Squeeze.c +++ b/nufxlib-0/Squeeze.c @@ -683,6 +683,10 @@ bail: * Compress "srcLen" bytes into SQ format, from "pStraw" to "fp". * * This requires two passes through the input. + * + * Bit of trivia: "sq3" on the Apple II self-destructs if you hand + * it an empty file. "xsq" works fine, creating an empty tree that + * "xusq" unpacks. */ NuError Nu_CompressHuffmanSQ(NuArchive* pArchive, NuStraw* pStraw, FILE* fp, @@ -905,6 +909,7 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, #endif short nodeCount; int i, inrep; + uchar lastc = 0; err = Nu_AllocCompressionBufferIFN(pArchive); if (err != kNuErrNone) @@ -915,7 +920,12 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, usqState.dataPtr = pArchive->compBuf; compRemaining = pThread->thCompThreadEOF; - if (compRemaining < 8) { +#ifdef FULL_SQ_HEADER + if (compRemaining < 8) +#else + if (compRemaining < 3) +#endif + { err = kNuErrBadData; Nu_ReportError(NU_BLOB, err, "thread too short to be valid SQ data"); goto bail; @@ -1007,7 +1017,6 @@ Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord, inrep = false; while (1) { int val; - uchar lastc; if (usqState.dataInBuffer < 65 && compRemaining) { /*