summaryrefslogtreecommitdiffstats
path: root/src/H5system.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2023-05-19 16:05:01 (GMT)
committerGitHub <noreply@github.com>2023-05-19 16:05:01 (GMT)
commitd7cb8aca5b4d07f9d04cd5aba618d4ec4dda7ac2 (patch)
tree4d9bfceb738e8aa19f2d34e8171433e59d16e496 /src/H5system.c
parent14edcfaffd6c2bbe487236742ae19093be9fe9dd (diff)
downloadhdf5-d7cb8aca5b4d07f9d04cd5aba618d4ec4dda7ac2.zip
hdf5-d7cb8aca5b4d07f9d04cd5aba618d4ec4dda7ac2.tar.gz
hdf5-d7cb8aca5b4d07f9d04cd5aba618d4ec4dda7ac2.tar.bz2
Add test for HDstrcasestr macro (#2115)
Diffstat (limited to 'src/H5system.c')
-rw-r--r--src/H5system.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/H5system.c b/src/H5system.c
index d6d734f..ecaa0f6 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -961,6 +961,28 @@ H5_strndup(const char *s, size_t n)
done:
FUNC_LEAVE_NOAPI(ret_value)
}
+
+/*-------------------------------------------------------------------------
+ * Function: Wstrcasestr_wrap
+ *
+ * Purpose: Windows wrapper function for strcasestr to retain GNU
+ * behavior where searching for an empty substring returns the
+ * input string being searched. StrStrIA on Windows does not
+ * exhibit this same behavior.
+ *
+ * Return: Pointer to input string if 'needle' is the empty substring
+ * Otherwise, returns StrStrIA(haystack, needle)
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+Wstrcasestr_wrap(const char *haystack, const char *needle)
+{
+ if (needle && !*needle)
+ return haystack;
+ else
+ return StrStrIA(haystack, needle);
+}
#endif /* H5_HAVE_WIN32_API */
/* dirname() and basename() are not easily ported to Windows and basename