File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 1111 *
1212 *
1313 * IDENTIFICATION
14- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.52 2002/08/27 20:29:10 momjian Exp $
14+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.53 2002/08/27 20:54:47 tgl Exp $
1515 *
1616 *-------------------------------------------------------------------------
1717 */
4242#define SCHAR_MIN (-SCHAR_MAX-1)
4343#endif
4444
45+
46+ /*
47+ * pg_atoi: convert string to integer
48+ *
49+ * size is the sizeof() the desired integral result (1, 2, or 4 bytes).
50+ *
51+ * c, if not 0, is the terminator character that may appear after the
52+ * integer. If 0, the string must end after the integer.
53+ *
54+ * Unlike plain atoi(), this will throw elog() upon bad input format or
55+ * overflow.
56+ */
4557int32
4658pg_atoi (char * s , int size , int c )
4759{
4860 long l = 0 ;
4961 char * badp = NULL ;
5062
51- Assert (s );
52-
5363 errno = 0 ;
5464
5565 /*
56- * Some versions of strtol treat the empty string as an error. This
57- * code will explicitly return 0 for an empty string .
66+ * Some versions of strtol treat the empty string as an error, but some
67+ * seem not to. Make an explicit test to be sure we catch it .
5868 */
5969
6070 if (s == (char * ) NULL )
You can’t perform that action at this time.
0 commit comments