mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Move strtoint() to common
Several places used similar code to convert a string to an int, so take the function that we already had and make it globally available. Reviewed-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include "access/htup_details.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "common/string.h"
|
||||
#include "funcapi.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
@ -251,23 +252,6 @@ static const datetkn *deltacache[MAXDATEFIELDS] = {NULL};
|
||||
static const datetkn *abbrevcache[MAXDATEFIELDS] = {NULL};
|
||||
|
||||
|
||||
/*
|
||||
* strtoint --- just like strtol, but returns int not long
|
||||
*/
|
||||
static int
|
||||
strtoint(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
long val;
|
||||
|
||||
val = strtol(nptr, endptr, base);
|
||||
#ifdef HAVE_LONG_INT_64
|
||||
if (val != (long) ((int32) val))
|
||||
errno = ERANGE;
|
||||
#endif
|
||||
return (int) val;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calendar time to Julian date conversions.
|
||||
* Julian date is commonly used in astronomical applications,
|
||||
|
Reference in New Issue
Block a user