mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-31 17:50:26 +08:00
Fix ncdump bug displaying NC_USHORT attribute values as NC_SHORT in netCDF-4 files. Add test for fix.
This commit is contained in:
parent
b3b7861756
commit
3a7556a306
@ -457,7 +457,7 @@ pr_att_valgs(
|
||||
break;
|
||||
case NC_USHORT:
|
||||
us = ((unsigned short *) vals)[iel];
|
||||
printf ("%hdUS%s", us, delim);
|
||||
printf ("%uUS%s", us, delim);
|
||||
break;
|
||||
case NC_UINT:
|
||||
ui = ((unsigned int *) vals)[iel];
|
||||
|
@ -4,4 +4,5 @@ types:
|
||||
|
||||
// global attributes:
|
||||
unimaginatively_named_vlen_type :equally_unimaginatively_named_attribute_YAWN = {-99}, {-99, -99} ;
|
||||
:for_testing_unsigned_short_attribute_bug = 0US, 32768US, 65535US ;
|
||||
}
|
||||
|
@ -184,13 +184,14 @@ main(int argc, char **argv)
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** creating file with VLEN %s...", FILE_NAME_2);
|
||||
#define ATT_NAME2 "equally_unimaginatively_named_attribute_YAWN"
|
||||
|
||||
#define ATT_NAME3 "for_testing_unsigned_short_attribute_bug"
|
||||
{
|
||||
int ncid;
|
||||
int i, j;
|
||||
nc_type typeid;
|
||||
nc_vlen_t data[DIM_LEN];
|
||||
int *phoney;
|
||||
unsigned short us_att[ATT_LEN] = {0, 32768, 65535};
|
||||
|
||||
/* Create phoney data. */
|
||||
for (i=0; i<DIM_LEN; i++)
|
||||
@ -209,6 +210,9 @@ main(int argc, char **argv)
|
||||
if (nc_def_vlen(ncid, VLEN_TYPE_NAME, NC_INT, &typeid)) ERR;
|
||||
if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME2, typeid, DIM_LEN, data)) ERR;
|
||||
|
||||
/* Test fix of ncdump bug displaying unsigned short attributes */
|
||||
if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME3, NC_USHORT, ATT_LEN, us_att)) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Free the memory used in our phoney data. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user