diff options
Diffstat (limited to 'src/test/regress/regress.c')
-rw-r--r-- | src/test/regress/regress.c | 198 |
1 files changed, 99 insertions, 99 deletions
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index ceace603781..d6b2fe246f6 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.10 1997/09/07 05:04:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.11 1997/09/08 02:40:56 momjian Exp $ */ #include <float.h> /* faked on sunos */ @@ -16,74 +16,74 @@ #define RDELIM ')' #define DELIM ',' -typedef void *TUPLE; +typedef void *TUPLE; -extern double *regress_dist_ptpath(Point * pt, PATH * path); -extern double *regress_path_dist(PATH * p1, PATH * p2); -extern PATH *poly2path(POLYGON * poly); -extern Point *interpt_pp(PATH * p1, PATH * p2); -extern void regress_lseg_construct(LSEG * lseg, Point * pt1, Point * pt2); -extern char overpaid(TUPLE tuple); -extern int boxarea(BOX * box); -extern char *reverse_c16(char *string); +extern double *regress_dist_ptpath(Point * pt, PATH * path); +extern double *regress_path_dist(PATH * p1, PATH * p2); +extern PATH *poly2path(POLYGON * poly); +extern Point *interpt_pp(PATH * p1, PATH * p2); +extern void regress_lseg_construct(LSEG * lseg, Point * pt1, Point * pt2); +extern char overpaid(TUPLE tuple); +extern int boxarea(BOX * box); +extern char *reverse_c16(char *string); /* ** Distance from a point to a path */ -double * +double * regress_dist_ptpath(pt, path) -Point *pt; -PATH *path; +Point *pt; +PATH *path; { - double *result; - double *tmp; - int i; - LSEG lseg; + double *result; + double *tmp; + int i; + LSEG lseg; switch (path->npts) { - case 0: - result = PALLOCTYPE(double); - *result = Abs((double) DBL_MAX); /* +infinity */ - break; - case 1: - result = point_distance(pt, &path->p[0]); - break; - default: - - /* - * the distance from a point to a path is the smallest distance - * from the point to any of its constituent segments. - */ - Assert(path->npts > 1); - result = PALLOCTYPE(double); - for (i = 0; i < path->npts - 1; ++i) - { - regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]); - tmp = dist_ps(pt, &lseg); - if (i == 0 || *tmp < *result) - *result = *tmp; - PFREE(tmp); - - } - break; + case 0: + result = PALLOCTYPE(double); + *result = Abs((double) DBL_MAX); /* +infinity */ + break; + case 1: + result = point_distance(pt, &path->p[0]); + break; + default: + + /* + * the distance from a point to a path is the smallest + * distance from the point to any of its constituent segments. + */ + Assert(path->npts > 1); + result = PALLOCTYPE(double); + for (i = 0; i < path->npts - 1; ++i) + { + regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]); + tmp = dist_ps(pt, &lseg); + if (i == 0 || *tmp < *result) + *result = *tmp; + PFREE(tmp); + + } + break; } return (result); } /* this essentially does a cartesian product of the lsegs in the two paths, and finds the min distance between any two lsegs */ -double * +double * regress_path_dist(p1, p2) -PATH *p1; -PATH *p2; +PATH *p1; +PATH *p2; { - double *min, - *tmp; - int i, - j; - LSEG seg1, - seg2; + double *min, + *tmp; + int i, + j; + LSEG seg1, + seg2; regress_lseg_construct(&seg1, &p1->p[0], &p1->p[1]); regress_lseg_construct(&seg2, &p2->p[0], &p2->p[1]); @@ -103,13 +103,13 @@ PATH *p2; return (min); } -PATH * +PATH * poly2path(poly) -POLYGON *poly; +POLYGON *poly; { - int i; - char *output = (char *) PALLOC(2 * (P_MAXDIG + 1) * poly->npts + 64); - char buf[2 * (P_MAXDIG) + 20]; + int i; + char *output = (char *) PALLOC(2 * (P_MAXDIG + 1) * poly->npts + 64); + char buf[2 * (P_MAXDIG) + 20]; sprintf(output, "(1, %*d", P_MAXDIG, poly->npts); @@ -125,23 +125,23 @@ POLYGON *poly; } /* return the point where two paths intersect. Assumes that they do. */ -Point * +Point * interpt_pp(p1, p2) -PATH *p1; -PATH *p2; +PATH *p1; +PATH *p2; { - Point *retval; - int i, - j; - LSEG seg1, - seg2; + Point *retval; + int i, + j; + LSEG seg1, + seg2; #if FALSE - LINE *ln; + LINE *ln; #endif - bool found; /* We've found the intersection */ + bool found; /* We've found the intersection */ found = false; /* Haven't found it yet */ @@ -167,9 +167,9 @@ PATH *p2; /* like lseg_construct, but assume space already allocated */ void regress_lseg_construct(lseg, pt1, pt2) -LSEG *lseg; -Point *pt1; -Point *pt2; +LSEG *lseg; +Point *pt1; +Point *pt2; { lseg->p[0].x = pt1->x; lseg->p[0].y = pt1->y; @@ -181,10 +181,10 @@ Point *pt2; char overpaid(tuple) -TUPLE tuple; +TUPLE tuple; { - bool isnull; - long salary; + bool isnull; + long salary; salary = (long) GetAttributeByName(tuple, "salary", &isnull); return (salary > 699); @@ -197,25 +197,25 @@ TUPLE tuple; typedef struct { - Point center; - double radius; -} WIDGET; + Point center; + double radius; +} WIDGET; -WIDGET *widget_in(char *str); -char *widget_out(WIDGET * widget); -int pt_in_widget(Point * point, WIDGET * widget); +WIDGET *widget_in(char *str); +char *widget_out(WIDGET * widget); +int pt_in_widget(Point * point, WIDGET * widget); #define NARGS 3 -WIDGET * +WIDGET * widget_in(str) -char *str; +char *str; { - char *p, - *coord[NARGS], - buf2[1000]; - int i; - WIDGET *result; + char *p, + *coord[NARGS], + buf2[1000]; + int i; + WIDGET *result; if (str == NULL) return (NULL); @@ -234,11 +234,11 @@ char *str; return (result); } -char * +char * widget_out(widget) -WIDGET *widget; +WIDGET *widget; { - char *result; + char *result; if (widget == NULL) return (NULL); @@ -251,10 +251,10 @@ WIDGET *widget; int pt_in_widget(point, widget) -Point *point; -WIDGET *widget; +Point *point; +WIDGET *widget; { - extern double point_dt(); + extern double point_dt(); return (point_dt(point, &widget->center) < widget->radius); } @@ -264,24 +264,24 @@ WIDGET *widget; int boxarea(box) -BOX *box; +BOX *box; { - int width, - height; + int width, + height; width = ABS(box->high.x - box->low.x); height = ABS(box->high.y - box->low.y); return (width * height); } -char * +char * reverse_c16(string) -char *string; +char *string; { - register i; - int len; - char *new_string; + register i; + int len; + char *new_string; if (!(new_string = palloc(16))) { |