Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix case error when opendap keyword is used as an identifier. #434

Merged
merged 12 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cf
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ MALLOC_CHECK=""
CPPFLAGS=""
LDFLAGS=""

#CFLAGS="-g -O0 $CFLAGS"
CFLAGS="-g $CFLAGS"
CFLAGS="-g -O0 $CFLAGS -Wno-undefined"

MAKE=make
IGNORE="test 0 = 1"
Expand Down
2 changes: 1 addition & 1 deletion cf.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Visual Studio
#VS=1
VS=1

# Is netcdf-4 and/or DAP enabled?
NC4=1
Expand Down
81 changes: 40 additions & 41 deletions h5_test/tst_h_dimscales.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define STR_LEN 255
#define MAX_DIMS 255

herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
void *visitor_data)
{
char name1[STR_LEN], name2[STR_LEN];
Expand All @@ -30,9 +30,9 @@ herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
/* printf("name of dsid: %s\n", name2); */

if (H5Gget_objinfo(did, ".", 1, &statbuf) < 0) ERR;
/* printf("statbuf.fileno = %d statbuf.objno = %d\n",
/* printf("statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/

return 0;
}

Expand All @@ -47,7 +47,7 @@ rec_scan_group(hid_t grpid)
int num_scales;
hsize_t dims[MAX_DIMS], max_dims[MAX_DIMS];
int ndims, d;

/* Loop through datasets to find variables. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
Expand All @@ -56,7 +56,7 @@ rec_scan_group(hid_t grpid)
* the object. */
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
obj_class, obj_name);*/

/* Deal with groups and datasets, ignore the rest. */
Expand Down Expand Up @@ -86,7 +86,7 @@ rec_scan_group(hid_t grpid)
else
{
int visitor_data = 0;

/* Here's how to get the number of scales attached
* to the dataset's dimension 0. */
if ((num_scales = H5DSget_num_scales(datasetid, 0)) < 0) ERR;
Expand Down Expand Up @@ -136,34 +136,34 @@ main()
hsize_t dimscale_dims[1] = {DIM1_LEN};

/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;

/* Create our dimension scale. Use the built-in NAME attribute
* on the dimscale. */
if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims,
if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims,
dimscale_dims)) < 0) ERR;
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
dimscale_spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5DSset_scale(dimscaleid, NAME_ATTRIBUTE) < 0) ERR;

