Skip to content

Commit

Permalink
clean clang compile, prototypes C23
Browse files Browse the repository at this point in the history
  • Loading branch information
webisu committed Feb 20, 2025
1 parent 640ca39 commit 747db80
Show file tree
Hide file tree
Showing 77 changed files with 1,806 additions and 1,679 deletions.
2 changes: 1 addition & 1 deletion wgrib2/Gctpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int gctpc_get_latlon(unsigned char **sec, double **lon, double **lat) {
double false_north;
double dx, dy;
double x0, y0;
long int (*inv_fn)();
long int (*inv_fn)(double, double, double *, double *);
double *llat, *llon, rlon, rlat;

int nnx, nny, nres, nscan, is_spherical;
Expand Down
26 changes: 16 additions & 10 deletions wgrib2/Match_inv.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "grb2.h"
#include "wgrib2.h"
#include "fnlist.h"
Expand All @@ -12,9 +13,12 @@
*
* Since the match inventory cannot include everything, the option has
* been added to add extra data to the match inventory.
*
* 2/2025: didn't finialize for functions with 2 args
* C23 needs prototypes
*/

int (*match_extra_fn[MATCH_EXTRA_FN])();
int (*match_extra_fn[MATCH_EXTRA_FN])(ARG8);
void *match_extra_fn_local[MATCH_EXTRA_FN];
int match_extra_fn_nargs[MATCH_EXTRA_FN];
char *match_extra_fn_arg1[MATCH_EXTRA_FN] = { NULL } ;
Expand Down Expand Up @@ -46,19 +50,19 @@ int f_match_inv_add(ARG3) {
/* add args to table and intialize fn() */
if (functions[j].nargs == 0 && functions[j].type == inv) {
// initialize fn(..)
match_extra_fn[match_extra_fn_n](-1, NULL, NULL, 0, inv_out, &(match_extra_fn_local[match_extra_fn_n]));
match_extra_fn[match_extra_fn_n](call_ARG0(inv_out, &(match_extra_fn_local[match_extra_fn_n])));
}
else if (functions[j].nargs == 1 && functions[j].type == inv) {
// initialize fn(..)
match_extra_fn[match_extra_fn_n](-1, NULL, NULL, 0, inv_out, &(match_extra_fn_local[match_extra_fn_n]),arg1);
match_extra_fn[match_extra_fn_n](call_ARG1(inv_out, &(match_extra_fn_local[match_extra_fn_n]),arg1));
i = strlen(arg1) + 1;
if ((match_extra_fn_arg1[match_extra_fn_n] = (char *) malloc(i)) == NULL)
fatal_error("match_inv_add: memory allocation","");
strncpy(match_extra_fn_arg1[match_extra_fn_n], arg1, i);
}
else if (functions[j].nargs == 2 && functions[j].type == inv) {
// initialize fn(..)
match_extra_fn[match_extra_fn_n](-1, NULL, NULL, 0, inv_out, &(match_extra_fn_local[match_extra_fn_n]),arg1,arg2);
match_extra_fn[match_extra_fn_n](call_ARG2(inv_out, &(match_extra_fn_local[match_extra_fn_n]),arg1,arg2));
i = strlen(arg1) + 1;
if ((match_extra_fn_arg1[match_extra_fn_n] = (char *) malloc(i)) == NULL)
fatal_error("match_inv_add: memory allocation","");
Expand All @@ -75,9 +79,12 @@ int f_match_inv_add(ARG3) {
else if (mode == -2) { /* finalize all the functions */
for (j = 0; j < match_extra_fn_n; j++) {
if (match_extra_fn_nargs[j] == 0)
match_extra_fn[j](-1, NULL, NULL, 0, inv_out, &(match_extra_fn_local[j]));
match_extra_fn[j](call_ARG0(inv_out, &(match_extra_fn_local[j])));
else if (match_extra_fn_nargs[j] == 1)
match_extra_fn[j](-1, NULL, NULL, 0, inv_out, &(match_extra_fn_local[j]), match_extra_fn_arg1[j] );
match_extra_fn[j](call_ARG1(inv_out, &(match_extra_fn_local[j]), match_extra_fn_arg1[j] ));
else if (match_extra_fn_nargs[j] == 2)
match_extra_fn[j](call_ARG2(inv_out, &(match_extra_fn_local[j]), match_extra_fn_arg1[j],
match_extra_fn_arg2[j] ));
}
for (j = 0; j < match_extra_fn_n; j++) {
if (match_extra_fn_arg1[j] != NULL) {
Expand Down Expand Up @@ -219,12 +226,11 @@ int match_inv(int type_datecode, ARG0) {
/* added 8/2017 */
for (j = 0; j < match_extra_fn_n; j++) {
if (match_extra_fn_nargs[j] == 0)
match_extra_fn[j](mode, sec, data, ndata, inv_out, &(match_extra_fn_local[j]));
match_extra_fn[j](call_ARG0(inv_out, &(match_extra_fn_local[j])));
else if (match_extra_fn_nargs[j] == 1)
match_extra_fn[j](mode, sec, data, ndata, inv_out, &(match_extra_fn_local[j]),match_extra_fn_arg1[j]);
match_extra_fn[j](call_ARG1(inv_out, &(match_extra_fn_local[j]),match_extra_fn_arg1[j]));
else if (match_extra_fn_nargs[j] == 2)
match_extra_fn[j](mode, sec, data, ndata, inv_out, &(match_extra_fn_local[j]),
match_extra_fn_arg1[j], match_extra_fn_arg2[j]);
match_extra_fn[j](call_ARG2(inv_out, &(match_extra_fn_local[j]), match_extra_fn_arg1[j], match_extra_fn_arg2[j]));
strcat(inv_out,":");
inv_out += strlen(inv_out);
}
Expand Down
788 changes: 394 additions & 394 deletions wgrib2/fnlist.h

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions wgrib2/function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cat >fnlist.h <<EOF
/* this file was generated by function.sh */
struct function {const char *name; int (*fn)(); enum fntype type; int nargs; const char *desc; int sort;};
struct function {const char *name; int (*fn)(ARG8); enum fntype type; int nargs; const char *desc; int sort;};
extern struct function functions[];
Expand Down Expand Up @@ -80,7 +80,8 @@ echo "var=$v $var $var1"
done
t="$t);"
# echo "$t"
echo "$t" >> fnlist.h
ARG="ARG`expr $arg - 1`"
echo "int $var1($ARG);" >> fnlist.h
read line
done
} < fnlist
Expand Down
1 change: 0 additions & 1 deletion wgrib2/gctpc/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(src
alconinv.c
azimfor.c
aziminv.c
br_gctp.c
cproj.c
eqconfor.c
eqconinv.c
Expand Down
36 changes: 20 additions & 16 deletions wgrib2/gctpc/source/alberfor.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ ALGORITHM REFERENCES

/* Initialize the Albers projection
-------------------------------*/
long alberforint(
double r_maj, /* major axis */
double r_min, /* minor axis */
double lat1, /* first standard parallel */
double lat2, /* second standard parallel */
double lon0, /* center longitude */
double lat0, /* center lattitude */
double false_east, /* x offset in meters */
double false_north) /* y offset in meters */
{
long alberforint(double r_maj, double r_min, double lat1, double lat2,
double lon0, double lat0, double false_east, double false_north) {
//long alberforint(
//double r_maj, /* major axis */
//double r_min, /* minor axis */
//double lat1, /* first standard parallel */
//double lat2, /* second standard parallel */
//double lon0, /* center longitude */
//double lat0, /* center lattitude */
//double false_east, /* x offset in meters */
//double false_north) /* y offset in meters */
//{
double sin_po,cos_po; /* sin and cos values */
double con; /* temporary variable */
double es,temp; /* eccentricity squared and temp var */
Expand Down Expand Up @@ -106,12 +108,14 @@ return(OK);

/* Albers Conical Equal Area forward equations--mapping lat,long to x,y
-------------------------------------------------------------------*/
long alberfor(lon, lat, x, y)
double lon; /* (I) Longitude */
double lat; /* (I) Latitude */
double *x; /* (O) X projection coordinate */
double *y; /* (O) Y projection coordinate */
{

long alberfor(double lon, double lat, double *x, double *y) {
// long alberfor(lon, lat, x, y)
// double lon; /* (I) Longitude */
// double lat; /* (I) Latitude */
// double *x; /* (O) X projection coordinate */
// double *y; /* (O) Y projection coordinate */
// {
double sin_phi,cos_phi; /* sine and cos values */
double qs; /* small q */
double theta; /* angle */
Expand Down
37 changes: 20 additions & 17 deletions wgrib2/gctpc/source/alberinv.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ ALGORITHM REFERENCES

/* Initialize the Albers projection
-------------------------------*/
long alberinvint(r_maj,r_min,lat1,lat2,lon0,lat0,false_east,false_north)

double r_maj; /* major axis */
double r_min; /* minor axis */
double lat1; /* first standard parallel */
double lat2; /* second standard parallel */
double lon0; /* center longitude */
double lat0; /* center lattitude */
double false_east; /* x offset in meters */
double false_north; /* y offset in meters */
{
long alberinvint( double r_maj, double r_min, double lat1, double lat2,
double lon0, double lat0, double false_east, double false_north) {
//long alberinvint(r_maj,r_min,lat1,lat2,lon0,lat0,false_east,false_north)
//
//double r_maj; /* major axis */
//double r_min; /* minor axis */
//double lat1; /* first standard parallel */
//double lat2; /* second standard parallel */
//double lon0; /* center longitude */
//double lat0; /* center lattitude */
//double false_east; /* x offset in meters */
//double false_north; /* y offset in meters */
//{
double sin_po,cos_po; /* sine and cos values */
double con; /* temporary variable */
double temp; /* temporary variable */
Expand Down Expand Up @@ -111,12 +113,13 @@ return(OK);

/* Albers Conical Equal Area inverse equations--mapping x,y to lat/long
-------------------------------------------------------------------*/
long alberinv(x, y, lon, lat)
double x; /* (O) X projection coordinate */
double y; /* (O) Y projection coordinate */
double *lon; /* (I) Longitude */
double *lat; /* (I) Latitude */
{
long alberinv( double x, double y, double *lon, double *lat) {
//long alberinv(x, y, lon, lat)
//double x; /* (O) X projection coordinate */
//double y; /* (O) Y projection coordinate */
//double *lon; /* (I) Longitude */
//double *lat; /* (I) Latitude */
//{
double rh1; /* height above ellipsoid */
double qs; /* function q */
double con; /* temporary sign value */
Expand Down
30 changes: 16 additions & 14 deletions wgrib2/gctpc/source/alconfor.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ static long n;

/* Initialize the ALASKA CONFORMAL projection
-----------------------------------------*/
long alconforint(r_maj,r_min,false_east,false_north)

double r_maj; /* Major axis */
double r_min; /* Minor axis */
double false_east; /* x offset in meters */
double false_north; /* y offset in meters */
{
long alconforint( double r_maj, double r_min, double false_east,
double false_north) {
//long alconforint(r_maj,r_min,false_east,false_north)
//
//double r_maj; /* Major axis */
//double r_min; /* Minor axis */
//double false_east; /* x offset in meters */
//double false_north; /* y offset in meters */
//{
long i;
double temp;
double es;
Expand Down Expand Up @@ -102,13 +104,13 @@ return(OK);

/* ALASKA CONFORMAL forward equations--mapping lat,long to x,y
----------------------------------------------------------*/
long alconfor(lon, lat, x, y)
double lon; /* (I) Longitude */
double lat; /* (I) Latitude */
double *x; /* (O) X projection coordinate */
double *y; /* (O) Y projection coordinate */

{
long alconfor(double lon, double lat, double *x, double *y) {
//long alconfor(lon, lat, x, y)
//double lon; /* (I) Longitude */
//double lat; /* (I) Latitude */
//double *x; /* (O) X projection coordinate */
//double *y; /* (O) Y projection coordinate */
//{
double dlon;
double sinlon,coslon;
double sinphi,cosphi;
Expand Down
29 changes: 15 additions & 14 deletions wgrib2/gctpc/source/alconinv.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ static long n;

/* Initialize the ALASKA CONFORMAL projection
-----------------------------------------*/
long alconinvint(r_maj,r_min,false_east,false_north)

double r_maj; /* Major axis */
double r_min; /* Minor axis */
double false_east; /* x offset in meters */
double false_north; /* y offset in meters */
{
long alconinvint( double r_maj, double r_min, double false_east,
double false_north) {
//long alconinvint(r_maj,r_min,false_east,false_north)
//double r_maj; /* Major axis */
//double r_min; /* Minor axis */
//double false_east; /* x offset in meters */
//double false_north; /* y offset in meters */
//{
long i;
double temp;
double es;
Expand Down Expand Up @@ -102,13 +103,13 @@ return(OK);

/* ALASKA CONFORMAL inverse equations--mapping x,y to lat/long
----------------------------------------------------------*/
long alconinv(x, y, lon, lat)
double x; /* (O) X projection coordinate */
double y; /* (O) Y projection coordinate */
double *lon; /* (I) Longitude */
double *lat; /* (I) Latitude */

{
long alconinv( double x, double y, double *lon, double *lat) {
//long alconinv(x, y, lon, lat)
//double x; /* (O) X projection coordinate */
//double y; /* (O) Y projection coordinate */
//double *lon; /* (I) Longitude */
//double *lat; /* (I) Latitude */
//{
double dlon;
double sinlon,coslon;
double esphi;
Expand Down
29 changes: 16 additions & 13 deletions wgrib2/gctpc/source/azimfor.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ static double cos_p12; /* cos of center latitude */

/* Initialize the Azimuthal projection
----------------------------------*/
long azimforint(r_maj,center_lon,center_lat,false_east,false_north)
long azimforint( double r_maj, double center_lon, double center_lat,
double false_east, double false_north) {
// long azimforint(r_maj,center_lon,center_lat,false_east,false_north)

double r_maj; /* major axis */
double center_lon; /* center longitude */
double center_lat; /* center latitude */
double false_east; /* x offset in meters */
double false_north; /* y offset in meters */
{
// double r_maj; /* major axis */
// double center_lon; /* center longitude */
// double center_lat; /* center latitude */
// double false_east; /* x offset in meters */
// double false_north; /* y offset in meters */
// {
double temp; /* temporary variable */

/* Place parameters in static storage for common use
Expand All @@ -70,12 +72,13 @@ return(OK);

/* Azimuthal forward equations--mapping lat,long to x,y
---------------------------------------------------*/
long azimfor(lon, lat, x, y)
double lon; /* (I) Longitude */
double lat; /* (I) Latitude */
double *x; /* (O) X projection coordinate */
double *y; /* (O) Y projection coordinate */
{
long azimfor( double lon, double lat, double *x, double *y) {
// long azimfor(lon, lat, x, y)
// double lon; /* (I) Longitude */
// double lat; /* (I) Latitude */
// double *x; /* (O) X projection coordinate */
// double *y; /* (O) Y projection coordinate */
// {
double sinphi, cosphi; /* sin and cos value */
double dlon; /* delta longitude value */
double coslon; /* cos of longitude */
Expand Down
29 changes: 16 additions & 13 deletions wgrib2/gctpc/source/aziminv.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ static double cos_p12; /* cos of center latitude */

/* Initialize the Azimuthal projection
----------------------------------*/
long aziminvint(r_maj,center_lon,center_lat,false_east,false_north)
long aziminvint( double r_maj, double center_lon, double center_lat,
double false_east, double false_north) {
// long aziminvint(r_maj,center_lon,center_lat,false_east,false_north)

double r_maj; /* major axis */
double center_lon; /* center longitude */
double center_lat; /* center latitude */
double false_east; /* x offset in meters */
double false_north; /* y offset in meters */
{
// double r_maj; /* major axis */
// double center_lon; /* center longitude */
// double center_lat; /* center latitude */
// double false_east; /* x offset in meters */
// double false_north; /* y offset in meters */
// {

/* Place parameters in static storage for common use
-------------------------------------------------*/
Expand All @@ -66,12 +68,13 @@ return(OK);

/* Azimuthal inverse equations--mapping x,y to lat/long
---------------------------------------------------*/
long aziminv(x, y, lon, lat)
double x; /* (O) X projection coordinate */
double y; /* (O) Y projection coordinate */
double *lon; /* (I) Longitude */
double *lat; /* (I) Latitude */
{
long aziminv( double x, double y, double *lon, double *lat) {
// long aziminv(x, y, lon, lat)
// double x; /* (O) X projection coordinate */
// double y; /* (O) Y projection coordinate */
// double *lon; /* (I) Longitude */
// double *lat; /* (I) Latitude */
// {
double rh; /* height above ellipsoid */
double z; /* angle */
double sinz,cosz; /* sin of z and cos of z */
Expand Down
Loading

0 comments on commit 747db80

Please sign in to comment.