summaryrefslogtreecommitdiffstats
path: root/test/tunicode.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2021-02-08 16:56:16 (GMT)
committerGitHub <noreply@github.com>2021-02-08 16:56:16 (GMT)
commit22c67ff6570f16050f0a5654cf1c84df917bb598 (patch)
tree38fb63aa498b250c2543fe7e22a511706de96a42 /test/tunicode.c
parent551f15f8ae02ca9c995619b216121081eb07633e (diff)
downloadhdf5-hdf5-1_8_22.zip
hdf5-hdf5-1_8_22.tar.gz
hdf5-hdf5-1_8_22.tar.bz2
1.8/master (#317)hdf5-1_8_22
* Revert incorrect bool type * Correct grep text for filter test * Check sizeof type to use correct ref_type * h5dump reg ref chnages has no error file * Fix comment * Remove unneeded files * Verify the decoded version for "all" and "none" selection. * Remove double entry * Add missing include * Snapshot version 1.8 release 22 (snap4) Update version to 1.8-snap5 * Fixes for test failures with --disable-tests --disable-tools options. Don't test ph5diff if tests are disabled. * Correct conditions for parallel builds with and without tests. * Snapshot version 1.8 release 22 (snap5) Update version to 1.8.22-snap6 * TRILAB-192 merging warnings changes from develop * Autotools reconfigure update * Restore page ejects. * Restore page eject chars * Fix orphaned token * Update LT files * Correct extra flags and merge TRILAB-24 * Update release note for CMake warnings * H5repack bug fixes from develop * TRILAB-192 - merge changes from develop Single source, config files, for warnings for both autotools and CMake. Update CMake libraries, tools, tests to use correct flags. * Add missing m4 file * Remove 128bit config check fo 1.8 * TRILAB-192 update LTparse files * A fix in the cleaning up code for datatype when datatype initialization via H5D__init_type() fails. The code to fix the problem is the same as what is done in H5D__open_oid(). * Add missing " and update function calls incorrectly named load_gcc_arguments. Commit changes to gnu-cxxflags to remove unmatched " and to gnu-fflags to not add C warnings flags to H5_FCFLAGS. * TRILAB-192 - cleanup edits and match CMake CXX to autotools * Fix shadowed type * TRILAB-192 correct fortran commands * TRILAB-192 version of std=f2008 special check * Fix shadow variable * Add prefix_relto_examplesdir function to set relative path to h5c++. * TRILAB-192 - parser files cannot handle this warning * Parallel Fortran tests now use the MPI module instead of including mpif.h. * Don't add general warnings flags for unsupported old versions of gcc and g++ (older than gcc/g++ 4.2). Correct gnu-cxxflags to determine warnings flags to be added based on C++ compiler version instead of C compiler version. * Snapshot version 1.8 release 22 (snap6) Update version to 1.8.22-snap7 * TRILAB-244 separate CXX warnings and errors from C * Fix NoFilter build * Move ADD_H5_FLAGS macro from *CompilerFlags.cmake files to config/cmake_ext_mod/HDFMacros.cmake for common use. * Restrict errors to gcc 4.8 and above. * OESS-65 replace szip with aec szip * Correct CMake version * Correct -Werror=unused-variable * Add -Werror= flags to lists displayed in libhdf5.settings. * Fix -Werror=unused-variable * More fixes for unused variable * Resolve warning errors from -Werror= flags: -Werror=bad-function-cast -Werror=bad-function-cast -Werror=implicit-function-declaration -Werror=nested-externs * Remove verbose assignments in smoke_check 3 and 5 functions. * Update to use optimization flags, C++ error flags, and correct libhdf5.settings.in to remove unworkable changes. * Update config/gnu-cxxflags. * Add missing headers * Fix ifort warning flag. Restore AC_DEFUN([PAC_PROG_FC_DEFAULT_REALisDBLE] in m4/aclocal_fc.m4. Add --enable-symbols, --enable-profiling, and --enable-optimization options to autotools configure; all configure flags for --enable-production and --disable-production should match HDF5 1.10 and 1.12 production and debug default flags. * Add github actions file * Correct path * OESS-65 Fix packaging * Update reference name * Correct filename * disable pr action and enable fail fast * Snapshot 1.8.22-snap7 Update version to 1.8.22-snap8. * Correct mingw path * Correct mingw paths * Revise gnu-*flags and cmake/HDF*CompilerFlags.cmake files to add warning flags for GCC compilers version 4.8 and above. Removed files from gnu-warnings that only apply to versions < 4.8. Consolidated warnings from versions < 4.8 that apply to versions >= 4.8 into the 4.8 warnings files. * Update MANIFEST for removal of older warnings files. * Yanked all MPI-1 calls Added batch scripts in bin/batch. * Snapshot 1.8.22-snap8. Update version to 1.8.22-snap9. * Squashed commit of the following: commit 45b0cbc71929930a874e1c09e0770aa64d0ae697 Author: Larry Knox <lrknox@hdfgroup.org> Date: Thu Apr 23 13:14:56 2020 -0500 Add C++ warnings treated as error for autotools builds. commit 6debcddcc766601799d5bd661bd60946f951a07e Author: Larry Knox <lrknox@hdfgroup.org> Date: Fri Jun 19 16:50:03 2020 -0500 Remove tests for develop branch from testh5cc.sh.in. Add @H5_ECXXFLAGS@ to AM_CXXFLAGS. commit fed497e7f207313b2a133d3b68c942b7d7104b90 Author: Larry Knox <lrknox@hdfgroup.org> Date: Fri Jun 12 15:06:39 2020 -0500 Merge pull request #2646 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit '998c6470d78e14228695419c3b514c35ecf3d69e': Remove unnecessary version conditions for Clang compilers. commit 92e52ce5c211bd1d3991a3b8bb67287ac7b652aa Author: Larry Knox <lrknox@hdfgroup.org> Date: Wed Jun 10 18:53:45 2020 -0500 Merge pull request #2639 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit 'a33667faf226f5d8c9633bf537893e8fce1bf1f6': Add c++ to --enable-sanitize-checks option. commit 2e802534fb997b81fa98fdd1c7d97d4310898e0d Author: Larry Knox <lrknox@hdfgroup.org> Date: Wed Jun 10 15:18:36 2020 -0500 Merge pull request #2633 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit '20eab963899841c9a003baebead8e3bc07d9e127': Remove duplicate entries in MANIFEST. Make changes to CMake CompilerFlags.cmake files so extra flags are loaded for non-GNU compilers. Update new clang files to not pick up clang as vendor for pgCC. Add new files to MANIFEST Temporary demotion of 2 -Werror warning flags that fail on macos 10.12 Remove Production flag unknown to Apple clang. commit 96ef60a58a23847a7da89a891f2415055ec2ab60 Author: Larry Knox <lrknox@hdfgroup.org> Date: Mon Jun 8 16:24:49 2020 -0500 Merge pull request #2631 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit 'b942a4d8a3e27317cac50ce37ff5302d477664d8': Clean up code to get clang version in config/linux-gnulibc1 commit 8a7c687da568e8b50b38fa53da1ca63759be6ec4 Author: Larry Knox <lrknox@hdfgroup.org> Date: Mon Jun 8 11:42:37 2020 -0500 Merge pull request #2623 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit 'c7626f79fdee4eee13925e240ef41e61f3367eab': Add flags from config/clang-warnings/*general files to H5 C and CXX flags for all versions of Clang and Clang++ compilers. Switched from cut to awk in testcheck_version.sh.in to avoid dependence on tab vs. " " in version definitions in H5public.h. Add files for adding warning flags for clang compilers in autotools configure. commit db3ef7ff3c1ed79167cecef831501411cff8291f Merge: 5a0f8d7 f9f1310 Author: Larry Knox <lrknox@hdfgroup.org> Date: Fri Jun 19 14:46:22 2020 -0500 Merge branch 'hdf5_1_12' of https://bitbucket.hdfgroup.org/scm/~lrknox/hdf5_lrk into hdf5_1_12 commit 5a0f8d7940ae57b445f545a0abd7e303ce6924ee Author: Larry Knox <lrknox@hdfgroup.org> Date: Wed Jun 10 20:15:41 2020 -0500 Merge pull request #2636 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:HDFFV-11000-update-testh5cc.sh.in-for-version to develop * commit '5c0bd670d6e9919c463fbc05de99e2ba55b0761e': Add tests for all version to H5_NO_DEPRECATED_SYMBOLS section and to section for current version, with and without default API version flags. HDFFV-11000: update-testh5cc.sh.in to test sample versioned functions in HDF5 1.10, 1.12 and develop. * Update configure and Makefile.ins after bin/reconfigure. * Fix MANIFEST * Fix HDFFV-10591 Description: h52gif produced a segfault when a buffer overflow occurred because the data size was corrupted and became very large. This commit added a check on the data size against the buffer size to prevent the segfault. It also added error reporting to h52gif to display an error message instead of silently exiting when the failure occurred. Platforms tested: Linux/64 (jelly) * Snapshot 1.8.22-snap9. Update version to 1.8.22-snap10. * Merge pull request #2686 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:develop to develop * commit '800f93f7c994f88dfa716746153ded4b1e690e3a': Remove path to szip header file from AM_CPPFLAGS when configure check of libsz fails. Fix for HDFFV-10830. * Regenerate configure. * Merge from 1.10-1.12-dev - LT parse needs update * Incorporate pull request #2693 from develop for the fix to HDFFV-11080: (1) Patch up the file pointer when reading attribute of variable length datatype (2) Test to verify the fix when doing multiple threads (3) Update MANIFEST (4) Add new test to Cmake * Switch bison and flex update of LT files from bin/genltanalyse to bin/genparser, and from automatically updating the LT files whenever reconfigure is run to running only on man<F12>ual command. * Update hl/sr/H5LT files. Add bin/genparser to MANIFEST; remove bin/genltanalyze. * Fix to the merge of PR #2708 for HDFFV-11080 to the 1.8 branch. Need to checkin test/Makefile.in for the new file added. * Fix HDFFV-11120 and HDFFV-11121 (CVE-2018-13870 and CVE-2018-13869) Description: When a buffer overflow occurred because a name length was corrupted and became very large, h5dump produced a segfault on one file and a memcpy parameter overlap on another file. This commit added checks that detect a read pass the end of the buffer to prevent these error conditions. Platforms tested: Linux/64 (jelly) * Fixed typo * Check for header szlib.h only when libsz passes AC_CHECK_LIB, so that H5_HAVE_SALIB_H is not defined when szip is not enabled, to prevent compile failures for incompatible szlib. * HDFFV-11127 - force RTLD_LOCAL in dlopen * spelling * Remove extra parens * Remove unnecessary assignment freom configure.ac. * Add hypen to subrelease regex * Add special case when H5_VERS_SUBRELEASE is 0 * Revert H5_VERS_SUBRELEASE check * The version string has a second use for packaging * MinGW uses "MinGW Makefiles" * Snapshot 1.8.22-snap10. Update version to 1.8.22-snap11. * Merge clang-format changes from develop * remove stray file * Source formatted * Add options to github actions. * Add back file, remove py file * HDFFV-11096 Correct h5dump usage text * Update formating * remove autogen for 1.8 branch * Fix comment whitespace * Change '==' to 'eq' in test script * Merge from develop github updates bin scripts parser updates * Snapshot 1.8.22-snap11. Update version to 1.8.22-snap12. * Merge from 1.10 Comments, whitespace Simple init and if block brackets. Minimal code changes limited to return value and spelling * Update autotools files * Update FD source * More merges from 1.10 comments and inits * Comment fixes * Fix macro argument * Remove autogen file and cache dir * Revert autotools files to previous version * Correct boolean value and missing define * URL and options corrections * revert autoconf files * Fix compile issues with vfd drivers. * Fix HDFS test * Remove extra #endif * Move init above execution * Multiple changes to bring branch up-to-date (#87) Correct TARGET variable and CMake config file location. Add option to allow filter plugins to be built inline. Update CMake tools macros. * hdf5 1 8 release text (#113) * Multiple changes to bring branch up-to-date Correct TARGET variable and CMake config file location. Add option to allow filter plugins to be built inline. Update CMake tools macros. * release text updates - mostly whitespace * Fixed HDFFV-10480 and HDFFV-11159 (#145) * Fixed HDFFV-10480 and HDFFV-11159 Description Checked against buffer size to prevent segfault, in case of data corruption. + HDFFV-11159 CVE-2018-14033 Buffer over-read in H5O_layout_decode + HDFFV-10480 CVE-2018-11206 Buffer over-read in H5O_fill_new[/old]_decode and A user's patch was applied to this previously, but it is redone for a more correct fix, that is the check now accounted for the previous advance of the buffer pointer. Platforms tested: Linux/64 (jelly) * Fixed typo * Update HDF5 1.8 copyright headers with updated copyright URL (#148) * Update URL for COPYING file in copyright headers. * Make fortran copyright headers uniformly spaced. * Update url for Copyright file in c++/src/footer.html. * OESS-98 Update plugin build option (#171) * 1.8 has extra fortran CMake option (#176) * 1.8 has extra fortran CMake option * Update license URL * OESS-98 fix tools test for plugins (#180) * Hdf5 1 8 (#169) * Fixed HDFFV-10480 and HDFFV-11159 Description Checked against buffer size to prevent segfault, in case of data corruption. + HDFFV-11159 CVE-2018-14033 Buffer over-read in H5O_layout_decode + HDFFV-10480 CVE-2018-11206 Buffer over-read in H5O_fill_new[/old]_decode and A user's patch was applied to this previously, but it is redone for a more correct fix, that is the check now accounted for the previous advance of the buffer pointer. Platforms tested: Linux/64 (jelly) * Fixed typo * Fixed HDFFV-11150 Description Replaced an HDassert with a check for null pointer in H5O_dec_rc() to catch null pointer in corrupted data situation. Reversed the fix in svn-r24463 in which a check for null pointer prior to calling H5O_dec_rc() Platforms tested: Linux/64 (jelly) * HDF5 1 8 fix fortran build on macs (#186) * Correct fortran and shared libs option * Fix for no shared fortran build * OESS-98 fix hdf5 link target (#191) * Partial changes to RELEASE.txt for release. (#185) * Partial changes to RELEASE.txt for release. * Update supported and tested platforms. * Update version to 1.8.22-12. * close #195. (#196) * Update HDF5PluginMacros.cmake * Update HDF5PluginMacros.cmake * Update directory for SZ filter in HDF5PluginMacros.cmake. Updates for release: Switch configure default to production mode. Set HDF5_GENERATE_HEADERS to OFF. * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Restores maintainer mode in the autotools (#200) (#203) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> * Hdf5 1 8 22 (#212) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Brings ttsafe_attr_vlen.c changes from develop (#214) Fixes exposed pthread problem on Windows. * Update SO numbers for Hdf5 1 8 22 (#215) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Hdf5 1 8 22 (#224) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> * Update CMake/HDF5Examples version in bin/release * Update CMake/HDF5Examples version number in bin/release (#225) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> * Fixed typo in an error message. (#228) * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * Bring 3 small changes from Hdf5 1.8 to 1.8.22 (#241) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Stat st blocks fix 1822 (#251) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * Fixes Autotools detection of the st_blocks field in stat (#246) * Fixes Autotools detection of the st_blocks field in stat The Autotools and CMake will now both correctly determine if the stat struct has the st_blocks field and set H5_HAVE_STAT_ST_BLOCKS appropriately. * Fixes a typo in configure.ac * Restore lines in RELEASE.txt. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Stat st blocks fix 1822 (#256) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * Fixes Autotools detection of the st_blocks field in stat (#246) * Fixes Autotools detection of the st_blocks field in stat The Autotools and CMake will now both correctly determine if the stat struct has the st_blocks field and set H5_HAVE_STAT_ST_BLOCKS appropriately. * Fixes a typo in configure.ac * Restore lines in RELEASE.txt. * Updated configure with reconfigure. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * RELEASE.txt cleanup. * Hdf5 1 8 22 (#261) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. * Hdf5 1 8 22 (#266) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Reverts lock/unlock callback signature to 1.8.21 version (#254) * Reverts lock/unlock callback signature to 1.8.21 version This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs that have the lock callback implemented and that is just as no-op stubs. These stubs were removed so the callbacks are now NULL pointers, like the other VFDs in 1.8. * Trivial whitespace fix * Update version to 1.8.22-14. * Hdf5 1 8 22 - Reverts lock/unlock callback signature to 1.8.21 version (#267) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. * Reverts lock/unlock callback signature to 1.8.21 version (#254) * Reverts lock/unlock callback signature to 1.8.21 version This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs that have the lock callback implemented and that is just as no-op stubs. These stubs were removed so the callbacks are now NULL pointers, like the other VFDs in 1.8. * Trivial whitespace fix * Update version to 1.8.22-14. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Update version in H5public.h * Hdf5 1 8 22 (#269) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. * Reverts lock/unlock callback signature to 1.8.21 version (#254) * Reverts lock/unlock callback signature to 1.8.21 version This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs that have the lock callback implemented and that is just as no-op stubs. These stubs were removed so the callbacks are now NULL pointers, like the other VFDs in 1.8. * Trivial whitespace fix * Update version to 1.8.22-14. * Update version in H5public.h Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Set version 1.8.22 for release. * dd RELEASE.txt entry for HDFFV-10741. * Hdf5 1 8 22 (#279) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. * Reverts lock/unlock callback signature to 1.8.21 version (#254) * Reverts lock/unlock callback signature to 1.8.21 version This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs that have the lock callback implemented and that is just as no-op stubs. These stubs were removed so the callbacks are now NULL pointers, like the other VFDs in 1.8. * Trivial whitespace fix * Update version to 1.8.22-14. * Update version in H5public.h * Set version 1.8.22 for release. * dd RELEASE.txt entry for HDFFV-10741. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> * Improve performance of multiple calls to H5Sget_select_elem_pointlist (#270) (#277) * Cache the pointer to the next point to process after the last call to H5S__get_select_elem_pointlist. This allows the normal process of iterating over the points in batches to be much more efficient, as the library does not need to traverse the entirety of the preceding points every time the funciton is re-entered. * Update RELEASE.txt for point selection iteration performance fix. * Hdf5 1 8 22 (#281) * Restores maintainer mode in the autotools (#200) Maintainer mode should be enabled in development branches. Also adds helpful commenting. Add bin/switch_maint_mode Disable maintainer mode for release. Fix incomplete merge for stub functions in H5Fdhdfs.c * Update configure for Restores maintainer mode in the autotools (#200). * Update MANIFEST for switch_maint_mode script. * Update so numbers for 1.8.22 release. * Add so numbers changes in Makefile.ins for 1.8.22 release. * Update pkgconfig settings with version - #218 (#223) * Add notice of final HDFF5 1.8 release. Add solaris 64bit alignment issue to "Known Problems". * Update 1.8 final release notice. * Update CMake/HDF5Examples version in bin/release * Fixed typo in an error message. (#227) * Remove duplicate setting (#239) * RELEASE.txt cleanup. * Add macOS Big Sur to tested machines, also missing entries for macOS 10.13 and 10.14. * )Update version. * Reverts lock/unlock callback signature to 1.8.21 version (#254) * Reverts lock/unlock callback signature to 1.8.21 version This callback is unused in 1.8. The ros3 and hdfs VFDs are the only VFDs that have the lock callback implemented and that is just as no-op stubs. These stubs were removed so the callbacks are now NULL pointers, like the other VFDs in 1.8. * Trivial whitespace fix * Update version to 1.8.22-14. * Update version in H5public.h * Set version 1.8.22 for release. * dd RELEASE.txt entry for HDFFV-10741. * Improve performance of multiple calls to H5Sget_select_elem_pointlist (#270) (#277) * Cache the pointer to the next point to process after the last call to H5S__get_select_elem_pointlist. This allows the normal process of iterating over the points in batches to be much more efficient, as the library does not need to traverse the entirety of the preceding points every time the funciton is re-entered. * Update RELEASE.txt for point selection iteration performance fix. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org> * Hdf5 1 8 22 (#284) * Fixed typo in an error message. * Updated for HDFFV-11150, HDFFV-10480, and HDFFV-11159 * Update "Support for New Platforms and Compilers" section in RELEASE.txt; add check_version workaround for binary compatibility to "Known Problems". * Add SUSE Linux to tested platforms. * Update numbers in config/lt_vers.am and run bin/reconfigure for so numbers. * Update version in 3 files missed by merge. Co-authored-by: Allen Byrne <byrn@hdfgroup.org> Co-authored-by: Vailin Choi <vchoi@hdfgroup.org> Co-authored-by: vchoi <vchoi@jelly.ad.hdfgroup.org> Co-authored-by: hdftest <hdftest@hdfgroup.org> Co-authored-by: Jordan Henderson <jhenderson@hdfgroup.org> Co-authored-by: Dana Robinson <derobins@hdfgroup.org> Co-authored-by: Binh-Minh Ribler <bmribler@hdfgroup.org> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: bmribler <39579120+bmribler@users.noreply.github.com> Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org> Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Neil Fortner <nfortne2@hdfgroup.org>
Diffstat (limited to 'test/tunicode.c')
-rw-r--r--test/tunicode.c1142
1 files changed, 572 insertions, 570 deletions
diff --git a/test/tunicode.c b/test/tunicode.c
index 566c21c..f497aa3 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -6,38 +6,34 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Unicode test */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include "testhdf5.h"
-#define NUM_CHARS 16
-#define MAX_STRING_LENGTH ((NUM_CHARS * 4) + 1) /* Max length in bytes */
-#define MAX_PATH_LENGTH (MAX_STRING_LENGTH + 20) /* Max length in bytes */
-#define MAX_CODE_POINT 0x200000
-#define FILENAME "unicode.h5"
+#define NUM_CHARS 16
+#define MAX_STRING_LENGTH ((NUM_CHARS * 4) + 1) /* Max length in bytes */
+#define MAX_PATH_LENGTH (MAX_STRING_LENGTH + 20) /* Max length in bytes */
+#define MAX_CODE_POINT 0x200000
+#define FILENAME "unicode.h5"
/* A buffer to hold two copies of the UTF-8 string */
#define LONG_BUF_SIZE (2 * MAX_STRING_LENGTH + 4)
-#define DSET1_NAME "fl_string_dataset"
-#define DSET3_NAME "dataset3"
-#define DSET4_NAME "dataset4"
+#define DSET1_NAME "fl_string_dataset"
+#define DSET3_NAME "dataset3"
+#define DSET4_NAME "dataset4"
#define VL_DSET1_NAME "vl_dset_1"
-#define GROUP1_NAME "group1"
-#define GROUP2_NAME "group2"
-#define GROUP3_NAME "group3"
-#define GROUP4_NAME "group4"
-
-#define RANK 1
-#define COMP_INT_VAL 7
-#define COMP_FLOAT_VAL -42.0F
+#define GROUP1_NAME "group1"
+#define GROUP2_NAME "group2"
+#define GROUP3_NAME "group3"
+#define GROUP4_NAME "group4"
+
+#define RANK 1
+#define COMP_INT_VAL 7
+#define COMP_FLOAT_VAL -42.0F
#define COMP_DOUBLE_VAL 42.0F
/* Test function prototypes */
@@ -52,62 +48,63 @@ void test_opaque(hid_t fid, const char *string);
/* Utility function prototypes */
static hid_t mkstr(size_t len, H5T_str_t strpad);
-unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos);
-void dump_string(const char * string);
+unsigned int write_char(unsigned int c, char *test_string, unsigned int cur_pos);
+void dump_string(const char *string);
/*
* test_fl_string
* Tests that UTF-8 can be used for fixed-length string data.
* Writes the string to a dataset and reads it back again.
*/
-void test_fl_string(hid_t fid, const char *string)
+void
+test_fl_string(hid_t fid, const char *string)
{
- hid_t dtype_id, space_id, dset_id;
- hsize_t dims = 1;
- char read_buf[MAX_STRING_LENGTH];
- H5T_cset_t cset;
- herr_t ret;
-
- /* Create the datatype, ensure that the character set behaves
- * correctly (it should default to ASCII and can be set to UTF8)
- */
- dtype_id = H5Tcopy(H5T_C_S1);
- CHECK(dtype_id, FAIL, "H5Tcopy");
- ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH);
- CHECK(ret, FAIL, "H5Tset_size");
- cset = H5Tget_cset(dtype_id);
- VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset");
- ret = H5Tset_cset(dtype_id, H5T_CSET_UTF8);
- CHECK(ret, FAIL, "H5Tset_cset");
- cset = H5Tget_cset(dtype_id);
- VERIFY(cset, H5T_CSET_UTF8, "H5Tget_cset");
-
- /* Create dataspace for a dataset */
- space_id = H5Screate_simple(RANK, &dims, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
-
- /* Create a dataset */
- dset_id = H5Dcreate2(fid, DSET1_NAME, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dcreate2");
-
- /* Write UTF-8 string to dataset */
- ret = H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, string);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Read string back and make sure it is unchanged */
- ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf);
- CHECK(ret, FAIL, "H5Dread");
-
- VERIFY(HDstrcmp(string, read_buf), 0, "strcmp");
-
- /* Close all */
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
-
- ret = H5Tclose(dtype_id);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
+ hid_t dtype_id, space_id, dset_id;
+ hsize_t dims = 1;
+ char read_buf[MAX_STRING_LENGTH];
+ H5T_cset_t cset;
+ herr_t ret;
+
+ /* Create the datatype, ensure that the character set behaves
+ * correctly (it should default to ASCII and can be set to UTF8)
+ */
+ dtype_id = H5Tcopy(H5T_C_S1);
+ CHECK(dtype_id, FAIL, "H5Tcopy");
+ ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH);
+ CHECK(ret, FAIL, "H5Tset_size");
+ cset = H5Tget_cset(dtype_id);
+ VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset");
+ ret = H5Tset_cset(dtype_id, H5T_CSET_UTF8);
+ CHECK(ret, FAIL, "H5Tset_cset");
+ cset = H5Tget_cset(dtype_id);
+ VERIFY(cset, H5T_CSET_UTF8, "H5Tget_cset");
+
+ /* Create dataspace for a dataset */
+ space_id = H5Screate_simple(RANK, &dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(fid, DSET1_NAME, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate2");
+
+ /* Write UTF-8 string to dataset */
+ ret = H5Dwrite(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, string);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read string back and make sure it is unchanged */
+ ret = H5Dread(dset_id, dtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ VERIFY(HDstrcmp(string, read_buf), 0, "strcmp");
+
+ /* Close all */
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ ret = H5Tclose(dtype_id);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
}
/*
@@ -117,58 +114,58 @@ void test_fl_string(hid_t fid, const char *string)
* Borrows heavily from dtypes.c, but is more complicated because
* the string is randomly generated.
*/
-void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
+void
+test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
{
/* buf is used to hold the data that H5Tconvert operates on. */
- char buf[LONG_BUF_SIZE];
+ char buf[LONG_BUF_SIZE];
/* cmpbuf holds the output that H5Tconvert should produce,
* to compare against the actual output. */
- char cmpbuf[LONG_BUF_SIZE];
+ char cmpbuf[LONG_BUF_SIZE];
/* new_string is a slightly modified version of the UTF-8
* string to make the tests run more smoothly. */
- char new_string[MAX_STRING_LENGTH + 2];
+ char new_string[MAX_STRING_LENGTH + 2];
- size_t length; /* Length of new_string in bytes */
- size_t small_len; /* Size of the small datatype */
- size_t big_len; /* Size of the larger datatype */
- hid_t src_type, dst_type;
- herr_t ret;
+ size_t length; /* Length of new_string in bytes */
+ size_t small_len; /* Size of the small datatype */
+ size_t big_len; /* Size of the larger datatype */
+ hid_t src_type, dst_type;
+ herr_t ret;
/* The following tests are simpler if the UTF-8 string contains
* the right number of bytes (even or odd, depending on the test).
* We create a 'new_string' whose length is convenient by prepending
* an 'x' to 'string' when necessary. */
length = HDstrlen(string);
- if(length % 2 != 1)
- {
- HDstrcpy(new_string, "x");
- HDstrcat(new_string, string);
- length++;
- } else {
- HDstrcpy(new_string, string);
+ if (length % 2 != 1) {
+ HDstrcpy(new_string, "x");
+ HDstrcat(new_string, string);
+ length++;
+ }
+ else {
+ HDstrcpy(new_string, string);
}
-
/* Convert a null-terminated string to a shorter and longer null
* terminated string. */
/* Create a src_type that holds the UTF-8 string and its final NULL */
- big_len = length + 1; /* +1 byte for final NULL */
- HDassert((2*big_len)<=sizeof(cmpbuf));
+ big_len = length + 1; /* +1 byte for final NULL */
+ HDassert((2 * big_len) <= sizeof(cmpbuf));
src_type = mkstr(big_len, H5T_STR_NULLTERM);
CHECK(src_type, FAIL, "mkstr");
/* Create a dst_type that holds half of the UTF-8 string and a final
* NULL */
small_len = (length + 1) / 2;
- dst_type = mkstr(small_len, H5T_STR_NULLTERM);
+ dst_type = mkstr(small_len, H5T_STR_NULLTERM);
CHECK(dst_type, FAIL, "mkstr");
/* Fill the buffer with two copies of the UTF-8 string, each with a
* terminating NULL. It will look like "abcdefg\0abcdefg\0". */
- strncpy(buf, new_string, big_len);
- strncpy(&buf[big_len], new_string, big_len);
+ HDstrncpy(buf, new_string, big_len);
+ HDstrncpy(&buf[big_len], new_string, big_len);
ret = H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tconvert");
@@ -180,11 +177,11 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
* string manually. */
HDstrncpy(cmpbuf, new_string, small_len - 1);
cmpbuf[small_len - 1] = '\0';
- HDstrncpy(&cmpbuf[small_len], new_string, small_len -1);
+ HDstrncpy(&cmpbuf[small_len], new_string, small_len - 1);
cmpbuf[2 * small_len - 1] = '\0';
HDstrcpy(&cmpbuf[2 * small_len], new_string);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
/* Now convert from smaller datatype to bigger datatype. This should
* leave our buffer looking like: "abc\0\0\0\0\0abc\0\0\0\0\0" */
@@ -194,44 +191,43 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
/* First fill the buffer with NULLs */
HDmemset(cmpbuf, '\0', (size_t)LONG_BUF_SIZE);
/* Copy in the characters */
- HDstrncpy(cmpbuf, new_string, small_len -1);
- HDstrncpy(&cmpbuf[big_len], new_string, small_len -1);
+ HDstrncpy(cmpbuf, new_string, small_len - 1);
+ HDstrncpy(&cmpbuf[big_len], new_string, small_len - 1);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
ret = H5Tclose(src_type);
CHECK(ret, FAIL, "H5Tclose");
ret = H5Tclose(dst_type);
CHECK(ret, FAIL, "H5Tclose");
-
/* Now test null padding. Null-padded strings do *not* need
* terminating NULLs, so the sizes of the datatypes are slightly
* different and we want a string with an even number of characters. */
length = HDstrlen(string);
- if(length % 2 != 0)
- {
- HDstrcpy(new_string, "x");
- HDstrcat(new_string, string);
- length++;
- } else {
- HDstrcpy(new_string, string);
+ if (length % 2 != 0) {
+ HDstrcpy(new_string, "x");
+ HDstrcat(new_string, string);
+ length++;
+ }
+ else {
+ HDstrcpy(new_string, string);
}
/* Create a src_type that holds the UTF-8 string */
big_len = length;
- HDassert((2*big_len)<=sizeof(cmpbuf));
+ HDassert((2 * big_len) <= sizeof(cmpbuf));
src_type = mkstr(big_len, H5T_STR_NULLPAD);
CHECK(src_type, FAIL, "mkstr");
/* Create a dst_type that holds half of the UTF-8 string */
small_len = length / 2;
- dst_type = mkstr(small_len, H5T_STR_NULLPAD);
+ dst_type = mkstr(small_len, H5T_STR_NULLPAD);
CHECK(dst_type, FAIL, "mkstr");
/* Fill the buffer with two copies of the UTF-8 string.
* It will look like "abcdefghabcdefgh". */
- strncpy(buf, new_string, big_len);
- strncpy(&buf[big_len], new_string, big_len);
+ HDstrncpy(buf, new_string, big_len);
+ HDstrncpy(&buf[big_len], new_string, big_len);
ret = H5Tconvert(src_type, dst_type, (size_t)2, buf, NULL, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tconvert");
@@ -245,7 +241,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
HDstrncpy(&cmpbuf[small_len], new_string, small_len);
HDstrncpy(&cmpbuf[2 * small_len], new_string, big_len);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
/* Now convert from smaller datatype to bigger datatype. This should
* leave our buffer looking like: "abcd\0\0\0\0abcd\0\0\0\0" */
@@ -258,14 +254,13 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
HDstrncpy(cmpbuf, new_string, small_len);
HDstrncpy(&cmpbuf[big_len], new_string, small_len);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
ret = H5Tclose(src_type);
CHECK(ret, FAIL, "H5Tclose");
ret = H5Tclose(dst_type);
CHECK(ret, FAIL, "H5Tclose");
-
/* Test space padding. This is very similar to null-padding; we can
use the same values of length, small_len, and big_len. */
@@ -291,7 +286,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
HDstrncpy(&cmpbuf[small_len], new_string, small_len);
HDstrncpy(&cmpbuf[2 * small_len], new_string, big_len);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
/* Now convert from smaller datatype to bigger datatype. This should
* leave our buffer looking like: "abcd abcd " */
@@ -304,7 +299,7 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
HDstrncpy(cmpbuf, new_string, small_len);
HDstrncpy(&cmpbuf[big_len], new_string, small_len);
- VERIFY(HDmemcmp(buf, cmpbuf, 2*big_len), 0, "HDmemcmp");
+ VERIFY(HDmemcmp(buf, cmpbuf, 2 * big_len), 0, "HDmemcmp");
ret = H5Tclose(src_type);
CHECK(ret, FAIL, "H5Tclose");
@@ -312,60 +307,60 @@ void test_strpad(hid_t H5_ATTR_UNUSED fid, const char *string)
CHECK(ret, FAIL, "H5Tclose");
}
-
/*
* test_vl_string
* Tests variable-length string datatype with UTF-8 strings.
*/
-void test_vl_string(hid_t fid, const char *string)
+void
+test_vl_string(hid_t fid, const char *string)
{
- hid_t type_id, space_id, dset_id;
- hsize_t dims = 1;
- hsize_t size; /* Number of bytes used */
- char *read_buf[1];
- herr_t ret;
-
- /* Create dataspace for datasets */
- space_id = H5Screate_simple(RANK, &dims, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
-
- /* Create a datatype to refer to */
- type_id = H5Tcopy(H5T_C_S1);
- CHECK(type_id, FAIL, "H5Tcopy");
- ret = H5Tset_size(type_id, H5T_VARIABLE);
- CHECK(ret, FAIL, "H5Tset_size");
-
- /* Create a dataset */
- dset_id = H5Dcreate2(fid, VL_DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dcreate2");
-
- /* Write dataset to disk */
- ret = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Make certain the correct amount of memory will be used */
- ret = H5Dvlen_get_buf_size(dset_id, type_id, space_id, &size);
- CHECK(ret, FAIL, "H5Dvlen_get_buf_size");
- VERIFY(size, (hsize_t)HDstrlen(string) + 1, "H5Dvlen_get_buf_size");
-
- /* Read dataset from disk */
- ret = H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Compare data read in */
- VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp");
-
- /* Reclaim the read VL data */
- ret = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, read_buf);
- CHECK(ret, FAIL, "H5Dvlen_reclaim");
-
- /* Close all */
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Tclose(type_id);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
+ hid_t type_id, space_id, dset_id;
+ hsize_t dims = 1;
+ hsize_t size; /* Number of bytes used */
+ char * read_buf[1];
+ herr_t ret;
+
+ /* Create dataspace for datasets */
+ space_id = H5Screate_simple(RANK, &dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+
+ /* Create a datatype to refer to */
+ type_id = H5Tcopy(H5T_C_S1);
+ CHECK(type_id, FAIL, "H5Tcopy");
+ ret = H5Tset_size(type_id, H5T_VARIABLE);
+ CHECK(ret, FAIL, "H5Tset_size");
+
+ /* Create a dataset */
+ dset_id = H5Dcreate2(fid, VL_DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate2");
+
+ /* Write dataset to disk */
+ ret = H5Dwrite(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &string);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Make certain the correct amount of memory will be used */
+ ret = H5Dvlen_get_buf_size(dset_id, type_id, space_id, &size);
+ CHECK(ret, FAIL, "H5Dvlen_get_buf_size");
+ VERIFY(size, (hsize_t)HDstrlen(string) + 1, "H5Dvlen_get_buf_size");
+
+ /* Read dataset from disk */
+ ret = H5Dread(dset_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read in */
+ VERIFY(HDstrcmp(string, read_buf[0]), 0, "strcmp");
+
+ /* Reclaim the read VL data */
+ ret = H5Dvlen_reclaim(type_id, space_id, H5P_DEFAULT, read_buf);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
+ /* Close all */
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
}
/*
@@ -378,345 +373,348 @@ void test_vl_string(hid_t fid, const char *string)
* was added to links it didn't change how they were stored in the file,
* -JML 2/2/2006
*/
-void test_objnames(hid_t fid, const char* string)
+void
+test_objnames(hid_t fid, const char *string)
{
- hid_t grp_id, grp1_id, grp2_id, grp3_id;
- hid_t type_id, dset_id, space_id;
- char read_buf[MAX_STRING_LENGTH];
- char path_buf[MAX_PATH_LENGTH];
- hsize_t dims=1;
- hobj_ref_t obj_ref;
- herr_t ret;
-
- /* Create a group with a UTF-8 name */
- grp_id = H5Gcreate2(fid, string, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp_id, FAIL, "H5Gcreate2");
-
- /* Set a comment on the group to test that we can access the group
- * Also test that UTF-8 comments can be read.
- */
- ret = H5Oset_comment_by_name(fid, string, string, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oset_comment_by_name");
- ret = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_comment_by_name");
-
- ret = H5Gclose(grp_id);
- CHECK(ret, FAIL, "H5Gclose");
-
- VERIFY(HDstrcmp(string, read_buf), 0, "strcmp");
-
- /* Create a new dataset with a UTF-8 name */
- grp1_id = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp1_id, FAIL, "H5Gcreate2");
-
- space_id = H5Screate_simple(RANK, &dims, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
- dset_id = H5Dcreate2(grp1_id, string, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dcreate2");
-
- /* Make sure that dataset can be opened again */
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
-
- dset_id = H5Dopen2(grp1_id, string, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Dopen2");
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Gclose(grp1_id);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Do the same for a named datatype */
- grp2_id = H5Gcreate2(fid, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp2_id, FAIL, "H5Gcreate2");
-
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
- CHECK(type_id, FAIL, "H5Tcreate");
- ret = H5Tcommit2(grp2_id, string, type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(type_id, FAIL, "H5Tcommit2");
- ret = H5Tclose(type_id);
- CHECK(type_id, FAIL, "H5Tclose");
-
- type_id = H5Topen2(grp2_id, string, H5P_DEFAULT);
- CHECK(type_id, FAIL, "H5Topen2");
- ret = H5Tclose(type_id);
- CHECK(type_id, FAIL, "H5Tclose");
-
- /* Don't close the group -- use it to test that object references
- * can refer to objects named in UTF-8 */
-
- space_id = H5Screate_simple(RANK, &dims, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
- dset_id = H5Dcreate2(grp2_id, DSET3_NAME, H5T_STD_REF_OBJ, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Dcreate2");
-
- /* Create reference to named datatype */
- ret = H5Rcreate(&obj_ref, grp2_id, string, H5R_OBJECT, (hid_t)-1);
- CHECK(ret, FAIL, "H5Rcreate");
- /* Write selection and read it back*/
- ret = H5Dwrite(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref);
- CHECK(ret, FAIL, "H5Dwrite");
- ret = H5Dread(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref);
- CHECK(ret, FAIL, "H5Dread");
-
- /* Ensure that we can open named datatype using object reference */
- type_id = H5Rdereference(dset_id, H5R_OBJECT, &obj_ref);
- CHECK(type_id, FAIL, "H5Rdereference");
- ret = H5Tcommitted(type_id);
- VERIFY(ret, 1, "H5Tcommitted");
-
- ret = H5Tclose(type_id);
- CHECK(type_id, FAIL, "H5Tclose");
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
-
- ret = H5Gclose(grp2_id);
- CHECK(ret, FAIL, "H5Gclose");
-
- /* Create "group3". Build a hard link from group3 to group2, which has
- * a datatype with the UTF-8 name. Create a soft link in group3
- * pointing through the hard link to the datatype. Give the soft
- * link a name in UTF-8. Ensure that the soft link works. */
-
- grp3_id = H5Gcreate2(fid, GROUP3_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(grp3_id, FAIL, "H5Gcreate2");
-
- ret = H5Lcreate_hard(fid, GROUP2_NAME, grp3_id, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Lcreate_hard");
- HDstrcpy(path_buf, GROUP2_NAME);
- HDstrcat(path_buf, "/");
- HDstrcat(path_buf, string);
- ret = H5Lcreate_hard(grp3_id, path_buf, H5L_SAME_LOC, string, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Lcreate_hard");
-
- /* Open named datatype using soft link */
- type_id = H5Topen2(grp3_id, string, H5P_DEFAULT);
- CHECK(type_id, FAIL, "H5Topen2");
-
- ret = H5Tclose(type_id);
- CHECK(type_id, FAIL, "H5Tclose");
- ret = H5Gclose(grp3_id);
- CHECK(ret, FAIL, "H5Gclose");
+ hid_t grp_id, grp1_id, grp2_id, grp3_id;
+ hid_t type_id, dset_id, space_id;
+ char read_buf[MAX_STRING_LENGTH];
+ char path_buf[MAX_PATH_LENGTH];
+ hsize_t dims = 1;
+ hobj_ref_t obj_ref;
+ ssize_t size;
+ herr_t ret;
+
+ /* Create a group with a UTF-8 name */
+ grp_id = H5Gcreate2(fid, string, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(grp_id, FAIL, "H5Gcreate2");
+
+ /* Set a comment on the group to test that we can access the group
+ * Also test that UTF-8 comments can be read.
+ */
+ ret = H5Oset_comment_by_name(fid, string, string, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oset_comment_by_name");
+ size = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT);
+ CHECK(size, FAIL, "H5Oget_comment_by_name");
+
+ ret = H5Gclose(grp_id);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ VERIFY(HDstrcmp(string, read_buf), 0, "strcmp");
+
+ /* Create a new dataset with a UTF-8 name */
+ grp1_id = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(grp1_id, FAIL, "H5Gcreate2");
+
+ space_id = H5Screate_simple(RANK, &dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+ dset_id = H5Dcreate2(grp1_id, string, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate2");
+
+ /* Make sure that dataset can be opened again */
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ dset_id = H5Dopen2(grp1_id, string, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Dopen2");
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Gclose(grp1_id);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Do the same for a named datatype */
+ grp2_id = H5Gcreate2(fid, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(grp2_id, FAIL, "H5Gcreate2");
+
+ type_id = H5Tcreate(H5T_OPAQUE, (size_t)1);
+ CHECK(type_id, FAIL, "H5Tcreate");
+ ret = H5Tcommit2(grp2_id, string, type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(type_id, FAIL, "H5Tcommit2");
+ ret = H5Tclose(type_id);
+ CHECK(type_id, FAIL, "H5Tclose");
+
+ type_id = H5Topen2(grp2_id, string, H5P_DEFAULT);
+ CHECK(type_id, FAIL, "H5Topen2");
+ ret = H5Tclose(type_id);
+ CHECK(type_id, FAIL, "H5Tclose");
+
+ /* Don't close the group -- use it to test that object references
+ * can refer to objects named in UTF-8 */
+
+ space_id = H5Screate_simple(RANK, &dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+ dset_id =
+ H5Dcreate2(grp2_id, DSET3_NAME, H5T_STD_REF_OBJ, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Dcreate2");
+
+ /* Create reference to named datatype */
+ ret = H5Rcreate(&obj_ref, grp2_id, string, H5R_OBJECT, (hid_t)-1);
+ CHECK(ret, FAIL, "H5Rcreate");
+ /* Write selection and read it back*/
+ ret = H5Dwrite(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref);
+ CHECK(ret, FAIL, "H5Dwrite");
+ ret = H5Dread(dset_id, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &obj_ref);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Ensure that we can open named datatype using object reference */
+ type_id = H5Rdereference(dset_id, H5R_OBJECT, &obj_ref);
+ CHECK(type_id, FAIL, "H5Rdereference");
+ ret = H5Tcommitted(type_id);
+ VERIFY(ret, 1, "H5Tcommitted");
+
+ ret = H5Tclose(type_id);
+ CHECK(type_id, FAIL, "H5Tclose");
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ ret = H5Gclose(grp2_id);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Create "group3". Build a hard link from group3 to group2, which has
+ * a datatype with the UTF-8 name. Create a soft link in group3
+ * pointing through the hard link to the datatype. Give the soft
+ * link a name in UTF-8. Ensure that the soft link works. */
+
+ grp3_id = H5Gcreate2(fid, GROUP3_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(grp3_id, FAIL, "H5Gcreate2");
+
+ ret = H5Lcreate_hard(fid, GROUP2_NAME, grp3_id, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_hard");
+ HDstrcpy(path_buf, GROUP2_NAME);
+ HDstrcat(path_buf, "/");
+ HDstrcat(path_buf, string);
+ ret = H5Lcreate_hard(grp3_id, path_buf, H5L_SAME_LOC, string, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_hard");
+
+ /* Open named datatype using soft link */
+ type_id = H5Topen2(grp3_id, string, H5P_DEFAULT);
+ CHECK(type_id, FAIL, "H5Topen2");
+
+ ret = H5Tclose(type_id);
+ CHECK(type_id, FAIL, "H5Tclose");
+ ret = H5Gclose(grp3_id);
+ CHECK(ret, FAIL, "H5Gclose");
}
/*
* test_attrname
* Test that attributes can deal with UTF-8 strings
*/
-void test_attrname(hid_t fid, const char * string)
+void
+test_attrname(hid_t fid, const char *string)
{
- hid_t group_id, attr_id;
- hid_t dtype_id, space_id;
- hsize_t dims=1;
- char read_buf[MAX_STRING_LENGTH];
- herr_t ret;
-
- /* Create a new group and give it an attribute whose
- * name and value are UTF-8 strings.
- */
- group_id = H5Gcreate2(fid, GROUP4_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(group_id, FAIL, "H5Gcreate2");
-
- space_id = H5Screate_simple(RANK, &dims, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
- dtype_id = H5Tcopy(H5T_C_S1);
- CHECK(dtype_id, FAIL, "H5Tcopy");
- ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH);
- CHECK(ret, FAIL, "H5Tset_size");
-
- /* Create the attribute and check that its name is correct */
- attr_id = H5Acreate2(group_id, string, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(attr_id, FAIL, "H5Acreate2");
- ret = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf);
- CHECK(ret, FAIL, "H5Aget_name");
- ret = strcmp(read_buf, string);
- VERIFY(ret, 0, "strcmp");
- read_buf[0] = '\0';
-
- /* Try writing and reading from the attribute */
- ret = H5Awrite(attr_id, dtype_id, string);
- CHECK(ret, FAIL, "H5Awrite");
- ret = H5Aread(attr_id, dtype_id, read_buf);
- CHECK(ret, FAIL, "H5Aread");
- ret = strcmp(read_buf, string);
- VERIFY(ret, 0, "strcmp");
-
- /* Clean up */
- ret = H5Aclose(attr_id);
- CHECK(ret, FAIL, "H5Aclose");
- ret = H5Tclose(dtype_id);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
- ret = H5Gclose(group_id);
- CHECK(ret, FAIL, "H5Gclose");
+ hid_t group_id, attr_id;
+ hid_t dtype_id, space_id;
+ hsize_t dims = 1;
+ char read_buf[MAX_STRING_LENGTH];
+ ssize_t size;
+ herr_t ret;
+
+ /* Create a new group and give it an attribute whose
+ * name and value are UTF-8 strings.
+ */
+ group_id = H5Gcreate2(fid, GROUP4_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(group_id, FAIL, "H5Gcreate2");
+
+ space_id = H5Screate_simple(RANK, &dims, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+ dtype_id = H5Tcopy(H5T_C_S1);
+ CHECK(dtype_id, FAIL, "H5Tcopy");
+ ret = H5Tset_size(dtype_id, (size_t)MAX_STRING_LENGTH);
+ CHECK(ret, FAIL, "H5Tset_size");
+
+ /* Create the attribute and check that its name is correct */
+ attr_id = H5Acreate2(group_id, string, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr_id, FAIL, "H5Acreate2");
+ size = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf);
+ CHECK(size, FAIL, "H5Aget_name");
+ ret = strcmp(read_buf, string);
+ VERIFY(ret, 0, "strcmp");
+ read_buf[0] = '\0';
+
+ /* Try writing and reading from the attribute */
+ ret = H5Awrite(attr_id, dtype_id, string);
+ CHECK(ret, FAIL, "H5Awrite");
+ ret = H5Aread(attr_id, dtype_id, read_buf);
+ CHECK(ret, FAIL, "H5Aread");
+ ret = strcmp(read_buf, string);
+ VERIFY(ret, 0, "strcmp");
+
+ /* Clean up */
+ ret = H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Tclose(dtype_id);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Gclose(group_id);
+ CHECK(ret, FAIL, "H5Gclose");
}
/*
* test_compound
* Test that compound datatypes can have UTF-8 field names.
*/
-void test_compound(hid_t fid, const char * string)
+void
+test_compound(hid_t fid, const char *string)
{
- /* Define two compound structures, s1_t and s2_t.
- * s2_t is a subset of s1_t, with two out of three
- * fields.
- * This is stolen from the h5_compound example.
- */
- typedef struct s1_t {
- int a;
- double c;
- float b;
- } s1_t;
- typedef struct s2_t {
- double c;
- int a;
- } s2_t;
- /* Actual variable declarations */
- s1_t s1;
- s2_t s2;
- hid_t s1_tid, s2_tid;
- hid_t space_id, dset_id;
- hsize_t dim = 1;
- char *readbuf;
- herr_t ret;
-
- /* Initialize compound data */
- HDmemset(&s1, 0, sizeof(s1_t)); /* To make purify happy */
- s1.a = COMP_INT_VAL;
- s1.c = COMP_DOUBLE_VAL;
- s1.b = COMP_FLOAT_VAL;
-
- /* Create compound datatypes using UTF-8 field name */
- s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
- CHECK(s1_tid, FAIL, "H5Tcreate");
- ret = H5Tinsert(s1_tid, string, HOFFSET(s1_t, a), H5T_NATIVE_INT);
- CHECK(ret, FAIL, "H5Tinsert");
-
- /* Check that the field name was stored correctly */
- readbuf = H5Tget_member_name(s1_tid, 0);
- ret = HDstrcmp(readbuf, string);
- VERIFY(ret, 0, "strcmp");
- H5free_memory(readbuf);
-
- /* Add the other fields to the datatype */
- ret = H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
- CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
- CHECK(ret, FAIL, "H5Tinsert");
-
- /* Create second datatype, with only two fields. */
- s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t));
- CHECK(s2_tid, FAIL, "H5Tcreate");
- ret = H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE);
- CHECK(ret, FAIL, "H5Tinsert");
- ret = H5Tinsert(s2_tid, string, HOFFSET(s2_t, a), H5T_NATIVE_INT);
- CHECK(ret, FAIL, "H5Tinsert");
-
- /* Create the dataspace and dataset. */
- space_id = H5Screate_simple(1, &dim, NULL);
- CHECK(space_id, FAIL, "H5Screate_simple");
- dset_id = H5Dcreate2(fid, DSET4_NAME, s1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dset_id, FAIL, "H5Dcreate2");
-
- /* Write data to the dataset. */
- ret = H5Dwrite(dset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s1);
- CHECK(ret, FAIL, "H5Dwrite");
-
- /* Ensure that data can be read back by field name into s2 struct */
- ret = H5Dread(dset_id, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s2);
- CHECK(ret, FAIL, "H5Dread");
-
- VERIFY(s2.a, COMP_INT_VAL, "H5Dread");
- VERIFY(s2.c, COMP_DOUBLE_VAL, "H5Dread");
-
- /* Clean up */
- ret = H5Tclose(s1_tid);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Tclose(s2_tid);
- CHECK(ret, FAIL, "H5Tclose");
- ret = H5Sclose(space_id);
- CHECK(ret, FAIL, "H5Sclose");
- ret = H5Dclose(dset_id);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Define two compound structures, s1_t and s2_t.
+ * s2_t is a subset of s1_t, with two out of three
+ * fields.
+ * This is stolen from the h5_compound example.
+ */
+ typedef struct s1_t {
+ int a;
+ double c;
+ float b;
+ } s1_t;
+ typedef struct s2_t {
+ double c;
+ int a;
+ } s2_t;
+ /* Actual variable declarations */
+ s1_t s1;
+ s2_t s2;
+ hid_t s1_tid, s2_tid;
+ hid_t space_id, dset_id;
+ hsize_t dim = 1;
+ char * readbuf;
+ herr_t ret;
+
+ /* Initialize compound data */
+ HDmemset(&s1, 0, sizeof(s1_t)); /* To make purify happy */
+ s1.a = COMP_INT_VAL;
+ s1.c = COMP_DOUBLE_VAL;
+ s1.b = COMP_FLOAT_VAL;
+
+ /* Create compound datatypes using UTF-8 field name */
+ s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
+ CHECK(s1_tid, FAIL, "H5Tcreate");
+ ret = H5Tinsert(s1_tid, string, HOFFSET(s1_t, a), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Check that the field name was stored correctly */
+ readbuf = H5Tget_member_name(s1_tid, 0);
+ ret = HDstrcmp(readbuf, string);
+ VERIFY(ret, 0, "strcmp");
+ H5free_memory(readbuf);
+
+ /* Add the other fields to the datatype */
+ ret = H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
+ CHECK(ret, FAIL, "H5Tinsert");
+ ret = H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create second datatype, with only two fields. */
+ s2_tid = H5Tcreate(H5T_COMPOUND, sizeof(s2_t));
+ CHECK(s2_tid, FAIL, "H5Tcreate");
+ ret = H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE);
+ CHECK(ret, FAIL, "H5Tinsert");
+ ret = H5Tinsert(s2_tid, string, HOFFSET(s2_t, a), H5T_NATIVE_INT);
+ CHECK(ret, FAIL, "H5Tinsert");
+
+ /* Create the dataspace and dataset. */
+ space_id = H5Screate_simple(1, &dim, NULL);
+ CHECK(space_id, FAIL, "H5Screate_simple");
+ dset_id = H5Dcreate2(fid, DSET4_NAME, s1_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate2");
+
+ /* Write data to the dataset. */
+ ret = H5Dwrite(dset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s1);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Ensure that data can be read back by field name into s2 struct */
+ ret = H5Dread(dset_id, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &s2);
+ CHECK(ret, FAIL, "H5Dread");
+
+ VERIFY(s2.a, COMP_INT_VAL, "H5Dread");
+ VERIFY(s2.c, COMP_DOUBLE_VAL, "H5Dread");
+
+ /* Clean up */
+ ret = H5Tclose(s1_tid);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Tclose(s2_tid);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
}
/*
* test_enum
* Test that enumerated datatypes can have UTF-8 member names.
*/
-void test_enum(hid_t H5_ATTR_UNUSED fid, const char * string)
+void
+test_enum(hid_t H5_ATTR_UNUSED fid, const char *string)
{
- /* Define an enumerated type */
- typedef enum {
- E1_RED,
- E1_GREEN,
- E1_BLUE,
- E1_WHITE
- } c_e1;
- /* Variable declarations */
- c_e1 val;
- herr_t ret;
- hid_t type_id;
- char readbuf[MAX_STRING_LENGTH];
-
- /* Create an enumerated datatype in HDF5 with a UTF-8 member name*/
- type_id = H5Tcreate(H5T_ENUM, sizeof(c_e1));
- CHECK(type_id, FAIL, "H5Tcreate");
- val = E1_RED;
- ret = H5Tenum_insert(type_id, "RED", &val);
- CHECK(ret, FAIL, "H5Tenum_insert");
- val = E1_GREEN;
- ret = H5Tenum_insert(type_id, "GREEN", &val);
- CHECK(ret, FAIL, "H5Tenum_insert");
- val = E1_BLUE;
- ret = H5Tenum_insert(type_id, "BLUE", &val);
- CHECK(ret, FAIL, "H5Tenum_insert");
- val = E1_WHITE;
- ret = H5Tenum_insert(type_id, string, &val);
- CHECK(ret, FAIL, "H5Tenum_insert");
-
- /* Ensure that UTF-8 member name gives the right value and vice versa. */
- ret = H5Tenum_valueof(type_id, string, &val);
- CHECK(ret, FAIL, "H5Tenum_valueof");
- VERIFY(val, E1_WHITE, "H5Tenum_valueof");
- ret = H5Tenum_nameof(type_id, &val, readbuf, (size_t)MAX_STRING_LENGTH);
- CHECK(ret, FAIL, "H5Tenum_nameof");
- ret = strcmp(readbuf, string);
- VERIFY(ret, 0, "strcmp");
-
- /* Close the datatype */
- ret = H5Tclose(type_id);
- CHECK(ret, FAIL, "H5Tclose");
+ /* Define an enumerated type */
+ typedef enum { E1_RED, E1_GREEN, E1_BLUE, E1_WHITE } c_e1;
+ /* Variable declarations */
+ c_e1 val;
+ herr_t ret;
+ hid_t type_id;
+ char readbuf[MAX_STRING_LENGTH];
+
+ /* Create an enumerated datatype in HDF5 with a UTF-8 member name*/
+ type_id = H5Tcreate(H5T_ENUM, sizeof(c_e1));
+ CHECK(type_id, FAIL, "H5Tcreate");
+ val = E1_RED;
+ ret = H5Tenum_insert(type_id, "RED", &val);
+ CHECK(ret, FAIL, "H5Tenum_insert");
+ val = E1_GREEN;
+ ret = H5Tenum_insert(type_id, "GREEN", &val);
+ CHECK(ret, FAIL, "H5Tenum_insert");
+ val = E1_BLUE;
+ ret = H5Tenum_insert(type_id, "BLUE", &val);
+ CHECK(ret, FAIL, "H5Tenum_insert");
+ val = E1_WHITE;
+ ret = H5Tenum_insert(type_id, string, &val);
+ CHECK(ret, FAIL, "H5Tenum_insert");
+
+ /* Ensure that UTF-8 member name gives the right value and vice versa. */
+ ret = H5Tenum_valueof(type_id, string, &val);
+ CHECK(ret, FAIL, "H5Tenum_valueof");
+ VERIFY(val, E1_WHITE, "H5Tenum_valueof");
+ ret = H5Tenum_nameof(type_id, &val, readbuf, (size_t)MAX_STRING_LENGTH);
+ CHECK(ret, FAIL, "H5Tenum_nameof");
+ ret = strcmp(readbuf, string);
+ VERIFY(ret, 0, "strcmp");
+
+ /* Close the datatype */
+ ret = H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
}
/*
* test_opaque
* Test comments on opaque datatypes
*/
-void test_opaque(hid_t H5_ATTR_UNUSED fid, const char * string)
+void
+test_opaque(hid_t H5_ATTR_UNUSED fid, const char *string)
{
- hid_t type_id;
- char * read_buf;
- herr_t ret;
-
- /* Create an opaque type and give it a UTF-8 tag */
- type_id = H5Tcreate(H5T_OPAQUE, (size_t)4);
- CHECK(type_id, FAIL, "H5Tcreate");
- ret = H5Tset_tag(type_id, string);
- CHECK(ret, FAIL, "H5Tset_tag");
-
- /* Read the tag back. */
- read_buf = H5Tget_tag(type_id);
- ret = strcmp(read_buf, string);
- VERIFY(ret, 0, "H5Tget_tag");
- H5free_memory(read_buf);
-
- ret = H5Tclose(type_id);
- CHECK(ret, FAIL, "H5Tclose");
+ hid_t type_id;
+ char * read_buf;
+ herr_t ret;
+
+ /* Create an opaque type and give it a UTF-8 tag */
+ type_id = H5Tcreate(H5T_OPAQUE, (size_t)4);
+ CHECK(type_id, FAIL, "H5Tcreate");
+ ret = H5Tset_tag(type_id, string);
+ CHECK(ret, FAIL, "H5Tset_tag");
+
+ /* Read the tag back. */
+ read_buf = H5Tget_tag(type_id);
+ ret = strcmp(read_buf, string);
+ VERIFY(ret, 0, "H5Tget_tag");
+ H5free_memory(read_buf);
+
+ ret = H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
}
/*********************/
@@ -726,12 +724,16 @@ void test_opaque(hid_t H5_ATTR_UNUSED fid, const char * string)
/* mkstr
* Borrwed from dtypes.c.
* Creates a new string data type. Used in string padding tests */
-static hid_t mkstr(size_t len, H5T_str_t strpad)
+static hid_t
+mkstr(size_t len, H5T_str_t strpad)
{
- hid_t t;
- if((t = H5Tcopy(H5T_C_S1)) < 0) return -1;
- if(H5Tset_size(t, len) < 0) return -1;
- if(H5Tset_strpad(t, strpad) < 0) return -1;
+ hid_t t;
+ if ((t = H5Tcopy(H5T_C_S1)) < 0)
+ return -1;
+ if (H5Tset_size(t, len) < 0)
+ return -1;
+ if (H5Tset_strpad(t, strpad) < 0)
+ return -1;
return t;
}
@@ -739,124 +741,124 @@ static hid_t mkstr(size_t len, H5T_str_t strpad)
* Append a unicode code point c to test_string in UTF-8 encoding.
* Return the new end of the string.
*/
-unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos)
+unsigned int
+write_char(unsigned int c, char *test_string, unsigned int cur_pos)
{
- if (c < 0x80) {
- test_string[cur_pos] = c;
- cur_pos++;
- }
- else if (c < 0x800) {
- test_string[cur_pos] = (0xC0 | c>>6);
- test_string[cur_pos+1] = (0x80 | (c & 0x3F));
- cur_pos += 2;
- }
- else if (c < 0x10000) {
- test_string[cur_pos] = (0xE0 | c>>12);
- test_string[cur_pos+1] = (0x80 | (c>>6 & 0x3F));
- test_string[cur_pos+2] = (0x80 | (c & 0x3F));
- cur_pos += 3;
- }
- else if (c < 0x200000) {
- test_string[cur_pos] = (0xF0 | c>>18);
- test_string[cur_pos+1] = (0x80 | (c>>12 & 0x3F));
- test_string[cur_pos+2] = (0x80 | (c>>6 & 0x3F));
- test_string[cur_pos+3] = (0x80 | (c & 0x3F));
- cur_pos += 4;
- }
-
- return cur_pos;
+ if (c < 0x80) {
+ test_string[cur_pos] = (char)c;
+ cur_pos++;
+ }
+ else if (c < 0x800) {
+ test_string[cur_pos] = (char)(0xC0 | c >> 6);
+ test_string[cur_pos + 1] = (char)(0x80 | (c & 0x3F));
+ cur_pos += 2;
+ }
+ else if (c < 0x10000) {
+ test_string[cur_pos] = (char)(0xE0 | c >> 12);
+ test_string[cur_pos + 1] = (char)(0x80 | (c >> 6 & 0x3F));
+ test_string[cur_pos + 2] = (char)(0x80 | (c & 0x3F));
+ cur_pos += 3;
+ }
+ else if (c < 0x200000) {
+ test_string[cur_pos] = (char)(0xF0 | c >> 18);
+ test_string[cur_pos + 1] = (char)(0x80 | (c >> 12 & 0x3F));
+ test_string[cur_pos + 2] = (char)(0x80 | (c >> 6 & 0x3F));
+ test_string[cur_pos + 3] = (char)(0x80 | (c & 0x3F));
+ cur_pos += 4;
+ }
+
+ return cur_pos;
}
/* dump_string
* Print a string both as text (which will look like garbage) and as hex.
* The text display is not guaranteed to be accurate--certain characters
* could confuse printf (e.g., '\n'). */
-void dump_string(const char * string)
+void
+dump_string(const char *string)
{
- unsigned int length;
- unsigned int x;
+ size_t length;
+ size_t x;
- printf("The string was:\n %s", string);
- printf("Or in hex:\n");
+ HDprintf("The string was:\n %s", string);
+ HDprintf("Or in hex:\n");
- length = strlen(string);
+ length = HDstrlen(string);
- for(x=0; x<length; x++)
- printf("%x ", string[x] & (0x000000FF));
+ for (x = 0; x < length; x++)
+ HDprintf("%x ", string[x] & (0x000000FF));
- printf("\n");
+ HDprintf("\n");
}
/* Main test.
* Create a string of random Unicode characters, then run each test with
* that string.
*/
-void test_unicode(void)
+void
+test_unicode(void)
{
- char test_string[MAX_STRING_LENGTH];
- unsigned int cur_pos=0; /* Current position in test_string */
- unsigned int unicode_point; /* Unicode code point for a single character */
- hid_t fid; /* ID of file */
- int x; /* Temporary variable */
- herr_t ret; /* Generic return value */
-
- /* Output message about test being performed */
- MESSAGE(5, ("Testing UTF-8 Encoding\n"));
-
- /* Create a random string with length NUM_CHARS */
- HDsrandom((unsigned)HDtime(NULL));
-
- HDmemset(test_string, 0, sizeof(test_string));
- for(x=0; x<NUM_CHARS; x++)
- {
- /* We need to avoid unprintable characters (codes 0-31) and the
- * . and / characters, since they aren't allowed in path names.
+ char test_string[MAX_STRING_LENGTH];
+ unsigned int cur_pos = 0; /* Current position in test_string */
+ unsigned int unicode_point; /* Unicode code point for a single character */
+ hid_t fid; /* ID of file */
+ int x; /* Temporary variable */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing UTF-8 Encoding\n"));
+
+ /* Create a random string with length NUM_CHARS */
+ HDsrandom((unsigned)HDtime(NULL));
+
+ HDmemset(test_string, 0, sizeof(test_string));
+ for (x = 0; x < NUM_CHARS; x++) {
+ /* We need to avoid unprintable characters (codes 0-31) and the
+ * . and / characters, since they aren't allowed in path names.
+ */
+ unicode_point = (unsigned)(HDrandom() % (MAX_CODE_POINT - 32)) + 32;
+ if (unicode_point != 46 && unicode_point != 47)
+ cur_pos = write_char(unicode_point, test_string, cur_pos);
+ }
+
+ /* Avoid unlikely case of the null string */
+ if (cur_pos == 0) {
+ test_string[cur_pos] = 'Q';
+ cur_pos++;
+ }
+ test_string[cur_pos] = '\0';
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ test_fl_string(fid, test_string);
+ test_strpad(fid, "abcdefgh");
+ test_strpad(fid, test_string);
+ test_vl_string(fid, test_string);
+ test_objnames(fid, test_string);
+ test_attrname(fid, test_string);
+ test_compound(fid, test_string);
+ test_enum(fid, test_string);
+ test_opaque(fid, test_string);
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* This function could be useful in debugging if certain strings
+ * create errors.
*/
- unicode_point = (HDrandom() % (MAX_CODE_POINT-32)) + 32;
- if(unicode_point != 46 && unicode_point != 47)
- cur_pos = write_char(unicode_point, test_string, cur_pos);
- }
-
- /* Avoid unlikely case of the null string */
- if(cur_pos == 0)
- {
- test_string[cur_pos] = 'Q';
- cur_pos++;
- }
- test_string[cur_pos]='\0';
-
- /* Create file */
- fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(fid, FAIL, "H5Fcreate");
-
- test_fl_string(fid, test_string);
- test_strpad(fid, "abcdefgh");
- test_strpad(fid, test_string);
- test_vl_string(fid, test_string);
- test_objnames(fid, test_string);
- test_attrname(fid, test_string);
- test_compound(fid, test_string);
- test_enum(fid, test_string);
- test_opaque(fid, test_string);
-
- /* Close file */
- ret = H5Fclose(fid);
- CHECK(ret, FAIL, "H5Fclose");
-
- /* This function could be useful in debugging if certain strings
- * create errors.
- */
#ifdef DEBUG
- dump_string(test_string);
+ dump_string(test_string);
#endif /* DEBUG */
}
/* cleanup_unicode(void)
* Delete the file this test created.
*/
-void cleanup_unicode(void)
+void
+cleanup_unicode(void)
{
- remove(FILENAME);
+ HDremove(FILENAME);
}
-
-