Skip to content

Commit 4e7318c

Browse files
davidfstrclaude
andcommitted
Patch Discount 2.2.7 to rewrite K&R syntax that is rejected in Clang's C23 mode
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e6bc99e commit 4e7318c

3 files changed

Lines changed: 94 additions & 30 deletions

File tree

ext.diff

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
diff -U7 ext.orig/generate.c ext.new/generate.c
2-
--- ext.orig/generate.c 2023-12-19 10:02:39.000000000 -0500
3-
+++ ext.new/generate.c 2023-12-31 11:54:37.000000000 -0500
4-
@@ -176,21 +176,26 @@
2+
--- ext.orig/generate.c
3+
+++ ext.new/generate.c
4+
@@ -173,24 +173,29 @@
5+
char bfr[80];
6+
va_list ptr;
7+
58
va_start(ptr,fmt);
69
vsnprintf(bfr, sizeof bfr, fmt, ptr);
710
va_end(ptr);
811
Qstring(bfr, f);
9-
}
10-
11-
12-
+static int Qchar_mkd_sta_function_t(const int n, const void* iot) {
13-
+ Qchar(n, iot);
1412
+}
1513
+
1614
+
15+
+static int Qchar_mkd_sta_function_t(const int n, const void* iot) {
16+
+ Qchar(n, iot);
17+
}
18+
19+
1720
/* Qanchor() prints out a suitable-for-id-tag version of a string
1821
*/
1922
static void
@@ -29,11 +32,68 @@ diff -U7 ext.orig/generate.c ext.new/generate.c
2932
*/
3033
static void
3134
Qem(MMIOT *f, char c, int count)
35+
@@ -622,16 +627,15 @@
36+
} /* printlinkyref */
37+
38+
39+
/* helper function for php markdown extra footnotes; allow the user to
40+
* define a prefix tag instead of just `fn`
41+
*/
42+
static char *
43+
-p_or_nothing(p)
44+
-MMIOT *p;
45+
+p_or_nothing(MMIOT *p)
46+
{
47+
return p->ref_prefix ? p->ref_prefix : "fn";
48+
}
49+
50+
51+
/* php markdown extra/daring fireball style print footnotes
52+
*/
3253
diff -U7 ext.orig/gethopt.c ext.new/gethopt.c
33-
--- ext.orig/gethopt.c 2023-12-19 10:01:53.000000000 -0500
34-
+++ ext.new/gethopt.c 2023-12-31 11:55:06.000000000 -0500
35-
@@ -41,16 +41,15 @@
36-
struct h_context *ctx;
54+
--- ext.orig/gethopt.c
55+
+++ ext.new/gethopt.c
56+
@@ -6,64 +6,54 @@
57+
#include <stdio.h>
58+
#include <string.h>
59+
60+
#include "gethopt.h"
61+
62+
63+
void
64+
-hoptset(ctx, argc, argv)
65+
-struct h_context *ctx;
66+
-int argc;
67+
-char **argv;
68+
+hoptset(struct h_context *ctx, int argc, char **argv)
69+
{
70+
memset(ctx, 0, sizeof *ctx);
71+
ctx->argc = argc;
72+
ctx->argv = argv;
73+
ctx->optind = 1;
74+
}
75+
76+
77+
char *
78+
-hoptarg(ctx)
79+
-struct h_context *ctx;
80+
+hoptarg(struct h_context *ctx)
81+
{
82+
return ctx->optarg;
83+
}
84+
85+
int
86+
-hoptind(ctx)
87+
-struct h_context *ctx;
88+
+hoptind(struct h_context *ctx)
89+
{
90+
return ctx->optind;
91+
}
92+
93+
char
94+
-hoptopt(ctx)
95+
-struct h_context *ctx;
96+
+hoptopt(struct h_context *ctx)
3797
{
3898
return ctx->optopt;
3999
}
@@ -50,9 +110,23 @@ diff -U7 ext.orig/gethopt.c ext.new/gethopt.c
50110
return old;
51111
}
52112

113+
114+
struct h_opt *
115+
-gethopt(ctx, opts, nropts)
116+
-struct h_context *ctx;
117+
-struct h_opt *opts;
118+
-int nropts;
119+
+gethopt(struct h_context *ctx, struct h_opt *opts, int nropts)
120+
{
121+
int i;
122+
int dashes;
123+
124+
125+
if ( (ctx == 0) || ctx->optend || (ctx->optind >= ctx->argc) )
126+
return 0;
53127
diff -U7 ext.orig/toc.c ext.new/toc.c
54-
--- ext.orig/toc.c 2023-12-19 10:01:53.000000000 -0500
55-
+++ ext.new/toc.c 2023-12-31 11:56:16.000000000 -0500
128+
--- ext.orig/toc.c
129+
+++ ext.new/toc.c
56130
@@ -11,14 +11,19 @@
57131
#include <stdlib.h>
58132
#include <ctype.h>

ext/generate.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
631631
* define a prefix tag instead of just `fn`
632632
*/
633633
static char *
634-
p_or_nothing(p)
635-
MMIOT *p;
634+
p_or_nothing(MMIOT *p)
636635
{
637636
return p->ref_prefix ? p->ref_prefix : "fn";
638637
}

ext/gethopt.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111

1212
void
13-
hoptset(ctx, argc, argv)
14-
struct h_context *ctx;
15-
int argc;
16-
char **argv;
13+
hoptset(struct h_context *ctx, int argc, char **argv)
1714
{
1815
memset(ctx, 0, sizeof *ctx);
1916
ctx->argc = argc;
@@ -23,22 +20,19 @@ char **argv;
2320

2421

2522
char *
26-
hoptarg(ctx)
27-
struct h_context *ctx;
23+
hoptarg(struct h_context *ctx)
2824
{
2925
return ctx->optarg;
3026
}
3127

3228
int
33-
hoptind(ctx)
34-
struct h_context *ctx;
29+
hoptind(struct h_context *ctx)
3530
{
3631
return ctx->optind;
3732
}
3833

3934
char
40-
hoptopt(ctx)
41-
struct h_context *ctx;
35+
hoptopt(struct h_context *ctx)
4236
{
4337
return ctx->optopt;
4438
}
@@ -55,10 +49,7 @@ hopterr(struct h_context *ctx, int val)
5549

5650

5751
struct h_opt *
58-
gethopt(ctx, opts, nropts)
59-
struct h_context *ctx;
60-
struct h_opt *opts;
61-
int nropts;
52+
gethopt(struct h_context *ctx, struct h_opt *opts, int nropts)
6253
{
6354
int i;
6455
int dashes;

0 commit comments

Comments
 (0)