Add a double as a bulk reply */
| 669 | |
| 670 | /* Add a double as a bulk reply */ |
| 671 | void addReplyDouble(client *c, double d) { |
| 672 | if (isinf(d)) { |
| 673 | /* Libc in odd systems (Hi Solaris!) will format infinite in a |
| 674 | * different way, so better to handle it in an explicit way. */ |
| 675 | if (c->resp == 2) { |
| 676 | addReplyBulkCString(c, d > 0 ? "inf" : "-inf"); |
| 677 | } else { |
| 678 | addReplyProto(c, d > 0 ? ",inf\r\n" : ",-inf\r\n", |
| 679 | d > 0 ? 6 : 7); |
| 680 | } |
| 681 | } else { |
| 682 | char dbuf[MAX_LONG_DOUBLE_CHARS+3], |
| 683 | sbuf[MAX_LONG_DOUBLE_CHARS+32]; |
| 684 | int dlen, slen; |
| 685 | if (c->resp == 2) { |
| 686 | dlen = snprintf(dbuf,sizeof(dbuf),"%.17g",d); |
| 687 | slen = snprintf(sbuf,sizeof(sbuf),"$%d\r\n%s\r\n",dlen,dbuf); |
| 688 | addReplyProto(c,sbuf,slen); |
| 689 | } else { |
| 690 | dlen = snprintf(dbuf,sizeof(dbuf),",%.17g\r\n",d); |
| 691 | addReplyProto(c,dbuf,dlen); |
| 692 | } |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | void addReplyBigNum(client *c, const char* num, size_t len) { |
| 697 | if (c->resp == 2) { |
no test coverage detected