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
|
$NetBSD: patch-trans_c,v 1.1 2011/12/18 16:54:09 dholland Exp $
- fix symbol conflict with logf (from math.h)
- fix wrong printf formats
- don't try to use sbrk() to figure the heap size
--- trans.c.orig 1991-04-24 20:30:37.000000000 +0000
+++ trans.c
@@ -551,17 +551,17 @@ Static void openlogfile()
if (!name)
name = format_s("%s.log", codefname);
saveoldfile(name);
- logf = fopen(name, "w");
- if (logf) {
- fprintf(logf, "\nTranslation of %s to %s by p2c %s\n",
+ loggf = fopen(name, "w");
+ if (loggf) {
+ fprintf(loggf, "\nTranslation of %s to %s by p2c %s\n",
infname, codefname, P2C_VERSION);
- fprintf(logf, "Translated");
+ fprintf(loggf, "Translated");
uname = getenv("USER");
if (uname)
- fprintf(logf, " by %s", uname);
+ fprintf(loggf, " by %s", uname);
time(&starting_time);
- fprintf(logf, " on %s", ctime(&starting_time));
- fprintf(logf, "\n\n");
+ fprintf(loggf, " on %s", ctime(&starting_time));
+ fprintf(loggf, "\n\n");
} else {
perror(name);
verbose = 0;
@@ -573,18 +573,18 @@ void closelogfile()
{
long ending_time;
- if (logf) {
- fprintf(logf, "\n\n");
-#if defined(unix) || defined(__unix)
- fprintf(logf, "Total memory used: %ld bytes.\n", (long)sbrk(0));
+ if (loggf) {
+ fprintf(loggf, "\n\n");
+#if 0
+ fprintf(loggf, "Total memory used: %ld bytes.\n", (long)sbrk(0));
#endif
time(&ending_time);
- fprintf(logf, "Processed %d source lines in %ld:%ld seconds.\n",
+ fprintf(loggf, "Processed %d source lines in %ld:%ld seconds.\n",
inf_ltotal,
(ending_time - starting_time) / 60,
(ending_time - starting_time) % 60);
- fprintf(logf, "\n\nTranslation completed on %s", ctime(&ending_time));
- fclose(logf);
+ fprintf(loggf, "\n\nTranslation completed on %s", ctime(&ending_time));
+ fclose(loggf);
}
}
@@ -833,7 +833,7 @@ char **argv;
setbuf(codef, NULL); /* for debugging */
outf = codef;
outf_lnum = 1;
- logf = NULL;
+ loggf = NULL;
if (verbose)
openlogfile();
setup_complete = 0;
@@ -1000,12 +1000,12 @@ Type *tp;
return;
}
if (ISBOGUS(tp)) {
- fprintf(outf, "0x%lX\n", tp);
+ fprintf(outf, "%p\n", tp);
return;
}
- fprintf(outf, " Type %lx, kind=%s", tp, typekindname(tp->kind));
+ fprintf(outf, " Type %p, kind=%s", tp, typekindname(tp->kind));
#ifdef HASDUMPS
- fprintf(outf, ", meaning=%lx, basetype=%lx, indextype=%lx\n",
+ fprintf(outf, ", meaning=%p, basetype=%p, indextype=%p\n",
tp->meaning, tp->basetype, tp->indextype);
tp->dumped = 1;
if (tp->basetype)
@@ -1026,13 +1026,13 @@ Meaning *mp;
return;
}
if (ISBOGUS(mp)) {
- fprintf(outf, "0x%lX\n", mp);
+ fprintf(outf, "%p\n", mp);
return;
}
- fprintf(outf, " Meaning %lx, name=%s, kind=%s", mp, ((mp->name) ? mp->name : "<null>"),
+ fprintf(outf, " Meaning %p, name=%s, kind=%s", mp, ((mp->name) ? mp->name : "<null>"),
meaningkindname(mp->kind));
#ifdef HASDUMPS
- fprintf(outf, ", ctx=%lx, cbase=%lx, cnext=%lx, type=%lx\n",
+ fprintf(outf, ", ctx=%p, cbase=%p, cnext=%p, type=%p\n",
mp->ctx, mp->cbase, mp->cnext, mp->type);
if (mp->type && !mp->type->dumped)
dumptype(mp->type);
@@ -1077,7 +1077,7 @@ int waddr;
return;
}
if (ISBOGUS(tp)) {
- fprintf(outf, "0x%lX", tp);
+ fprintf(outf, "%p", tp);
return;
}
if (tp == tp_int) fprintf(outf, "I");
@@ -1117,7 +1117,7 @@ int waddr;
waddr = 1;
}
if (waddr) {
- fprintf(outf, "%lX", tp);
+ fprintf(outf, "%p", tp);
if (tp->dumped)
return;
fprintf(outf, ":");
@@ -1251,7 +1251,7 @@ Expr *ex;
return;
}
if (ISBOGUS(ex)) {
- fprintf(outf, "0x%lX", ex);
+ fprintf(outf, "p", ex);
return;
}
if (ex->kind == EK_CONST && ex->val.type == tp_integer &&
@@ -1291,7 +1291,7 @@ Expr *ex;
}
}
if (ISBOGUS(ex->val.s))
- fprintf(outf, "[0x%lX]", ex->val.s);
+ fprintf(outf, "[%p]", ex->val.s);
else if (ex->val.s) {
switch (ex->kind) {
@@ -1310,7 +1310,7 @@ Expr *ex;
fprintf(outf, "[s=%s]", ex->val.s);
break;
default:
- fprintf(outf, "[s=%lx]", ex->val.s);
+ fprintf(outf, "[s=%p]", ex->val.s);
}
break;
}
@@ -1353,7 +1353,7 @@ int indent;
}
while (sp) {
if (ISBOGUS(sp)) {
- fprintf(outf, "0x%lX\n", sp);
+ fprintf(outf, "%p\n", sp);
return;
}
fprintf(outf, "%s", stmtkindname(sp->kind));
|