Bug#462545: tqsllib1c2a: Locale dependent failure of frequency conversion
Package: tqsllib1c2a
Version: 2.0-5
Tags: patch l10n
Converting a frequency from an ADIF input file to a band may fail with
locales which define something different than '.' as decimal separator
(e.g. de_DE).
ADIF always uses '.' as separator, but the conversion by atof() in
tqsl_infer_band() in tqslconvert.cpp depends on the locale and cuts the
frequency to an integer when a different separator is used. This leads to
errors with 3.5 and 1.8MHz (atof("3.5") == 3), which result in out-of-band
frequencies (as defined in config.xml).
Example error message (from 'tqsl', which is using tqsllib):
01:57:35: Error: Invalid BAND () on line 10
call: DJ1YFK
freq: 3.5
mode: CW
qso_date: 20071209
time_on: 0035
One way to fix this would be:
--- tqslconvert.cpp-orig 2008-01-24 21:43:37.000000000 +0100
+++ tqslconvert.cpp 2008-01-24 21:44:11.000000000 +0100
@@ -23,6 +23,7 @@
#include <string>
#include <ctype.h>
#include <set>
+#include <locale.h>
//#include <iostream>
@@ -264,6 +265,7 @@
static const char *
tqsl_infer_band(const char* infreq) {
+ setlocale(LC_NUMERIC, "C");
double freq = atof(infreq);
double freq_khz = freq * 1000.0;
int nband = 0;
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-686
Locale: LANG=de_DE@euro, LC_CTYPE=de_DE@euro (charmap=ISO-8859-15)
Reply to: