diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5tools_str.c | 25 | ||||
-rw-r--r-- | tools/testfiles/tenum.ddl | 36 | ||||
-rw-r--r-- | tools/testfiles/tenum.h5 | bin | 1560 -> 2128 bytes | |||
-rw-r--r-- | tools/testfiles/tenum.h5.xml | 23 |
4 files changed, 45 insertions, 39 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index b3ee8e3..0ed66b4 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -962,15 +962,24 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) size_t n = strlen(s); const char *escape; char octal[8]; - + for (i = 0; i < n; i++) { switch (s[i]) { - case '"': + case '\'': + escape = "\\\'"; + break; + case '\"': escape = "\\\""; break; case '\\': escape = "\\\\"; break; + case '\?': + escape = "\\\?"; + break; + case '\a': + escape = "\\a"; + break; case '\b': escape = "\\b"; break; @@ -986,11 +995,11 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) case '\t': escape = "\\t"; break; - case ' ': - escape = escape_spaces ? "\\ " : NULL; + case '\v': + escape = "\\v"; break; default: - if (!isprint((int)*s)) { + if (!isprint(s[i])) { sprintf(octal, "\\%03o", (unsigned char)s[i]); escape = octal; } else { @@ -1007,10 +1016,10 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) /*would overflow*/ return NULL; - memmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/ + memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ memcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size; - i += esc_size - 1; + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ } } diff --git a/tools/testfiles/tenum.ddl b/tools/testfiles/tenum.ddl index fdd3a60..496647d 100644 --- a/tools/testfiles/tenum.ddl +++ b/tools/testfiles/tenum.ddl @@ -3,30 +3,24 @@ Expected output for 'h5dump tenum.h5' ############################# HDF5 "tenum.h5" { GROUP "/" { - DATATYPE "enum normal" { - H5T_ENUM - { H5T_STD_I32BE; - "RED" 0; - "GREEN" 1; - "BLUE" 2; - "WHITE" 3; - "BLACK" 4; + DATATYPE "enum normal" H5T_ENUM { + H5T_STD_I32LE; + "RED" 0; + "GREEN +green" 1; + "BLUE blue" 2; + "WHITE "white"" 3; + "BLACK 'black'" 4; }; - } + DATASET "table" { - DATATYPE { H5T_ENUM - { H5T_STD_I32BE; - "RED" 0; - "GREEN" 1; - "BLUE" 2; - "WHITE" 3; - "BLACK" 4; - } - } - DATASPACE { SIMPLE ( 20 ) / ( 20 ) } + DATATYPE "/enum normal" + DATASPACE SIMPLE { ( 20 ) / ( 20 ) } DATA { - RED, GREEN, BLUE, GREEN, WHITE, WHITE, BLACK, GREEN, BLUE, RED, RED, - BLUE, GREEN, BLACK, WHITE, RED, WHITE, GREEN, GREEN, BLUE + RED, GREEN\ngreen, BLUE blue, GREEN\ngreen, WHITE \"white\", + WHITE \"white\", BLACK \'black\', GREEN\ngreen, BLUE blue, RED, RED, + BLUE blue, GREEN\ngreen, BLACK \'black\', WHITE \"white\", RED, + WHITE \"white\", GREEN\ngreen, GREEN\ngreen, BLUE blue } } } diff --git a/tools/testfiles/tenum.h5 b/tools/testfiles/tenum.h5 Binary files differindex 89a3379..667be98 100644 --- a/tools/testfiles/tenum.h5 +++ b/tools/testfiles/tenum.h5 diff --git a/tools/testfiles/tenum.h5.xml b/tools/testfiles/tenum.h5.xml index 0d6c3dd..231d9cd 100644 --- a/tools/testfiles/tenum.h5.xml +++ b/tools/testfiles/tenum.h5.xml @@ -3,14 +3,14 @@ Expected output for 'h5dump --xml tenum.h5' ############################# <?xml version="1.0" encoding="UTF-8"?> <hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd"> -<hdf5:RootGroup OBJ-XID="xid_696" H5Path="/"> - <hdf5:NamedDataType Name="enum normal" OBJ-XID="xid_744" H5Path="/enum normal" Parents="xid_696" H5ParentPaths="/"> +<hdf5:RootGroup OBJ-XID="xid_928" H5Path="/"> + <hdf5:NamedDataType Name="enum normal" OBJ-XID="xid_976" H5Path="/enum normal" Parents="xid_928" H5ParentPaths="/"> <hdf5:DataType> <hdf5:AtomicType> <hdf5:EnumType Nelems="5"> <hdf5:DataType> <hdf5:AtomicType> - <hdf5:IntegerType ByteOrder="BE" Sign="true" Size="4" /> + <hdf5:IntegerType ByteOrder="LE" Sign="true" Size="4" /> </hdf5:AtomicType> </hdf5:DataType> <hdf5:EnumElement> @@ -21,24 +21,25 @@ Expected output for 'h5dump --xml tenum.h5' </hdf5:EnumValue> <hdf5:EnumElement> GREEN +green </hdf5:EnumElement> <hdf5:EnumValue> 1 </hdf5:EnumValue> <hdf5:EnumElement> - BLUE + BLUE blue </hdf5:EnumElement> <hdf5:EnumValue> 2 </hdf5:EnumValue> <hdf5:EnumElement> - WHITE + WHITE "white" </hdf5:EnumElement> <hdf5:EnumValue> 3 </hdf5:EnumValue> <hdf5:EnumElement> - BLACK + BLACK 'black' </hdf5:EnumElement> <hdf5:EnumValue> 4 @@ -47,7 +48,7 @@ Expected output for 'h5dump --xml tenum.h5' </hdf5:AtomicType> </hdf5:DataType> </hdf5:NamedDataType> - <hdf5:Dataset Name="table" OBJ-XID="xid_1152" H5Path= "/table" Parents="xid_696" H5ParentPaths="/"> + <hdf5:Dataset Name="table" OBJ-XID="xid_1384" H5Path= "/table" Parents="xid_928" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> @@ -61,11 +62,13 @@ Expected output for 'h5dump --xml tenum.h5' <hdf5:Dimension DimSize="20" MaxDimSize="20"/> </hdf5:SimpleDataspace> </hdf5:Dataspace> - <hdf5:NamedDataTypePtr OBJ-XID="xid_744" H5Path="/enum normal" /> + <hdf5:NamedDataTypePtr OBJ-XID="xid_976" H5Path="/enum normal" /> <hdf5:Data> <hdf5:DataFromFile> - RED GREEN BLUE GREEN WHITE WHITE BLACK GREEN BLUE RED RED BLUE GREEN - BLACK WHITE RED WHITE GREEN GREEN BLUE + RED GREEN\ngreen BLUE blue GREEN\ngreen WHITE \"white\" WHITE \"white\" + BLACK \'black\' GREEN\ngreen BLUE blue RED RED BLUE blue GREEN\ngreen + BLACK \'black\' WHITE \"white\" RED WHITE \"white\" GREEN\ngreen + GREEN\ngreen BLUE blue </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> |