|
From: Nicholas N. <nj...@ca...> - 2004-06-02 20:43:29
|
CVS commit by nethercote:
Fix wishlist item 82098, thanks to Ralf Wildenhues:
ANSIfication of the hp2ps code. The most important changes are the correct
use of the stdarg mechanism (former hacks could bite on other systems, so
please tell upstream), inclusion of stdlib.h instead of declaring free
yourself, adding a few missed PROTO()s and using size_t for xmalloc and
xrealloc.:
M +1 -2 AreaBelow.c 1.3
M +2 -1 Curves.c 1.3
M +1 -2 Deviation.c 1.3
M +14 -10 Error.c 1.3 [POSSIBLY UNSAFE: printf]
M +3 -3 Error.h 1.3
M +1 -2 Scale.c 1.3
M +1 -2 TopTwenty.c 1.3
M +1 -2 TraceElement.c 1.3
M +2 -2 Utilities.c 1.4
M +2 -2 Utilities.h 1.3
--- valgrind/massif/hp2ps/AreaBelow.c #1.2:1.3
@@ -4,4 +4,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "Main.h"
#include "Defines.h"
@@ -13,6 +14,4 @@
#include "AreaBelow.h"
-extern void free();
-
/*
* Return the area enclosed by all of the curves. The algorithm
--- valgrind/massif/hp2ps/Curves.c #1.2:1.3
@@ -21,5 +21,6 @@ static floatish *g_py; /* previous y va
static void Curve PROTO((struct entry *)); /* forward */
-static void ShadeCurve(); /* forward */
+static void ShadeCurve
+ PROTO((floatish *x, floatish *y, floatish *py, floatish shade));
void
--- valgrind/massif/hp2ps/Deviation.c #1.2:1.3
@@ -4,4 +4,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -12,6 +13,4 @@
#include "Utilities.h"
-extern void free();
-
/* own stuff */
#include "Deviation.h"
--- valgrind/massif/hp2ps/Error.c #1.2:1.3
@@ -3,5 +3,7 @@
This program is governed by the license contained in the file LICENSE. */
+#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include "Main.h"
#include "Defines.h"
@@ -10,14 +12,14 @@
#include "Error.h"
-void exit PROTO((int));
-
/*VARARGS0*/
void
-Error(a1,a2,a3,a4)
- char* a1; char* a2; char* a3; char* a4;
+Error(const char *fmt, ...)
{
+ va_list ap;
fflush(stdout);
fprintf(stderr, "%s: ", programname);
- fprintf(stderr, a1, a2, a3, a4);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
fprintf(stderr, "\n");
exit(1);
@@ -26,11 +28,13 @@ Error(a1,a2,a3,a4)
/*VARARGS0*/
void
-Disaster(a1,a2,a3,a4)
- char* a1; char* a2; char* a3; char* a4;
+Disaster(const char *fmt, ...)
{
+ va_list ap;
fflush(stdout);
fprintf(stderr, "%s: ", programname);
fprintf(stderr, " Disaster! (");
- fprintf(stderr, a1, a2, a3, a4);
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
fprintf(stderr, ")\n");
exit(1);
@@ -39,5 +43,5 @@ Disaster(a1,a2,a3,a4)
void
Usage(str)
- char *str;
+ const char *str;
{
if (str) printf("error: %s\n", str);
--- valgrind/massif/hp2ps/Error.h #1.2:1.3
@@ -6,7 +6,7 @@
#define ERROR_H
-extern void Error (); /*PROTO((char *, ...)); */
-extern void Disaster (); /* PROTO((char *, ...)); */
-extern void Usage (); /* PROTO((char *)); */
+extern void Error PROTO((const char *, ...));
+extern void Disaster PROTO((const char *, ...));
+extern void Usage PROTO((const char *));
#endif /* ERROR_H */
--- valgrind/massif/hp2ps/Scale.c #1.2:1.3
@@ -4,4 +4,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "Main.h"
#include "Defines.h"
@@ -21,6 +22,4 @@
*/
-extern void free();
-
floatish
MaxCombinedHeight()
--- valgrind/massif/hp2ps/TopTwenty.c #1.2:1.3
@@ -4,4 +4,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "Main.h"
#include "Defines.h"
@@ -22,6 +23,4 @@
*/
-extern void free();
-
void
TopTwenty()
--- valgrind/massif/hp2ps/TraceElement.c #1.2:1.3
@@ -4,4 +4,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include "Main.h"
#include "Defines.h"
@@ -21,6 +22,4 @@
*/
-extern void free();
-
extern floatish thresholdpercent;
--- valgrind/massif/hp2ps/Utilities.c #1.3:1.4
@@ -84,5 +84,5 @@ CommaPrint(fp,n)
void *
xmalloc(n)
- int n;
+ size_t n;
{
void *r;
@@ -99,5 +99,5 @@ void *
xrealloc(p, n)
void *p;
- int n;
+ size_t n;
{
void *r;
--- valgrind/massif/hp2ps/Utilities.h #1.2:1.3
@@ -12,6 +12,6 @@ void CommaPrint PROTO((FILE *, intish)
char *copystring PROTO((char *));
char *copystring2 PROTO((char *, char *));
-void *xmalloc PROTO((int));
-void *xrealloc PROTO((void *, int));
+void *xmalloc PROTO((size_t));
+void *xrealloc PROTO((void *, size_t));
#endif /* UTILITIES_H */
|