Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89a871e

Browse files
yatsukhnenkomichael-grunder
authored andcommitted
Issue #1893
On some locales `snprintf` uses comma as radix character. Simply replace comma with point to make valid float value.
1 parent 99975b5 commit 89a871e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

library.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,15 @@ int redis_cmd_append_sstr_i64(smart_string *str, int64_t append) {
951951
int
952952
redis_cmd_append_sstr_dbl(smart_string *str, double value)
953953
{
954-
char tmp[64];
954+
char tmp[64], *p;
955955
int len;
956956

957957
/* Convert to string */
958958
len = snprintf(tmp, sizeof(tmp), "%.17g", value);
959959

960+
/* snprintf depends on locale, replace comma with point */
961+
if ((p = strchr(tmp, ',')) != NULL) *p = '.';
962+
960963
// Append the string
961964
return redis_cmd_append_sstr(str, tmp, len);
962965
}

0 commit comments

Comments
 (0)