*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.164 2005/12/01 21:11:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.165 2005/12/02 02:49:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (tzp == NULL)
return DTERR_BAD_FORMAT;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtol(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
char *cp;
int val;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtol(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
break;
}
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtol(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
*tmask = DTK_TIME_M;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
tm->tm_hour = strtol(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (*cp != ':')
return DTERR_BAD_FORMAT;
str = cp + 1;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
tm->tm_min = strtol(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
else
{
str = cp + 1;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
tm->tm_sec = strtol(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
*tmask = 0;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtol(str, &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
if (*str != '+' && *str != '-')
return DTERR_BAD_FORMAT;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
hr = strtol(str + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_TZDISP_OVERFLOW;
/* explicit delimiter? */
if (*cp == ':')
{
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
min = strtol(cp + 1, &cp, 10);
if (errno == ERANGE)
return DTERR_TZDISP_OVERFLOW;
case DTK_DATE:
case DTK_NUMBER:
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtol(field[i], &cp, 10);
if (errno == ERANGE)
return DTERR_FIELD_OVERFLOW;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.118 2005/12/01 21:11:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.119 2005/12/02 02:49:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
while (*num != '\0' && isspace((unsigned char) *num))
num++;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtod(num, &endptr);
/* did we not see anything that looks like a double? */
while (*num != '\0' && isspace((unsigned char) *num))
num++;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
val = strtod(num, &endptr);
/* did we not see anything that looks like a double? */
* We must check both for errno getting set and for a NaN result, in order
* to deal with the vagaries of different platforms...
*/
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = pow(arg1, arg2);
if (errno != 0
#ifdef HAVE_FINITE
* to deal with the vagaries of different platforms. Also, a zero result
* implies unreported underflow.
*/
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = exp(arg1);
if (errno != 0 || result == 0.0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = acos(arg1);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = asin(arg1);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = atan(arg1);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg2 = PG_GETARG_FLOAT8(1);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = atan2(arg1, arg2);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = cos(arg1);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = tan(arg1);
if (errno != 0 || result == 0.0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = sin(arg1);
if (errno != 0
#ifdef HAVE_FINITE
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
result = tan(arg1);
if (errno != 0
#ifdef HAVE_FINITE
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.71 2005/12/01 21:16:13 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/numutils.c,v 1.72 2005/12/02 02:49:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
errmsg("invalid input syntax for integer: \"%s\"",
s)));
- errno = 0; /* avoid having to check the result for failure */
+ errno = 0;
l = strtol(s, &badp, 10);
/* We made no progress parsing the string, so bail out */
#define const
+/*
+ * Usage Tip:
+ *
+ * strtol() doesn't give a unique return value to indicate that errno
+ * should be consulted, so in most cases it is best to set errno = 0
+ * before calling this function, and then errno != 0 can be tested
+ * after the function completes.
+ */
+
/*
* Convert a string to a long integer.
*