|
12 | 12 | * |
13 | 13 | * |
14 | 14 | * IDENTIFICATION |
15 | | - * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.77 2001/02/21 18:53:47 tgl Exp $ |
| 15 | + * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.78 2001/04/02 08:17:24 meskes Exp $ |
16 | 16 | * |
17 | 17 | *------------------------------------------------------------------------- |
18 | 18 | */ |
@@ -335,13 +335,20 @@ cppline {space}*#(.*\\{line_end})*.* |
335 | 335 | startlit(); |
336 | 336 | } |
337 | 337 | <xh>{xhstop} { |
| 338 | + long val; |
338 | 339 | char* endptr; |
339 | 340 |
|
340 | 341 | BEGIN(SQL); |
341 | 342 | errno = 0; |
342 | | - yylval.ival = strtol(literalbuf, &endptr, 16); |
343 | | - if (*endptr != '\0' || errno == ERANGE) |
| 343 | + val = strtol(literalbuf, &endptr, 16); |
| 344 | + if (*endptr != '\0' || errno == ERANGE |
| 345 | +#ifdef HAVE_LONG_INT_64 |
| 346 | + /* if long > 32 bits, check for overflow of int4 */ |
| 347 | + || val != (long) ((int32) val) |
| 348 | +#endif |
| 349 | + ) |
344 | 350 | mmerror(ET_ERROR, "Bad hexadecimal integer input"); |
| 351 | + yylval.ival = val; |
345 | 352 | return ICONST; |
346 | 353 | } |
347 | 354 |
|
@@ -498,16 +505,23 @@ cppline {space}*#(.*\\{line_end})*.* |
498 | 505 | return PARAM; |
499 | 506 | } |
500 | 507 | <C,SQL>{integer} { |
| 508 | + long val; |
501 | 509 | char* endptr; |
502 | 510 |
|
503 | 511 | errno = 0; |
504 | | - yylval.ival = strtol((char *)yytext, &endptr,10); |
505 | | - if (*endptr != '\0' || errno == ERANGE) |
| 512 | + val = strtol((char *)yytext, &endptr,10); |
| 513 | + if (*endptr != '\0' || errno == ERANGE |
| 514 | +#ifdef HAVE_LONG_INT_64 |
| 515 | + /* if long > 32 bits, check for overflow of int4 */ |
| 516 | + || val != (long) ((int32) val) |
| 517 | +#endif |
| 518 | + ) |
506 | 519 | { |
507 | 520 | errno = 0; |
508 | 521 | yylval.str = mm_strdup((char*)yytext); |
509 | 522 | return FCONST; |
510 | 523 | } |
| 524 | + yylval.ival = val; |
511 | 525 | return ICONST; |
512 | 526 | } |
513 | 527 | <SQL>{ip} { |
|
0 commit comments