summaryrefslogtreecommitdiffstats
path: root/tools/h5tools.c
diff options
context:
space:
mode:
authorPatrick Lu <ptlu@hawkwind.ncsa.uiuc.edu>1999-05-20 18:54:08 (GMT)
committerPatrick Lu <ptlu@hawkwind.ncsa.uiuc.edu>1999-05-20 18:54:08 (GMT)
commit19d46ed16f7fd26550c18d2b34b75820b3285f1c (patch)
treee831b021d81510e392760a159425e6282bce1709 /tools/h5tools.c
parentb6ffdf65b9e13006d7b0200c2e82ad69a37f70c9 (diff)
downloadhdf5-19d46ed16f7fd26550c18d2b34b75820b3285f1c.zip
hdf5-19d46ed16f7fd26550c18d2b34b75820b3285f1c.tar.gz
hdf5-19d46ed16f7fd26550c18d2b34b75820b3285f1c.tar.bz2
[svn-r1268]
changing the display_numeric_data abd the display_string to use the h5dump_sprint from the tools lib. added a section to initialize the h5dump_t variable in both these functions. in the display_string had to remove the extra quotes that gets displayed when printing. in h5dump_sprint i changed the for loop in the case of the string. I added a check to see if the last character is a \0. it was being printed before.
Diffstat (limited to 'tools/h5tools.c')
-rw-r--r--tools/h5tools.c158
1 files changed, 63 insertions, 95 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c
index 50ce060..73c2314 100644
--- a/tools/h5tools.c
+++ b/tools/h5tools.c
@@ -509,8 +509,10 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info,
} else if (H5T_STRING==H5Tget_class(type)) {
size = H5Tget_size(type);
quote = '\0';
-
- for (i=0; i<size; i++) {
+ if (str->s == '"') {
+ quote = 'a';
+ }
+ for (i=0; i<size && ((char*)vp)[i] != '\0'; i++) {
/* Count how many times the next character repeats */
j=1;
@@ -702,95 +704,7 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info,
return h5dump_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
}
- else {
-/*
- this is just my first step in copmbining these 2 functions
- this is ripped straight out of h5dumputil.c
-*/
- char temp[1024];
- H5T_str_t str_pad;
- // char *s = str->s;
- if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- sprintf(str->s, "%g", *((double*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- sprintf(str->s, "%g", *((float*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- sprintf(str->s, "%d", *((short*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- sprintf(str->s, "%u", *((unsigned short*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_INT)) {
- sprintf(str->s, "%d", *((int*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- sprintf(str->s, "%u", *((unsigned*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- sprintf(str->s, "%ld", *((long*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- sprintf(str->s, "%lu", *((unsigned long*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- sprintf(str->s, "%d", *((signed char*)vp));
- } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- sprintf(str->s, "%u", *((unsigned char*)vp));
- } else if (H5T_STRING==H5Tget_class(type)) {
- str_pad = H5Tget_strpad(type) ;
- j = 0;
- for (i = 0; i < H5Tget_size(type); i++) {
- switch (*((char*)vp+i)) {
- case '"':
- strcpy(str->s+j, "\\\"");
- j += strlen("\\\"");
- break;
- case '\\':
- strcpy(str->s+j, "\\\\");
- j += strlen("\\\\");
- break;
- case '\b':
- strcpy(str->s+j, "\\b");
- j += strlen("\\b");
- break;
- case '\f':
- strcpy(str->s+j, "\\f");
- j += strlen("\\f");
- break;
- case '\n':
- strcpy(str->s+j, "\\n");
- j += strlen("\\n");
- break;
- case '\r':
- strcpy(str->s+j, "\\r");
- j += strlen("\\r");
- break;
- case '\t':
- strcpy(str->s+j, "\\t");
- j += strlen("\\t");
- break;
- default:
- if (isprint(*((char*)vp+i))){
- sprintf(str->s+j, "%c", *((char*)vp+i));
- j += strlen(str->s+j);
- } else {
- if (str_pad == H5T_STR_NULLTERM &&
- *((unsigned char*)vp+i) == '\0' ) {
- sprintf(str->s+j, "%c", *((unsigned char*)vp+i));
- i = H5Tget_size(type);
- } else {
- sprintf(str->s+j, "\\%03o", *((unsigned char*)vp+i));
- j += strlen(str->s+j);
- }
- }
- break;
- }
- }
- } else {
- strcpy(temp, "0x");
- n = H5Tget_size(type);
- for (i=0; i<n; i++) {
- sprintf(temp+strlen(temp), "%02x", ((unsigned char*)vp)[i]);
- }
- sprintf(str->s, "%s", temp);
-
-
- }
- }
+ else {}
}
@@ -1478,9 +1392,24 @@ h5dump_mem(FILE *stream, const h5dump_t *info, hid_t type, hid_t space,
}
+
+
+
/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+
/*from h5dumputil.c*/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
/*-------------------------------------------------------------------------
* Function: display_numeric_data
@@ -1508,6 +1437,24 @@ hsize_t i;
char out_buf[NCOLS];
struct h5dump_str_t tempstr;
+/******************************************************************************************/
+ h5dump_t info;
+
+ /* Set to all default values and then override */
+ memset(&info, 0, sizeof info);
+ info.idx_fmt = "(%s)";
+ info.line_ncols = 80;
+ info.line_multi_new = 1;
+
+ /*
+ * If a compound datatype is split across multiple lines then add an
+ * ellipsis to the beginning of the continuation line.
+ */
+ info.line_pre = " %s ";
+ info.line_cont = " %s ";
+/*********************************************************************************************/
+
+
out_buf[0] = '\0';
if ((indent+COL) > NCOLS) indent = 0;
@@ -1515,7 +1462,7 @@ struct h5dump_str_t tempstr;
for (i=0; i<hs_nelmts && (elmtno+i) < p_nelmts; i++) {
h5dump_str_reset(&tempstr);
- h5dump_sprint(&tempstr, NULL,p_type, sm_buf+i*p_type_nbytes);
+ h5dump_sprint(&tempstr, &info, p_type, sm_buf+i*p_type_nbytes);
if ((int)(strlen(out_buf)+strlen(tempstr.s)+1) > (NCOLS-indent-COL)) {
/* first row of member */
if (compound_data && (elmtno+i+1) == dim_n_size)
@@ -1598,7 +1545,22 @@ static void display_string
int free_space, long_string = 0;
char out_buf[NCOLS];
struct h5dump_str_t tempstr;
-
+ /******************************************************************************************/
+ h5dump_t info;
+
+ /* Set to all default values and then override */
+ memset(&info, 0, sizeof info);
+ info.idx_fmt = "(%s)";
+ info.line_ncols = 80;
+ info.line_multi_new = 1;
+
+ /*
+ * If a compound datatype is split across multiple lines then add an
+ * ellipsis to the beginning of the continuation line.
+ */
+ info.line_pre = " %s ";
+ info.line_cont = " %s ";
+/*********************************************************************************************/
out_buf[0] = '\0';
memset(&tempstr, 0, sizeof(h5dump_str_t));
@@ -1609,7 +1571,7 @@ static void display_string
row_size++;
h5dump_str_reset(&tempstr);
- h5dump_sprint(&tempstr, NULL,p_type, sm_buf+i*p_type_nbytes);
+ h5dump_sprint(&tempstr, &info,p_type, sm_buf+i*p_type_nbytes);
free_space = NCOLS - indent - COL - strlen(out_buf);
@@ -1733,11 +1695,17 @@ static void display_string
/* flush out_buf if it's end of a row */
if (row_size == dim_n_size) {
if (compound_data && (elmtno+i+1) == dim_n_size) { /* 1st row */
+/*
printf("%s\"%s\"", out_buf, tempstr.s);
+*/
+ printf("%s%s", out_buf, tempstr.s);
first_row = 0;
} else {
indentation(indent+COL);
- printf("%s\"%s\"", out_buf, tempstr.s);
+/*
+ printf("%s\"%s\"", out_buf, tempstr.s);
+*/
+ printf("%s%s", out_buf, tempstr.s);
}
if ((elmtno+i+1) != p_nelmts)