[project @ 2002-11-11 11:18:39 by simonmar]
authorsimonmar <unknown>
Mon, 11 Nov 2002 11:18:39 +0000 (11:18 +0000)
committersimonmar <unknown>
Mon, 11 Nov 2002 11:18:39 +0000 (11:18 +0000)
Increase the size of many of the int variables used in hp2ps to 64
bits on a 32 bit machine, since they can easily overflow if the
program runs for a few seconds.

Fortunately there was a useful typedef to change - I couldn't be
bothered figuring out exactly which variables to make wider, and the
performance of hp2ps isn't really critical anyhow (this change makes
it about 30% slower, but who cares).

ghc/utils/hp2ps/AuxFile.c
ghc/utils/hp2ps/Axes.c
ghc/utils/hp2ps/Main.c
ghc/utils/hp2ps/Main.h
ghc/utils/hp2ps/Makefile
ghc/utils/hp2ps/PsFile.c
ghc/utils/hp2ps/Shade.c
ghc/utils/hp2ps/Utilities.c
ghc/utils/hp2ps/Utilities.h

index a6088eb..e5ce090 100644 (file)
@@ -150,7 +150,7 @@ void
 PutAuxFile(auxfp)
   FILE* auxfp;
 {
-    intish i;
+    int i;
 
     fprintf(auxfp, "X_RANGE %.2f\n", xrange);
     fprintf(auxfp, "Y_RANGE %.2f\n", yrange);
index ddd2bbf..0733edd 100644 (file)
@@ -107,17 +107,17 @@ YAxisMark(y, num, unit)
     switch (unit) {
     case MEGABYTE :
        fprintf(psfp, "(");
-       CommaPrint(psfp, (int) (num / 1e6 + 0.5));
+       CommaPrint(psfp, (intish) (num / 1e6 + 0.5));
        fprintf(psfp, "M)\n");
        break;
     case KILOBYTE :
        fprintf(psfp, "(");
-       CommaPrint(psfp, (int) (num / 1e3 + 0.5));
+       CommaPrint(psfp, (intish) (num / 1e3 + 0.5));
        fprintf(psfp, "k)\n");
        break;
     case BYTE:
        fprintf(psfp, "(");
-       CommaPrint(psfp, (int) (num + 0.5));
+       CommaPrint(psfp, (intish) (num + 0.5));
        fprintf(psfp, ")\n");
        break;
     }
index 2e2c3cc..e1cfe63 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 #include "AuxFile.h"
 #include "Error.h"
 #include "Utilities.h"
 
-#ifndef atof
-double atof PROTO((char *));
-#endif
-
 boolish pflag = 0;     /* read auxiliary file                  */
 boolish eflag = 0;     /* scaled EPSF                          */ 
 boolish dflag = 0;     /* sort by standard deviation           */
index b0d4bf4..efe520e 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MAIN_H
 #define MAIN_H
 
+#include "config.h"
+
 #ifdef __STDC__
 #define PROTO(x)       x
 #else
@@ -27,9 +29,17 @@ void _ghcAssert PROTO((char *, unsigned int));
 */
 typedef double floatish;
 typedef double  doublish; /* higher precision, if anything; little used */
-typedef long   intish;
 typedef int    boolish;
 
+/* Use "long long" if we have it: the numbers in profiles can easily
+ * overflow 32 bits after a few seconds execution.
+ */
+#ifdef HAVE_LONG_LONG
+typedef long long int intish;
+#else
+typedef long int intish;
+#endif
+
 extern intish nsamples;
 extern intish nmarks;
 extern intish nidents;
index 878c51b..18cb05b 100644 (file)
@@ -1,10 +1,10 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
-C_SRCS  = $(wildcard *.c)
-H_SRCS  = $(wildcard *.h)
 C_PROG         = hp2ps
 
+SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall
+
 INSTALL_PROGS += $(C_PROG)
 
 LIBS        = $(LIBM)
index b2040f1..5286ad9 100644 (file)
@@ -212,7 +212,7 @@ BigTitleText()
     fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
     fprintf(psfp, "%f %f moveto\n", x, y);
     fputc('(', psfp);
-    CommaPrint(psfp, (int) areabelow);
+    CommaPrint(psfp, (intish)areabelow);
     fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring); 
     fprintf(psfp, "show\n");
 
@@ -248,7 +248,7 @@ TitleText()
  
     fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT);
     fputc('(', psfp);
-    CommaPrint(psfp, (int) areabelow);
+    CommaPrint(psfp, (intish) areabelow);
     fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring);
  
     fprintf(psfp, "dup stringwidth pop\n");
index f7e517b..e898027 100644 (file)
@@ -97,8 +97,6 @@ ThinkOfAShade()
 {
     static int thisshade = -1;
 
-    floatish x;
-
     thisshade++;
     return cflag ?
        c_shades[ thisshade % N_COLOUR_SHADES ] :
index c6faca4..57d20b1 100644 (file)
@@ -67,13 +67,13 @@ OpenFile(s, mode)
 void
 CommaPrint(fp,n)
   FILE* fp;
-  int n;
+  intish n;
 {
     if (n < ONETHOUSAND) {
-        fprintf(fp, "%d", n);
+        fprintf(fp, "%d", (int)n);
     } else {
         CommaPrint(fp, n / ONETHOUSAND);
-        fprintf(fp, ",%03d", n % ONETHOUSAND);
+        fprintf(fp, ",%03d", (int)n % ONETHOUSAND);
     }
 }
 
index d6e9a17..bffc87d 100644 (file)
@@ -4,7 +4,7 @@
 char* Basename    PROTO((char *));
 void  DropSuffix  PROTO((char *, char *));
 FILE* OpenFile    PROTO((char *, char *));
-void  CommaPrint  PROTO((FILE *, int));
+void  CommaPrint  PROTO((FILE *, intish));
 char *copystring  PROTO((char *));
 char *copystring2 PROTO((char *, char *));
 void *xmalloc   PROTO((int));