Package init

This commit is contained in:
overweight 2019-09-30 11:09:28 -04:00
commit 903bd168be
10 changed files with 284 additions and 0 deletions

View File

@ -0,0 +1,13 @@
diff --git a/compress42.c b/compress42.c
index 4d33342..495bdf3 100644
--- a/compress42.c
+++ b/compress42.c
@@ -1373,7 +1373,7 @@ compress(fdin, fdout)
REG11 int boff;
REG12 int n_bits;
REG13 int ratio;
- REG14 long checkpoint;
+ REG14 unsigned long long checkpoint;
REG15 code_int extcode;
union
{

View File

@ -0,0 +1,11 @@
--- ncompress-4.2.4/compress42.c.endians 2006-09-19 13:53:58.000000000 +0200
+++ ncompress-4.2.4/compress42.c 2006-09-19 13:57:54.000000000 +0200
@@ -432,7 +432,7 @@
union bytes
{
- long word;
+ int word;
struct
{
#if BYTEORDER == 4321

View File

@ -0,0 +1,60 @@
diff --git a/compress42.c b/compress42.c
index b3b3add..6878046 100644
--- a/compress42.c
+++ b/compress42.c
@@ -141,6 +141,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
+#include <string.h>
#ifdef DIRENT
# include <dirent.h>
@@ -214,7 +215,7 @@
# define OBUFSIZ BUFSIZ /* Default output buffer size */
#endif
-#define MAXPATHLEN 1024 /* MAXPATHLEN - maximum length of a pathname we allow */
+#define MAXPATHLEN PATH_MAX /* MAXPATHLEN - maximum length of a pathname we allow */
#define SIZE_INNER_LOOP 256 /* Size of the inter (fast) compress loop */
/* Defines for third byte of header */
@@ -701,6 +702,7 @@ main(argc, argv)
{
REG3 char **filelist;
REG4 char **fileptr;
+ int i;
if (fgnd_flag = (signal(SIGINT, SIG_IGN) != SIG_IGN))
signal(SIGINT, (SIG_TYPE)abort_compress);
@@ -714,13 +716,18 @@ main(argc, argv)
nomagic = 1; /* Original didn't have a magic number */
#endif
- filelist = (char **)malloc(argc*sizeof(char *));
+ for (i=0; i<argc; i++) {
+ if (strlen(argv[i])>(MAXPATHLEN-1)) {
+ fprintf(stderr,"Filename too long\n");
+ exit(1);
+ }
+ }
+ filelist = fileptr = (char **)malloc(argc*sizeof(char *));
if (filelist == NULL)
{
fprintf(stderr, "Cannot allocate memory for file list.\n");
exit (1);
}
- fileptr = filelist;
*filelist = NULL;
if((progname = strrchr(argv[0], '/')) != 0)
@@ -860,7 +867,9 @@ nextarg: continue;
decompress(0, 1);
}
+ free(filelist);
exit((exit_code== -1) ? 1:exit_code);
+ return 0;
}
void

View File

@ -0,0 +1,23 @@
diff --git a/compress42.c b/compress42.c
index 804d099..b3b3add 100644
--- a/compress42.c
+++ b/compress42.c
@@ -130,6 +130,7 @@
* Add variable bit length output.
*
*/
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -538,8 +539,8 @@ int remove_ofname = 0; /* Remove output file on a error */
char ofname[MAXPATHLEN]; /* Output filename */
int fgnd_flag = 0; /* Running in background (SIGINT=SIGIGN) */
-long bytes_in; /* Total number of byte from input */
-long bytes_out; /* Total number of byte to output */
+long long bytes_in; /* Total number of byte from input */
+long long bytes_out; /* Total number of byte to output */
/*
* 8086 & 80286 Has a problem with array bigger than 64K so fake the array

View File

@ -0,0 +1,20 @@
diff --git a/Makefile.def b/Makefile.def
index e493d7c..1e6612f 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -31,7 +31,14 @@ MANDIR=/usr/local/man/man1
# -DDEF_ERRNO=1 Define error (not defined in errno.h).
# -DMAXSEG_64K=1 -BITS=16 Support segment processsor like 80286.
#
-options= $(CFLAGS) $(CPPFLAGS) -DDIRENT=1 -DUSERMEM=800000 -DREGISTERS=3
+options= $(CFLAGS) $(CPPFLAGS) -DDIRENT=1 -DUSERMEM=800000 -DREGISTERS=20 \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_LARGEFILE_SOURCE \
+ -DNOFUNCDEF=1 \
+ -DOBUFSIZ=1024 \
+ -DUTIME_H \
+ -DSYSDIR=1 \
+ $(ARCH_FLAGS)
# libary options
LBOPT= $(LDFLAGS)

View File

@ -0,0 +1,12 @@
diff -urNp ncompress-4.2.4-orig/compress42.c ncompress-4.2.4/compress42.c
--- ncompress-4.2.4-orig/compress42.c 2012-01-03 15:13:58.014222927 +0100
+++ ncompress-4.2.4/compress42.c 2012-01-03 15:15:17.117097419 +0100
@@ -1441,7 +1441,7 @@ compress(fdin, fdout)
boff = -(((OBUFSIZ<<3)-boff)%(n_bits<<3));
bytes_out += OBUFSIZ;
- memcpy(outbuf, outbuf+OBUFSIZ, (outbits>>3)+1);
+ memmove(outbuf, outbuf+OBUFSIZ, (outbits>>3)+1);
memset(outbuf+(outbits>>3)+1, '\0', OBUFSIZ);
}

View File

@ -0,0 +1,33 @@
diff --git a/compress42.c b/compress42.c
index c3f6b35..834c2f2 100644
--- a/compress42.c
+++ b/compress42.c
@@ -704,7 +704,7 @@ main(argc, argv)
REG4 char **fileptr;
int i;
- if (fgnd_flag = (signal(SIGINT, SIG_IGN) != SIG_IGN))
+ if ((fgnd_flag = (signal(SIGINT, SIG_IGN)) != SIG_IGN))
signal(SIGINT, (SIG_TYPE)abort_compress);
signal(SIGTERM, (SIG_TYPE)abort_compress);
@@ -1016,8 +1016,8 @@ comprexx(fileptr)
if (infstat.st_nlink > 1 && (!force))
{
- fprintf(stderr, "%s has %d other links: unchanged\n",
- tempname, infstat.st_nlink - 1);
+ fprintf(stderr, "%s has %ld other links: unchanged\n",
+ tempname, (long)(infstat.st_nlink - 1));
exit_code = 1;
return;
}
@@ -1318,7 +1318,7 @@ compdir(dir)
** think it's worth it. -- Dave Mack
*/
- while (dp = readdir(dirp))
+ while ((dp = readdir(dirp)))
{
if (dp->d_ino == 0)
continue;

BIN
ncompress-4.2.4.4.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
From c3644836a013841efd385a05e6f250985c024dfe Mon Sep 17 00:00:00 2001
From: hexiaowen <hexiaowen@huawei.com>
Date: Fri, 3 May 2019 16:06:24 +0800
Subject: [PATCH] ncompress: compression with 9 bits don't work
---
compress42.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compress42.c b/compress42.c
index 834c2f2..19a4043 100644
--- a/compress42.c
+++ b/compress42.c
@@ -233,7 +233,7 @@
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
-#define INIT_BITS 9 /* initial number of bits/code */
+#define INIT_BITS 8 /* initial number of bits/code */
#ifndef SACREDMEM
/*
@@ -835,7 +835,7 @@ main(argc, argv)
nextarg: continue;
}
- if (maxbits < INIT_BITS) maxbits = INIT_BITS;
+ if (maxbits <= INIT_BITS) maxbits = INIT_BITS + 1;
if (maxbits > BITS) maxbits = BITS;
if (*filelist != NULL)
--
1.8.3.1

78
ncompress.spec Normal file
View File

@ -0,0 +1,78 @@
Name: ncompress
Version: 4.2.4.4
Release: 18
Summary: A fast, simple LZW file compressor
License: Public Domain
URL: http://ncompress.sourceforge.net/
Source0: https://github.com/vapier/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: %{name}-4.2.4.4-make.patch
Patch1: %{name}-4.2.4.4-lfs.patch
Patch2: %{name}-4.2.4.4-filenamelen.patch
Patch3: %{name}-4.2.4.4-2GB.patch
Patch4: %{name}-4.2.4.4-endians.patch
Patch5: %{name}-4.2.4.4-memmove.patch
Patch6: %{name}-4.2.4.4-silence-gcc.patch
Patch6000: ncompress-compression-with-9-bits-don-t-work.patch
BuildRequires: git gcc glibc-devel
%description
Compress is a fast, simple LZW file compressor. Compress does not have the highest
compression rate, but it is one of the fastest programs to compress data. Compress
is the defacto standard in the UNIX community for compressing files.
%package_help
%prep
%autosetup -n %{name}-%{version} -p1
%build
make CFLAGS="%{optflags} %{build_ldflags}"
%install
install -D -p compress %{buildroot}%{_bindir}/compress
ln -sf compress %{buildroot}%{_bindir}/uncompress
install -D -p compress.1 %{buildroot}%{_mandir}/man1/compress.1
ln -sf compress.1 %{buildroot}%{_mandir}/man1/uncompress.1
%files
%defattr(-,root,root)
%doc LZW.INFO
%attr(755,root,root) %{_bindir}/compress
%{_bindir}/uncompress
%files help
%defattr(-,root,root)
%doc README Changes
%{_mandir}/man1/*.gz
%changelog
* Sat Sep 21 2019 shenyangyang<shenyangyang4@huawei.com> - 4.2.4.4-18
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:revise description
* Thu Aug 22 2019 shenyangyang<shenyangyang4@huawei.com> - 4.2.4.4-17
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:strenthen spec
* Wed Aug 21 2019 fangyufa<fangyufa1@huawei.com> - 4.2.4.4-16
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:modify name of patch
* Fri May 3 2019 hexiaowen<hexiaowen@huawei.com> - 4.2.4.4-15
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:compression with 9 bits don't work
* Wed Aug 22 2018 openEuler Buildteam <buildteam@openeuler.org> - 4.2.4.4-14
- Package init