Add a double as a bulk reply */
| 828 | |
| 829 | /* Add a double as a bulk reply */ |
| 830 | void addReplyDouble(client *c, double d) { |
| 831 | if (std::isinf(d)) { |
| 832 | /* Libc in odd systems (Hi Solaris!) will format infinite in a |
| 833 | * different way, so better to handle it in an explicit way. */ |
| 834 | if (c->resp == 2) { |
| 835 | addReplyBulkCString(c, d > 0 ? "inf" : "-inf"); |
| 836 | } else { |
| 837 | addReplyProto(c, d > 0 ? ",inf\r\n" : ",-inf\r\n", |
| 838 | d > 0 ? 6 : 7); |
| 839 | } |
| 840 | } else { |
| 841 | char dbuf[MAX_LONG_DOUBLE_CHARS+3], |
| 842 | sbuf[MAX_LONG_DOUBLE_CHARS+32]; |
| 843 | int dlen, slen; |
| 844 | if (c->resp == 2) { |
| 845 | dlen = snprintf(dbuf,sizeof(dbuf),"%.17g",d); |
| 846 | slen = snprintf(sbuf,sizeof(sbuf),"$%d\r\n%s\r\n",dlen,dbuf); |
| 847 | addReplyProto(c,sbuf,slen); |
| 848 | } else { |
| 849 | dlen = snprintf(dbuf,sizeof(dbuf),",%.17g\r\n",d); |
| 850 | addReplyProto(c,dbuf,dlen); |
| 851 | } |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | void addReplyBigNum(client *c, const char* num, size_t len) { |
| 856 | if (c->resp == 2) { |
no test coverage detected