From: Mathieu Desnoyers Date: Sat, 17 Sep 2011 03:31:44 +0000 (-0400) Subject: Remove underscore prefix from field names (pretty-print) X-Git-Tag: v0.7~8 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=de913cfdf87242ec3ff54c72a318ebb8714e5465 Remove underscore prefix from field names (pretty-print) Signed-off-by: Mathieu Desnoyers --- diff --git a/formats/ctf-text/types/array.c b/formats/ctf-text/types/array.c index 6dc84480..3aaa6331 100644 --- a/formats/ctf-text/types/array.c +++ b/formats/ctf-text/types/array.c @@ -41,7 +41,7 @@ int ctf_text_array_write(struct stream_pos *ppos, struct definition *definition) fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); } if (elem->id == CTF_TYPE_INTEGER) { diff --git a/formats/ctf-text/types/enum.c b/formats/ctf-text/types/enum.c index 12031c24..b973d494 100644 --- a/formats/ctf-text/types/enum.c +++ b/formats/ctf-text/types/enum.c @@ -44,7 +44,7 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition) fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); field_nr_saved = pos->field_nr; pos->field_nr = 0; diff --git a/formats/ctf-text/types/float.c b/formats/ctf-text/types/float.c index 0c559b0e..2b0dccec 100644 --- a/formats/ctf-text/types/float.c +++ b/formats/ctf-text/types/float.c @@ -40,7 +40,7 @@ int ctf_text_float_write(struct stream_pos *ppos, struct definition *definition) fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); fprintf(pos->fp, "%Lg\n", float_definition->value); return 0; diff --git a/formats/ctf-text/types/integer.c b/formats/ctf-text/types/integer.c index 46803f64..f56a753b 100644 --- a/formats/ctf-text/types/integer.c +++ b/formats/ctf-text/types/integer.c @@ -43,7 +43,7 @@ int ctf_text_integer_write(struct stream_pos *ppos, struct definition *definitio fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); if (pos->string && (integer_declaration->encoding == CTF_STRING_ASCII diff --git a/formats/ctf-text/types/sequence.c b/formats/ctf-text/types/sequence.c index 6a0472f8..3fe5ff17 100644 --- a/formats/ctf-text/types/sequence.c +++ b/formats/ctf-text/types/sequence.c @@ -41,7 +41,7 @@ int ctf_text_sequence_write(struct stream_pos *ppos, struct definition *definiti fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); } if (elem->id == CTF_TYPE_INTEGER) { diff --git a/formats/ctf-text/types/string.c b/formats/ctf-text/types/string.c index 82bc361f..1ac38c46 100644 --- a/formats/ctf-text/types/string.c +++ b/formats/ctf-text/types/string.c @@ -43,7 +43,7 @@ int ctf_text_string_write(struct stream_pos *ppos, fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); fprintf(pos->fp, "\"%s\"", string_definition->value); return 0; diff --git a/formats/ctf-text/types/struct.c b/formats/ctf-text/types/struct.c index b1395351..a10e4da1 100644 --- a/formats/ctf-text/types/struct.c +++ b/formats/ctf-text/types/struct.c @@ -42,7 +42,7 @@ int ctf_text_struct_write(struct stream_pos *ppos, struct definition *definition fprintf(pos->fp, " "); if (pos->print_names && definition->name != 0) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); if (pos->print_names || len > 1) fprintf(pos->fp, "{"); } diff --git a/formats/ctf-text/types/variant.c b/formats/ctf-text/types/variant.c index 871b8d58..da069c8a 100644 --- a/formats/ctf-text/types/variant.c +++ b/formats/ctf-text/types/variant.c @@ -37,7 +37,7 @@ int ctf_text_variant_write(struct stream_pos *ppos, struct definition *definitio fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", - g_quark_to_string(definition->name)); + rem_(g_quark_to_string(definition->name))); fprintf(pos->fp, "{"); } pos->depth++; diff --git a/include/babeltrace/ctf-text/types.h b/include/babeltrace/ctf-text/types.h index 400e62c6..7d9b5bfb 100644 --- a/include/babeltrace/ctf-text/types.h +++ b/include/babeltrace/ctf-text/types.h @@ -74,4 +74,13 @@ void print_pos_tabs(struct ctf_text_stream_pos *pos) */ int print_field(struct definition *definition); +static inline +const char *rem_(const char *str) +{ + if (str[0] == '_') + return &str[1]; + else + return str; +} + #endif /* _BABELTRACE_CTF_TEXT_TYPES_H */