aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/scat
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2009-04-30 11:35:25 -0700
committerRuss Cox <rsc@swtch.com>2009-04-30 11:35:25 -0700
commit347aa646fc86fca426d5f9de95884bb68f133b9a (patch)
tree122e1371d2e711057e4e69f3a61b223ff234ce75 /src/cmd/scat
parent122fda5913bc6bf993bbc73202a55e4cbd7f9c4d (diff)
downloadplan9port-347aa646fc86fca426d5f9de95884bb68f133b9a.tar.gz
plan9port-347aa646fc86fca426d5f9de95884bb68f133b9a.tar.bz2
plan9port-347aa646fc86fca426d5f9de95884bb68f133b9a.zip
scat: make 64-bit safe
Diffstat (limited to 'src/cmd/scat')
-rw-r--r--src/cmd/scat/dssread.c4
-rw-r--r--src/cmd/scat/patch.c4
-rw-r--r--src/cmd/scat/plate.h2
-rw-r--r--src/cmd/scat/plot.c20
-rw-r--r--src/cmd/scat/scat.c50
-rw-r--r--src/cmd/scat/sky.h32
6 files changed, 57 insertions, 55 deletions
diff --git a/src/cmd/scat/dssread.c b/src/cmd/scat/dssread.c
index 06f0135e..bd72132a 100644
--- a/src/cmd/scat/dssread.c
+++ b/src/cmd/scat/dssread.c
@@ -4,7 +4,7 @@
#include "sky.h"
static void dodecode(Biobuf*, Pix*, int, int, uchar*);
-static long getlong(uchar*);
+static int32 getlong(uchar*);
int debug;
Img*
@@ -107,7 +107,7 @@ dodecode(Biobuf *infile, Pix *a, int nx, int ny, uchar *nbitplanes)
}
static
-long getlong(uchar *p)
+int32 getlong(uchar *p)
{
return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
}
diff --git a/src/cmd/scat/patch.c b/src/cmd/scat/patch.c
index 27d04edb..583a7c7d 100644
--- a/src/cmd/scat/patch.c
+++ b/src/cmd/scat/patch.c
@@ -35,7 +35,7 @@ radec(int p, int *rah, int *ram, int *deg)
(*deg)++;
}
-long
+int32
patcha(Angle ra, Angle dec)
{
ra = DEG(ra);
@@ -61,7 +61,7 @@ char round[91]={ /* extra 0 is to offset the array */
/* 90 */
};
-long
+int32
patch(int rah, int ram, int deg)
{
int ra, dec;
diff --git a/src/cmd/scat/plate.h b/src/cmd/scat/plate.h
index f2786f63..b4c5b3fd 100644
--- a/src/cmd/scat/plate.h
+++ b/src/cmd/scat/plate.h
@@ -90,7 +90,7 @@ struct Header
float xi;
float eta;
};
-typedef long Type;
+typedef int32 Type;
typedef struct Image Image;
struct Image
diff --git a/src/cmd/scat/plot.c b/src/cmd/scat/plot.c
index e0020282..ade4ac5b 100644
--- a/src/cmd/scat/plot.c
+++ b/src/cmd/scat/plot.c
@@ -10,8 +10,8 @@
#include "sky.h"
/* convert to milliarcsec */
-static long c = MILLIARCSEC; /* 1 degree */
-static long m5 = 1250*60*60; /* 5 minutes of ra */
+static int32 c = MILLIARCSEC; /* 1 degree */
+static int32 m5 = 1250*60*60; /* 5 minutes of ra */
DAngle ramin;
DAngle ramax;
@@ -40,8 +40,8 @@ Image *cometcolor;
Planetrec *planet;
-long mapx0, mapy0;
-long mapra, mapdec;
+int32 mapx0, mapy0;
+int32 mapra, mapdec;
double mylat, mylon, mysid;
double mapscale;
double maps;
@@ -235,7 +235,7 @@ heavens(double zlatdeg, double zlondeg, double clatdeg, double clondeg))(struct
}
int
-maptoxy(long ra, long dec, double *x, double *y)
+maptoxy(int32 ra, int32 dec, double *x, double *y)
{
double lat, lon;
struct place pl;
@@ -255,7 +255,7 @@ maptoxy(long ra, long dec, double *x, double *y)
/* end of 'heavens' section */
int
-setmap(long ramin, long ramax, long decmin, long decmax, Rectangle r, int zenithup)
+setmap(int32 ramin, int32 ramax, int32 decmin, int32 decmax, Rectangle r, int zenithup)
{
int c;
double minx, maxx, miny, maxy;
@@ -298,7 +298,7 @@ setmap(long ramin, long ramax, long decmin, long decmax, Rectangle r, int zenith
}
Point
-map(long ra, long dec)
+map(int32 ra, int32 dec)
{
double x, y;
Point p;
@@ -456,7 +456,7 @@ tolast(char *name)
}
int
-bbox(long extrara, long extradec, int quantize)
+bbox(int32 extrara, int32 extradec, int quantize)
{
int i;
Record *r;
@@ -566,7 +566,7 @@ inbbox(DAngle ra, DAngle dec)
}
int
-gridra(long mapdec)
+gridra(int32 mapdec)
{
mapdec = abs(mapdec)+c/2;
mapdec /= c;
@@ -586,7 +586,7 @@ plot(char *flags)
{
int i, j, k;
char *t;
- long x, y;
+ int32 x, y;
int ra, dec;
int m;
Point p, pts[10];
diff --git a/src/cmd/scat/scat.c b/src/cmd/scat/scat.c
index f8c1ee6e..26bea1c3 100644
--- a/src/cmd/scat/scat.c
+++ b/src/cmd/scat/scat.c
@@ -26,9 +26,9 @@ char ngctype[NNGCrec];
Mindexrec mindex[NMrec];
Namerec name[NName];
Bayerec bayer[NBayer];
-long con[MAXcon];
+int32 con[MAXcon];
ushort conindex[Ncon+1];
-long patchaddr[Npatch+1];
+int32 patchaddr[Npatch+1];
Record *rec;
Record *orec;
@@ -46,10 +46,10 @@ int condb;
int conindexdb;
int patchdb;
char parsed[3];
-long nrec;
-long nreca;
-long norec;
-long noreca;
+int32 nrec;
+int32 nreca;
+int32 norec;
+int32 noreca;
Biobuf bin;
Biobuf bout;
@@ -132,7 +132,7 @@ eopen(char *s)
void
-Eread(int f, char *name, void *addr, long n)
+Eread(int f, char *name, void *addr, int32 n)
{
if(read(f, addr, n) != n){ /* BUG! */
fprint(2, "scat: read error on %s\n", name);
@@ -156,17 +156,17 @@ skipstr(char *s, char *t)
return skipbl(s);
}
-/* produce little-endian long at address l */
-long
-Long(long *l)
+/* produce little-endian int32 at address l */
+int32
+Long(int32 *l)
{
uchar *p;
p = (uchar*)l;
- return (long)p[0]|((long)p[1]<<8)|((long)p[2]<<16)|((long)p[3]<<24);
+ return (int32)p[0]|((int32)p[1]<<8)|((int32)p[2]<<16)|((int32)p[3]<<24);
}
-/* produce little-endian long at address l */
+/* produce little-endian int32 at address l */
int
Short(short *s)
{
@@ -254,7 +254,7 @@ void
patchopen(void)
{
Biobuf *b;
- long l, m;
+ int32 l, m;
char buf[100];
if(patchdb == 0){
@@ -309,10 +309,10 @@ lowercase(char *s)
}
int
-loadngc(long index)
+loadngc(int32 index)
{
static int failed;
- long j;
+ int32 j;
ngcopen();
j = (index-1)*sizeof(NGCrec);
@@ -343,9 +343,9 @@ loadngc(long index)
}
int
-loadabell(long index)
+loadabell(int32 index)
{
- long j;
+ int32 j;
abellopen();
j = index-1;
@@ -408,7 +408,7 @@ loadplanet(int index, Record *r)
}
int
-loadpatch(long index)
+loadpatch(int32 index)
{
int i;
@@ -446,7 +446,7 @@ flatten(void)
{
int i, j, notflat;
Record *or;
- long key;
+ int32 key;
loop:
copy();
@@ -759,7 +759,7 @@ coords(int deg)
int i;
int x, y;
Record *or;
- long dec, ra, ndec, nra;
+ int32 dec, ra, ndec, nra;
int rdeg;
flatten();
@@ -807,7 +807,7 @@ coords(int deg)
int i;
int x, y, xx;
Record *or;
- long min, circle;
+ int32 min, circle;
double factor;
flatten();
@@ -853,11 +853,11 @@ void
pplate(char *flags)
{
int i;
- long c;
+ int32 c;
int na, rah, ram, d1, d2;
double r0;
int ra, dec;
- long ramin, ramax, decmin, decmax; /* all in degrees */
+ int32 ramin, ramax, decmin, decmax; /* all in degrees */
Record *r;
int folded;
Angle racenter, deccenter, rasize, decsize, a[4];
@@ -1006,7 +1006,7 @@ lookup(char *s, int doreset)
char *starts, *inputline=s, *t, *u;
Record *r;
Rune c;
- long n;
+ int32 n;
double x;
Angle ra;
@@ -1526,7 +1526,7 @@ prrec(Record *r)
Abellrec *a;
Planetrec *p;
int i, rah, ram, dec, nn;
- long key;
+ int32 key;
if(r) switch(r->type){
default:
diff --git a/src/cmd/scat/sky.h b/src/cmd/scat/sky.h
index 53045853..158dd1c7 100644
--- a/src/cmd/scat/sky.h
+++ b/src/cmd/scat/sky.h
@@ -1,3 +1,5 @@
+typedef s32int int32;
+
#define DIR "#9/sky"
/*
* This code reflects many years of changes. There remain residues
@@ -135,9 +137,9 @@ enum
#define NPlanet 20
typedef float Angle; /* in radians */
-typedef long DAngle; /* on disk: in units of milliarcsec */
+typedef int32 DAngle; /* on disk: in units of milliarcsec */
typedef short Mag; /* multiplied by 10 */
-typedef long Key; /* known to be 4 bytes, unfortunately */
+typedef int32 Key; /* known to be 4 bytes, unfortunately */
/*
* All integers are stored in little-endian order.
@@ -203,7 +205,7 @@ struct SAOrec{
char compid[2];
char hdcode;
char pad1;
- long hd; /* HD catalog number */
+ int32 hd; /* HD catalog number */
char name[3]; /* name[0]=alpha name[1]=2 name[3]=ori */
char nname; /* number of prose names */
/* 36 bytes to here */
@@ -218,7 +220,7 @@ struct Mindexrec{ /* code knows the bit patterns in here; this is a long */
typedef struct Bayerec Bayerec;
struct Bayerec{
- long sao;
+ int32 sao;
char name[3];
char pad;
};
@@ -234,22 +236,22 @@ struct Namedrec{
typedef struct Namerec Namerec;
struct Namerec{
- long sao;
- long ngc;
- long abell;
+ int32 sao;
+ int32 ngc;
+ int32 abell;
char name[36]; /* null terminated */
};
typedef struct Patchrec Patchrec;
struct Patchrec{
int nkey;
- long key[60];
+ int32 key[60];
};
typedef struct Record Record;
struct Record{
Type type;
- long index;
+ int32 index;
union{
SAOrec sao;
NGCrec ngc;
@@ -287,7 +289,7 @@ struct Header
float xi;
float eta;
};
-typedef long Pix;
+typedef int32 Pix;
typedef struct Img Img;
struct Img
@@ -340,7 +342,7 @@ extern char *progname;
extern char *desctab[][2];
extern Name names[];
extern Record *rec;
-extern long nrec;
+extern int32 nrec;
extern Planetrec *planet;
/* for bbox: */
extern int folded;
@@ -365,8 +367,8 @@ extern int equal(char*, char*);
extern int parsename(char*);
extern void radec(int, int*, int*, int*);
extern int btag(short);
-extern long patcha(Angle, Angle);
-extern long patch(int, int, int);
+extern int32 patcha(Angle, Angle);
+extern int32 patch(int, int, int);
extern char*hms(Angle);
extern char*dms(Angle);
extern char*ms(Angle);
@@ -374,7 +376,7 @@ extern char*hm(Angle);
extern char*dm(Angle);
extern char*deg(Angle);
extern char*hm5(Angle);
-extern long dangle(Angle);
+extern int32 dangle(Angle);
extern Angle angle(DAngle);
extern void prdesc(char*, char*(*)[2], short*);
extern double xsqrt(double);
@@ -406,7 +408,7 @@ extern void astro(char*, int);
extern char* alpha(char*, char*);
extern char* skipbl(char*);
extern void flatten(void);
-extern int bbox(long, long, int);
+extern int bbox(int32, int32, int);
extern int inbbox(DAngle, DAngle);
extern char* nameof(Record*);