From 2deeca86dc95c02f8cb92cbc5a447a4525535215 Mon Sep 17 00:00:00 2001 From: Nonoo Date: Sat, 14 Nov 2020 08:56:37 +0100 Subject: [PATCH] Fix decimal separators which sscanf can't handle This is a workaround for some apps like Gpredict, which use comma as a decimal separator (depending on locale settings), but sscanf in Hamlib can only handle dots. --- tests/rotctl_parse.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 95f5064a6..63873ad1f 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1692,6 +1692,22 @@ declare_proto_rot(set_position) { azimuth_t az; elevation_t el; + char *comma_pos; + + /* Fixing args with an invalid decimal separator. */ + comma_pos = strchr(arg1, ','); + + if (comma_pos) + { + *comma_pos = '.'; + } + + comma_pos = strchr(arg2, ','); + + if (comma_pos) + { + *comma_pos = '.'; + } CHKSCN1ARG(sscanf(arg1, "%f", &az)); CHKSCN1ARG(sscanf(arg2, "%f", &el));