mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
Corrected issues where functions were not available in Windows. Specifically strndup. Also accomodated an included needed for getcwd.
This commit is contained in:
parent
720e4ea82c
commit
6c071be031
@ -1059,6 +1059,7 @@ CHECK_FUNCTION_EXISTS(strrchr HAVE_STRRCHR)
|
||||
CHECK_FUNCTION_EXISTS(strcat HAVE_STRCAT)
|
||||
CHECK_FUNCTION_EXISTS(strcpy HAVE_STRCPY)
|
||||
CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
|
||||
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
|
||||
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
|
||||
CHECK_FUNCTION_EXISTS(strtod HAVE_STRTOD)
|
||||
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
|
||||
|
@ -237,6 +237,7 @@ are set when opening a binary file on Windows. */
|
||||
|
||||
/* Set if we have strdup */
|
||||
#cmakedefine HAVE_STRDUP
|
||||
#cmakedefine HAVE_STRNDUP
|
||||
#cmakedefine HAVE_STRLCAT
|
||||
#cmakedefine HAVE_STRERROR
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
|
@ -64,6 +64,21 @@ static char* fileallow =
|
||||
static char* queryallow =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$&'()*+,-./:;=?@_~";
|
||||
|
||||
#ifndef HAVE_STRNCMP
|
||||
#define strndup ncstrndup
|
||||
/* Not all systems have strndup, so provide one*/
|
||||
char*
|
||||
ncstrndup(const char* s, size_t len)
|
||||
{
|
||||
char* dup;
|
||||
if(s == NULL) return NULL;
|
||||
dup = (char*)malloc(len+1);
|
||||
if(dup == NULL) return NULL;
|
||||
memcpy((void*)dup,s,len);
|
||||
dup[len] = '\0';
|
||||
return dup;
|
||||
}
|
||||
#endif
|
||||
/* Forward */
|
||||
static void ncparamfree(char** params);
|
||||
static int ncfind(char** params, const char* key);
|
||||
|
@ -536,6 +536,9 @@ vardata(
|
||||
size_t nrows;
|
||||
int vrank = vp->ndims;
|
||||
|
||||
int level = 0;
|
||||
int marks_pending = 0;
|
||||
|
||||
cor = (size_t *) emalloc((1 + vrank) * sizeof(size_t));
|
||||
edg = (size_t *) emalloc((1 + vrank) * sizeof(size_t));
|
||||
add = (size_t *) emalloc((1 + vrank) * sizeof(size_t));
|
||||
@ -576,8 +579,6 @@ vardata(
|
||||
nrows = nels/ncols; /* number of "rows" */
|
||||
vals = emalloc(ncols * vp->tinfo->size);
|
||||
|
||||
int level = 0;
|
||||
int marks_pending = 0;
|
||||
NC_CHECK(print_rows(level, ncid, varid, vp, vdims, cor, edg, vals, marks_pending));
|
||||
free(vals);
|
||||
free(cor);
|
||||
|
@ -11,6 +11,13 @@
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
/* Required for getcwd, other functions. */
|
||||
#ifdef _MSC_VER
|
||||
#include <direct.h>
|
||||
#define getcwd _getcwd
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
@ -40,6 +47,12 @@
|
||||
|
||||
#define OCCACHEPOS
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
/* Not all systems have strndup, so provide one*/
|
||||
#define strndup ocstrndup
|
||||
#endif
|
||||
|
||||
|
||||
/* Forwards */
|
||||
typedef struct OCstate OCstate;
|
||||
typedef struct OCnode OCnode;
|
||||
|
@ -55,7 +55,7 @@ ocstrncmp(const char* s1, const char* s2, size_t len)
|
||||
}
|
||||
|
||||
|
||||
#ifdef EXTERN_UNUSEd
|
||||
#ifdef EXTERN_UNUSED
|
||||
void
|
||||
makedimlist(OClist* path, OClist* dims)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user