diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2011-12-23 02:11:46 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2011-12-23 02:11:46 +0000 |
| commit | 6a350a8b49abbc2ef7c78a70c1cd4b63eb3ec6ff (patch) | |
| tree | c531737f9eaaaa02d4e8d31669ccc1ab9a98d55b /src | |
| parent | 33f73be49591d5de9b21905941b4705a37e2e4a9 (diff) | |
| download | PROJ-6a350a8b49abbc2ef7c78a70c1cd4b63eb3ec6ff.tar.gz PROJ-6a350a8b49abbc2ef7c78a70c1cd4b63eb3ec6ff.zip | |
only split keywords on pluses following spaces (#132)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2131 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src')
| -rw-r--r-- | src/pj_init.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/pj_init.c b/src/pj_init.c index e483f44a..cec7c544 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -171,7 +171,7 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) #define MAX_ARG 200 char *argv[MAX_ARG]; char *defn_copy; - int argc = 0, i; + int argc = 0, i, blank_count = 0; PJ *result; /* make a copy that we can manipulate */ @@ -185,8 +185,15 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) switch( defn_copy[i] ) { case '+': - if( i == 0 || defn_copy[i-1] == '\0' ) + if( i == 0 || defn_copy[i-1] == '\0' || blank_count > 0 ) { + /* trim trailing spaces from the previous param */ + if( blank_count > 0 ) + { + defn_copy[i - blank_count] = '\0'; + blank_count = 0; + } + if( argc+1 == MAX_ARG ) { pj_ctx_set_errno( ctx, -44 ); @@ -200,13 +207,20 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) case ' ': case '\t': case '\n': - defn_copy[i] = '\0'; + /* trim leading spaces from the current param */ + if( i == 0 || defn_copy[i-1] == '\0' || argc == 0 || argv[argc-1] == defn_copy + i ) + defn_copy[i] = '\0'; + else + blank_count++; break; default: - /* do nothing */; + /* reset blank_count */ + blank_count = 0; } } + /* trim trailing spaces from the last param */ + defn_copy[i - blank_count] = '\0'; /* perform actual initialization */ result = pj_init_ctx( ctx, argc, argv ); |
