Commit 3c28f9c1 authored by Bruce Momjian's avatar Bruce Momjian

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
parent 15ce2d2e
/* /*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.54 2002/11/13 00:39:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.55 2003/03/20 04:52:35 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -30,8 +30,8 @@ extern Datum int44in(PG_FUNCTION_ARGS); ...@@ -30,8 +30,8 @@ extern Datum int44in(PG_FUNCTION_ARGS);
extern Datum int44out(PG_FUNCTION_ARGS); extern Datum int44out(PG_FUNCTION_ARGS);
/* /*
** Distance from a point to a path * Distance from a point to a path
*/ */
PG_FUNCTION_INFO_V1(regress_dist_ptpath); PG_FUNCTION_INFO_V1(regress_dist_ptpath);
Datum Datum
...@@ -72,8 +72,10 @@ regress_dist_ptpath(PG_FUNCTION_ARGS) ...@@ -72,8 +72,10 @@ regress_dist_ptpath(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8(result); PG_RETURN_FLOAT8(result);
} }
/* this essentially does a cartesian product of the lsegs in the /*
two paths, and finds the min distance between any two lsegs */ * this essentially does a cartesian product of the lsegs in the
* two paths, and finds the min distance between any two lsegs
*/
PG_FUNCTION_INFO_V1(regress_path_dist); PG_FUNCTION_INFO_V1(regress_path_dist);
Datum Datum
...@@ -114,8 +116,7 @@ regress_path_dist(PG_FUNCTION_ARGS) ...@@ -114,8 +116,7 @@ regress_path_dist(PG_FUNCTION_ARGS)
} }
PATH * PATH *
poly2path(poly) poly2path(POLYGON *poly)
POLYGON *poly;
{ {
int i; int i;
char *output = (char *) palloc(2 * (P_MAXDIG + 1) * poly->npts + 64); char *output = (char *) palloc(2 * (P_MAXDIG + 1) * poly->npts + 64);
...@@ -125,11 +126,12 @@ POLYGON *poly; ...@@ -125,11 +126,12 @@ POLYGON *poly;
for (i = 0; i < poly->npts; i++) for (i = 0; i < poly->npts; i++)
{ {
sprintf(buf, ",%*g,%*g", P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y); snprintf(buf, sizeof(buf), ",%*g,%*g",
P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
strcat(output, buf); strcat(output, buf);
} }
sprintf(buf, "%c", RDELIM); snprintf(buf, sizeof(buf), "%c", RDELIM);
strcat(output, buf); strcat(output, buf);
return DatumGetPathP(DirectFunctionCall1(path_in, return DatumGetPathP(DirectFunctionCall1(path_in,
CStringGetDatum(output))); CStringGetDatum(output)));
...@@ -180,10 +182,7 @@ interpt_pp(PG_FUNCTION_ARGS) ...@@ -180,10 +182,7 @@ interpt_pp(PG_FUNCTION_ARGS)
/* like lseg_construct, but assume space already allocated */ /* like lseg_construct, but assume space already allocated */
void void
regress_lseg_construct(lseg, pt1, pt2) regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2)
LSEG *lseg;
Point *pt1;
Point *pt2;
{ {
lseg->p[0].x = pt1->x; lseg->p[0].x = pt1->x;
lseg->p[0].y = pt1->y; lseg->p[0].y = pt1->y;
...@@ -219,14 +218,13 @@ typedef struct ...@@ -219,14 +218,13 @@ typedef struct
} WIDGET; } WIDGET;
WIDGET *widget_in(char *str); WIDGET *widget_in(char *str);
char *widget_out(WIDGET * widget); char *widget_out(WIDGET *widget);
extern Datum pt_in_widget(PG_FUNCTION_ARGS); extern Datum pt_in_widget(PG_FUNCTION_ARGS);
#define NARGS 3 #define NARGS 3
WIDGET * WIDGET *
widget_in(str) widget_in(char *str)
char *str;
{ {
char *p, char *p,
*coord[NARGS], *coord[NARGS],
...@@ -246,14 +244,13 @@ char *str; ...@@ -246,14 +244,13 @@ char *str;
result->center.y = atof(coord[1]); result->center.y = atof(coord[1]);
result->radius = atof(coord[2]); result->radius = atof(coord[2]);
sprintf(buf2, "widget_in: read (%f, %f, %f)\n", result->center.x, snprintf(buf2, sizeof(buf2), "widget_in: read (%f, %f, %f)\n",
result->center.y, result->radius); result->center.x, result->center.y, result->radius);
return result; return result;
} }
char * char *
widget_out(widget) widget_out(WIDGET *widget)
WIDGET *widget;
{ {
char *result; char *result;
...@@ -315,7 +312,8 @@ reverse_name(char *string) ...@@ -315,7 +312,8 @@ reverse_name(char *string)
return new_string; return new_string;
} }
/* This rather silly function is just to test that oldstyle functions /*
* This rather silly function is just to test that oldstyle functions
* work correctly on toast-able inputs. * work correctly on toast-able inputs.
*/ */
int int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment