Ticket #132 (closed defect: fixed)

Opened 17 months ago

Last modified 17 months ago

pj_init_plus trim all spaces even if not followed by a plus sign (+)

Reported by: brushtyler Owned by: warmerdam
Priority: major Milestone:
Component: Core Version: unspecified
Keywords: Cc:

Description

Looking at the  Proj API Reference the pj_init function is obsolete, so there isn't a way through API to pass a proj4 param followed by a string containing spaces (e.g. +nadgrids).

I know this was discussed on ML times ago, but IMHO it's a bug. The right behavior should be to split the proj4 string on spaces followed by a plus sign (+), not to trim spaces at all.

Attachments

proj_ticket_132.diff Download (1.6 KB) - added by brushtyler 17 months ago.
[patch] split on spaces followed by '+', trim leading and trailing spaces but keep those within the string

Change History

Changed 17 months ago by brushtyler

[patch] split on spaces followed by '+', trim leading and trailing spaces but keep those within the string

Changed 17 months ago by brushtyler

The attached patch fixes this bug.
Instead of removing all spaces, the patched pj_init_plus() function splits on spaces followed by a '+'. Spaces are kept only if within the string.

I agree that using spaces on paths is evil, but i.e. on WinOS a main/system folder's name like "Program Files" contains a space.
The patch will cover almost all the cases, except one: only crazy people can use spaces followed by '+' into filenames...


Here an example of old vs. new behaviors (do not take quotes into account, I use them only to make start and end of strings visible)

pj_init_plus() input:

" +  ++ +proj=latlong   +ellps=clrk66 +nadgrids=/home/brushtyler/test  proj grid/with   spaces/conus+ +towgs84=0,0,0  +nodefs   "

using r2130, when calling pj_init_ctx() argv contains:

""
"+"
"proj=latlong"
"ellps=clrk66"
"nadgrids=/home/brushtyler/test"
"towgs84=0,0,0"
"nodefs"

after applying the patch, pj_init_ctx() is called with the following argv:

""
"+"
"proj=latlong"
"ellps=clrk66"
"nadgrids=/home/brushtyler/test  proj grid/with   spaces/conus+"
"towgs84=0,0,0"
"nodefs"

As far as you can see the output is the same even in the bordeline cases, the only difference is the nadgrids param's value (a path containing spaces).

Changed 17 months ago by warmerdam

  • status changed from new to closed
  • resolution set to fixed

While I'm afraid there will be some surprising consequences, I believe you have the best solution.

Change applied in trunk (r2131).

Changed 17 months ago by warmerdam

  • component changed from default to Core
Note: See TracTickets for help on using tickets.