From d59da45c98ed057608cf0b655a5a8f6c93becb52 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 22 Feb 2012 16:58:50 -0500 Subject: [svn-r21969] Added missing HD prefix Correct indentation --- tools/lib/h5tools.c | 269 +++++++++++++++++++++++----------------------- tools/lib/h5tools_dump.c | 64 +++++------ tools/lib/h5tools_type.c | 226 +++++++++++++++++++------------------- tools/lib/h5tools_utils.c | 124 ++++++++++----------- 4 files changed, 338 insertions(+), 345 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index fdc2e4d..363b380 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -195,7 +195,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) /* Determine which driver the user wants to open the file with. Try * that driver. If it can't open it, then fail. */ - if (!strcmp(driver, drivernames[SEC2_IDX])) { + if (!HDstrcmp(driver, drivernames[SEC2_IDX])) { /* SEC2 driver */ if (H5Pset_fapl_sec2(new_fapl) < 0) goto error; @@ -203,7 +203,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if (drivernum) *drivernum = SEC2_IDX; } - else if (!strcmp(driver, drivernames[FAMILY_IDX])) { + else if (!HDstrcmp(driver, drivernames[FAMILY_IDX])) { /* FAMILY Driver */ /* Set member size to be 0 to indicate the current first member size @@ -215,7 +215,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if (drivernum) *drivernum = FAMILY_IDX; } - else if (!strcmp(driver, drivernames[SPLIT_IDX])) { + else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) { /* SPLIT Driver */ if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) goto error; @@ -223,7 +223,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if (drivernum) *drivernum = SPLIT_IDX; } - else if (!strcmp(driver, drivernames[MULTI_IDX])) { + else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) { /* MULTI Driver */ if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0) goto error; @@ -232,7 +232,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) *drivernum = MULTI_IDX; #ifdef H5_HAVE_STREAM } - else if(!strcmp(driver, drivernames[STREAM_IDX])) { + else if(!HDstrcmp(driver, drivernames[STREAM_IDX])) { /* STREAM Driver */ if(H5Pset_fapl_stream(new_fapl, NULL) < 0) goto error; @@ -242,7 +242,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) #endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL } - else if(!strcmp(driver, drivernames[MPIO_IDX])) { + else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) { /* MPI-I/O Driver */ /* check if MPI has been initialized. */ if(!h5tools_mpi_init_g) @@ -255,7 +255,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) *drivernum = MPIO_IDX; } /* end if */ } - else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { + else if (!HDstrcmp(driver, drivernames[MPIPOSIX_IDX])) { /* MPI-I/O Driver */ /* check if MPI has been initialized. */ if(!h5tools_mpi_init_g) @@ -381,7 +381,7 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, /* Save the driver name */ if (drivername && drivername_size) { if (fid != FAIL) { - strncpy(drivername, drivernames[drivernum], drivername_size); + HDstrncpy(drivername, drivernames[drivernum], drivername_size); drivername[drivername_size - 1] = '\0'; } else { @@ -551,14 +551,14 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, if (!ctx->need_prefix) return; - memset(&prefix, 0, sizeof(h5tools_str_t)); - memset(&str, 0, sizeof(h5tools_str_t)); + HDmemset(&prefix, 0, sizeof(h5tools_str_t)); + HDmemset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -582,23 +582,23 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, the prefix is printed one indentation level before */ if (info->pindex) { for (i = 0; i < indentlevel - 1; i++) { - fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); + HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); } } if (elmtno == 0 && secnum == 0 && info->line_1st) - fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); else if (secnum && info->line_cont) - fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); else - fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); templength = h5tools_str_len(&prefix); for (i = 0; i < indentlevel; i++) { /*we already made the indent for the array indices case */ if (!info->pindex) { - fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); templength += h5tools_str_len(&prefix); } else { @@ -640,14 +640,14 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, if (!ctx->need_prefix) return; - memset(&prefix, 0, sizeof(h5tools_str_t)); - memset(&str, 0, sizeof(h5tools_str_t)); + HDmemset(&prefix, 0, sizeof(h5tools_str_t)); + HDmemset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -671,23 +671,23 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, the prefix is printed one indentation level before */ if (info->pindex) { for (i = 0; i < indentlevel - 1; i++) { - fputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); + HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream); } } if (elmtno == 0 && secnum == 0 && info->line_1st) - fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); else if (secnum && info->line_cont) - fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); else - fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); templength = h5tools_str_len(&prefix); for (i = 0; i < indentlevel; i++) { /*we already made the indent for the array indices case */ if (!info->pindex) { - fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); templength += h5tools_str_len(&prefix); } else { @@ -749,8 +749,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, */ if (info->line_multi_new == 1 && (ctx->cur_column + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -759,8 +759,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, ctx->need_prefix = TRUE; } else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) <= ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -794,8 +794,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline && (ctx->cur_column + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; /* @@ -812,7 +812,7 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, */ multiline = 0; for (secnum = 0, multiline = 0; - (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); + (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) { /* * If the current section plus possible suffix and end-of-line @@ -823,9 +823,9 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, /* * check for displaying prefix for each section */ - if ( (ctx->cur_column + strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + if ( (ctx->cur_column + HDstrlen(section) + + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -845,13 +845,13 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum); } else if ((local_elmt_counter || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); + HDfputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " ")); } /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); + HDfputs(section, stream); + ctx->cur_column += HDstrlen(section); } ctx->prev_multiline = multiline; @@ -903,8 +903,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, */ if (info->line_multi_new == 1 && (ctx->cur_column + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -913,8 +913,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, ctx->need_prefix = TRUE; } else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) <= ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -948,8 +948,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline && (ctx->cur_column + h5tools_count_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; /* @@ -965,7 +965,7 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * one-at a time. */ multiline = 0; - for (secnum = 0, multiline = 0; (section = strtok(secnum ? NULL : s, + for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) { /* * If the current section plus possible suffix and end-of-line @@ -979,9 +979,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, */ if ((!info->skip_first || local_elmt_counter) && (ctx->cur_column + - strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + HDstrlen(section) + + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -1001,13 +1001,13 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum); } else if ((local_elmt_counter || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); + HDfputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " ")); } /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); + HDfputs(section, stream); + ctx->cur_column += HDstrlen(section); } ctx->prev_multiline = multiline; @@ -1059,7 +1059,7 @@ do_bin_output(FILE *stream, hid_t container, hsize_t nelmts, hid_t tid, void *_m for (i = 0; i < nelmts; i++) { if (render_bin_output(stream, container, tid, mem + i * size) < 0) { - printf("\nError in writing binary stream\n"); + HDprintf("\nError in writing binary stream\n"); return FAIL; } } @@ -1101,8 +1101,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) #ifdef DEBUG_H5DUMP_BIN static char fmt_llong[8], fmt_ullong[8]; if (!fmt_llong[0]) { - sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); + HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); + HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } #endif @@ -1110,30 +1110,30 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); if (H5Tequal(tid, H5T_NATIVE_FLOAT)) { - memcpy(&tempfloat, mem, sizeof(float)); + HDmemcpy(&tempfloat, mem, sizeof(float)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%g ", tempfloat); + HDfprintf(stream, "%g ", tempfloat); #else - if (1 != fwrite(&tempfloat, size, 1, stream)) + if (1 != HDfwrite(&tempfloat, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) { - memcpy(&tempdouble, mem, sizeof(double)); + HDmemcpy(&tempdouble, mem, sizeof(double)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%g ", tempdouble); + HDfprintf(stream, "%g ", tempdouble); #else - if (1 != fwrite(&tempdouble, size, 1, stream)) + if (1 != HDfwrite(&tempdouble, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } #if H5_SIZEOF_LONG_DOUBLE !=0 else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) { - memcpy(&templdouble, mem, sizeof(long double)); + HDmemcpy(&templdouble, mem, sizeof(long double)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%Lf ", templdouble); + HDfprintf(stream, "%Lf ", templdouble); #else - if (1 != fwrite(&templdouble, size, 1, stream)) + if (1 != HDfwrite(&templdouble, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } @@ -1156,159 +1156,159 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); } for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - memcpy(&tempuchar, &s[i], sizeof(unsigned char)); + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%d", tempuchar); + HDfprintf(stream, "%d", tempuchar); #else - if (1 != fwrite(&tempuchar, size, 1, stream)) + if (1 != HDfwrite(&tempuchar, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } /* i */ } else if (H5Tequal(tid, H5T_NATIVE_INT)) { - memcpy(&tempint, mem, sizeof(int)); + HDmemcpy(&tempint, mem, sizeof(int)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%d ", tempint); + HDfprintf(stream, "%d ", tempint); #else - if (1 != fwrite(&tempint, size, 1, stream)) + if (1 != HDfwrite(&tempint, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_UINT)) { - memcpy(&tempuint, mem, sizeof(unsigned int)); + HDmemcpy(&tempuint, mem, sizeof(unsigned int)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%u ", tempuint); + HDfprintf(stream, "%u ", tempuint); #else - if (1 != fwrite(&tempuint, size, 1, stream)) + if (1 != HDfwrite(&tempuint, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) { - memcpy(&tempschar, mem, sizeof(char)); + HDmemcpy(&tempschar, mem, sizeof(char)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%d ", tempschar); + HDfprintf(stream, "%d ", tempschar); #else - if (1 != fwrite(&tempschar, size, 1, stream)) + if (1 != HDfwrite(&tempschar, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) { - memcpy(&tempuchar, mem, sizeof(unsigned char)); + HDmemcpy(&tempuchar, mem, sizeof(unsigned char)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%u ", tempuchar); + HDfprintf(stream, "%u ", tempuchar); #else - if (1 != fwrite(&tempuchar, size, 1, stream)) + if (1 != HDfwrite(&tempuchar, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_SHORT)) { - memcpy(&tempshort, mem, sizeof(short)); + HDmemcpy(&tempshort, mem, sizeof(short)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%d ", tempshort); + HDfprintf(stream, "%d ", tempshort); #else - if (1 != fwrite(&tempshort, size, 1, stream)) + if (1 != HDfwrite(&tempshort, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_USHORT)) { - memcpy(&tempushort, mem, sizeof(unsigned short)); + HDmemcpy(&tempushort, mem, sizeof(unsigned short)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%u ", tempushort); + HDfprintf(stream, "%u ", tempushort); #else - if (1 != fwrite(&tempushort, size, 1, stream)) + if (1 != HDfwrite(&tempushort, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_LONG)) { - memcpy(&templong, mem, sizeof(long)); + HDmemcpy(&templong, mem, sizeof(long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%ld ", templong); + HDfprintf(stream, "%ld ", templong); #else - if (1 != fwrite(&templong, size, 1, stream)) + if (1 != HDfwrite(&templong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_ULONG)) { - memcpy(&tempulong, mem, sizeof(unsigned long)); + HDmemcpy(&tempulong, mem, sizeof(unsigned long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%lu ", tempulong); + HDfprintf(stream, "%lu ", tempulong); #else - if (1 != fwrite(&tempulong, size, 1, stream)) + if (1 != HDfwrite(&tempulong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_LLONG)) { - memcpy(&templlong, mem, sizeof(long long)); + HDmemcpy(&templlong, mem, sizeof(long long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, fmt_llong, templlong); + HDfprintf(stream, fmt_llong, templlong); #else - if (1 != fwrite(&templlong, size, 1, stream)) + if (1 != HDfwrite(&templlong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) { - memcpy(&tempullong, mem, sizeof(unsigned long long)); + HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, fmt_ullong, tempullong); + HDfprintf(stream, fmt_ullong, tempullong); #else - if (1 != fwrite(&tempullong, size, 1, stream)) + if (1 != HDfwrite(&tempullong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { - memcpy(&tempint, mem, sizeof(int)); + HDmemcpy(&tempint, mem, sizeof(int)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%d ", tempint); + HDfprintf(stream, "%d ", tempint); #else - if (1 != fwrite(&tempint, size, 1, stream)) + if (1 != HDfwrite(&tempint, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (sizeof(hssize_t) == sizeof(long)) { - memcpy(&templong, mem, sizeof(long)); + HDmemcpy(&templong, mem, sizeof(long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%ld ", templong); + HDfprintf(stream, "%ld ", templong); #else - if (1 != fwrite(&templong, size, 1, stream)) + if (1 != HDfwrite(&templong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else { - memcpy(&templlong, mem, sizeof(long long)); + HDmemcpy(&templlong, mem, sizeof(long long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, fmt_llong, templlong); + HDfprintf(stream, fmt_llong, templlong); #else - if (1 != fwrite(&templlong, size, 1, stream)) + if (1 != HDfwrite(&templlong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } } else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) { if (sizeof(hsize_t) == sizeof(int)) { - memcpy(&tempuint, mem, sizeof(unsigned int)); + HDmemcpy(&tempuint, mem, sizeof(unsigned int)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%u ", tempuint); + HDfprintf(stream, "%u ", tempuint); #else - if (1 != fwrite(&tempuint, size, 1, stream)) + if (1 != HDfwrite(&tempuint, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else if (sizeof(hsize_t) == sizeof(long)) { - memcpy(&tempulong, mem, sizeof(unsigned long)); + HDmemcpy(&tempulong, mem, sizeof(unsigned long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%lu ", tempulong); + HDfprintf(stream, "%lu ", tempulong); #else - if (1 != fwrite(&tempulong, size, 1, stream)) + if (1 != HDfwrite(&tempulong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else { - memcpy(&tempullong, mem, sizeof(unsigned long long)); + HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, fmt_ullong, tempullong); + HDfprintf(stream, fmt_ullong, tempullong); #else - if (1 != fwrite(&tempullong, size, 1, stream)) + if (1 != HDfwrite(&tempullong, size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } @@ -1335,18 +1335,18 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) unsigned int i; if (1 == size) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "0x%02x", mem[0]); + HDfprintf(stream, "0x%02x", mem[0]); #else - if (1 != fwrite(&mem[0], size, 1, stream)) + if (1 != HDfwrite(&mem[0], size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else { for (i = 0; i < size; i++) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%s%02x", i?":":"", mem[i]); + HDfprintf(stream, "%s%02x", i?":":"", mem[i]); #else - if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) + if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } /*i*/ @@ -1425,18 +1425,18 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) size_t i; if (1 == size) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "0x%02x", mem[0]); + HDfprintf(stream, "0x%02x", mem[0]); #else - if (1 != fwrite(&mem[0], size, 1, stream)) + if (1 != HDfwrite(&mem[0], size, 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } else { for (i = 0; i < size; i++) { #ifdef DEBUG_H5DUMP_BIN - fprintf(stream, "%s%02x", i?":":"", mem[i]); + HDfprintf(stream, "%s%02x", i?":":"", mem[i]); #else - if (1 != fwrite(&mem[i], sizeof(char), 1, stream)) + if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); #endif } /*i*/ @@ -1467,7 +1467,8 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hsize_t *dims1 = NULL; hsize_t *start = NULL; hsize_t *count = NULL; - size_t numelem; + hsize_t numelem; + hsize_t numindex; hsize_t total_size[H5S_MAX_RANK]; int jndx; int type_size; @@ -1525,10 +1526,10 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - for (jndx = 0; jndx < numelem; jndx++) { + for (numindex = 0; numindex < numelem; numindex++) { render_bin_output(stream, container, type_id, - ((char*)region_buf + jndx * type_size)); + ((char*)region_buf + numindex * type_size)); /* Render the region data element end */ } /* end for (jndx = 0; jndx < numelem; jndx++) */ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -1581,7 +1582,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL) + if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); @@ -1597,7 +1598,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, type_id, nblocks, ptdata); done: - free(ptdata); + HDfree(ptdata); if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -1785,12 +1786,12 @@ h5tools_is_obj_same(hid_t loc_id1, const char *name1, H5O_info_t oinfo1, oinfo2; hbool_t ret_val = 0; - if ( name1 && strcmp(name1, ".")) + if ( name1 && HDstrcmp(name1, ".")) H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT); else H5Oget_info(loc_id1, &oinfo1); - if ( name2 && strcmp(name2, ".")) + if ( name2 && HDstrcmp(name2, ".")) H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT); else H5Oget_info(loc_id2, &oinfo2); diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 7a83fc7..b0c8591 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -437,7 +437,8 @@ h5tools_print_region_data_blocks(hid_t region_id, hsize_t elmtno; /* elemnt index */ hsize_t curr_pos = 0; unsigned int region_flags; /* buffer extent flags */ - size_t numelem; + hsize_t numelem; + hsize_t numindex; size_t jndx; int indx; int type_size; @@ -452,7 +453,7 @@ h5tools_print_region_data_blocks(hid_t region_id, assert(buffer); assert(ptdata); - memset(&ctx, 0, sizeof(ctx)); + HDmemset(&ctx, 0, sizeof(ctx)); /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); @@ -529,19 +530,19 @@ h5tools_print_region_data_blocks(hid_t region_id, h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); elmtno = 0; - for (jndx = 0; jndx < numelem; jndx++, elmtno++, ctx.cur_elmt++) { + for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) { /* Render the region data element begin */ h5tools_str_reset(buffer); - h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : ""); + h5tools_str_append(buffer, "%s", numindex ? OPTIONAL_LINE_BREAK "" : ""); h5tools_str_sprint(buffer, info, region_id, type_id, - ((char*)region_buf + jndx * type_size), &ctx); + ((char*)region_buf + numindex * type_size), &ctx); - if (jndx + 1 < numelem || (region_flags & END_OF_DATA) == 0) + if (numindex + 1 < numelem || (region_flags & END_OF_DATA) == 0) h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ",")); dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, - ncols, ptdata, jndx, elmtno); + ncols, ptdata, numindex, elmtno); /* Render the region data element end */ if(FALSE == dimension_break) @@ -634,7 +635,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL) + if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); @@ -725,7 +726,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, buffer, ncols, ndims, type_id, nblocks, ptdata); done: - free(ptdata); + HDfree(ptdata); if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -803,7 +804,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, assert(buffer); assert(ptdata); - memset(&ctx, 0, sizeof(ctx)); + HDmemset(&ctx, 0, sizeof(ctx)); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims"); @@ -1045,7 +1046,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, rawdatastream, info, ctx, buffer, ncols, ndims, type_id, npoints, ptdata); done: - free(ptdata); + HDfree(ptdata); if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -1598,8 +1599,8 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont init_acc_pos(ctx, total_size); /* The stripmine loop */ - memset(hs_offset, 0, sizeof hs_offset); - memset(zero, 0, sizeof zero); + HDmemset(hs_offset, 0, sizeof hs_offset); + HDmemset(zero, 0, sizeof zero); for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* Calculate the hyperslab size */ @@ -1623,7 +1624,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { H5Sclose(f_space); H5Sclose(sm_space); - free(sm_buf); + HDfree(sm_buf); return FAIL; } @@ -1756,7 +1757,7 @@ h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t * stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof info_dflt); + HDmemset(&info_dflt, 0, sizeof info_dflt); info = &info_dflt; } @@ -1828,7 +1829,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof(info_dflt)); + HDmemset(&info_dflt, 0, sizeof(info_dflt)); info = &info_dflt; } @@ -2311,7 +2312,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ } else HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed"); - free(mname); + HDfree(mname); } ctx->indent_level--; @@ -2595,7 +2596,7 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i h5tools_str_reset(buffer); h5tools_str_append(buffer, "\"%s\"", name[i]); - nchars = strlen(name[i]); + nchars = HDstrlen(name[i]); h5tools_str_append(buffer, "%*s ", MAX(0, 16 - nchars), ""); if (native < 0) { @@ -2628,12 +2629,12 @@ CATCH /* Release resources */ for(i = 0; i < nmembs; i++) if(name[i]) - free(name[i]); - free(name); + HDfree(name[i]); + HDfree(name); } /* end if */ if(value) - free(value); + HDfree(value); if(super >= 0 && H5Tclose(super) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class"); @@ -2805,7 +2806,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t n_type = h5tools_get_native_type(type_id); size = H5Tget_size(n_type); - buf = malloc(size); + buf = HDmalloc(size); H5Pget_fill_value(dcpl, n_type, buf); @@ -2814,7 +2815,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t H5Tclose(n_type); if (buf) - free (buf); + HDfree (buf); } /*------------------------------------------------------------------------- @@ -3803,7 +3804,6 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, status = SUCCEED; } else { - char string_prefix[64]; /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ @@ -3825,7 +3825,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ if(alloc_size) { - buf = malloc((size_t)alloc_size); + buf = HDmalloc((size_t)alloc_size); assert(buf); if (H5Aread(obj_id, p_type, buf) >= 0) @@ -3869,7 +3869,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, if (vl_data) H5Dvlen_reclaim(p_type, space, H5P_DEFAULT, buf); - free(buf); + HDfree(buf); } else status = SUCCEED; @@ -3889,12 +3889,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, &outputformat, ctx, 0, 0); h5tools_str_reset(&buffer); - if(strlen(h5tools_dump_header_format->datablockend)) { + if(HDstrlen(h5tools_dump_header_format->datablockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->datablockend); - if(strlen(h5tools_dump_header_format->dataend)) + if(HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(&buffer, " "); } - if(strlen(h5tools_dump_header_format->dataend)) + if(HDstrlen(h5tools_dump_header_format->dataend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataend); h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0); @@ -3905,12 +3905,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_simple_prefix(stream, &outputformat, ctx, 0, 0); h5tools_str_reset(&buffer); - if(strlen(h5tools_dump_header_format->subsettingblockend)) { + if(HDstrlen(h5tools_dump_header_format->subsettingblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingblockend); - if(strlen(h5tools_dump_header_format->subsettingend)) + if(HDstrlen(h5tools_dump_header_format->subsettingend)) h5tools_str_append(&buffer, " "); } - if(strlen(h5tools_dump_header_format->subsettingend)) + if(HDstrlen(h5tools_dump_header_format->subsettingend)) h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->subsettingend); h5tools_render_element(stream, &outputformat, ctx, &buffer, &curr_pos, ncols, 0, 0); } diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index bbd1b8d..d68d3c5 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -66,62 +66,62 @@ h5tools_get_native_type(hid_t type) hid_t h5tools_get_little_endian_type(hid_t tid) { - hid_t p_type=-1; - H5T_class_t type_class; - size_t size; - H5T_sign_t sign; - - type_class = H5Tget_class(tid); - size = H5Tget_size(tid); - sign = H5Tget_sign(tid); - - switch( type_class ) - { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8LE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16LE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32LE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64LE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8LE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16LE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32LE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64LE); - } - break; - - case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32LE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64LE); - break; - - case H5T_TIME: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_STRING: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - break; - - default: - break; - - } - - return(p_type); + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8LE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16LE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32LE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64LE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8LE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16LE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32LE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64LE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32LE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64LE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + return(p_type); } @@ -143,62 +143,62 @@ h5tools_get_little_endian_type(hid_t tid) hid_t h5tools_get_big_endian_type(hid_t tid) { - hid_t p_type=-1; - H5T_class_t type_class; - size_t size; - H5T_sign_t sign; - - type_class = H5Tget_class(tid); - size = H5Tget_size(tid); - sign = H5Tget_sign(tid); - - switch( type_class ) - { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8BE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16BE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32BE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64BE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8BE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16BE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32BE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64BE); - } - break; - - case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32BE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64BE); - break; - - case H5T_TIME: - case H5T_BITFIELD: - case H5T_OPAQUE: - case H5T_STRING: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - break; - - default: - break; - - } - - - return(p_type); + hid_t p_type=-1; + H5T_class_t type_class; + size_t size; + H5T_sign_t sign; + + type_class = H5Tget_class(tid); + size = H5Tget_size(tid); + sign = H5Tget_sign(tid); + + switch( type_class ) + { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I8BE); + else if ( size == 2 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I16BE); + else if ( size == 4 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I32BE); + else if ( size == 8 && sign == H5T_SGN_2) + p_type=H5Tcopy(H5T_STD_I64BE); + else if ( size == 1 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U8BE); + else if ( size == 2 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U16BE); + else if ( size == 4 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U32BE); + else if ( size == 8 && sign == H5T_SGN_NONE) + p_type=H5Tcopy(H5T_STD_U64BE); + } + break; + + case H5T_FLOAT: + if ( size == 4) + p_type=H5Tcopy(H5T_IEEE_F32BE); + else if ( size == 8) + p_type=H5Tcopy(H5T_IEEE_F64BE); + break; + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + + } + + + return(p_type); } diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 4d7b88e..a1fe7c6 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -79,57 +79,54 @@ static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t */ void parallel_print(const char* format, ...) { - int bytes_written; - va_list ap; - - va_start(ap, format); + int bytes_written; + va_list ap; - if(!g_Parallel) - vprintf(format, ap); - else - { + HDva_start(ap, format); - if(overflow_file == NULL) /*no overflow has occurred yet */ - { + if(!g_Parallel) + HDvprintf(format, ap); + else { + if(overflow_file == NULL) /*no overflow has occurred yet */ { #if 0 - printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset); + printf("calling HDvsnprintf: OUTBUFF_SIZE=%ld, outBuffOffset=%ld, ", (long)OUTBUFF_SIZE, (long)outBuffOffset); #endif - bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); + bytes_written = HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); #if 0 - printf("bytes_written=%ld\n", (long)bytes_written); + printf("bytes_written=%ld\n", (long)bytes_written); #endif - va_end(ap); - va_start(ap, format); + HDva_end(ap); + HDva_start(ap, format); #if 0 - printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset); + printf("Result: bytes_written=%ld, OUTBUFF_SIZE-outBuffOffset=%ld\n", (long)bytes_written, (long)OUTBUFF_SIZE-outBuffOffset); #endif - if ((bytes_written < 0) || + if ((bytes_written < 0) || #ifdef H5_VSNPRINTF_WORKS - (bytes_written >= (OUTBUFF_SIZE-outBuffOffset)) + (bytes_written >= (OUTBUFF_SIZE-outBuffOffset)) #else - ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset)) + ((bytes_written+1) == (OUTBUFF_SIZE-outBuffOffset)) #endif - ) - { - /* Terminate the outbuff at the end of the previous output */ - outBuff[outBuffOffset] = '\0'; - - overflow_file = HDtmpfile(); - if(overflow_file == NULL) - fprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n"); - else - bytes_written = HDvfprintf(overflow_file, format, ap); - } - else - outBuffOffset += bytes_written; - } - else - bytes_written = HDvfprintf(overflow_file, format, ap); - - } - va_end(ap); + ) + { + /* Terminate the outbuff at the end of the previous output */ + outBuff[outBuffOffset] = '\0'; + + overflow_file = HDtmpfile(); + if(overflow_file == NULL) + HDfprintf(stderr, "warning: could not create overflow file. Output may be truncated.\n"); + else + bytes_written = HDvfprintf(overflow_file, format, ap); + } + else + outBuffOffset += bytes_written; + } + else + bytes_written = HDvfprintf(overflow_file, format, ap); + + } + HDva_end(ap); } @@ -153,12 +150,12 @@ error_msg(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); + HDva_start(ap, fmt); HDfflush(stdout); HDfprintf(stderr, "%s error: ", h5tools_getprogname()); HDvfprintf(stderr, fmt, ap); - va_end(ap); + HDva_end(ap); } @@ -182,11 +179,11 @@ warn_msg(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); + HDva_start(ap, fmt); HDfflush(stdout); HDfprintf(stderr, "%s warning: ", h5tools_getprogname()); HDvfprintf(stderr, fmt, ap); - va_end(ap); + HDva_end(ap); } /*------------------------------------------------------------------------- @@ -239,7 +236,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti /* check for more flag-like tokens */ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; - } else if (HDstrcmp(argv[opt_ind], "--") == 0) { + } + else if (HDstrcmp(argv[opt_ind], "--") == 0) { opt_ind++; return EOF; } @@ -265,7 +263,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (opt_ind < (argc - 1)) if (argv[opt_ind + 1][0] != '-') opt_arg = argv[++opt_ind]; - } else if (l_opts[i].has_arg == require_arg) { + } + else if (l_opts[i].has_arg == require_arg) { if (opt_err) HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", @@ -273,7 +272,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_opt = '?'; } - } else { + } + else { if (arg[len] == '=') { if (opt_err) HDfprintf(stderr, @@ -282,10 +282,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_opt = '?'; } - opt_arg = NULL; } - break; } } @@ -300,13 +298,14 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; sp = 1; - } else { + } + else { register char *cp; /* pointer into current token */ /* short command line option */ opt_opt = argv[opt_ind][sp]; - if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { + if (opt_opt == ':' || (cp = HDstrchr(opts, opt_opt)) == 0) { if (opt_err) HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); @@ -316,7 +315,6 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; sp = 1; } - return '?'; } @@ -325,48 +323,41 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (argv[opt_ind][sp + 1] != '\0') { /* flag value is rest of current token */ opt_arg = &argv[opt_ind++][sp + 1]; - } else if (++opt_ind >= argc) { + } + else if (++opt_ind >= argc) { if (opt_err) HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); opt_opt = '?'; - } else { + } + else { /* flag value is next token */ opt_arg = argv[opt_ind++]; } sp = 1; } - /* wildcard argument */ - else if (*cp == '*') - { + else if (*cp == '*') { /* check the next argument */ opt_ind++; /* we do have an extra argument, check if not last */ - if ( argv[opt_ind][0] != '-' && (opt_ind+1) < argc ) - { + if ( argv[opt_ind][0] != '-' && (opt_ind+1) < argc ) { opt_arg = argv[opt_ind++]; } - else - { + else { opt_arg = NULL; } } - - else - { + else { /* set up to look at next char in token, next time */ if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ opt_ind++; sp = 1; - - } - opt_arg = NULL; } } @@ -395,7 +386,8 @@ indentation(int x) if (x < h5tools_nCols) { while (x-- > 0) printf(" "); - } else { + } + else { HDfprintf(stderr, "error: the indentation exceeds the number of cols.\n"); exit(1); } -- cgit v0.12