Skip to content

Commit

Permalink
Followon to
Browse files Browse the repository at this point in the history
re: #365

1. Added to RELEASENOTES.md
2. Add a range check to more closely
   mimic unix sscanf
3. locate and fix same sscanf problems in ncgen/cvt.c

Still need a stable url for a test case.
  • Loading branch information
DennisHeimbigner committed Feb 20, 2017
1 parent 96bd037 commit f71b695
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 45 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This file contains a high-level description of this package's evolution. Release

## 4.4.2 - TBD

* [Bug] Addressed conversion problem with Windows sscanf. See [GitHub #365](https://github.com/Unidata/netcdf-c/issues/365) for more information.
* [Enhancement] Added support for HDF5 collective metadata operations when available. Patch submitted by Greg Sjaardema, see [Pull request #335](https://github.com/Unidata/netcdf-c/pull/335) for more information.
* [Bug] Addressed a potential type punning issue. See [GitHub #351](https://github.com/Unidata/netcdf-c/issues/351) for more information.
* [Bug] Addressed an issue where netCDF wouldn't build on Windows systems using MSVC 2012. See [GitHub #304](https://github.com/Unidata/netcdf-c/issues/304) for more information.
Expand Down
44 changes: 0 additions & 44 deletions cf.cmake

This file was deleted.

2 changes: 2 additions & 0 deletions libdap2/dapcvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
int ival;
ok = sscanf(s,"%d%n",&ival,&nread);
_ASSERTE(_CrtCheckMemory());
if(ival < NC_MIN_BYTE || ival > NC_MAX_BYTE) ok = 0;
*p = (char)ival;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
Expand Down Expand Up @@ -246,6 +247,7 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
unsigned int uval;
ok = sscanf(s,"%u%n",&uval,&nread);
_ASSERTE(_CrtCheckMemory());
if(uval > NC_MAX_UBYTE) ok = 0;
*p = (unsigned char)uval;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
Expand Down
11 changes: 10 additions & 1 deletion ncgen/cvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ convert1(NCConstant* src, NCConstant* dst)
Constvalue tmp;
unsigned char* bytes = NULL;
size_t bytelen;

#ifdef _MSC_VER
int byteval;
#endif
dst->lineno = src->lineno;

/* Need to translate all possible sources to all possible sinks.*/
Expand Down Expand Up @@ -405,10 +407,17 @@ case CASE(NC_DOUBLE,NC_DOUBLE):
break;

/* Conversion of a string to e.g. an integer should be what?*/
#ifdef _MSC_VER
case CASE(NC_STRING,NC_BYTE):
sscanf(src->value.stringv.stringv,"%d",&byteval); tmp.int8v = (char)byteval; break;
case CASE(NC_STRING,NC_UBYTE):
sscanf(src->value.stringv.stringv,"%d",&byteval); tmp.uint8v = (unsigned char)byteval; break;
#else
case CASE(NC_STRING,NC_BYTE):
sscanf(src->value.stringv.stringv,"%hhd",&tmp.int8v); break;
case CASE(NC_STRING,NC_UBYTE):
sscanf(src->value.stringv.stringv,"%hhu",&tmp.uint8v); break;
#endif
case CASE(NC_STRING,NC_USHORT):
sscanf(src->value.stringv.stringv,"%hu",&tmp.uint16v); break;
case CASE(NC_STRING,NC_UINT):
Expand Down

0 comments on commit f71b695

Please sign in to comment.