[svn-r1491] removed teh extra funtion that wasn't being used and now if the

indentation is greater than the number of columns it will generate an error
This commit is contained in:
Patrick Lu 1999-07-16 11:45:24 -05:00
parent 758ee9ca3f
commit 04e3099538

View File

@ -2469,8 +2469,13 @@ print_data(hid_t oid, hid_t _p_type, int obj_data)
*-----------------------------------------------------------------------*/
void indentation(int x) {
while (x>0) { printf(" "); x--; }
if(x < nCols) {
while (x>0) { printf(" "); x--; }
}
else {
printf("The indentation exceeds the number of cols. Exiting....\n");
exit(1);
}
}
@ -2620,162 +2625,5 @@ int h5dump_attr(hid_t oid, hid_t p_type){
free(sm_buf);
return (status);
}
#if 0
/*-------------------------------------------------------------------------
* Function: display_numeric_data
*
* Purpose: Display numeric data in ddl format.
*
* Return: void
*
* Comment: hs_nelmts number of elements to be printed
* p_type memory data type
* sm_buf data buffer
* p_type_nbytes size of p_type
* p_nelmts total number of elements
* dim_n_size size of dimemsion n
* elmtno element index
*
*-------------------------------------------------------------------------
*/
static void display_reference_data
(hsize_t hs_nelmts, hid_t p_type, unsigned char *sm_buf, size_t p_type_nbytes,
hsize_t p_nelmts, hsize_t dim_n_size, hsize_t elmtno, hid_t container) {
hsize_t i;
/*char p_buf[256]; */
char* out_buf = malloc(sizeof(char) * nCols);
struct h5dump_str_t tempstr;
int x;
int totalspace;
hbool_t done;
int temp;
/******************************************************************************************/
h5dump_t info;
/* Set to all default values and then override */
memset(&info, 0, sizeof info);
info.idx_fmt = "(%s)";
info.line_ncols = nCols;
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;
memset(&tempstr, 0, sizeof(h5dump_str_t));
for (i=0; i<hs_nelmts && (elmtno+i) < p_nelmts; i++) {
h5dump_str_reset(&tempstr);
h5dump_sprint(&tempstr, &info, container, p_type, sm_buf+i*p_type_nbytes);
for (x = 0; x <tempstr.len; x++){
/* removes the strange characters */
if (tempstr.s[x] == 1){
memmove(tempstr.s+x, tempstr.s+(x+1), strlen(tempstr.s+x));
tempstr.len --;
}
}
totalspace = nCols - indent - COL;
if ((int)(strlen(out_buf)+tempstr.len+1) > (totalspace)) {
/* first row of member */
/* i added this */
temp = strlen(out_buf);
if ((strlen(out_buf) + 7) < (totalspace)){ /* 7 for the word dataset */
memcpy(out_buf+strlen(out_buf), tempstr.s, totalspace - strlen(out_buf));
out_buf[totalspace] = '\0';
memmove(tempstr.s, tempstr.s+(totalspace - temp), tempstr.len - (totalspace - temp));
tempstr.s[tempstr.len - totalspace + temp] = '\0';
tempstr.len = strlen(tempstr.s);
}
/* first row of member */
if (compound_data && (elmtno+i+1) == dim_n_size)
printf("%s\n", out_buf);
else {
indentation(indent+COL);
printf("%s\n", out_buf);
}
strcpy(out_buf, tempstr.s);
/* i added this too*/
done = FALSE;
while (!done) {
if (tempstr.len > totalspace) {
/* keep printing until we can fit in the totalspace */
memmove(out_buf,tempstr.s, totalspace);
out_buf[totalspace] = '\0';
memmove(tempstr.s,tempstr.s+totalspace, strlen(tempstr.s + totalspace));
tempstr.s[tempstr.len - totalspace] = '\0';
tempstr.len = strlen(tempstr.s);
indentation(indent+COL);
printf(out_buf);
} else {
strcpy(out_buf, tempstr.s);
done = TRUE;
}
}
if ((elmtno+i+1) % dim_n_size)
strcat(out_buf, ", ");
else { /* end of a row, flush out_buf */
indentation(indent+COL);
printf("%s", out_buf);
if ((elmtno+i+1) != p_nelmts) /* not last element */
printf(",\n");
else if (compound_data) { /* last element of member data*/
if ((nCols-strlen(out_buf)-indent-COL) < 2) {
/* 2 for space and ] */
printf("\n");
indentation(indent+COL-3);
}
} else
printf("\n"); /* last row */
*out_buf = '\0';
}
} else {
strcat(out_buf, tempstr.s);
if ((elmtno+i+1) % dim_n_size) {
if ((nCols-strlen(out_buf)-indent-COL-1) > 0)
strcat(out_buf, ", ");
else
strcat(out_buf, ",");
} else { /* end of a row */
/* 1st row of member data */
if (compound_data && (elmtno+i+1) == dim_n_size)
printf("%s", out_buf);
else {
indentation(indent+COL);
printf("%s", out_buf);
}
/* if it's the last element */
if ((elmtno+i+1) != p_nelmts)
printf(",\n");
else if (compound_data) { /* last row of member data*/
/* 2 for space and ] */
if ((nCols-strlen(out_buf)-indent-COL) < 2) {
printf("\n");
indentation(indent+COL-3);
}
} else
printf("\n"); /* last row */
*out_buf = '\0';
}
}
}
free(out_buf);
}
#endif