From 0d82e3cd280b4e0baff3e87d6418f3e04d55e977 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 19:06:27 -0500 Subject: [PATCH 01/48] Auto fixed clang-tidy bugprone-suspicious-string-compare warnings --- examples/C/sfc_pres_temp_rd.c | 8 ++++---- libdispatch/dcopy.c | 4 ++-- nc_test/tst_diskless.c | 24 ++++++++++++------------ nc_test/tst_formats.c | 2 +- nc_test/tst_inmemory.c | 18 +++++++++--------- nc_test/tst_small.c | 6 +++--- ncdump/ncvalidator.c | 8 ++++---- ncdump/tst_utf8.c | 4 ++-- nctest/tst_rename.c | 2 +- nczarr_test/test_zchunks.c | 4 ++-- nczarr_test/test_zchunks2.c | 16 ++++++++-------- 11 files changed, 48 insertions(+), 48 deletions(-) diff --git a/examples/C/sfc_pres_temp_rd.c b/examples/C/sfc_pres_temp_rd.c index c9f568f848..d0f9fb486d 100644 --- a/examples/C/sfc_pres_temp_rd.c +++ b/examples/C/sfc_pres_temp_rd.c @@ -140,22 +140,22 @@ main() them and check them. */ if ((retval = nc_get_att_text(ncid, lat_varid, UNITS, lat_units_in))) ERR(retval); - if (strncmp(lat_units_in, LAT_UNITS, strlen(LAT_UNITS))) + if (strncmp(lat_units_in, LAT_UNITS, strlen(LAT_UNITS)) != 0) return 2; if ((retval = nc_get_att_text(ncid, lon_varid, UNITS, lon_units_in))) ERR(retval); - if (strncmp(lon_units_in, LON_UNITS, strlen(LON_UNITS))) + if (strncmp(lon_units_in, LON_UNITS, strlen(LON_UNITS)) != 0) return 2; if ((retval = nc_get_att_text(ncid, pres_varid, UNITS, pres_units_in))) ERR(retval); - if (strncmp(pres_units_in, PRES_UNITS, strlen(PRES_UNITS))) + if (strncmp(pres_units_in, PRES_UNITS, strlen(PRES_UNITS)) != 0) return 2; if ((retval = nc_get_att_text(ncid, temp_varid, UNITS, temp_units_in))) ERR(retval); - if (strncmp(temp_units_in, TEMP_UNITS, strlen(TEMP_UNITS))) return 2; + if (strncmp(temp_units_in, TEMP_UNITS, strlen(TEMP_UNITS)) != 0) return 2; /* Close the file. */ if ((retval = nc_close(ncid))) diff --git a/libdispatch/dcopy.c b/libdispatch/dcopy.c index 1f0ff034aa..a1bf5c714d 100644 --- a/libdispatch/dcopy.c +++ b/libdispatch/dcopy.c @@ -77,7 +77,7 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2, int *equalp) return ret; /* Check the obvious. */ - if(size1 != size2 || class1 != class2 || strcmp(name1,name2)) + if(size1 != size2 || class1 != class2 || strcmp(name1,name2) != 0) return NC_NOERR; /* Check user-defined types in detail. */ @@ -109,7 +109,7 @@ NC_compare_nc_types(int ncid1, int typeid1, int ncid2, int typeid2, int *equalp) value1)) || (ret = nc_inq_enum_member(ncid2, typeid2, i, name2, value2)) || - strcmp(name1, name2) || memcmp(value1, value2, size1)) + strcmp(name1, name2) != 0 || memcmp(value1, value2, size1) != 0) { free(value1); free(value2); diff --git a/nc_test/tst_diskless.c b/nc_test/tst_diskless.c index d252de6d57..84758aa980 100644 --- a/nc_test/tst_diskless.c +++ b/nc_test/tst_diskless.c @@ -152,13 +152,13 @@ printf("*** testing diskless file with scalar vars..."); /* Check variables. */ if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, RESISTOR) || type_in != NC_INT || ndims_in != 0 || + if (strcmp(name_in, RESISTOR) != 0 || type_in != NC_INT || ndims_in != 0 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, CAPACITOR) || type_in != NC_FLOAT || ndims_in != 0 || + if (strcmp(name_in, CAPACITOR) != 0 || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, NUM555) || type_in != NC_SHORT || natts_in != 0) ERR; + if (strcmp(name_in, NUM555) != 0 || type_in != NC_SHORT || natts_in != 0) ERR; /* Read my absolutely crucial data. */ if (nc_get_vara_int(ncid, varid0, NULL, NULL, &int_data_in)) ERR; @@ -262,23 +262,23 @@ printf("*** testing diskless file with scalar vars..."); * of scientists to understand my data. */ if (nc_get_att_text(ncid, NC_GLOBAL, ATT0_NAME, att0_in)) ERR; att0_in[sizeof(ATT0_TEXT)] = '\0'; - if (strcmp(att0_in, ATT0_TEXT)) ERR; + if (strcmp(att0_in, ATT0_TEXT) != 0) ERR; /* Check dimensions. */ if (nc_inq_dim(ncid, dimid[0], name_in, &len_in)) ERR; - if (strcmp(name_in, DIM0_NAME) || len_in != 0) ERR; + if (strcmp(name_in, DIM0_NAME) != 0 || len_in != 0) ERR; if (nc_inq_dim(ncid, dimid[1], name_in, &len_in)) ERR; - if (strcmp(name_in, DIM1_NAME) || len_in != DIM1_LEN) ERR; + if (strcmp(name_in, DIM1_NAME) != 0 || len_in != DIM1_LEN) ERR; /* Check variables. */ if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR; - if (strcmp(name_in, VAR0_NAME) || type_in != NC_INT || ndims_in != NDIMS || + if (strcmp(name_in, VAR0_NAME) != 0 || type_in != NC_INT || ndims_in != NDIMS || dimid_in[0] != 0 || dimid_in[1] != 1 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR; - if (strcmp(name_in, VAR1_NAME) || type_in != NC_FLOAT || ndims_in != 0 || + if (strcmp(name_in, VAR1_NAME) != 0 || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, dimid_in, &natts_in)) ERR; - if (strcmp(name_in, VAR2_NAME) || type_in != NC_SHORT || ndims_in != 1 || + if (strcmp(name_in, VAR2_NAME) != 0 || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0) ERR; /* Read my absolutely crucial data. */ @@ -327,14 +327,14 @@ printf("*** testing diskless file with scalar vars..."); /* Check variables. */ if (nc_inq_var(ncid, varid0, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, DUNE) || type_in != NC_INT || ndims_in != 0 || + if (strcmp(name_in, DUNE) != 0 || type_in != NC_INT || ndims_in != 0 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid1, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, STAR_TREK) || type_in != NC_FLOAT || ndims_in != 0 || + if (strcmp(name_in, STAR_TREK) != 0 || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0) ERR; if (nc_inq_var(ncid, varid2, name_in, &type_in, &ndims_in, NULL, &natts_in)) ERR; - if (strcmp(name_in, STAR_WARS) || type_in != NC_SHORT || natts_in != 0) ERR; + if (strcmp(name_in, STAR_WARS) != 0 || type_in != NC_SHORT || natts_in != 0) ERR; /* Read my absolutely crucial data. */ if (nc_get_vara_int(ncid, varid0, NULL, NULL, &int_data_in)) ERR; diff --git a/nc_test/tst_formats.c b/nc_test/tst_formats.c index 898a12b2ab..1eacf0e15b 100644 --- a/nc_test/tst_formats.c +++ b/nc_test/tst_formats.c @@ -334,7 +334,7 @@ main(int argc, char **argv) var_dimid[1] != dimid[1] || natts != 0) ERR; if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR; if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR; - if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR; + if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t]) != 0) ERR; free(data_in); } diff --git a/nc_test/tst_inmemory.c b/nc_test/tst_inmemory.c index 2075dd2957..5cb6e76a90 100644 --- a/nc_test/tst_inmemory.c +++ b/nc_test/tst_inmemory.c @@ -383,27 +383,27 @@ verify_file(int ncid, int modified, int extra) CHECK(nc_get_att_text(ncid, NC_GLOBAL, ATT0_NAME, att0_in)); att0_in[sizeof(ATT0_TEXT)] = '\0'; - if (strcmp(att0_in, ATT0_TEXT)) CHECK(NC_EINVAL); + if (strcmp(att0_in, ATT0_TEXT) != 0) CHECK(NC_EINVAL); /* CHECK dimensions. */ CHECK(nc_inq_dim(ncid, dimid[0], name_in, &len_in)); - if (strcmp(name_in, DIM0_NAME)) CHECK(NC_EINVAL); + if (strcmp(name_in, DIM0_NAME) != 0) CHECK(NC_EINVAL); CHECK(nc_inq_dim(ncid, dimid[1], name_in, &len_in)); - if (strcmp(name_in, DIM1_NAME) || len_in != DIM1_LEN) CHECK(NC_EINVAL); + if (strcmp(name_in, DIM1_NAME) != 0 || len_in != DIM1_LEN) CHECK(NC_EINVAL); if(extra) { CHECK(nc_inq_dim(ncid, dimid[2], name_in, &len_in)); - if (strcmp(name_in, DIMX_NAME) || len_in != DIMX_LEN) CHECK(NC_EINVAL); + if (strcmp(name_in, DIMX_NAME) != 0 || len_in != DIMX_LEN) CHECK(NC_EINVAL); } /* CHECK variables. */ CHECK(nc_inq_var(ncid, varid[0], name_in, &type_in, &ndims_in, dimid_in, &natts_in)); - if (strcmp(name_in, VAR0_NAME) || type_in != NC_INT || ndims_in != NDIMS0 || + if (strcmp(name_in, VAR0_NAME) != 0 || type_in != NC_INT || ndims_in != NDIMS0 || dimid_in[0] != 0 || dimid_in[1] != 1 || natts_in != 0) CHECK(NC_EINVAL); CHECK(nc_inq_var(ncid, varid[1], name_in, &type_in, &ndims_in, dimid_in, &natts_in)); - if (strcmp(name_in, VAR1_NAME) || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0) + if (strcmp(name_in, VAR1_NAME) != 0 || type_in != NC_SHORT || ndims_in != 1 || dimid_in[0] != 1 || natts_in != 0) CHECK(NC_EINVAL); CHECK(nc_inq_var(ncid, varid[2], name_in, &type_in, &ndims_in, dimid_in, &natts_in)); - if (strcmp(name_in, VAR2_NAME) || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0) + if (strcmp(name_in, VAR2_NAME) != 0 || type_in != NC_FLOAT || ndims_in != 0 || natts_in != 0) CHECK(NC_EINVAL); CHECK(nc_get_var_int(ncid, varid[0], nightdata_in)); @@ -422,7 +422,7 @@ verify_file(int ncid, int modified, int extra) if(modified) { size_t unlimlen; CHECK(nc_inq_var(ncid, varid[3], name_in, &type_in, &ndims_in, dimid_in, &natts_in)); - if (strcmp(name_in, VAR3_NAME) || type_in != NC_INT || ndims_in != 1 || + if (strcmp(name_in, VAR3_NAME) != 0 || type_in != NC_INT || ndims_in != 1 || dimid_in[0] != 0 || natts_in != 0) CHECK(NC_EINVAL); CHECK(nc_inq_dimlen(ncid, dimid_in[0], &unlimlen)); CHECK(nc_get_var_int(ncid, varid[3], milesdata_in)); @@ -434,7 +434,7 @@ verify_file(int ncid, int modified, int extra) if(extra) { size_t xlen; CHECK(nc_inq_var(ncid, varid[4], name_in, &type_in, &ndims_in, dimid_in, &natts_in)); - if (strcmp(name_in, VARX_NAME) || type_in != NC_INT || ndims_in != 1 || + if (strcmp(name_in, VARX_NAME) != 0 || type_in != NC_INT || ndims_in != 1 || dimid_in[0] != dimid[2] || natts_in != 0) CHECK(NC_EINVAL); CHECK(nc_inq_dimlen(ncid, dimid_in[0], &xlen)); CHECK(nc_get_var_int(ncid, varid[4], expenses_in)); diff --git a/nc_test/tst_small.c b/nc_test/tst_small.c index 1f4d7e3c23..ae94cc63d4 100644 --- a/nc_test/tst_small.c +++ b/nc_test/tst_small.c @@ -122,7 +122,7 @@ test_small_atts(const char *testfile) if (nc_inq_attlen(ncid, NC_GLOBAL, ATT_NAME, &len_in)) ERR; if (len_in != t + 1) ERR; if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, att_in)) ERR; - if (strncmp(att_in, att, t)) ERR; + if (strncmp(att_in, att, t) != 0) ERR; if (nc_close(ncid)) ERR; } } @@ -184,7 +184,7 @@ test_small_unlim(const char *testfile) if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR; if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR; for (i = 0; i < NUM_VALS; i++) - if (strncmp(data[i], data_in[i], STR_LEN)) ERR; + if (strncmp(data[i], data_in[i], STR_LEN) != 0) ERR; if (nc_close(ncid)) ERR; return 0; } @@ -229,7 +229,7 @@ test_small_fixed(const char *testfile) if (ndims != 2 && nvars != 1 && natts != 0 && unlimdimid != -1) ERR; if (nc_get_var_text(ncid, varid, (char *)data_in)) ERR; for (i = 0; i < NUM_VALS; i++) - if (strncmp(data[i], data_in[i], STR_LEN)) ERR; + if (strncmp(data[i], data_in[i], STR_LEN) != 0) ERR; if (nc_close(ncid)) ERR; return 0; } diff --git a/ncdump/ncvalidator.c b/ncdump/ncvalidator.c index 852cbd2824..6986704804 100644 --- a/ncdump/ncvalidator.c +++ b/ncdump/ncvalidator.c @@ -1563,7 +1563,7 @@ val_get_NC_attrarray(int fd, * checking the tag when ndefined is zero. */ if (trace) { - if (strcmp(loc, "Global")) printf("\t\t"); + if (strcmp(loc, "Global") != 0) printf("\t\t"); printf("\ttag = ABSENT (no attribute defined)\n"); } return NC_NOERR; @@ -1582,9 +1582,9 @@ val_get_NC_attrarray(int fd, DEBUG_RETURN_ERROR(NC_ENOTNC) } if (trace) { - if (strcmp(loc, "Global")) printf("\t\t"); + if (strcmp(loc, "Global") != 0) printf("\t\t"); printf("\ttag = NC_ATTRIBUTE\n"); - if (strcmp(loc, "Global")) printf("\t\t"); + if (strcmp(loc, "Global") != 0) printf("\t\t"); printf("\tnumber of attributes = %d\n", ncap->ndefined); } @@ -1601,7 +1601,7 @@ val_get_NC_attrarray(int fd, } if (status == NC_NOERR) status = err; if (trace) { - if (strcmp(loc, "Global")) printf("\t\t"); + if (strcmp(loc, "Global") != 0) printf("\t\t"); printf("\tattribute name \"%s\", type = %s, length = %lld\n", ncap->value[i]->name, str_NC_type(ncap->value[i]->xtype), ncap->value[i]->nelems); diff --git a/ncdump/tst_utf8.c b/ncdump/tst_utf8.c index 02844febcf..8b775a5126 100644 --- a/ncdump/tst_utf8.c +++ b/ncdump/tst_utf8.c @@ -107,7 +107,7 @@ main(int argc, char **argv) }; #define NNAME ((char *) norm_utf8) #define NNAMELEN (sizeof norm_utf8) - if (strncmp(NNAME, name_in, NNAMELEN)) + if (strncmp(NNAME, name_in, NNAMELEN) != 0) ERR; } if (nc_inq_att(ncid, varid, UNITS, &att_type, &att_len)) @@ -118,7 +118,7 @@ main(int argc, char **argv) if (nc_get_att_text(ncid, varid, UNITS, strings_in)) ERR; strings_in[att_len] = '\0'; - if (strncmp(UNAME, strings_in, UNAMELEN)) + if (strncmp(UNAME, strings_in, UNAMELEN) != 0) ERR; if (nc_close(ncid)) ERR; diff --git a/nctest/tst_rename.c b/nctest/tst_rename.c index 256775ab04..3d9ab6e2e8 100644 --- a/nctest/tst_rename.c +++ b/nctest/tst_rename.c @@ -247,7 +247,7 @@ main(int argc, char **argv) if (nc_def_dim(ncid, QQ, QQ_SIZE, &qq_dimid)) ERR; if (nc_rename_dim(ncid, pp_dimid, NEW_NAME)) ERR; if (nc_inq_dimname(ncid, pp_dimid, name_in)) ERR; - if (strcmp(NEW_NAME, name_in)) ERR; + if (strcmp(NEW_NAME, name_in) != 0) ERR; if (nc_rename_dim(ncid, pp_dimid, QQ) != NC_ENAMEINUSE) ERR; if (nc_rename_dim(ncid, -1, ANOTHER_NAME) != NC_EBADDIM) ERR; if (nc_rename_dim(ncid, 12, ANOTHER_NAME) != NC_EBADDIM) ERR; diff --git a/nczarr_test/test_zchunks.c b/nczarr_test/test_zchunks.c index 75ba14f9f9..af49308a7a 100644 --- a/nczarr_test/test_zchunks.c +++ b/nczarr_test/test_zchunks.c @@ -73,7 +73,7 @@ main(int argc, char **argv) if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR; if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR; - if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 || + if (strcmp(var_name_in, V_SMALL) != 0 || xtype_in != NC_INT64 || ndims_in != 1 || natts_in != 0) ERR; /* Make sure chunking sizes are what we expect. */ @@ -200,7 +200,7 @@ main(int argc, char **argv) if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; if (nvars != 3 || ndims != 3 || ngatts != 0 || unlimdimid != -1) ERR; if (nc_inq_var(ncid, 0, var_name_in, &xtype_in, &ndims_in, &dimids_in, &natts_in)) ERR; - if (strcmp(var_name_in, V_SMALL) || xtype_in != NC_INT64 || ndims_in != 1 || + if (strcmp(var_name_in, V_SMALL) != 0 || xtype_in != NC_INT64 || ndims_in != 1 || natts_in != 0) ERR; /* Make sure chunking settings are what we expect. */ diff --git a/nczarr_test/test_zchunks2.c b/nczarr_test/test_zchunks2.c index 4766f8ac65..2ad80cf02e 100644 --- a/nczarr_test/test_zchunks2.c +++ b/nczarr_test/test_zchunks2.c @@ -110,14 +110,14 @@ main(int argc, char **argv) if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; if (nvars != NUM_VARS || ndims != NDIMS3 || ngatts != 0 || unlimdimid != -1) ERR; if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; - if (strcmp(name_in, VAR_NAME_JOE) || type_in != NC_FLOAT || ndims != NDIMS3 || + if (strcmp(name_in, VAR_NAME_JOE) != 0 || type_in != NC_FLOAT || ndims != NDIMS3 || dims_in[0] != dims[0] || dims_in[1] != dims[1] || dims_in[2] != dims[2] || natts != 0) ERR; if (nc_inq_dim(ncid, 0, name_in, &len_in[0])) ERR; - if (strcmp(name_in, X_NAME) || len_in[0] != XDIM_LEN) ERR; + if (strcmp(name_in, X_NAME) != 0 || len_in[0] != XDIM_LEN) ERR; if (nc_inq_dim(ncid, 1, name_in, &len_in[1])) ERR; - if (strcmp(name_in, Y_NAME) || len_in[1] != YDIM_LEN) ERR; + if (strcmp(name_in, Y_NAME) != 0 || len_in[1] != YDIM_LEN) ERR; if (nc_inq_dim(ncid, 2, name_in, &len_in[2])) ERR; - if (strcmp(name_in, Z_NAME) || len_in[2] != ZDIM_LEN) ERR; + if (strcmp(name_in, Z_NAME) != 0 || len_in[2] != ZDIM_LEN) ERR; if (nc_inq_var_chunking(ncid, 0, &storage, chunksizes)) ERR; if (storage != NC_CHUNKED) ERR; if (nc_close(ncid)) ERR; @@ -127,14 +127,14 @@ main(int argc, char **argv) if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; if (nvars != NUM_VARS || ndims != NDIMS3 || ngatts != 0 || unlimdimid != -1) ERR; if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; - if (strcmp(name_in, VAR_NAME_JOE) || type_in != NC_FLOAT || ndims != NDIMS3 || + if (strcmp(name_in, VAR_NAME_JOE) != 0 || type_in != NC_FLOAT || ndims != NDIMS3 || dims_in[0] != dims[0] || dims_in[1] != dims[1] || dims_in[2] != dims[2] || natts != 0) ERR; if (nc_inq_dim(ncid, 0, name_in, &len_in[0])) ERR; - if (strcmp(name_in, X_NAME) || len_in[0] != XDIM_LEN) ERR; + if (strcmp(name_in, X_NAME) != 0 || len_in[0] != XDIM_LEN) ERR; if (nc_inq_dim(ncid, 1, name_in, &len_in[1])) ERR; - if (strcmp(name_in, Y_NAME) || len_in[1] != YDIM_LEN) ERR; + if (strcmp(name_in, Y_NAME) != 0 || len_in[1] != YDIM_LEN) ERR; if (nc_inq_dim(ncid, 2, name_in, &len_in[2])) ERR; - if (strcmp(name_in, Z_NAME) || len_in[2] != ZDIM_LEN) ERR; + if (strcmp(name_in, Z_NAME) != 0 || len_in[2] != ZDIM_LEN) ERR; if (nc_inq_var_chunking(ncid, 0, &storage, chunksizes)) ERR; if (storage != NC_CHUNKED) ERR; if (calculate_waste(NDIMS3, len_in, chunksizes, &waste)) ERR; From 4188db28171bf2deea1de303cb612025578dd5f5 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 19:24:35 -0500 Subject: [PATCH 02/48] Auto fixed clang-tidy readability-redundant-control-flow warnings --- libdap2/daputil.c | 1 - libdispatch/dhttp.c | 1 - libdispatch/nctime.c | 21 --------------------- nc_test/t_nc.c | 1 - ncdump/chunkspec.c | 3 +-- ncdump/dumplib.c | 1 - ncdump/ncdump.c | 2 -- ncdump/nctime0.c | 1 - ncgen/generate.c | 1 - ncgen/util.c | 1 - ncgen3/escapes.c | 1 - ncgen3/genlib.c | 1 - ncgen3/load.c | 1 - 13 files changed, 1 insertion(+), 35 deletions(-) diff --git a/libdap2/daputil.c b/libdap2/daputil.c index f70237f21f..ed3daab924 100644 --- a/libdap2/daputil.c +++ b/libdap2/daputil.c @@ -631,7 +631,6 @@ normal: *s++ = *t++; } } *s = '\0'; - return; } diff --git a/libdispatch/dhttp.c b/libdispatch/dhttp.c index 1008ff62f2..70be551e63 100644 --- a/libdispatch/dhttp.c +++ b/libdispatch/dhttp.c @@ -512,7 +512,6 @@ trim(char* s) /* Ok, overwrite any leading whitespace */ for(q=s;*p;) {*q++ = *p++;} *q = '\0'; - return; } static size_t diff --git a/libdispatch/nctime.c b/libdispatch/nctime.c index b92eb4b5da..4d6915a5a2 100644 --- a/libdispatch/nctime.c +++ b/libdispatch/nctime.c @@ -55,7 +55,6 @@ cdTrim(char* s, int n) return; for(c=s; *c && ctimeType & Cd360 */ *doy = 30*(month-1) + date->day + leap_add ; } - return; } /* Convert epochal time (hours since 00 jan 1, 1970) @@ -235,8 +231,6 @@ Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime) if(!(timeType & CdChronCal)) htime->year = 0; /* Set year to 0 for Clim */ htime->timeType = timeType; CdMonthDay(&doy,htime); - - return; } /* Add 'nDel' times 'delTime' to epochal time 'begEtm', @@ -305,7 +299,6 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType, break; default: break; } - return; } /* Parse relative units, returning the unit and base component time. */ @@ -541,7 +534,6 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT break; default: break; } - return; } /* Value is in hours. Translate to units. */ @@ -655,7 +647,6 @@ Cdh2e(CdTime *htime, double *etime) } } *etime = (double) (day_cnt + doy - 1) * 24. + htime->hour; - return; } /* Validate the component time, return 0 if valid, 1 if not */ @@ -764,7 +755,6 @@ cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime) } } (void)cdValidateTime(timetype,*comptime); - return; } /* Convert ct to relunits (unit, basetime) */ @@ -778,7 +768,6 @@ cdComp2RelMixed(cdCompTime ct, cdUnitTime unit, cdCompTime basetime, double *rel hourdiff = cdDiffMixed(ct, basetime); *reltime = cdFromHours(hourdiff, unit); - return; } static void @@ -884,8 +873,6 @@ cdComp2Rel(cdCalenType timetype, cdCompTime comptime, char* relunits, double* re cdError("invalid unit in conversion"); break; } - - return; } /* Add (value,unit) to comptime. */ @@ -899,7 +886,6 @@ cdCompAdd(cdCompTime comptime, double value, cdCalenType calendar, cdCompTime *r cdComp2Rel(calendar, comptime, "hours", &reltime); reltime += value; cdRel2Comp(calendar, "hours", reltime, result); - return; } /* Add value in hours to ct, in the mixed Julian/Gregorian @@ -927,7 +913,6 @@ cdCompAddMixed(cdCompTime ct, double value, cdCompTime *result){ cdCompAdd(ZA, value-xg, cdJulian, result); } } - return; } /* Return value expressed in hours. */ @@ -969,7 +954,6 @@ cdRel2CompMixed(double reltime, cdUnitTime unit, cdCompTime basetime, cdCompTime reltime = cdToHours(reltime, unit); cdCompAddMixed(basetime, reltime, comptime); - return; } @@ -1079,8 +1063,6 @@ cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* com comptime->month = humantime.month; comptime->day = humantime.day; comptime->hour = humantime.hour; - - return; } /* rkr: output as ISO 8601 strings */ @@ -1166,7 +1148,6 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time, break; } } - return; } /* rkr: added for output closer to ISO 8601 */ @@ -1177,8 +1158,6 @@ cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, c cdRel2Comp(timetype, relunits, reltime, &comptime); cdComp2Iso(timetype, separator, comptime, chartime, chartime_size); - - return; } int diff --git a/nc_test/t_nc.c b/nc_test/t_nc.c index 7fdc285208..a13709f953 100644 --- a/nc_test/t_nc.c +++ b/nc_test/t_nc.c @@ -313,7 +313,6 @@ check_fill_seq(int id) bad_ret : (void) printf("couldn't get a var in check_fill_seq() %d\n", ii); - return; } static size_t indices[][3] = { diff --git a/ncdump/chunkspec.c b/ncdump/chunkspec.c index d3fca875f1..0d3e21f8dc 100644 --- a/ncdump/chunkspec.c +++ b/ncdump/chunkspec.c @@ -129,8 +129,7 @@ dimchunkspec_parse(int igrp, const char *spec) size_t chunksize; for(; pp > np && *pp != '/'; pp--) { /* look backwards for "/" */ - continue; - } + } if(*pp != '/') { /* no '/' found, no chunksize specified for dimension */ ret = NC_EINVAL; goto done; diff --git a/ncdump/dumplib.c b/ncdump/dumplib.c index 0df8763f25..e0785663b8 100644 --- a/ncdump/dumplib.c +++ b/ncdump/dumplib.c @@ -1441,7 +1441,6 @@ set_tostring_func(ncvar_t *varp) { varp->tinfo->class); } #endif /* USE_NETCDF4 */ - return; } diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index a47884ced1..cd9e35f3be 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -257,7 +257,6 @@ tztrim(char *ss) while (*ep) *cp++ = *ep++; *cp = '\0'; - return; } @@ -2246,7 +2245,6 @@ adapt_url_for_cache(char **pathp) if(pathp) {*pathp = path; path = NULL;} ncurifree(url); nullfree(path); - return; } #endif diff --git a/ncdump/nctime0.c b/ncdump/nctime0.c index e47a14f4d4..9ce54f89db 100644 --- a/ncdump/nctime0.c +++ b/ncdump/nctime0.c @@ -237,7 +237,6 @@ get_timeinfo(int ncid1, int varid1, ncvar_t *vp) { vp->has_timeval = true; free(units); } - return; } /* print_att_times diff --git a/ncgen/generate.c b/ncgen/generate.c index 339993233d..9eaf015f47 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -353,7 +353,6 @@ generate_primdata(Symbol* basetype, NCConstant* prim, Bytebuffer* codebuf, generator->constant(generator,basetype,target,codebuf); reclaimconstant(target); target = NULL; - return; } /* Avoid long argument lists */ diff --git a/ncgen/util.c b/ncgen/util.c index e5c73362d4..e3a5bb4abb 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -97,7 +97,6 @@ tztrim( while (*ep) *cp++ = *ep++; *cp = '\0'; - return; } static void diff --git a/ncgen3/escapes.c b/ncgen3/escapes.c index a6a838f855..5f7b923d18 100644 --- a/ncgen3/escapes.c +++ b/ncgen3/escapes.c @@ -92,5 +92,4 @@ expand_escapes( } } *s = '\0'; - return; } diff --git a/ncgen3/genlib.c b/ncgen3/genlib.c index a34ae5c096..fdfe8eb274 100644 --- a/ncgen3/genlib.c +++ b/ncgen3/genlib.c @@ -2026,5 +2026,4 @@ deescapify (char *name) /* assert(strlen(newname) <= strlen(name)); */ strncpy(name, newname, len); free(newname); - return; } diff --git a/ncgen3/load.c b/ncgen3/load.c index df0db88ee0..fa13853ffb 100644 --- a/ncgen3/load.c +++ b/ncgen3/load.c @@ -52,7 +52,6 @@ tztrim( while (*ep) *cp++ = *ep++; *cp = '\0'; - return; } From fb5c6b139c250d042c21554f94d337806ce6bced Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 19:41:08 -0500 Subject: [PATCH 03/48] Auto fixed clang-tidy readability-uppercase-literal-suffix warnings --- examples/C/format.c | 2 +- examples/C/pres_temp_4D_wr.c | 4 ++-- examples/C/sfc_pres_temp_wr.c | 4 ++-- libsrc4/nc4var.c | 8 +++---- nc_test/tst_diskless.c | 8 +++---- ncdap_test/t_dap3a.c | 2 +- ncdap_test/test_cvt.c | 2 +- ncdap_test/test_varm3.c | 42 +++++++++++++++++------------------ ncdump/dumplib.c | 2 +- ncdump/nccopy.c | 4 ++-- ncdump/ncdump.c | 2 +- plugins/H5Zdeflate.c | 2 +- 12 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/C/format.c b/examples/C/format.c index 40413dbe3f..3ffeb68eb0 100644 --- a/examples/C/format.c +++ b/examples/C/format.c @@ -45,7 +45,7 @@ main() /* Create a bunch of phoney data so we have something to write in the example file. */ for (fp=(float *)temp, i=0; i 0.0f) != (v2 > 0.0f)) /* avoid overflow */ + if((v1 > 0.0F) != (v2 > 0.0F)) /* avoid overflow */ return false; if(isfinite(v1) && isfinite(v2)) return (absval(v1 - v2) <= absval(float_eps * v2)) ; diff --git a/ncdump/nccopy.c b/ncdump/nccopy.c index a369f3bdfc..f15920fe8a 100644 --- a/ncdump/nccopy.c +++ b/ncdump/nccopy.c @@ -39,7 +39,7 @@ /* default bytes of memory we are willing to allocate for variable * values during copy */ #define COPY_BUFFER_SIZE (5000000) -#define COPY_CHUNKCACHE_PREEMPTION (1.0f) /* for copying, can eject fully read chunks */ +#define COPY_CHUNKCACHE_PREEMPTION (1.0F) /* for copying, can eject fully read chunks */ #define SAME_AS_INPUT (-1) /* default, if kind not specified */ #define CHUNK_THRESHOLD (8192) /* non-record variables with fewer bytes don't get chunked */ @@ -484,7 +484,7 @@ inq_var_chunking_params(int igrp, int ivarid, int ogrp, int ovarid, if(icontig == NC_CHUNKED && ocontig != NC_CHUNKED) { /* chunking only in input */ *chunkcache_nelemsp = 1; /* read one input chunk at a time */ *chunkcache_sizep = iprod; - *chunkcache_preemptionp = 1.0f; + *chunkcache_preemptionp = 1.0F; return stat; } diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index cd9e35f3be..15bc9d01c5 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -604,7 +604,7 @@ pr_att_valgs( if(isnan(ff)) { printf("NaNf%s", delim); } else if(isinf(ff)) { - if(ff < 0.0f) { + if(ff < 0.0F) { printf("-"); } printf("Infinityf%s", delim); diff --git a/plugins/H5Zdeflate.c b/plugins/H5Zdeflate.c index 93a637ef10..31726408ee 100644 --- a/plugins/H5Zdeflate.c +++ b/plugins/H5Zdeflate.c @@ -54,7 +54,7 @@ H5PLget_plugin_info(void) } -#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001f) + 12) +#define H5Z_DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * (double)1.001F) + 12) /*------------------------------------------------------------------------- From d5d24f756f169d74bc0aaec34faed68cae3a46e0 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 20:29:57 -0500 Subject: [PATCH 04/48] Manually fixed some bugprone-not-null-terminated-result warnings --- ncgen/ncgeny.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index a6ecf191a2..1ff2457a69 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -3403,11 +3403,11 @@ truefalse(NCConstant* con, int tag) { if(con->nctype == NC_STRING) { char* sdata = con->value.stringv.stringv; - if(strncmp(sdata,"false",NC_MAX_NAME) == 0 - || strncmp(sdata,"0",NC_MAX_NAME) == 0) + if(strcmp(sdata,"false") == 0 + || strcmp(sdata,"0") == 0) return 0; - else if(strncmp(sdata,"true",NC_MAX_NAME) == 0 - || strncmp(sdata,"1",NC_MAX_NAME) == 0) + else if(strcmp(sdata,"true") == 0 + || strcmp(sdata,"1") == 0) return 1; else goto fail; } else if(con->value.int32v < 0 || con->value.int32v > 1) From fa7f751b97516c391695a01025b90d3438fe28ab Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 20:30:25 -0500 Subject: [PATCH 05/48] Manually fixed some bugprone-assert-side-effect warnings --- nc_test/t_nc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nc_test/t_nc.c b/nc_test/t_nc.c index a13709f953..c77a53988f 100644 --- a/nc_test/t_nc.c +++ b/nc_test/t_nc.c @@ -110,8 +110,9 @@ createtestdims(int cdfid, size_t num_dims, const size_t *sizes, const char * con int dimid; while(num_dims-- != 0) { - assert( nc_def_dim(cdfid, *dim_names++, *sizes, &dimid) + assert( nc_def_dim(cdfid, *dim_names, *sizes, &dimid) == NC_NOERR); + dim_names++; sizes++; } @@ -131,7 +132,8 @@ testdims(int cdfid, size_t num_dims, size_t *sizes, const char * const dim_names (void) fprintf(stderr, "%d: %lu != %lu\n", ii, (unsigned long)size, (unsigned long)*sizes); assert( size == *sizes); - assert( strcmp(cp, *dim_names++) == 0); + assert( strcmp(cp, *dim_names) == 0); + dim_names++; } } From 7516c21032ffa1f29c610cc681b72419d1141f2d Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 20:33:11 -0500 Subject: [PATCH 06/48] Manually fixed some bugprone-suspicious-string-compare warnings --- libnczarr/zsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnczarr/zsync.c b/libnczarr/zsync.c index f2be0f5705..af6198324d 100644 --- a/libnczarr/zsync.c +++ b/libnczarr/zsync.c @@ -1726,7 +1726,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames) /* Capture row vs column major; currently, column major not used*/ { if((stat = NCJdictget(jvar,"order",&jvalue))) goto done; - if(strcmp(NCJstring(jvalue),"C")==1) + if(strcmp(NCJstring(jvalue),"C") > 0) ((NCZ_VAR_INFO_T*)var->format_var_info)->order = 1; else ((NCZ_VAR_INFO_T*)var->format_var_info)->order = 0; } From dededdf2ee51b3072cbb68590a68d15c7a47d487 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 20:44:29 -0500 Subject: [PATCH 07/48] Manually fixed some bugprone-unsafe-functions warnings --- libdispatch/dinfermodel.c | 4 +++- ncgen/main.c | 2 +- oc2/ocinternal.c | 8 +++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index fb04d4df7c..45c643dee0 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -1384,7 +1384,9 @@ openmagic(struct MagicFile* file) file->filelen = (long long)size; #endif } - rewind(file->fp); + int retval2 = fseek(file->fp, 0L, SEEK_SET); + if(retval2 != 0) + {status = errno; goto done;} } done: return check(status); diff --git a/ncgen/main.c b/ncgen/main.c index 78f5422b98..a42640500e 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -454,7 +454,7 @@ main( (void)fread(bom,1,1,fp); break; default: /* legal printable char, presumably; rewind */ - rewind(fp); + (void)fseek(fp, 0L, SEEK_SET); break; } } diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c index ef82342a38..c9225c0cf2 100644 --- a/oc2/ocinternal.c +++ b/oc2/ocinternal.c @@ -422,10 +422,16 @@ ocextractddsinfile(OCstate* state, OCtree* tree, OCflags flags) { OCerror stat = OC_NOERR; size_t ddslen, bod, bodfound; + int retVal; /* Read until we find the separator (or EOF)*/ ncbytesclear(state->packet); - rewind(tree->data.file); + retVal = fseek(tree->data.file, 0L, SEEK_SET); + if (retVal != 0) { + stat = OC_EDATADDS; + return OCTHROW(stat); + } + bodfound = 0; do { char chunk[1024]; From c92381721ebd2fe0b7d87ee9dd11376f379a6f95 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 21:03:27 -0500 Subject: [PATCH 08/48] Manually fixed some bugprone-suspicious-semicolon warnings --- libnczarr/zmap.c | 2 +- ncgen/semantics.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libnczarr/zmap.c b/libnczarr/zmap.c index 5b1c42c961..9c8d9e2c23 100644 --- a/libnczarr/zmap.c +++ b/libnczarr/zmap.c @@ -537,7 +537,7 @@ NCZ_freeenvv(int n, char** envv) char** p; if(envv == NULL) return; if(n < 0) - {for(n=0, p = envv; *p; n++); /* count number of strings */} + {for(n=0, p = envv; *p; n++) {}; /* count number of strings */} for(i=0;i Date: Sat, 16 Dec 2023 21:30:01 -0500 Subject: [PATCH 09/48] Auto fixed clang-tidy readability-redundant-declaration warnings --- libdap2/constraints.c | 1 - libdap4/d4util.c | 2 -- libdispatch/dfile.c | 2 -- libdispatch/nctime.c | 5 ----- liblib/nc_initialize.c | 10 ---------- libsrc4/nc4dispatch.c | 7 ------- ncgen/debug.c | 2 -- ncgen/genf77.c | 2 -- ncgen/genj.c | 2 -- ncgen/semantics.c | 1 - nctest/error.c | 2 -- oc2/ocnode.c | 1 - 12 files changed, 37 deletions(-) diff --git a/libdap2/constraints.c b/libdap2/constraints.c index e1c2308562..9d76ee6eb4 100644 --- a/libdap2/constraints.c +++ b/libdap2/constraints.c @@ -12,7 +12,6 @@ static void completesegments(NClist* fullpath, NClist* segments); static NCerror qualifyprojectionnames(DCEprojection* proj); static NCerror qualifyprojectionsizes(DCEprojection* proj); -static NCerror qualifyprojectionnames(DCEprojection* proj); static NCerror matchpartialname(NClist* nodes, NClist* segments, CDFnode** nodep); static int matchsuffix(NClist* matchpath, NClist* segments); static int iscontainer(CDFnode* node); diff --git a/libdap4/d4util.c b/libdap4/d4util.c index 8e422b5cad..09557db890 100644 --- a/libdap4/d4util.c +++ b/libdap4/d4util.c @@ -15,8 +15,6 @@ #include #endif -extern int mkstemp(char *template); - #define LBRACKET '[' #define RBRACKET ']' diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 7447db3511..f485478420 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -45,8 +45,6 @@ #endif -extern int NC_initialized; /**< True when dispatch table is initialized. */ - /* User-defined formats. */ NC_Dispatch *UDF0_dispatch_table = NULL; char UDF0_magic_number[NC_MAX_MAGIC_NUMBER_LEN + 1] = ""; diff --git a/libdispatch/nctime.c b/libdispatch/nctime.c index 4d6915a5a2..62f95095c3 100644 --- a/libdispatch/nctime.c +++ b/libdispatch/nctime.c @@ -244,9 +244,6 @@ CdAddDelTime(double begEtm, long nDel, CdDeltaTime delTime, CdTimeType timeType, long delMonths, delYears; CdTime bhtime, ehtime; - extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime); - extern void Cdh2e(CdTime *htime, double *etime); - switch(delTime.units){ case CdYear: delMonths = 12; @@ -466,8 +463,6 @@ CdDivDelTime(double begEtm, double endEtm, CdDeltaTime delTime, CdTimeType timeT CdTime bhtime, ehtime; int hoursInYear; - extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime); - switch(delTime.units){ case CdYear: delMonths = 12; diff --git a/liblib/nc_initialize.c b/liblib/nc_initialize.c index e98a5bc1e5..158c023fd8 100644 --- a/liblib/nc_initialize.c +++ b/liblib/nc_initialize.c @@ -11,13 +11,8 @@ #include "ncdispatch.h" -extern int NC3_initialize(void); -extern int NC3_finalize(void); - #ifdef USE_NETCDF4 #include "nc4internal.h" -extern int NC4_initialize(void); -extern int NC4_finalize(void); #endif #ifdef USE_HDF5 @@ -31,11 +26,6 @@ extern int NCD2_initialize(void); extern int NCD2_finalize(void); #endif -#ifdef ENABLE_DAP4 -extern int NCD4_initialize(void); -extern int NCD4_finalize(void); -#endif - #ifdef USE_PNETCDF extern int NCP_initialize(void); extern int NCP_finalize(void); diff --git a/libsrc4/nc4dispatch.c b/libsrc4/nc4dispatch.c index 474d6aee38..7c4f839528 100644 --- a/libsrc4/nc4dispatch.c +++ b/libsrc4/nc4dispatch.c @@ -25,13 +25,6 @@ extern NC_Dispatch UDF0_DISPATCH; extern NC_Dispatch UDF1_DISPATCH; #endif /* USE_UDF1 */ -#ifdef USE_NETCDF4 -/* Pointers to dispatch tables for user-defined formats. */ -extern NC_Dispatch *UDF0_dispatch_table; -extern NC_Dispatch *UDF1_dispatch_table; -#endif /* USE_NETCDF4 */ - - /** * @internal Initialize netCDF-4. If user-defined format(s) have been diff --git a/ncgen/debug.c b/ncgen/debug.c index 81f531f3fb..a62a8771f7 100644 --- a/ncgen/debug.c +++ b/ncgen/debug.c @@ -7,8 +7,6 @@ See COPYRIGHT for license information. #define TRACE -extern char* ncclassname(nc_class); - #ifdef TRACE #define T(fcn,mem) {if(trace) {fprintf(stderr,"X: %s: %p\n", fcn,mem);}} #else diff --git a/ncgen/genf77.c b/ncgen/genf77.c index 89c20ed076..d04419313b 100644 --- a/ncgen/genf77.c +++ b/ncgen/genf77.c @@ -18,7 +18,6 @@ static List* f77procs = NULL; /* bodies of generated procedures */ /* Forward */ static void genf77_definevardata(Symbol* vsym); static void genf77_defineattr(Symbol* asym); -static void genf77_definevardata(Symbol*); static void f77attrify(Symbol* asym, Bytebuffer* buf); static const char* f77varncid(Symbol* vsym); @@ -26,7 +25,6 @@ static const char* f77dimncid(Symbol* vsym); static const char* nfstype(nc_type nctype); static const char* nftype(nc_type type); -static const char* nfstype(nc_type nctype); static const char* ncftype(nc_type type); static const char* nfdtype(nc_type type); diff --git a/ncgen/genj.c b/ncgen/genj.c index ec8e194f8c..a125332499 100644 --- a/ncgen/genj.c +++ b/ncgen/genj.c @@ -18,8 +18,6 @@ extern List* vlenconstants; /* List;*/ /* Forward */ -static void genj_definevardata(Symbol* vsym); - static const char* jtypeallcaps(nc_type type); static const char* jtypecap(nc_type type); static const char* jtype(nc_type type); diff --git a/ncgen/semantics.c b/ncgen/semantics.c index cbd7276c06..43d0c456d4 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -23,7 +23,6 @@ static void processtypesizes(void); static void processvars(void); static void processattributes(void); static void processunlimiteddims(void); -static void processeconstrefs(void); static void processeconstrefsR(Symbol*,Datalist*); static void processroot(void); static void processvardata(void); diff --git a/nctest/error.c b/nctest/error.c index 50498b2ca4..92c2ae00df 100644 --- a/nctest/error.c +++ b/nctest/error.c @@ -54,7 +54,6 @@ error(fmt, va_alist) void off_errs() { - extern int ncopts; /* error options */ ncopts &= ~NC_FATAL; /* make errors nonfatal */ ncopts &= ~NC_VERBOSE; /* turn off error messages */ } @@ -67,7 +66,6 @@ off_errs() void on_errs() { - extern int ncopts; /* error options */ ncopts |= NC_FATAL; /* make errors fatal */ ncopts |= NC_VERBOSE; /* library prints error messages */ } diff --git a/oc2/ocnode.c b/oc2/ocnode.c index 6ad286306e..d66f40ac13 100644 --- a/oc2/ocnode.c +++ b/oc2/ocnode.c @@ -12,7 +12,6 @@ static OCerror mergedods1(OCnode* dds, OCnode* das); static OCerror mergeother1(OCnode* root, OCnode* das); static char* pathtostring(NClist* path, char* separator); static void computefullname(OCnode* node); -static OCerror mergeother1(OCnode* root, OCnode* das); static OCerror mergeother(OCnode* ddsroot, NClist* dasnodes); /* Process ocnodes to fix various semantic issues*/ From 42d0b48e8d58b144640013c51131aebf8bda51a2 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 21:50:57 -0500 Subject: [PATCH 10/48] Auto fixed clang-tidy readability-avoid-const-params-in-decls warnings --- libdispatch/daux.c | 2 +- libdispatch/ncjson.c | 2 +- libnczarr/zchunking.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdispatch/daux.c b/libdispatch/daux.c index 2011c93d42..538403533e 100644 --- a/libdispatch/daux.c +++ b/libdispatch/daux.c @@ -311,7 +311,7 @@ computefieldinfo(struct NCAUX_CMPD* cmpd) #define LBRACK '[' #define RBRACK ']' -static int gettype(const int q0, const int q1, int* unsignedp); +static int gettype(int q0, int q1, int* unsignedp); /* Look at q0 and q1) to determine type */ static int diff --git a/libdispatch/ncjson.c b/libdispatch/ncjson.c index acbe3e92bd..1a574a9b80 100644 --- a/libdispatch/ncjson.c +++ b/libdispatch/ncjson.c @@ -117,7 +117,7 @@ static int NCJcloneDict(const NCjson* dict, NCjson** clonep); static int NCJunparseR(const NCjson* json, NCJbuf* buf, unsigned flags); static int bytesappendquoted(NCJbuf* buf, const char* s); static int bytesappend(NCJbuf* buf, const char* s); -static int bytesappendc(NCJbuf* bufp, const char c); +static int bytesappendc(NCJbuf* bufp, char c); /* Hide everything for plugins */ #ifdef NETCDF_JSON_H diff --git a/libnczarr/zchunking.c b/libnczarr/zchunking.c index d2defd230a..81827183d1 100644 --- a/libnczarr/zchunking.c +++ b/libnczarr/zchunking.c @@ -10,7 +10,7 @@ static int pcounter = 0; /* Forward */ -static int compute_intersection(const NCZSlice* slice, const size64_t chunklen, unsigned char isunlimited, NCZChunkRange* range); +static int compute_intersection(const NCZSlice* slice, size64_t chunklen, unsigned char isunlimited, NCZChunkRange* range); static void skipchunk(const NCZSlice* slice, NCZProjection* projection); static int verifyslice(const NCZSlice* slice); From e1f22bc4edc34a5d49a1f1c499832a45ffb381f9 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 21:54:57 -0500 Subject: [PATCH 11/48] Manually fixed readability-suspicious-call-argument warnings --- libdispatch/dinstance.c | 2 +- libdispatch/dinstance_intern.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdispatch/dinstance.c b/libdispatch/dinstance.c index d2a66079b7..7f6088cb1b 100644 --- a/libdispatch/dinstance.c +++ b/libdispatch/dinstance.c @@ -235,7 +235,7 @@ nc_copy_data_all(int ncid, nc_type xtype, const void* memory, size_t count, void /* allocate the top-level */ if(count > 0) { - if((copy = calloc(xsize,count))==NULL) + if((copy = calloc(count,xsize))==NULL) {stat = NC_ENOMEM; goto done;} } stat = nc_copy_data(ncid,xtype,memory,count,copy); diff --git a/libdispatch/dinstance_intern.c b/libdispatch/dinstance_intern.c index c64398b434..b4b1b41f64 100644 --- a/libdispatch/dinstance_intern.c +++ b/libdispatch/dinstance_intern.c @@ -567,7 +567,7 @@ NC_copy_data_all(NC* nc, nc_type xtype, const void* memory, size_t count, void** if(xtype <= NC_STRING && count > 0) { xsize = NC_atomictypelen(xtype); - if((copy = calloc(xsize,count))==NULL) {stat = NC_ENOMEM; goto done;} + if((copy = calloc(count,xsize))==NULL) {stat = NC_ENOMEM; goto done;} if(xtype < NC_STRING) /* fixed-size atomic type */ memcpy(copy,memory,xsize*count); else { /* string type */ @@ -589,7 +589,7 @@ NC_copy_data_all(NC* nc, nc_type xtype, const void* memory, size_t count, void** xsize = utype->size; /* allocate the top-level */ if(count > 0) { - if((copy = calloc(xsize,count))==NULL) {stat = NC_ENOMEM; goto done;} + if((copy = calloc(count,xsize))==NULL) {stat = NC_ENOMEM; goto done;} } if((stat = NC_copy_data(nc,xtype,memory,count,copy))) (void)NC_reclaim_data_all(nc,xtype,copy,count); From edcfc61fe6a3a22742efd7ebc448c1fa6822eb86 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 22:36:39 -0500 Subject: [PATCH 12/48] Manually fixed performance-type-promotion-in-math-fn warnings --- nc_test4/tst_quantize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nc_test4/tst_quantize.c b/nc_test4/tst_quantize.c index c2694e7a9f..597b4afa74 100644 --- a/nc_test4/tst_quantize.c +++ b/nc_test4/tst_quantize.c @@ -1368,7 +1368,7 @@ main(int argc, char **argv) for (i = 0; i < DIM_LEN_SIMPLE; i++) { - if (fabs(float_data_in[i] - float_data[i]) > EPSILON) + if (fabsf(float_data_in[i] - float_data[i]) > EPSILON) ERR; if (fabs(double_data_in[i] - double_data[i]) > EPSILON) ERR; From 6f5a3b73714b6dd3cc914a268a161d960892bf4f Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 16 Dec 2023 23:14:41 -0500 Subject: [PATCH 13/48] Added a .clang-tidy config file --- .clang-tidy | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..e996b362f4 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,88 @@ +--- +Checks: "-*,\ +bugprone-*,\ +-bugprone-easily-swappable-parameters,\ +-bugprone-assignment-in-if-condition,\ +-bugprone-signed-char-misuse,\ +-bugprone-branch-clone,\ +-bugprone-narrowing-conversions,\ +-bugprone-macro-parentheses,\ +-bugprone-switch-missing-default-case,\ +-bugprone-suspicious-include,\ +-bugprone-reserved-identifier,\ +-bugprone-misplaced-widening-cast,\ +-bugprone-implicit-widening-of-multiplication-result,\ +-bugprone-suspicious-realloc-usage,\ +-bugprone-sizeof-expression,\ +cert*,\ +-cert-err33-c,\ +-cert-err34-c,\ +-cert-str34-c,\ +-cert-dcl03-c,\ +-cert-msc30-c,\ +-cert-msc50-cpp,\ +-cert-dcl37-c,\ +-cert-dcl51-cpp,\ +clang-analyzer-*,\ +-clang-analyzer-core.CallAndMessage,\ +-clang-analyzer-core.DivideZero,\ +-clang-analyzer-core.NonNullParamChecker,\ +-clang-analyzer-core.NullDereference,\ +-clang-analyzer-core.UndefinedBinaryOperatorResult,\ +-clang-analyzer-core.VLASize,\ +-clang-analyzer-core.uninitialized.ArraySubscript,\ +-clang-analyzer-core.uninitialized.Assign,\ +-clang-analyzer-core.uninitialized.Branch,\ +-clang-analyzer-cplusplus.Move,\ +-clang-analyzer-cplusplus.NewDelete,\ +-clang-analyzer-cplusplus.NewDeleteLeaks,\ +-clang-analyzer-cplusplus.PlacementNew,\ +-clang-analyzer-deadcode.DeadStores,\ +-clang-analyzer-optin.cplusplus.UninitializedObject,\ +-clang-analyzer-optin.cplusplus.VirtualCall,\ +-clang-analyzer-optin.mpi.MPI-Checker,\ +-clang-analyzer-optin.performance.Padding,\ +-clang-analyzer-optin.portability.UnixAPI,\ +-clang-analyzer-security.FloatLoopCounter,\ +-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\ +-clang-analyzer-security.insecureAPI.rand,\ +-clang-analyzer-security.insecureAPI.strcpy,\ +-clang-analyzer-unix.Malloc,\ +-clang-analyzer-unix.MallocSizeof,\ +-clang-analyzer-unix.MismatchedDeallocator,\ +-clang-analyzer-unix.cstring.NullArg,\ +-clang-analyzer-valist.Unterminated,\ +misc-*,\ +-misc-header-include-cycle,\ +-misc-include-cleaner,\ +-misc-no-recursion,\ +-misc-unused-parameters,\ +-misc-static-assert,\ +-misc-redundant-expression,\ +modernize-*,\ +-modernize-macro-to-enum,\ +mpi-*,\ +openmp-*,\ +performance-*,\ +-performance-no-int-to-ptr,\ +portability-*,\ +readability-*,\ +-readability-identifier-length,\ +-readability-isolate-declaration,\ +-readability-braces-around-statements,\ +-readability-magic-numbers,\ +-readability-else-after-return,\ +-readability-function-cognitive-complexity,\ +-readability-function-size,\ +-readability-non-const-parameter,\ +-readability-inconsistent-declaration-parameter-name,\ +-readability-avoid-unconditional-preprocessor-if,\ +-readability-named-parameter,\ +-readability-duplicate-include,\ +-readability-misleading-indentation,\ +-readability-avoid-const-params-in-decls,\ +-readability-redundant-declaration,\ +-readability-redundant-preprocessor,\ +" +#WarningsAsErrors: "*" +... From 6c249365f067b7d9b3b0613fae1cee8bc4edfd62 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 30 Nov 2023 17:16:05 +0000 Subject: [PATCH 14/48] Change `bbAppendn` argument type to `size_t` Fixes lots of warnings about conversions changing value --- ncgen/bytebuffer.c | 4 ++-- ncgen/bytebuffer.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index e0446a6c39..e06c3b4912 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -144,9 +144,9 @@ bbCatbuf(Bytebuffer* bb, const Bytebuffer* s) } int -bbAppendn(Bytebuffer* bb, const void* elem, const unsigned int n0) +bbAppendn(Bytebuffer* bb, const void* elem, const size_t n0) { - unsigned int n = n0; + size_t n = n0; if(bb == NULL || elem == NULL) return bbFail(); if(n == 0) {n = strlen((char*)elem);} while(!bbNeed(bb,(n+1))) {if(!bbSetalloc(bb,0)) return bbFail();} diff --git a/ncgen/bytebuffer.h b/ncgen/bytebuffer.h index 6ecbc5b5e7..10777c8a9c 100644 --- a/ncgen/bytebuffer.h +++ b/ncgen/bytebuffer.h @@ -1,6 +1,7 @@ /* Copyright 2018, UCAR/Unidata and OPeNDAP, Inc. See the COPYRIGHT file for more information. */ +#include #ifndef BYTEBUFFER_H #define BYTEBUFFER_H 1 @@ -33,7 +34,7 @@ EXTERNC int bbGet(Bytebuffer*,unsigned int); EXTERNC int bbSet(Bytebuffer*,unsigned int,char); EXTERNC int bbAppend(Bytebuffer*,const char); /* Add at Tail */ -EXTERNC int bbAppendn(Bytebuffer*,const void*,unsigned int); /* Add at Tail */ +EXTERNC int bbAppendn(Bytebuffer*, const void*, size_t); /* Add at Tail */ /* Insert 1 or more characters at given location */ EXTERNC int bbInsert(Bytebuffer*,const unsigned int,const char); From c80d71213dab500abbcc3a1d09c1f8aeb16a18a5 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 30 Nov 2023 17:16:54 +0000 Subject: [PATCH 15/48] Fix a bunch of sign conversion warnings from `ncgen.y` --- ncgen3/init.c | 3 ++- ncgen3/ncgen.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ncgen3/init.c b/ncgen3/init.c index 068fd0eb77..bc7aab75f5 100644 --- a/ncgen3/init.c +++ b/ncgen3/init.c @@ -4,6 +4,7 @@ * $Header: /upc/share/CVS/netcdf-3/ncgen3/init.c,v 1.6 1997/05/23 11:41:14 russ Exp $ *********************************************************************/ +#include #include #include #include "generic.h" @@ -23,7 +24,7 @@ int natts; /* number of attributes */ int nvdims; /* number of dimensions for variables */ int dimnum; /* dimension number index for variables */ int varnum; /* variable number index for attributes */ -int valnum; /* value number index for attributes */ +size_t valnum; /* value number index for attributes */ int rec_dim; /* number of the unlimited dimension, if any */ size_t var_len; /* variable length (product of dimensions) */ size_t rec_len; /* number of elements for a record of data */ diff --git a/ncgen3/ncgen.h b/ncgen3/ncgen.h index a51b1d79a2..d5a157cec0 100644 --- a/ncgen3/ncgen.h +++ b/ncgen3/ncgen.h @@ -6,6 +6,7 @@ * $Header: /upc/share/CVS/netcdf-3/ncgen3/ncgen.h,v 1.8 1997/07/07 18:27:04 russ Exp $ *********************************************************************/ +#include #define MAX_NC_ATTSIZE 20000 /* max size of attribute (for ncgen) */ #define MAXTRST 5000 /* max size of string value (for ncgen) */ @@ -23,7 +24,7 @@ extern int natts; /* number of attributes */ extern int nvdims; /* number of dimensions for variables */ extern int dimnum; /* dimension number index for variables */ extern int varnum; /* variable number index for attributes */ -extern int valnum; /* number of values specified for variable */ +extern size_t valnum; /* number of values specified for variable */ extern int rec_dim; /* number of the unlimited dimension, if any */ extern size_t rec_len; /* number of elements for a record of data */ extern size_t var_len; /* variable length (product of dimensions) */ From 83faffacaa0fd4f26326b09167e91683434cd936 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 30 Nov 2023 17:18:34 +0000 Subject: [PATCH 16/48] Change type of string length member Fixes lots of sign-conversion warnings --- ncgen/data.h | 5 +++-- ncgen/genchar.c | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ncgen/data.h b/ncgen/data.h index f822ff66fc..8342a2d7b1 100644 --- a/ncgen/data.h +++ b/ncgen/data.h @@ -3,6 +3,7 @@ * See netcdf/COPYRIGHT file for copying and redistribution conditions. *********************************************************************/ +#include #ifndef DATA_H #define DATA_H 1 @@ -36,8 +37,8 @@ typedef union Constvalue { float floatv; /* NC_FLOAT*/ double doublev; /* NC_DOUBLE*/ struct Stringv { /* NC_STRING*/ - int len; - char* stringv; + size_t len; + char* stringv; } stringv; struct Opaquev { /* NC_OPAQUE*/ int len; /* length as originally written (rounded to even number)*/ diff --git a/ncgen/genchar.c b/ncgen/genchar.c index 25ff0622fb..8526989eb9 100644 --- a/ncgen/genchar.c +++ b/ncgen/genchar.c @@ -4,6 +4,7 @@ *********************************************************************/ #include "includes.h" +#include /******************************************************/ /* Code for generating char variables etc; mostly @@ -14,7 +15,7 @@ static size_t gen_charconstant(NCConstant*, Bytebuffer*, int fillchar); static int getfillchar(Datalist* fillsrc); static void gen_leafchararray(Dimset*,int,Datalist*,Bytebuffer*, int); -static NCConstant* makeconst(int lineno, int len, char* str); +static NCConstant* makeconst(int lineno, size_t len, char* str); static void rebuildsingletons(Datalist* data); /* @@ -237,7 +238,7 @@ gen_charconstant(NCConstant* con, Bytebuffer* databuf, int fillchar) /* Create a new string constant */ static NCConstant* -makeconst(int lineno, int len, char* str) +makeconst(int lineno, size_t len, char* str) { NCConstant* con = nullconst(); con->nctype = NC_STRING; @@ -245,8 +246,8 @@ makeconst(int lineno, int len, char* str) con->filled = 0; con->value.stringv.len = len; /* We cannot use strdup because str might have embedded nuls */ - con->value.stringv.stringv = (char*)ecalloc((size_t)len+1); - memcpy((void*)con->value.stringv.stringv,(void*)str, (size_t)len); + con->value.stringv.stringv = (char*)ecalloc(len+1); + memcpy((void*)con->value.stringv.stringv,(void*)str, len); con->value.stringv.stringv[len] = '\0'; return con; } From 57e754f5795a653d15863b5878bd04acead2425b Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 30 Nov 2023 17:29:43 +0000 Subject: [PATCH 17/48] Silence lots conversion warnings in ncgen --- ncgen/bindata.c | 2 +- ncgen/bytebuffer.c | 3 ++- ncgen/cvt.c | 6 +++--- ncgen/data.c | 14 +++++++------- ncgen/genbin.c | 10 +++++----- ncgen/genc.c | 15 ++++++++------- ncgen/genchar.c | 2 +- ncgen/semantics.c | 2 +- ncgen/util.c | 10 ++++------ 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ncgen/bindata.c b/ncgen/bindata.c index 1482176d03..5469ff2e21 100644 --- a/ncgen/bindata.c +++ b/ncgen/bindata.c @@ -105,7 +105,7 @@ bin_listbegin(Generator* generator, Symbol* tsym, void* liststate, ListClass lc, { if(uidp) *uidp = ++bin_uid; if(lc == LISTCOMPOUND) - *((int*)liststate) = bbLength(buf); + *((int*)liststate) = (int)bbLength(buf); return 1; } diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index e06c3b4912..63bc50267d 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -2,6 +2,7 @@ See the COPYRIGHT file for more information. */ #include "config.h" +#include #include #include #include @@ -22,7 +23,7 @@ int bbdebug = 1; /* For debugging purposes*/ -static long +static int bbFail(void) { fflush(stdout); diff --git a/ncgen/cvt.c b/ncgen/cvt.c index dfd033087e..b7daa7483b 100644 --- a/ncgen/cvt.c +++ b/ncgen/cvt.c @@ -9,6 +9,7 @@ #include "bytebuffer.h" #include "isnan.h" #include +#include #ifndef nulldup @@ -71,7 +72,7 @@ case CASE(NC_CHAR,NC_CHAR): tmp.charv = src->value.charv; break; case CASE(NC_CHAR,NC_BYTE): - tmp.int8v = (unsigned char)src->value.charv; + tmp.int8v = (signed char)src->value.charv; break; case CASE(NC_CHAR,NC_UBYTE): tmp.uint8v = (unsigned char)src->value.charv; @@ -636,10 +637,9 @@ convertstringtochars(NCConstant* str) { int i; Datalist* dl; - int slen; char* s; - slen = str->value.stringv.len; + size_t slen = str->value.stringv.len; dl = builddatalist(slen); s = str->value.stringv.stringv; for(i=0;i /* for isprint() */ +#include #include "netcdf_aux.h" #include "netcdf_filter.h" @@ -32,12 +33,12 @@ void genbin_netcdf(void) { int stat, ncid; - int idim, ivar, iatt; + size_t idim, ivar, iatt; int ndims, nvars, natts, ngatts; const char* filename = rootgroup->file.filename; #ifdef USE_NETCDF4 - int ntyps, ngrps, igrp; + int ntyps, ngrps; #endif ndims = listlength(dimdefs); @@ -75,7 +76,7 @@ genbin_netcdf(void) #ifdef USE_NETCDF4 /* Define the group structure */ /* walking grdefs list will do a preorder walk of all defined groups*/ - for(igrp=0;igrpcontainer->nc_id,gsym->name,&gsym->nc_id); @@ -86,8 +87,7 @@ genbin_netcdf(void) #ifdef USE_NETCDF4 /* Define the types*/ if (ntyps > 0) { - int ityp; - for(ityp = 0; ityp < ntyps; ityp++) { + for(size_t ityp = 0; ityp < ntyps; ityp++) { Symbol* tsym = (Symbol*)listget(typdefs,ityp); genbin_deftype(tsym); } diff --git a/ncgen/genc.c b/ncgen/genc.c index 51b74abfcd..65aec192ab 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -6,6 +6,7 @@ #include "includes.h" #include /* for isprint() */ +#include #ifdef ENABLE_C @@ -37,13 +38,15 @@ static void genc_writeattr(Generator*,Symbol*,Bytebuffer*,int,size_t*,size_t*); void genc_netcdf(void) { - int idim, ivar, iatt, maxdims; + size_t idim, ivar, iatt; + int maxdims; int ndims, nvars, natts, ngatts; char* cmode_string; const char *filename = rootgroup->file.filename; #ifdef USE_NETCDF4 - int igrp,ityp, ngrps, ntyps; + size_t igrp, ityp; + int ngrps, ntyps; #endif ndims = listlength(dimdefs); @@ -844,7 +847,7 @@ Generate the C code for defining a given type static void genc_deftype(Symbol* tsym) { - int i; + size_t i; ASSERT(tsym->objectclass == NC_TYPE); switch (tsym->subclass) { @@ -1032,8 +1035,7 @@ genc_writevar(Generator* generator, Symbol* vsym, Bytebuffer* code, /* Dump any vlen decls first */ generator_getstate(generator,(void**)&vlendecls); if(vlendecls != NULL && listlength(vlendecls) > 0) { - int i; - for(i=0;i 0) { - int i; - for(i=0;ivalue.int8v); break; case NC_UBYTE: - bbAppend(databuf,con->value.uint8v); + bbAppend(databuf,(char)con->value.uint8v); break; case NC_STRING: constsize = con->value.stringv.len; diff --git a/ncgen/semantics.c b/ncgen/semantics.c index 307e3deb54..1061ac8795 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -1338,7 +1338,7 @@ explode(NCConstant* con) len = con->value.stringv.len; chars = builddatalist(len); p = con->value.stringv.stringv; -fprintf(stderr,"p[%d]=|%s|\n",con->value.stringv.len,p); +fprintf(stderr,"p[%zu]=|%s|\n",con->value.stringv.len,p); for(i=0;inctype = NC_CHAR; diff --git a/ncgen/util.c b/ncgen/util.c index e5c73362d4..5b40dd0bbe 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -374,7 +374,7 @@ prefixtostring(List* prefix, char* separator) { size_t slen=0; int plen; - int i; + size_t i; char* result; if(prefix == NULL) return pooldup(""); plen = prefixlen(prefix); @@ -439,11 +439,10 @@ List* prefixdup(List* prefix) { List* dupseq; - int i; if(prefix == NULL) return listnew(); dupseq = listnew(); listsetalloc(dupseq, (size_t)listlength(prefix)); - for(i=0;i Date: Thu, 30 Nov 2023 18:01:53 +0000 Subject: [PATCH 18/48] Use `char` consistently for `fillchar` in `genchar.c` --- ncgen/genchar.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ncgen/genchar.c b/ncgen/genchar.c index 320473c527..b888c13670 100644 --- a/ncgen/genchar.c +++ b/ncgen/genchar.c @@ -12,9 +12,9 @@ /******************************************************/ /*Forward*/ -static size_t gen_charconstant(NCConstant*, Bytebuffer*, int fillchar); -static int getfillchar(Datalist* fillsrc); -static void gen_leafchararray(Dimset*,int,Datalist*,Bytebuffer*, int); +static size_t gen_charconstant(NCConstant*, Bytebuffer*, char fillchar); +static char getfillchar(Datalist* fillsrc); +static void gen_leafchararray(Dimset*,int,Datalist*,Bytebuffer*, char); static NCConstant* makeconst(int lineno, size_t len, char* str); static void rebuildsingletons(Datalist* data); @@ -54,7 +54,7 @@ Two special cases: void gen_chararray(Dimset* dimset, int dimindex, Datalist* data, Bytebuffer* charbuf, Datalist* fillsrc) { - int fillchar = getfillchar(fillsrc); + char fillchar = getfillchar(fillsrc); int rank = rankfor(dimset); int firstunlim = findunlimited(dimset,0); int nunlim = countunlimited(dimset); @@ -95,7 +95,7 @@ gen_chararray(Dimset* dimset, int dimindex, Datalist* data, Bytebuffer* charbuf, static void gen_leafchararray(Dimset* dimset, int dimindex, Datalist* data, - Bytebuffer* charbuf, int fillchar) + Bytebuffer* charbuf, char fillchar) { int i; size_t expectedsize,xproduct,unitsize; @@ -206,7 +206,7 @@ gen_charseq(Datalist* data, Bytebuffer* databuf) } static size_t -gen_charconstant(NCConstant* con, Bytebuffer* databuf, int fillchar) +gen_charconstant(NCConstant* con, Bytebuffer* databuf, char fillchar) { /* Following cases should be consistent with isstringable */ size_t constsize = 1; @@ -252,23 +252,21 @@ makeconst(int lineno, size_t len, char* str) return con; } -static int +static char getfillchar(Datalist* fillsrc) { /* Determine the fill char */ - int fillchar = 0; if(fillsrc != NULL && fillsrc->length > 0) { NCConstant* ccon = fillsrc->data[0]; if(ccon->nctype == NC_CHAR) { - fillchar = ccon->value.charv; + return ccon->value.charv; } else if(ccon->nctype == NC_STRING) { if(ccon->value.stringv.len > 0) { - fillchar = ccon->value.stringv.stringv[0]; + return ccon->value.stringv.stringv[0]; } } } - if(fillchar == 0) fillchar = NC_FILL_CHAR; /* default */ - return fillchar; + return NC_FILL_CHAR; /* default */ } From c1977cacc9e716761709f3d03fb9e94667232de2 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 1 Dec 2023 09:24:33 +0000 Subject: [PATCH 19/48] Fix some sign conversion warnings in ncgen --- ncgen/data.c | 3 +-- ncgen/dump.c | 4 ++-- ncgen/genc.c | 2 +- ncgen/genchar.c | 2 +- ncgen/generate.c | 7 ++++--- ncgen/genf77.c | 21 ++++++++++---------- ncgen/genj.c | 4 +++- ncgen/getfill.c | 6 +++--- ncgen/semantics.c | 50 +++++++++++++++++++---------------------------- ncgen/util.c | 4 ++-- ncgen/util.h | 3 ++- 11 files changed, 49 insertions(+), 57 deletions(-) diff --git a/ncgen/data.c b/ncgen/data.c index 19d6393b16..51c339bc4b 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -629,11 +629,10 @@ dlset(Datalist* dl, size_t pos, NCConstant* constant) NCConstant* dlremove(Datalist* dl, size_t pos) { - int i; NCConstant* con = NULL; ASSERT(dl->length > 0 && pos < dl->length); con = dl->data[pos]; - for(i=pos+1;ilength;i++) + for(size_t i=pos+1;ilength;i++) dl->data[i-1] = dl->data[i]; dl->length--; return con; diff --git a/ncgen/dump.c b/ncgen/dump.c index 004009840c..374d47ba15 100644 --- a/ncgen/dump.c +++ b/ncgen/dump.c @@ -6,6 +6,7 @@ /* $Header: /upc/share/CVS/netcdf-3/ncgen/dump.c,v 1.3 2010/05/24 19:59:57 dmh Exp $ */ #include "includes.h" +#include #include "dump.h" #undef DEBUGSRC @@ -51,14 +52,13 @@ bufdump(Datalist* list, Bytebuffer* buf) { int i; NCConstant** dpl; - unsigned int count; if(list == NULL) { bbCat(buf,"NULL"); return; } - count = list->length; + size_t count = list->length; for(dpl=list->data,i=0;inctype) { diff --git a/ncgen/genc.c b/ncgen/genc.c index 65aec192ab..0cab7aac2d 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -767,7 +767,7 @@ ctypename(Symbol* tsym) static void definectype(Symbol* tsym) { - int i,j; + size_t i,j; ASSERT(tsym->objectclass == NC_TYPE); switch (tsym->subclass) { diff --git a/ncgen/genchar.c b/ncgen/genchar.c index b888c13670..f7dd1b4565 100644 --- a/ncgen/genchar.c +++ b/ncgen/genchar.c @@ -284,7 +284,7 @@ rebuildsingletons(Datalist* data) } if(cccount > 1) { Bytebuffer* accum = bbNew(); - int len = 0; /* >0 implies doing accum */ + size_t len = 0; /* >0 implies doing accum */ Datalist* newlist = builddatalist(datalistlen(data)); int lineno = 0; NCConstant* con; diff --git a/ncgen/generate.c b/ncgen/generate.c index 339993233d..5c4d7070bd 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -116,7 +116,8 @@ generate_basetype(Symbol* tsym, NCConstant* con, Bytebuffer* codebuf, Datalist* break; case NC_COMPOUND: { - int i,uid, nfields, dllen; + size_t i, dllen; + int uid, nfields; if(con == NULL || isfillconst(con)) { Datalist* fill = (filler==NULL?getfiller(tsym):filler); ASSERT(fill->length == 1); @@ -212,7 +213,7 @@ static void generate_fieldarray(Symbol* basetype, NCConstant* con, Dimset* dimset, Bytebuffer* codebuf, Datalist* filler, Generator* generator) { - int i; + size_t i; int chartype = (basetype->typ.typecode == NC_CHAR); Datalist* data; int rank = rankfor(dimset); @@ -372,7 +373,7 @@ struct Args { }; static void -generate_arrayR(struct Args* args, int dimindex, size_t* index, Datalist* data) +generate_arrayR(struct Args* args, size_t dimindex, size_t* index, Datalist* data) { size_t counter,stop; size_t count[NC_MAX_VAR_DIMS]; diff --git a/ncgen/genf77.c b/ncgen/genf77.c index 89c20ed076..22f0beea06 100644 --- a/ncgen/genf77.c +++ b/ncgen/genf77.c @@ -5,6 +5,7 @@ *********************************************************************/ #include "includes.h" +#include #ifdef ENABLE_F77 @@ -46,7 +47,7 @@ static void genf77_writeattr(Generator*,Symbol*,Bytebuffer*,int,size_t*,size_t*) void genf77_netcdf(void) { - int idim, ivar, iatt; + size_t idim, ivar, iatt; int ndims, nvars, natts, ngatts; char* cmode_string; const char *filename = rootgroup->file.filename; @@ -170,12 +171,12 @@ genf77_netcdf(void) /* F77 (as defined for ncgen3) requires per-type vectors for attributes */ if(ngatts > 0 || natts > 0) { nc_type nctype; - int pertypesizes[NC_DOUBLE+1]; + size_t pertypesizes[NC_DOUBLE+1]; for(nctype=0;nctype<=NC_DOUBLE;nctype++) {pertypesizes[nctype] = 0;} if(ngatts > 0) { for(iatt = 0; iatt < ngatts; iatt++) { Symbol* gasym = (Symbol*)listget(gattdefs,iatt); - int count = gasym->data->length; + size_t count = gasym->data->length; int typecode = gasym->typ.basetype->typ.typecode; if(count == 0) continue; if(pertypesizes[typecode] < count) @@ -185,7 +186,7 @@ genf77_netcdf(void) if(natts > 0) { for(iatt = 0; iatt < natts; iatt++) { Symbol* asym = (Symbol*)listget(attdefs,iatt); - int count = asym->data->length; + size_t count = asym->data->length; int typecode = asym->typ.basetype->typ.typecode; if(count == 0) continue; if(pertypesizes[typecode] < count) @@ -254,7 +255,7 @@ genf77_netcdf(void) if(dimset->ndims > 0) { /* Remember; FORTRAN dimension order is reversed */ for(idim = 0; idim < dimset->ndims; idim++) { - int reverse = (dimset->ndims - idim) - 1; + int reverse = (dimset->ndims - (int)idim) - 1; Symbol* dsym = dimset->dimsyms[reverse]; bbprintf0(stmt, "%s_dims(%d) = %s\n", @@ -336,7 +337,6 @@ genf77_netcdf(void) f77skip(); f77comment("perform variable data writes"); for(ivar = 0; ivar < nvars; ivar++) { - int i; Symbol* vsym = (Symbol*)listget(vardefs,ivar); /* Call the procedures for writing unlimited variables */ if(vsym->data != NULL @@ -346,7 +346,7 @@ genf77_netcdf(void) /* dump any calls */ generator_getstate(f77_generator,(void*)&calllist); ASSERT(calllist != NULL); - for(i=0;i 0) { - int i; f77skip(); - for(i=0;i #ifdef ENABLE_JAVA @@ -39,7 +40,8 @@ static void genj_writeattr(Generator*,Symbol*,Bytebuffer*,int,size_t*,size_t*); void genjava_netcdf(void) { - int idim, ivar, iatt, maxdims; + size_t idim, ivar, iatt; + int maxdims; int ndims, nvars, natts, ngatts; const char *filename = rootgroup->file.filename; diff --git a/ncgen/getfill.c b/ncgen/getfill.c index 745de59392..0fd0659807 100644 --- a/ncgen/getfill.c +++ b/ncgen/getfill.c @@ -6,6 +6,7 @@ #include "includes.h" #include "dump.h" +#include /* mnemonic*/ #define TOPLEVEL 1 @@ -110,7 +111,6 @@ fill(Symbol* tsym, Datalist* filler) static void filllist(Symbol* tsym, Datalist* dl) { - int i; Datalist* sublist; NCConstant* con = NULL; @@ -124,7 +124,7 @@ filllist(Symbol* tsym, Datalist* dl) break; case NC_COMPOUND: sublist = builddatalist(listlength(tsym->subnodes)); - for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* field = (Symbol*)listget(tsym->subnodes,i); filllist(field->typ.basetype,sublist); } @@ -149,7 +149,7 @@ fillarray(Symbol* basetype, Dimset* dimset, int index, Datalist* arraylist) { int i; Symbol* dim = dimset->dimsyms[index]; - unsigned int size = dim->dim.declsize; + size_t size = dim->dim.declsize; int isunlimited = (size == 0); int lastdim = (index == (dimset->ndims - 1)); diff --git a/ncgen/semantics.c b/ncgen/semantics.c index 1061ac8795..d950c7f39b 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -10,6 +10,7 @@ #include "ncoffsets.h" #include "netcdf_aux.h" #include "ncpathmgr.h" +#include #define floordiv(x,y) ((x) / (y)) #define ceildiv(x,y) (((x) % (y)) == 0 ? ((x) / (y)) : (((x) / (y)) + 1)) @@ -391,8 +392,7 @@ tagvlentypes(Symbol* tsym) static void filltypecodes(void) { - int i; - for(i=0;ityp.basetype != NULL && sym->typ.typecode == NC_NAT) sym->typ.typecode = sym->typ.basetype->typ.typecode; @@ -508,9 +508,8 @@ orderedtypes(Symbol* avsym, nc_type typ, List* types) } /* walk up the containing groups and collect type */ for(;container!= NULL;container = container->container) { - int i; /* Walk types in the container */ - for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* sym = (Symbol*)listget(container->subnodes,i); if(sym->objectclass == NC_TYPE && (typ == NC_NAT || sym->subclass == typ)) listpush(types,sym); @@ -523,8 +522,7 @@ orderedtypes(Symbol* avsym, nc_type typ, List* types) static Symbol* locateeconst(Symbol* enumt, const char* ecname) { - int i; - for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* esym = (Symbol*)listget(enumt->subnodes,i); ASSERT(esym->subclass == NC_ECONST); if(strcmp(esym->name,ecname)==0) @@ -536,7 +534,6 @@ locateeconst(Symbol* enumt, const char* ecname) static Symbol* findeconstenum(Symbol* avsym, NCConstant* con) { - int i; Symbol* refsym = con->value.enumv; List* typdefs = listnew(); Symbol* enumt = NULL; @@ -558,7 +555,7 @@ findeconstenum(Symbol* avsym, NCConstant* con) } else name = refsym->name; /* See if we can find the enum type */ - for(i=0;iobjectclass == NC_TYPE && sym->subclass == NC_ENUM); if(path != NULL && strcmp(sym->name,path)==0) {enumt = sym; break;} @@ -592,9 +589,6 @@ fixeconstref(Symbol* avsym, NCConstant* con) void computesize(Symbol* tsym) { - int i; - int offset = 0; - int largealign; unsigned long totaldimsize; if(tsym->touched) return; tsym->touched=1; @@ -622,20 +616,20 @@ computesize(Symbol* tsym) break; case NC_COMPOUND: /* keep if all fields are primitive*/ /* First, compute recursively, the size and alignment of fields*/ - for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* field = (Symbol*)listget(tsym->subnodes,i); ASSERT(field->subclass == NC_FIELD); computesize(field); if(i==0) tsym->typ.alignment = field->typ.alignment; } /* now compute the size of the compound based on what user specified*/ - offset = 0; - largealign = 1; - for(i=0;isubnodes);i++) { + size_t offset = 0; + size_t largealign = 1; + for(size_t i=0;isubnodes);i++) { Symbol* field = (Symbol*)listget(tsym->subnodes,i); /* only support 'c' alignment for now*/ - int alignment = field->typ.alignment; - int padding = getpadding(offset,alignment); + size_t alignment = field->typ.alignment; + size_t padding = getpadding(offset, alignment); offset += padding; field->typ.offset = offset; offset += field->typ.size; @@ -669,8 +663,7 @@ computesize(Symbol* tsym) void processvars(void) { - int i,j; - for(i=0;ityp.basetype; /* If we are in classic mode, then convert long -> int32 */ @@ -684,7 +677,7 @@ processvars(void) vsym->typ.typecode = basetype->typ.typecode; /* validate uses of NIL */ validateNIL(vsym); - for(j=0;jtyp.dimset.ndims;j++) { + for(size_t j=0;jtyp.dimset.ndims;j++) { /* validate the dimensions*/ /* UNLIMITED must only be in first place if using classic */ if(vsym->typ.dimset.dimsyms[j]->dim.declsize == NC_UNLIMITED) { @@ -698,7 +691,7 @@ processvars(void) static void processtypesizes(void) { - int i; + size_t i; /* use touch flag to avoid circularity*/ for(i=0;isubnodes);i++) { + for(size_t i=0;isubnodes);i++) { Symbol* sym = (Symbol*)listget(grp->subnodes,i); if(sym->ref.is_ref) continue; if(sym->objectclass != objectclass) continue; @@ -1020,9 +1012,8 @@ nctypesize( static int sqContains(List* seq, Symbol* sym) { - int i; if(seq == NULL) return 0; - for(i=0;iname, static void processunlimiteddims(void) { - int i; + size_t i; /* Set all unlimited dims to size 0; */ for(i=0;idata == NULL) continue; diff --git a/ncgen/util.c b/ncgen/util.c index 5b40dd0bbe..4f4ef2511e 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -203,7 +203,7 @@ ncclassname(nc_class ncc) return s; } -int ncsizes[17] = { +size_t ncsizes[17] = { 0, 1,1,2,4, 4,8, @@ -214,7 +214,7 @@ sizeof(nc_vlen_t), 0,0,0 }; -int +size_t ncsize(nc_type nctype) { if(nctype >= NC_NAT && nctype <= NC_COMPOUND) diff --git a/ncgen/util.h b/ncgen/util.h index 71528ecdfc..5cafb09187 100644 --- a/ncgen/util.h +++ b/ncgen/util.h @@ -6,6 +6,7 @@ * $Header: /upc/share/CVS/netcdf-3/ncgen/util.h,v 1.3 2010/04/04 19:39:57 dmh Exp $ *********************************************************************/ +#include #define MAX(x,y) ((x)>(y)?(x):(y)) extern void expe2d(char*); @@ -24,7 +25,7 @@ extern int classicunlimited(Dimset* dimset); extern int isbounded(Dimset* dimset); extern char* nctypename(nc_type); extern char* ncclassname(nc_class); -extern int ncsize(nc_type); +extern size_t ncsize(nc_type); extern nc_type signedtype(nc_type nctype); extern nc_type unsignedtype(nc_type nctype); From 506a09df7ed41681df0e95c47561bb8c3c6a5cab Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 8 Dec 2023 16:17:59 +0000 Subject: [PATCH 20/48] Try to be more consistent with types of alignments/offsets --- ncgen/bindata.c | 26 ++++++++++++-------------- ncgen/data.c | 2 +- ncgen/generate.c | 2 +- ncgen/util.c | 9 ++++----- ncgen/util.h | 2 +- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ncgen/bindata.c b/ncgen/bindata.c index 5469ff2e21..8a06be89ec 100644 --- a/ncgen/bindata.c +++ b/ncgen/bindata.c @@ -10,7 +10,7 @@ #ifdef ENABLE_BINARY /* Forward */ -static void alignto(int alignment, Bytebuffer* buf, ptrdiff_t base); +static void alignto(size_t alignment, Bytebuffer* buf, size_t base); static int bin_uid = 0; @@ -105,7 +105,7 @@ bin_listbegin(Generator* generator, Symbol* tsym, void* liststate, ListClass lc, { if(uidp) *uidp = ++bin_uid; if(lc == LISTCOMPOUND) - *((int*)liststate) = (int)bbLength(buf); + *((size_t*)liststate) = bbLength(buf); return 1; } @@ -113,9 +113,9 @@ static int bin_list(Generator* generator, Symbol* tsym, void* liststate, ListClass lc, int uid, size_t count, Bytebuffer* buf, ...) { if(lc == LISTCOMPOUND) { - int offsetbase = *((int*)liststate); + size_t offsetbase = *((size_t*)liststate); /* Pad for the alignment */ - alignto(tsym->typ.alignment,buf,offsetbase); + alignto(tsym->typ.alignment,buf,offsetbase); } return 1; } @@ -124,7 +124,7 @@ static int bin_listend(Generator* generator, Symbol* tsym, void* liststate, ListClass lc, int uid, size_t count, Bytebuffer* buf, ...) { if(lc == LISTCOMPOUND) { - int offsetbase = *((int*)liststate); + size_t offsetbase = *((size_t*)liststate); /* Pad out the whole instance */ alignto(tsym->typ.cmpdalign,buf,offsetbase); } @@ -167,12 +167,11 @@ static const char zeros[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; static void -alignto(int alignment, Bytebuffer* buf, ptrdiff_t base) +alignto(size_t alignment, Bytebuffer* buf, size_t base) { - int pad = 0; - ptrdiff_t offset = bbLength(buf); - offset -= base; /* Need to actually align wrt to the base */ - pad = getpadding(offset,alignment); + /* Need to actually align wrt to the base */ + size_t offset = bbLength(buf) - base; + size_t pad = getpadding(offset,alignment); if(pad > 0) { bbAppendn(buf,(void*)zeros,pad); } @@ -196,11 +195,10 @@ Generator* bin_generator = &bin_generator_singleton; static int bin_generate_data_r(NCConstant* instance, Symbol* tsym, Datalist* fillvalue, Bytebuffer* databuf); static void -write_alignment(int alignment, Bytebuffer* buf) +write_alignment(size_t alignment, Bytebuffer* buf) { - int pad = 0; - ptrdiff_t offset = bbLength(buf); - pad = getpadding(offset,alignment); + unsigned int offset = bbLength(buf); + size_t pad = getpadding(offset,alignment); if(pad > 0) { bbAppendn(buf,(void*)zeros,pad); } diff --git a/ncgen/data.c b/ncgen/data.c index 51c339bc4b..513248848d 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -309,7 +309,7 @@ alignbuffer(NCConstant* prim, Bytebuffer* buf) { int stat = NC_NOERR; size_t alignment; - int pad,offset; + size_t pad,offset; ASSERT(prim->nctype != NC_COMPOUND); diff --git a/ncgen/generate.c b/ncgen/generate.c index 5c4d7070bd..bb5846644e 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -97,7 +97,7 @@ void generate_basetype(Symbol* tsym, NCConstant* con, Bytebuffer* codebuf, Datalist* filler, Generator* generator) { Datalist* data; - int offsetbase = 0; + size_t offsetbase = 0; switch (tsym->subclass) { diff --git a/ncgen/util.c b/ncgen/util.c index 4f4ef2511e..3802d32f91 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -524,12 +524,11 @@ makebytestring(char* s, size_t* lenp) return bytes; } -int -getpadding(int offset, int alignment) +size_t +getpadding(size_t offset, size_t alignment) { - int rem = (alignment==0?0:(offset % alignment)); - int pad = (rem==0?0:(alignment - rem)); - return pad; + size_t rem = (alignment==0 ? 0 : (offset % alignment)); + return rem == 0 ? 0 : (alignment - rem); } static void diff --git a/ncgen/util.h b/ncgen/util.h index 5cafb09187..f6defb005d 100644 --- a/ncgen/util.h +++ b/ncgen/util.h @@ -57,7 +57,7 @@ extern int findlastunlimited(Dimset* dimset); extern int countunlimited(Dimset* dimset); extern unsigned char* makebytestring(char* s, size_t* lenp); -extern int getpadding(int offset, int alignment); +extern size_t getpadding(size_t offset, size_t alignment); extern void check_err(const int stat, const int line, const char* file, const char* func); extern void check_err2(const int stat, const int cdlline, const int line, const char* file, const char* func); From a90730c4025440cd50943f8a50cb2484fb594ca2 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 8 Dec 2023 16:52:40 +0000 Subject: [PATCH 21/48] Try to be more consistent in `char` type for escaping characters --- ncgen/escapes.c | 16 ++++++++-------- ncgen/genlib.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ncgen/escapes.c b/ncgen/escapes.c index 2b7ff86422..807b428086 100644 --- a/ncgen/escapes.c +++ b/ncgen/escapes.c @@ -27,7 +27,7 @@ Returns s as its result. */ char* -escapifychar(unsigned int c, char* s0, int quote) +escapifychar(char c, char* s0, int quote) { char* s = s0; if(c == '\\') { @@ -47,9 +47,9 @@ escapifychar(unsigned int c, char* s0, int quote) case '\t': strcpy(s,"\\t"); s+=2; break; case '\v': strcpy(s,"\\v"); s+=2; break; default: { - unsigned int oct1 = (c & 007); - unsigned int oct2 = ((c >> 3) & 007); - unsigned int oct3 = ((c >> 6) & 003); + char oct1 = (c & 007); + char oct2 = ((c >> 3) & 007); + char oct3 = ((c >> 6) & 003); *s++ = '\\'; *s++ = oct3 + '0'; *s++ = oct2 + '0'; @@ -67,7 +67,7 @@ escapifychar(unsigned int c, char* s0, int quote) /* Since the string might actually contain nulls, specify the length.*/ char* -escapify(char* s0, int quote, size_t len) +escapify(const char* s0, int quote, size_t len) { int i; char* result; @@ -75,14 +75,14 @@ escapify(char* s0, int quote, size_t len) result[0] = '\0'; for(i=0;i Date: Fri, 8 Dec 2023 17:13:32 +0000 Subject: [PATCH 22/48] Remove unused function from ncgen/dump.c --- ncgen/dump.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ncgen/dump.c b/ncgen/dump.c index 374d47ba15..c8ffc63803 100644 --- a/ncgen/dump.c +++ b/ncgen/dump.c @@ -17,16 +17,6 @@ /* Forward */ static void dumpdataprim(NCConstant*,Bytebuffer*); -char* -indentstr(int n) -{ - static char indentline[1024]; - memset(indentline,' ',n+1); - indentline[n+1] = '\0'; - return indentline; -} - - void dumpconstant(NCConstant* con, char* tag) { From 6b17d77e7a79d41d5e0385eeafda4a6a460ee997 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 11 Dec 2023 13:38:25 +0000 Subject: [PATCH 23/48] Fix some size/conversion warnings in ncgen.l/y --- ncgen/ncgen.l | 12 ++++++------ ncgen/ncgen.y | 27 +++++++++++++-------------- ncgen/ncgenl.c | 12 ++++++------ ncgen/ncgeny.c | 27 ++++++++++++++------------- ncgen/ncgeny.h | 2 +- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index 963ecefcca..ffc035e90d 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -376,7 +376,7 @@ NIL|nil|Nil { return lexdebug(DATASETID); } -{ID} { char* id = NULL; int len; +{ID} { char* id = NULL; size_t len; len = strlen(yytext); len = unescape(yytext,len,ISIDENT,&id); if(NCSTREQ(id, FILL_STRING)) { @@ -395,7 +395,7 @@ NIL|nil|Nil { If out of any integer range, then complain Also, if the digits begin with 0, then assume octal. */ - int slen = strlen(ncgtext); + size_t slen = strlen(ncgtext); char* stag = NULL; int tag = NC_NAT; int isneg = 0; @@ -469,11 +469,11 @@ done: return 0; {XUNUMBER} { int c; int token = 0; - int slen = strlen(yytext); + size_t slen = strlen(yytext); char* stag = NULL; int tag = NC_NAT; char* hex = yytext+2; /* point to first true hex digit */ - int xlen = (slen - 3); /* true hex length */ + size_t xlen = (slen - 3); /* true hex length */ yytext[slen-1] = '\0'; /* capture the tag string */ @@ -842,8 +842,8 @@ collecttag(char* text, char** stagp) char* stag0; #define MAXTAGLEN 3 char stag[MAXTAGLEN+1]; - int slen = strlen(text); - int staglen; + size_t slen = strlen(text); + size_t staglen; int tag = NC_NAT; int hasU = 0; diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index c8c2d5ac62..3610f3576b 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -66,9 +66,9 @@ static List* stack; static nc_type consttype; /* Misc. */ -static int stackbase; -static int stacklen; -static int count; +static size_t stackbase; +static size_t stacklen; +static size_t count; static int opaqueid; /* counter for opaque constants*/ static int arrayuid; /* counter for pseudo-array types*/ @@ -156,7 +156,7 @@ extern int lex_init(void); %union { Symbol* sym; unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/ -long mark; /* track indices into the sequence*/ +size_t mark; /* track indices into the sequence*/ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant* constant; @@ -312,7 +312,7 @@ optsemicolon: /*empty*/ | ';' ; enumdecl: primtype ENUM typename '{' enumidlist '}' { - int i; + size_t i; addtogroup($3); /* sets prefix*/ $3->objectclass=NC_TYPE; $3->subclass=NC_ENUM; @@ -343,7 +343,7 @@ enumidlist: enumid {$$=listlength(stack); listpush(stack,(void*)$1);} | enumidlist ',' enumid { - int i; + size_t i; $$=$1; /* check for duplicates*/ stackbase=$1; @@ -395,7 +395,7 @@ vlendecl: typeref '(' '*' ')' typename compounddecl: COMPOUND typename '{' fields '}' { - int i,j; + size_t i,j; vercheck(NC_COMPOUND); addtogroup($2); /* check for duplicate field names*/ @@ -432,7 +432,7 @@ fields: field ';' {$$=$1;} field: typeref fieldlist { - int i; + size_t i; $$=$2; stackbase=$2; stacklen=listlength(stack); @@ -517,7 +517,7 @@ vadecl_or_attr: vardecl {} | attrdecl {} ; vardecl: typeref varlist { - int i; + size_t i; stackbase=$2; stacklen=listlength(stack); /* process each variable in the varlist*/ @@ -547,7 +547,7 @@ varlist: varspec varspec: varident dimspec { - int i; + size_t i; Dimset dimset; Symbol* var = $1; /* for debugging */ stacklen=listlength(stack); @@ -608,7 +608,7 @@ fieldlist: fieldspec: ident fielddimspec { - int i; + size_t i; Dimset dimset; stackbase=$2; stacklen=listlength(stack); @@ -1082,8 +1082,7 @@ makeconstdata(nc_type nctype) #ifdef USE_NETCDF4 case NC_OPAQUE: { char* s; - int len; - len = bbLength(lextext); + size_t len = bbLength(lextext); s = (char*)ecalloc(len+1); strncpy(s,bbContents(lextext),len); s[len] = '\0'; @@ -1136,7 +1135,7 @@ addtogroup(Symbol* sym) static int dupobjectcheck(nc_class objectclass, Symbol* pattern) { - int i; + size_t i; Symbol* grp; if(pattern == NULL) return 0; grp = pattern->container; diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index 54596c8f73..860063fed5 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -2347,7 +2347,7 @@ YY_RULE_SETUP case 40: YY_RULE_SETUP #line 379 "ncgen/ncgen.l" -{ char* id = NULL; int len; +{ char* id = NULL; size_t len; len = strlen(yytext); len = unescape(yytext,len,ISIDENT,&id); if(NCSTREQ(id, FILL_STRING)) { @@ -2369,7 +2369,7 @@ YY_RULE_SETUP If out of any integer range, then complain Also, if the digits begin with 0, then assume octal. */ - int slen = strlen(ncgtext); + size_t slen = strlen(ncgtext); char* stag = NULL; int tag = NC_NAT; int isneg = 0; @@ -2446,11 +2446,11 @@ YY_RULE_SETUP { int c; int token = 0; - int slen = strlen(yytext); + size_t slen = strlen(yytext); char* stag = NULL; int tag = NC_NAT; char* hex = yytext+2; /* point to first true hex digit */ - int xlen = (slen - 3); /* true hex length */ + size_t xlen = (slen - 3); /* true hex length */ yytext[slen-1] = '\0'; /* capture the tag string */ @@ -3876,8 +3876,8 @@ collecttag(char* text, char** stagp) char* stag0; #define MAXTAGLEN 3 char stag[MAXTAGLEN+1]; - int slen = strlen(text); - int staglen; + size_t slen = strlen(text); + size_t staglen; int tag = NC_NAT; int hasU = 0; diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index 2fd6ea19aa..d9f4074137 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -133,9 +133,9 @@ static List* stack; static nc_type consttype; /* Misc. */ -static int stackbase; -static int stacklen; -static int count; +static size_t stackbase; +static size_t stacklen; +static size_t count; static int opaqueid; /* counter for opaque constants*/ static int arrayuid; /* counter for pseudo-array types*/ @@ -1913,7 +1913,7 @@ yyparse (void) case 25: /* enumdecl: primtype ENUM typename '{' enumidlist '}' */ #line 314 "ncgen/ncgen.y" { - int i; + size_t i; addtogroup((yyvsp[-3].sym)); /* sets prefix*/ (yyvsp[-3].sym)->objectclass=NC_TYPE; (yyvsp[-3].sym)->subclass=NC_ENUM; @@ -1950,7 +1950,7 @@ yyparse (void) case 27: /* enumidlist: enumidlist ',' enumid */ #line 345 "ncgen/ncgen.y" { - int i; + size_t i; (yyval.mark)=(yyvsp[-2].mark); /* check for duplicates*/ stackbase=(yyvsp[-2].mark); @@ -2010,7 +2010,7 @@ yyparse (void) case 31: /* compounddecl: COMPOUND typename '{' fields '}' */ #line 397 "ncgen/ncgen.y" { - int i,j; + size_t i,j; vercheck(NC_COMPOUND); addtogroup((yyvsp[-3].sym)); /* check for duplicate field names*/ @@ -2056,7 +2056,7 @@ yyparse (void) case 34: /* field: typeref fieldlist */ #line 434 "ncgen/ncgen.y" { - int i; + size_t i; (yyval.mark)=(yyvsp[0].mark); stackbase=(yyvsp[0].mark); stacklen=listlength(stack); @@ -2230,7 +2230,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); case 66: /* vardecl: typeref varlist */ #line 519 "ncgen/ncgen.y" { - int i; + size_t i; stackbase=(yyvsp[0].mark); stacklen=listlength(stack); /* process each variable in the varlist*/ @@ -2268,7 +2268,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); case 69: /* varspec: varident dimspec */ #line 549 "ncgen/ncgen.y" { - int i; + size_t i; Dimset dimset; Symbol* var = (yyvsp[-1].sym); /* for debugging */ stacklen=listlength(stack); @@ -2352,7 +2352,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); case 77: /* fieldspec: ident fielddimspec */ #line 610 "ncgen/ncgen.y" { - int i; + size_t i; Dimset dimset; stackbase=(yyvsp[0].mark); stacklen=listlength(stack); @@ -3318,12 +3318,13 @@ makeconstdata(nc_type nctype) #ifdef USE_NETCDF4 case NC_OPAQUE: { char* s; - size_t len = bbLength(lextext); + size_t len; + len = bbLength(lextext); s = (char*)ecalloc(len+1); strncpy(s,bbContents(lextext),len); s[len] = '\0'; con->value.opaquev.stringv = s; - con->value.opaquev.len = (int)len; + con->value.opaquev.len = len; } break; case NC_NIL: @@ -3371,7 +3372,7 @@ addtogroup(Symbol* sym) static int dupobjectcheck(nc_class objectclass, Symbol* pattern) { - int i; + size_t i; Symbol* grp; if(pattern == NULL) return 0; grp = pattern->container; diff --git a/ncgen/ncgeny.h b/ncgen/ncgeny.h index 3b1821a7a0..09ce4d2aae 100644 --- a/ncgen/ncgeny.h +++ b/ncgen/ncgeny.h @@ -123,7 +123,7 @@ union YYSTYPE Symbol* sym; unsigned long size; /* allow for zero size to indicate e.g. UNLIMITED*/ -long mark; /* track indices into the sequence*/ +size_t mark; /* track indices into the sequence*/ int nctype; /* for tracking attribute list type*/ Datalist* datalist; NCConstant* constant; From 17a7b283016dfbc03331af2ca34a393b4c871f26 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 11 Dec 2023 13:41:17 +0000 Subject: [PATCH 24/48] Change type of opaque object length member --- ncgen/cdata.c | 2 +- ncgen/cvt.c | 4 ++-- ncgen/data.c | 4 ++-- ncgen/data.h | 2 +- ncgen/generate.c | 6 +++--- ncgen/ncgeny.c | 3 +-- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ncgen/cdata.c b/ncgen/cdata.c index 0b9c2296f7..eccf86a07c 100644 --- a/ncgen/cdata.c +++ b/ncgen/cdata.c @@ -99,7 +99,7 @@ c_constant(Generator* generator, Symbol* sym, NCConstant* con, Bytebuffer* buf,. } break; case NC_OPAQUE: { char* p; - size_t bslen = (size_t)(4*con->value.opaquev.len); + size_t bslen = 4*con->value.opaquev.len; special = poolalloc(bslen+2+1); strcpy(special,"\""); p = con->value.opaquev.stringv; diff --git a/ncgen/cvt.c b/ncgen/cvt.c index b7daa7483b..aa1b4c4cb9 100644 --- a/ncgen/cvt.c +++ b/ncgen/cvt.c @@ -560,8 +560,8 @@ case CASE(NC_OPAQUE,NC_DOUBLE): tmp.doublev = *(double*)bytes; break; case CASE(NC_OPAQUE,NC_OPAQUE): - tmp.opaquev.stringv = (char*)ecalloc((size_t)src->value.opaquev.len+1); - memcpy(tmp.opaquev.stringv,src->value.opaquev.stringv, (size_t)src->value.opaquev.len); + tmp.opaquev.stringv = (char*)ecalloc(src->value.opaquev.len+1); + memcpy(tmp.opaquev.stringv,src->value.opaquev.stringv, src->value.opaquev.len); tmp.opaquev.len = src->value.opaquev.len; tmp.opaquev.stringv[tmp.opaquev.len] = '\0'; break; diff --git a/ncgen/data.c b/ncgen/data.c index 513248848d..a70572fb15 100644 --- a/ncgen/data.c +++ b/ncgen/data.c @@ -156,9 +156,9 @@ cloneconstant(NCConstant* con) newcon->value.stringv.stringv = s; break; case NC_OPAQUE: - s = (char*)ecalloc((size_t)newcon->value.opaquev.len+1); + s = (char*)ecalloc(newcon->value.opaquev.len+1); if(newcon->value.opaquev.len > 0) - memcpy(s,newcon->value.opaquev.stringv, (size_t)newcon->value.opaquev.len); + memcpy(s,newcon->value.opaquev.stringv, newcon->value.opaquev.len); s[newcon->value.opaquev.len] = '\0'; newcon->value.opaquev.stringv = s; break; diff --git a/ncgen/data.h b/ncgen/data.h index 8342a2d7b1..64566cec59 100644 --- a/ncgen/data.h +++ b/ncgen/data.h @@ -41,7 +41,7 @@ typedef union Constvalue { char* stringv; } stringv; struct Opaquev { /* NC_OPAQUE*/ - int len; /* length as originally written (rounded to even number)*/ + size_t len; /* length as originally written (rounded to even number)*/ char* stringv; /*as constant was written*/ /* (padded to even # chars >= 16)*/ /* without leading 0x*/ diff --git a/ncgen/generate.c b/ncgen/generate.c index bb5846644e..9121920957 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -259,16 +259,16 @@ normalizeopaquelength(NCConstant* prim, unsigned long nbytes) /* do nothing*/ } else if(prim->value.opaquev.len > nnibs) { /* truncate*/ prim->value.opaquev.stringv[nnibs] = '\0'; - prim->value.opaquev.len = (int)nnibs; + prim->value.opaquev.len = nnibs; } else {/* prim->value.opaquev.len < nnibs => expand*/ char* s; s = (char*)ecalloc(nnibs+1); memset(s,'0',nnibs); /* Fill with '0' characters */ - memcpy(s,prim->value.opaquev.stringv, (size_t)prim->value.opaquev.len); + memcpy(s,prim->value.opaquev.stringv, prim->value.opaquev.len); s[nnibs] = '\0'; efree(prim->value.opaquev.stringv); prim->value.opaquev.stringv=s; - prim->value.opaquev.len = (int)nnibs; + prim->value.opaquev.len = nnibs; } } diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index d9f4074137..bd6afd22cd 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -3318,8 +3318,7 @@ makeconstdata(nc_type nctype) #ifdef USE_NETCDF4 case NC_OPAQUE: { char* s; - size_t len; - len = bbLength(lextext); + size_t len = bbLength(lextext); s = (char*)ecalloc(len+1); strncpy(s,bbContents(lextext),len); s[len] = '\0'; From 3134af3ce7b304389043152fe4954122841fd761 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 11 Dec 2023 14:04:43 +0000 Subject: [PATCH 25/48] Remove unused static variable --- ncgen/escapes.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ncgen/escapes.c b/ncgen/escapes.c index 807b428086..f838e28474 100644 --- a/ncgen/escapes.c +++ b/ncgen/escapes.c @@ -117,7 +117,6 @@ cquotestring(Bytebuffer* databuf, char quote) static int init = 0; static char* repls[256]; /* replacement string for each char */ -static int lens[256]; /* lengths of replacement strings */ static struct { char c; char *s; @@ -186,9 +185,6 @@ initcodify(void) rp[hexlen] = '\0'; repls[i] = rp; } - for(i = 0; i < 256; i++) { - lens[i] = strlen(repls[i]); - } init = 1; /* only do this initialization once */ } From 47d1b68599313e4812111d8d9bf5addb0f4458fe Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 11 Dec 2023 14:08:55 +0000 Subject: [PATCH 26/48] Cast to correct type in assignment --- ncgen/genbin.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ncgen/genbin.c b/ncgen/genbin.c index 1e4193057c..9b447e4068 100644 --- a/ncgen/genbin.c +++ b/ncgen/genbin.c @@ -357,8 +357,7 @@ genbin_deftype(Symbol* tsym) int dimsizes[NC_MAX_VAR_DIMS]; /* int because inside compound */ /* Generate the field dimension constants*/ for(j=0;jtyp.dimset.ndims;j++) { - unsigned int size = efield->typ.dimset.dimsyms[j]->dim.declsize; - dimsizes[j] = size; + dimsizes[j] = (int)efield->typ.dimset.dimsyms[j]->dim.declsize; } stat = nc_insert_array_compound( tsym->container->nc_id, From 320c29c7237479a3eb44a7df5fdf91dbf55e8594 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 14 Mar 2024 14:34:31 +0000 Subject: [PATCH 27/48] Fix more sign conversion warnings in ncgen --- ncgen/bytebuffer.c | 4 ++-- ncgen/cvt.c | 2 +- ncgen/data.c | 18 ++++++++---------- ncgen/escapes.c | 8 ++++---- ncgen/genchar.c | 2 +- ncgen/generate.c | 6 +++--- ncgen/genf77.c | 2 +- ncgen/semantics.c | 2 +- ncgen/util.c | 6 +++--- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/ncgen/bytebuffer.c b/ncgen/bytebuffer.c index 63bc50267d..16122ee634 100644 --- a/ncgen/bytebuffer.c +++ b/ncgen/bytebuffer.c @@ -152,7 +152,7 @@ bbAppendn(Bytebuffer* bb, const void* elem, const size_t n0) if(n == 0) {n = strlen((char*)elem);} while(!bbNeed(bb,(n+1))) {if(!bbSetalloc(bb,0)) return bbFail();} memcpy((void*)&bb->content[bb->length],(void*)elem,n); - bb->length += n; + bb->length += (unsigned int)n; bb->content[bb->length] = '\0'; return TRUE; } @@ -169,7 +169,7 @@ int bbInsertn(Bytebuffer* bb, const unsigned int index, const char* elem, const unsigned int n) { unsigned int i; - int j; + unsigned int j; unsigned int newlen = 0; if(bb == NULL) return bbFail(); diff --git a/ncgen/cvt.c b/ncgen/cvt.c index aa1b4c4cb9..e074390db9 100644 --- a/ncgen/cvt.c +++ b/ncgen/cvt.c @@ -640,7 +640,7 @@ convertstringtochars(NCConstant* str) char* s; size_t slen = str->value.stringv.len; - dl = builddatalist(slen); + dl = builddatalist((int)slen); s = str->value.stringv.stringv; for(i=0;i 0) memmove(&dl->data[pos+len2],&dl->data[pos], (size_t)delta*sizeof(NCConstant*)); dl->length += len2; - for(i=0;idata[i]; con = cloneconstant(con); dl->data[pos+i] = con; @@ -700,7 +699,7 @@ clonedatalist(Datalist* dl) if(dl == NULL) return NULL; len = datalistlen(dl); - newdl = builddatalist(len); + newdl = builddatalist((int)len); /* initialize */ for(i=0;i 1) { Bytebuffer* accum = bbNew(); size_t len = 0; /* >0 implies doing accum */ - Datalist* newlist = builddatalist(datalistlen(data)); + Datalist* newlist = builddatalist((int)datalistlen(data)); int lineno = 0; NCConstant* con; /* We are going to construct a single string constant for each diff --git a/ncgen/generate.c b/ncgen/generate.c index 9121920957..10843f3ea7 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -454,7 +454,7 @@ generate_array(Symbol* vsym, Bytebuffer* code, Datalist* filler, Generator* gene if(vsym->var.special._Storage == NC_CHUNKED) { if(vsym->var.special._ChunkSizes) - memcpy(args.chunksizes,vsym->var.special._ChunkSizes,sizeof(size_t)*args.rank); + memcpy(args.chunksizes,vsym->var.special._ChunkSizes,sizeof(size_t)*(size_t)args.rank); } memset(index,0,sizeof(index)); @@ -466,8 +466,8 @@ generate_array(Symbol* vsym, Bytebuffer* code, Datalist* filler, Generator* gene Bytebuffer* charbuf = bbNew(); gen_chararray(args.dimset,0,args.vsym->data,charbuf,args.filler); args.generator->charconstant(args.generator,args.vsym,args.code,charbuf); - memset(start,0,sizeof(size_t)*args.rank); - memcpy(count,args.dimsizes,sizeof(size_t)*args.rank); + memset(start,0,sizeof(size_t)*(size_t)args.rank); + memcpy(count,args.dimsizes,sizeof(size_t)*(size_t)args.rank); args.writer(args.generator,args.vsym,args.code,args.rank,start,count); bbFree(charbuf); bbClear(args.code); diff --git a/ncgen/genf77.c b/ncgen/genf77.c index 22f0beea06..497cf0d710 100644 --- a/ncgen/genf77.c +++ b/ncgen/genf77.c @@ -490,7 +490,7 @@ f77fold(Bytebuffer* lines) while(*linen != '\n' && *linen != '\0') linen++; if(*linen == '\0') break; linen++; /* include trailing newline */ - linelen = (linen - line0); + linelen = (size_t)(linen - line0); /* handle comments and empty lines */ if(*line0 == '*' || linelen == 1) { bbAppendn(lines,line0,linelen); diff --git a/ncgen/semantics.c b/ncgen/semantics.c index d950c7f39b..189047499e 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -1326,7 +1326,7 @@ explode(NCConstant* con) Datalist* chars; ASSERT((con->nctype == NC_STRING)); len = con->value.stringv.len; - chars = builddatalist(len); + chars = builddatalist((int)len); p = con->value.stringv.stringv; fprintf(stderr,"p[%zu]=|%s|\n",con->value.stringv.len,p); for(i=0;i Date: Thu, 14 Mar 2024 14:56:10 +0000 Subject: [PATCH 28/48] Fix return type of `listlength` --- ncgen/genbin.c | 17 ++++++----------- ncgen/genc.c | 14 ++++++-------- ncgen/generate.c | 4 ++-- ncgen/genf77.c | 11 +++++------ ncgen/genj.c | 9 ++++----- ncgen/getfill.c | 4 ++-- ncgen/list.h | 2 +- ncgen/util.c | 5 ++--- 8 files changed, 28 insertions(+), 38 deletions(-) diff --git a/ncgen/genbin.c b/ncgen/genbin.c index 9b447e4068..019ed52638 100644 --- a/ncgen/genbin.c +++ b/ncgen/genbin.c @@ -34,20 +34,15 @@ genbin_netcdf(void) { int stat, ncid; size_t idim, ivar, iatt; - int ndims, nvars, natts, ngatts; const char* filename = rootgroup->file.filename; + size_t ndims = listlength(dimdefs); + size_t nvars = listlength(vardefs); + size_t natts = listlength(attdefs); + size_t ngatts = listlength(gattdefs); #ifdef USE_NETCDF4 - int ntyps, ngrps; -#endif - - ndims = listlength(dimdefs); - nvars = listlength(vardefs); - natts = listlength(attdefs); - ngatts = listlength(gattdefs); -#ifdef USE_NETCDF4 - ntyps = listlength(typdefs); - ngrps = listlength(grpdefs); + size_t ntyps = listlength(typdefs); + size_t ngrps = listlength(grpdefs); #endif /*USE_NETCDF4*/ /* Turn on logging */ diff --git a/ncgen/genc.c b/ncgen/genc.c index 0cab7aac2d..fc16a78ddd 100644 --- a/ncgen/genc.c +++ b/ncgen/genc.c @@ -40,22 +40,20 @@ genc_netcdf(void) { size_t idim, ivar, iatt; int maxdims; - int ndims, nvars, natts, ngatts; char* cmode_string; const char *filename = rootgroup->file.filename; #ifdef USE_NETCDF4 size_t igrp, ityp; - int ngrps, ntyps; #endif - ndims = listlength(dimdefs); - nvars = listlength(vardefs); - natts = listlength(attdefs); - ngatts = listlength(gattdefs); + size_t ndims = listlength(dimdefs); + size_t nvars = listlength(vardefs); + size_t natts = listlength(attdefs); + size_t ngatts = listlength(gattdefs); #ifdef USE_NETCDF4 - ngrps = listlength(grpdefs); - ntyps = listlength(typdefs); + size_t ngrps = listlength(grpdefs); + size_t ntyps = listlength(typdefs); #endif /*USE_NETCDF4*/ /* wrap in main program */ diff --git a/ncgen/generate.c b/ncgen/generate.c index 10843f3ea7..2b21d82f2f 100644 --- a/ncgen/generate.c +++ b/ncgen/generate.c @@ -117,7 +117,7 @@ generate_basetype(Symbol* tsym, NCConstant* con, Bytebuffer* codebuf, Datalist* case NC_COMPOUND: { size_t i, dllen; - int uid, nfields; + int uid; if(con == NULL || isfillconst(con)) { Datalist* fill = (filler==NULL?getfiller(tsym):filler); ASSERT(fill->length == 1); @@ -140,7 +140,7 @@ generate_basetype(Symbol* tsym, NCConstant* con, Bytebuffer* codebuf, Datalist* } data = con->value.compoundv; - nfields = listlength(tsym->subnodes); + size_t nfields = listlength(tsym->subnodes); dllen = datalistlen(data); if(dllen > nfields) { semerror(con->lineno,"Datalist longer than the number of compound fields"); diff --git a/ncgen/genf77.c b/ncgen/genf77.c index 497cf0d710..ef8fd136d0 100644 --- a/ncgen/genf77.c +++ b/ncgen/genf77.c @@ -48,14 +48,13 @@ void genf77_netcdf(void) { size_t idim, ivar, iatt; - int ndims, nvars, natts, ngatts; char* cmode_string; const char *filename = rootgroup->file.filename; - ndims = listlength(dimdefs); - nvars = listlength(vardefs); - natts = listlength(attdefs); - ngatts = listlength(gattdefs); + size_t ndims = listlength(dimdefs); + size_t nvars = listlength(vardefs); + size_t natts = listlength(attdefs); + size_t ngatts = listlength(gattdefs); /* Construct the main program */ @@ -708,7 +707,7 @@ genf77_writevar(Generator* generator, Symbol* vsym, Bytebuffer* code, f77skip(); } else { /* rank > 0 && typecode != NC_CHAR*/ char* dimstring; - int index = listlength(f77procs); + size_t index = listlength(f77procs); Bytebuffer* proctext; Bytebuffer* save; List* calllist; diff --git a/ncgen/genj.c b/ncgen/genj.c index e74e0b8fc6..f76a5cb466 100644 --- a/ncgen/genj.c +++ b/ncgen/genj.c @@ -42,13 +42,12 @@ genjava_netcdf(void) { size_t idim, ivar, iatt; int maxdims; - int ndims, nvars, natts, ngatts; const char *filename = rootgroup->file.filename; - ndims = listlength(dimdefs); - nvars = listlength(vardefs); - natts = listlength(attdefs); - ngatts = listlength(gattdefs); + size_t ndims = listlength(dimdefs); + size_t nvars = listlength(vardefs); + size_t natts = listlength(attdefs); + size_t ngatts = listlength(gattdefs); /* Construct the main class */ codeline("import java.util.*;"); diff --git a/ncgen/getfill.c b/ncgen/getfill.c index 0fd0659807..e5c06aa127 100644 --- a/ncgen/getfill.c +++ b/ncgen/getfill.c @@ -74,7 +74,7 @@ fill(Symbol* tsym, Datalist* filler) consisting itself of N constants, where N is the number of fields. Non-array fields will be direct, array fields will be sublists. */ - Datalist* cmpdlist = builddatalist(listlength(tsym->subnodes)); /* list of field constants */ + Datalist* cmpdlist = builddatalist((int)listlength(tsym->subnodes)); /* list of field constants */ for(i=0;isubnodes);i++) { NCConstant* fieldinstance = NULL; Symbol* field = (Symbol*)listget(tsym->subnodes,i); @@ -123,7 +123,7 @@ filllist(Symbol* tsym, Datalist* dl) dlappend(dl,con); break; case NC_COMPOUND: - sublist = builddatalist(listlength(tsym->subnodes)); + sublist = builddatalist((int)listlength(tsym->subnodes)); for(size_t i=0;isubnodes);i++) { Symbol* field = (Symbol*)listget(tsym->subnodes,i); filllist(field->typ.basetype,sublist); diff --git a/ncgen/list.h b/ncgen/list.h index 86f85cc262..06b73bc870 100644 --- a/ncgen/list.h +++ b/ncgen/list.h @@ -57,6 +57,6 @@ EXTERNC List* listclone(List*); #define listclear(l) listsetlength((l),0) #define listextend(l,len) listsetalloc((l),(len)+(l->alloc)) #define listcontents(l) ((l)==NULL?NULL:(l)->content) -#define listlength(l) ((l)==NULL?0:(int)(l)->length) +#define listlength(l) ((l)==NULL?0:(l)->length) #endif /*LIST_H*/ diff --git a/ncgen/util.c b/ncgen/util.c index 8ba96d2267..25e1dc7774 100644 --- a/ncgen/util.c +++ b/ncgen/util.c @@ -373,11 +373,10 @@ char* prefixtostring(List* prefix, char* separator) { size_t slen=0; - int plen; size_t i; char* result; if(prefix == NULL) return pooldup(""); - plen = prefixlen(prefix); + size_t plen = prefixlen(prefix); if(plen == 0) { /* root prefix*/ slen=0; /* slen += strlen(separator);*/ @@ -425,7 +424,7 @@ prefixeq(List* x1, List* x2) { Symbol** l1; Symbol** l2; - int len,i; + size_t len,i; if((len=listlength(x1)) != listlength(x2)) return 0; l1=(Symbol**)listcontents(x1); l2=(Symbol**)listcontents(x2); From 0d354152cadc3d25204d69ebc2d351a116a0adb4 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 14 Mar 2024 16:00:56 +0000 Subject: [PATCH 29/48] Silence some conversion warnings in ncgen generated files --- ncgen/escapes.c | 2 +- ncgen/genlib.h | 2 +- ncgen/ncgen.h | 2 +- ncgen/ncgen.l | 26 ++++++++++++------------- ncgen/ncgen.y | 8 ++++---- ncgen/ncgenl.c | 50 ++++++++++++++++++++++++------------------------- ncgen/ncgeny.c | 14 +++++++------- 7 files changed, 52 insertions(+), 52 deletions(-) diff --git a/ncgen/escapes.c b/ncgen/escapes.c index e2099d9f75..842022537f 100644 --- a/ncgen/escapes.c +++ b/ncgen/escapes.c @@ -604,7 +604,7 @@ unescapeoct(const char* s) int unescape( const char *yytext, /* text to unescape */ - int yyleng, /* length of yytext */ + size_t yyleng, /* length of yytext */ int isident, /* Is this an identifier? */ char** sp /* Return the unescaped version of yytext */ ) diff --git a/ncgen/genlib.h b/ncgen/genlib.h index 6de7d2fbdd..bd5d9c1719 100644 --- a/ncgen/genlib.h +++ b/ncgen/genlib.h @@ -59,7 +59,7 @@ extern void nestedfqn(Symbol* sym); extern void attfqn(Symbol* sym); /* from: escapes.c */ -extern int unescape(const char*, int, int, char**); +extern int unescape(const char*, size_t, int, char**); extern int unescapeoct(const char* s); extern int unescapehex(const char* s); extern char* cescapifychar(char c, int quote); diff --git a/ncgen/ncgen.h b/ncgen/ncgen.h index f7f901671d..7aa285ffd5 100644 --- a/ncgen/ncgen.h +++ b/ncgen/ncgen.h @@ -119,7 +119,7 @@ typedef struct Specialdata { Datalist* _Fillvalue; /* This is a per-type ; points to the _FillValue attribute node */ int _Storage; /* NC_CHUNKED | NC_CONTIGUOUS | NC_COMPACT*/ size_t* _ChunkSizes; /* NULL => defaults*/ - int nchunks; /* |_Chunksize| ; 0 => not specified*/ + size_t nchunks; /* |_Chunksize| ; 0 => not specified*/ int _Fletcher32; /* 1=>fletcher32*/ int _DeflateLevel; /* 0-9 => level*/ int _Shuffle; /* 0 => false, 1 => true*/ diff --git a/ncgen/ncgen.l b/ncgen/ncgen.l index ffc035e90d..6718e5f40c 100644 --- a/ncgen/ncgen.l +++ b/ncgen/ncgen.l @@ -241,13 +241,13 @@ yyerror("string too long, truncated\n"); yytext[MAXTRST-1] = '\0'; } */ - len = unescape((char *)yytext+1,yyleng-2,!ISIDENT,&s); + len = unescape((char *)yytext+1,(size_t)(yyleng-2),!ISIDENT,&s); if(len < 0) { snprintf(errstr, sizeof(errstr),"Illegal character: %s",yytext); yyerror(errstr); } bbClear(lextext); - bbAppendn(lextext,s,len); + bbAppendn(lextext,s,(size_t)len); bbNull(lextext); if(s) efree(s); return lexdebug(TERMSTRING); @@ -257,11 +257,11 @@ yytext[MAXTRST-1] = '\0'; char* p = yytext+2; int len = yyleng - 2; bbClear(lextext); - bbAppendn(lextext,p,len); + bbAppendn(lextext,p,(size_t)len); if((len % 2) == 1) bbAppend(lextext,'0'); bbNull(lextext); /* convert all chars to lower case */ - for(p=bbContents(lextext);(int)*p;p++) *p = tolower(*p); + for(p=bbContents(lextext);*p;p++) *p = (char)tolower((int)*p); return lexdebug(OPAQUESTRING); } @@ -342,7 +342,7 @@ NIL|nil|Nil { {PATH} { bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); yylval.sym = makepath(bbContents(lextext)); return lexdebug(PATH); @@ -351,7 +351,7 @@ NIL|nil|Nil { {SPECIAL} {struct Specialtoken* st; bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); for(st=specials;st->name;st++) { if(strcmp(bbContents(lextext),st->name)==0) {return lexdebug(st->token);} @@ -360,11 +360,11 @@ NIL|nil|Nil { } {DATASETID} { - int c; + char c; char* p; char* q; /* copy the trimmed name */ bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); p = bbContents(lextext); q = p; @@ -378,7 +378,7 @@ NIL|nil|Nil { {ID} { char* id = NULL; size_t len; len = strlen(yytext); - len = unescape(yytext,len,ISIDENT,&id); + len = (size_t)unescape(yytext,len,ISIDENT,&id); if(NCSTREQ(id, FILL_STRING)) { efree(id); return lexdebug(FILLMARKER); @@ -491,7 +491,7 @@ done: return 0; /* convert to an unsigned long long */ uint64_val = 0; while((c=*hex++)) { - unsigned int hexdigit = (c <= '9'?(c-'0'):(c-'a')+0xa); + unsigned int hexdigit = (unsigned int)(c <= '9'?(c-'0'):(c-'a')+0xa); uint64_val = ((uint64_val << 4) | hexdigit); } switch (tag) { @@ -538,7 +538,7 @@ done: return 0; snprintf(errstr, sizeof(errstr),"bad octal character constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = (unsigned int)oct; + byte_val = (signed char)oct; return lexdebug(BYTE_CONST); } \'\\[xX][0-9a-fA-F][0-9a-fA-F]\' { @@ -547,7 +547,7 @@ done: return 0; snprintf(errstr, sizeof(errstr),"bad hex character constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = (unsigned int)hex; + byte_val = (signed char)hex; return lexdebug(BYTE_CONST); } \'\\.\' { @@ -716,7 +716,7 @@ downconvert(unsigned long long uint64, int* tagp, int isneg, int hasU) { nc_type nct = NC_NAT; int tag = *tagp; - int bit63set = (uint64 >> 63); + int bit63set = (int)(uint64 >> 63); long long int64 = *((long long*)&uint64); if(isneg && hasU) { diff --git a/ncgen/ncgen.y b/ncgen/ncgen.y index 3610f3576b..29f0819830 100644 --- a/ncgen/ncgen.y +++ b/ncgen/ncgen.y @@ -374,7 +374,7 @@ opaquedecl: OPAQUE_ '(' INT_CONST ')' typename $5->objectclass=NC_TYPE; $5->subclass=NC_OPAQUE; $5->typ.typecode=NC_OPAQUE; - $5->typ.size=int32_val; + $5->typ.size=(size_t)int32_val; (void)ncaux_class_alignment(NC_OPAQUE,&$5->typ.alignment); } ; @@ -558,7 +558,7 @@ varspec: varident dimspec count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } - dimset.ndims = count; + dimset.ndims = (int)count; /* extract the actual dimensions*/ if(dimset.ndims > 0) { for(i=0;i 0) { /* extract the actual dimensions*/ for(i=0;iobjectclass = NC_DIM; $$->dim.isconstant = 1; - $$->dim.declsize = int32_val; + $$->dim.declsize = (size_t)int32_val; } ; diff --git a/ncgen/ncgenl.c b/ncgen/ncgenl.c index 860063fed5..b37d9a2c36 100644 --- a/ncgen/ncgenl.c +++ b/ncgen/ncgenl.c @@ -2079,13 +2079,13 @@ yyerror("string too long, truncated\n"); yytext[MAXTRST-1] = '\0'; } */ - len = unescape((char *)yytext+1,yyleng-2,!ISIDENT,&s); + len = unescape((char *)yytext+1,(size_t)(yyleng-2),!ISIDENT,&s); if(len < 0) { - snprintf(errstr,sizeof(errstr),"Illegal character: %s",yytext); + snprintf(errstr, sizeof(errstr),"Illegal character: %s",yytext); yyerror(errstr); } bbClear(lextext); - bbAppendn(lextext,s,len); + bbAppendn(lextext,s,(size_t)len); bbNull(lextext); if(s) efree(s); return lexdebug(TERMSTRING); @@ -2098,11 +2098,11 @@ YY_RULE_SETUP char* p = yytext+2; int len = yyleng - 2; bbClear(lextext); - bbAppendn(lextext,p,len); + bbAppendn(lextext,p,(size_t)len); if((len % 2) == 1) bbAppend(lextext,'0'); bbNull(lextext); /* convert all chars to lower case */ - for(p=bbContents(lextext);(int)*p;p++) *p = tolower(*p); + for(p=bbContents(lextext);*p;p++) *p = (char)tolower((int)*p); return lexdebug(OPAQUESTRING); } YY_BREAK @@ -2304,7 +2304,7 @@ YY_RULE_SETUP #line 343 "ncgen/ncgen.l" { bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); yylval.sym = makepath(bbContents(lextext)); return lexdebug(PATH); @@ -2315,7 +2315,7 @@ YY_RULE_SETUP #line 352 "ncgen/ncgen.l" {struct Specialtoken* st; bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); for(st=specials;st->name;st++) { if(strcmp(bbContents(lextext),st->name)==0) {return lexdebug(st->token);} @@ -2328,11 +2328,11 @@ case 39: YY_RULE_SETUP #line 362 "ncgen/ncgen.l" { - int c; + char c; char* p; char* q; /* copy the trimmed name */ bbClear(lextext); - bbAppendn(lextext,(char*)yytext,yyleng+1); /* include null */ + bbAppendn(lextext,(char*)yytext,(size_t)yyleng+1); /* include null */ bbNull(lextext); p = bbContents(lextext); q = p; @@ -2349,7 +2349,7 @@ YY_RULE_SETUP #line 379 "ncgen/ncgen.l" { char* id = NULL; size_t len; len = strlen(yytext); - len = unescape(yytext,len,ISIDENT,&id); + len = (size_t)unescape(yytext,len,ISIDENT,&id); if(NCSTREQ(id, FILL_STRING)) { efree(id); return lexdebug(FILLMARKER); @@ -2385,7 +2385,7 @@ YY_RULE_SETUP /* capture the tag string */ tag = collecttag(pos,&stag); if(tag == NC_NAT) { - snprintf(errstr,sizeof(errstr),"Illegal integer suffix: %s",stag); + snprintf(errstr, sizeof(errstr),"Illegal integer suffix: %s",stag); yyerror(errstr); goto done; } @@ -2407,13 +2407,13 @@ YY_RULE_SETUP radix = 10; if(isneg && hasU) { - snprintf(errstr,sizeof(errstr),"Unsigned integer cannot be signed: %s",ncgtext); + snprintf(errstr, sizeof(errstr),"Unsigned integer cannot be signed: %s",ncgtext); yyerror(errstr); goto done; } uint64_val = parseULL(radix, pos,&fail); if(fail) { - snprintf(errstr,sizeof(errstr),"integer constant out of range: %s",ncgtext); + snprintf(errstr, sizeof(errstr),"integer constant out of range: %s",ncgtext); yyerror(errstr); goto done; } @@ -2427,7 +2427,7 @@ YY_RULE_SETUP case NC_FORMAT_64BIT_OFFSET: case NC_FORMAT_NETCDF4_CLASSIC: if(nct > NC_INT) { - snprintf(errstr,sizeof(errstr),"Illegal integer constant for classic format: %s",ncgtext); + snprintf(errstr, sizeof(errstr),"Illegal integer constant for classic format: %s",ncgtext); yyerror(errstr); goto done; } @@ -2456,7 +2456,7 @@ YY_RULE_SETUP /* capture the tag string */ tag = collecttag(yytext,&stag); if(tag == NC_NAT) { - snprintf(errstr,sizeof(errstr),"Illegal integer suffix: %s",stag); + snprintf(errstr, sizeof(errstr),"Illegal integer suffix: %s",stag); yyerror(errstr); //goto done; return 0; @@ -2468,7 +2468,7 @@ YY_RULE_SETUP /* convert to an unsigned long long */ uint64_val = 0; while((c=*hex++)) { - unsigned int hexdigit = (c <= '9'?(c-'0'):(c-'a')+0xa); + unsigned int hexdigit = (unsigned int)(c <= '9'?(c-'0'):(c-'a')+0xa); uint64_val = ((uint64_val << 4) | hexdigit); } switch (tag) { @@ -2484,7 +2484,7 @@ YY_RULE_SETUP break; default: /* should never happen */ if (sscanf((char*)yytext, "%i", &uint32_val) != 1) { - snprintf(errstr,sizeof(errstr),"bad unsigned int constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr),"bad unsigned int constant: %s",(char*)yytext); yyerror(errstr); } token = UINT_CONST; @@ -2497,7 +2497,7 @@ YY_RULE_SETUP #line 517 "ncgen/ncgen.l" { if (sscanf((char*)yytext, "%le", &double_val) != 1) { - snprintf(errstr,sizeof(errstr),"bad long or double constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr),"bad long or double constant: %s",(char*)yytext); yyerror(errstr); } return lexdebug(DOUBLE_CONST); @@ -2508,7 +2508,7 @@ YY_RULE_SETUP #line 524 "ncgen/ncgen.l" { if (sscanf((char*)yytext, "%e", &float_val) != 1) { - snprintf(errstr,sizeof(errstr),"bad float constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr),"bad float constant: %s",(char*)yytext); yyerror(errstr); } return lexdebug(FLOAT_CONST); @@ -2529,10 +2529,10 @@ YY_RULE_SETUP { int oct = unescapeoct(&yytext[2]); if(oct < 0) { - snprintf(errstr,sizeof(errstr),"bad octal character constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr),"bad octal character constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = (unsigned int)oct; + byte_val = (signed char)oct; return lexdebug(BYTE_CONST); } YY_BREAK @@ -2542,10 +2542,10 @@ YY_RULE_SETUP { int hex = unescapehex(&yytext[3]); if(byte_val < 0) { - snprintf(errstr,sizeof(errstr),"bad hex character constant: %s",(char*)yytext); + snprintf(errstr, sizeof(errstr),"bad hex character constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = (unsigned int)hex; + byte_val = (signed char)hex; return lexdebug(BYTE_CONST); } YY_BREAK @@ -3681,7 +3681,7 @@ makepath(char* text0) refsym = lookupingroup(NC_GRP,ident,container); if(!lastident) { if(refsym == NULL) { - snprintf(errstr,sizeof(errstr),"Undefined or forward referenced group: %s",ident); + snprintf(errstr, sizeof(errstr),"Undefined or forward referenced group: %s",ident); yyerror(errstr); refsym = rootgroup; } else @@ -3750,7 +3750,7 @@ downconvert(unsigned long long uint64, int* tagp, int isneg, int hasU) { nc_type nct = NC_NAT; int tag = *tagp; - int bit63set = (uint64 >> 63); + int bit63set = (int)(uint64 >> 63); long long int64 = *((long long*)&uint64); if(isneg && hasU) { diff --git a/ncgen/ncgeny.c b/ncgen/ncgeny.c index bd6afd22cd..61a36e336e 100644 --- a/ncgen/ncgeny.c +++ b/ncgen/ncgeny.c @@ -1543,7 +1543,7 @@ yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, return -1; } - /* Avoid snprintf, as that infringes on the user's name space. + /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ { @@ -1985,7 +1985,7 @@ yyparse (void) (yyvsp[0].sym)->objectclass=NC_TYPE; (yyvsp[0].sym)->subclass=NC_OPAQUE; (yyvsp[0].sym)->typ.typecode=NC_OPAQUE; - (yyvsp[0].sym)->typ.size=int32_val; + (yyvsp[0].sym)->typ.size=(size_t)int32_val; (void)ncaux_class_alignment(NC_OPAQUE,&(yyvsp[0].sym)->typ.alignment); } #line 1992 "ncgeny.c" @@ -2279,7 +2279,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } - dimset.ndims = count; + dimset.ndims = (int)count; /* extract the actual dimensions*/ if(dimset.ndims > 0) { for(i=0;iname); count = NC_MAX_VAR_DIMS - 1; stacklen = stackbase + count; } - dimset.ndims = count; + dimset.ndims = (int)count; if(count > 0) { /* extract the actual dimensions*/ for(i=0;iname); { /* Anonymous integer dimension. Can only occur in type definitions*/ char anon[32]; - snprintf(anon,sizeof(anon),"const%u",uint32_val); + snprintf(anon, sizeof(anon),"const%u",uint32_val); (yyval.sym) = install(anon); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; @@ -2427,11 +2427,11 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[-2].sym)->name); derror("field dimension must be positive"); YYABORT; } - snprintf(anon,sizeof(anon),"const%d",int32_val); + snprintf(anon, sizeof(anon),"const%d",int32_val); (yyval.sym) = install(anon); (yyval.sym)->objectclass = NC_DIM; (yyval.sym)->dim.isconstant = 1; - (yyval.sym)->dim.declsize = int32_val; + (yyval.sym)->dim.declsize = (size_t)int32_val; } #line 2437 "ncgeny.c" break; From 3c6bd83330bd1dd089d9463e2cd789b8e423e132 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 12 Mar 2024 16:34:56 +0000 Subject: [PATCH 30/48] Change format of backwards-loops Enables using correct `size_t` type for loop counter, usually fixing some conversion warnings --- libdap2/cache.c | 7 ++++--- libdap2/constraints.c | 7 +++---- libdap2/dapodom.c | 3 +-- libdap2/daputil.c | 7 ++----- libdap2/ncd2dispatch.c | 4 ++-- libdispatch/dinfermodel.c | 19 +++++++++---------- libdispatch/drc.c | 3 +-- libhdf5/hdf5filter.c | 7 +++---- libnczarr/zchunking.c | 3 +-- libnczarr/zfilter.c | 9 ++++----- ncdump/ocprint.c | 9 ++++----- oc2/ocutil.c | 7 +++---- 12 files changed, 37 insertions(+), 48 deletions(-) diff --git a/libdap2/cache.c b/libdap2/cache.c index d481704e45..40db103924 100644 --- a/libdap2/cache.c +++ b/libdap2/cache.c @@ -25,7 +25,7 @@ static int iscacheableconstraint(DCEconstraint* con); int iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep) { - int i, found; + int found; size_t j; size_t index; NCcache* cache; @@ -39,7 +39,8 @@ iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep) cache = nccomm->cdf.cache; cachenode = cache->prefetch; if(cachenode!= NULL) { - for(found=0,i=0;ivars);i++) { + found = 0; + for(size_t i=0;ivars);i++) { CDFnode* var = (CDFnode*)nclistget(cachenode->vars,i); if(var == target) { if(cachenodep) *cachenodep = cachenode; @@ -51,7 +52,7 @@ iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep) /*search other cache nodes starting at latest first */ index = 0; - for(i=nclistlength(cache->nodes)-1;i>=0;i--) { + for(size_t i = nclistlength(cache->nodes); i-->0;) { cachenode = (NCcachenode*)nclistget(cache->nodes,i); /* We currently do not try to match constraints; If the cachenode is constrained by more than diff --git a/libdap2/constraints.c b/libdap2/constraints.c index e1c2308562..036feeb4ed 100644 --- a/libdap2/constraints.c +++ b/libdap2/constraints.c @@ -623,11 +623,10 @@ next: continue; } /*for(;;)*/ /* remove all NULL elements */ - int n; - for(n=nclistlength(list)-1;n>=0;n--) { + for(size_t n = nclistlength(list); n-->0;) { DCEprojection* target = (DCEprojection*)nclistget(list,n); - if(target == NULL) - nclistremove(list,n); + if(target == NULL) + nclistremove(list,n); } done: #ifdef DEBUG diff --git a/libdap2/dapodom.c b/libdap2/dapodom.c index c8d4a22396..8d59bc6cfb 100644 --- a/libdap2/dapodom.c +++ b/libdap2/dapodom.c @@ -114,9 +114,8 @@ dapodom_count(Dapodometer* odom) int dapodom_next(Dapodometer* odom) { - int i; /* do not make unsigned */ if(odom->rank == 0) return 0; - for(i=odom->rank-1;i>=0;i--) { + for(size_t i = odom->rank; i-->0;) { odom->index[i] += odom->stride[i]; if(odom->index[i] < odom->stop[i]) break; if(i == 0) return 0; /* leave the 0th entry if it overflows*/ diff --git a/libdap2/daputil.c b/libdap2/daputil.c index f70237f21f..70c3516257 100644 --- a/libdap2/daputil.c +++ b/libdap2/daputil.c @@ -268,11 +268,8 @@ nclistminus(NClist* l1, NClist* l2) int nclistdeleteall(NClist* l, void* elem) { - int i; /* do not make unsigned */ - unsigned int len,found; - found = 0; - len = nclistlength(l); - for(i=len-1;i>=0;i--) { + int found = 0; + for(size_t i = nclistlength(l); i-->0;) { void* test = nclistget(l,i); if(test==elem) { nclistremove(l,i); diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c index b60d2eca27..577e5a7cec 100644 --- a/libdap2/ncd2dispatch.c +++ b/libdap2/ncd2dispatch.c @@ -2146,14 +2146,14 @@ fprintf(stderr,"constrained:\n%s",dumptree(dapcomm->cdf.ddsroot)); static NCerror suppressunusablevars(NCDAPCOMMON* dapcomm) { - int i,j; + size_t i,j; int found = 1; NClist* path = nclistnew(); while(found) { found = 0; /* Walk backwards to aid removal semantics */ - for(i=nclistlength(dapcomm->cdf.ddsroot->tree->varnodes)-1;i>=0;i--) { + for(i = nclistlength(dapcomm->cdf.ddsroot->tree->varnodes); i-->0;) { CDFnode* var = (CDFnode*)nclistget(dapcomm->cdf.ddsroot->tree->varnodes,i); /* See if this var is under an unusable sequence */ nclistclear(path); diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index ebd2d3ef81..882f1771b0 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -557,10 +557,9 @@ negateone(const char* mode, NClist* newmodes) const struct MODEINFER* tests = modenegations; int changed = 0; for(;tests->key;tests++) { - int i; if(strcasecmp(tests->key,mode)==0) { /* Find and remove all instances of the inference value */ - for(i=nclistlength(newmodes)-1;i>=0;i--) { + for(size_t i = nclistlength(newmodes); i-- > 0;) { char* candidate = nclistget(newmodes,i); if(strcasecmp(candidate,tests->inference)==0) { nclistremove(newmodes,i); @@ -1188,25 +1187,25 @@ cleancommalist(const char* commalist, int caseinsensitive) static void cleanstringlist(NClist* strs, int caseinsensitive) { - int i,j; + int j; if(nclistlength(strs) == 0) return; /* Remove nulls */ - for(i=nclistlength(strs)-1;i>=0;i--) { + for(size_t i = nclistlength(strs); i-->0;) { if(nclistget(strs,i)==NULL) nclistremove(strs,i); } /* Remove duplicates*/ - for(i=0;ii;j--) { int match; const char* candidate = nclistget(strs,j); if(caseinsensitive) - match = (strcasecmp(value,candidate) == 0); - else - match = (strcmp(value,candidate) == 0); - if(match) {char* dup = nclistremove(strs,j); nullfree(dup);} - } + match = (strcasecmp(value,candidate) == 0); + else + match = (strcmp(value,candidate) == 0); + if(match) {char* dup = nclistremove(strs,j); nullfree(dup);} + } } } diff --git a/libdispatch/drc.c b/libdispatch/drc.c index 7ad2c7e45a..9bfaa35a7c 100644 --- a/libdispatch/drc.c +++ b/libdispatch/drc.c @@ -362,7 +362,6 @@ rctrim(char* text) char* p; char* q; size_t len = 0; - int i; if(text == NULL || *text == '\0') return; @@ -375,7 +374,7 @@ rctrim(char* text) len = strlen(p); /* locate last non-trimchar */ if(len > 0) { - for(i=(len-1);i>=0;i--) { + for(size_t i = len; i-->0;) { p = &text[i]; if(*p != ' ' && *p != '\t' && *p != '\r') {break;} *p = '\0'; /* elide trailing trimchars */ diff --git a/libhdf5/hdf5filter.c b/libhdf5/hdf5filter.c index c529eac926..2cd840aac2 100644 --- a/libhdf5/hdf5filter.c +++ b/libhdf5/hdf5filter.c @@ -224,13 +224,13 @@ printfilterlist(NC_VAR_INFO_T* var, const char* tag, int line) int NC4_hdf5_filter_freelist(NC_VAR_INFO_T* var) { - int i, stat=NC_NOERR; + int stat=NC_NOERR; NClist* filters = (NClist*)var->filters; if(filters == NULL) goto done; PRINTFILTERLIST(var,"free: before"); /* Free the filter list backward */ - for(i=nclistlength(filters)-1;i>=0;i--) { + for(size_t i = nclistlength(filters);i-->0;) { struct NC_HDF5_Filter* spec = (struct NC_HDF5_Filter*)nclistremove(filters,i); if(spec->nparams > 0) nullfree(spec->params); nullfree(spec); @@ -312,11 +312,10 @@ PRINTFILTERLIST(var,"add"); int NC4_hdf5_filter_remove(NC_VAR_INFO_T* var, unsigned int id) { - int k; NClist* flist = (NClist*)var->filters; /* Walk backwards */ - for(k=nclistlength(flist)-1;k>=0;k--) { + for(size_t k = nclistlength(flist); k-->0;) { struct NC_HDF5_Filter* f = (struct NC_HDF5_Filter*)nclistget(flist,k); if(f->filterid == id) { /* Remove from variable */ diff --git a/libnczarr/zchunking.c b/libnczarr/zchunking.c index d2defd230a..eb328d3c72 100644 --- a/libnczarr/zchunking.c +++ b/libnczarr/zchunking.c @@ -96,8 +96,7 @@ NCZ_compute_projections(struct Common* common, int r, size64_t chunkindex, cons projection = &projections[n]; if(n > 0) { /* Find last non-skipped projection */ - int i; - for(i=n-1;i>=0;i--) { /* walk backward */ + for(size_t i=n;i-->0;) { /* walk backward */ if(!projections[i].skip) { prev = &projections[i]; break; diff --git a/libnczarr/zfilter.c b/libnczarr/zfilter.c index bf1eb8542c..6f4a8b9730 100644 --- a/libnczarr/zfilter.c +++ b/libnczarr/zfilter.c @@ -423,12 +423,12 @@ NCZ_addfilter(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, unsigned int id, size_t int NCZ_filter_remove(NC_VAR_INFO_T* var, unsigned int id) { - int k, stat = NC_NOERR; + int stat = NC_NOERR; NClist* flist = (NClist*)var->filters; ZTRACE(6,"var=%s id=%u",var->hdr.name,id); /* Walk backwards */ - for(k=nclistlength(flist)-1;k>=0;k--) { + for(size_t k = nclistlength(flist); k-->0;) { struct NCZ_Filter* f = (struct NCZ_Filter*)nclistget(flist,k); if(f->hdf5.id == id) { /* Remove from variable */ @@ -896,9 +896,8 @@ fprintf(stderr,">>> next: alloc=%u used=%u buf=%p\n",(unsigned)next_alloc,(unsig } } else { /* Apply in reverse order */ - int k; - for(k=(int)nclistlength(chain)-1;k>=0;k--) { - f = (struct NCZ_Filter*)nclistget(chain,(size_t)k); + for(size_t k=nclistlength(chain); k-->0;) { + f = (struct NCZ_Filter*)nclistget(chain, k); if(f->flags & FLAG_SUPPRESS) continue; /* this filter should not be applied */ ff = f->plugin->hdf5.filter; /* code can be simplified */ diff --git a/ncdump/ocprint.c b/ncdump/ocprint.c index e75d153a04..9860d6d87a 100644 --- a/ncdump/ocprint.c +++ b/ncdump/ocprint.c @@ -1104,11 +1104,10 @@ odom_init(size_t rank, size_t* indices, size_t* dimsizes) static void odom_next(size_t rank, size_t* indices, size_t* dimsizes) { - int i; - for(i=rank-1;i>=0;i--) { - indices[i]++; - if(indices[i] < dimsizes[i]) break; - if(i > 0) indices[i] = 0; + for(size_t i = rank; i-->0;) { + indices[i]++; + if(indices[i] < dimsizes[i]) break; + if(i > 0) indices[i] = 0; } } diff --git a/oc2/ocutil.c b/oc2/ocutil.c index a5000be9e3..9cb808afa2 100644 --- a/oc2/ocutil.c +++ b/oc2/ocutil.c @@ -490,10 +490,9 @@ ocarrayoffset(size_t rank, size_t* sizes, const size_t* indices) void ocarrayindices(size_t index, size_t rank, size_t* sizes, size_t* indices) { - int i; - for(i=rank-1;i>=0;i--) { - indices[i] = index % sizes[i]; - index = (index - indices[i]) / sizes[i]; + for(size_t i = rank; i-->0;) { + indices[i] = index % sizes[i]; + index = (index - indices[i]) / sizes[i]; } } From 1cf1522436c0f569e29f8cd7a7457c98a71b355c Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 13:45:38 +0000 Subject: [PATCH 31/48] Skip checking for duplicates if only one element in list --- libdispatch/dinfermodel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 882f1771b0..218ae6640d 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -1187,18 +1187,18 @@ cleancommalist(const char* commalist, int caseinsensitive) static void cleanstringlist(NClist* strs, int caseinsensitive) { - int j; if(nclistlength(strs) == 0) return; /* Remove nulls */ for(size_t i = nclistlength(strs); i-->0;) { if(nclistget(strs,i)==NULL) nclistremove(strs,i); } + if(nclistlength(strs) <= 1) return; /* Remove duplicates*/ for(size_t i=0;ii;j--) { - int match; + /* look ahead for duplicates */ + for(size_t j=nclistlength(strs)-1;j>i;j--) { + int match; const char* candidate = nclistget(strs,j); if(caseinsensitive) match = (strcasecmp(value,candidate) == 0); From 6176eaa785213695cee97fc21fa534669f71e2b4 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 15:31:39 +0000 Subject: [PATCH 32/48] CMake: Add option to automatically regenerate ncgen3/ncgen --- ncgen3/CMakeLists.txt | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/ncgen3/CMakeLists.txt b/ncgen3/CMakeLists.txt index 5f26419f07..a1ca6abf27 100644 --- a/ncgen3/CMakeLists.txt +++ b/ncgen3/CMakeLists.txt @@ -14,23 +14,32 @@ SET(ncgen3_FILES main.c load.c escapes.c getfill.c init.c genlib.c ncgeny.c ${XG FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nc ${CMAKE_CURRENT_SOURCE_DIR}/*.sh ${CMAKE_CURRENT_SOURCE_DIR}/*.cdl) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE) -IF(NOT EXISTS ${netCDF_SOURCE_DIR}/ncgen3/ncgeny.c AND NOT EXISTS - ${netCDF_SOURCE_DIR}/ncgen3/ncgeny.h) - ADD_CUSTOM_COMMAND( - OUTPUT ncgentab.h - COMMAND flex -Pncg -8 ncgen.l - COMMAND rm -f ncgenl.c - COMMAND mv lex.ncg.c ncgenl.c - COMMAND bison -pncg -t -d ncgen.y - COMMAND rm -f ncgeny.c ncgeny.h - COMMAND mv ncgen.tab.c ncgeny.c - COMMAND mv ncgen.tab.h ncgeny.h - COMMAND mv ncgeny.h ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND mv ncgeny.c ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND mv ncgenl.c ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM +# With this option enabled, automatically generate the parser source +# files from the yacc input files when they're changed. They don't +# change very often, so this option is off by default. +if (NETCDF_GENERATE_NCGEN) + find_program(FLEX flex REQUIRED) + find_program(BISON bison REQUIRED) + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.h ${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.c ${CMAKE_CURRENT_SOURCE_DIR}/ncgenl.c + DEPENDS ncgen.y ncgen.l + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + + COMMAND ${FLEX} -Pncg -8 ncgen/ncgen.l + COMMAND mv lex.ncg.c "${CMAKE_CURRENT_SOURCE_DIR}/ncgenl.c" + + COMMAND ${BISON} -pncg -t -d ncgen/ncgen.y + COMMAND mv ncgen.tab.c "${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.c" + COMMAND mv ncgen.tab.h "${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.h" + + # Fix the `#line` preprocessor directives with the correct source paths + COMMAND sed -i s/ncgen.tab/ncgeny/ "${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.c" + COMMAND sed -i s/lex.ncg/ncgenl/ "${CMAKE_CURRENT_SOURCE_DIR}/ncgenl.c" + COMMAND sed -i s/ncgen.tab/ncgeny/ "${CMAKE_CURRENT_SOURCE_DIR}/ncgeny.h" + VERBATIM ) -ENDIF() +endif() ADD_EXECUTABLE(ncgen3 ${ncgen3_FILES}) TARGET_LINK_LIBRARIES(ncgen3 netcdf ${ALL_TLL_LIBS}) From e0622c8a3adc2ed031d619d0d4516496c1294e0b Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 15:32:23 +0000 Subject: [PATCH 33/48] Regenerate ncgen3 Use flex 2.6.4 and bison 3.8.2 Lots of changes but does squash a bunch of warnings --- ncgen3/ncgenl.c | 927 ++++++++++++++++++------------ ncgen3/ncgeny.c | 1461 ++++++++++++++++++++++------------------------- ncgen3/ncgeny.h | 60 +- 3 files changed, 1276 insertions(+), 1172 deletions(-) diff --git a/ncgen3/ncgenl.c b/ncgen3/ncgenl.c index 1db8ff1d69..1cc3c4831b 100644 --- a/ncgen3/ncgenl.c +++ b/ncgen3/ncgenl.c @@ -1,5 +1,5 @@ -#line 3 "ncgenl.c" +#line 2 "ncgenl.c" #define YY_INT_ALIGNED short int @@ -7,14 +7,20 @@ #define yy_create_buffer ncg_create_buffer #define yy_delete_buffer ncg_delete_buffer -#define yy_flex_debug ncg_flex_debug +#define yy_scan_buffer ncg_scan_buffer +#define yy_scan_string ncg_scan_string +#define yy_scan_bytes ncg_scan_bytes #define yy_init_buffer ncg_init_buffer #define yy_flush_buffer ncg_flush_buffer #define yy_load_buffer_state ncg_load_buffer_state #define yy_switch_to_buffer ncg_switch_to_buffer +#define yypush_buffer_state ncgpush_buffer_state +#define yypop_buffer_state ncgpop_buffer_state +#define yyensure_buffer_stack ncgensure_buffer_stack +#define yy_flex_debug ncg_flex_debug #define yyin ncgin #define yyleng ncgleng -#define yylex ncglex +#define yyncgenllex #define yylineno ncglineno #define yyout ncgout #define yyrestart ncgrestart @@ -27,11 +33,245 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define ncg_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer ncg_create_buffer +#endif + +#ifdef yy_delete_buffer +#define ncg_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer ncg_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define ncg_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer ncg_scan_buffer +#endif + +#ifdef yy_scan_string +#define ncg_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string ncg_scan_string +#endif + +#ifdef yy_scan_bytes +#define ncg_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes ncg_scan_bytes +#endif + +#ifdef yy_init_buffer +#define ncg_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer ncg_init_buffer +#endif + +#ifdef yy_flush_buffer +#define ncg_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer ncg_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define ncg_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state ncg_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define ncg_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer ncg_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define ncgpush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state ncgpush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define ncgpop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state ncgpop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define ncgensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack ncgensure_buffer_stack +#endif + +#ifdef yylex +#define ncglex_ALREADY_DEFINED +#else +#define yyncgenllex +#endif + +#ifdef yyrestart +#define ncgrestart_ALREADY_DEFINED +#else +#define yyrestart ncgrestart +#endif + +#ifdef yylex_init +#define ncglex_init_ALREADY_DEFINED +#else +#define yylex_init ncglex_init +#endif + +#ifdef yylex_init_extra +#define ncglex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra ncglex_init_extra +#endif + +#ifdef yylex_destroy +#define ncglex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy ncglex_destroy +#endif + +#ifdef yyget_debug +#define ncgget_debug_ALREADY_DEFINED +#else +#define yyget_debug ncgget_debug +#endif + +#ifdef yyset_debug +#define ncgset_debug_ALREADY_DEFINED +#else +#define yyset_debug ncgset_debug +#endif + +#ifdef yyget_extra +#define ncgget_extra_ALREADY_DEFINED +#else +#define yyget_extra ncgget_extra +#endif + +#ifdef yyset_extra +#define ncgset_extra_ALREADY_DEFINED +#else +#define yyset_extra ncgset_extra +#endif + +#ifdef yyget_in +#define ncgget_in_ALREADY_DEFINED +#else +#define yyget_in ncgget_in +#endif + +#ifdef yyset_in +#define ncgset_in_ALREADY_DEFINED +#else +#define yyset_in ncgset_in +#endif + +#ifdef yyget_out +#define ncgget_out_ALREADY_DEFINED +#else +#define yyget_out ncgget_out +#endif + +#ifdef yyset_out +#define ncgset_out_ALREADY_DEFINED +#else +#define yyset_out ncgset_out +#endif + +#ifdef yyget_leng +#define ncgget_leng_ALREADY_DEFINED +#else +#define yyget_leng ncgget_leng +#endif + +#ifdef yyget_text +#define ncgget_text_ALREADY_DEFINED +#else +#define yyget_text ncgget_text +#endif + +#ifdef yyget_lineno +#define ncgget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno ncgget_lineno +#endif + +#ifdef yyset_lineno +#define ncgset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno ncgset_lineno +#endif + +#ifdef yywrap +#define ncgwrap_ALREADY_DEFINED +#else +#define yywrap ncgwrap +#endif + +#ifdef yyalloc +#define ncgalloc_ALREADY_DEFINED +#else +#define yyalloc ncgalloc +#endif + +#ifdef yyrealloc +#define ncgrealloc_ALREADY_DEFINED +#else +#define yyrealloc ncgrealloc +#endif + +#ifdef yyfree +#define ncgfree_ALREADY_DEFINED +#else +#define yyfree ncgfree +#endif + +#ifdef yytext +#define ncgtext_ALREADY_DEFINED +#else +#define yytext ncgtext +#endif + +#ifdef yyleng +#define ncgleng_ALREADY_DEFINED +#else +#define yyleng ncgleng +#endif + +#ifdef yyin +#define ncgin_ALREADY_DEFINED +#else +#define yyin ncgin +#endif + +#ifdef yyout +#define ncgout_ALREADY_DEFINED +#else +#define yyout ncgout +#endif + +#ifdef yy_flex_debug +#define ncg_flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug ncg_flex_debug +#endif + +#ifdef yylineno +#define ncglineno_ALREADY_DEFINED +#else +#define yylineno ncglineno +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -102,60 +342,48 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST +/* begin standard C++ headers. */ -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE ncgrestart(ncgin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -185,14 +413,14 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t ncgleng; +extern int yyleng; -extern FILE *ncgin, *ncgout; +extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) @@ -200,16 +428,15 @@ extern FILE *ncgin, *ncgout; #define yyless(n) \ do \ { \ - /* Undo effects of setting up ncgtext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up ncgtext again */ \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -224,7 +451,7 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. @@ -252,7 +479,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -269,8 +496,8 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via ncgrestart()), so that the user can continue scanning by - * just pointing ncgin at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -280,7 +507,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -291,109 +518,98 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] -/* yy_hold_char holds the character lost when ncgtext is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t ncgleng; +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow ncgwrap()'s to do buffer switches - * instead of setting up a fresh ncgin. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -void ncgrestart (FILE *input_file ); -void ncg_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE ncg_create_buffer (FILE *file,int size ); -void ncg_delete_buffer (YY_BUFFER_STATE b ); -void ncg_flush_buffer (YY_BUFFER_STATE b ); -void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void ncgpop_buffer_state (void ); - -static void ncgensure_buffer_stack (void ); -static void ncg_load_buffer_state (void ); -static void ncg_init_buffer (YY_BUFFER_STATE b,FILE *file ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -#define YY_FLUSH_BUFFER ncg_flush_buffer(YY_CURRENT_BUFFER ) +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -YY_BUFFER_STATE ncg_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE ncg_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,yy_size_t len ); +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -void *ncgalloc (yy_size_t ); -void *ncgrealloc (void *,yy_size_t ); -void ncgfree (void * ); - -#define yy_new_buffer ncg_create_buffer +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - ncgensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - ncg_create_buffer(ncgin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - ncgensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - ncg_create_buffer(ncgin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *ncgin = (FILE *) 0, *ncgout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; -extern int ncglineno; - -int ncglineno = 1; +extern int yylineno; +int yylineno = 1; -extern char *ncgtext; +extern char *yytext; #ifdef yytext_ptr #undef yytext_ptr #endif -#define yytext_ptr ncgtext +#define yytext_ptr yytext -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -#if defined(__GNUC__) && __GNUC__ >= 3 -__attribute__((__noreturn__)) -#endif -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the - * corresponding action - sets up ncgtext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - ncgleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - #define YY_NUM_RULES 30 #define YY_END_OF_BUFFER 31 /* This struct is not used in this scanner, @@ -403,7 +619,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[236] = +static const flex_int16_t yy_accept[236] = { 0, 0, 0, 31, 29, 28, 17, 29, 29, 29, 29, 19, 29, 22, 22, 16, 16, 16, 16, 16, 16, @@ -433,7 +649,7 @@ static yyconst flex_int16_t yy_accept[236] = 16, 11, 16, 10, 0 } ; -static yyconst YY_CHAR yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 4, 4, 1, 1, 1, 1, 1, 1, 1, @@ -465,7 +681,7 @@ static yyconst YY_CHAR yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst YY_CHAR yy_meta[61] = +static const YY_CHAR yy_meta[61] = { 0, 1, 1, 2, 1, 1, 1, 1, 3, 4, 4, 4, 1, 5, 5, 5, 1, 4, 5, 5, 5, @@ -475,7 +691,7 @@ static yyconst YY_CHAR yy_meta[61] = 4, 4, 4, 4, 4, 7, 1, 4, 4, 4 } ; -static yyconst flex_uint16_t yy_base[246] = +static const flex_int16_t yy_base[246] = { 0, 0, 0, 327, 1206, 59, 1206, 55, 277, 54, 59, 88, 295, 124, 165, 30, 57, 159, 61, 141, 149, @@ -506,7 +722,7 @@ static yyconst flex_uint16_t yy_base[246] = 1187, 66, 1191, 1194, 1199 } ; -static yyconst flex_int16_t yy_def[246] = +static const flex_int16_t yy_def[246] = { 0, 235, 1, 235, 235, 235, 235, 236, 237, 235, 235, 235, 235, 235, 235, 238, 238, 238, 238, 238, 238, @@ -537,7 +753,7 @@ static yyconst flex_int16_t yy_def[246] = 235, 235, 235, 235, 235 } ; -static yyconst flex_uint16_t yy_nxt[1267] = +static const flex_int16_t yy_nxt[1267] = { 0, 4, 5, 6, 5, 5, 4, 7, 8, 9, 10, 11, 12, 13, 14, 14, 4, 4, 15, 15, 15, @@ -680,7 +896,7 @@ static yyconst flex_uint16_t yy_nxt[1267] = 235, 235, 235, 235, 235, 235 } ; -static yyconst flex_int16_t yy_chk[1267] = +static const flex_int16_t yy_chk[1267] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -826,8 +1042,8 @@ static yyconst flex_int16_t yy_chk[1267] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int ncg_flex_debug; -int ncg_flex_debug = 0; +extern int yy_flex_debug; +int yy_flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -836,9 +1052,9 @@ int ncg_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *ncgtext; -#line 1 "ncgen.l" -#line 2 "ncgen.l" +char *yytext; +#line 1 "ncgen3/ncgen.l" +#line 2 "ncgen3/ncgen.l" /********************************************************************* * Copyright 2018, UCAR/Unidata * See netcdf/COPYRIGHT file for copying and redistribution conditions. @@ -886,6 +1102,7 @@ char errstr[100]; /* for short error messages */ but make sure every action ends with "return" or "break"! */ +#line 1105 "ncgenl.c" /* The most correct (validating) version of UTF8 character set (Taken from: http://www.w3.org/2005/03/23-lex-U) @@ -925,7 +1142,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})* /* Note: this definition of string will work for utf8 as well, although it is a very relaxed definition */ -#line 929 "ncgenl.c" +#line 1145 "ncgenl.c" #define INITIAL 0 @@ -941,36 +1158,36 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})* #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int ncglex_destroy (void ); +int yylex_destroy ( void ); -int ncgget_debug (void ); +int yyget_debug ( void ); -void ncgset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE ncgget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void ncgset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *ncgget_in (void ); +FILE *yyget_in ( void ); -void ncgset_in (FILE * _in_str ); +void yyset_in ( FILE * _in_str ); -FILE *ncgget_out (void ); +FILE *yyget_out ( void ); -void ncgset_out (FILE * _out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t ncgget_leng (void ); + int yyget_leng ( void ); -char *ncgget_text (void ); +char *yyget_text ( void ); -int ncgget_lineno (void ); +int yyget_lineno ( void ); -void ncgset_lineno (int _line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -978,32 +1195,31 @@ void ncgset_lineno (int _line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int ncgwrap (void ); +extern "C" int yywrap ( void ); #else -extern int ncgwrap (void ); +extern int yywrap ( void ); #endif #endif #ifndef YY_NO_UNPUT - static void yyunput (int c,char *buf_ptr ); + static void yyunput ( int c, char *buf_ptr ); #endif #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif #endif @@ -1023,7 +1239,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( ncgtext, ncgleng, 1, ncgout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1034,20 +1250,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ - (c = getc( ncgin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( ncgin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, ncgin))==0 && ferror(ncgin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -1055,7 +1271,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(ncgin); \ + clearerr(yyin); \ } \ }\ \ @@ -1088,12 +1304,12 @@ static int input (void ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int ncglex (void); +extern int yylex (void); -#define YY_DECL int ncglex (void) +#define YY_DECL int yylex (void) #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after ncgtext and ncgleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -1127,31 +1343,31 @@ YY_DECL if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ - if ( ! ncgin ) - ncgin = stdin; + if ( ! yyin ) + yyin = stdin; - if ( ! ncgout ) - ncgout = stdout; + if ( ! yyout ) + yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - ncgensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - ncg_create_buffer(ncgin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - ncg_load_buffer_state( ); + yy_load_buffer_state( ); } { -#line 107 "ncgen.l" +#line 107 "ncgen3/ncgen.l" -#line 1149 "ncgenl.c" +#line 1364 "ncgenl.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); - /* Support of ncgtext. */ + /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of @@ -1173,9 +1389,9 @@ YY_DECL { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 236 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 1206 ); @@ -1204,7 +1420,7 @@ YY_DECL case 1: YY_RULE_SETUP -#line 108 "ncgen.l" +#line 108 "ncgen3/ncgen.l" { /* comment */ break; } @@ -1212,74 +1428,74 @@ YY_RULE_SETUP case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 112 "ncgen.l" +#line 112 "ncgen3/ncgen.l" { - if(ncgleng > MAXTRST) { + if(yyleng > MAXTRST) { yyerror("string too long, truncated\n"); - ncgtext[MAXTRST-1] = '\0'; + yytext[MAXTRST-1] = '\0'; } - expand_escapes(termstring,(char *)ncgtext,ncgleng); + expand_escapes(termstring,(char *)yytext,yyleng); return (TERMSTRING); } YY_BREAK case 3: YY_RULE_SETUP -#line 121 "ncgen.l" +#line 121 "ncgen3/ncgen.l" {return (FLOAT_K);} YY_BREAK case 4: YY_RULE_SETUP -#line 122 "ncgen.l" +#line 122 "ncgen3/ncgen.l" {return (CHAR_K);} YY_BREAK case 5: YY_RULE_SETUP -#line 123 "ncgen.l" +#line 123 "ncgen3/ncgen.l" {return (BYTE_K);} YY_BREAK case 6: YY_RULE_SETUP -#line 124 "ncgen.l" +#line 124 "ncgen3/ncgen.l" {return (SHORT_K);} YY_BREAK case 7: YY_RULE_SETUP -#line 125 "ncgen.l" +#line 125 "ncgen3/ncgen.l" {return (INT_K);} YY_BREAK case 8: YY_RULE_SETUP -#line 126 "ncgen.l" +#line 126 "ncgen3/ncgen.l" {return (DOUBLE_K);} YY_BREAK case 9: YY_RULE_SETUP -#line 127 "ncgen.l" +#line 127 "ncgen3/ncgen.l" {int_val = -1; return (NC_UNLIMITED_K);} YY_BREAK case 10: YY_RULE_SETUP -#line 130 "ncgen.l" +#line 130 "ncgen3/ncgen.l" {return (DIMENSIONS);} YY_BREAK case 11: YY_RULE_SETUP -#line 131 "ncgen.l" +#line 131 "ncgen3/ncgen.l" {return (VARIABLES);} YY_BREAK case 12: YY_RULE_SETUP -#line 132 "ncgen.l" +#line 132 "ncgen3/ncgen.l" {return (DATA);} YY_BREAK case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 133 "ncgen.l" +#line 133 "ncgen3/ncgen.l" { - char *s = (char*)ncgtext+strlen("netcdf"); - char *t = (char*)ncgtext+ncgleng-1; + char *s = (char*)yytext+strlen("netcdf"); + char *t = (char*)yytext+yyleng-1; while (isspace(*s)) s++; while (isspace(*t)) @@ -1298,9 +1514,9 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 151 "ncgen.l" +#line 151 "ncgen3/ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ - if (ncgtext[0] == '-') { + if (yytext[0] == '-') { double_val = -NC_FILL_DOUBLE; } else { double_val = NC_FILL_DOUBLE; @@ -1310,9 +1526,9 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 159 "ncgen.l" +#line 159 "ncgen3/ncgen.l" { /* missing value (pre-2.4 backward compatibility) */ - if (ncgtext[0] == '-') { + if (yytext[0] == '-') { float_val = -NC_FILL_FLOAT; } else { float_val = NC_FILL_FLOAT; @@ -1322,12 +1538,12 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 167 "ncgen.l" +#line 167 "ncgen3/ncgen.l" { - if (STREQ((char *)ncgtext, FILL_STRING)) + if (STREQ((char *)yytext, FILL_STRING)) return (FILLVALUE); - if ((yylval = lookup((char *)ncgtext)) == NULL) { - yylval = install((char *)ncgtext); + if ((yylval = lookup((char *)yytext)) == NULL) { + yylval = install((char *)yytext); } return (IDENT); } @@ -1335,7 +1551,7 @@ YY_RULE_SETUP case 17: /* rule 17 can match eol */ YY_RULE_SETUP -#line 176 "ncgen.l" +#line 176 "ncgen3/ncgen.l" { lineno++ ; break; @@ -1343,16 +1559,16 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 181 "ncgen.l" +#line 181 "ncgen3/ncgen.l" { int ii; - if (sscanf((char*)ncgtext, "%d", &ii) != 1) { - snprintf(errstr,sizeof(errstr),"bad byte constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%d", &ii) != 1) { + snprintf(errstr, sizeof(errstr),"bad byte constant: %s",(char*)yytext); yyerror(errstr); } byte_val = ii; if (ii != (int)byte_val) { - snprintf(errstr,sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)ncgtext); + snprintf(errstr, sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)yytext); yyerror(errstr); } return (BYTE_CONST); @@ -1360,10 +1576,10 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 195 "ncgen.l" +#line 195 "ncgen3/ncgen.l" { - if (sscanf((char*)ncgtext, "%le", &double_val) != 1) { - snprintf(errstr,sizeof(errstr),"bad long or double constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%le", &double_val) != 1) { + snprintf(errstr, sizeof(errstr),"bad long or double constant: %s",(char*)yytext); yyerror(errstr); } return (DOUBLE_CONST); @@ -1371,10 +1587,10 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 202 "ncgen.l" +#line 202 "ncgen3/ncgen.l" { - if (sscanf((char*)ncgtext, "%e", &float_val) != 1) { - snprintf(errstr,sizeof(errstr),"bad float constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%e", &float_val) != 1) { + snprintf(errstr, sizeof(errstr),"bad float constant: %s",(char*)yytext); yyerror(errstr); } return (FLOAT_CONST); @@ -1382,11 +1598,11 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 209 "ncgen.l" +#line 209 "ncgen3/ncgen.l" { int tmp = 0; - if (sscanf((char*)ncgtext, "%d", &tmp) != 1) { - snprintf(errstr,sizeof(errstr),"bad short constant: %s",(char*)ncgtext); + if (sscanf((char*)yytext, "%d", &tmp) != 1) { + snprintf(errstr, sizeof(errstr),"bad short constant: %s",(char*)yytext); yyerror(errstr); } short_val = (short)tmp; @@ -1395,13 +1611,13 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 218 "ncgen.l" +#line 218 "ncgen3/ncgen.l" { char *ptr; errno = 0; - double_val = strtod((char*)ncgtext, &ptr); + double_val = strtod((char*)yytext, &ptr); if (errno != 0 && double_val == 0.0) { - snprintf(errstr,sizeof(errstr),"bad numerical constant: %s",(char*)ncgtext); + snprintf(errstr, sizeof(errstr),"bad numerical constant: %s",(char*)yytext); yyerror(errstr); } if (double_val < XDR_INT_MIN ||double_val > XDR_INT_MAX) { @@ -1414,14 +1630,14 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 233 "ncgen.l" +#line 233 "ncgen3/ncgen.l" { char *ptr; long long_val; errno = 0; - long_val = strtol((char*)ncgtext, &ptr, 0); + long_val = strtol((char*)yytext, &ptr, 0); if (errno != 0) { - snprintf(errstr,sizeof(errstr),"bad long constant: %s",(char*)ncgtext); + snprintf(errstr, sizeof(errstr),"bad long constant: %s",(char*)yytext); yyerror(errstr); } if (long_val < XDR_INT_MIN || long_val > XDR_INT_MAX) { @@ -1436,33 +1652,33 @@ YY_RULE_SETUP case 24: /* rule 24 can match eol */ YY_RULE_SETUP -#line 250 "ncgen.l" +#line 250 "ncgen3/ncgen.l" { - (void) sscanf((char*)&ncgtext[1],"%c",&byte_val); + (void) sscanf((char*)&yytext[1],"%c",&byte_val); return (BYTE_CONST); } YY_BREAK case 25: YY_RULE_SETUP -#line 254 "ncgen.l" +#line 254 "ncgen3/ncgen.l" { - byte_val = (char) strtol((char*)&ncgtext[2], (char **) 0, 8); + byte_val = (char) strtol((char*)&yytext[2], (char **) 0, 8); return (BYTE_CONST); } YY_BREAK case 26: YY_RULE_SETUP -#line 258 "ncgen.l" +#line 258 "ncgen3/ncgen.l" { - byte_val = (char) strtol((char*)&ncgtext[3], (char **) 0, 16); + byte_val = (char) strtol((char*)&yytext[3], (char **) 0, 16); return (BYTE_CONST); } YY_BREAK case 27: YY_RULE_SETUP -#line 262 "ncgen.l" +#line 262 "ncgen3/ncgen.l" { - switch ((char)ncgtext[2]) { + switch ((char)yytext[2]) { case 'a': byte_val = '\007'; break; /* not everyone under- * stands '\a' yet */ case 'b': byte_val = '\b'; break; @@ -1474,31 +1690,31 @@ YY_RULE_SETUP case '\\': byte_val = '\\'; break; case '?': byte_val = '\177'; break; case '\'': byte_val = '\''; break; - default: byte_val = (char)ncgtext[2]; + default: byte_val = (char)yytext[2]; } return (BYTE_CONST); } YY_BREAK case 28: YY_RULE_SETUP -#line 280 "ncgen.l" +#line 280 "ncgen3/ncgen.l" { /* whitespace */ break; } YY_BREAK case 29: YY_RULE_SETUP -#line 283 "ncgen.l" +#line 283 "ncgen3/ncgen.l" {/* Note: this next rule will not work for UTF8 characters */ - return (ncgtext[0]) ; + return (yytext[0]) ; } YY_BREAK case 30: YY_RULE_SETUP -#line 287 "ncgen.l" +#line 287 "ncgen3/ncgen.l" ECHO; YY_BREAK -#line 1502 "ncgenl.c" +#line 1717 "ncgenl.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1515,15 +1731,15 @@ case YY_STATE_EOF(INITIAL): { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed ncgin at a new source and called - * ncglex(). If so, then we have to assure + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = ncgin; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -1576,11 +1792,11 @@ case YY_STATE_EOF(INITIAL): { (yy_did_buffer_switch_on_eof) = 0; - if ( ncgwrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * ncgtext, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the @@ -1630,7 +1846,7 @@ case YY_STATE_EOF(INITIAL): } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of ncglex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1643,7 +1859,7 @@ static int yy_get_next_buffer (void) { char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *source = (yytext_ptr); - yy_size_t number_to_move, i; + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1672,7 +1888,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -1685,7 +1901,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -1699,7 +1915,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1708,11 +1924,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - ncgrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1740,7 +1957,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - ncgrestart(ncgin ); + yyrestart( yyin ); } else @@ -1754,12 +1971,15 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ncgrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); } (yy_n_chars) += number_to_move; @@ -1792,9 +2012,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 236 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -1820,9 +2040,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 236 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 235); return yy_is_jam ? 0 : yy_current_state; @@ -1836,13 +2056,13 @@ static int yy_get_next_buffer (void) yy_cp = (yy_c_buf_p); - /* undo effects of setting up ncgtext */ + /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - yy_size_t number_to_move = (yy_n_chars) + 2; + int number_to_move = (yy_n_chars) + 2; char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; char *source = @@ -1854,7 +2074,7 @@ static int yy_get_next_buffer (void) yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1893,7 +2113,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -1910,14 +2130,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - ncgrestart(ncgin ); + yyrestart( yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( ncgwrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -1936,7 +2156,7 @@ static int yy_get_next_buffer (void) } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve ncgtext */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); return c; @@ -1948,32 +2168,32 @@ static int yy_get_next_buffer (void) * * @note This function does not reset the start condition to @c INITIAL . */ - void ncgrestart (FILE * input_file ) + void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ - ncgensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - ncg_create_buffer(ncgin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - ncg_init_buffer(YY_CURRENT_BUFFER,input_file ); - ncg_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ - void ncg_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with - * ncgpop_buffer_state(); - * ncgpush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - ncgensure_buffer_stack (); + yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -1986,21 +2206,21 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - ncg_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during - * EOF (ncgwrap()) processing, but the only time this flag - * is looked at is after ncgwrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } -static void ncg_load_buffer_state (void) +static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - ncgin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } @@ -2010,35 +2230,35 @@ static void ncg_load_buffer_state (void) * * @return the allocated buffer state. */ - YY_BUFFER_STATE ncg_create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) ncgalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = (yy_size_t)size; + b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) ncgalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - ncg_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } /** Destroy the buffer. - * @param b a buffer created with ncg_create_buffer() + * @param b a buffer created with yy_create_buffer() * */ - void ncg_delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) @@ -2048,27 +2268,27 @@ static void ncg_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - ncgfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - ncgfree((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a ncgrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void ncg_init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; - ncg_flush_buffer(b ); + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then ncg_init_buffer was _probably_ - * called from ncgrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -2085,7 +2305,7 @@ static void ncg_load_buffer_state (void) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ - void ncg_flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; @@ -2105,7 +2325,7 @@ static void ncg_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - ncg_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -2114,14 +2334,14 @@ static void ncg_load_buffer_state (void) * @param new_buffer The new state. * */ -void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; - ncgensure_buffer_stack(); + yyensure_buffer_stack(); - /* This block is copied from ncg_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -2135,8 +2355,8 @@ void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from ncg_switch_to_buffer. */ - ncg_load_buffer_state( ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -2144,18 +2364,18 @@ void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer ) * The next element becomes the new top. * */ -void ncgpop_buffer_state (void) +void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; - ncg_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - ncg_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -2163,7 +2383,7 @@ void ncgpop_buffer_state (void) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void ncgensure_buffer_stack (void) +static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; @@ -2173,15 +2393,15 @@ static void ncgensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ - (yy_buffer_stack) = (struct yy_buffer_state**)ncgalloc + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in ncgensure_buffer_stack()" ); - + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -2193,12 +2413,12 @@ static void ncgensure_buffer_stack (void) yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)ncgrealloc + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in ncgensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -2210,9 +2430,9 @@ static void ncgensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; @@ -2220,69 +2440,69 @@ YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) ncgalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - ncg_switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } -/** Setup the input buffer state to scan a string. The next call to ncglex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * ncg_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return ncg_scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } -/** Setup the input buffer state to scan the given bytes. The next call to ncglex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) ncgalloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in ncg_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = ncg_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in ncg_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -2296,9 +2516,9 @@ YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -2308,14 +2528,14 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up ncgtext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - ncgtext[ncgleng] = (yy_hold_char); \ - (yy_c_buf_p) = ncgtext + yyless_macro_arg; \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ - ncgleng = yyless_macro_arg; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) @@ -2324,126 +2544,126 @@ static void yy_fatal_error (yyconst char* msg ) /** Get the current line number. * */ -int ncgget_lineno (void) +int yyget_lineno (void) { - - return ncglineno; + + return yylineno; } /** Get the input stream. * */ -FILE *ncgget_in (void) +FILE *yyget_in (void) { - return ncgin; + return yyin; } /** Get the output stream. * */ -FILE *ncgget_out (void) +FILE *yyget_out (void) { - return ncgout; + return yyout; } /** Get the length of the current token. * */ -yy_size_t ncgget_leng (void) +int yyget_leng (void) { - return ncgleng; + return yyleng; } /** Get the current token. * */ -char *ncgget_text (void) +char *yyget_text (void) { - return ncgtext; + return yytext; } /** Set the current line number. * @param _line_number line number * */ -void ncgset_lineno (int _line_number ) +void yyset_lineno (int _line_number ) { - ncglineno = _line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param _in_str A readable stream. * - * @see ncg_switch_to_buffer + * @see yy_switch_to_buffer */ -void ncgset_in (FILE * _in_str ) +void yyset_in (FILE * _in_str ) { - ncgin = _in_str ; + yyin = _in_str ; } -void ncgset_out (FILE * _out_str ) +void yyset_out (FILE * _out_str ) { - ncgout = _out_str ; + yyout = _out_str ; } -int ncgget_debug (void) +int yyget_debug (void) { - return ncg_flex_debug; + return yy_flex_debug; } -void ncgset_debug (int _bdebug ) +void yyset_debug (int _bdebug ) { - ncg_flex_debug = _bdebug ; + yy_flex_debug = _bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. - * This function is called from ncglex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT - ncgin = stdin; - ncgout = stdout; + yyin = stdin; + yyout = stdout; #else - ncgin = (FILE *) 0; - ncgout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * ncglex_init() + * yylex_init() */ return 0; } -/* ncglex_destroy is for both reentrant and non-reentrant scanners. */ -int ncglex_destroy (void) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - ncg_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; - ncgpop_buffer_state(); + yypop_buffer_state(); } /* Destroy the stack itself. */ - ncgfree((yy_buffer_stack) ); + yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * ncglex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; @@ -2454,7 +2674,7 @@ int ncglex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { int i; @@ -2464,7 +2684,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { int n; for ( n = 0; s[n]; ++n ) @@ -2474,12 +2694,12 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *ncgalloc (yy_size_t size ) +void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } -void *ncgrealloc (void * ptr, yy_size_t size ) +void *yyrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both @@ -2489,18 +2709,17 @@ void *ncgrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void ncgfree (void * ptr ) +void yyfree (void * ptr ) { - free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 287 "ncgen.l" - +#line 287 "ncgen3/ncgen.l" /* Hack to keep compile quiet */ diff --git a/ncgen3/ncgeny.c b/ncgen3/ncgeny.c index 2e87109d08..1a6be938ee 100644 --- a/ncgen3/ncgeny.c +++ b/ncgen3/ncgeny.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -40,11 +45,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Identify Bison output. */ -#define YYBISON 1 +/* Identify Bison output, and Bison version. */ +#define YYBISON 30802 -/* Bison version. */ -#define YYBISON_VERSION "3.0.4" +/* Bison version string. */ +#define YYBISON_VERSION "3.8.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -65,12 +70,11 @@ #define yyerror ncgerror #define yydebug ncgdebug #define yynerrs ncgnerrs - #define yylval ncglval #define yychar ncgchar -/* Copy the first part of user declarations. */ -#line 9 "ncgen.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 9 "ncgen3/ncgen.y" #ifdef sccs static char SccsId[] = "$Id: ncgen.y,v 1.34 2010/03/31 18:18:41 dmh Exp $"; @@ -146,108 +150,198 @@ void yyerror(char*); int yyerror(char*); #endif -#line 150 "ncgeny.c" /* yacc.c:339 */ +#line 154 "ncgeny.c" +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "ncgeny.h". */ -#ifndef YY_NCG_NCGEN_TAB_H_INCLUDED -# define YY_NCG_NCGEN_TAB_H_INCLUDED -/* Debug traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif -#if YYDEBUG -extern int ncgdebug; -#endif - -/* Token type. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - enum yytokentype - { - NC_UNLIMITED_K = 258, - BYTE_K = 259, - CHAR_K = 260, - SHORT_K = 261, - INT_K = 262, - FLOAT_K = 263, - DOUBLE_K = 264, - IDENT = 265, - TERMSTRING = 266, - BYTE_CONST = 267, - CHAR_CONST = 268, - SHORT_CONST = 269, - INT_CONST = 270, - FLOAT_CONST = 271, - DOUBLE_CONST = 272, - DIMENSIONS = 273, - VARIABLES = 274, - NETCDF = 275, - DATA = 276, - FILLVALUE = 277 - }; -#endif +#include "ncgeny.h" +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL_NC_UNLIMITED_K = 3, /* NC_UNLIMITED_K */ + YYSYMBOL_BYTE_K = 4, /* BYTE_K */ + YYSYMBOL_CHAR_K = 5, /* CHAR_K */ + YYSYMBOL_SHORT_K = 6, /* SHORT_K */ + YYSYMBOL_INT_K = 7, /* INT_K */ + YYSYMBOL_FLOAT_K = 8, /* FLOAT_K */ + YYSYMBOL_DOUBLE_K = 9, /* DOUBLE_K */ + YYSYMBOL_IDENT = 10, /* IDENT */ + YYSYMBOL_TERMSTRING = 11, /* TERMSTRING */ + YYSYMBOL_BYTE_CONST = 12, /* BYTE_CONST */ + YYSYMBOL_CHAR_CONST = 13, /* CHAR_CONST */ + YYSYMBOL_SHORT_CONST = 14, /* SHORT_CONST */ + YYSYMBOL_INT_CONST = 15, /* INT_CONST */ + YYSYMBOL_FLOAT_CONST = 16, /* FLOAT_CONST */ + YYSYMBOL_DOUBLE_CONST = 17, /* DOUBLE_CONST */ + YYSYMBOL_DIMENSIONS = 18, /* DIMENSIONS */ + YYSYMBOL_VARIABLES = 19, /* VARIABLES */ + YYSYMBOL_NETCDF = 20, /* NETCDF */ + YYSYMBOL_DATA = 21, /* DATA */ + YYSYMBOL_FILLVALUE = 22, /* FILLVALUE */ + YYSYMBOL_23_ = 23, /* '{' */ + YYSYMBOL_24_ = 24, /* '}' */ + YYSYMBOL_25_ = 25, /* ';' */ + YYSYMBOL_26_ = 26, /* ',' */ + YYSYMBOL_27_ = 27, /* '=' */ + YYSYMBOL_28_ = 28, /* '(' */ + YYSYMBOL_29_ = 29, /* ')' */ + YYSYMBOL_30_ = 30, /* ':' */ + YYSYMBOL_YYACCEPT = 31, /* $accept */ + YYSYMBOL_ncdesc = 32, /* ncdesc */ + YYSYMBOL_33_1 = 33, /* $@1 */ + YYSYMBOL_34_2 = 34, /* $@2 */ + YYSYMBOL_dimsection = 35, /* dimsection */ + YYSYMBOL_dimdecls = 36, /* dimdecls */ + YYSYMBOL_dimdecline = 37, /* dimdecline */ + YYSYMBOL_dimdecl = 38, /* dimdecl */ + YYSYMBOL_dimd = 39, /* dimd */ + YYSYMBOL_dim = 40, /* dim */ + YYSYMBOL_vasection = 41, /* vasection */ + YYSYMBOL_vadecls = 42, /* vadecls */ + YYSYMBOL_vadecl = 43, /* vadecl */ + YYSYMBOL_gattdecls = 44, /* gattdecls */ + YYSYMBOL_vardecl = 45, /* vardecl */ + YYSYMBOL_type = 46, /* type */ + YYSYMBOL_varlist = 47, /* varlist */ + YYSYMBOL_varspec = 48, /* varspec */ + YYSYMBOL_49_3 = 49, /* $@3 */ + YYSYMBOL_var = 50, /* var */ + YYSYMBOL_dimspec = 51, /* dimspec */ + YYSYMBOL_dimlist = 52, /* dimlist */ + YYSYMBOL_vdim = 53, /* vdim */ + YYSYMBOL_attdecl = 54, /* attdecl */ + YYSYMBOL_55_4 = 55, /* $@4 */ + YYSYMBOL_gattdecl = 56, /* gattdecl */ + YYSYMBOL_57_5 = 57, /* $@5 */ + YYSYMBOL_att = 58, /* att */ + YYSYMBOL_gatt = 59, /* gatt */ + YYSYMBOL_avar = 60, /* avar */ + YYSYMBOL_attr = 61, /* attr */ + YYSYMBOL_attvallist = 62, /* attvallist */ + YYSYMBOL_aconst = 63, /* aconst */ + YYSYMBOL_attconst = 64, /* attconst */ + YYSYMBOL_datasection = 65, /* datasection */ + YYSYMBOL_datadecls = 66, /* datadecls */ + YYSYMBOL_datadecl = 67, /* datadecl */ + YYSYMBOL_68_6 = 68, /* $@6 */ + YYSYMBOL_constlist = 69, /* constlist */ + YYSYMBOL_dconst = 70, /* dconst */ + YYSYMBOL_71_7 = 71, /* $@7 */ + YYSYMBOL_const = 72 /* const */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; -/* Value type. */ -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define YYSTYPE_IS_DECLARED 1 -#endif -extern YYSTYPE ncglval; -int ncgparse (void); +#ifdef short +# undef short +#endif -#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */ +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ -/* Copy the second part of user declarations. */ +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif +#endif -#line 224 "ncgeny.c" /* yacc.c:358 */ +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ -#ifdef short -# undef short +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; +#else +typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; #else -typedef unsigned char yytype_uint8; +typedef short yytype_int16; #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#else -typedef signed char yytype_int8; +/* Work around bug in HP-UX 11.23, which defines these macros + incorrectly for preprocessor constants. This workaround can likely + be removed in 2023, as HPE has promised support for HP-UX 11.23 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of + . */ +#ifdef __hpux +# undef UINT_LEAST8_MAX +# undef UINT_LEAST16_MAX +# define UINT_LEAST8_MAX 255 +# define UINT_LEAST16_MAX 65535 #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; #else -typedef short int yytype_int16; +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -255,15 +349,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_int8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -277,47 +384,43 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif #ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif #endif #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(E) ((void) (E)) +# define YY_USE(E) ((void) (E)) #else -# define YYUSE(E) /* empty */ +# define YY_USE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ +# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") +# else +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# endif +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -330,8 +433,22 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) -#if ! defined yyoverflow || YYERROR_VERBOSE +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -396,8 +513,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -406,17 +522,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -429,11 +545,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -445,12 +561,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -473,17 +589,20 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 112 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 +/* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 277 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -516,8 +635,8 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_int16 yyrline[] = { 0, 117, 117, 120, 115, 133, 134, 136, 137, 139, 140, 142, 148, 159, 167, 184, 186, 187, 188, 190, @@ -530,49 +649,51 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "NC_UNLIMITED_K", "BYTE_K", "CHAR_K", - "SHORT_K", "INT_K", "FLOAT_K", "DOUBLE_K", "IDENT", "TERMSTRING", - "BYTE_CONST", "CHAR_CONST", "SHORT_CONST", "INT_CONST", "FLOAT_CONST", - "DOUBLE_CONST", "DIMENSIONS", "VARIABLES", "NETCDF", "DATA", "FILLVALUE", - "'{'", "'}'", "';'", "','", "'='", "'('", "')'", "':'", "$accept", - "ncdesc", "$@1", "$@2", "dimsection", "dimdecls", "dimdecline", - "dimdecl", "dimd", "dim", "vasection", "vadecls", "vadecl", "gattdecls", - "vardecl", "type", "varlist", "varspec", "$@3", "var", "dimspec", - "dimlist", "vdim", "attdecl", "$@4", "gattdecl", "$@5", "att", "gatt", - "avar", "attr", "attvallist", "aconst", "attconst", "datasection", - "datadecls", "datadecl", "$@6", "constlist", "dconst", "$@7", "const", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", "NC_UNLIMITED_K", + "BYTE_K", "CHAR_K", "SHORT_K", "INT_K", "FLOAT_K", "DOUBLE_K", "IDENT", + "TERMSTRING", "BYTE_CONST", "CHAR_CONST", "SHORT_CONST", "INT_CONST", + "FLOAT_CONST", "DOUBLE_CONST", "DIMENSIONS", "VARIABLES", "NETCDF", + "DATA", "FILLVALUE", "'{'", "'}'", "';'", "','", "'='", "'('", "')'", + "':'", "$accept", "ncdesc", "$@1", "$@2", "dimsection", "dimdecls", + "dimdecline", "dimdecl", "dimd", "dim", "vasection", "vadecls", "vadecl", + "gattdecls", "vardecl", "type", "varlist", "varspec", "$@3", "var", + "dimspec", "dimlist", "vdim", "attdecl", "$@4", "gattdecl", "$@5", "att", + "gatt", "avar", "attr", "attvallist", "aconst", "attconst", + "datasection", "datadecls", "datadecl", "$@6", "constlist", "dconst", + "$@7", "const", YY_NULLPTR }; -#endif -# ifdef YYPRINT -/* YYTOKNUM[NUM] -- (External) token number corresponding to the - (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) { - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 123, 125, 59, 44, 61, 40, 41, - 58 -}; -# endif + return yytname[yysymbol]; +} +#endif -#define YYPACT_NINF -73 +#define YYPACT_NINF (-73) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-73))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF (-1) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int8 yypact[] = { 10, 3, 31, -73, -73, 19, 36, 6, -73, 36, @@ -589,10 +710,10 @@ static const yytype_int8 yypact[] = -73, -73 }; - /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = +/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_int8 yydefact[] = { 0, 0, 0, 2, 1, 5, 0, 16, 15, 6, 0, 9, 0, 14, 0, 0, 3, 18, 0, 45, @@ -608,7 +729,7 @@ static const yytype_uint8 yydefact[] = 71, 69 }; - /* YYPGOTO[NTERM-NUM]. */ +/* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -73, -73, -73, -73, -73, -73, 49, 44, -73, -72, @@ -618,20 +739,20 @@ static const yytype_int8 yypgoto[] = -73, -73 }; - /* YYDEFGOTO[NTERM-NUM]. */ +/* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 2, 5, 42, 7, 9, 10, 11, 12, 13, + 0, 2, 5, 42, 7, 9, 10, 11, 12, 13, 16, 31, 32, 17, 33, 34, 53, 54, 64, 35, 83, 90, 91, 36, 56, 37, 45, 38, 19, 39, 41, 78, 79, 80, 59, 68, 69, 85, 97, 98, 99, 110 }; - /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint8 yytable[] = +/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = { 55, 24, 25, 26, 27, 28, 29, 30, 48, 95, 89, 18, 96, 102, 103, 104, 105, 106, 107, 108, @@ -655,9 +776,9 @@ static const yytype_int8 yycheck[] = 25, 57, 26, 88, 101, -1, 68, -1, 31 }; - /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of + state STATE-NUM. */ +static const yytype_int8 yystos[] = { 0, 20, 32, 23, 0, 33, 18, 35, 10, 36, 37, 38, 39, 40, 19, 30, 41, 44, 56, 59, @@ -673,8 +794,8 @@ static const yytype_uint8 yystos[] = 72, 70 }; - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr1[] = { 0, 31, 33, 34, 32, 35, 35, 36, 36, 37, 37, 38, 38, 38, 39, 40, 41, 41, 41, 42, @@ -686,8 +807,8 @@ static const yytype_uint8 yyr1[] = 71, 70, 72, 72, 72, 72, 72, 72, 72, 72 }; - /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ +static const yytype_int8 yyr2[] = { 0, 2, 0, 0, 8, 0, 2, 2, 3, 1, 3, 3, 3, 3, 1, 1, 0, 2, 1, 2, @@ -700,39 +821,39 @@ static const yytype_uint8 yyr2[] = }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab +#define YYNOMEM goto yyexhaustedlab #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -749,55 +870,52 @@ do { \ YYFPRINTF Args; \ } while (0) -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ + +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value); \ + Kind, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YY_USE (yyoutput); if (!yyvaluep) return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YY_USE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -806,7 +924,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -829,21 +947,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)]); YYFPRINTF (stderr, "\n"); } } @@ -858,8 +976,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -882,249 +1000,30 @@ int yydebug; #endif -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - /* Avoid snprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { - YYUSE (yyvaluep); + YY_USE (yyvaluep); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YYUSE (yytype); + YY_USE (yykind); YY_IGNORE_MAYBE_UNINITIALIZED_END } - - -/* The lookahead symbol. */ +/* Lookahead token kind. */ int yychar; /* The semantic value of the lookahead symbol. */ @@ -1133,6 +1032,8 @@ YYSTYPE yylval; int yynerrs; + + /*----------. | yyparse. | `----------*/ @@ -1140,43 +1041,36 @@ int yynerrs; int yyparse (void) { - int yystate; + yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yyerrstatus = 0; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow + /* Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + /* Their size. */ + YYPTRDIFF_T yystacksize = YYINITDEPTH; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; + /* The state stack: array, bottom, top. */ + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss = yyssa; + yy_state_t *yyssp = yyss; - YYSIZE_T yystacksize; + /* The semantic value stack: array, bottom, top. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp = yyvs; int yyn; + /* The return value of yyparse. */ int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead symbol kind. */ + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1184,71 +1078,75 @@ yyparse (void) Keep to zero when no symbol should be popped. */ int yylen = 0; - yyssp = yyss = yyssa; - yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + YYNOMEM; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + YYNOMEM; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) - goto yyexhaustedlab; + YYNOMEM; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE @@ -1256,30 +1154,31 @@ yyparse (void) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1290,18 +1189,29 @@ yyparse (void) /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (); } if (yychar <= YYEOF) { - yychar = yytoken = YYEOF; + yychar = YYEOF; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1329,15 +1239,13 @@ yyparse (void) /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1352,7 +1260,7 @@ yyparse (void) /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1372,45 +1280,45 @@ yyparse (void) YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 117 "ncgen.y" /* yacc.c:1646 */ - { init_netcdf(); } -#line 1379 "ncgeny.c" /* yacc.c:1646 */ + case 2: /* $@1: %empty */ +#line 117 "ncgen3/ncgen.y" + { init_netcdf(); } +#line 1287 "ncgeny.c" break; - case 3: -#line 120 "ncgen.y" /* yacc.c:1646 */ - { + case 3: /* $@2: %empty */ +#line 120 "ncgen3/ncgen.y" + { if (derror_count == 0) define_netcdf(netcdfname); if (derror_count > 0) exit(6); } -#line 1390 "ncgeny.c" /* yacc.c:1646 */ +#line 1298 "ncgeny.c" break; - case 4: -#line 128 "ncgen.y" /* yacc.c:1646 */ - { + case 4: /* ncdesc: NETCDF '{' $@1 dimsection vasection $@2 datasection '}' */ +#line 128 "ncgen3/ncgen.y" + { if (derror_count == 0) close_netcdf(); } -#line 1399 "ncgeny.c" /* yacc.c:1646 */ +#line 1307 "ncgeny.c" break; - case 11: -#line 143 "ncgen.y" /* yacc.c:1646 */ - { if (int_val <= 0) + case 11: /* dimdecl: dimd '=' INT_CONST */ +#line 143 "ncgen3/ncgen.y" + { if (int_val <= 0) derror("dimension length must be positive"); dims[ndims].size = int_val; ndims++; } -#line 1409 "ncgeny.c" /* yacc.c:1646 */ +#line 1317 "ncgeny.c" break; - case 12: -#line 149 "ncgen.y" /* yacc.c:1646 */ - { /* for rare case where 2^31 < dimsize < 2^32 */ + case 12: /* dimdecl: dimd '=' DOUBLE_CONST */ +#line 149 "ncgen3/ncgen.y" + { /* for rare case where 2^31 < dimsize < 2^32 */ if (double_val <= 0) derror("dimension length must be positive"); if (double_val > 4294967295.0) @@ -1420,79 +1328,79 @@ yyparse (void) dims[ndims].size = (size_t) double_val; ndims++; } -#line 1424 "ncgeny.c" /* yacc.c:1646 */ +#line 1332 "ncgeny.c" break; - case 13: -#line 160 "ncgen.y" /* yacc.c:1646 */ - { if (rec_dim != -1) + case 13: /* dimdecl: dimd '=' NC_UNLIMITED_K */ +#line 160 "ncgen3/ncgen.y" + { if (rec_dim != -1) derror("only one NC_UNLIMITED dimension allowed"); rec_dim = ndims; /* the unlimited (record) dimension */ dims[ndims].size = NC_UNLIMITED; ndims++; } -#line 1435 "ncgeny.c" /* yacc.c:1646 */ +#line 1343 "ncgeny.c" break; - case 14: -#line 168 "ncgen.y" /* yacc.c:1646 */ - { - if ((yyvsp[0])->is_dim == 1) { + case 14: /* dimd: dim */ +#line 168 "ncgen3/ncgen.y" + { + if (yyvsp[0]->is_dim == 1) { derror( "duplicate dimension declaration for %s", - (yyvsp[0])->name); + yyvsp[0]->name); } - (yyvsp[0])->is_dim = 1; - (yyvsp[0])->dnum = ndims; + yyvsp[0]->is_dim = 1; + yyvsp[0]->dnum = ndims; /* make sure dims array will hold dimensions */ grow_darray(ndims, /* must hold ndims+1 dims */ &dims); /* grow as needed */ - dims[ndims].name = (char *) emalloc(strlen((yyvsp[0])->name)+1); - (void) strcpy(dims[ndims].name, (yyvsp[0])->name); + dims[ndims].name = (char *) emalloc(strlen(yyvsp[0]->name)+1); + (void) strcpy(dims[ndims].name, yyvsp[0]->name); /* name for use in generated Fortran and C variables */ - dims[ndims].lname = decodify((yyvsp[0])->name); + dims[ndims].lname = decodify(yyvsp[0]->name); } -#line 1455 "ncgeny.c" /* yacc.c:1646 */ +#line 1363 "ncgeny.c" break; - case 27: -#line 200 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_BYTE; } -#line 1461 "ncgeny.c" /* yacc.c:1646 */ + case 27: /* type: BYTE_K */ +#line 200 "ncgen3/ncgen.y" + { type_code = NC_BYTE; } +#line 1369 "ncgeny.c" break; - case 28: -#line 201 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_CHAR; } -#line 1467 "ncgeny.c" /* yacc.c:1646 */ + case 28: /* type: CHAR_K */ +#line 201 "ncgen3/ncgen.y" + { type_code = NC_CHAR; } +#line 1375 "ncgeny.c" break; - case 29: -#line 202 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_SHORT; } -#line 1473 "ncgeny.c" /* yacc.c:1646 */ + case 29: /* type: SHORT_K */ +#line 202 "ncgen3/ncgen.y" + { type_code = NC_SHORT; } +#line 1381 "ncgeny.c" break; - case 30: -#line 203 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_INT; } -#line 1479 "ncgeny.c" /* yacc.c:1646 */ + case 30: /* type: INT_K */ +#line 203 "ncgen3/ncgen.y" + { type_code = NC_INT; } +#line 1387 "ncgeny.c" break; - case 31: -#line 204 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_FLOAT; } -#line 1485 "ncgeny.c" /* yacc.c:1646 */ + case 31: /* type: FLOAT_K */ +#line 204 "ncgen3/ncgen.y" + { type_code = NC_FLOAT; } +#line 1393 "ncgeny.c" break; - case 32: -#line 205 "ncgen.y" /* yacc.c:1646 */ - { type_code = NC_DOUBLE; } -#line 1491 "ncgeny.c" /* yacc.c:1646 */ + case 32: /* type: DOUBLE_K */ +#line 205 "ncgen3/ncgen.y" + { type_code = NC_DOUBLE; } +#line 1399 "ncgeny.c" break; - case 35: -#line 211 "ncgen.y" /* yacc.c:1646 */ - { + case 35: /* $@3: %empty */ +#line 211 "ncgen3/ncgen.y" + { static struct vars dummyvar; dummyvar.name = "dummy"; @@ -1504,49 +1412,49 @@ yyparse (void) nvdims = 0; /* make sure variable not re-declared */ - if ((yyvsp[0])->is_var == 1) { + if (yyvsp[0]->is_var == 1) { derror( "duplicate variable declaration for %s", - (yyvsp[0])->name); + yyvsp[0]->name); } - (yyvsp[0])->is_var = 1; - (yyvsp[0])->vnum = nvars; + yyvsp[0]->is_var = 1; + yyvsp[0]->vnum = nvars; /* make sure vars array will hold variables */ grow_varray(nvars, /* must hold nvars+1 vars */ &vars); /* grow as needed */ vars[nvars] = dummyvar; /* to make Purify happy */ - vars[nvars].name = (char *) emalloc(strlen((yyvsp[0])->name)+1); - (void) strcpy(vars[nvars].name, (yyvsp[0])->name); + vars[nvars].name = (char *) emalloc(strlen(yyvsp[0]->name)+1); + (void) strcpy(vars[nvars].name, yyvsp[0]->name); /* name for use in generated Fortran and C variables */ - vars[nvars].lname = decodify((yyvsp[0])->name); + vars[nvars].lname = decodify(yyvsp[0]->name); vars[nvars].type = type_code; /* set default fill value. You can override this with * the variable attribute "_FillValue". */ nc_getfill(type_code, &vars[nvars].fill_value); vars[nvars].has_data = 0; /* has no data (yet) */ } -#line 1528 "ncgeny.c" /* yacc.c:1646 */ +#line 1436 "ncgeny.c" break; - case 36: -#line 244 "ncgen.y" /* yacc.c:1646 */ - { + case 36: /* varspec: var $@3 dimspec */ +#line 244 "ncgen3/ncgen.y" + { vars[nvars].ndims = nvdims; nvars++; } -#line 1537 "ncgeny.c" /* yacc.c:1646 */ +#line 1445 "ncgeny.c" break; - case 42: -#line 258 "ncgen.y" /* yacc.c:1646 */ - { + case 42: /* vdim: dim */ +#line 258 "ncgen3/ncgen.y" + { if (nvdims >= NC_MAX_VAR_DIMS) { derror("%s has too many dimensions",vars[nvars].name); } - if ((yyvsp[0])->is_dim == 1) - dimnum = (yyvsp[0])->dnum; + if (yyvsp[0]->is_dim == 1) + dimnum = yyvsp[0]->dnum; else { derror( "%s is not declared as a dimension", - (yyvsp[0])->name); + yyvsp[0]->name); dimnum = ndims; } if (rec_dim != -1 && dimnum == rec_dim && nvdims != 0) { @@ -1557,100 +1465,100 @@ yyparse (void) vars[nvars].dims[nvdims] = dimnum; nvdims++; } -#line 1561 "ncgeny.c" /* yacc.c:1646 */ +#line 1469 "ncgeny.c" break; - case 43: -#line 279 "ncgen.y" /* yacc.c:1646 */ - { + case 43: /* $@4: %empty */ +#line 279 "ncgen3/ncgen.y" + { defatt(); } -#line 1569 "ncgeny.c" /* yacc.c:1646 */ +#line 1477 "ncgeny.c" break; - case 44: -#line 283 "ncgen.y" /* yacc.c:1646 */ - { + case 44: /* attdecl: att $@4 '=' attvallist */ +#line 283 "ncgen3/ncgen.y" + { equalatt(); } -#line 1577 "ncgeny.c" /* yacc.c:1646 */ +#line 1485 "ncgeny.c" break; - case 45: -#line 288 "ncgen.y" /* yacc.c:1646 */ - { + case 45: /* $@5: %empty */ +#line 288 "ncgen3/ncgen.y" + { defatt(); } -#line 1585 "ncgeny.c" /* yacc.c:1646 */ +#line 1493 "ncgeny.c" break; - case 46: -#line 292 "ncgen.y" /* yacc.c:1646 */ - { + case 46: /* gattdecl: gatt $@5 '=' attvallist */ +#line 292 "ncgen3/ncgen.y" + { equalatt(); } -#line 1593 "ncgeny.c" /* yacc.c:1646 */ +#line 1501 "ncgeny.c" break; - case 48: -#line 300 "ncgen.y" /* yacc.c:1646 */ - { + case 48: /* gatt: ':' attr */ +#line 300 "ncgen3/ncgen.y" + { varnum = NC_GLOBAL; /* handle of "global" attribute */ } -#line 1601 "ncgeny.c" /* yacc.c:1646 */ +#line 1509 "ncgeny.c" break; - case 49: -#line 306 "ncgen.y" /* yacc.c:1646 */ - { if ((yyvsp[0])->is_var == 1) - varnum = (yyvsp[0])->vnum; + case 49: /* avar: var */ +#line 306 "ncgen3/ncgen.y" + { if (yyvsp[0]->is_var == 1) + varnum = yyvsp[0]->vnum; else { derror("%s not declared as a variable, fatal error", - (yyvsp[0])->name); + yyvsp[0]->name); YYABORT; } } -#line 1614 "ncgeny.c" /* yacc.c:1646 */ +#line 1522 "ncgeny.c" break; - case 50: -#line 316 "ncgen.y" /* yacc.c:1646 */ - { + case 50: /* attr: IDENT */ +#line 316 "ncgen3/ncgen.y" + { /* make sure atts array will hold attributes */ grow_aarray(natts, /* must hold natts+1 atts */ &atts); /* grow as needed */ - atts[natts].name = (char *) emalloc(strlen((yyvsp[0])->name)+1); - (void) strcpy(atts[natts].name,(yyvsp[0])->name); + atts[natts].name = (char *) emalloc(strlen(yyvsp[0]->name)+1); + (void) strcpy(atts[natts].name,yyvsp[0]->name); /* name for use in generated Fortran and C variables */ - atts[natts].lname = decodify((yyvsp[0])->name); + atts[natts].lname = decodify(yyvsp[0]->name); } -#line 1628 "ncgeny.c" /* yacc.c:1646 */ +#line 1536 "ncgeny.c" break; - case 53: -#line 330 "ncgen.y" /* yacc.c:1646 */ - { + case 53: /* aconst: attconst */ +#line 330 "ncgen3/ncgen.y" + { if (valtype == NC_UNSPECIFIED) valtype = atype_code; if (valtype != atype_code) derror("values for attribute must be all of same type"); } -#line 1639 "ncgeny.c" /* yacc.c:1646 */ +#line 1547 "ncgeny.c" break; - case 54: -#line 339 "ncgen.y" /* yacc.c:1646 */ - { + case 54: /* attconst: CHAR_CONST */ +#line 339 "ncgen3/ncgen.y" + { atype_code = NC_CHAR; *char_valp++ = char_val; valnum++; } -#line 1649 "ncgeny.c" /* yacc.c:1646 */ +#line 1557 "ncgeny.c" break; - case 55: -#line 345 "ncgen.y" /* yacc.c:1646 */ - { + case 55: /* attconst: TERMSTRING */ +#line 345 "ncgen3/ncgen.y" + { atype_code = NC_CHAR; { /* don't null-terminate attribute strings */ @@ -1662,62 +1570,62 @@ yyparse (void) char_valp += len; } } -#line 1666 "ncgeny.c" /* yacc.c:1646 */ +#line 1574 "ncgeny.c" break; - case 56: -#line 358 "ncgen.y" /* yacc.c:1646 */ - { + case 56: /* attconst: BYTE_CONST */ +#line 358 "ncgen3/ncgen.y" + { atype_code = NC_BYTE; *byte_valp++ = byte_val; valnum++; } -#line 1676 "ncgeny.c" /* yacc.c:1646 */ +#line 1584 "ncgeny.c" break; - case 57: -#line 364 "ncgen.y" /* yacc.c:1646 */ - { + case 57: /* attconst: SHORT_CONST */ +#line 364 "ncgen3/ncgen.y" + { atype_code = NC_SHORT; *short_valp++ = short_val; valnum++; } -#line 1686 "ncgeny.c" /* yacc.c:1646 */ +#line 1594 "ncgeny.c" break; - case 58: -#line 370 "ncgen.y" /* yacc.c:1646 */ - { + case 58: /* attconst: INT_CONST */ +#line 370 "ncgen3/ncgen.y" + { atype_code = NC_INT; *int_valp++ = int_val; valnum++; } -#line 1696 "ncgeny.c" /* yacc.c:1646 */ +#line 1604 "ncgeny.c" break; - case 59: -#line 376 "ncgen.y" /* yacc.c:1646 */ - { + case 59: /* attconst: FLOAT_CONST */ +#line 376 "ncgen3/ncgen.y" + { atype_code = NC_FLOAT; *float_valp++ = float_val; valnum++; } -#line 1706 "ncgeny.c" /* yacc.c:1646 */ +#line 1614 "ncgeny.c" break; - case 60: -#line 382 "ncgen.y" /* yacc.c:1646 */ - { + case 60: /* attconst: DOUBLE_CONST */ +#line 382 "ncgen3/ncgen.y" + { atype_code = NC_DOUBLE; *double_valp++ = double_val; valnum++; } -#line 1716 "ncgeny.c" /* yacc.c:1646 */ +#line 1624 "ncgeny.c" break; - case 66: -#line 398 "ncgen.y" /* yacc.c:1646 */ - { + case 66: /* $@6: %empty */ +#line 398 "ncgen3/ncgen.y" + { valtype = vars[varnum].type; /* variable type */ valnum = 0; /* values accumulated for variable */ vars[varnum].has_data = 1; @@ -1767,12 +1675,12 @@ yyparse (void) default: break; } } -#line 1771 "ncgeny.c" /* yacc.c:1646 */ +#line 1679 "ncgeny.c" break; - case 67: -#line 449 "ncgen.y" /* yacc.c:1646 */ - { + case 67: /* datadecl: avar $@6 '=' constlist */ +#line 449 "ncgen3/ncgen.y" + { if (valnum < var_len) { /* leftovers */ nc_fill(valtype, var_len - valnum, @@ -1786,12 +1694,12 @@ yyparse (void) put_variable(rec_start); free ((char *) rec_start); } -#line 1790 "ncgeny.c" /* yacc.c:1646 */ +#line 1698 "ncgeny.c" break; - case 70: -#line 468 "ncgen.y" /* yacc.c:1646 */ - { + case 70: /* $@7: %empty */ +#line 468 "ncgen3/ncgen.y" + { if(valnum >= var_len) { if (vars[varnum].dims[0] != rec_dim) { /* not recvar */ derror("too many values for this variable, %d >= %d", @@ -1815,12 +1723,12 @@ yyparse (void) } not_a_string = 1; } -#line 1819 "ncgeny.c" /* yacc.c:1646 */ +#line 1727 "ncgeny.c" break; - case 71: -#line 493 "ncgen.y" /* yacc.c:1646 */ - { + case 71: /* dconst: $@7 const */ +#line 493 "ncgen3/ncgen.y" + { if (not_a_string) { switch (valtype) { case NC_CHAR: @@ -1845,12 +1753,12 @@ yyparse (void) } } } -#line 1849 "ncgeny.c" /* yacc.c:1646 */ +#line 1757 "ncgeny.c" break; - case 72: -#line 521 "ncgen.y" /* yacc.c:1646 */ - { + case 72: /* const: CHAR_CONST */ +#line 521 "ncgen3/ncgen.y" + { atype_code = NC_CHAR; switch (valtype) { case NC_CHAR: @@ -1875,12 +1783,12 @@ yyparse (void) } valnum++; } -#line 1879 "ncgeny.c" /* yacc.c:1646 */ +#line 1787 "ncgeny.c" break; - case 73: -#line 547 "ncgen.y" /* yacc.c:1646 */ - { + case 73: /* const: TERMSTRING */ +#line 547 "ncgen3/ncgen.y" + { not_a_string = 0; atype_code = NC_CHAR; { @@ -1934,12 +1842,12 @@ yyparse (void) } } } -#line 1938 "ncgeny.c" /* yacc.c:1646 */ +#line 1846 "ncgeny.c" break; - case 74: -#line 602 "ncgen.y" /* yacc.c:1646 */ - { + case 74: /* const: BYTE_CONST */ +#line 602 "ncgen3/ncgen.y" + { atype_code = NC_BYTE; switch (valtype) { case NC_CHAR: @@ -1964,12 +1872,12 @@ yyparse (void) } valnum++; } -#line 1968 "ncgeny.c" /* yacc.c:1646 */ +#line 1876 "ncgeny.c" break; - case 75: -#line 628 "ncgen.y" /* yacc.c:1646 */ - { + case 75: /* const: SHORT_CONST */ +#line 628 "ncgen3/ncgen.y" + { atype_code = NC_SHORT; switch (valtype) { case NC_CHAR: @@ -1994,12 +1902,12 @@ yyparse (void) } valnum++; } -#line 1998 "ncgeny.c" /* yacc.c:1646 */ +#line 1906 "ncgeny.c" break; - case 76: -#line 654 "ncgen.y" /* yacc.c:1646 */ - { + case 76: /* const: INT_CONST */ +#line 654 "ncgen3/ncgen.y" + { atype_code = NC_INT; switch (valtype) { case NC_CHAR: @@ -2024,12 +1932,12 @@ yyparse (void) } valnum++; } -#line 2028 "ncgeny.c" /* yacc.c:1646 */ +#line 1936 "ncgeny.c" break; - case 77: -#line 680 "ncgen.y" /* yacc.c:1646 */ - { + case 77: /* const: FLOAT_CONST */ +#line 680 "ncgen3/ncgen.y" + { atype_code = NC_FLOAT; switch (valtype) { case NC_CHAR: @@ -2054,12 +1962,12 @@ yyparse (void) } valnum++; } -#line 2058 "ncgeny.c" /* yacc.c:1646 */ +#line 1966 "ncgeny.c" break; - case 78: -#line 706 "ncgen.y" /* yacc.c:1646 */ - { + case 78: /* const: DOUBLE_CONST */ +#line 706 "ncgen3/ncgen.y" + { atype_code = NC_DOUBLE; switch (valtype) { case NC_CHAR: @@ -2087,12 +1995,12 @@ yyparse (void) } valnum++; } -#line 2091 "ncgeny.c" /* yacc.c:1646 */ +#line 1999 "ncgeny.c" break; - case 79: -#line 735 "ncgen.y" /* yacc.c:1646 */ - { + case 79: /* const: FILLVALUE */ +#line 735 "ncgen3/ncgen.y" + { /* store fill_value */ switch (valtype) { case NC_CHAR: @@ -2123,11 +2031,12 @@ yyparse (void) } valnum++; } -#line 2127 "ncgeny.c" /* yacc.c:1646 */ +#line 2035 "ncgeny.c" break; -#line 2131 "ncgeny.c" /* yacc.c:1646 */ +#line 2039 "ncgeny.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2141,25 +2050,23 @@ yyparse (void) case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -2170,50 +2077,14 @@ yyparse (void) yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an @@ -2242,12 +2113,11 @@ yyparse (void) | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; + ++yynerrs; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2264,13 +2134,14 @@ yyparse (void) yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -2284,7 +2155,7 @@ yyparse (void) yydestruct ("Error: popping", - yystos[yystate], yyvsp); + YY_ACCESSING_SYMBOL (yystate), yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2296,7 +2167,7 @@ yyparse (void) /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -2307,26 +2178,30 @@ yyparse (void) `-------------------------------------*/ yyacceptlab: yyresult = 0; - goto yyreturn; + goto yyreturnlab; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; - goto yyreturn; + goto yyreturnlab; + -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ +/*-----------------------------------------------------------. +| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | +`-----------------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; - /* Fall through. */ -#endif + goto yyreturnlab; + -yyreturn: +/*----------------------------------------------------------. +| yyreturnlab -- parsing is finished, clean up and return. | +`----------------------------------------------------------*/ +yyreturnlab: if (yychar != YYEMPTY) { /* Make sure we have latest lookahead translation. See comments at @@ -2342,20 +2217,18 @@ yyparse (void) while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 770 "ncgen.y" /* yacc.c:1906 */ + +#line 770 "ncgen3/ncgen.y" /* HELPER PROGRAMS */ diff --git a/ncgen3/ncgeny.h b/ncgen3/ncgeny.h index b35939ff5a..3665e03a19 100644 --- a/ncgen3/ncgeny.h +++ b/ncgen3/ncgeny.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.8.2. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see . */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -30,6 +31,10 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + #ifndef YY_NCG_NCGEN_TAB_H_INCLUDED # define YY_NCG_NCGEN_TAB_H_INCLUDED /* Debug traces. */ @@ -40,32 +45,37 @@ extern int ncgdebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - NC_UNLIMITED_K = 258, - BYTE_K = 259, - CHAR_K = 260, - SHORT_K = 261, - INT_K = 262, - FLOAT_K = 263, - DOUBLE_K = 264, - IDENT = 265, - TERMSTRING = 266, - BYTE_CONST = 267, - CHAR_CONST = 268, - SHORT_CONST = 269, - INT_CONST = 270, - FLOAT_CONST = 271, - DOUBLE_CONST = 272, - DIMENSIONS = 273, - VARIABLES = 274, - NETCDF = 275, - DATA = 276, - FILLVALUE = 277 + YYEMPTY = -2, + YYEOF = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + NC_UNLIMITED_K = 258, /* NC_UNLIMITED_K */ + BYTE_K = 259, /* BYTE_K */ + CHAR_K = 260, /* CHAR_K */ + SHORT_K = 261, /* SHORT_K */ + INT_K = 262, /* INT_K */ + FLOAT_K = 263, /* FLOAT_K */ + DOUBLE_K = 264, /* DOUBLE_K */ + IDENT = 265, /* IDENT */ + TERMSTRING = 266, /* TERMSTRING */ + BYTE_CONST = 267, /* BYTE_CONST */ + CHAR_CONST = 268, /* CHAR_CONST */ + SHORT_CONST = 269, /* SHORT_CONST */ + INT_CONST = 270, /* INT_CONST */ + FLOAT_CONST = 271, /* FLOAT_CONST */ + DOUBLE_CONST = 272, /* DOUBLE_CONST */ + DIMENSIONS = 273, /* DIMENSIONS */ + VARIABLES = 274, /* VARIABLES */ + NETCDF = 275, /* NETCDF */ + DATA = 276, /* DATA */ + FILLVALUE = 277 /* FILLVALUE */ }; + typedef enum yytokentype yytoken_kind_t; #endif /* Value type. */ @@ -78,6 +88,8 @@ typedef int YYSTYPE; extern YYSTYPE ncglval; + int ncgparse (void); + #endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */ From 317d2bfd08302cfb2cfe5deeb05428b7e4673b59 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 15:42:34 +0000 Subject: [PATCH 34/48] Fix some conversion warnings in ncgen3 generated files --- ncgen3/ncgen.l | 6 +++--- ncgen3/ncgen.y | 32 ++++++++++++++++---------------- ncgen3/ncgenl.c | 6 +++--- ncgen3/ncgeny.c | 32 ++++++++++++++++---------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ncgen3/ncgen.l b/ncgen3/ncgen.l index 9c304f4038..ab15a8a9bb 100644 --- a/ncgen3/ncgen.l +++ b/ncgen3/ncgen.l @@ -142,8 +142,8 @@ data:|DATA: {return (DATA);} yyerror("netCDF name required"); return (DATA); /* generate syntax error */ } - netcdfname = (char *) emalloc(t-s+1); - (void) strncpy(netcdfname, s, t-s); + netcdfname = (char *) emalloc((size_t)(t-s+1)); + (void) strncpy(netcdfname, s, (size_t)(t-s)); netcdfname[t-s] = '\0'; deescapify(netcdfname); /* so "\5foo" becomes "5foo", for example */ return (NETCDF); @@ -184,7 +184,7 @@ FloatInf|-?Inff { /* missing value (pre-2.4 backward compatibility) */ snprintf(errstr, sizeof(errstr),"bad byte constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = ii; + byte_val = (signed char)ii; if (ii != (int)byte_val) { snprintf(errstr, sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)yytext); yyerror(errstr); diff --git a/ncgen3/ncgen.y b/ncgen3/ncgen.y index dfd99ff364..c388e562bd 100644 --- a/ncgen3/ncgen.y +++ b/ncgen3/ncgen.y @@ -142,7 +142,7 @@ dimdecline: dimdecl dimdecl: dimd '=' INT_CONST { if (int_val <= 0) derror("dimension length must be positive"); - dims[ndims].size = int_val; + dims[ndims].size = (size_t)int_val; ndims++; } | dimd '=' DOUBLE_CONST @@ -629,10 +629,10 @@ const: CHAR_CONST atype_code = NC_SHORT; switch (valtype) { case NC_CHAR: - *char_valp++ = short_val; + *char_valp++ = (char)short_val; break; case NC_BYTE: - *byte_valp++ = short_val; + *byte_valp++ = (signed char)short_val; break; case NC_SHORT: *short_valp++ = short_val; @@ -655,19 +655,19 @@ const: CHAR_CONST atype_code = NC_INT; switch (valtype) { case NC_CHAR: - *char_valp++ = int_val; + *char_valp++ = (char)int_val; break; case NC_BYTE: - *byte_valp++ = int_val; + *byte_valp++ = (signed char)int_val; break; case NC_SHORT: - *short_valp++ = int_val; + *short_valp++ = (short)int_val; break; case NC_INT: *int_valp++ = int_val; break; case NC_FLOAT: - *float_valp++ = int_val; + *float_valp++ = (float)int_val; break; case NC_DOUBLE: *double_valp++ = int_val; @@ -681,16 +681,16 @@ const: CHAR_CONST atype_code = NC_FLOAT; switch (valtype) { case NC_CHAR: - *char_valp++ = float_val; + *char_valp++ = (char)float_val; break; case NC_BYTE: - *byte_valp++ = float_val; + *byte_valp++ = (signed char)float_val; break; case NC_SHORT: - *short_valp++ = float_val; + *short_valp++ = (short)float_val; break; case NC_INT: - *int_valp++ = float_val; + *int_valp++ = (int)float_val; break; case NC_FLOAT: *float_valp++ = float_val; @@ -707,22 +707,22 @@ const: CHAR_CONST atype_code = NC_DOUBLE; switch (valtype) { case NC_CHAR: - *char_valp++ = double_val; + *char_valp++ = (char)double_val; break; case NC_BYTE: - *byte_valp++ = double_val; + *byte_valp++ = (signed char)double_val; break; case NC_SHORT: - *short_valp++ = double_val; + *short_valp++ = (short)double_val; break; case NC_INT: - *int_valp++ = double_val; + *int_valp++ = (int)double_val; break; case NC_FLOAT: if (double_val == NC_FILL_DOUBLE) *float_valp++ = NC_FILL_FLOAT; else - *float_valp++ = double_val; + *float_valp++ = (float)double_val; break; case NC_DOUBLE: *double_valp++ = double_val; diff --git a/ncgen3/ncgenl.c b/ncgen3/ncgenl.c index 1cc3c4831b..936f5fc14d 100644 --- a/ncgen3/ncgenl.c +++ b/ncgen3/ncgenl.c @@ -1505,8 +1505,8 @@ YY_RULE_SETUP yyerror("netCDF name required"); return (DATA); /* generate syntax error */ } - netcdfname = (char *) emalloc(t-s+1); - (void) strncpy(netcdfname, s, t-s); + netcdfname = (char *) emalloc((size_t)(t-s+1)); + (void) strncpy(netcdfname, s, (size_t)(t-s)); netcdfname[t-s] = '\0'; deescapify(netcdfname); /* so "\5foo" becomes "5foo", for example */ return (NETCDF); @@ -1566,7 +1566,7 @@ YY_RULE_SETUP snprintf(errstr, sizeof(errstr),"bad byte constant: %s",(char*)yytext); yyerror(errstr); } - byte_val = ii; + byte_val = (signed char)ii; if (ii != (int)byte_val) { snprintf(errstr, sizeof(errstr),"byte constant out of range (-128,127): %s",(char*)yytext); yyerror(errstr); diff --git a/ncgen3/ncgeny.c b/ncgen3/ncgeny.c index 1a6be938ee..8a4b51104c 100644 --- a/ncgen3/ncgeny.c +++ b/ncgen3/ncgeny.c @@ -1310,7 +1310,7 @@ yyparse (void) #line 143 "ncgen3/ncgen.y" { if (int_val <= 0) derror("dimension length must be positive"); - dims[ndims].size = int_val; + dims[ndims].size = (size_t)int_val; ndims++; } #line 1317 "ncgeny.c" @@ -1881,10 +1881,10 @@ yyparse (void) atype_code = NC_SHORT; switch (valtype) { case NC_CHAR: - *char_valp++ = short_val; + *char_valp++ = (char)short_val; break; case NC_BYTE: - *byte_valp++ = short_val; + *byte_valp++ = (signed char)short_val; break; case NC_SHORT: *short_valp++ = short_val; @@ -1911,19 +1911,19 @@ yyparse (void) atype_code = NC_INT; switch (valtype) { case NC_CHAR: - *char_valp++ = int_val; + *char_valp++ = (char)int_val; break; case NC_BYTE: - *byte_valp++ = int_val; + *byte_valp++ = (signed char)int_val; break; case NC_SHORT: - *short_valp++ = int_val; + *short_valp++ = (short)int_val; break; case NC_INT: *int_valp++ = int_val; break; case NC_FLOAT: - *float_valp++ = int_val; + *float_valp++ = (float)int_val; break; case NC_DOUBLE: *double_valp++ = int_val; @@ -1941,16 +1941,16 @@ yyparse (void) atype_code = NC_FLOAT; switch (valtype) { case NC_CHAR: - *char_valp++ = float_val; + *char_valp++ = (char)float_val; break; case NC_BYTE: - *byte_valp++ = float_val; + *byte_valp++ = (signed char)float_val; break; case NC_SHORT: - *short_valp++ = float_val; + *short_valp++ = (short)float_val; break; case NC_INT: - *int_valp++ = float_val; + *int_valp++ = (int)float_val; break; case NC_FLOAT: *float_valp++ = float_val; @@ -1971,22 +1971,22 @@ yyparse (void) atype_code = NC_DOUBLE; switch (valtype) { case NC_CHAR: - *char_valp++ = double_val; + *char_valp++ = (char)double_val; break; case NC_BYTE: - *byte_valp++ = double_val; + *byte_valp++ = (signed char)double_val; break; case NC_SHORT: - *short_valp++ = double_val; + *short_valp++ = (short)double_val; break; case NC_INT: - *int_valp++ = double_val; + *int_valp++ = (int)double_val; break; case NC_FLOAT: if (double_val == NC_FILL_DOUBLE) *float_valp++ = NC_FILL_FLOAT; else - *float_valp++ = double_val; + *float_valp++ = (float)double_val; break; case NC_DOUBLE: *double_valp++ = double_val; From cffc5187a2034689922e721dbae8f19ef728bb9b Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 15:48:34 +0000 Subject: [PATCH 35/48] Fix some conversion warnings in ncgen3 --- ncgen3/genlib.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ncgen3/genlib.c b/ncgen3/genlib.c index a34ae5c096..9f0d5b721b 100644 --- a/ncgen3/genlib.c +++ b/ncgen3/genlib.c @@ -1866,13 +1866,13 @@ extern char* decodify ( const char *name) { - int count; /* number chars in newname */ + size_t count; /* number chars in newname */ char *newname; const char *cp; char *sp; static int init = 0; static char* repls[256]; /* replacement string for each char */ - static int lens[256]; /* lengths of replacement strings */ + static size_t lens[256]; /* lengths of replacement strings */ static struct { char c; char *s; @@ -1911,7 +1911,7 @@ decodify ( {'/', "_SLASH_"} /* should not occur in names */ /* {'_', "_UNDERSCORE_"} */ }; - static int idtlen; + static size_t idtlen; static size_t hexlen; int nctable = (sizeof(ctable))/(sizeof(ctable[0])); size_t newlen; @@ -1924,12 +1924,12 @@ decodify ( for(i = 0; i < 128; i++) { rp = emalloc(2); - rp[0] = i; + rp[0] = (char)i; rp[1] = '\0'; repls[i] = rp; } for(i=0; i < nctable; i++) { - size_t j = ctable[i].c; + size_t j = (size_t)ctable[i].c; free(repls[j]); repls[j] = ctable[i].s; } @@ -1950,9 +1950,9 @@ decodify ( while(*cp != '\0') { /* get number of extra bytes for newname */ size_t j; if(*cp < 0) { /* handle signed or unsigned chars */ - j = *cp + 256; + j = (size_t)*cp + 256; } else { - j = *cp; + j = (size_t)*cp; } count += lens[j] - 1; cp++; @@ -1976,9 +1976,9 @@ decodify ( size_t j, len; /* cp is current position in name, sp is current position in newname */ if(*cp < 0) { /* j is table index for character *cp */ - j = *cp + 256; + j = (size_t)*cp + 256; } else { - j = *cp; + j = (size_t)*cp; } len = strlcat(sp, repls[j], newlen); assert(len < newlen); From 33a6ab034aa44eb2e9ad2120bb2ac7cb9ee3b3c4 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 25 Mar 2024 15:49:03 +0000 Subject: [PATCH 36/48] Fix truncated-format warning in ncgen --- ncgen3/genlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ncgen3/genlib.c b/ncgen3/genlib.c index 9f0d5b721b..0d775a7379 100644 --- a/ncgen3/genlib.c +++ b/ncgen3/genlib.c @@ -193,7 +193,7 @@ cstring( return cp; case NC_DOUBLE: - cp_size = 20; + cp_size = 24; cp = (char *) emalloc (cp_size); doublep = (double *)valp; (void) snprintf(cp,cp_size,"%.16g",* (doublep + num)); From acec11d515d70db1b35a9b7c6fb2239a8e5b2eb7 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 3 Apr 2024 11:42:59 -0600 Subject: [PATCH 37/48] Use modern cmake nomenclature for curl. --- cmake/dependencies.cmake | 28 +++++++++++++--------------- libdap2/CMakeLists.txt | 2 +- libdap4/CMakeLists.txt | 2 +- liblib/CMakeLists.txt | 6 +++++- libsrc/CMakeLists.txt | 2 ++ oc2/CMakeLists.txt | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index d74a6ecd5e..2b5905f5e3 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -218,25 +218,23 @@ endif(USE_HDF5) ################################ # See if we have libcurl find_package(CURL) -target_compile_options(netcdf - PRIVATE - -DCURL_STATICLIB=1 -) -target_include_directories(netcdf +#target_compile_options(netcdf +# PRIVATE +# -DCURL_STATICLIB=1 +#) +#target_include_directories(netcdf +# PRIVATE +# ${CURL_INCLUDE_DIRS} +#) +if(CURL_FOUND) + set(FOUND_CURL TRUE) + target_link_libraries(netcdf PRIVATE - ${CURL_INCLUDE_DIRS} + CURL::libcurl ) - - - -MESSAGE(STATUS "Found CURL_INCLUDE_DIRS: ${CURL_INCLUDE_DIRS}") -# Define a test flag for have curl library -if(CURL_LIBRARIES OR CURL_LIBRARY) - set(FOUND_CURL TRUE) else() set(FOUND_CURL FALSE) -endif() -set(FOUND_CURL ${FOUND_CURL} TRUE ) +endif(CURL_FOUND) # Start disabling if curl not found if(NOT FOUND_CURL) diff --git a/libdap2/CMakeLists.txt b/libdap2/CMakeLists.txt index ed59fc1cde..9e09abe070 100644 --- a/libdap2/CMakeLists.txt +++ b/libdap2/CMakeLists.txt @@ -27,7 +27,7 @@ set_property(SOURCE ncd2dispatch.c add_library(dap2 OBJECT ${dap2_SOURCES}) -target_link_libraries(dap2 PUBLIC ${CURL_LIBRARIES}) +target_link_libraries(dap2 PUBLIC CURL::libcurl ${CURL_LIBRARIES}) target_include_directories(dap2 PUBLIC ${CURL_INCLUDE_DIRS}) target_compile_options(dap2 PRIVATE diff --git a/libdap4/CMakeLists.txt b/libdap4/CMakeLists.txt index 4b21a642b8..e410977c1c 100644 --- a/libdap4/CMakeLists.txt +++ b/libdap4/CMakeLists.txt @@ -20,7 +20,7 @@ set_property(SOURCE d4meta.c SKIP_UNITY_BUILD_INCLUSION ON) add_library(dap4 OBJECT ${dap4_SOURCES}) -target_link_libraries(dap4 PUBLIC ${CURL_LIBRARIES}) +target_link_libraries(dap4 PUBLIC CURL::libcurl ${CURL_LIBRARIES}) target_include_directories(dap4 PUBLIC ${CURL_INCLUDE_DIRS}) target_compile_options(dap4 PRIVATE diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt index 36a709f65c..e0fe9f5c92 100644 --- a/liblib/CMakeLists.txt +++ b/liblib/CMakeLists.txt @@ -42,6 +42,10 @@ if(USE_HDF4) ) endif() +if(FOUND_CURL) + target_link_libraries(netcdf PRIVATE CURL::libcurl) +endif() + if(NETCDF_ENABLE_DAP2) target_sources(netcdf PRIVATE @@ -144,7 +148,7 @@ if(USE_HDF5) endif() if(FOUND_CURL) - set(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARIES}) + set(TLL_LIBS ${TLL_LIBS} CURL::libcurl ${CURL_LIBRARIES}) endif() if(USE_HDF4) diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index a3ea899c91..022c6f42c5 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -42,6 +42,7 @@ ENDif (USE_FFIO) if (NETCDF_ENABLE_BYTERANGE) list(APPEND libsrc_SOURCES httpio.c) + if (NETCDF_ENABLE_S3) list(APPEND libsrc_SOURCES s3io.c) endif(NETCDF_ENABLE_S3) @@ -55,6 +56,7 @@ endif() if (NETCDF_ENABLE_BYTERANGE) target_include_directories(netcdf3 PUBLIC ${CURL_INCLUDE_DIRS}) + target_link_libraries(netcdf3 PUBLIC CURL::libcurl) target_compile_options(netcdf3 PRIVATE -DCURL_STATICLIB=1 diff --git a/oc2/CMakeLists.txt b/oc2/CMakeLists.txt index 36a675c763..01b2e998ee 100644 --- a/oc2/CMakeLists.txt +++ b/oc2/CMakeLists.txt @@ -15,7 +15,7 @@ endif() if(STATUS_PARALLEL) target_link_libraries(oc2 PUBLIC MPI::MPI_C) endif(STATUS_PARALLEL) -target_link_libraries(oc2 PUBLIC ${CURL_LIBRARIES}) +target_link_libraries(oc2 PUBLIC CURL::libcurl ${CURL_LIBRARIES}) target_include_directories(oc2 PUBLIC ${CURL_INCLUDE_DIRS}) target_compile_options(oc2 PRIVATE From 19d6c023145873a03fce2060b48055ac7da3bb39 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 3 Apr 2024 12:06:24 -0600 Subject: [PATCH 38/48] Set flags to avoid warning messages if curl isn't found. --- cmake/dependencies.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 2b5905f5e3..f58b65ee6e 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -234,6 +234,10 @@ if(CURL_FOUND) ) else() set(FOUND_CURL FALSE) + set(NETCDF_ENABLE_DAP2 OFF) + set(NETCDF_ENABLE_DAP4 OFF) + set(NETCDF_ENABLE_BYTERANGE OFF) + set(NETCDF_ENABLE_S3 OFF) endif(CURL_FOUND) # Start disabling if curl not found From c72511404ebfe858bdbc0c548fc036885eafbb98 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 2 Feb 2024 10:59:55 +0000 Subject: [PATCH 39/48] Fix conversion warnings in libdispatch --- libdispatch/dauth.c | 4 ++-- libdispatch/daux.c | 4 +--- libdispatch/dhttp.c | 2 +- libdispatch/dinfermodel.c | 12 ++++++------ libdispatch/dinstance.c | 22 ++++++++++++---------- libdispatch/dinstance_intern.c | 6 +++--- libdispatch/dpathmgr.c | 4 ++-- libdispatch/ds3util.c | 29 ++++++++++++----------------- libdispatch/dutf8.c | 2 +- libdispatch/dutil.c | 7 +++---- libdispatch/dv2i.c | 2 +- libdispatch/dvar.c | 4 +--- libdispatch/ncbytes.c | 2 +- libdispatch/ncexhash.c | 17 ++++++++--------- libdispatch/nchashmap.c | 20 ++++++++++---------- libdispatch/ncjson.c | 27 +++++++++++++-------------- libdispatch/ncuri.c | 6 +++--- libdispatch/ncxcache.c | 2 +- libsrc4/nc4var.c | 8 ++++---- 19 files changed, 85 insertions(+), 95 deletions(-) diff --git a/libdispatch/dauth.c b/libdispatch/dauth.c index 9cd335eeba..6e12ee3c72 100644 --- a/libdispatch/dauth.c +++ b/libdispatch/dauth.c @@ -281,7 +281,7 @@ setauthfield(NCauth* auth, const char* flag, const char* value) } if(strcmp(flag,"HTTP.SSL.VERIFYPEER")==0) { int v; - if((v = atol(value))) { + if((v = atoi(value))) { auth->ssl.verifypeer = v; #ifdef DEBUG nclog(NCLOGNOTE,"HTTP.SSL.VERIFYPEER: %d", v); @@ -290,7 +290,7 @@ setauthfield(NCauth* auth, const char* flag, const char* value) } if(strcmp(flag,"HTTP.SSL.VERIFYHOST")==0) { int v; - if((v = atol(value))) { + if((v = atoi(value))) { auth->ssl.verifyhost = v; #ifdef DEBUG nclog(NCLOGNOTE,"HTTP.SSL.VERIFYHOST: %d", v); diff --git a/libdispatch/daux.c b/libdispatch/daux.c index 538403533e..77fddaffef 100644 --- a/libdispatch/daux.c +++ b/libdispatch/daux.c @@ -311,11 +311,9 @@ computefieldinfo(struct NCAUX_CMPD* cmpd) #define LBRACK '[' #define RBRACK ']' -static int gettype(int q0, int q1, int* unsignedp); - /* Look at q0 and q1) to determine type */ static int -gettype(const int q0, const int q1, int* isunsignedp) +gettype(const char q0, const char q1, int* isunsignedp) { int type = 0; int isunsigned = 0; diff --git a/libdispatch/dhttp.c b/libdispatch/dhttp.c index db82c5e00f..45f93828f6 100644 --- a/libdispatch/dhttp.c +++ b/libdispatch/dhttp.c @@ -774,7 +774,7 @@ void dump(const char *text, FILE *stream, unsigned char *ptr, size_t size) /* show data on the right */ for(c = 0; (c < width) && (i+c < size); c++) { - char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.'; + const int x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x80) ? ptr[i+c] : '.'; fputc(x, stream); } diff --git a/libdispatch/dinfermodel.c b/libdispatch/dinfermodel.c index 44352c1573..7bb2eaddda 100644 --- a/libdispatch/dinfermodel.c +++ b/libdispatch/dinfermodel.c @@ -213,7 +213,7 @@ static int parseonchar(const char* s, int ch, NClist* segments); static int mergelist(NClist** valuesp); static int openmagic(struct MagicFile* file); -static int readmagic(struct MagicFile* file, long pos, char* magic); +static int readmagic(struct MagicFile* file, size_t pos, char* magic); static int closemagic(struct MagicFile* file); static int NC_interpret_magic_number(char* magic, NCmodel* model); #ifdef DEBUG @@ -1288,7 +1288,7 @@ check_file_type(const char *path, int omode, int use_parallel, search forward at starting at 512 and doubling to see if we have HDF5 magic number */ { - long pos = 512L; + size_t pos = 512L; for(;;) { if((pos+MAGIC_NUMBER_LEN) > magicinfo.filelen) {status = NC_ENOTNC; goto done;} @@ -1395,7 +1395,7 @@ openmagic(struct MagicFile* file) } static int -readmagic(struct MagicFile* file, long pos, char* magic) +readmagic(struct MagicFile* file, size_t pos, char* magic) { int status = NC_NOERR; NCbytes* buf = ncbytesnew(); @@ -1413,8 +1413,8 @@ readmagic(struct MagicFile* file, long pos, char* magic) #endif } else if(file->uri != NULL) { #ifdef NETCDF_ENABLE_BYTERANGE - fileoffset_t start = (size_t)pos; - fileoffset_t count = MAGIC_NUMBER_LEN; + size64_t start = (size64_t)pos; + size64_t count = MAGIC_NUMBER_LEN; status = nc_http_read(file->state, start, count, buf); if (status == NC_NOERR) { if (ncbyteslength(buf) != count) @@ -1436,7 +1436,7 @@ readmagic(struct MagicFile* file, long pos, char* magic) #endif /* USE_PARALLEL */ { /* Ordinary read */ long i; - i = fseek(file->fp, pos, SEEK_SET); + i = fseek(file->fp, (long)pos, SEEK_SET); if (i < 0) { status = errno; goto done; } ncbytessetlength(buf, 0); if ((status = NC_readfileF(file->fp, buf, MAGIC_NUMBER_LEN))) goto done; diff --git a/libdispatch/dinstance.c b/libdispatch/dinstance.c index 38d5217cb4..52b1d21bb0 100644 --- a/libdispatch/dinstance.c +++ b/libdispatch/dinstance.c @@ -12,6 +12,8 @@ Currently two operations are defined: */ #include "config.h" +#include +#include #include #include #include @@ -411,7 +413,7 @@ dump_datar(int ncid, nc_type xtype, Position* offset, NCbytes* buf) break; } if(xtype <= NC_MAX_ATOMIC_TYPE) - offset->offset += xsize; + offset->offset += (ptrdiff_t)xsize; done: return stat; @@ -440,12 +442,12 @@ dump_vlen(int ncid, nc_type xtype, nc_type basetype, Position* offset, NCbytes* voffset.offset = 0; for(i=0;ilen;i++) { if(i > 0) ncbytescat(buf," "); - voffset.offset = NC_read_align(voffset.offset,alignment); + voffset.offset = (ptrdiff_t)NC_read_align((uintptr_t)voffset.offset, alignment); if((stat = dump_datar(ncid,basetype,&voffset,buf))) goto done; } } ncbytescat(buf,")}"); - offset->offset += sizeof(nc_vlen_t); + offset->offset += (ptrdiff_t)sizeof(nc_vlen_t); done: return stat; @@ -469,12 +471,12 @@ dump_opaque(int ncid, nc_type xtype, size_t size, Position* offset, NCbytes* buf /* basically a fixed size sequence of bytes */ ncbytescat(buf,"|"); for(i=0;imemory+offset->offset+i); + unsigned char x = (unsigned char)*(offset->memory+offset->offset+i); snprintf(sx,sizeof(sx),"%2x",x); ncbytescat(buf,sx); } ncbytescat(buf,"|"); - offset->offset += size; + offset->offset += (ptrdiff_t)size; return NC_NOERR; } @@ -482,7 +484,7 @@ static int dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* offset, NCbytes* buf) { int stat = NC_NOERR; - size_t fid, i, arraycount; + size_t i; ptrdiff_t saveoffset; int ndims; int dimsizes[NC_MAX_VAR_DIMS]; @@ -492,7 +494,7 @@ dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* of ncbytescat(buf,"<"); /* Get info about each field in turn and dump it */ - for(fid=0;fidoffset = saveoffset + fieldalignment; + offset->offset = saveoffset + (ptrdiff_t)fieldalignment; /* compute the total number of elements in the field array */ - arraycount = 1; + int arraycount = 1; for(i=0;i 0) ncbytescat(buf," "); @@ -525,7 +527,7 @@ dump_compound(int ncid, nc_type xtype, size_t size, size_t nfields, Position* of ncbytescat(buf,">"); /* Return to beginning of the compound and move |compound| */ offset->offset = saveoffset; - offset->offset += size; + offset->offset += (ptrdiff_t)size; done: return stat; diff --git a/libdispatch/dinstance_intern.c b/libdispatch/dinstance_intern.c index b4b1b41f64..f1dac8eda6 100644 --- a/libdispatch/dinstance_intern.c +++ b/libdispatch/dinstance_intern.c @@ -133,7 +133,7 @@ reclaim_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position instance) NC_TYPE_INFO_T* basetype = NULL; size_t nfields; nc_vlen_t* vlen; - size_t fid, arraycount; + size_t fid; int ndims; int dimsizes[NC_MAX_VAR_DIMS]; size_t alignment = 0; @@ -184,7 +184,7 @@ reclaim_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position instance) /* Get field's dimension sizes */ field = (NC_FIELD_INFO_T*)nclistget(utype->u.c.field,fid); ndims = field->ndims; - arraycount = 1; + int arraycount = 1; for(i=0;idim_size[i]; arraycount *= dimsizes[i];} if(field->ndims == 0) {ndims=1; dimsizes[0]=1;} /* fake the scalar case */ @@ -423,7 +423,7 @@ copy_datar(NC_FILE_INFO_T* file, NC_TYPE_INFO_T* utype, Position src, Position d field = (NC_FIELD_INFO_T*)nclistget(utype->u.c.field,fid); ndims = field->ndims; arraycount = 1; - for(i=0;idim_size[i]; arraycount *= dimsizes[i];} + for(i=0;idim_size[i]; arraycount *= (size_t)dimsizes[i];} if(field->ndims == 0) {ndims=1; dimsizes[0]=1;} /* fake the scalar case */ /* "move" to this field */ diff --git a/libdispatch/dpathmgr.c b/libdispatch/dpathmgr.c index dca9f7f80f..7e67fbbeb5 100644 --- a/libdispatch/dpathmgr.c +++ b/libdispatch/dpathmgr.c @@ -85,7 +85,7 @@ static const char* cygwinspecial[] = static const struct Path { int kind; - int drive; + char drive; char* path; } empty = {NCPD_UNKNOWN,0,NULL}; @@ -896,7 +896,7 @@ unparsepath(struct Path* xp, char** pathp, int target) char sdrive[4] = "\0\0\0\0"; char* p = NULL; int cygspecial = 0; - int drive = 0; + char drive = 0; /* Short circuit a relative path */ if(xp->kind == NCPD_REL) { diff --git a/libdispatch/ds3util.c b/libdispatch/ds3util.c index 75c7851a96..8db08d2e82 100644 --- a/libdispatch/ds3util.c +++ b/libdispatch/ds3util.c @@ -282,11 +282,10 @@ NC_s3urlrebuild(NCURI* url, NCS3INFO* s3, NCURI** newurlp) static int endswith(const char* s, const char* suffix) { - ssize_t ls, lsf, delta; if(s == NULL || suffix == NULL) return 0; - ls = strlen(s); - lsf = strlen(suffix); - delta = (ls - lsf); + size_t ls = strlen(s); + size_t lsf = strlen(suffix); + ssize_t delta = (ssize_t)(ls - lsf); if(delta < 0) return 0; if(memcmp(s+delta,suffix,lsf)!=0) return 0; return 1; @@ -404,11 +403,10 @@ static void freeprofile(struct AWSprofile* profile) { if(profile) { - int i; #ifdef AWSDEBUG fprintf(stderr,">>> freeprofile: %s\n",profile->name); #endif - for(i=0;ientries);i++) { + for(size_t i=0;ientries);i++) { struct AWSentry* e = (struct AWSentry*)nclistget(profile->entries,i); freeentry(e); } @@ -422,8 +420,7 @@ void NC_s3freeprofilelist(NClist* profiles) { if(profiles) { - int i; - for(i=0;ircinfo->s3profiles);i++) { + for(size_t i=0;ircinfo->s3profiles);i++) { struct AWSprofile* profile = (struct AWSprofile*)nclistget(gstate->rcinfo->s3profiles,i); if(strcmp(profilename,profile->name)==0) {if(profilep) {*profilep = profile; goto done;}} @@ -572,13 +568,13 @@ NC_authgets3profile(const char* profilename, struct AWSprofile** profilep) int NC_s3profilelookup(const char* profile, const char* key, const char** valuep) { - int i,stat = NC_NOERR; + int stat = NC_NOERR; struct AWSprofile* awsprof = NULL; const char* value = NULL; if(profile == NULL) return NC_ES3; if((stat=NC_authgets3profile(profile,&awsprof))==NC_NOERR && awsprof != NULL) { - for(i=0;ientries);i++) { + for(size_t i=0;ientries);i++) { struct AWSentry* entry = (struct AWSentry*)nclistget(awsprof->entries,i); if(strcasecmp(entry->key,key)==0) { value = entry->value; @@ -735,7 +731,6 @@ typedef struct AWSparser { static int awslex(AWSparser* parser) { - int c; int token = 0; char* start; size_t count; @@ -751,7 +746,7 @@ awslex(AWSparser* parser) } while(token == 0) { /* avoid need to goto when retrying */ - c = *parser->pos; + char c = *parser->pos; if(c == '\0') { token = AWS_EOF; } else if(c == '\n') { @@ -785,7 +780,7 @@ awslex(AWSparser* parser) } /* Pushback last char */ parser->pos--; - count = ((parser->pos) - start); + count = (size_t)(parser->pos - start); ncbytesappendn(parser->yytext,start,count); ncbytesnull(parser->yytext); token = AWS_WORD; @@ -811,7 +806,7 @@ fprintf(stderr,"%s(%d): |%s|\n",tokenname(token),token,ncbytescontents(parser->y static int awsparse(const char* text, NClist* profiles) { - int i,stat = NC_NOERR; + int stat = NC_NOERR; size_t len; AWSparser* parser = NULL; struct AWSprofile* profile = NULL; @@ -891,7 +886,7 @@ fprintf(stderr,">>> parse: entry=(%s,%s)\n",entry->key,entry->value); } /* If this profile already exists, then replace old one */ - for(i=0;iname,profile->name)==0) { nclistset(profiles,i,profile); diff --git a/libdispatch/dutf8.c b/libdispatch/dutf8.c index f8e0d6b9a0..86f917d207 100644 --- a/libdispatch/dutf8.c +++ b/libdispatch/dutf8.c @@ -153,7 +153,7 @@ int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* l goto done; } else { /* move to next char */ /* Complain if top 16 bits not zero */ - if((codepoint & 0xFFFF0000) != 0) { + if((codepoint & (nc_utf8proc_int32_t)0xFFFF0000) != 0) { ncstat = NC_EBADNAME; goto done; } diff --git a/libdispatch/dutil.c b/libdispatch/dutil.c index 47e1ead503..f6f0eecc34 100644 --- a/libdispatch/dutil.c +++ b/libdispatch/dutil.c @@ -282,7 +282,7 @@ NC_readfileF(FILE* stream, NCbytes* content, long long amount) { #define READ_BLOCK_SIZE 4194304 int ret = NC_NOERR; - long long red = 0; + size_t red = 0; char *part = (char*) malloc(READ_BLOCK_SIZE); while(amount < 0 || red < amount) { @@ -294,7 +294,7 @@ NC_readfileF(FILE* stream, NCbytes* content, long long amount) } /* Keep only amount */ if(amount >= 0) { - if(red > amount) ncbytessetlength(content,amount); /* read too much */ + if(red > amount) ncbytessetlength(content, (unsigned long)amount); /* read too much */ if(red < amount) ret = NC_ETRUNC; /* |file| < amount */ } ncbytesnull(content); @@ -405,7 +405,6 @@ NC_addmodetag(NCURI* uri, const char* tag) { int stat = NC_NOERR; int found = 0; - int i; const char* modestr = NULL; char* modevalue = NULL; NClist* modelist = NULL; @@ -417,7 +416,7 @@ NC_addmodetag(NCURI* uri, const char* tag) } else modelist = nclistnew(); /* Search for tag */ - for(i=0;ilength <= pos) return ncbytesfail(); if(pos < (bb->length - 1)) { - int copylen = (bb->length - pos) - 1; + size_t copylen = (bb->length - pos) - 1; memmove(bb->content+pos,bb->content+pos+1,copylen); } bb->length--; diff --git a/libdispatch/ncexhash.c b/libdispatch/ncexhash.c index 0d3d9dc212..8a65841e15 100644 --- a/libdispatch/ncexhash.c +++ b/libdispatch/ncexhash.c @@ -736,7 +736,7 @@ ncexhashiterate(NCexhashmap* map, ncexhashkey_t* keyp, uintptr_t* datap) void ncexhashprint(NCexhashmap* hm) { - int dirindex,index; + int index; if(hm == NULL) {fprintf(stderr,"NULL"); fflush(stderr); return;} fprintf(stderr,"{depth=%u leaflen=%u",hm->depth,hm->leaflen); @@ -745,9 +745,9 @@ ncexhashprint(NCexhashmap* hm) hm->iterator.leaf,hm->iterator.index); } fprintf(stderr,"\n"); - for(dirindex=0;dirindex<(1<depth);dirindex++) { + for(size_t dirindex=0;dirindex<(1<depth);dirindex++) { NCexleaf* leaf = hm->directory[dirindex]; - fprintf(stderr,"\tdirectory[%03d|%sb]=(%04x)[(%u)^%d|%d|", + fprintf(stderr,"\tdirectory[%03zu|%sb]=(%04x)[(%u)^%d|%d|", dirindex,ncexbinstr(dirindex,hm->depth), leaf->active, (unsigned)(0xffff & (uintptr_t)leaf), @@ -776,10 +776,9 @@ ncexhashprint(NCexhashmap* hm) void ncexhashprintdir(NCexhashmap* map, NCexleaf** dir) { - int dirindex; - for(dirindex=0;dirindex<(1<depth);dirindex++) { + for(unsigned long long dirindex=0;dirindex<(1<depth);dirindex++) { NCexleaf* leaf = dir[dirindex]; - fprintf(stderr,"\tdirectory[%03d|%sb]=%d/%p\n", + fprintf(stderr,"\tdirectory[%03llu|%sb]=%d/%p\n", dirindex,ncexbinstr(dirindex,map->depth),leaf->uid,leaf); } fflush(stderr); @@ -831,14 +830,14 @@ ncexbinstr(ncexhashkey_t hkey, int depth) void ncexhashprintstats(NCexhashmap* map) { - int nactive, nleaves; + int nactive; NCexleaf* leaf = NULL; double leafavg = 0.0; double leafload = 0.0; unsigned long long dirsize, leafsize, total; nactive = 0; - nleaves = 0; + unsigned long long nleaves = 0; for(leaf=map->leaves;leaf;leaf=leaf->next) { nleaves++; nactive += leaf->active; @@ -850,7 +849,7 @@ ncexhashprintstats(NCexhashmap* map) if(nactive != map->nactive) { fprintf(stderr,"nactive mismatch: map->active=%d actual=%d\n",map->nactive,nactive); } - fprintf(stderr,"|directory|=%llu nleaves=%d nactive=%d", + fprintf(stderr,"|directory|=%llu nleaves=%llu nactive=%d", (unsigned long long)(1<<(map->depth)),nleaves,nactive); fprintf(stderr," |leaf|=%d nactive/nleaves=%g", map->leaflen, leafavg); fprintf(stderr," load=%g",leafload); diff --git a/libdispatch/nchashmap.c b/libdispatch/nchashmap.c index af08aac027..0e438bca86 100644 --- a/libdispatch/nchashmap.c +++ b/libdispatch/nchashmap.c @@ -71,7 +71,7 @@ extern nchashkey_t hash_fast(const char*, size_t length); /* Forward */ static const unsigned int NC_nprimes; static const unsigned int NC_primes[16386]; -static unsigned int findPrimeGreaterThan(size_t val); +static size_t findPrimeGreaterThan(size_t val); extern void printhashmapstats(NC_hashmap* hm); extern void printhashmap(NC_hashmap* hm); @@ -160,7 +160,7 @@ locate(NC_hashmap* hash, nchashkey_t hashkey, const char* key, size_t keysize, s nchashkey_t NC_hashmapkey(const char* key, size_t size) { - return NC_crc64(0,(void*)key,(unsigned int)size); + return (nchashkey_t)NC_crc64(0,(void*)key,(unsigned int)size); } NC_hashmap* @@ -399,7 +399,7 @@ static int isPrime(size_t n) } /* Function to return the smallest prime number greater than N */ -static int nextPrime(size_t val) +static size_t nextPrime(size_t val) { if (val <= 1) return 2; @@ -424,18 +424,18 @@ Binary search prime table for first prime just greater than or equal to val */ -static unsigned int +static size_t findPrimeGreaterThan(size_t val) { - int n = NC_nprimes; - int L = 1; /* skip leading flag number */ - int R = (n - 2); /* skip trailing flag */ - unsigned int v = 0; - int m; + size_t n = NC_nprimes; + size_t L = 1; /* skip leading flag number */ + size_t R = (n - 2); /* skip trailing flag */ + size_t v = 0; + size_t m; if(val >= 0xFFFFFFFF) return 0; /* Too big */ - v = (unsigned int)val; + v = val; if (v > NC_primes[n - 2]) { /* diff --git a/libdispatch/ncjson.c b/libdispatch/ncjson.c index 1a574a9b80..363b24ffef 100644 --- a/libdispatch/ncjson.c +++ b/libdispatch/ncjson.c @@ -71,7 +71,7 @@ typedef struct NCJparser { } NCJparser; typedef struct NCJbuf { - int len; /* |text|; does not include nul terminator */ + size_t len; /* |text|; does not include nul terminator */ char* text; /* NULL || nul terminated */ } NCJbuf; @@ -109,7 +109,7 @@ static int NCJyytext(NCJparser*, char* start, size_t pdlen); static void NCJreclaimArray(struct NCjlist*); static void NCJreclaimDict(struct NCjlist*); static int NCJunescape(NCJparser* parser); -static int unescape1(int c); +static char unescape1(char c); static int listappend(struct NCjlist* list, NCjson* element); static int NCJcloneArray(const NCjson* array, NCjson** clonep); @@ -368,13 +368,12 @@ NCJparseDict(NCJparser* parser, struct NCjlist* dictp) static int NCJlex(NCJparser* parser) { - int c; int token = NCJ_UNDEF; char* start; size_t count; while(token == 0) { /* avoid need to goto when retrying */ - c = *parser->pos; + char c = *parser->pos; if(c == '\0') { token = NCJ_EOF; } else if(c <= ' ' || c == '\177') {/* ignore whitespace */ @@ -393,7 +392,7 @@ NCJlex(NCJparser* parser) } /* Pushback c */ parser->pos--; - count = ((parser->pos) - start); + count = (size_t)((parser->pos) - start); if(NCJyytext(parser,start,count)) goto done; /* Discriminate the word string to get the proper sort */ if(testbool(parser->yytext) == NCJ_OK) @@ -420,7 +419,7 @@ NCJlex(NCJparser* parser) token = NCJ_UNDEF; goto done; } - count = ((parser->pos) - start) - 1; /* -1 for trailing quote */ + count = (size_t)((parser->pos) - start) - 1; /* -1 for trailing quote */ if(NCJyytext(parser,start,count)==NCJ_ERR) goto done; if(NCJunescape(parser)==NCJ_ERR) goto done; token = NCJ_STRING; @@ -641,7 +640,7 @@ NCJunescape(NCJparser* parser) { char* p = parser->yytext; char* q = p; - int c; + char c; for(;(c=*p++);) { if(c == NCJ_ESCAPE) { c = *p++; @@ -651,9 +650,9 @@ NCJunescape(NCJparser* parser) case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; - case NCJ_QUOTE: c = c; break; - case NCJ_ESCAPE: c = c; break; - default: c = c; break;/* technically not Json conformant */ + case NCJ_QUOTE: break; + case NCJ_ESCAPE: break; + default: break;/* technically not Json conformant */ } } *q++ = c; @@ -663,8 +662,8 @@ NCJunescape(NCJparser* parser) } /* Unescape a single character */ -static int -unescape1(int c) +static char +unescape1(char c) { switch (c) { case 'b': c = '\b'; break; @@ -672,7 +671,7 @@ unescape1(int c) case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; - default: c = c; break;/* technically not Json conformant */ + default: break;/* technically not Json conformant */ } return c; } @@ -1007,7 +1006,7 @@ static int escape(const char* text, NCJbuf* buf) { const char* p = text; - int c; + char c; for(;(c=*p++);) { char replace = 0; switch (c) { diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 01e48151ef..e5be032e46 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -143,7 +143,7 @@ ncuriparse(const char* uri0, NCURI** durip) NClist* params = nclistnew(); NClist* querylist = nclistnew(); size_t len0; - int pathchar; + char pathchar; if(uri0 == NULL) {THROW(NC_EURL);} @@ -899,7 +899,7 @@ ncrshift1(char* p) static const char* hexchars = "0123456789abcdefABCDEF"; static void -toHex(unsigned int b, char hex[2]) +toHex(char b, char hex[2]) { hex[0] = hexchars[(b >> 4) & 0xf]; hex[1] = hexchars[(b) & 0xf]; @@ -943,7 +943,7 @@ ncuriencodeonly(const char* s, const char* allowable) encoded = (char*)malloc((3*slen) + 1); /* max possible size */ for(inptr=s,outptr=encoded;*inptr;) { - int c = *inptr++; + char c = *inptr++; { /* search allowable */ char* p = strchr(allowable,c); diff --git a/libdispatch/ncxcache.c b/libdispatch/ncxcache.c index 40b82f81c4..11a8248c61 100644 --- a/libdispatch/ncxcache.c +++ b/libdispatch/ncxcache.c @@ -230,7 +230,7 @@ ncxcachenew(size_t leaflen, NCxcache** cachep) cache = calloc(1,sizeof(NCxcache)); if(cache == NULL) {stat = NC_ENOMEM; goto done;} - cache->map = ncexhashnew(leaflen); + cache->map = ncexhashnew((int)leaflen); if(cache->map == NULL) {stat = NC_ENOMEM; goto done;} cache->lru.next = &cache->lru; diff --git a/libsrc4/nc4var.c b/libsrc4/nc4var.c index d3d7c0048a..9da3a03ec9 100644 --- a/libsrc4/nc4var.c +++ b/libsrc4/nc4var.c @@ -1763,8 +1763,8 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) LOG((4, "%s: name %s dim %d DEFAULT_CHUNK_SIZE %d num_values %f type_size %d " "chunksize %ld", __func__, var->hdr.name, d, DEFAULT_CHUNK_SIZE, num_values, type_size, var->chunksizes[0])); } - if (var->ndims > 1 && var->ndims == num_unlim) { /* all dims unlimited */ - suggested_size = pow((double)DEFAULT_CHUNK_SIZE/type_size, 1.0/(double)(var->ndims)); + if (var->ndims > 1 && (float)var->ndims == num_unlim) { /* all dims unlimited */ + suggested_size = (size_t)pow((double)DEFAULT_CHUNK_SIZE/(double)type_size, 1.0/(double)(var->ndims)); for (d = 0; d < var->ndims; d++) { var->chunksizes[d] = suggested_size ? suggested_size : 1; @@ -1778,8 +1778,8 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) for (d = 0; d < var->ndims; d++) if (!var->chunksizes[d]) { - suggested_size = (pow((double)DEFAULT_CHUNK_SIZE/(num_values * type_size), - 1.0/(double)(var->ndims - num_unlim)) * var->dim[d]->len - .5); + suggested_size = (size_t)(pow((double)DEFAULT_CHUNK_SIZE/(num_values * (double)type_size), + 1.0/(double)((double)var->ndims - num_unlim)) * (double)var->dim[d]->len - .5); if (suggested_size > var->dim[d]->len) suggested_size = var->dim[d]->len; var->chunksizes[d] = suggested_size ? suggested_size : 1; From 46935565203e435849360a044df9df39444ce208 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Mon, 8 Apr 2024 13:13:08 +0200 Subject: [PATCH 40/48] Rename the vendored strlcat symbol Fixes #927 --- include/ncconfigure.h | 3 ++- libdispatch/dmissing.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/ncconfigure.h b/include/ncconfigure.h index 496ec59e03..214b8150f6 100644 --- a/include/ncconfigure.h +++ b/include/ncconfigure.h @@ -69,7 +69,8 @@ char* strdup(const char*); #ifndef HAVE_STRLCAT #ifndef strlcat -size_t strlcat(char*,const char*,size_t); +#define strlcat nc_strlcat +size_t nc_strlcat(char*,const char*,size_t); #endif #endif diff --git a/libdispatch/dmissing.c b/libdispatch/dmissing.c index b53335cef0..42c2d773ec 100644 --- a/libdispatch/dmissing.c +++ b/libdispatch/dmissing.c @@ -117,7 +117,7 @@ strlcpy(char *dst, const char* src, size_t dsize) * If retval >= dsize, truncation occurred. */ size_t -strlcat(char* dst, const char* src, size_t dsize) +nc_strlcat(char* dst, const char* src, size_t dsize) { const char *odst = dst; const char *osrc = src; From 27989486706479a90ddcd24be6173613f3a64d4d Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 8 Apr 2024 10:34:22 -0600 Subject: [PATCH 41/48] Remove check for libcurl unless it is necessary for required functionality. --- CMakeLists.txt | 3 +- cmake/dependencies.cmake | 187 ++++++++++++++++++++------------------- liblib/CMakeLists.txt | 2 +- 3 files changed, 101 insertions(+), 91 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47527d16b5..1e19d1871d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -468,6 +468,7 @@ message(">>> NETCDF_ENABLE_REMOTE_FUNCTIONALITY=${NETCDF_ENABLE_REMOTE_FUNCTIONA if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY) message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP[4]=NO") set(NETCDF_ENABLE_DAP OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP=NO" FORCE) +set(NETCDF_ENABLE_DAP2 OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP2=NO" FORCE) set(NETCDF_ENABLE_DAP4 OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_DAP4=NO" FORCE) endif() @@ -544,7 +545,7 @@ else() endif() # Option to support byte-range reading of remote datasets -option(NETCDF_ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." ON) +option(NETCDF_ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." ${ENABLE_DAP}) if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY) message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO") set(NETCDF_ENABLE_BYTERANGE OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO" FORCE) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index f58b65ee6e..2294c272bc 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -214,101 +214,110 @@ if(USE_HDF5) endif(USE_HDF5) ################################ -# Curl +# Curl Libraryies +# Only needed for DAP (DAP2 or DAP4) +# and NCZARR with S3 Support ################################ -# See if we have libcurl -find_package(CURL) -#target_compile_options(netcdf -# PRIVATE -# -DCURL_STATICLIB=1 -#) -#target_include_directories(netcdf -# PRIVATE -# ${CURL_INCLUDE_DIRS} -#) -if(CURL_FOUND) - set(FOUND_CURL TRUE) - target_link_libraries(netcdf - PRIVATE - CURL::libcurl -) -else() - set(FOUND_CURL FALSE) - set(NETCDF_ENABLE_DAP2 OFF) - set(NETCDF_ENABLE_DAP4 OFF) - set(NETCDF_ENABLE_BYTERANGE OFF) - set(NETCDF_ENABLE_S3 OFF) -endif(CURL_FOUND) - -# Start disabling if curl not found -if(NOT FOUND_CURL) - message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling") - set(NETCDF_ENABLE_REMOTE_FUNCTIONALITY OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling" FORCE ) -endif() - -set (CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS}) -# Check to see if we have libcurl 7.66 or later -CHECK_C_SOURCE_COMPILES(" -#include -int main() { -#if LIBCURL_VERSION_NUM < 0x074200 - choke me; -#endif -}" HAVE_LIBCURL_766) - -IF (HAVE_LIBCURL_766) - # If libcurl version is >= 7.66, then can skip tests - # for these symbols which were added in an earlier version - set(HAVE_CURLOPT_USERNAME TRUE) - set(HAVE_CURLOPT_PASSWORD TRUE) - set(HAVE_CURLOPT_KEYPASSWD TRUE) - set(HAVE_CURLINFO_RESPONSE_CODE TRUE) - set(HAVE_CURLINFO_HTTP_CONNECTCODE TRUE) - set(HAVE_CURLOPT_BUFFERSIZE TRUE) - set(HAVE_CURLOPT_KEEPALIVE TRUE) -else() - # Check to see if CURLOPT_USERNAME is defined. - # It is present starting version 7.19.1. - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLOPT_USERNAME;}" HAVE_CURLOPT_USERNAME) - # Check to see if CURLOPT_PASSWORD is defined. - # It is present starting version 7.19.1. - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLOPT_PASSWORD;}" HAVE_CURLOPT_PASSWORD) - - # Check to see if CURLOPT_KEYPASSWD is defined. - # It is present starting version 7.16.4. - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLOPT_KEYPASSWD;}" HAVE_CURLOPT_KEYPASSWD) - - # Check to see if CURLINFO_RESPONSE_CODE is defined. - # It showed up in curl 7.10.7. - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLINFO_RESPONSE_CODE;}" HAVE_CURLINFO_RESPONSE_CODE) - - # Check to see if CURLINFO_HTTP_CONNECTCODE is defined. - # It showed up in curl 7.10.7. - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLINFO_HTTP_CONNECTCODE;}" HAVE_CURLINFO_HTTP_CONNECTCODE) - - # Check to see if CURLOPT_BUFFERSIZE is defined. - # It is present starting version 7.59 - CHECK_C_SOURCE_COMPILES(" - #include - int main() {int x = CURLOPT_BUFFERSIZE;}" HAVE_CURLOPT_BUFFERSIZE) +if( (NETCDF_ENABLE_DAP AND (NETCDF_ENABLE_DAP2 OR NETCDF_ENABLE_DAP4 OR NETCDF_ENABLE_BYTERANGE_SUPPORT)) OR (NETCDF_ENABLE_NCZARR AND NETCDF_ENABLENCZARR_S3)) + + # See if we have libcurl + find_package(CURL) + #target_compile_options(netcdf + # PRIVATE + # -DCURL_STATICLIB=1 + #) + #target_include_directories(netcdf + # PRIVATE + # ${CURL_INCLUDE_DIRS} + #) + if(CURL_FOUND) + set(FOUND_CURL TRUE) + target_link_libraries(netcdf + PRIVATE + CURL::libcurl + ) + else() + set(FOUND_CURL FALSE) + set(NETCDF_ENABLE_DAP2 OFF) + set(NETCDF_ENABLE_DAP4 OFF) + set(NETCDF_ENABLE_BYTERANGE OFF) + set(NETCDF_ENABLE_S3 OFF) + endif(CURL_FOUND) + + # Start disabling if curl not found + if(NOT FOUND_CURL) + message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling") + set(NETCDF_ENABLE_REMOTE_FUNCTIONALITY OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY requires libcurl; disabling" FORCE ) + endif() - # Check to see if CURLOPT_TCP_KEEPALIVE is defined. - # It is present starting version 7.25 + set (CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS}) + # Check to see if we have libcurl 7.66 or later CHECK_C_SOURCE_COMPILES(" #include - int main() {int x = CURLOPT_TCP_KEEPALIVE;}" HAVE_CURLOPT_KEEPALIVE) + int main() { + #if LIBCURL_VERSION_NUM < 0x074200 + choke me; + #endif + }" HAVE_LIBCURL_766) + + IF (HAVE_LIBCURL_766) + # If libcurl version is >= 7.66, then can skip tests + # for these symbols which were added in an earlier version + set(HAVE_CURLOPT_USERNAME TRUE) + set(HAVE_CURLOPT_PASSWORD TRUE) + set(HAVE_CURLOPT_KEYPASSWD TRUE) + set(HAVE_CURLINFO_RESPONSE_CODE TRUE) + set(HAVE_CURLINFO_HTTP_CONNECTCODE TRUE) + set(HAVE_CURLOPT_BUFFERSIZE TRUE) + set(HAVE_CURLOPT_KEEPALIVE TRUE) + else() + # Check to see if CURLOPT_USERNAME is defined. + # It is present starting version 7.19.1. + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLOPT_USERNAME;}" HAVE_CURLOPT_USERNAME) + + # Check to see if CURLOPT_PASSWORD is defined. + # It is present starting version 7.19.1. + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLOPT_PASSWORD;}" HAVE_CURLOPT_PASSWORD) + + # Check to see if CURLOPT_KEYPASSWD is defined. + # It is present starting version 7.16.4. + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLOPT_KEYPASSWD;}" HAVE_CURLOPT_KEYPASSWD) + + # Check to see if CURLINFO_RESPONSE_CODE is defined. + # It showed up in curl 7.10.7. + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLINFO_RESPONSE_CODE;}" HAVE_CURLINFO_RESPONSE_CODE) + + # Check to see if CURLINFO_HTTP_CONNECTCODE is defined. + # It showed up in curl 7.10.7. + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLINFO_HTTP_CONNECTCODE;}" HAVE_CURLINFO_HTTP_CONNECTCODE) + + # Check to see if CURLOPT_BUFFERSIZE is defined. + # It is present starting version 7.59 + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLOPT_BUFFERSIZE;}" HAVE_CURLOPT_BUFFERSIZE) + + # Check to see if CURLOPT_TCP_KEEPALIVE is defined. + # It is present starting version 7.25 + CHECK_C_SOURCE_COMPILES(" + #include + int main() {int x = CURLOPT_TCP_KEEPALIVE;}" HAVE_CURLOPT_KEEPALIVE) + endif() endif() +################################ +# End LibCurl stuff +################################ ################################ # Math diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt index e0fe9f5c92..cc482d5461 100644 --- a/liblib/CMakeLists.txt +++ b/liblib/CMakeLists.txt @@ -148,7 +148,7 @@ if(USE_HDF5) endif() if(FOUND_CURL) - set(TLL_LIBS ${TLL_LIBS} CURL::libcurl ${CURL_LIBRARIES}) + set(TLL_LIBS ${TLL_LIBS} CURL::libcurl) endif() if(USE_HDF4) From 610afe8c2c70e017ba99290b25f482dcc1bf3832 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 8 Apr 2024 11:51:52 -0600 Subject: [PATCH 42/48] Correct typo. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e19d1871d..ee5e729ee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,7 +545,7 @@ else() endif() # Option to support byte-range reading of remote datasets -option(NETCDF_ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." ${ENABLE_DAP}) +option(NETCDF_ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." ${NETCDF_ENABLE_DAP}) if(NOT NETCDF_ENABLE_REMOTE_FUNCTIONALITY) message(WARNING "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO") set(NETCDF_ENABLE_BYTERANGE OFF CACHE BOOL "NETCDF_ENABLE_REMOTE_FUNCTIONALITY=NO => NETCDF_ENABLE_BYTERANGE=NO" FORCE) From c2c6129980dcc092bfaffd349871493d7d25932d Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 8 Apr 2024 14:38:19 -0600 Subject: [PATCH 43/48] Attempt to fix zlib-related error in appveyor. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ed3ca77a07..9ce8112085 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,7 +26,7 @@ install: - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat - cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - cmd: conda update conda - - cmd: conda install hdf5=1.8.18 curl hdf4 + - cmd: conda install hdf5=1.8.18 curl hdf4 zlib configuration: Release From 1081d2931f8ab4fed7c0d33fcac68fe684acb37d Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 8 Apr 2024 14:43:44 -0600 Subject: [PATCH 44/48] Add cmake prefix path to appveyor config. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9ce8112085..6e4b476744 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,7 +36,7 @@ build: off build_script: - cmd: mkdir build - cmd: cd build - - cmd: cmake .. -G "%CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_LOC% -DNETCDF_ENABLE_BASH_SCRIPT_TESTING=OFF -DNETCDF_ENABLE_FILTER_TESTING=OFF -DNETCDF_ENABLE_BYTERANGE=ON + - cmd: cmake .. -G "%CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_LOC% -DNETCDF_ENABLE_BASH_SCRIPT_TESTING=OFF -DNETCDF_ENABLE_FILTER_TESTING=OFF -DNETCDF_ENABLE_BYTERANGE=ON -DCMAKE_PREFIX_PATH=%CONDA_INSTALL_LOCN% - cmd: if errorlevel 1 exit 1 - cmd: cmake --build . --config Release -- /maxcpucount:4 From cdfe909a1aa145c47648d7df6e54b0f08691da12 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 17 Apr 2024 13:29:18 -0500 Subject: [PATCH 45/48] Add CI for a Windows Runner on Github Actions. --- .github/workflows/main-cmake.yml | 163 +++++++++++++++++++++ .github/workflows/run_tests_cdash.yml | 12 +- .github/workflows/run_tests_osx.yml | 24 +-- .github/workflows/run_tests_s3.yml | 8 +- .github/workflows/run_tests_ubuntu.yml | 38 ++--- .github/workflows/run_tests_win_cygwin.yml | 2 +- .github/workflows/run_tests_win_mingw.yml | 2 +- libdispatch/dmissing.c | 2 +- libdispatch/ncrandom.c | 2 +- ncdump/tst_bom.sh | 13 +- nczarr_test/run_nccopyz.sh | 11 +- 11 files changed, 227 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/main-cmake.yml diff --git a/.github/workflows/main-cmake.yml b/.github/workflows/main-cmake.yml new file mode 100644 index 0000000000..70432e5c4a --- /dev/null +++ b/.github/workflows/main-cmake.yml @@ -0,0 +1,163 @@ +name: NetCDF-C CMake CI - Windows + +on: [pull_request, workflow_dispatch] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + + cmake_build_and_test: + strategy: + + matrix: + name: + - "Windows MSVC" + hdf5: + - "1.14.3" + + # Visual Studio + CMake + include: + - name: "Windows MSVC" + os: windows-latest + generator: "-G \"Visual Studio 17 2022\"" + + name: "${{ matrix.name }}" + + runs-on: ${{ matrix.os }} + + # Each step in the job. + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + steps: + - uses: msys2/setup-msys2@v2 + with: + update: true + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + activate-environment: "" + auto-activate-base: true + + - name: Set up Paths and env + shell: bash -el {0} + run: | + echo "" >> ~/.bash_profile + cat ~/.bash_profile + + + - name: Dump Matrix Context + run: echo '${{ toJSON(matrix) }}' + + #- run: echo "CMAKE_PREFIX_PATH=${env.CONDA_PREFIX}/Library" >> $GITHUB_ENV + #- run: echo "/c/Users/runneradmin/miniconda3/Library/lib:${GITHUB_PATH}" >> $GITHUB_ENV + #- run: echo "" + #- run: echo "CTEST_OUTPUT_ON_FAILURE=1" >> $GITHUB_ENV + + # Grab miniconda and use it to install HDF5 + - name: Install Dependencies using Miniconda + run: | + conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + conda config --add channels conda-forge + conda update conda + conda install hdf5=${{ matrix.hdf5 }} m2-m4 libxml2 + shell: bash -el {0} + + # Double-check something + - name: Check Miniconda + run: | + which h5dump + which m4 + shell: bash -el {0} + + # Check current directory + - name: Query Current Environment + run: | + ls + echo "" + echo "PATH: $PATH" + echo "" + env + echo "" + ls $CONDA_PREFIX/Library + echo "" + ls $CONDA_PREFIX/Library/include/ + shell: bash -el {0} + + - name: Perform out-of-directory configuration + shell: bash -el {0} + run: | + mkdir build + cd build + cmake .. -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}/Library" -DCMAKE_C_FLAGS="-I${CONDA_PREFIX}/Library/include" -DCMAKE_INSTALL_PREFIX=~/tmp -DNETCDF_ENABLE_FILTER_TESTING=OFF + if: ${{ success() }} + + - name: View cache - configuration + shell: bash -el {0} + run: | + cd build + cmake -L . + if: ${{ success() }} + + - name: Print Summary + shell: bash -el {0} + run: | + cd build + cat libnetcdf.settings + + - name: Perform out-of-directory build - libnetcdf + shell: bash -el {0} + run: | + cd build + cmake --build . --config Release --target netcdf -j 4 + + - name: Perform out-of-directory install - libnetcdf + shell: bash -el {0} + run: | + cd build + cmake --build . --config Release --target install -j 4 + if: ${{ success() }} + + - name: View config.h - libnetcdf failure + shell: bash -el {0} + run: | + cd build + cat config.h + if: ${{ failure() }} + + - name: Perform out-of-directory build - test suite + shell: bash -el {0} + run: | + cd build + cmake --build . --config Release -j 4 + if: ${{ success() }} + + - name: View config.h - tests failure failure + shell: bash -el {0} + run: | + cd build + cat config.h + if: ${{ failure() }} + + - name: Prepare ctest Paths and env + shell: bash -el {0} + run: | + cat ~/.bash_profile + echo "" >> ~/.bash_profile + + - name: Run ctest + shell: bash -el {0} + run: | + echo "Run ctest PATH: $PATH" + echo "Run ctest combined PATH: $PATH" + echo "Run ctest combined GITHUB_PATH: $PATH" + cd build + PATH=~/tmp/bin:$PATH ctest . -j 4 -E 'bom' --output-on-failure + + - name: Verbose Output if CTest Failure + shell: bash -el {0} + run: | + cd build + PATH=~/tmp/bin:$PATH ctest . --rerun-failed --output-on-failure -VV + if: ${{ failure() }} \ No newline at end of file diff --git a/.github/workflows/run_tests_cdash.yml b/.github/workflows/run_tests_cdash.yml index 5dd5c85cbc..1d135a1b04 100644 --- a/.github/workflows/run_tests_cdash.yml +++ b/.github/workflows/run_tests_cdash.yml @@ -21,7 +21,7 @@ jobs: hdf5: [ 1.10.8, 1.12.2, 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -32,7 +32,7 @@ jobs: ### - name: Cache libhdf5-${{ matrix.hdf5 }} id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -70,7 +70,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -81,7 +81,7 @@ jobs: ### - name: Cache libhdf5-parallel-${{ matrix.hdf5 }} id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-parallel-${{ runner.os }}-${{ matrix.hdf5 }} @@ -129,7 +129,7 @@ jobs: hdf5: [ 1.10.8, 1.12.2, 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: CDASH_TOKEN: ${{ secrets.CDASH_TOKEN }} env: @@ -153,7 +153,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} diff --git a/.github/workflows/run_tests_osx.yml b/.github/workflows/run_tests_osx.yml index 04ea6740c7..ba64c777c2 100644 --- a/.github/workflows/run_tests_osx.yml +++ b/.github/workflows/run_tests_osx.yml @@ -24,14 +24,14 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # libhdf5 ### - name: Cache libhdf5-${{ runner.os }}-${{ matrix.hdf5 }} id: cache-hdf5-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -62,7 +62,7 @@ jobs: use_nczarr: [ nczarr_off, nczarr_on ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # Set Environmental Variables @@ -94,7 +94,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -168,7 +168,7 @@ jobs: use_nczarr: [ nczarr_off, nczarr_on ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # Set Environmental Variables @@ -200,7 +200,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -260,7 +260,7 @@ jobs: hdf5: [ 1.12.2, 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # Set Environmental Variables @@ -277,7 +277,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -342,7 +342,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # Set Environmental Variables @@ -357,7 +357,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -416,7 +416,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 ### # Set Environmental Variables @@ -432,7 +432,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5-osx - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} diff --git a/.github/workflows/run_tests_s3.yml b/.github/workflows/run_tests_s3.yml index 61af997dc0..b7f9d3fe6f 100644 --- a/.github/workflows/run_tests_s3.yml +++ b/.github/workflows/run_tests_s3.yml @@ -26,7 +26,7 @@ jobs: hdf5: [ 1.10.8, 1.12.2, 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -37,7 +37,7 @@ jobs: ### - name: Cache libhdf5-${{ matrix.hdf5 }} id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -73,7 +73,7 @@ jobs: hdf5: [ 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -94,7 +94,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} diff --git a/.github/workflows/run_tests_ubuntu.yml b/.github/workflows/run_tests_ubuntu.yml index 186f8da180..a755db876e 100644 --- a/.github/workflows/run_tests_ubuntu.yml +++ b/.github/workflows/run_tests_ubuntu.yml @@ -21,7 +21,7 @@ jobs: hdf5: [ 1.10.8, 1.12.2, 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -32,7 +32,7 @@ jobs: ### - name: Cache libhdf5-${{ matrix.hdf5 }} id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -70,7 +70,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -81,7 +81,7 @@ jobs: ### - name: Cache libhdf5-parallel-${{ matrix.hdf5 }} id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-parallel-${{ runner.os }}-${{ matrix.hdf5 }} @@ -131,7 +131,7 @@ jobs: hdf5: [ 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -152,7 +152,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -226,7 +226,7 @@ jobs: hdf5: [ 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -247,7 +247,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -322,7 +322,7 @@ jobs: hdf5: [ 1.14.3 ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -338,7 +338,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-parallel-${{ runner.os }}-${{ matrix.hdf5 }} @@ -403,7 +403,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -422,7 +422,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -483,7 +483,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -503,7 +503,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -565,7 +565,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -584,7 +584,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-parallel-${{ runner.os }}-${{ matrix.hdf5 }} @@ -699,7 +699,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} @@ -808,7 +808,7 @@ jobs: use_nczarr: [ nczarr_off, nczarr_on ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install System dependencies shell: bash -l {0} @@ -842,7 +842,7 @@ jobs: - name: Fetch HDF Cache id: cache-hdf5 - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/environments/${{ matrix.hdf5 }} key: hdf5-${{ runner.os }}-${{ matrix.hdf5 }} diff --git a/.github/workflows/run_tests_win_cygwin.yml b/.github/workflows/run_tests_win_cygwin.yml index 6e124448ed..e7a4d8002a 100644 --- a/.github/workflows/run_tests_win_cygwin.yml +++ b/.github/workflows/run_tests_win_cygwin.yml @@ -28,7 +28,7 @@ jobs: - name: Fix line endings run: git config --global core.autocrlf input - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: cygwin/cygwin-install-action@v2 with: diff --git a/.github/workflows/run_tests_win_mingw.yml b/.github/workflows/run_tests_win_mingw.yml index 978275cf6c..db0be3748e 100644 --- a/.github/workflows/run_tests_win_mingw.yml +++ b/.github/workflows/run_tests_win_mingw.yml @@ -26,7 +26,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: msystem: MINGW64 diff --git a/libdispatch/dmissing.c b/libdispatch/dmissing.c index 42c2d773ec..0c9be82745 100644 --- a/libdispatch/dmissing.c +++ b/libdispatch/dmissing.c @@ -44,7 +44,7 @@ strdup(const char* s) #endif -#ifndef WIN32 +#if !defined(_MSC_VER) && !defined(WIN32) #ifndef HAVE_STRLCPY /* diff --git a/libdispatch/ncrandom.c b/libdispatch/ncrandom.c index bfb1fbe3ca..7575aa72ad 100644 --- a/libdispatch/ncrandom.c +++ b/libdispatch/ncrandom.c @@ -19,7 +19,7 @@ int main() { unsigned int urnd = 0; /* range 0..2147483647 */ -#ifdef WIN32 +#if defined(WIN32) || defined(_MSC_VER) (void)rand_s(&urnd); #else long rnd; diff --git a/ncdump/tst_bom.sh b/ncdump/tst_bom.sh index 63eb38d88d..9b11b9ab70 100755 --- a/ncdump/tst_bom.sh +++ b/ncdump/tst_bom.sh @@ -6,7 +6,7 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi # This shell script tests BOM support in ncgen set -e - +set -x # add hack for sunos export srcdir; @@ -28,7 +28,13 @@ echo "*** Generate a cdl file with leading UTF-8 BOM." ${execdir}/bom 8 >tst_bom8.cdl cat tst_bom.cdl >> tst_bom8.cdl +echo "" +echo "Viewing tst_bom8.cdl:" +cat tst_bom8.cdl +echo "" + echo "*** Verify .nc file" + ${NCGEN} -k nc3 -o tst_bom8.nc tst_bom8.cdl ${NCDUMP} -n tst_bom tst_bom8.nc > tmp_bom.cdl diff -w tst_bom.cdl tmp_bom.cdl @@ -40,6 +46,11 @@ rm -f tmp_bom.cdl tst_bom8.* tst_bom16.* echo "*** Generate a cdl file with leading UTF-16 BOM." ${execdir}/bom 16 >tst_bom16.cdl cat tst_bom.cdl >> tst_bom16.cdl +echo "" +echo "Viewing tst_bom16.cdl:" +cat tst_bom16.cdl +echo "" + echo "*** Verify UTF-16 file fails" if ${NCGEN} -k nc3 -o tst_bom16.nc tst_bom16.cdl ; then diff --git a/nczarr_test/run_nccopyz.sh b/nczarr_test/run_nccopyz.sh index 66b4286cd7..113f86085b 100755 --- a/nczarr_test/run_nccopyz.sh +++ b/nczarr_test/run_nccopyz.sh @@ -22,7 +22,7 @@ verifychunking() { f=$1 shift for t in "$@" ; do - x=`cat $f | tr -d "\t \r" | sed -e "/$t/p" -ed` + x=`cat $f | tr -d "[:space:]" | sed -e "/$t/p" -ed` if test "x$x" = x ; then echo "$f: $t not found"; exit 1; fi done } @@ -71,9 +71,12 @@ fileargs tmp_pds ${NCCOPY} -M0 -4 -c "time/10,lat/15,lon/20" "$SRC" "$fileurl" ${NCDUMP} -n tmp_pds -hs "$fileurl" > tmp_pds.cdl -STORAGE=`cat tmp_pds.cdl | sed -e "/tas:_Storage/p" -ed | tr '"' "'" | tr -d "\t \r"` -test "x$STORAGE" = "xtas:_Storage='chunked';" -CHUNKSIZES=`cat tmp_pds.cdl | sed -e "/tas:_ChunkSizes/p" -ed | tr -d "\t \r"` + +STORAGE=`cat tmp_pds.cdl | sed -e "/tas:_Storage/p" -ed | tr -d "[:space:]"` +echo "STORAGE: $STORAGE" + +test "x$STORAGE" = "xtas:_Storage='chunked';" || test "x$STORAGE" = "xtas:_Storage=\"chunked\";" +CHUNKSIZES=`cat tmp_pds.cdl | sed -e "/tas:_ChunkSizes/p" -ed | tr -d "[:space:]"` test "x$CHUNKSIZES" = "xtas:_ChunkSizes=10,15,20;" } From e153c8a81d3cbcc4f9889983f683d04b3aa9e86c Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 17 Apr 2024 13:33:55 -0500 Subject: [PATCH 46/48] Remove appveyor config file. --- appveyor.yml | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 6e4b476744..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -image: Visual Studio 2019 - -environment: - matrix: - - TARGET_ARCH: x64 - CONDA_INSTALL_LOCN: C:\\Miniconda-x64 - MSYS2_INSTALL_LOCN: C:\msys64 - MSYS2_BIN_LOCN: C:\msys64\usr\bin - CMAKE_GENERATOR: "Visual Studio 16" - -platform: - - x64 - -branches: - except: -# - /.*[.]dmh/ - - /.*[.]wif/ - -# Do not build feature branch with open Pull Requests -skip_branch_with_pr: true - -install: - - cmd: set SRC_DIR=%cd% - - cmd: set INSTALL_LOC=%SRC_DIR%\install - - cmd: set PATH=%PATH%;%MSYS2_BIN_LOCN%;%INSTALL_LOC%\bin;%INSTALL_LOC%\lib - - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat - - cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - - cmd: conda update conda - - cmd: conda install hdf5=1.8.18 curl hdf4 zlib - -configuration: Release - -build: off - -# Run a custom script. -build_script: - - cmd: mkdir build - - cmd: cd build - - cmd: cmake .. -G "%CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%INSTALL_LOC% -DNETCDF_ENABLE_BASH_SCRIPT_TESTING=OFF -DNETCDF_ENABLE_FILTER_TESTING=OFF -DNETCDF_ENABLE_BYTERANGE=ON -DCMAKE_PREFIX_PATH=%CONDA_INSTALL_LOCN% - - cmd: if errorlevel 1 exit 1 - - cmd: cmake --build . --config Release -- /maxcpucount:4 - -test_script: - - cmd: cmake --build . --config Release --target install -- /maxcpucount:4 From c26f7eabf4a1cd25353f22734f439505fe636a45 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 24 Apr 2024 11:38:07 -0600 Subject: [PATCH 47/48] Refactor macro _FillValue to NC_FillValue in support of https://github.com/Unidata/netcdf-c/issues/2858 --- include/netcdf.h | 2 +- libhdf5/hdf5attr.c | 2 +- libhdf5/hdf5var.c | 6 +++--- libnczarr/zattr.c | 6 +++--- libnczarr/zvar.c | 6 +++--- libsrc/nc3internal.c | 2 +- libsrc/putget.m4 | 2 +- libsrc/var.c | 6 +++--- nc_test/t_nc.c | 6 +++--- nc_test4/tst_elatefill.c | 2 +- nc_test4/tst_h_scalar.c | 6 +++--- nc_test4/tst_quantize.c | 4 ++-- nc_test4/tst_strings.c | 2 +- nc_test4/tst_vars.c | 4 ++-- nc_test4/tst_vars2.c | 38 +++++++++++++++++++------------------- ncdump/ncdump.c | 6 +++--- ncdump/tst_nans.c | 2 +- ncgen3/ncgeny.c | 4 ++-- 18 files changed, 53 insertions(+), 53 deletions(-) diff --git a/include/netcdf.h b/include/netcdf.h index d29a134558..5b856d2799 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -110,7 +110,7 @@ extern "C" { * the same type as the variable and this reserved name. The value you * give the attribute will be used as the fill value for that * variable. */ -#define _FillValue "_FillValue" +#define NC_FillValue "_FillValue" #define NC_FILL 0 /**< Argument to nc_set_fill() to clear NC_NOFILL */ #define NC_NOFILL 0x100 /**< Argument to nc_set_fill() to turn off filling of data. */ diff --git a/libhdf5/hdf5attr.c b/libhdf5/hdf5attr.c index 795bce81f9..e8c80fc174 100644 --- a/libhdf5/hdf5attr.c +++ b/libhdf5/hdf5attr.c @@ -564,7 +564,7 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type, * Since fill mismatch is no longer required, we need to convert the * att's type to the vars's type as part of storing. */ - if (!strcmp(att->hdr.name, _FillValue) && varid != NC_GLOBAL) + if (!strcmp(att->hdr.name, NC_FillValue) && varid != NC_GLOBAL) { /* Fill value must have exactly one value */ if (len != 1) diff --git a/libhdf5/hdf5var.c b/libhdf5/hdf5var.c index aaf48140e9..4ba7fa5cfb 100644 --- a/libhdf5/hdf5var.c +++ b/libhdf5/hdf5var.c @@ -673,17 +673,17 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *unused1, var->hdr.name)); /* If there's a _FillValue attribute, delete it. */ - retval = NC4_HDF5_del_att(ncid, varid, _FillValue); + retval = NC4_HDF5_del_att(ncid, varid, NC_FillValue); if (retval && retval != NC_ENOTATT) return retval; /* Create a _FillValue attribute; will also fill in var->fill_value */ - if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id, + if ((retval = nc_put_att(ncid, varid, NC_FillValue, var->type_info->hdr.id, 1, fill_value))) return retval; } else if (var->fill_value && no_fill && (*no_fill)) { /* Turning off fill value? */ /* If there's a _FillValue attribute, delete it. */ - retval = NC4_HDF5_del_att(ncid, varid, _FillValue); + retval = NC4_HDF5_del_att(ncid, varid, NC_FillValue); if (retval && retval != NC_ENOTATT) return retval; if((retval = NC_reclaim_data_all(h5->controller,var->type_info->hdr.id,var->fill_value,1))) return retval; var->fill_value = NULL; diff --git a/libnczarr/zattr.c b/libnczarr/zattr.c index 23fbb04281..29d8e693fb 100644 --- a/libnczarr/zattr.c +++ b/libnczarr/zattr.c @@ -581,7 +581,7 @@ ncz_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type, * copy the value to the fill_value pointer of the NC_VAR_INFO_T * struct for this var. (But ignore a global _FillValue * attribute). Also kill the cache fillchunk as no longer valid */ - if (!strcmp(att->hdr.name, _FillValue) && varid != NC_GLOBAL) + if (!strcmp(att->hdr.name, NC_FillValue) && varid != NC_GLOBAL) { /* Fill value must have exactly one value */ if (len != 1) @@ -991,12 +991,12 @@ ncz_create_fillvalue(NC_VAR_INFO_T* var) /* Make sure _FillValue does not exist */ for(i=0;iatt);i++) { fv = (NC_ATT_INFO_T*)ncindexith(var->att,i); - if(strcmp(fv->hdr.name,_FillValue)==0) break; + if(strcmp(fv->hdr.name,NC_FillValue)==0) break; fv = NULL; } if(fv == NULL) { /* Create it */ - if((stat = ncz_makeattr((NC_OBJ*)var,var->att,_FillValue,var->type_info->hdr.id,1,var->fill_value,&fv))) + if((stat = ncz_makeattr((NC_OBJ*)var,var->att,NC_FillValue,var->type_info->hdr.id,1,var->fill_value,&fv))) goto done; } } diff --git a/libnczarr/zvar.c b/libnczarr/zvar.c index b10df70c02..eb26eb7eda 100644 --- a/libnczarr/zvar.c +++ b/libnczarr/zvar.c @@ -727,19 +727,19 @@ ncz_def_var_extra(int ncid, int varid, int *shuffle, int *unused1, var->hdr.name)); /* If there's a _FillValue attribute, delete it. */ - retval = NCZ_del_att(ncid, varid, _FillValue); + retval = NCZ_del_att(ncid, varid, NC_FillValue); if (retval && retval != NC_ENOTATT) goto done; /* Create a _FillValue attribute; will also fill in var->fill_value */ - if ((retval = nc_put_att(ncid, varid, _FillValue, var->type_info->hdr.id, + if ((retval = nc_put_att(ncid, varid, NC_FillValue, var->type_info->hdr.id, 1, fill_value))) goto done; /* Reclaim any existing fill_chunk */ if((retval = NCZ_reclaim_fill_chunk(zvar->cache))) goto done; } else if (var->fill_value && no_fill && (*no_fill)) { /* Turning off fill value? */ /* If there's a _FillValue attribute, delete it. */ - retval = NCZ_del_att(ncid, varid, _FillValue); + retval = NCZ_del_att(ncid, varid, NC_FillValue); if (retval && retval != NC_ENOTATT) return retval; if((retval = NCZ_reclaim_fill_value(var))) return retval; } diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c index f6968dc463..3fced4746a 100644 --- a/libsrc/nc3internal.c +++ b/libsrc/nc3internal.c @@ -1726,7 +1726,7 @@ NC3_inq_var_fill(const NC_var *varp, void *fill_value) /* * find fill value */ - attrpp = NC_findattr(&varp->attrs, _FillValue); + attrpp = NC_findattr(&varp->attrs, NC_FillValue); if ( attrpp != NULL ) { const void *xp; /* User defined fill value */ diff --git a/libsrc/putget.m4 b/libsrc/putget.m4 index c8d713880e..927ec854f9 100644 --- a/libsrc/putget.m4 +++ b/libsrc/putget.m4 @@ -156,7 +156,7 @@ fill_NC_var(NC3_INFO* ncp, const NC_var *varp, long long varsize, size_t recno) /* * Set up fill value */ - attrpp = NC_findattr(&varp->attrs, _FillValue); + attrpp = NC_findattr(&varp->attrs, NC_FillValue); if( attrpp != NULL ) { /* User defined fill value */ diff --git a/libsrc/var.c b/libsrc/var.c index 6b636e1cdb..ea126359ac 100644 --- a/libsrc/var.c +++ b/libsrc/var.c @@ -720,7 +720,7 @@ NC3_inq_var(int ncid, if (no_fillp != NULL) *no_fillp = varp->no_fill; if (fill_valuep != NULL) { - status = nc_get_att(ncid, varid, _FillValue, fill_valuep); + status = nc_get_att(ncid, varid, NC_FillValue, fill_valuep); if (status != NC_NOERR && status != NC_ENOTATT) return status; if (status == NC_ENOTATT) { @@ -854,12 +854,12 @@ NC3_def_var_fill(int ncid, if (fill_value != NULL && !varp->no_fill) { /* If there's a _FillValue attribute, delete it. */ - status = NC3_del_att(ncid, varid, _FillValue); + status = NC3_del_att(ncid, varid, NC_FillValue); if (status != NC_NOERR && status != NC_ENOTATT) return status; /* Create/overwrite attribute _FillValue */ - status = NC3_put_att(ncid, varid, _FillValue, varp->type, 1, fill_value, varp->type); + status = NC3_put_att(ncid, varid, NC_FillValue, varp->type, 1, fill_value, varp->type); if (status != NC_NOERR) return status; } diff --git a/nc_test/t_nc.c b/nc_test/t_nc.c index 064335d98c..27301a4555 100644 --- a/nc_test/t_nc.c +++ b/nc_test/t_nc.c @@ -147,7 +147,7 @@ static const char * const reqattr[] = { "SCALEMIN", "SCALEMAX", "FIELDNAM", - _FillValue + NC_FillValue }; #define NUM_RATTRS 6 @@ -399,9 +399,9 @@ main(int argc, char *argv[]) { int ifill = -1; double dfill = -9999; assert( nc_put_att_int(id, Long_id, - _FillValue, NC_INT, 1, &ifill) == NC_NOERR); + NC_FillValue, NC_INT, 1, &ifill) == NC_NOERR); assert( nc_put_att_double(id, Double_id, - _FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR); + NC_FillValue, NC_DOUBLE, 1, &dfill) == NC_NOERR); } #ifdef REDEF diff --git a/nc_test4/tst_elatefill.c b/nc_test4/tst_elatefill.c index 9b24747732..acdddc4887 100644 --- a/nc_test4/tst_elatefill.c +++ b/nc_test4/tst_elatefill.c @@ -36,7 +36,7 @@ main(int argc, char **argv) /* try put attribute _FillValue and expect NC_ELATEFILL */ fillv = 9; - err = nc_put_att_int(ncid, varid, _FillValue, NC_INT, 1, &fillv); + err = nc_put_att_int(ncid, varid, NC_FillValue, NC_INT, 1, &fillv); if (err != NC_ELATEFILL) printf("line %d expecting NC_ELATEFILL but got %d\n",__LINE__,err); err = nc_close(ncid); ERR_CHK; diff --git a/nc_test4/tst_h_scalar.c b/nc_test4/tst_h_scalar.c index c21b0ecb45..cfeed9f280 100644 --- a/nc_test4/tst_h_scalar.c +++ b/nc_test4/tst_h_scalar.c @@ -360,14 +360,14 @@ main() /* Write to the variable's fill-value */ vlstr = NULL; - if (nc_put_att(ncid, varid, _FillValue, NC_STRING, 1, &vlstr)) ERR; + if (nc_put_att(ncid, varid, NC_FillValue, NC_STRING, 1, &vlstr)) ERR; vlstr = malloc(10); *vlstr = '\0'; - if (nc_put_att(ncid, varid, _FillValue, NC_STRING, 1, &vlstr)) ERR; + if (nc_put_att(ncid, varid, NC_FillValue, NC_STRING, 1, &vlstr)) ERR; strcpy(vlstr, "foo"); - if (nc_put_att(ncid, varid, _FillValue, NC_STRING, 1, &vlstr)) ERR; + if (nc_put_att(ncid, varid, NC_FillValue, NC_STRING, 1, &vlstr)) ERR; free(vlstr); diff --git a/nc_test4/tst_quantize.c b/nc_test4/tst_quantize.c index b788c9514f..ce4bda713d 100644 --- a/nc_test4/tst_quantize.c +++ b/nc_test4/tst_quantize.c @@ -1005,9 +1005,9 @@ main(int argc, char **argv) if (nc_create(FILE_NAME, mode, &ncid)) ERR; if (nc_def_dim(ncid, DIM_NAME_1, DIM_LEN_5, &dimid)) ERR; if (nc_def_var(ncid, VAR_NAME_1, NC_FLOAT, NDIM1, &dimid, &varid1)) ERR; - if (nc_put_att_float(ncid, varid1, _FillValue, NC_FLOAT, 1, &custom_fill_float)) ERR; + if (nc_put_att_float(ncid, varid1, NC_FillValue, NC_FLOAT, 1, &custom_fill_float)) ERR; if (nc_def_var(ncid, VAR_NAME_2, NC_DOUBLE, NDIM1, &dimid, &varid2)) ERR; - if (nc_put_att_double(ncid, varid2, _FillValue, NC_DOUBLE, 1, &custom_fill_double)) ERR; + if (nc_put_att_double(ncid, varid2, NC_FillValue, NC_DOUBLE, 1, &custom_fill_double)) ERR; /* Turn on quantize for both vars. */ if (nc_def_var_quantize(ncid, varid1, quantize_mode[q], NSD_3)) ERR; diff --git a/nc_test4/tst_strings.c b/nc_test4/tst_strings.c index 5aa78a681d..5fe87baeaf 100644 --- a/nc_test4/tst_strings.c +++ b/nc_test4/tst_strings.c @@ -450,7 +450,7 @@ main(int argc, char **argv) /* Create a scalar variable for the empty string. */ if (nc_def_var(ncid, VAR_NAME2, NC_STRING, 0, NULL, &varid2)) ERR; if (dim_combo == 3) - if (nc_put_att(ncid, varid, _FillValue, NC_STRING, 1, my_string_fill)) ERR; + if (nc_put_att(ncid, varid, NC_FillValue, NC_STRING, 1, my_string_fill)) ERR; /* Check some stuff. */ if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR; diff --git a/nc_test4/tst_vars.c b/nc_test4/tst_vars.c index f7aef6881c..3bf174b3b5 100644 --- a/nc_test4/tst_vars.c +++ b/nc_test4/tst_vars.c @@ -1080,9 +1080,9 @@ main(int argc, char **argv) if (nc_def_var(ncid, VAR7_NAME, NC_USHORT, NDIMS, dimids, &varid)) ERR; if (nc_def_var(ncid, VAR8_NAME, NC_USHORT, NDIMS, dimids, &varid2)) ERR; if (nc_def_var(ncid, VAR9_NAME, NC_USHORT, NDIMS, dimids, &varid3)) ERR; - if (nc_put_att(ncid, varid3, _FillValue, NC_USHORT, 1, &my_fill_value2)) ERR; + if (nc_put_att(ncid, varid3, NC_FillValue, NC_USHORT, 1, &my_fill_value2)) ERR; if (nc_def_var(ncid, VAR10_NAME, NC_USHORT, NDIMS, dimids, &varid4)) ERR; - if (nc_put_att(ncid, varid4, _FillValue, NC_USHORT, 1, &my_fill_value2)) ERR; + if (nc_put_att(ncid, varid4, NC_FillValue, NC_USHORT, 1, &my_fill_value2)) ERR; /* Check stuff. */ if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims, dimids_in, diff --git a/nc_test4/tst_vars2.c b/nc_test4/tst_vars2.c index 0f9cee6983..a8603b12f0 100644 --- a/nc_test4/tst_vars2.c +++ b/nc_test4/tst_vars2.c @@ -87,11 +87,11 @@ main(int argc, char **argv) if (nc_create(FILE_NAME2, cmode, &ncid)) ERR; if (nc_def_dim(ncid, VAR_NAME, TEST_VAL_42, &dimid)) ERR; if (nc_def_var(ncid, VAR_NAME, NC_BYTE, 1, &dimid, &varid)) ERR; - if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR; + if (nc_put_att_schar(ncid, varid, NC_FillValue, NC_BYTE, 1, &fill_value)) ERR; if (nc_enddef(ncid)) ERR; if (nc_put_var1(ncid, varid, index, &schar_data)) ERR; if (nc_redef(ncid)) ERR; - if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, + if (nc_put_att_schar(ncid, varid, NC_FillValue, NC_BYTE, 1, &fill_value) != expected_ret) ERR; if (nc_close(ncid)) ERR; @@ -101,9 +101,9 @@ main(int argc, char **argv) if (nvars_in != 1 || varids_in[0] != 0) ERR; if (nc_inq_varname(ncid, 0, name_in)) ERR; if (strcmp(name_in, VAR_NAME)) ERR; - if (nc_inq_att(ncid, varid, _FillValue, &xtype_in, &len_in)) ERR; + if (nc_inq_att(ncid, varid, NC_FillValue, &xtype_in, &len_in)) ERR; if (xtype_in != NC_BYTE || len_in != 1) ERR; - if (nc_get_att(ncid, varid, _FillValue, &fill_value_in)) ERR; + if (nc_get_att(ncid, varid, NC_FillValue, &fill_value_in)) ERR; if (fill_value_in != fill_value) ERR; if (nc_close(ncid)) ERR; } @@ -119,7 +119,7 @@ main(int argc, char **argv) if (nc_create(FILE_NAME, cmode, &ncid)) ERR; if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR; if (nc_def_var(ncid, VAR_NAME, NC_BYTE, NUM_DIMS, dimids, &varid)) ERR; - if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR; + if (nc_put_att_schar(ncid, varid, NC_FillValue, NC_BYTE, 1, &fill_value)) ERR; if (nc_enddef(ncid)) ERR; /* Write the second record. */ @@ -154,9 +154,9 @@ main(int argc, char **argv) if (strcmp(name_in, VAR_NAME)) ERR; /* Check fill value att. */ - if (nc_inq_att(ncid, varid, _FillValue, &xtype_in, &len_in)) ERR; + if (nc_inq_att(ncid, varid, NC_FillValue, &xtype_in, &len_in)) ERR; if (xtype_in != NC_BYTE || len_in != 1) ERR; - if (nc_get_att(ncid, varid, _FillValue, &fill_value_in)) ERR; + if (nc_get_att(ncid, varid, NC_FillValue, &fill_value_in)) ERR; if (fill_value_in != fill_value) ERR; /* Read the first record, it should be the fill value. */ @@ -185,7 +185,7 @@ main(int argc, char **argv) if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR; if (nc_def_var(ncid, VAR_NAME, NC_BYTE, NUM_DIMS, dimids, &varid)) ERR; if (nc_put_att_int(ncid, varid, LOSSES_NAME, NC_INT, 1, &losses_value)) ERR; - if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR; + if (nc_put_att_schar(ncid, varid, NC_FillValue, NC_BYTE, 1, &fill_value)) ERR; if (nc_close(ncid)) ERR; /* Open the file and check. */ @@ -194,13 +194,13 @@ main(int argc, char **argv) if (xtype_in != NC_INT || len_in != 1) ERR; if (nc_get_att(ncid, 0, LOSSES_NAME, &losses_value_in)) ERR; if (losses_value_in != losses_value) ERR; - if (nc_inq_att(ncid, 0, _FillValue, &xtype_in, &len_in)) ERR; + if (nc_inq_att(ncid, 0, NC_FillValue, &xtype_in, &len_in)) ERR; if (xtype_in != NC_BYTE || len_in != 1) ERR; - if (nc_get_att(ncid, 0, _FillValue, &fill_value_in)) ERR; + if (nc_get_att(ncid, 0, NC_FillValue, &fill_value_in)) ERR; if (fill_value_in != fill_value) ERR; if (nc_inq_attid(ncid, 0, LOSSES_NAME, &attnum_in)) ERR; if (attnum_in != 0) ERR; - if (nc_inq_attid(ncid, 0, _FillValue, &attnum_in)) ERR; + if (nc_inq_attid(ncid, 0, NC_FillValue, &attnum_in)) ERR; if (attnum_in != 1) ERR; if (nc_close(ncid)) ERR; } @@ -223,7 +223,7 @@ main(int argc, char **argv) if (nc_def_var(ncid, VAR_NAME, NC_BYTE, NUM_DIMS, dimids, &varid)) ERR; for (a = 0; a < NUM_LEADERS; a++) if (nc_put_att_short(ncid, varid, leader[a], NC_SHORT, 1, &hair_length[a])) ERR; - if (nc_put_att_schar(ncid, varid, _FillValue, NC_BYTE, 1, &fill_value)) ERR; + if (nc_put_att_schar(ncid, varid, NC_FillValue, NC_BYTE, 1, &fill_value)) ERR; if (nc_close(ncid)) ERR; /* Open the file. */ @@ -241,9 +241,9 @@ main(int argc, char **argv) } /* Check our fill value attribute. */ - if (nc_inq_att(ncid, 0, _FillValue, &xtype_in, &len_in)) ERR; + if (nc_inq_att(ncid, 0, NC_FillValue, &xtype_in, &len_in)) ERR; if (xtype_in != NC_BYTE || len_in != 1) ERR; - if (nc_get_att(ncid, 0, _FillValue, &fill_value_in)) ERR; + if (nc_get_att(ncid, 0, NC_FillValue, &fill_value_in)) ERR; if (fill_value_in != fill_value) ERR; if (nc_close(ncid)) ERR; @@ -302,7 +302,7 @@ main(int argc, char **argv) /* Now add a fill value. This will acutually cause HDF5 to * destroy the dataset and recreate it, recreating also the * three attributes that are attached to it. */ - if (nc_put_att(ncid, varid, _FillValue, NC_FLOAT, + if (nc_put_att(ncid, varid, NC_FillValue, NC_FLOAT, 1, &fill_value)) ERR; /* Check to ensure the atts have their expected attnums. */ @@ -319,7 +319,7 @@ main(int argc, char **argv) if (attnum_in != 0) ERR; if (nc_inq_attid(ncid, 0, UNITS, &attnum_in)) ERR; if (attnum_in != 1) ERR; - if (nc_inq_attid(ncid, 0, _FillValue, &attnum_in)) ERR; + if (nc_inq_attid(ncid, 0, NC_FillValue, &attnum_in)) ERR; if (attnum_in != 2) ERR; if (nc_close(ncid)) ERR; @@ -388,14 +388,14 @@ main(int argc, char **argv) /* Now add a fill value. This will acutually cause HDF5 to * destroy the dataset and recreate it, recreating also the * three attributes that are attached to it. */ - ncattput(ncid, varid, _FillValue, NC_FLOAT, 1, &fill_value); + ncattput(ncid, varid, NC_FillValue, NC_FLOAT, 1, &fill_value); /* Check to ensure the atts have their expected attnums. */ if (nc_inq_attid(ncid, 0, LONG_NAME, &attnum_in)) ERR; if (attnum_in != 0) ERR; if (nc_inq_attid(ncid, 0, UNITS, &attnum_in)) ERR; if (attnum_in != 1) ERR; - if (nc_inq_attid(ncid, 0, _FillValue, &attnum_in)) ERR; + if (nc_inq_attid(ncid, 0, NC_FillValue, &attnum_in)) ERR; if (attnum_in != 2) ERR; ncclose(ncid); @@ -406,7 +406,7 @@ main(int argc, char **argv) if (attnum_in != 0) ERR; if (nc_inq_attid(ncid, 0, UNITS, &attnum_in)) ERR; if (attnum_in != 1) ERR; - if (nc_inq_attid(ncid, 0, _FillValue, &attnum_in)) ERR; + if (nc_inq_attid(ncid, 0, NC_FillValue, &attnum_in)) ERR; if (attnum_in != 2) ERR; ncclose(ncid); } diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index 15bc9d01c5..b9407a925d 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -779,7 +779,7 @@ pr_att( printf ("\t\t"); #ifdef USE_NETCDF4 if (is_user_defined_type(att.type) || att.type == NC_STRING - || (formatting_specs.xopt_filltype && varid != NC_GLOBAL && strcmp(_FillValue,att.name)==0)) + || (formatting_specs.xopt_filltype && varid != NC_GLOBAL && strcmp(NC_FillValue,att.name)==0)) #else if (is_user_defined_type(att.type)) #endif @@ -1511,11 +1511,11 @@ get_fill_info(int ncid, int varid, ncvar_t *vp) vp->has_fillval = 1; /* by default, but turn off for bytes */ /* get _FillValue attribute */ - nc_status = nc_inq_att(ncid,varid,_FillValue,&att.type,&att.len); + nc_status = nc_inq_att(ncid,varid,NC_FillValue,&att.type,&att.len); fillvalp = ecalloc(vp->tinfo->size + 1); if(nc_status == NC_NOERR && att.type == vp->type && att.len == 1) { - NC_CHECK(nc_get_att(ncid, varid, _FillValue, fillvalp)); + NC_CHECK(nc_get_att(ncid, varid, NC_FillValue, fillvalp)); } else { switch (vp->type) { case NC_BYTE: diff --git a/ncdump/tst_nans.c b/ncdump/tst_nans.c index 0e3efdd488..46a7bf103a 100644 --- a/ncdump/tst_nans.c +++ b/ncdump/tst_nans.c @@ -16,7 +16,7 @@ #include "isnan.h" #define FILE8_NAME "tst_nans.nc" -#define FV_NAME _FillValue /* defined in netcdf.h */ +#define FV_NAME NC_FillValue /* defined in netcdf.h */ #define FV_NVALS 1 #define ATT_NAME "att" #define NDIMS 1 diff --git a/ncgen3/ncgeny.c b/ncgen3/ncgeny.c index 8a4b51104c..99a2ed64fc 100644 --- a/ncgen3/ncgeny.c +++ b/ncgen3/ncgeny.c @@ -2264,13 +2264,13 @@ void equalatt(void) /* shrink space down to what was really needed */ att_space = erealloc(att_space, valnum*nctypesize(valtype)); atts[natts].val = att_space; - if (STREQ(atts[natts].name, _FillValue) && + if (STREQ(atts[natts].name, NC_FillValue) && atts[natts].var != NC_GLOBAL) { nc_putfill(atts[natts].type,atts[natts].val, &vars[atts[natts].var].fill_value); if(atts[natts].type != vars[atts[natts].var].type) { derror("variable %s: %s type mismatch", - vars[atts[natts].var].name, _FillValue); + vars[atts[natts].var].name, NC_FillValue); } } natts++; From 2b0b18bc6a611684fba4ef4f0ee5dcfd4c971b51 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Wed, 24 Apr 2024 11:41:18 -0600 Subject: [PATCH 48/48] Update release notes. --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 35f4de9beb..bfa8c58c81 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release ## 4.9.3 - TBD +* Refactor macro `_FillValue` to `NC_FillValue` to avoid conflict with libc++ headers. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information. * Changed `cmake` build options to be prefaced with `NETCDF`, to bring things in to line with best practices. This will permit a number of overall quality of life improvements to netCDF, in terms of allowing it to be more easily integrated with upstream projects via `FetchContent()`, `subdirectory()`, etc. Currently, the naming convention in use thus far will still work, but will result in warning messages about deprecation, and instructions on how to update your workflow. See [Github #2895](https://github.com/Unidata/netcdf-c/pull/2895) for more information. * Fix some problems in handling S3 urls with missing regions. See [Github #2819](https://github.com/Unidata/netcdf-c/pull/2819). * Incorporate a more modern look and feel to user documentation generated by Doxygen. See [Doxygen Awesome CSS](https://github.com/jothepro/doxygen-awesome-css) and [Github #2864](https://github.com/Unidata/netcdf-c/pull/2864) for more information.