|
11 | 11 | *
|
12 | 12 | *
|
13 | 13 | * 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 $ |
15 | 15 | *
|
16 | 16 | *-------------------------------------------------------------------------
|
17 | 17 | */
|
|
42 | 42 | #defineSCHAR_MIN (-SCHAR_MAX-1)
|
43 | 43 | #endif
|
44 | 44 |
|
| 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 | + */ |
45 | 57 | int32
|
46 | 58 | pg_atoi(char*s,intsize,intc)
|
47 | 59 | {
|
48 | 60 | longl=0;
|
49 | 61 | char*badp=NULL;
|
50 | 62 |
|
51 |
| -Assert(s); |
52 |
| - |
53 | 63 | errno=0;
|
54 | 64 |
|
55 | 65 | /*
|
56 |
| - * Some versions of strtol treat the empty string as an error.This |
57 |
| - *code will explicitly return 0 foranempty string. |
| 66 | + * Some versions of strtol treat the empty string as an error, but some |
| 67 | + *seem not to. Makeanexplicit test to be sure we catch it. |
58 | 68 | */
|
59 | 69 |
|
60 | 70 | if (s== (char*)NULL)
|
|