Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit724119a

Browse files
committed
Modify int8 to not depend on sscanf(), and fix configure's test
for int8 support. configure now checks only snprintf() for int8 support,not sprintf and sscanf as it used to. The reason for doing this is thatif we are supplying our own snprintf code (which does handle long long int),we now only need working long long support in the compiler not in theplatform's C library. I have verified that int8 now passes regression teston HPUX 9, and I think it should work on SunOS 4.1.* and other olderplatforms if gcc is used.
1 parent4090d17 commit724119a

File tree

3 files changed

+344
-322
lines changed

3 files changed

+344
-322
lines changed

‎src/backend/utils/adt/int8.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,31 @@ int64 *
3737
int8in(char*str)
3838
{
3939
int64*result=palloc(sizeof(int64));
40+
char*ptr=str;
41+
int64tmp=0;
42+
intsign=1;
4043

4144
if (!PointerIsValid(str))
4245
elog(ERROR,"Bad (null) int8 external representation",NULL);
4346

44-
if (sscanf(str,INT64_FORMAT,result)!=1)
47+
/* Do our own scan, rather than relying on sscanf which might be
48+
* broken for long long. NOTE: this will not detect int64 overflow...
49+
* but sscanf doesn't either...
50+
*/
51+
while (*ptr&&isspace(*ptr))/* skip leading spaces */
52+
ptr++;
53+
if (*ptr=='-')/* handle sign */
54+
sign=-1,ptr++;
55+
elseif (*ptr=='+')
56+
ptr++;
57+
if (!isdigit(*ptr))/* require at least one digit */
58+
elog(ERROR,"Bad int8 external representation '%s'",str);
59+
while (*ptr&&isdigit(*ptr))/* process digits */
60+
tmp=tmp*10+ (*ptr++-'0');
61+
if (*ptr)/* trailing junk? */
4562
elog(ERROR,"Bad int8 external representation '%s'",str);
4663

47-
#ifFALSE
48-
elog(ERROR,"64-bit integers are not supported",NULL);
49-
result=NULL;
50-
#endif
64+
*result= (sign<0) ?-tmp :tmp;
5165

5266
returnresult;
5367
}/* int8in() */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp