Remove underscore prefix from field names (pretty-print)
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 17 Sep 2011 03:31:44 +0000 (23:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 17 Sep 2011 03:31:44 +0000 (23:31 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf-text/types/array.c
formats/ctf-text/types/enum.c
formats/ctf-text/types/float.c
formats/ctf-text/types/integer.c
formats/ctf-text/types/sequence.c
formats/ctf-text/types/string.c
formats/ctf-text/types/struct.c
formats/ctf-text/types/variant.c
include/babeltrace/ctf-text/types.h

index 6dc84480c67e49eff8b0837ca81a040d13f9b4f7..3aaa633143ef48ee997d9239e26eb5e699353120 100644 (file)
@@ -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) {
index 12031c242fef048c6de3687636fd211790456405..b973d494b195dcd67d65931979b3d28dc06996a7 100644 (file)
@@ -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;
index 0c559b0eba4e8be23d1ca7d0c3511b3127bd513e..2b0dccecc9a3a3b68948a7e04c3c8d4eb654a2a5 100644 (file)
@@ -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;
index 46803f640c3376ed662883a1a4876ae5a052e3d5..f56a753bbb47177b0ab2811600f3669a2b935ce7 100644 (file)
@@ -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
index 6a0472f87c5d797b3276caf8b22e24714e838a1d..3fe5ff170c381e43f7276f9cf063a5588f50e604 100644 (file)
@@ -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) {
index 82bc361f2b96931cbe1f79be93a777f5b0940fd8..1ac38c46ff86da5e6f9b282fb73a08aba41104d2 100644 (file)
@@ -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;
index b1395351d9ff7498663992915399b33cd3dc48de..a10e4da1d9c6b0ee5735112c6cd118762c5374d0 100644 (file)
@@ -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, "{");
                }
index 871b8d58a8435af3badad90cface116bbae73a93..da069c8ac3e9395b9e7ad6b4b612c2447d602daf 100644 (file)
@@ -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++;
index 400e62c689d0ee3319cb706a73f64f54e15436a1..7d9b5bfb70b8a7da34ad88ff7c3b0566e9f1be44 100644 (file)
@@ -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 */
This page took 0.028166 seconds and 4 git commands to generate.