utils/*.c: K&R conversion to ANSI

This commit is contained in:
Darryl L. Miles 2025-01-06 16:14:34 +00:00
parent 07f9bbe1fb
commit d9cfd64d60
7 changed files with 139 additions and 148 deletions

View File

@ -53,10 +53,10 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
char * char *
ArgStr(pargc, pargv, argType) ArgStr(
int *pargc; int *pargc,
char ***pargv; char ***pargv,
const char *argType;/* For error messages: what the following string is const char *argType)/* For error messages: what the following string is
* supposed to be interpreted as. * supposed to be interpreted as.
*/ */
{ {

View File

@ -22,7 +22,7 @@
*------------------------------------------------------------------------*/ *------------------------------------------------------------------------*/
struct Wait_List { struct Wait_List {
int pid; int pid; /* FIXME pid_t */
int status; int status;
int pending; int pending;
struct Wait_List *next; struct Wait_List *next;
@ -30,11 +30,10 @@ struct Wait_List {
static struct Wait_List *wl = NULL; static struct Wait_List *wl = NULL;
static static void
void make_finished(
make_finished (pid, status) int pid,
int pid; int *status)
int *status;
{ {
struct Wait_List *l; struct Wait_List *l;
@ -50,10 +49,9 @@ make_finished (pid, status)
return; return;
} }
static static void
void add_pending_to_list(
add_pending_to_list (pid) int pid)
int pid;
{ {
struct Wait_List *l; struct Wait_List *l;
@ -66,11 +64,10 @@ add_pending_to_list (pid)
return; return;
} }
static static int
int find_pid(
find_pid (pid,status) int pid,
int pid; int *status)
int *status;
{ {
struct Wait_List *l; struct Wait_List *l;
l = wl; l = wl;
@ -84,10 +81,9 @@ find_pid (pid,status)
return -1; return -1;
} }
static static int
int get_next(
get_next (status) int *status)
int *status;
{ {
struct Wait_List *l, *prev; struct Wait_List *l, *prev;
int pid; int pid;
@ -111,10 +107,9 @@ get_next (status)
return -1; return -1;
} }
static static void
void delete_from_list(
delete_from_list (pid) int pid)
int pid;
{ {
struct Wait_List *l, *prev; struct Wait_List *l, *prev;
@ -159,8 +154,8 @@ delete_from_list (pid)
*/ */
int int
Wait (status) Wait(
int *status; int *status)
{ {
int pid; int pid;
int p_status = 0; int p_status = 0;
@ -208,9 +203,9 @@ Wait (status)
*/ */
int int
WaitPid (pid,status) WaitPid(
int pid; int pid,
int *status; int *status)
{ {
int stat; int stat;
int n_pid, n_status; int n_pid, n_status;
@ -254,8 +249,8 @@ WaitPid (pid,status)
*/ */
void void
ForkChildAdd (pid) ForkChildAdd(
int pid; int pid)
{ {
add_pending_to_list (pid); add_pending_to_list (pid);
} }

View File

@ -92,16 +92,15 @@ global const Point GeoOrigin = { 0, 0 };
*/ */
void void
GeoTransPoint(t, p1, p2) GeoTransPoint(
const Transform *t; /* A description of the mapping from the const Transform *t, /* A description of the mapping from the
* coordinate system of p1 to that of p2. * coordinate system of p1 to that of p2.
*/ */
const Point *p1; const Point *p1,
Point *p2; /* Pointers to two points; p1 is the old Point *p2) /* Pointers to two points) p1 is the old
* point, and p2 will contain the transformed * point, and p2 will contain the transformed
* point. * point.
*/ */
{ {
p2->p_x = p1->p_x*t->t_a + p1->p_y*t->t_b + t->t_c; p2->p_x = p1->p_x*t->t_a + p1->p_y*t->t_b + t->t_c;
p2->p_y = p1->p_x*t->t_d + p1->p_y*t->t_e + t->t_f; p2->p_y = p1->p_x*t->t_d + p1->p_y*t->t_e + t->t_f;
@ -127,16 +126,15 @@ GeoTransPoint(t, p1, p2)
*------------------------------------------------------------------- *-------------------------------------------------------------------
*/ */
void void
GeoTransPointDelta(t, p1, p2) GeoTransPointDelta(
const Transform *t; /* A description of the mapping from the const Transform *t, /* A description of the mapping from the
* coordinate system of p1 to that of p2. * coordinate system of p1 to that of p2.
*/ */
const Point *p1; const Point *p1,
Point *p2; /* Pointers to two points; p1 is the old Point *p2) /* Pointers to two points) p1 is the old
* point, and p2 will contain the transformed * point, and p2 will contain the transformed
* point. * point.
*/ */
{ {
p2->p_x = p1->p_x * t->t_a + p1->p_y * t->t_b; p2->p_x = p1->p_x * t->t_a + p1->p_y * t->t_b;
p2->p_y = p1->p_x * t->t_d + p1->p_y * t->t_e; p2->p_y = p1->p_x * t->t_d + p1->p_y * t->t_e;
@ -153,9 +151,9 @@ GeoTransPointDelta(t, p1, p2)
*/ */
int int
GeoTransAngle(t, a) GeoTransAngle(
const Transform *t; /* Transformation matrix */ const Transform *t, /* Transformation matrix */
int a; /* Angle to transform */ int a) /* Angle to transform */
{ {
bool flip = FALSE; bool flip = FALSE;
int asave = a; int asave = a;
@ -204,16 +202,15 @@ GeoTransAngle(t, a)
*/ */
void void
GeoTransRect(t, r1, r2) GeoTransRect(
const Transform *t; /* A description of the mapping from the const Transform *t, /* A description of the mapping from the
* coordinate system of r1 to that of r2. * coordinate system of r1 to that of r2.
*/ */
const Rect *r1; const Rect *r1,
Rect *r2; /* Pointers to two rectangles, r1 is the old Rect *r2) /* Pointers to two rectangles, r1 is the old
* rectangle, r2 will contain the transformed * rectangle, r2 will contain the transformed
* rectangle. * rectangle.
*/ */
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
x1 = r1->r_xbot*t->t_a + r1->r_ybot*t->t_b + t->t_c; x1 = r1->r_xbot*t->t_a + r1->r_ybot*t->t_b + t->t_c;
@ -260,10 +257,11 @@ GeoTransRect(t, r1, r2)
*/ */
void void
GeoTranslateTrans(trans1, x, y, trans2) GeoTranslateTrans(
const Transform *trans1; /* Transform to be translated */ const Transform *trans1, /* Transform to be translated */
int x, y; /* Amount by which to translated */ int x, /* Amount by which to translated */
Transform *trans2; /* Result transform */ int y,
Transform *trans2) /* Result transform */
{ {
trans2->t_a = trans1->t_a; trans2->t_a = trans1->t_a;
trans2->t_b = trans1->t_b; trans2->t_b = trans1->t_b;
@ -293,10 +291,11 @@ GeoTranslateTrans(trans1, x, y, trans2)
*/ */
void void
GeoTransTranslate(x, y, trans1, trans2) GeoTransTranslate(
int x, y; /* Amount of translation */ int x, /* Amount of translation */
const Transform *trans1; /* Transform to be applied to translation */ int y,
Transform *trans2; /* Result transform */ const Transform *trans1, /* Transform to be applied to translation */
Transform *trans2) /* Result transform */
{ {
trans2->t_a = trans1->t_a; trans2->t_a = trans1->t_a;
trans2->t_b = trans1->t_b; trans2->t_b = trans1->t_b;
@ -322,10 +321,10 @@ GeoTransTranslate(x, y, trans1, trans2)
*/ */
void void
GeoTransTrans(first, second, net) GeoTransTrans(
const Transform *first; /* Pointers to three transforms */ const Transform *first, /* Pointers to three transforms */
const Transform *second; const Transform *second,
Transform *net; Transform *net)
{ {
net->t_a = first->t_a*second->t_a + first->t_d*second->t_b; net->t_a = first->t_a*second->t_a + first->t_d*second->t_b;
net->t_b = first->t_b*second->t_a + first->t_e*second->t_b; net->t_b = first->t_b*second->t_a + first->t_e*second->t_b;
@ -351,12 +350,12 @@ GeoTransTrans(first, second, net)
*/ */
int int
GeoNameToPos(name, manhattan, verbose) GeoNameToPos(
const char *name; const char *name,
bool manhattan; /* If TRUE, only Manhattan directions (up, down, bool manhattan, /* If TRUE, only Manhattan directions (up, down,
* left, right, and their synonyms) are allowed. * left, right, and their synonyms) are allowed.
*/ */
bool verbose; /* If TRUE, we print an error message and list bool verbose) /* If TRUE, we print an error message and list
* valid directions. * valid directions.
*/ */
{ {
@ -464,8 +463,8 @@ GeoNameToPos(name, manhattan, verbose)
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
*/ */
const char * const char *
GeoPosToName(pos) GeoPosToName(
int pos; int pos)
{ {
switch(pos) switch(pos)
{ {
@ -495,10 +494,9 @@ GeoPosToName(pos)
*/ */
int int
GeoTransPos(t, pos) GeoTransPos(
const Transform *t; /* Transform to be applied. */ const Transform *t, /* Transform to be applied. */
int pos; /* Position to which it is to be applied. */ int pos) /* Position to which it is to be applied. */
{ {
if ((pos <= 0) || (pos > 8)) return pos; if ((pos <= 0) || (pos > 8)) return pos;
@ -551,9 +549,8 @@ enum def_orient {ORIENT_NORTH, ORIENT_SOUTH, ORIENT_EAST, ORIENT_WEST,
ORIENT_FLIPPED_WEST}; ORIENT_FLIPPED_WEST};
int int
GeoTransOrient(t) GeoTransOrient(
const Transform *t; /* Transform to be applied. */ const Transform *t) /* Transform to be applied. */
{ {
int pidx; int pidx;
@ -609,10 +606,9 @@ GeoTransOrient(t)
*/ */
void void
GeoInvertTrans(t, inverse) GeoInvertTrans(
const Transform *t; /* Pointer to a transform */ const Transform *t, /* Pointer to a transform */
Transform *inverse; /* Place to store the inverse */ Transform *inverse) /* Place to store the inverse */
{ {
Transform t2, t3; Transform t2, t3;
t2.t_a = t2.t_e = 1; t2.t_a = t2.t_e = 1;
@ -643,9 +639,9 @@ GeoInvertTrans(t, inverse)
*/ */
bool bool
GeoInclude(src, dst) GeoInclude(
const Rect *src; const Rect *src,
Rect *dst; Rect *dst)
{ {
int value; int value;
@ -700,9 +696,9 @@ GeoInclude(src, dst)
*/ */
bool bool
GeoIncludeAll(src, dst) GeoIncludeAll(
const Rect *src; const Rect *src,
Rect *dst; Rect *dst)
{ {
bool value; bool value;
@ -758,9 +754,9 @@ GeoIncludeAll(src, dst)
*/ */
void void
GeoIncludePoint(src, dst) GeoIncludePoint(
const Point *src; const Point *src,
Rect *dst; Rect *dst)
{ {
if ((dst->r_xbot > dst->r_xtop) || (dst->r_ybot > dst->r_ytop)) if ((dst->r_xbot > dst->r_xtop) || (dst->r_ybot > dst->r_ytop))
{ {
@ -788,9 +784,9 @@ GeoIncludePoint(src, dst)
*------------------------------------------------------------------- *-------------------------------------------------------------------
*/ */
void void
GeoIncludeRectInBBox(r, bbox) GeoIncludeRectInBBox(
const Rect *r; const Rect *r,
Rect *bbox; Rect *bbox)
{ {
bbox->r_xbot = MIN(bbox->r_xbot,r->r_xbot); bbox->r_xbot = MIN(bbox->r_xbot,r->r_xbot);
bbox->r_ybot = MIN(bbox->r_ybot,r->r_ybot); bbox->r_ybot = MIN(bbox->r_ybot,r->r_ybot);
@ -815,10 +811,9 @@ GeoIncludeRectInBBox(r, bbox)
*/ */
void void
GeoClip(r, area) GeoClip(
Rect *r; /* Rectangle to be clipped. */ Rect *r, /* Rectangle to be clipped. */
const Rect *area; /* Area against which to be clipped. */ const Rect *area) /* Area against which to be clipped. */
{ {
if (r->r_xbot < area->r_xbot) r->r_xbot = area->r_xbot; if (r->r_xbot < area->r_xbot) r->r_xbot = area->r_xbot;
if (r->r_ybot < area->r_ybot) r->r_ybot = area->r_ybot; if (r->r_ybot < area->r_ybot) r->r_ybot = area->r_ybot;
@ -839,9 +834,9 @@ GeoClip(r, area)
*/ */
void void
GeoClipPoint(p, area) GeoClipPoint(
Point *p; /* Point to be clipped. */ Point *p, /* Point to be clipped. */
const Rect *area; /* Area against which to be clipped. */ const Rect *area) /* Area against which to be clipped. */
{ {
if (p->p_x < area->r_xbot) p->p_x = area->r_xbot; if (p->p_x < area->r_xbot) p->p_x = area->r_xbot;
if (p->p_y < area->r_ybot) p->p_y = area->r_ybot; if (p->p_y < area->r_ybot) p->p_y = area->r_ybot;
@ -874,11 +869,11 @@ GeoClipPoint(p, area)
*/ */
bool bool
GeoDisjoint(area, clipBox, func, cdarg) GeoDisjoint(
Rect * area; Rect * area,
const Rect * clipBox; const Rect * clipBox,
bool (*func) (); bool (*func)(),
ClientData cdarg; ClientData cdarg)
{ {
Rect ok, rArea; Rect ok, rArea;
bool result; bool result;
@ -947,9 +942,9 @@ GeoDisjoint(area, clipBox, func, cdarg)
bool bool
GeoDummyFunc(box, cdarg) GeoDummyFunc(
const Rect *box; const Rect *box,
ClientData cdarg; ClientData cdarg)
{ {
return TRUE; return TRUE;
} }
@ -968,9 +963,9 @@ GeoDummyFunc(box, cdarg)
*/ */
void void
GeoCanonicalRect(r, rnew) GeoCanonicalRect(
const Rect *r; const Rect *r,
Rect *rnew; Rect *rnew)
{ {
if (r->r_xbot > r->r_xtop) if (r->r_xbot > r->r_xtop)
{ {
@ -1009,8 +1004,8 @@ GeoCanonicalRect(r, rnew)
*/ */
int int
GeoScale(t) GeoScale(
const Transform *t; const Transform *t)
{ {
int scale; int scale;
@ -1038,10 +1033,10 @@ GeoScale(t)
*/ */
void void
GeoScaleTrans(trans1, m, trans2) GeoScaleTrans(
const Transform *trans1; /* Transform to be scaled */ const Transform *trans1, /* Transform to be scaled */
int m; /* Amount by which to scale */ int m, /* Amount by which to scale */
Transform *trans2; /* Result transform */ Transform *trans2) /* Result transform */
{ {
trans2->t_a = trans1->t_a * m; trans2->t_a = trans1->t_a * m;
trans2->t_b = trans1->t_b * m; trans2->t_b = trans1->t_b * m;
@ -1066,9 +1061,9 @@ GeoScaleTrans(trans1, m, trans2)
*/ */
int int
GeoRectPointSide(r, p) GeoRectPointSide(
const Rect * r; const Rect * r,
const Point * p; const Point * p)
{ {
if(r->r_xbot == p->p_x) return GEO_WEST; if(r->r_xbot == p->p_x) return GEO_WEST;
else else
@ -1098,9 +1093,9 @@ GeoRectPointSide(r, p)
*/ */
int int
GeoRectRectSide(r0, r1) GeoRectRectSide(
const Rect * r0; const Rect * r0,
const Rect * r1; const Rect * r1)
{ {
if(r0->r_xbot == r1->r_xtop) return GEO_WEST; if(r0->r_xbot == r1->r_xtop) return GEO_WEST;
else else
@ -1131,12 +1126,12 @@ GeoRectRectSide(r0, r1)
*/ */
void void
GeoDecomposeTransform(t, upsidedown, angle) GeoDecomposeTransform(
const Transform *t; const Transform *t,
bool *upsidedown; /* Set to TRUE iff we should flip upsidedown bool *upsidedown, /* Set to TRUE iff we should flip upsidedown
* before rotating. * before rotating.
*/ */
int *angle; /* Amount to rotate. int *angle) /* Amount to rotate.
* Will be 0, 90, 180, or 270. * Will be 0, 90, 180, or 270.
*/ */
{ {

View File

@ -44,9 +44,9 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
bool bool
Match(pattern, string) Match(
const char *pattern; /* csh-like pattern. */ const char *pattern, /* csh-like pattern. */
const char *string; /* String to check for match against pattern.*/ const char *string) /* String to check for match against pattern.*/
{ {
char c2; char c2;

View File

@ -41,8 +41,8 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
*/ */
float float
MagAtof(s) MagAtof(
const char *s; const char *s)
{ {
#ifdef linux #ifdef linux
float flt; float flt;

View File

@ -76,9 +76,10 @@ int end;
*/ */
char * char *
RunStats(flags, lastt, deltat) RunStats(
int flags; int flags,
struct tms *lastt, *deltat; struct tms *lastt,
struct tms *deltat)
{ {
struct tms buffer; struct tms buffer;
static char string[100]; static char string[100];
@ -166,7 +167,7 @@ RunStats(flags, lastt, deltat)
*/ */
char * char *
RunStatsRealTime() RunStatsRealTime(void)
{ {
struct timeval curtime; struct timeval curtime;
static struct timeval firsttime, lasttime; static struct timeval firsttime, lasttime;

View File

@ -64,10 +64,10 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/
/* SetNoisyInt -- */ /* SetNoisyInt -- */
void void
SetNoisyInt(parm,valueS,file) SetNoisyInt(
int *parm; int *parm,
const char *valueS; const char *valueS,
FILE *file; FILE *file)
{ {
/* If value not null, set parm */ /* If value not null, set parm */
@ -96,10 +96,10 @@ SetNoisyInt(parm,valueS,file)
/* SetNoisyBool -- */ /* SetNoisyBool -- */
int int
SetNoisyBool(parm,valueS,file) SetNoisyBool(
bool *parm; bool *parm,
const char *valueS; const char *valueS,
FILE *file; FILE *file)
{ {
int n, which, result = -2; int n, which, result = -2;
@ -170,10 +170,10 @@ SetNoisyBool(parm,valueS,file)
/* SetNoisyDI -- */ /* SetNoisyDI -- */
/* double size non-negative integer */ /* double size non-negative integer */
void void
SetNoisyDI(parm,valueS,file) SetNoisyDI(
dlong *parm; /* BY NP */ dlong *parm, /* BY NP */
const char *valueS; const char *valueS,
FILE *file; FILE *file)
{ {
/* If value not null, set parm */ /* If value not null, set parm */
if (valueS) if (valueS)