Skip to content

Commit 5bdb90c

Browse files
committed
Fixed float format (thanks to brstgt).
1 parent 958f1cb commit 5bdb90c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

library.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ integer_length(int i) {
140140
int
141141
double_length(double d) {
142142
char *s;
143-
int ret = spprintf(&s, 0, "%f", d);
143+
int ret = spprintf(&s, 0, "%F", d);
144144
efree(s);
145145
return ret;
146146
}
@@ -182,10 +182,11 @@ redis_cmd_format(char **ret, char *format, ...) {
182182
total += sz;
183183
break;
184184

185+
case 'F':
185186
case 'f':
186187
/* use spprintf here */
187188
dbl = va_arg(ap, double);
188-
double_len = spprintf(&double_str, 0, "%f", dbl);
189+
double_len = spprintf(&double_str, 0, "%F", dbl);
189190
if(stage == 1) {
190191
memcpy((*ret) + total, double_str, double_len);
191192
}

redis.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ PHP_METHOD(Redis, zAdd) {
26872687
"%s" _NL /* key */
26882688

26892689
"$%d" _NL /* score_len */
2690-
"%f" _NL /* score */
2690+
"%F" _NL /* score */
26912691

26922692
"$%d" _NL /* val_len */
26932693
"%s" _NL /* val */
@@ -2842,10 +2842,10 @@ PHP_METHOD(Redis, zDeleteRangeByScore)
28422842
"%s" _NL /* key */
28432843

28442844
"$%d" _NL /* start_len */
2845-
"%f" _NL /* start */
2845+
"%F" _NL /* start */
28462846

28472847
"$%d" _NL /* end_len */
2848-
"%f" _NL /* end */
2848+
"%F" _NL /* end */
28492849

28502850
, key_len, key, key_len
28512851
, double_length(start), start
@@ -2985,10 +2985,10 @@ PHP_METHOD(Redis, zRangeByScore)
29852985
"%s" _NL /* key */\
29862986
\
29872987
"$%d" _NL /* start_len */\
2988-
"%f" _NL /* start */\
2988+
"%F" _NL /* start */\
29892989
\
29902990
"$%d" _NL /* end_len */\
2991-
"%f" _NL /* end */
2991+
"%F" _NL /* end */
29922992
#define BASIC_FORMAT_WITH_LIMIT BASIC_FORMAT\
29932993
"$5" _NL\
29942994
"LIMIT" _NL\
@@ -3167,7 +3167,7 @@ PHPAPI void generic_incrby_method(INTERNAL_FUNCTION_PARAMETERS, char *keyword, i
31673167
"%s" _NL /* key */
31683168

31693169
"$%d" _NL
3170-
"%f" _NL /* val */
3170+
"%F" _NL /* val */
31713171

31723172
"$%d" _NL
31733173
"%s" _NL /* member */

0 commit comments

Comments
 (0)