66#include <ctype.h>
77#include <math.h>
88
9+ #include "common/string.h"
910#include "pgtypeslib_extern.h"
1011#include "dt.h"
1112#include "pgtypes_timestamp.h"
@@ -1110,7 +1111,7 @@ DecodeNumberField(int len, char *str, int fmask,
11101111 for (i = 0 ; i < 6 ; i ++ )
11111112 fstr [i ] = * cp != '\0' ? * cp ++ : '0' ;
11121113 fstr [i ] = '\0' ;
1113- * fsec = strtol (fstr , NULL , 10 );
1114+ * fsec = strtoint (fstr , NULL , 10 );
11141115 * cp = '\0' ;
11151116 len = strlen (str );
11161117 }
@@ -1201,7 +1202,7 @@ DecodeNumber(int flen, char *str, int fmask,
12011202
12021203 * tmask = 0 ;
12031204
1204- val = strtol (str , & cp , 10 );
1205+ val = strtoint (str , & cp , 10 );
12051206 if (cp == str )
12061207 return -1 ;
12071208
@@ -1437,11 +1438,11 @@ DecodeTime(char *str, int *tmask, struct tm *tm, fsec_t *fsec)
14371438
14381439 * tmask = DTK_TIME_M ;
14391440
1440- tm -> tm_hour = strtol (str , & cp , 10 );
1441+ tm -> tm_hour = strtoint (str , & cp , 10 );
14411442 if (* cp != ':' )
14421443 return -1 ;
14431444 str = cp + 1 ;
1444- tm -> tm_min = strtol (str , & cp , 10 );
1445+ tm -> tm_min = strtoint (str , & cp , 10 );
14451446 if (* cp == '\0' )
14461447 {
14471448 tm -> tm_sec = 0 ;
@@ -1452,7 +1453,7 @@ DecodeTime(char *str, int *tmask, struct tm *tm, fsec_t *fsec)
14521453 else
14531454 {
14541455 str = cp + 1 ;
1455- tm -> tm_sec = strtol (str , & cp , 10 );
1456+ tm -> tm_sec = strtoint (str , & cp , 10 );
14561457 if (* cp == '\0' )
14571458 * fsec = 0 ;
14581459 else if (* cp == '.' )
@@ -1473,7 +1474,7 @@ DecodeTime(char *str, int *tmask, struct tm *tm, fsec_t *fsec)
14731474 for (i = 0 ; i < 6 ; i ++ )
14741475 fstr [i ] = * cp != '\0' ? * cp ++ : '0' ;
14751476 fstr [i ] = '\0' ;
1476- * fsec = strtol (fstr , & cp , 10 );
1477+ * fsec = strtoint (fstr , & cp , 10 );
14771478 if (* cp != '\0' )
14781479 return -1 ;
14791480 }
@@ -1505,20 +1506,20 @@ DecodeTimezone(char *str, int *tzp)
15051506 int len ;
15061507
15071508 /* assume leading character is "+" or "-" */
1508- hr = strtol (str + 1 , & cp , 10 );
1509+ hr = strtoint (str + 1 , & cp , 10 );
15091510
15101511 /* explicit delimiter? */
15111512 if (* cp == ':' )
1512- min = strtol (cp + 1 , & cp , 10 );
1513+ min = strtoint (cp + 1 , & cp , 10 );
15131514 /* otherwise, might have run things together... */
15141515 else if (* cp == '\0' && (len = strlen (str )) > 3 )
15151516 {
1516- min = strtol (str + len - 2 , & cp , 10 );
1517+ min = strtoint (str + len - 2 , & cp , 10 );
15171518 if (min < 0 || min >= 60 )
15181519 return -1 ;
15191520
15201521 * (str + len - 2 ) = '\0' ;
1521- hr = strtol (str + 1 , & cp , 10 );
1522+ hr = strtoint (str + 1 , & cp , 10 );
15221523 if (hr < 0 || hr > 13 )
15231524 return -1 ;
15241525 }
@@ -1825,7 +1826,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
18251826 if (tzp == NULL )
18261827 return -1 ;
18271828
1828- val = strtol (field [i ], & cp , 10 );
1829+ val = strtoint (field [i ], & cp , 10 );
18291830 if (* cp != '-' )
18301831 return -1 ;
18311832
@@ -1960,7 +1961,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
19601961 char * cp ;
19611962 int val ;
19621963
1963- val = strtol (field [i ], & cp , 10 );
1964+ val = strtoint (field [i ], & cp , 10 );
19641965
19651966 /*
19661967 * only a few kinds are allowed to have an embedded
0 commit comments