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

Commitcf17131

Browse files
committed
Remove comment on errno=0 lines, but add mention to port/strtol.c function.
1 parentde1dfc1 commitcf17131

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

‎src/backend/utils/adt/datetime.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.164 2005/12/01 21:11:58 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.165 2005/12/02 02:49:11 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1013,7 +1013,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
10131013
if (tzp==NULL)
10141014
returnDTERR_BAD_FORMAT;
10151015

1016-
errno=0;/* avoid having to check the result for failure */
1016+
errno=0;
10171017
val=strtol(field[i],&cp,10);
10181018
if (errno==ERANGE)
10191019
returnDTERR_FIELD_OVERFLOW;
@@ -1161,7 +1161,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
11611161
char*cp;
11621162
intval;
11631163

1164-
errno=0;/* avoid having to check the result for failure */
1164+
errno=0;
11651165
val=strtol(field[i],&cp,10);
11661166
if (errno==ERANGE)
11671167
returnDTERR_FIELD_OVERFLOW;
@@ -1921,7 +1921,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19211921
break;
19221922
}
19231923

1924-
errno=0;/* avoid having to check the result for failure */
1924+
errno=0;
19251925
val=strtol(field[i],&cp,10);
19261926
if (errno==ERANGE)
19271927
returnDTERR_FIELD_OVERFLOW;
@@ -2465,14 +2465,14 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
24652465

24662466
*tmask=DTK_TIME_M;
24672467

