aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2011-02-21 22:40:05 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2011-02-21 22:40:05 +0000
commitc174749873eaa0143e96d89138b47fc1e3a15a6d (patch)
treeb25a4bc5b86adec876181d00bb5aabe3a26098e7
parent818f6a9c153cd924d02ea9fc693a661ebc9b99ea (diff)
downloadPROJ-c174749873eaa0143e96d89138b47fc1e3a15a6d.tar.gz
PROJ-c174749873eaa0143e96d89138b47fc1e3a15a6d.zip
fix locale handling, we need to copy the old locale. Avoid too much altering of locale.
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1977 4e78687f-474d-0410-85f9-8d5e500ac6b2
-rw-r--r--ChangeLog3
-rw-r--r--src/pj_init.c10
2 files changed, 10 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c743cb3e..9a9f337c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-02-21 Frank Warmerdam <warmerdam@pobox.com>
+ * src/pj_init.c: fix serious bug in locale handling, wasn't copying
+ the old locale so it would sometimes get corrupted.
+
* src/proj_etmerc.c: added extended transverse mercator impl. (#97)
* Rerun autogen.sh with the latest versions of automake, autoconf and
diff --git a/src/pj_init.c b/src/pj_init.c
index bffbf786..26f32d1a 100644
--- a/src/pj_init.c
+++ b/src/pj_init.c
@@ -241,8 +241,9 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
ctx->last_errno = 0;
start = NULL;
- old_locale = setlocale(LC_NUMERIC, NULL);
- setlocale(LC_NUMERIC,"C");
+ old_locale = strdup(setlocale(LC_NUMERIC, NULL));
+ if( strcmp(old_locale,"C") != 0 )
+ setlocale(LC_NUMERIC,"C");
/* put arguments into internal linked list */
if (argc <= 0) { pj_ctx_set_errno( ctx, -1 ); goto bum_call; }
@@ -433,7 +434,10 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) {
}
PIN = 0;
}
- setlocale(LC_NUMERIC,old_locale);
+
+ if( strcmp(old_locale,"C") != 0 )
+ setlocale(LC_NUMERIC,old_locale);
+ free( old_locale );
return PIN;
}