Skip to content

Commit

Permalink
Fix formating floats in SQL queries.
Browse files Browse the repository at this point in the history
Force POSIX locale for LC_NUMERIC to be sure that the dot separater is used when using floats in SQL queries (some locales are using the comma for that, breaking the SQL syntax).

Closes #1538

(cherry picked from commit 0ccda2e)
  • Loading branch information
bogdan-iancu committed Nov 26, 2018
1 parent d578fa6 commit a034161
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.c
Expand Up @@ -90,6 +90,7 @@
#include <grp.h>
#include <signal.h>
#include <time.h>
#include <locale.h>

#include <sys/ioctl.h>
#include <net/if.h>
Expand Down Expand Up @@ -782,6 +783,11 @@ int main(int argc, char** argv)

init_route_lists();

/* we want to be sure that from now on, all the floating numbers are
* using the dot as separator. This is a real issue when printing the
* floats for SQL ops, where the dot must be used */
setlocale( LC_NUMERIC, "POSIX");

/* process command line (get port no, cfg. file path etc) */
/* first reset getopt */
optind = 1;
Expand Down

0 comments on commit a034161

Please sign in to comment.