-
Notifications
You must be signed in to change notification settings - Fork 21
encode: prevent appending .0 to scientific notation to le bucket labels #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -373,7 +373,11 @@ static cfl_sds_t bucket_value_to_string(double val) | |
| len = snprintf(str, 64, "%g", val); | ||
| cfl_sds_len_set(str, len); | ||
|
|
||
| if (!strchr(str, '.')) { | ||
| /* | ||
| * Append .0 only when there is no decimal point and the number | ||
| * is not in scientific notation. | ||
| */ | ||
| if (!strchr(str, '.') && !strchr(str, 'e')) { | ||
| cfl_sds_cat_safe(&str, ".0", 2); | ||
|
Comment on lines
+376
to
381
|
||
| } | ||
|
Comment on lines
373
to
382
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for scientific notation only looks for lowercase 'e'. While
%gtypically uses 'e', this becomes fragile if the formatting ever changes (e.g.,%G) or if a platform emits an uppercase exponent. Consider using a character-class check (e.g., treating either 'e' or 'E' as scientific notation) so.0is never appended to exponent-form values.