/* Create a 1D variable which uses the dimscale. Attach a label
* to this scale. */
if ((var1_spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((var1_datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT,
if ((var1_datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT,
var1_spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5DSattach_scale(var1_datasetid, dimscaleid, 0) < 0) ERR;
if (H5DSset_label(var1_datasetid, 0, FIFTIES_SONG) < 0) ERR;

/* Create a 1D variabls that doesn't use the dimension scale. */
if ((var2_datasetid = H5Dcreate(grpid, VAR2_NAME, H5T_NATIVE_INT,
if ((var2_datasetid = H5Dcreate(grpid, VAR2_NAME, H5T_NATIVE_INT,
var1_spaceid, H5P_DEFAULT)) < 0) ERR;

/* Create a 2D dataset which uses the scale for one of its
* dimensions. */
if ((var3_spaceid = H5Screate_simple(2, dims, dims)) < 0) ERR;
if ((var3_datasetid = H5Dcreate(grpid, VAR3_NAME, H5T_NATIVE_INT,
if ((var3_datasetid = H5Dcreate(grpid, VAR3_NAME, H5T_NATIVE_INT,
var3_spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5DSattach_scale(var3_datasetid, dimscaleid, 0) < 0) ERR;

Expand Down Expand Up @@ -199,7 +199,7 @@ main()
/* Reopen the file and group. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, GRP_NAME)) < 0) ERR;

/* Loop through datasets to find variables. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
Expand All @@ -224,7 +224,7 @@ main()
{
H5Dclose(datasetid);
}

if ((datasetid = H5Dopen(grpid, obj_name)) < 0) ERR;
if ((is_scale = H5DSis_scale(datasetid)) < 0) ERR;
if (is_scale && strcmp(obj_name, DIMSCALE_NAME)) ERR;
Expand All @@ -234,7 +234,7 @@ main()

/* A dimscale comes with a NAME attribute, in
* addition to its real name. */
if (H5DSget_scale_name(datasetid, nom_de_quincey,
if (H5DSget_scale_name(datasetid, nom_de_quincey,
STR_LEN) < 0) ERR;
if (strcmp(nom_de_quincey, NAME_ATTRIBUTE)) ERR;

Expand All @@ -254,7 +254,7 @@ main()
if (strcmp(obj_name, VAR1_NAME) == 0 && num_scales != 1) ERR;
if (strcmp(obj_name, VAR2_NAME) == 0 && num_scales > 0) ERR;
if (strcmp(obj_name, VAR3_NAME) == 0 && num_scales != 1) ERR;

/* There's also a label for dimension 0 of var1. */
if (strcmp(obj_name, VAR1_NAME) == 0)
{
Expand Down Expand Up @@ -292,15 +292,15 @@ main()
int v;

/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;

/* Create our dimension scale. Use the built-in NAME attribute
* on the dimscale. */
if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims,
if ((dimscale_spaceid = H5Screate_simple(1, dimscale_dims,
dimscale_dims)) < 0) ERR;
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
dimscale_spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5DSset_scale(dimscaleid, NAME_ATTRIBUTE) < 0) ERR;

Expand All @@ -309,7 +309,7 @@ main()
for (v = 0; v < NUM_DATASETS; v++)
{
sprintf(var_name, "var_%d", v);
if ((var1_datasetid[v] = H5Dcreate(grpid, var_name, H5T_NATIVE_INT,
if ((var1_datasetid[v] = H5Dcreate(grpid, var_name, H5T_NATIVE_INT,
var1_spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5DSattach_scale(var1_datasetid[v], dimscaleid, 0) < 0) ERR;
}
Expand All @@ -332,7 +332,7 @@ main()
hsize_t dims[1] = {1}, maxdims[1] = {H5S_UNLIMITED};

/* Create file and group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;

Expand All @@ -343,12 +343,12 @@ main()
if (H5Pset_chunk(cparmsid, 1, dims) < 0) ERR;

/* Create our dimension scale, as an unlimited dataset. */
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
if ((dimscaleid = H5Dcreate(grpid, DIMSCALE_NAME, H5T_NATIVE_INT,
spaceid, cparmsid)) < 0) ERR;
if (H5DSset_scale(dimscaleid, NAME_ATTRIBUTE) < 0) ERR;

/* Create a variable which uses it. */
if ((datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT,
if ((datasetid = H5Dcreate(grpid, VAR1_NAME, H5T_NATIVE_INT,
spaceid, cparmsid)) < 0) ERR;
if (H5DSattach_scale(datasetid, dimscaleid, 0) < 0) ERR;
if (H5DSset_label(datasetid, 0, "dimension label") < 0) ERR;
Expand All @@ -367,7 +367,7 @@ main()

{
hid_t fileid, grpid, spaceid = 0, datasetid = 0;
hsize_t num_obj, i;
hsize_t volatile num_obj, i;
int obj_class;
char obj_name[STR_LEN + 1];
htri_t is_scale;
Expand All @@ -377,7 +377,7 @@ main()
/* Reopen the file and group. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, GRP_NAME)) < 0) ERR;

/* Loop through datasets to find variables. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
Expand All @@ -401,7 +401,7 @@ main()
H5Dclose(datasetid);
datasetid = 0;
}

/* Open the dataset. */
if ((datasetid = H5Dopen(grpid, obj_name)) < 0) ERR;

Expand Down Expand Up @@ -434,9 +434,9 @@ main()
if (num_scales != 1) ERR;

/* Go through all dimscales for this var and learn about them. */
if (H5DSiterate_scales(datasetid, 0, NULL, alien_visitor,
if (H5DSiterate_scales(datasetid, 0, NULL, alien_visitor,
&visitor_data) < 0) ERR;

/* There's also a label for dimension 0. */
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;

Expand Down Expand Up @@ -464,7 +464,7 @@ main()

{
#define NDIMS 3
#define TIME_DIM 0
#define TIME_DIM 0
#define LAT_DIM 1
#define LON_DIM 2
#define LAT_LEN 2
Expand Down Expand Up @@ -569,7 +569,7 @@ main()
/* Reopen the file and group. */
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, GRP_NAME)) < 0) ERR;

/* Loop through datasets to find variables. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
Expand Down Expand Up @@ -602,25 +602,25 @@ main()

/* A dimscale comes with a NAME attribute, in
* addition to its real name. */
if (H5DSget_scale_name(datasetid, nom_de_quincey,
if (H5DSget_scale_name(datasetid, nom_de_quincey,
STR_LEN) < 0) ERR;
/*printf("found scale %s, NAME %s id 0x%x\n", obj_name,
/*printf("found scale %s, NAME %s id 0x%x\n", obj_name,
nom_de_quincey, datasetid);*/

/* Check size depending on name. */
if ((!strcmp(obj_name, LAT_NAME) && dims[TIME_DIM] != LAT_LEN) ||
(!strcmp(obj_name, LON_NAME) && dims[TIME_DIM] != LON_LEN) ||
(!strcmp(obj_name, TIME_NAME) &&
(!strcmp(obj_name, TIME_NAME) &&
max_dims[TIME_DIM] != H5S_UNLIMITED)) ERR;

}
else
{
char label[STR_LEN+1];
int visitor_data = 0;

/* SHould have these dimensions... */
if (dims[TIME_DIM] != 0 || dims[LAT_DIM] != LAT_LEN ||
if (dims[TIME_DIM] != 0 || dims[LAT_DIM] != LAT_LEN ||
dims[LON_DIM] != LON_LEN) ERR;
if (max_dims[TIME_DIM] != H5S_UNLIMITED) ERR;

Expand All @@ -636,7 +636,7 @@ main()
if (H5DSiterate_scales(datasetid, d, NULL, alien_visitor,
&visitor_data) < 0) ERR;
/*printf("visitor_data: 0x%x\n", visitor_data);*/

/* There's also a label for each dimension. */
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
if (strcmp(label, TIME_NAME)) ERR;
Expand Down Expand Up @@ -673,7 +673,7 @@ main()
#define SMELLINESS_NAME "Smelliness"
#define DISTANCE_NAME "Distance"
#define TIME_NAME "Time"
#define TIME_DIM 0
#define TIME_DIM 0
#define SMELLINESS_DIM 1
#define DISTANCE_DIM 2
#define GOAT_NAME "Billy_goat_gruff"
Expand Down Expand Up @@ -773,7 +773,7 @@ main()
/* If we can't scan the group, crash into a flaming heap of
* smoking, smoldering rubbish. */
if (rec_scan_group(grpid)) ERR;

/* Close up the shop. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
Expand All @@ -783,4 +783,3 @@ main()
#endif
FINAL_RESULTS;
}

7 changes: 5 additions & 2 deletions include/nctime.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* $Id: nctime.h,v 1.6 2010/03/18 19:24:26 russ Exp $
*********************************************************************/

#ifndef _NCTIME_H
#define _NCTIME_H

struct bounds_node{
int ncid; /* group (or file) in which variable with associated
* bounds variable resides */
Expand All @@ -14,7 +17,7 @@ struct bounds_node{

typedef struct bounds_node bounds_node_t;

/*
/*
* This code was extracted with permission from the CDMS time
* conversion and arithmetic routines developed by Bob Drach, Lawrence
* Livermore National Laboratory as part of the cdtime library.
Expand Down Expand Up @@ -158,4 +161,4 @@ extern int cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* uni
#endif /* DLL Considerations. */



#endif /* ifdef */
20 changes: 17 additions & 3 deletions include/ncutf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef NCUTF8_H
#define NCUTF8_H 1

#include "ncexternl.h"

/* Provide a wrapper around whatever utf8 library we use. */

/*
Expand All @@ -15,7 +17,7 @@
* NC_ENOMEM -- out of memory
* NC_EBADNAME-- not valid utf8
*/
extern int nc_utf8_validate(const unsigned char * name);
EXTERNL int nc_utf8_validate(const unsigned char * name);

/*
* Apply NFC normalization to a string.
Expand All @@ -28,7 +30,19 @@ extern int nc_utf8_validate(const unsigned char * name);
* NC_ENOMEM -- out of memory
* NC_EBADNAME -- other failure
*/
extern int nc_utf8_normalize(const unsigned char* str, unsigned char** normalp);
EXTERNL int nc_utf8_normalize(const unsigned char* str, unsigned char** normalp);

#endif /*NCUTF8_H*/
/*
* Convert a normalized utf8 string to utf16. This is approximate
* because it just does the truncation version of conversion for
* each 32-bit codepoint to get the corresponding utf16.
* Return codes:
* NC_NOERR -- success
* NC_ENOMEM -- out of memory
* NC_EINVAL -- invalid argument or internal error
* NC_EBADNAME-- not valid utf16
*/

EXTERNL int nc_utf8_to_utf16(const unsigned char* s8, unsigned short** utf16p, size_t* lenp);

#endif /*NCUTF8_H*/
Loading