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
|
From ce18a556b6b1829a9e9b1effed12b822648907c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= <ricolvs123@gmail.com>
Date: Sun, 9 Mar 2025 16:54:41 -0300
Subject: [PATCH] remove K&R C function declaration bullshit from lemon.c
should be enough to fix GCC15 compilation without fucking up size_t/etc
---
tools/lemon/lemon.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c
index bdc004a17db..e5fd16905a6 100644
--- a/tools/lemon/lemon.c
+++ b/tools/lemon/lemon.c
@@ -53,7 +53,7 @@ extern int access(char *path, int mode);
#endif
static int showPrecedenceConflict = 0;
-static void *msort(void *list, void *next, int (*cmp)());
+static void *msort(void *list, void *next, int (*cmp)(void*, void*));
/*
** Compilers are getting increasingly pedantic about type conversions
@@ -359,7 +359,7 @@ struct symbol **Symbol_arrayof(void);
/* Routines to manage the state table */
-int Configcmp(const char *, const char *);
+int Configcmp(void *, void *);
struct state *State_new(void);
void State_init(void);
int State_insert(struct state *, struct config *);
@@ -403,10 +403,10 @@ static struct action *Action_new(void){
** positive if the first action is less than, equal to, or greater than
** the first
*/
-static int actioncmp(ap1,ap2)
-struct action *ap1;
-struct action *ap2;
+static int actioncmp(void *_ap1,void *_ap2)
{
+ struct action * ap1 = (struct action *)_ap1;
+ struct action * ap2 = (struct action *)_ap2;
int rc;
rc = ap1->sp->index - ap2->sp->index;
if( rc==0 ){
@@ -1757,9 +1757,9 @@ int main(int argc, char **argv)
** The "next" pointers for elements in the lists a and b are
** changed.
*/
-static void *merge(void *a,void *b,int (*cmp)(),size_t offset)
+static void *merge(void *a,void *b,int (*cmp)(void *a, void *b),size_t offset)
{
- char *ptr, *head;
+ void *ptr, *head;
if( a==0 ){
head = b;
@@ -1805,11 +1805,11 @@ static void *merge(void *a,void *b,int (*cmp)(),size_t offset)
** The "next" pointers for elements in list are changed.
*/
#define LISTSIZE 30
-static void *msort(void *list,void *next,int (*cmp)())
+static void *msort(void *list,void *next,int (*cmp)(void*, void*))
{
size_t offset;
- char *ep;
- char *set[LISTSIZE];
+ void *ep;
+ void *set[LISTSIZE];
int i;
offset = (size_t)next - (size_t)list;
for(i=0; i<LISTSIZE; i++) set[i] = 0;
@@ -2714,9 +2714,7 @@ static void preprocess_input(char *z){
}
}
-int strip_crlf(filebuf, filesize)
-char *filebuf;
-int filesize;
+int strip_crlf(char *filebuf, int filesize)
{
int i, j;
@@ -5136,10 +5134,10 @@ struct symbol **Symbol_arrayof()
}
/* Compare two configurations */
-int Configcmp(const char *_a,const char *_b)
+int Configcmp(void *_a,void *_b)
{
- const struct config *a = (struct config *) _a;
- const struct config *b = (struct config *) _b;
+ const struct config *a = (const struct config *) _a;
+ const struct config *b = (const struct config *) _b;
int x;
x = a->rp->index - b->rp->index;
if( x==0 ) x = a->dot - b->dot;
@@ -5147,8 +5145,10 @@ int Configcmp(const char *_a,const char *_b)
}
/* Compare two states */
-PRIVATE int statecmp(struct config *a, struct config *b)
+PRIVATE int statecmp(void *_a, void *_b)
{
+ const struct config *a = (const struct config *) _a;
+ const struct config *b = (const struct config *) _b;
int rc;
for(rc=0; rc==0 && a && b; a=a->bp, b=b->bp){
rc = a->rp->index - b->rp->index;
@@ -5377,7 +5377,7 @@ int Configtable_insert(struct config *data)
h = ph & (x4a->size-1);
np = x4a->ht[h];
while( np ){
- if( Configcmp((const char *) np->data,(const char *) data)==0 ){
+ if( Configcmp(np->data, data)==0 ){
/* An existing entry with the same key is found. */
/* Fail because overwrite is not allows. */
return 0;
@@ -5430,7 +5430,7 @@ struct config *Configtable_find(struct config *key)
h = confighash(key) & (x4a->size-1);
np = x4a->ht[h];
while( np ){
- if( Configcmp((const char *) np->data,(const char *) key)==0 ) break;
+ if( Configcmp(np->data,key)==0 ) break;
np = np->next;
}
return np ? np->data : 0;
|