diff options
| author | Thomas Knudsen <busstoptaktik@users.noreply.github.com> | 2018-02-07 12:15:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-07 12:15:04 +0100 |
| commit | 4f00f09f1c306e87dfea3a5bc49dcaae72280e00 (patch) | |
| tree | 8e1378ed32ac4f9b2badf37fd9b5ceac66d049c8 /src/gie.c | |
| parent | 4cd6fe1369f52bc53c8e595a218bd0e7426b05db (diff) | |
| download | PROJ-4f00f09f1c306e87dfea3a5bc49dcaae72280e00.tar.gz PROJ-4f00f09f1c306e87dfea3a5bc49dcaae72280e00.zip | |
Shrink PJ_XXX_INFO structs, but keep same syntax. (#775)
* Shrink PJ_XXX_INFO structs, but keep same syntax.
A number of the fixed length strings in the INFO structs are simply
reflections of material that already exists as static strings at a
number of places in the library (or in the case of PJ_INFO, really
*should* exist, and now is implemented).
This PR replaces these cases of constant length strings with const
char pointers. The usage syntax is unchanged, and so is the nice
property of having the return value allocated on the stack, and
hence not requiring explicit memory management by the caller.
proj_info now only does setup once - and the searchpath entry of
PJ_INFO is not arbitrarily truncated at 512 bytes. Repeated calls
simply returns a copy of already prepared material.
The id, description and definition entries of PJ_PROJ_INFO are now
also guaranteed to hold the entire text of the corresponding static
string, by being represented by a const char pointer to that actual
static string.
PJ_GRID_INFO and PJ_INIT_INFO (i.e. the two smallest INFO structs)
are unchanged.
* Eliminate pj_strlcpy - not needed anymore: Remining calls could
safely be replaced by strncpy.
* Extend PROJ_INFO with paths from pj_set_searchpath.
NOTE: Need to call pj_set_searchpath before first call to proj_info
Huge thanks to Kristian Evers and Even Rouault for comments, debugging and advice.
Diffstat (limited to 'src/gie.c')
| -rw-r--r-- | src/gie.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1492,7 +1492,7 @@ static int pj_cart_selftest (void) { size_t n, sz; double dist, h, t; char *args[3] = {"proj=utm", "zone=32", "ellps=GRS80"}; - const char *arg = {"+proj=utm +zone=32 +ellps=GRS80"}; + char arg[50] = {"+proj=utm; +zone=32; +ellps=GRS80"}; char buf[40]; /* An utm projection on the GRS80 ellipsoid */ @@ -1723,7 +1723,8 @@ static int pj_cart_selftest (void) { if (strcmp(info.version, tmpstr)) return 55; } if (info.release[0] == '\0') return 56; - if (info.searchpath[0] == '\0') return 57; + if (getenv ("HOME") || getenv ("PROJ_LIB")) + if (info.searchpath[0] == '\0') return 57; /* proj_pj_info() */ P = proj_create(PJ_DEFAULT_CTX, "+proj=august"); /* august has no inverse */ @@ -1733,6 +1734,7 @@ static int pj_cart_selftest (void) { P = proj_create(PJ_DEFAULT_CTX, arg); pj_info = proj_pj_info(P); if ( !pj_info.has_inverse ) { proj_destroy(P); return 61; } + pj_shrink (arg); if ( strcmp(pj_info.definition, arg) ) { proj_destroy(P); return 62; } if ( strcmp(pj_info.id, "utm") ) { proj_destroy(P); return 63; } |
