Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
2fa33028
Commit
2fa33028
authored
27 years ago
by
Thomas G. Lockhart
Browse files
Options
Downloads
Patches
Plain Diff
Use limits.h for INT, SHRT, and SCHAR min and max values rather than
hardcoded values.
parent
174f984b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/utils/adt/numutils.c
+29
-7
29 additions, 7 deletions
src/backend/utils/adt/numutils.c
with
29 additions
and
7 deletions
src/backend/utils/adt/numutils.c
+
29
−
7
View file @
2fa33028
...
@@ -10,13 +10,16 @@
...
@@ -10,13 +10,16 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.1
6
1997/
09/18 20:22:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.1
7
1997/
11/17 16:26:27 thomas
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include
<stdio.h>
/* for sprintf() */
#include
<stdio.h>
/* for sprintf() */
#include
<errno.h>
#include
<errno.h>
#include
<math.h>
#include
<math.h>
#ifdef HAVE_LIMITS
#include
<limits.h>
#endif
#include
"postgres.h"
#include
"postgres.h"
#include
"utils/builtins.h"
/* where the declarations go */
#include
"utils/builtins.h"
/* where the declarations go */
#ifndef HAVE_MEMMOVE
#ifndef HAVE_MEMMOVE
...
@@ -26,6 +29,25 @@
...
@@ -26,6 +29,25 @@
#endif
#endif
#include
<port-protos.h>
/* ecvt(), fcvt() */
#include
<port-protos.h>
/* ecvt(), fcvt() */
#ifndef INT_MAX
#define INT_MAX (0x7FFFFFFFL)
#endif
#ifndef INT_MIN
#define INT_MIN (-0x80000000L)
#endif
#ifndef SHRT_MAX
#define SHRT_MAX (0x7FFF)
#endif
#ifndef SHRT_MIN
#define SHRT_MIN (-0x8000)
#endif
#ifndef SCHAR_MAX
#define SCHAR_MAX (0x7F)
#endif
#ifndef SCHAR_MIN
#define SCHAR_MIN (-0x80)
#endif
int32
int32
pg_atoi
(
char
*
s
,
int
size
,
int
c
)
pg_atoi
(
char
*
s
,
int
size
,
int
c
)
{
{
...
@@ -46,12 +68,12 @@ pg_atoi(char *s, int size, int c)
...
@@ -46,12 +68,12 @@ pg_atoi(char *s, int size, int c)
case
sizeof
(
int32
):
case
sizeof
(
int32
):
#ifdef HAS_LONG_LONG
#ifdef HAS_LONG_LONG
/* won't get ERANGE on these with 64-bit longs... */
/* won't get ERANGE on these with 64-bit longs... */
if
(
l
<
-
0x80000000L
)
if
(
l
<
INT_MIN
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
}
}
if
(
l
>
0x7fffffffL
)
if
(
l
>
INT_MAX
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
...
@@ -59,24 +81,24 @@ pg_atoi(char *s, int size, int c)
...
@@ -59,24 +81,24 @@ pg_atoi(char *s, int size, int c)
#endif
/* HAS_LONG_LONG */
#endif
/* HAS_LONG_LONG */
break
;
break
;
case
sizeof
(
int16
):
case
sizeof
(
int16
):
if
(
l
<
-
0x8000
)
if
(
l
<
SHRT_MIN
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
}
}
if
(
l
>
0x7fff
)
if
(
l
>
SHRT_MAX
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
}
}
break
;
break
;
case
sizeof
(
int8
):
case
sizeof
(
int8
):
if
(
l
<
-
0x80
)
if
(
l
<
SCHAR_MIN
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
}
}
if
(
l
>
0x7f
)
if
(
l
>
SCHAR_MAX
)
{
{
errno
=
ERANGE
;
errno
=
ERANGE
;
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
elog
(
WARN
,
"pg_atoi: error reading
\"
%s
\"
: %m"
,
s
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment