Skip to content

Commit

Permalink
Merge pull request #2003 from DennisHeimbigner/closedir.dmh
Browse files Browse the repository at this point in the history
Fix NCclosedir in dpathmgr.c
  • Loading branch information
WardF authored May 20, 2021
2 parents 92e8808 + 0e931f2 commit 427166f
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 60 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release Notes {#RELEASE_NOTES}
This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.
## 4.8.1 - TBD

* [Bug Fix] Fix bug in NCclosedir in dpathmgr.c. See [Github #2003](https://github.com/Unidata/netcdf-c/issues/2003).
* [Bug Fix] Fix bug in ncdump that assumes that there is a relationship between the total number of dimensions and the max dimension id. See [Github #2004](https://github.com/Unidata/netcdf-c/issues/2004).
* [Bug Fix] Fix bug in JSON processing of strings with embedded quotes. See [Github #1993](https://github.com/Unidata/netcdf-c/issues/1993).
* [Enhancement] Add support for the new "dimension_separator" enhancement to Zarr v2. See [Github #1990](https://github.com/Unidata/netcdf-c/pull/1990) for more information.
Expand Down
8 changes: 6 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1095,10 +1095,16 @@ AC_C_BIGENDIAN
# Figure out platforms of special interest
case "`uname`" in
CYGWIN*) ISCYGWIN=yes;;
Darwin*) ISOSX=yes;;
WIN*) ISMSVC=yes;;
esac
AM_CONDITIONAL(ISCYGWIN, [test "x$ISCYGWIN" = xyes])
AM_CONDITIONAL(ISMSVC, [test "x$ISMSVC" = xyes])
AM_CONDITIONAL(ISOSX, [test "x$ISOSX" = xyes])

AC_SUBST([ISMSVC], [${ISMSVC}])
AC_SUBST([ISCYGWIN], [${ISCYGWIN}])
AC_SUBST([ISOSX], [${ISOSX}])

###
# Crude hack to work around an issue
Expand Down Expand Up @@ -1722,8 +1728,6 @@ AC_DEFINE_UNQUOTED([NC_DISPATCH_VERSION], [${NC_DISPATCH_VERSION}], [Dispatch ta
# End netcdf_meta.h definitions.
#####

# This would be true for a visual studio build.
AC_SUBST([ISMSVC], [${ISMSVC}])
# This would be true for a cmake build.
AC_SUBST([ISCMAKE], [])

Expand Down
2 changes: 1 addition & 1 deletion dap4_test/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
7 changes: 5 additions & 2 deletions include/ncpathmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
Expand Down Expand Up @@ -133,11 +136,11 @@ EXTERNL int NCclosedir(DIR* ent);
#define NCaccess(path,mode) access(path,mode)
#define NCmkdir(path,mode) mkdir(path,mode)
#define NCgetcwd(buf,len) getcwd(buf,len)
#define NCcwd(buf, len) getcwd(buf,len)
#define NCrmdir(path) rmdir(path)
#ifdef HAVE_SYS_STAT_H
#define NCstat(path,buf) stat(path,buf)
#endif
#define NCcwd(buf, len) getcwd(buf,len)
#define NCrmdir(path) rmdir(path)
#ifdef HAVE_DIRENT_H
#define NCopendir(path) opendir(path)
#define NCclosedir(ent) closedir(ent)
Expand Down
35 changes: 1 addition & 34 deletions libdispatch/dpathmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,7 @@ int
NCclosedir(DIR* ent)
{
int stat = NC_NOERR;
char* cvtname = NCpathcvt(path);
if(cvtname == NULL) {errno = ENOENT; return -1;}
stat = closedir(cvtname);
free(cvtname);
if(closedir(ent) < 0) stat = errno;
return stat;
}
#endif
Expand Down Expand Up @@ -911,33 +908,3 @@ printutf8hex(const char* s, char* sx)
}
*q = '\0';
}

/**************************************************/
#if 0
#ifdef HAVE_DIRENT_H
EXTERNL
DIR*
NCopendir(const char* path)
{
DIR* ent = NULL;
char* cvtpath = NCpathcvt(path);
if(cvtpath == NULL) return -1;
ent = opendir(cvtpath);
free(cvtpath);
return ent;
}

EXTERNL
int
NCclosedir(DIR* ent)
{
int stat = 0;
char* cvtpath = NCpathcvt(path);
if(cvtpath == NULL) return -1;
stat = closedir(cvtpath);
free(cvtpath);
return stat;
}
#endif
#endif /*0*/

2 changes: 1 addition & 1 deletion libnczarr/zdebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#undef ZDEBUG1 /* detailed debug */

#undef ZCATCH /* Warning: significant performance impact */
#define ZTRACING /* Warning: significant performance impact */
#undef ZTRACING /* Warning: significant performance impact */

#include "ncexternl.h"
#include "nclog.h"
Expand Down
2 changes: 1 addition & 1 deletion libnczarr/zincludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <unistd.h>
#endif
#endif
#ifdef _MSC_VER
#ifdef _WIN32
#include <malloc.h>
#endif

Expand Down
5 changes: 4 additions & 1 deletion libnczarr/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,16 @@ nczm_localize(const char* path, char** localpathp, int localize)
char* p;
int forward = 1;
int offset = 0;
static const char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

#ifdef _MSC_VER
forward = (localize?0:1);
#endif
/* If path comes from a url, then it may start with: /x:/...
where x is a drive letter. If so, then remove leading / */
if(path[0] == '/' && NChasdriveletter(path+1))
if(strlen(path) >= 4
&& path[0] == '/' && strchr(windrive,path[1]) != NULL
&& path[2] == ':' && path[3] == '/')
offset = 1;
if((localpath = strdup(path+offset))==NULL) return NC_ENOMEM;

Expand Down
10 changes: 2 additions & 8 deletions nc_test4/findplugin.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ FP_NAME="$1"
# Figure out the compiler (some values from ./configure)
FP_ISCMAKE=@ISCMAKE@
FP_ISMSVC=@ISMSVC@

# Are we operating under OS-X? (test using uname)
FP_OS=`uname | cut -d '_' -f 1`
if test "x$FP_OS" = xDarwin ; then FP_ISOSX=1; fi

# Are we operating under CYGWIN? (test using uname)
FP_OS=`uname | cut -d '_' -f 1`
if test "x$FP_OS" = xCYGWIN ; then FP_ISCYGWIN=1; fi
FP_ISCYGWIN=@ISCYGWIN@
FP_ISOSX=@ISOSX@

FP_PLUGINS="$TOPBUILDDIR/plugins"

Expand Down
6 changes: 5 additions & 1 deletion ncdump/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bom tst_dimsizes nctrunc tst_rcmerge
# Tests for classic and 64-bit offset files.
TESTS = tst_inttags.sh run_tests.sh tst_64bit.sh ref_ctest \
ref_ctest64 tst_output.sh tst_lengths.sh tst_calendars.sh \
run_utf8_tests.sh test_unicode_directory.sh tst_nccopy3.sh tst_nccopy3_subset.sh \
run_utf8_tests.sh tst_nccopy3.sh tst_nccopy3_subset.sh \
tst_charfill.sh tst_iter.sh tst_formatx3.sh tst_bom.sh \
tst_dimsizes.sh run_ncgen_tests.sh tst_ncgen4_classic.sh test_radix.sh test_rcmerge.sh

Expand All @@ -80,6 +80,10 @@ if USE_STRICT_NULL_BYTE_HEADER_PADDING
XFAIL_TESTS += tst_null_byte_padding.sh
endif

if ! ISCYGWIN
TESTS += test_unicode_directory.sh
endif

if LARGE_FILE_TESTS
TESTS += tst_iter.sh
endif
Expand Down
2 changes: 1 addition & 1 deletion ncdump/nccopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ncdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Research/Unidata. See \ref copyright file for more info. */
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ncvalidator.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ THIS SOFTWARE.
#include <unistd.h> /* read() getopt() */
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include <io.h>
#include "XGetopt.h"
#define snprintf _snprintf
Expand Down
2 changes: 1 addition & 1 deletion ncdump/ocprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "oc.h"
#include "ocx.h"

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion ncgen/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion ncgen3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#define snprintf _snprintf
#endif
Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/bm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/test_nczarr_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/ut_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ x * Copyright 2018, University Corporation for Atmospheric Research
#include <getopt.h>
#endif

#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
#endif

Expand Down
2 changes: 2 additions & 0 deletions nczarr_test/zs3parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions test_common.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ TOPSRCDIR='@abs_top_srcdir@'
TOPBUILDDIR='@abs_top_builddir@'
FP_ISCMAKE=@ISCMAKE@
FP_ISMSVC=@ISMSVC@
FP_ISCYGWIN=@ISCYGWIN@

# Feature flags
FEATURE_HDF5=@HAS_HDF5@
Expand Down

0 comments on commit 427166f

Please sign in to comment.