Skip to content

Commit 3c28f9c

Browse files
committed
This trivial cleans up a little bit of the code in
src/test/regress/regress.c (e.g. removing K & R style parameter declarations, improving sprintf() usage, etc.) Neil Conway
1 parent 15ce2d2 commit 3c28f9c

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/test/regress/regress.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.54 2002/11/13 00:39:48 momjian Exp $
2+
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.55 2003/03/20 04:52:35 momjian Exp $
33
*/
44

55
#include "postgres.h"
@@ -30,8 +30,8 @@ extern Datum int44in(PG_FUNCTION_ARGS);
3030
extern Datum int44out(PG_FUNCTION_ARGS);
3131

3232
/*
33-
** Distance from a point to a path
34-
*/
33+
* Distance from a point to a path
34+
*/
3535
PG_FUNCTION_INFO_V1(regress_dist_ptpath);
3636

3737
Datum
@@ -72,8 +72,10 @@ regress_dist_ptpath(PG_FUNCTION_ARGS)
7272
PG_RETURN_FLOAT8(result);
7373
}
7474

75-
/* this essentially does a cartesian product of the lsegs in the
76-
two paths, and finds the min distance between any two lsegs */
75+
/*
76+
* this essentially does a cartesian product of the lsegs in the
77+
* two paths, and finds the min distance between any two lsegs
78+
*/
7779
PG_FUNCTION_INFO_V1(regress_path_dist);
7880

7981
Datum
@@ -114,8 +116,7 @@ regress_path_dist(PG_FUNCTION_ARGS)
114116
}
115117

116118
PATH *
117-
poly2path(poly)
118-
POLYGON *poly;
119+
poly2path(POLYGON *poly)
119120
{
120121
int i;
121122
char *output = (char *) palloc(2 * (P_MAXDIG + 1) * poly->npts + 64);
@@ -125,11 +126,12 @@ POLYGON *poly;
125126

126127
for (i = 0; i < poly->npts; i++)
127128
{
128-
sprintf(buf, ",%*g,%*g", P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
129+
snprintf(buf, sizeof(buf), ",%*g,%*g",
130+
P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
129131
strcat(output, buf);
130132
}
131133

132-
sprintf(buf, "%c", RDELIM);
134+
snprintf(buf, sizeof(buf), "%c", RDELIM);
133135
strcat(output, buf);
134136
return DatumGetPathP(DirectFunctionCall1(path_in,
135137
CStringGetDatum(output)));
@@ -180,10 +182,7 @@ interpt_pp(PG_FUNCTION_ARGS)
180182

181183
/* like lseg_construct, but assume space already allocated */
182184
void
183-
regress_lseg_construct(lseg, pt1, pt2)
184-
LSEG *lseg;
185-
Point *pt1;
186-
Point *pt2;
185+
regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
187186
{
188187
lseg->p[0].x = pt1->x;
189188
lseg->p[0].y = pt1->y;
@@ -219,14 +218,13 @@ typedef struct
219218
} WIDGET;
220219

221220
WIDGET *widget_in(char *str);
222-
char *widget_out(WIDGET * widget);
221+
char *widget_out(WIDGET *widget);
223222
extern Datum pt_in_widget(PG_FUNCTION_ARGS);
224223

225224
#define NARGS 3
226225

227226
WIDGET *
228-
widget_in(str)
229-
char *str;
227+
widget_in(char *str)
230228
{
231229
char *p,
232230
*coord[NARGS],
@@ -246,14 +244,13 @@ char *str;
246244
result->center.y = atof(coord[1]);
247245
result->radius = atof(coord[2]);
248246

249-
sprintf(buf2, "widget_in: read (%f, %f, %f)\n", result->center.x,
250-
result->center.y, result->radius);
247+
snprintf(buf2, sizeof(buf2), "widget_in: read (%f, %f, %f)\n",
248+
result->center.x, result->center.y, result->radius);
251249
return result;
252250
}
253251

254252
char *
255-
widget_out(widget)
256-
WIDGET *widget;
253+
widget_out(WIDGET *widget)
257254
{
258255
char *result;
259256

@@ -315,7 +312,8 @@ reverse_name(char *string)
315312
return new_string;
316313
}
317314

318-
/* This rather silly function is just to test that oldstyle functions
315+
/*
316+
* This rather silly function is just to test that oldstyle functions
319317
* work correctly on toast-able inputs.
320318
*/
321319
int

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy