Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c28f9c

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 parameterdeclarations, improving sprintf() usage, etc.)Neil Conway
1 parent15ce2d2 commit3c28f9c

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
externDatumint44out(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
inti;
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
returnDatumGetPathP(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
externDatumpt_in_widget(PG_FUNCTION_ARGS);
224223

225224
#defineNARGS3
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
returnresult;
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
returnnew_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)

[8]ページ先頭

©2009-2025 Movatter.jp