summaryrefslogtreecommitdiff
path: root/app-arch/ncompress/files/ncompress-5.0-c23.patch
blob: 7e61ade43fc1a565dc2d13b8993a00b71f958d8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
https://github.com/vapier/ncompress/commit/af7d29d87ddf8b2002dad41152efa94e9c825b35
https://github.com/vapier/ncompress/commit/aa359df10ec29a56c12f6e5c2bcec8d8ecfa2740
https://github.com/vapier/ncompress/pull/40

From af7d29d87ddf8b2002dad41152efa94e9c825b35 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gmail.com>
Date: Mon, 8 Feb 2021 00:28:08 -0500
Subject: [PATCH] require standard C function prototype support

We can drop the main prototype entirely as we don't need it.
---
 compress.c | 58 +++++++++++++++++++-----------------------------------
 2 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/compress.c b/compress.c
index 12c89b8..ff3b51b 100644
--- a/compress.c
+++ b/compress.c
@@ -49,12 +49,6 @@
 	};
 #endif
 
-#ifdef	__STDC__
-#	define	ARGS(a)				a
-#else
-#	define	ARGS(a)				()
-#endif
-
 #ifndef SIG_TYPE
 #	define	SIG_TYPE	void (*)()
 #endif
@@ -365,17 +359,16 @@ unsigned short	codetab[HSIZE];
 	} ;
 #endif
 
-int  	main			ARGS((int,char **));
-void  	Usage			ARGS((int));
-void  	comprexx		ARGS((const char *));
-void  	compdir			ARGS((char *));
-void  	compress		ARGS((int,int));
-void  	decompress		ARGS((int,int));
-void  	read_error		ARGS((void));
-void  	write_error		ARGS((void));
-void 	abort_compress	ARGS((void));
-void  	prratio			ARGS((FILE *,long,long));
-void  	about			ARGS((void));
+void  	Usage			(int);
+void  	comprexx		(const char *);
+void  	compdir			(char *);
+void  	compress		(int, int);
+void  	decompress		(int, int);
+void  	read_error		(void);
+void  	write_error		(void);
+void 	abort_compress	(void);
+void  	prratio			(FILE *, long, long);
+void  	about			(void);
 
 /*****************************************************************
  * TAG( main )
@@ -418,9 +411,7 @@ void  	about			ARGS((void));
  *   procedure needs no input table, but tracks the way the table was built.
  */ 
 int
-main(argc, argv)
-	int 	 argc;
-	char	*argv[];
+main(int argc, char *argv[])
 	{
 		char **filelist;
 		char **fileptr;
@@ -632,8 +623,7 @@ Usage: %s [-dfhvcVr] [-b maxbits] [--] [path ...]\n\
 	}
 
 void
-comprexx(fileptr)
-	const char	*fileptr;
+comprexx(const char	*fileptr)
 	{
 		int				 fdin = -1;
 		int				 fdout = -1;
@@ -982,8 +972,7 @@ comprexx(fileptr)
 
 #ifdef	RECURSIVE
 void
-compdir(dir)
-	char	*dir;
+compdir(char *dir)
 	{
 		struct dirent *dp;
 		DIR *dirp;
@@ -1059,9 +1048,7 @@ compdir(dir)
  * questions about this implementation to ames!jaw.
  */
 void
-compress(fdin, fdout)
-	int		fdin;
-	int		fdout;
+compress(int fdin, int fdout)
 	{
 		long hp;
 		int rpos;
@@ -1294,9 +1281,7 @@ endlop:			if (fcode.e.ent >= FIRST && rpos < rsize)
  */
 
 void
-decompress(fdin, fdout)
-	int		fdin;
-	int		fdout;
+decompress(int fdin, int fdout)
 	{
 		char_type *stackp;
 		code_int code;
@@ -1519,7 +1504,7 @@ resetbuf:	;
 	}
 
 void
-read_error()
+read_error(void)
 	{
 		fprintf(stderr, "\nread error on");
 	    perror((ifname[0] != '\0') ? ifname : "stdin");
@@ -1527,7 +1512,7 @@ read_error()
 	}
 
 void
-write_error()
+write_error(void)
 	{
 		fprintf(stderr, "\nwrite error on");
 	    perror(ofname ? ofname : "stdout");
@@ -1535,7 +1520,7 @@ write_error()
 	}
 
 void
-abort_compress()
+abort_compress(void)
 	{
 		if (remove_ofname)
 	    	unlink(ofname);
@@ -1544,10 +1529,7 @@ abort_compress()
 	}
 
 void
-prratio(stream, num, den)
-	FILE		*stream;
-	long int	 num;
-	long int	 den;
+prratio(FILE *stream, long int num, long int den)
 	{
 		int q;			/* Doesn't need to be long */
 
@@ -1571,7 +1553,7 @@ prratio(stream, num, den)
 	}
 
 void
-about()
+about(void)
 	{
 		printf("Compress version: %s\n", version_id);
 		printf("Compile options:\n        ");


From aa359df10ec29a56c12f6e5c2bcec8d8ecfa2740 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gmail.com>
Date: Mon, 8 Feb 2021 00:30:41 -0500
Subject: [PATCH] mark all local functions as static

This saves a small amount of space as the compiler can do better.
---
 compress.c | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/compress.c b/compress.c
index ff3b51b..86a8cda 100644
--- a/compress.c
+++ b/compress.c
@@ -359,16 +359,16 @@ unsigned short	codetab[HSIZE];
 	} ;
 #endif
 
-void  	Usage			(int);
-void  	comprexx		(const char *);
-void  	compdir			(char *);
-void  	compress		(int, int);
-void  	decompress		(int, int);
-void  	read_error		(void);
-void  	write_error		(void);
-void 	abort_compress	(void);
-void  	prratio			(FILE *, long, long);
-void  	about			(void);
+static void Usage(int);
+static void comprexx(const char *);
+static void compdir(char *);
+static void compress(int, int);
+static void decompress(int, int);
+static void read_error(void);
+static void write_error(void);
+static void abort_compress(void);
+static void prratio(FILE *, long, long);
+static void about(void);
 
 /*****************************************************************
  * TAG( main )

From 90810a7f11bf157b479c23c0fe6cee0bebec15c6 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Sat, 16 Nov 2024 18:49:48 +0000
Subject: [PATCH] compress.c: fix -std=c23 build failure (signal handler
 protos)

gcc-15 switched to -std=c23 by default:

    https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=55e3bd376b2214e200fa76d12b67ff259b06c212

As a result `ncompress` fails the build as:

    compress.c: In function 'main':
    compress.c:382:40: error:
      passing argument 2 of 'signal' from incompatible pointer type [-Wincompatible-pointer-types]
      382 |                         signal(SIGINT, (SIG_TYPE)abort_compress);
          |                                        ^~~~~~~~~~~~~~~~~~~~~~~~
          |                                        |
          |                                        void (*)(void)
    In file included from compress.c:30:
    ...-glibc-2.40-36-dev/include/signal.h:88:57: note:
      expected '__sighandler_t' {aka 'void (*)(int)'} but argument is of type 'void (*)(void)'
       88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
          |                                          ~~~~~~~~~~~~~~~^~~~~~~~~

The change removes type casts around function prototypes and define
signal handler as `void(*)(int)`.
---
 compress.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/compress.c b/compress.c
index da91603..ea8081e 100644
--- a/compress.c
+++ b/compress.c
@@ -49,10 +49,6 @@
 	};
 #endif
 
-#ifndef SIG_TYPE
-#	define	SIG_TYPE	void (*)()
-#endif
-
 #if defined(AMIGA) || defined(DOS) || defined(MINGW) || defined(WINDOWS)
 #	define	chmod(pathname, mode) 0
 #	define	chown(pathname, owner, group) 0
@@ -327,6 +323,7 @@ static void decompress(int, int);
 static void read_error(void);
 static void write_error(void);
 static void abort_compress(void);
+static void abort_compress_handler(int);
 static void prratio(FILE *, long, long);
 static void about(void);
 
@@ -379,14 +376,14 @@ main(int argc, char *argv[])
 
 #ifdef SIGINT
 		if ((fgnd_flag = (signal(SIGINT, SIG_IGN)) != SIG_IGN))
-			signal(SIGINT, (SIG_TYPE)abort_compress);
+			signal(SIGINT, abort_compress_handler);
 #endif
 
 #ifdef SIGTERM
-		signal(SIGTERM, (SIG_TYPE)abort_compress);
+		signal(SIGTERM, abort_compress_handler);
 #endif
 #ifdef SIGHUP
-		signal(SIGHUP, (SIG_TYPE)abort_compress);
+		signal(SIGHUP, abort_compress_handler);
 #endif
 
 #ifdef COMPATIBLE
@@ -1489,6 +1486,14 @@ abort_compress(void)
 		exit(1);
 	}
 
+
+void
+abort_compress_handler(int signo)
+	{
+		(void)signo;
+		abort_compress();
+	}
+
 void
 prratio(FILE *stream, long int num, long int den)
 	{