Bug 1064 - Some drivers use local dependent string to float/double conversion
Summary: Some drivers use local dependent string to float/double conversion
Status: RESOLVED FIXED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: Other (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-02 18:12 CET by knarfS
Modified: 2017-11-11 19:55 CET (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description knarfS 2017-11-02 18:12:02 CET
Some drivers use sscanf() or sr_atof() to convert their input data (string) to a float/double value. This two functions recognize the decimal mark dependent to the locale settings.

In the case your locale uses "," (comma) as the decimal mark, a string like "1.234" will be converted to 1.0f

This drivers are affected:
dmm/metex14.c: sscanf()
dmm/m2110.c: 2x sscanf()
motech-lps-30x/protocol.c: sr_atod()
In scpi/scpi.c the sr_scpi_get_double() function: sr_atod()

I pushed a fix to https://github.com/knarfS/libsigrok

I was able to test the fix for the metex14 driver and for the scpi function, but couldn't test the m2110 driver and the motech-lps-30x driver.
Comment 1 Uwe Hermann 2017-11-11 19:55:44 CET
Great stuff! Merged in 4f0463a079f61ca60ac94a126a5a9cd0f40c14f3, thanks!