diff options
Diffstat (limited to 'src/cs2cs.c')
| -rw-r--r-- | src/cs2cs.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cs2cs.c b/src/cs2cs.c index 43f7bf86..90369326 100644 --- a/src/cs2cs.c +++ b/src/cs2cs.c @@ -33,6 +33,7 @@ #include <string.h> #include <math.h> #include "emess.h" +#include <locale.h> #define MAX_LINE 1000 #define MAX_PARGS 100 @@ -167,6 +168,12 @@ int main(int argc, char **argv) FILE *fid; int from_argc=0, to_argc=0, eargc = 0, c, mon = 0; int have_to_flag = 0, inverse = 0, i; + int use_env_locale = 0; + + /* This is just to check that pj_init() is locale-safe */ + /* Used by nad/testvarious */ + if( getenv("PROJ_USE_ENV_LOCALE") != NULL ) + use_env_locale = 1; if ((emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != NULL) ++emess_dat.Prog_name; @@ -336,6 +343,12 @@ int main(int argc, char **argv) to_argc = argcount; } + if( use_env_locale ) + { + /* Set locale from environment */ + setlocale(LC_ALL, ""); + } + if( from_argc == 0 && to_argc != 0 ) { /* we will generate the from proj as the latlong of the +to in a bit */ @@ -389,6 +402,12 @@ int main(int argc, char **argv) } } + if( use_env_locale ) + { + /* Restore C locale to avoid issues in parsing/outputing numbers*/ + setlocale(LC_ALL, "C"); + } + if (mon) { printf( "%c ---- From Coordinate System ----\n", tag ); pj_pr_list(fromProj); |
