| 1515 | // |
| 1516 | |
| 1517 | static void cmp_literal( const gpre_nod* node, gpre_req* request) |
| 1518 | { |
| 1519 | bool negate = false; |
| 1520 | |
| 1521 | if (node->nod_type == nod_negate) |
| 1522 | { |
| 1523 | node = node->nod_arg[0]; |
| 1524 | negate = true; |
| 1525 | } |
| 1526 | |
| 1527 | request->add_byte(blr_literal); |
| 1528 | const ref* reference = (ref*) node->nod_arg[0]; |
| 1529 | const char* string = reference->ref_value; |
| 1530 | |
| 1531 | if (*string != '"' && *string != '\'') |
| 1532 | { |
| 1533 | // If the numeric string contains an 'E' or 'e' in it |
| 1534 | // then the datatype is double. |
| 1535 | |
| 1536 | if (strpbrk(string, "Ee")) |
| 1537 | { |
| 1538 | string = reference->ref_value; |
| 1539 | |
| 1540 | request->add_byte(blr_double); |
| 1541 | request->add_word(static_cast<int>(strlen(string))); |
| 1542 | while (*string) |
| 1543 | request->add_byte(*string++); |
| 1544 | } |
| 1545 | else |
| 1546 | { |
| 1547 | // The numeric string doesn't contain 'E' or 'e' in it. |
| 1548 | // Then this must be a scaled int. Figure out if there |
| 1549 | // is a '.' in it and calculate its scale. |
| 1550 | |
| 1551 | const char* s_ptr = string; |
| 1552 | |
| 1553 | // Get the scale |
| 1554 | int scale = 0; |
| 1555 | const char* ptr = strpbrk(string, "."); |
| 1556 | if (ptr) |
| 1557 | { |
| 1558 | // Aha!, there is a '.'. find the scale |
| 1559 | scale = static_cast<int>((string + (strlen(string) - 1)) - ptr); |
| 1560 | scale = -scale; |
| 1561 | } |
| 1562 | |
| 1563 | FB_UINT64 uint64_val = 0; |
| 1564 | while (*s_ptr) |
| 1565 | { |
| 1566 | if (*s_ptr != '.') |
| 1567 | uint64_val = (uint64_val * 10) + (*s_ptr - '0'); |
| 1568 | s_ptr++; |
| 1569 | } |
| 1570 | |
| 1571 | // see if we can fit the value in a long or INT64. |
| 1572 | if ((uint64_val <= MAX_SLONG) || ((uint64_val == (MAX_SLONG + (FB_UINT64) 1)) && negate)) |
| 1573 | { |
| 1574 | long long_val; |