2468-
errno=0;/* avoid having to check the result for failure */
2468+
errno=0;
24692469
tm->tm_hour=strtol(str,&cp,10);
24702470
if (errno==ERANGE)
24712471
returnDTERR_FIELD_OVERFLOW;
24722472
if (*cp!=':')
24732473
returnDTERR_BAD_FORMAT;
24742474
str=cp+1;
2475-
errno=0;/* avoid having to check the result for failure */
2475+
errno=0;
24762476
tm->tm_min=strtol(str,&cp,10);
24772477
if (errno==ERANGE)
24782478
returnDTERR_FIELD_OVERFLOW;
@@ -2486,7 +2486,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct pg_tm * tm, fsec_t *fsec)
24862486
else
24872487
{
24882488
str=cp+1;
2489-
errno=0;/* avoid having to check the result for failure */
2489+
errno=0;
24902490
tm->tm_sec=strtol(str,&cp,10);
24912491
if (errno==ERANGE)
24922492
returnDTERR_FIELD_OVERFLOW;
@@ -2540,7 +2540,7 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
25402540

25412541
*tmask=0;
25422542

2543-
errno=0;/* avoid having to check the result for failure */
2543+
errno=0;
25442544
val=strtol(str,&cp,10);
25452545
if (errno==ERANGE)
25462546
returnDTERR_FIELD_OVERFLOW;
@@ -2830,15 +2830,15 @@ DecodeTimezone(char *str, int *tzp)
28302830
if (*str!='+'&&*str!='-')
28312831
returnDTERR_BAD_FORMAT;
28322832

2833-
errno=0;/* avoid having to check the result for failure */
2833+
errno=0;
28342834
hr=strtol(str+1,&cp,10);
28352835
if (errno==ERANGE)
28362836
returnDTERR_TZDISP_OVERFLOW;
28372837

28382838
/* explicit delimiter? */
28392839
if (*cp==':')
28402840
{
2841-
errno=0;/* avoid having to check the result for failure */
2841+
errno=0;
28422842
min=strtol(cp+1,&cp,10);
28432843
if (errno==ERANGE)
28442844
returnDTERR_TZDISP_OVERFLOW;
@@ -3085,7 +3085,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
30853085

30863086
caseDTK_DATE:
30873087
caseDTK_NUMBER:
3088-
errno=0;/* avoid having to check the result for failure */
3088+
errno=0;
30893089
val=strtol(field[i],&cp,10);
30903090
if (errno==ERANGE)
30913091
returnDTERR_FIELD_OVERFLOW;

‎src/backend/utils/adt/float.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.118 2005/12/01 21:11:58 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.119 2005/12/02 02:49:11 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -278,7 +278,7 @@ float4in(PG_FUNCTION_ARGS)
278278
while (*num!='\0'&&isspace((unsignedchar)*num))
279279
num++;
280280

281-
errno=0;/* avoid having to check the result for failure */
281+
errno=0;
282282
val=strtod(num,&endptr);
283283

284284
/* did we not see anything that looks like a double? */
@@ -445,7 +445,7 @@ float8in(PG_FUNCTION_ARGS)
445445
while (*num!='\0'&&isspace((unsignedchar)*num))
446446
num++;
447447

448-
errno=0;/* avoid having to check the result for failure */
448+
errno=0;
449449
val=strtod(num,&endptr);
450450

451451
/* did we not see anything that looks like a double? */
@@ -1476,7 +1476,7 @@ dpow(PG_FUNCTION_ARGS)
14761476
* We must check both for errno getting set and for a NaN result, in order
14771477
* to deal with the vagaries of different platforms...
14781478
*/
1479-
errno=0;/* avoid having to check the result for failure */
1479+
errno=0;
14801480
result=pow(arg1,arg2);
14811481
if (errno!=0
14821482
#ifdefHAVE_FINITE
@@ -1506,7 +1506,7 @@ dexp(PG_FUNCTION_ARGS)
15061506
* to deal with the vagaries of different platforms. Also, a zero result
15071507
* implies unreported underflow.
15081508
*/
1509-
errno=0;/* avoid having to check the result for failure */
1509+
errno=0;
15101510
result=exp(arg1);
15111511
if (errno!=0||result==0.0
15121512
#ifdefHAVE_FINITE
@@ -1590,7 +1590,7 @@ dacos(PG_FUNCTION_ARGS)
15901590
float8arg1=PG_GETARG_FLOAT8(0);
15911591
float8result;
15921592

1593-
errno=0;/* avoid having to check the result for failure */
1593+
errno=0;
15941594
result=acos(arg1);
15951595
if (errno!=0
15961596
#ifdefHAVE_FINITE
@@ -1615,7 +1615,7 @@ dasin(PG_FUNCTION_ARGS)
16151615
float8arg1=PG_GETARG_FLOAT8(0);
16161616
float8result;
16171617

1618-
errno=0;/* avoid having to check the result for failure */
1618+
errno=0;
16191619
result=asin(arg1);
16201620
if (errno!=0
16211621
#ifdefHAVE_FINITE
@@ -1640,7 +1640,7 @@ datan(PG_FUNCTION_ARGS)
16401640
float8arg1=PG_GETARG_FLOAT8(0);
16411641
float8result;
16421642

1643-
errno=0;/* avoid having to check the result for failure */
1643+
errno=0;
16441644
result=atan(arg1);
16451645
if (errno!=0
16461646
#ifdefHAVE_FINITE
@@ -1666,7 +1666,7 @@ datan2(PG_FUNCTION_ARGS)
16661666
float8arg2=PG_GETARG_FLOAT8(1);
16671667
float8result;
16681668

1669-
errno=0;/* avoid having to check the result for failure */
1669+
errno=0;
16701670
result=atan2(arg1,arg2);
16711671
if (errno!=0
16721672
#ifdefHAVE_FINITE
@@ -1691,7 +1691,7 @@ dcos(PG_FUNCTION_ARGS)
16911691
float8arg1=PG_GETARG_FLOAT8(0);
16921692
float8result;
16931693

1694-
errno=0;/* avoid having to check the result for failure */
1694+
errno=0;
16951695
result=cos(arg1);
16961696
if (errno!=0
16971697
#ifdefHAVE_FINITE
@@ -1716,7 +1716,7 @@ dcot(PG_FUNCTION_ARGS)
17161716
float8arg1=PG_GETARG_FLOAT8(0);
17171717
float8result;
17181718

1719-
errno=0;/* avoid having to check the result for failure */
1719+
errno=0;
17201720
result=tan(arg1);
17211721
if (errno!=0||result==0.0
17221722
#ifdefHAVE_FINITE
@@ -1742,7 +1742,7 @@ dsin(PG_FUNCTION_ARGS)
17421742
float8arg1=PG_GETARG_FLOAT8(0);
17431743
float8result;
17441744

1745-
errno=0;/* avoid having to check the result for failure */
1745+
errno=0;
17461746
result=sin(arg1);
17471747
if (errno!=0
17481748
#ifdefHAVE_FINITE
@@ -1767,7 +1767,7 @@ dtan(PG_FUNCTION_ARGS)
17671767
float8arg1=PG_GETARG_FLOAT8(0);
17681768
float8result;
17691769

1770-
errno=0;/* avoid having to check the result for failure */
1770+
errno=0;
17711771
result=tan(arg1);
17721772
if (errno!=0
17731773
#ifdefHAVE_FINITE

‎src/backend/utils/adt/numutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.71 2005/12/01 21:16:13 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.72 2005/12/02 02:49:11 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -73,7 +73,7 @@ pg_atoi(char *s, int size, int c)
7373
errmsg("invalid input syntax for integer: \"%s\"",
7474
s)));
7575

76-
errno=0;/* avoid having to check the result for failure */
76+
errno=0;
7777
l=strtol(s,&badp,10);
7878

7979
/* We made no progress parsing the string, so bail out */

‎src/port/strtol.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ static char sccsid[] = "@(#)strtol.c5.4 (Berkeley) 2/23/91";
4444

4545
#defineconst
4646

47+
/*
48+
*Usage Tip:
49+
*
50+
*strtol() doesn't give a unique return value to indicate that errno
51+
*should be consulted, so in most cases it is best to set errno = 0
52+
*before calling this function, and then errno != 0 can be tested
53+
*after the function completes.
54+
*/
55+
4756
/*
4857
* Convert a string to a long integer.
4958
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp