summaryrefslogtreecommitdiffstats
path: root/tools/h5tools.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>2000-10-31 16:18:45 (GMT)
committerRobb Matzke <matzke@llnl.gov>2000-10-31 16:18:45 (GMT)
commit3c2dfa4bab65093fb689b80afd285a0f2f011eaf (patch)
treeaf9d5e80a266d11c45ffc77a634b7fc11eefd6bb /tools/h5tools.c
parente787e3659ca19fe699b62a07a13cd92e46911081 (diff)
downloadhdf5-3c2dfa4bab65093fb689b80afd285a0f2f011eaf.zip
hdf5-3c2dfa4bab65093fb689b80afd285a0f2f011eaf.tar.gz
hdf5-3c2dfa4bab65093fb689b80afd285a0f2f011eaf.tar.bz2
[svn-r2767] ./hdf5/tools/h5tools.c
* 2000-10-31 Robb Matzke <matzke@llnl.gov> (h5dump_sprint) The whitespace added for indentation after the line-feed kludge is performed only if a line-feed was actually inserted. This fixes funny-looking h5ls output that had ` %s' sequences appearing in nested compound datatypes. Also added a prominent warning in the code to indicate that when a line-feed is inserted into the string that column number calculations will be incorrect and object indices will be missing.
Diffstat (limited to 'tools/h5tools.c')
-rw-r--r--tools/h5tools.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c
index 2713044..15229d6 100644
--- a/tools/h5tools.c
+++ b/tools/h5tools.c
@@ -863,13 +863,20 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info,
OPT(info->cmpd_sep,
", " OPTIONAL_LINE_BREAK));
- /*put code to indent compound type elemnts here*/
- if (ctx->indent_level >= 0) {
- h5dump_str_append(str, "%s", OPT(info->line_pre, ""));
- }
- for (x=0; x < ctx->indent_level + 1; x++){
- h5dump_str_append(str,"%s",OPT(info->line_indent,""));
- }
+ /* RPM 2000-10-31
+ * If the previous character is a line-feed (which is true when
+ * h5dump is running) then insert some white space for
+ * indentation. Be warned that column number calculations will be
+ * incorrect and that object indices at the beginning of the line
+ * will be missing (h5dump doesn't display them anyway). */
+ if (ctx->indent_level >= 0 &&
+ str->len && '\n'==str->s[str->len-1]) {
+ h5dump_str_append(str, OPT(info->line_pre, ""), "");
+ for (x=0; x<ctx->indent_level+1; x++) {
+ h5dump_str_append(str, "%s", OPT(info->line_indent, ""));
+ }
+ }
+
/* The name */
name = H5Tget_member_name(type, j);
h5dump_str_append(str, OPT(info->cmpd_name, ""), name);
@@ -916,17 +923,22 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info,
}
+ /* RPM 2000-10-31
+ * If the previous character is a line feed (which is true when
+ * h5dump is running) then insert some white space for indentation.
+ * Be warned that column number calculations will be incorrect and
+ * that object indices at the beginning of the line will be missing
+ * (h5dump doesn't display them anyway). */
h5dump_str_append(str, "%s", OPT(info->cmpd_end, ""));
-
- /*put code to indent compound type elemnts here*/
- if (ctx->indent_level >= 0) {
- h5dump_str_append(str, "%s", OPT(info->line_pre, ""));
- }
- for (x=0; x < ctx->indent_level; x++){
- h5dump_str_append(str,"%s",OPT(info->line_indent,""));
- }
-
- h5dump_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+ if (ctx->indent_level >= 0 &&
+ str->len && '\n'==str->s[str->len-1]) {
+ h5dump_str_append(str, OPT(info->line_pre, ""), "");
+ for (x=0; x<ctx->indent_level; x++) {
+ h5dump_str_append(str, "%s", OPT(info->line_indent, ""));
+ }
+ }
+ h5dump_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
+
} else if (H5T_ENUM==H5Tget_class(type)) {
char enum_name[1024];
if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name)>=0) {