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

Commita1f5851

Browse files
committed
Replace ad-hoc atof() code with call to float4in, per Andrew Dunstan.
1 parent85b2fac commita1f5851

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

‎contrib/seg/expected/seg.out

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ SELECT '1 e7'::seg AS seg;
418418
ERROR: bad seg representation
419419
DETAIL: syntax error at or near "e"
420420
SELECT '1e700'::seg AS seg;
421-
ERROR: syntax error
422-
DETAIL: numeric value 1e700 unrepresentable
421+
ERROR: "1e700" is out of range for type real
423422
--
424423
-- testing the operators
425424
--

‎contrib/seg/segparse.y

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include<math.h>
77

8+
#include"fmgr.h"
9+
#include"utils/builtins.h"
810
#include"segdata.h"
911

1012
#undef yylex/* failure to redefine yylex will result in calling the*/
@@ -129,22 +131,13 @@ deviation:
129131
%%
130132

131133

132-
floatseg_atof (char *value ) {
133-
float result;
134-
char *buf = (char *)palloc(256);
134+
float
135+
seg_atof(char *value)
136+
{
137+
Datum datum;
135138

136-
errno =0;
137-
sscanf(value,"%f", &result);
138-
139-
if ( errno ) {
140-
snprintf(buf,256,"numeric value %s unrepresentable", value);
141-
ereport(ERROR,
142-
(errcode(ERRCODE_SYNTAX_ERROR),
143-
errmsg("syntax error"),
144-
errdetail("%s", buf)));
145-
}
146-
147-
return result;
139+
datum =DirectFunctionCall1(float4in,CStringGetDatum(value));
140+
returnDatumGetFloat4(datum);
148141
}
149142

150143

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp