Skip to content

Commit

Permalink
Remove 'pj_' prefix from static functions
Browse files Browse the repository at this point in the history
Functions should only be prefixed with 'pj_' when they can be used in
other parts of the code base and not just within a single file.

Takes care of the last step in OSGeo#675.
  • Loading branch information
kbevers committed Mar 11, 2018
1 parent ab87b8e commit 18d5c03
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 89 deletions.
10 changes: 5 additions & 5 deletions src/PJ_healpix.c
Expand Up @@ -71,7 +71,7 @@ static const double rot[7][2][2] = ROT;
* @param v the parameter whose sign is returned.
* @return 1 for positive number, -1 for negative, and 0 for zero.
**/
static double pj_sign (double v) {
static double sign (double v) {
return v > 0 ? 1 : (v < 0 ? -1 : 0);
}

Expand Down Expand Up @@ -236,7 +236,7 @@ static double auth_lat(PJ *P, double alpha, int inverse) {

if (fabs(ratio) > 1) {
/* Rounding error. */
ratio = pj_sign(ratio);
ratio = sign(ratio);
}
return asin(ratio);
} else {
Expand Down Expand Up @@ -269,7 +269,7 @@ static XY healpix_sphere(LP lp) {
}
lamc = -3*M_FORTPI + M_HALFPI*cn;
xy.x = lamc + (lam - lamc)*sigma;
xy.y = pj_sign(phi)*M_FORTPI*(2 - sigma);
xy.y = sign(phi)*M_FORTPI*(2 - sigma);
}
return xy;
}
Expand Down Expand Up @@ -297,10 +297,10 @@ static LP healpix_sphere_inverse(XY xy) {
xc = -3*M_FORTPI + M_HALFPI*cn;
tau = 2.0 - 4*fabs(y)/M_PI;
lp.lam = xc + (x - xc)/tau;
lp.phi = pj_sign(y)*asin(1.0 - pow(tau, 2)/3.0);
lp.phi = sign(y)*asin(1.0 - pow(tau, 2)/3.0);
} else {
lp.lam = -M_PI;
lp.phi = pj_sign(y)*M_HALFPI;
lp.phi = sign(y)*M_HALFPI;
}
return (lp);
}
Expand Down
24 changes: 12 additions & 12 deletions src/gie.c
Expand Up @@ -579,9 +579,9 @@ either a conversion or a transformation)



static int pj_unitconvert_selftest (void);
static int pj_cart_selftest (void);
static int pj_horner_selftest (void);
static int unitconvert_selftest (void);
static int cart_selftest (void);
static int horner_selftest (void);

/*****************************************************************************/
static int builtins (const char *args) {
Expand All @@ -598,26 +598,26 @@ using the "builtins" command verb.
T.op_ok = 0;
T.op_ko = 0;
T.op_skip = 0;
i = pj_unitconvert_selftest ();
i = unitconvert_selftest ();
if (i!=0) {
fprintf (T.fout, "pj_unitconvert_selftest fails with %d\n", i);
fprintf (T.fout, "unitconvert_selftest fails with %d\n", i);
another_failing_builtin();
}
else
another_succeeding_builtin ();


i = pj_cart_selftest ();
i = cart_selftest ();
if (i!=0) {
fprintf (T.fout, "pj_cart_selftest fails with %d\n", i);
fprintf (T.fout, "cart_selftest fails with %d\n", i);
another_failing_builtin();
}
else
another_succeeding_builtin ();

i = pj_horner_selftest ();
i = horner_selftest ();
if (i!=0) {
fprintf (T.fout, "pj_horner_selftest fails with %d\n", i);
fprintf (T.fout, "horner_selftest fails with %d\n", i);
another_failing_builtin();
}
else
Expand Down Expand Up @@ -1473,7 +1473,7 @@ static const char sb_utm32[] = {
" +inv_c=6.13342118787027e+06,4.94690181709311e+05,9.99824464710368e-01,2.82279070814774e-02,7.66123542220864e-11,1.78425334628927e-09,-1.05584823306400e-14,-3.32554258683744e-15"
};

static int pj_horner_selftest (void) {
static int horner_selftest (void) {
PJ *P;
PJ_COORD a, b, c;
double dist;
Expand Down Expand Up @@ -1539,7 +1539,7 @@ static int pj_horner_selftest (void) {


/* Testing quite a bit of the pj_obs_api as a side effect (inspired by pj_obs_api_test.c) */
static int pj_cart_selftest (void) {
static int cart_selftest (void) {
PJ_CONTEXT *ctx;
PJ *P;
PJ_COORD a, b, obs[2];
Expand Down Expand Up @@ -1968,7 +1968,7 @@ static int test_time(const char* args, double tol, double t_in, double t_exp) {
return ret;
}

static int pj_unitconvert_selftest (void) {
static int unitconvert_selftest (void) {
int ret = 0;
char args1[] = "+proj=unitconvert +t_in=decimalyear +t_out=decimalyear";
double in1 = 2004.25;
Expand Down
6 changes: 3 additions & 3 deletions src/pj_apply_vgridshift.c
Expand Up @@ -33,7 +33,7 @@
#include "proj_internal.h"
#include "projects.h"

static double pj_read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GRIDINFO **tables, struct CTABLE *ct) {
static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GRIDINFO **tables, struct CTABLE *ct) {
int itable = 0;
double value = HUGE_VAL;
double grid_x, grid_y;
Expand Down Expand Up @@ -180,7 +180,7 @@ int pj_apply_vgridshift( PJ *defn, const char *listname,
input.phi = y[io];
input.lam = x[io];

value = pj_read_vgrid_value(defn, input, gridlist_count_p, tables, &ct);
value = read_vgrid_value(defn, input, gridlist_count_p, tables, &ct);

if( inverse )
z[io] -= value;
Expand Down Expand Up @@ -286,7 +286,7 @@ double proj_vgrid_value(PJ *P, LP lp){
double value;
memset(&used_grid, 0, sizeof(struct CTABLE));

value = pj_read_vgrid_value(P, lp, &(P->vgridlist_geoid_count), P->vgridlist_geoid, &used_grid);
value = read_vgrid_value(P, lp, &(P->vgridlist_geoid_count), P->vgridlist_geoid, &used_grid);
proj_log_trace(P, "proj_vgrid_value: (%f, %f) = %f", lp.lam*RAD_TO_DEG, lp.phi*RAD_TO_DEG, value);

return value;
Expand Down
40 changes: 20 additions & 20 deletions src/pj_fileapi.c
Expand Up @@ -30,20 +30,20 @@
#include "projects.h"
#include <string.h>

static PAFile pj_stdio_fopen(projCtx ctx, const char *filename,
static PAFile stdio_fopen(projCtx ctx, const char *filename,
const char *access);
static size_t pj_stdio_fread(void *buffer, size_t size, size_t nmemb,
static size_t stdio_fread(void *buffer, size_t size, size_t nmemb,
PAFile file);
static int pj_stdio_fseek(PAFile file, long offset, int whence);
static long pj_stdio_ftell(PAFile file);
static void pj_stdio_fclose(PAFile file);
static int stdio_fseek(PAFile file, long offset, int whence);
static long stdio_ftell(PAFile file);
static void stdio_fclose(PAFile file);

static projFileAPI default_fileapi = {
pj_stdio_fopen,
pj_stdio_fread,
pj_stdio_fseek,
pj_stdio_ftell,
pj_stdio_fclose
stdio_fopen,
stdio_fread,
stdio_fseek,
stdio_ftell,
stdio_fclose
};

typedef struct {
Expand All @@ -61,10 +61,10 @@ projFileAPI *pj_get_default_fileapi(void)
}

/************************************************************************/
/* pj_stdio_fopen() */
/* stdio_fopen() */
/************************************************************************/

static PAFile pj_stdio_fopen(projCtx ctx, const char *filename,
static PAFile stdio_fopen(projCtx ctx, const char *filename,
const char *access)
{
stdio_pafile *pafile;
Expand All @@ -90,38 +90,38 @@ static PAFile pj_stdio_fopen(projCtx ctx, const char *filename,
}

/************************************************************************/
/* pj_stdio_fread() */
/* stdio_fread() */
/************************************************************************/

static size_t pj_stdio_fread(void *buffer, size_t size, size_t nmemb,
static size_t stdio_fread(void *buffer, size_t size, size_t nmemb,
PAFile file)
{
stdio_pafile *pafile = (stdio_pafile *) file;
return fread(buffer, size, nmemb, pafile->fp);
}

/************************************************************************/
/* pj_stdio_fseek() */
/* stdio_fseek() */
/************************************************************************/
static int pj_stdio_fseek(PAFile file, long offset, int whence)
static int stdio_fseek(PAFile file, long offset, int whence)
{
stdio_pafile *pafile = (stdio_pafile *) file;
return fseek(pafile->fp, offset, whence);
}

/************************************************************************/
/* pj_stdio_ftell() */
/* stdio_ftell() */
/************************************************************************/
static long pj_stdio_ftell(PAFile file)
static long stdio_ftell(PAFile file)
{
stdio_pafile *pafile = (stdio_pafile *) file;
return ftell(pafile->fp);
}

/************************************************************************/
/* pj_stdio_fclose() */
/* stdio_fclose() */
/************************************************************************/
static void pj_stdio_fclose(PAFile file)
static void stdio_fclose(PAFile file)
{
stdio_pafile *pafile = (stdio_pafile *) file;
fclose(pafile->fp);
Expand Down
16 changes: 8 additions & 8 deletions src/pj_fwd.c
Expand Up @@ -36,7 +36,7 @@
#define OUTPUT_UNITS P->right


static PJ_COORD pj_fwd_prepare (PJ *P, PJ_COORD coo) {
static PJ_COORD fwd_prepare (PJ *P, PJ_COORD coo) {
if (HUGE_VAL==coo.v[0])
return proj_coord_error ();

Expand Down Expand Up @@ -100,7 +100,7 @@ static PJ_COORD pj_fwd_prepare (PJ *P, PJ_COORD coo) {



static PJ_COORD pj_fwd_finalize (PJ *P, PJ_COORD coo) {
static PJ_COORD fwd_finalize (PJ *P, PJ_COORD coo) {

switch (OUTPUT_UNITS) {

Expand Down Expand Up @@ -180,7 +180,7 @@ XY pj_fwd(LP lp, PJ *P) {
coo.lp = lp;

if (!P->skip_fwd_prepare)
coo = pj_fwd_prepare (P, coo);
coo = fwd_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
return proj_coord_error ().xy;

Expand All @@ -199,7 +199,7 @@ XY pj_fwd(LP lp, PJ *P) {
return proj_coord_error ().xy;

if (!P->skip_fwd_finalize)
coo = pj_fwd_finalize (P, coo);
coo = fwd_finalize (P, coo);
return coo.xy;
}

Expand All @@ -210,7 +210,7 @@ XYZ pj_fwd3d(LPZ lpz, PJ *P) {
coo.lpz = lpz;

if (!P->skip_fwd_prepare)
coo = pj_fwd_prepare (P, coo);
coo = fwd_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
return proj_coord_error ().xyz;

Expand All @@ -229,15 +229,15 @@ XYZ pj_fwd3d(LPZ lpz, PJ *P) {
return proj_coord_error ().xyz;

if (!P->skip_fwd_finalize)
coo = pj_fwd_finalize (P, coo);
coo = fwd_finalize (P, coo);
return coo.xyz;
}



PJ_COORD pj_fwd4d (PJ_COORD coo, PJ *P) {
if (!P->skip_fwd_prepare)
coo = pj_fwd_prepare (P, coo);
coo = fwd_prepare (P, coo);
if (HUGE_VAL==coo.v[0])
return proj_coord_error ();

Expand All @@ -256,6 +256,6 @@ PJ_COORD pj_fwd4d (PJ_COORD coo, PJ *P) {
return proj_coord_error ();

if (!P->skip_fwd_finalize)
coo = pj_fwd_finalize (P, coo);
coo = fwd_finalize (P, coo);
return coo;
}
14 changes: 7 additions & 7 deletions src/pj_gc_reader.c
Expand Up @@ -32,7 +32,7 @@
#include <string.h>
#include <ctype.h>

static int pj_gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry);
static int gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry);

/************************************************************************/
/* pj_gc_readcatalog() */
Expand Down Expand Up @@ -81,7 +81,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name )
return NULL;
}

while( pj_gc_readentry( ctx, fid,
while( gc_readentry( ctx, fid,
catalog->entries+catalog->entry_count) == 0)
{
catalog->entry_count++;
Expand Down Expand Up @@ -114,13 +114,13 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name )
}

/************************************************************************/
/* pj_gc_read_csv_line() */
/* gc_read_csv_line() */
/* */
/* Simple csv line splitter with fixed maximum line size and */
/* token count. */
/************************************************************************/

static int pj_gc_read_csv_line( projCtx ctx, PAFile fid,
static int gc_read_csv_line( projCtx ctx, PAFile fid,
char **tokens, int max_tokens )
{
char line[302];
Expand Down Expand Up @@ -197,15 +197,15 @@ double pj_gc_parsedate( projCtx ctx, const char *date_string )


/************************************************************************/
/* pj_gc_readentry() */
/* gc_readentry() */
/* */
/* Read one catalog entry from the file */
/* */
/* Format: */
/* gridname,ll_long,ll_lat,ur_long,ur_lat,priority,date */
/************************************************************************/

static int pj_gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry)
static int gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry)
{
#define MAX_TOKENS 30
char *tokens[MAX_TOKENS];
Expand All @@ -214,7 +214,7 @@ static int pj_gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry)

memset( entry, 0, sizeof(PJ_GridCatalogEntry) );

token_count = pj_gc_read_csv_line( ctx, fid, tokens, MAX_TOKENS );
token_count = gc_read_csv_line( ctx, fid, tokens, MAX_TOKENS );
if( token_count < 5 )
{
error = 1; /* TODO: need real error codes */
Expand Down
8 changes: 4 additions & 4 deletions src/pj_gridinfo.c
Expand Up @@ -389,20 +389,20 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
}

/************************************************************************/
/* pj_gridinfo_parent() */
/* gridinfo_parent() */
/* */
/* Seek a parent grid file by name from a grid list */
/************************************************************************/

static PJ_GRIDINFO* pj_gridinfo_parent( PJ_GRIDINFO *gilist,
static PJ_GRIDINFO* gridinfo_parent( PJ_GRIDINFO *gilist,
const char *name, int length )
{
while( gilist )
{
if( strncmp(gilist->ct->id,name,length) == 0 ) return gilist;
if( gilist->child )
{
PJ_GRIDINFO *parent=pj_gridinfo_parent( gilist->child, name, length );
PJ_GRIDINFO *parent=gridinfo_parent( gilist->child, name, length );
if( parent ) return parent;
}
gilist=gilist->next;
Expand Down Expand Up @@ -596,7 +596,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
else
{
PJ_GRIDINFO *lnk;
PJ_GRIDINFO *gp = pj_gridinfo_parent(gilist,
PJ_GRIDINFO *gp = gridinfo_parent(gilist,
(const char*)header+24,8);

if( gp == NULL )
Expand Down

0 comments on commit 18d5c03

Please sign in to comment.