summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test/regress/regress.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index be76f7dc416..697b39aae3a 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -243,25 +243,27 @@ WIDGET *
widget_in(char *str)
{
char *p,
- *coord[NARGS],
- buf2[1000];
+ *coord[NARGS];
int i;
WIDGET *result;
- if (str == NULL)
- return NULL;
for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
- if (*p == ',' || (*p == LDELIM && !i))
+ {
+ if (*p == DELIM || (*p == LDELIM && i == 0))
coord[i++] = p + 1;
- if (i < NARGS - 1)
- return NULL;
+ }
+
+ if (i < NARGS)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+ errmsg("invalid input syntax for type widget: \"%s\"",
+ str)));
+
result = (WIDGET *) palloc(sizeof(WIDGET));
result->center.x = atof(coord[0]);
result->center.y = atof(coord[1]);
result->radius = atof(coord[2]);
- snprintf(buf2, sizeof(buf2), "widget_in: read (%f, %f, %f)\n",
- result->center.x, result->center.y, result->radius);
return result;
}
@@ -270,12 +272,9 @@ widget_out(WIDGET * widget)
{
char *result;
- if (widget == NULL)
- return NULL;
-
- result = (char *) palloc(60);
- sprintf(result, "(%g,%g,%g)",
- widget->center.x, widget->center.y, widget->radius);
+ result = (char *) palloc(100);
+ snprintf(result, 100, "(%g,%g,%g)",
+ widget->center.x, widget->center.y, widget->radius);
return result;
}