summaryrefslogtreecommitdiffstats
path: root/development/opencomal/patches/02-vsprintf.diff
blob: 4f254064ddc96f2d26798516e4551f43f3f7f52f (about) (plain) (blame)
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
diff -Naur opencomal-0.2.6/src/pdcexec.c opencomal-0.2.6.patched/src/pdcexec.c
--- opencomal-0.2.6/src/pdcexec.c	2002-11-30 09:58:16.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcexec.c	2017-12-10 17:29:51.489206949 -0500
@@ -25,6 +25,7 @@
 #include "pdcexec.h"
 #include "pdcdsys.h"
 
+#include <stdarg.h>
 #include <fcntl.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -42,10 +43,13 @@
 
 PUBLIC void run_error(int error, char *s, ...)
 {
+	va_list ap;
 	char *buf;
 	char buf2[MAX_LINELEN];
 
-	vsprintf(buf2, s, (char *) &s + sizeof(s));
+	va_start(ap, s);
+	vsprintf(buf2, s, ap);
+	va_end(ap);
 
 	curenv->error = curenv->lasterr = error;
 	mem_free(curenv->lasterrmsg);
diff -Naur opencomal-0.2.6/src/pdcmisc.c opencomal-0.2.6.patched/src/pdcmisc.c
--- opencomal-0.2.6/src/pdcmisc.c	2017-12-10 17:23:13.344206273 -0500
+++ opencomal-0.2.6.patched/src/pdcmisc.c	2017-12-10 17:24:52.465206441 -0500
@@ -18,6 +18,7 @@
 #include "pdcexec.h"
 #include "pdclist.h"
 
+#include <stdarg.h>
 #include <string.h>
 #include <math.h>
 #include <fcntl.h>
@@ -58,9 +59,12 @@
 
 PUBLIC void my_printf(int stream, int newline, char *s, ...)
 {
+	va_list ap;
 	char buf[MAX_LINELEN];
 
-	vsprintf(buf, s, (char *) &s + sizeof(s));
+	va_start(ap, s);
+	vsprintf(buf, s, ap);
+	va_end(ap);
 	my_put(stream, buf, -1L);
 
 	if (newline)
@@ -70,9 +74,12 @@
 
 PUBLIC void fatal(char *s, ...)
 {
+	va_list ap;
 	char buf[140];
 
-	vsprintf(buf, s, (char *) &s + sizeof(s));
+	va_start(ap, s);
+	vsprintf(buf, s, ap);
+	va_end(ap);
 	my_printf(MSG_ERROR, 1, "FATAL error: %s", buf);
 
 	longjmp(RESTART, ERR_FATAL);
diff -Naur opencomal-0.2.6/src/pdcparss.c opencomal-0.2.6.patched/src/pdcparss.c
--- opencomal-0.2.6/src/pdcparss.c	2002-11-30 03:22:16.000000000 -0500
+++ opencomal-0.2.6.patched/src/pdcparss.c	2017-12-10 17:29:21.935206898 -0500
@@ -16,6 +16,8 @@
 #include "pdcstr.h"
 #include "pdcparss.h"
 
+#include <stdarg.h>
+
 PRIVATE int pars_error_happened = 0;
 PRIVATE char pars_errtxt[MAX_LINELEN];
 
@@ -282,11 +284,14 @@
 
 PUBLIC void pars_error(char *s, ...)
 {
+	va_list ap;
 	if (pars_error_happened)
 		return;
 
 	pars_error_happened = lex_pos();
-	vsprintf(pars_errtxt, s, (char *) &s + sizeof(s));
+	va_start(ap, s);
+	vsprintf(pars_errtxt, s, ap);
+	va_end(ap);
 }