1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Replace ad-hoc atof() code with call to float4in, per Andrew Dunstan.

This commit is contained in:
Tom Lane
2004-10-24 21:47:07 +00:00
parent 85b2facdd8
commit a1f585139b
2 changed files with 9 additions and 17 deletions

View File

@ -5,6 +5,8 @@
#include <math.h>
#include "fmgr.h"
#include "utils/builtins.h"
#include "segdata.h"
#undef yylex /* failure to redefine yylex will result in calling the */
@ -129,22 +131,13 @@ deviation:
%%
float seg_atof ( char *value ) {
float result;
char *buf = (char *) palloc(256);
float
seg_atof(char *value)
{
Datum datum;
errno = 0;
sscanf(value, "%f", &result);
if ( errno ) {
snprintf(buf, 256, "numeric value %s unrepresentable", value);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"),
errdetail("%s", buf)));
}
return result;
datum = DirectFunctionCall1(float4in, CStringGetDatum(value));
return DatumGetFloat4(datum);
}